test.js 2.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812
  1. var test = function(exports, mxdraw, mxcad2, vue, axios2) {
  2. var __vite_style__ = document.createElement("style");
  3. __vite_style__.textContent = ".heading[data-v-9bd7093d] {\n font-size: 1.5em;\n margin-bottom: 12px;\n}\n.card[data-v-9bd7093d] {\n background: #fff;\n color: #000;\n background-image: linear-gradient(48deg, #fff 0%, #e5efe9 100%);\n border-top-right-radius: 16px;\n border-bottom-left-radius: 16px;\n box-shadow: -20px 20px 35px 1px rgba(10, 49, 86, 0.18);\n display: flex;\n flex-direction: column;\n padding: 32px;\n margin: 40px;\n max-width: 400px;\n width: 100%;\n}\n.content-wrapper[data-v-9bd7093d] {\n font-size: 1.1em;\n margin-bottom: 44px;\n}\n.content-wrapper[data-v-9bd7093d]:last-child {\n margin-bottom: 0;\n}\n.button[data-v-9bd7093d] {\n align-items: center;\n background: #e5efe9;\n border: 1px solid #5a72b5;\n border-radius: 4px;\n color: #121943;\n cursor: pointer;\n display: flex;\n font-size: 1em;\n font-weight: 700;\n height: 40px;\n justify-content: center;\n width: 180px;\n}\n.button[data-v-9bd7093d]:focus {\n border: 2px solid transparent;\n box-shadow: 0px 0px 0px 2px #121943;\n outline: solid 4px transparent;\n}\n.link[data-v-9bd7093d] {\n color: #121943;\n}\n.link[data-v-9bd7093d]:focus {\n box-shadow: 0px 0px 0px 2px #121943;\n}\n.input-wrapper[data-v-9bd7093d] {\n display: flex;\n flex-direction: column;\n}\n.input-wrapper .label[data-v-9bd7093d] {\n align-items: baseline;\n display: flex;\n font-weight: 700;\n justify-content: space-between;\n margin-bottom: 8px;\n}\n.input-wrapper .optional[data-v-9bd7093d] {\n color: #5a72b5;\n font-size: 0.9em;\n}\n.input-wrapper .input[data-v-9bd7093d] {\n border: 1px solid #5a72b5;\n border-radius: 4px;\n height: 40px;\n padding: 8px;\n}\ncode[data-v-9bd7093d] {\n background: #e5efe9;\n border: 1px solid #5a72b5;\n border-radius: 4px;\n padding: 2px 4px;\n}\n.modal-header[data-v-9bd7093d] {\n align-items: baseline;\n display: flex;\n justify-content: space-between;\n}\n.close[data-v-9bd7093d] {\n background: none;\n border: none;\n cursor: pointer;\n display: flex;\n height: 16px;\n text-decoration: none;\n width: 16px;\n}\n.close svg[data-v-9bd7093d] {\n width: 16px;\n}\n.modal-wrapper[data-v-9bd7093d] {\n align-items: center;\n background: rgba(0, 0, 0, 0.7);\n bottom: 0;\n display: flex;\n justify-content: center;\n left: 0;\n position: fixed;\n right: 0;\n top: 0;\n}\n#modal[data-v-9bd7093d] {\n transition: opacity 0.25s ease-in-out;\n}\n#modal .modal-body[data-v-9bd7093d] {\n max-width: 830px;\n opacity: 1;\n transform: translateY(-100px);\n transition: opacity 0.25s ease-in-out;\n width: 100%;\n z-index: 1;\n}\n.outside-trigger[data-v-9bd7093d] {\n bottom: 0;\n cursor: default;\n left: 0;\n position: fixed;\n right: 0;\n top: 0;\n}\n.button__link[data-v-9bd7093d] {\n text-decoration: none;\n}\n.button[data-v-9bd7093d] {\n background-color: #4caf50;\n /* Green */\n border: none;\n color: white;\n text-align: center;\n text-decoration: none;\n display: inline-block;\n font-size: 16px;\n margin: 4px 2px;\n -webkit-transition-duration: 0.4s;\n /* Safari */\n transition-duration: 0.4s;\n cursor: pointer;\n}\n.button1[data-v-9bd7093d] {\n background-color: white;\n color: black;\n border: 2px solid #4caf50;\n}\n.button1[data-v-9bd7093d]:hover {\n background-color: #4caf50;\n color: white;\n}\n.button2[data-v-9bd7093d] {\n background-color: white;\n color: black;\n border: 2px solid #008cba;\n}\n.button2[data-v-9bd7093d]:hover {\n background-color: #008cba;\n color: white;\n}\n.btn_box[data-v-9bd7093d] {\n width: 100%;\n display: flex;\n justify-items: center;\n justify-content: start;\n align-items: start;\n}";
  4. document.head.appendChild(__vite_style__);
  5. "use strict";var __pow = Math.pow;
  6. var __async = (__this, __arguments, generator) => {
  7. return new Promise((resolve, reject) => {
  8. var fulfilled = (value) => {
  9. try {
  10. step(generator.next(value));
  11. } catch (e) {
  12. reject(e);
  13. }
  14. };
  15. var rejected = (value) => {
  16. try {
  17. step(generator.throw(value));
  18. } catch (e) {
  19. reject(e);
  20. }
  21. };
  22. var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
  23. step((generator = generator.apply(__this, __arguments)).next());
  24. });
  25. };
  26. const isModalVisible = vue.ref(false);
  27. const showModal$1 = (options) => {
  28. isModalVisible.value = true;
  29. modalOptions.value = Object.assign(modalOptions.value, options || {});
  30. };
  31. const hideModal$1 = () => {
  32. isModalVisible.value = false;
  33. };
  34. const modalOpts = {
  35. title: "Modal",
  36. text: "",
  37. oncancel: hideModal$1,
  38. onsubmit: hideModal$1,
  39. ongetallentity: hideModal$1,
  40. ondrawline: hideModal$1,
  41. docommand: (cmd) => {
  42. }
  43. };
  44. const modalOptions = vue.ref(modalOpts);
  45. const useModalVisible = () => {
  46. return {
  47. isModalVisible,
  48. showModal: showModal$1,
  49. hideModal: hideModal$1,
  50. modalOptions
  51. };
  52. };
  53. const _withScopeId = (n) => (vue.pushScopeId("data-v-9bd7093d"), n = n(), vue.popScopeId(), n);
  54. const _hoisted_1 = {
  55. key: 0,
  56. class: "modal-wrapper",
  57. id: "modal"
  58. };
  59. const _hoisted_2 = { class: "modal-body card" };
  60. const _hoisted_3 = { class: "modal-header" };
  61. const _hoisted_4 = { class: "heading" };
  62. const _hoisted_5 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ vue.createElementVNode("svg", { viewBox: "0 0 24 24" }, [
  63. /* @__PURE__ */ vue.createElementVNode("path", { d: "M24 20.188l-8.315-8.209 8.2-8.282-3.697-3.697-8.212 8.318-8.31-8.203-3.666 3.666 8.321 8.24-8.206 8.313 3.666 3.666 8.237-8.318 8.285 8.203z" })
  64. ], -1));
  65. const _hoisted_6 = [
  66. _hoisted_5
  67. ];
  68. const _hoisted_7 = { style: { "overflow-y": "auto", "height": "500px" } };
  69. const _hoisted_8 = { class: "btn_box" };
  70. const _hoisted_9 = { class: "btn_box" };
  71. const _hoisted_10 = { class: "btn_box" };
  72. const _hoisted_11 = { class: "btn_box" };
  73. const _hoisted_12 = { class: "btn_box" };
  74. const _hoisted_13 = { class: "btn_box" };
  75. const _hoisted_14 = { class: "btn_box" };
  76. const _hoisted_15 = { class: "btn_box" };
  77. const _hoisted_16 = { class: "btn_box" };
  78. const _hoisted_17 = { class: "btn_box" };
  79. const _hoisted_18 = { class: "btn_box" };
  80. const _hoisted_19 = { class: "btn_box" };
  81. const _hoisted_20 = { class: "btn_box" };
  82. const _hoisted_21 = { class: "btn_box" };
  83. const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
  84. __name: "Modal",
  85. setup(__props) {
  86. const { isModalVisible: isModalVisible2, hideModal: hideModal2, modalOptions: modalOptions2 } = useModalVisible();
  87. hideModal2();
  88. return (_ctx, _cache) => {
  89. return vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
  90. vue.createTextVNode(" 2356788909-80976564578697809-090897867 "),
  91. vue.unref(isModalVisible2) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
  92. vue.createElementVNode("div", _hoisted_2, [
  93. vue.createElementVNode("div", _hoisted_3, [
  94. vue.createElementVNode("h2", _hoisted_4, vue.toDisplayString(vue.unref(modalOptions2).title), 1),
  95. vue.createElementVNode("a", {
  96. href: "#!",
  97. onClick: _cache[0] || (_cache[0] = //@ts-ignore
  98. (...args) => vue.unref(hideModal2) && vue.unref(hideModal2)(...args)),
  99. role: "button",
  100. class: "close",
  101. "aria-label": "close this modal"
  102. }, _hoisted_6)
  103. ]),
  104. vue.createElementVNode("div", _hoisted_7, [
  105. vue.createElementVNode("div", _hoisted_8, [
  106. vue.createElementVNode("button", {
  107. class: "button button2",
  108. onClick: _cache[1] || (_cache[1] = ($event) => vue.unref(modalOptions2).docommand("Mx_Open_DemoCode"))
  109. }, " 下载开Demo代码 "),
  110. vue.createElementVNode("button", {
  111. class: "button button2",
  112. onClick: _cache[2] || (_cache[2] = ($event) => vue.unref(modalOptions2).docommand("Mx_Open_DevInstall"))
  113. }, " 下载开发包 "),
  114. vue.createElementVNode("button", {
  115. class: "button button2",
  116. onClick: _cache[3] || (_cache[3] = //@ts-ignore
  117. (...args) => vue.unref(modalOptions2).ondrawline && vue.unref(modalOptions2).ondrawline(...args))
  118. }, " 调用画圆线命令 "),
  119. vue.createElementVNode("button", {
  120. class: "button button2",
  121. onClick: _cache[4] || (_cache[4] = ($event) => vue.unref(modalOptions2).docommand("MxTest_DrawLine"))
  122. }, " 交互画直线 ")
  123. ]),
  124. vue.createElementVNode("div", _hoisted_9, [
  125. vue.createElementVNode("button", {
  126. class: "button button2",
  127. onClick: _cache[5] || (_cache[5] = ($event) => vue.unref(modalOptions2).docommand("MxTest_AddLayer"))
  128. }, " 添加图层 "),
  129. vue.createElementVNode("button", {
  130. class: "button button2",
  131. onClick: _cache[6] || (_cache[6] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetAllLayer"))
  132. }, " 得到所有图层 "),
  133. vue.createElementVNode("button", {
  134. class: "button button2",
  135. onClick: _cache[7] || (_cache[7] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetAllTextStyle"))
  136. }, " 得到所有文字样式 "),
  137. vue.createElementVNode("button", {
  138. class: "button button2",
  139. onClick: _cache[8] || (_cache[8] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetAllBlock"))
  140. }, " 得到所有图块 ")
  141. ]),
  142. vue.createElementVNode("div", _hoisted_10, [
  143. vue.createElementVNode("button", {
  144. class: "button button2",
  145. onClick: _cache[9] || (_cache[9] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetAllLinetype"))
  146. }, " 得到所有线型 "),
  147. vue.createElementVNode("button", {
  148. class: "button button2",
  149. onClick: _cache[10] || (_cache[10] = ($event) => vue.unref(modalOptions2).docommand("MxTest_WritexData"))
  150. }, " 写扩展数据 "),
  151. vue.createElementVNode("button", {
  152. class: "button button2",
  153. onClick: _cache[11] || (_cache[11] = ($event) => vue.unref(modalOptions2).docommand("MxTest_ReadxData"))
  154. }, " 读扩展数据 "),
  155. vue.createElementVNode("button", {
  156. class: "button button2",
  157. onClick: _cache[12] || (_cache[12] = ($event) => vue.unref(modalOptions2).docommand("MxTest_InsertBlock"))
  158. }, " 测试插入一个图块 ")
  159. ]),
  160. vue.createElementVNode("div", _hoisted_11, [
  161. vue.createElementVNode("button", {
  162. class: "button button2",
  163. onClick: _cache[13] || (_cache[13] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawLine"))
  164. }, " 绘直线 "),
  165. vue.createElementVNode("button", {
  166. class: "button button2",
  167. onClick: _cache[14] || (_cache[14] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawArc"))
  168. }, " 绘圆弧 "),
  169. vue.createElementVNode("button", {
  170. class: "button button2",
  171. onClick: _cache[15] || (_cache[15] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawCircle"))
  172. }, " 绘圆 "),
  173. vue.createElementVNode("button", {
  174. class: "button button2",
  175. onClick: _cache[16] || (_cache[16] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawPolyline"))
  176. }, " 绘PL线 ")
  177. ]),
  178. vue.createElementVNode("div", _hoisted_12, [
  179. vue.createElementVNode("button", {
  180. class: "button button2",
  181. onClick: _cache[17] || (_cache[17] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawHatch"))
  182. }, " 绘填充 "),
  183. vue.createElementVNode("button", {
  184. class: "button button2",
  185. onClick: _cache[18] || (_cache[18] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawText"))
  186. }, " 绘文字 "),
  187. vue.createElementVNode("button", {
  188. class: "button button2",
  189. onClick: _cache[19] || (_cache[19] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_Ellipse"))
  190. }, " 绘椭圆 "),
  191. vue.createElementVNode("button", {
  192. class: "button button2",
  193. onClick: _cache[20] || (_cache[20] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_EllipseArc"))
  194. }, " 绘椭圆弧 ")
  195. ]),
  196. vue.createElementVNode("div", _hoisted_13, [
  197. vue.createElementVNode("button", {
  198. class: "button button2",
  199. onClick: _cache[21] || (_cache[21] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_MText"))
  200. }, " 绘制多行文字 "),
  201. vue.createElementVNode("button", {
  202. class: "button button2",
  203. onClick: _cache[22] || (_cache[22] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawTable"))
  204. }, " 绘制表格 "),
  205. vue.createElementVNode("button", {
  206. class: "button button2",
  207. onClick: _cache[23] || (_cache[23] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_QRCode"))
  208. }, " 绘制二维码 "),
  209. vue.createElementVNode("button", {
  210. class: "button button2",
  211. onClick: _cache[24] || (_cache[24] = ($event) => vue.unref(modalOptions2).docommand("MxTest_InsertStamp"))
  212. }, " 插入图章 ")
  213. ]),
  214. vue.createElementVNode("div", _hoisted_14, [
  215. vue.createElementVNode("button", {
  216. class: "button button2",
  217. onClick: _cache[25] || (_cache[25] = //@ts-ignore
  218. (...args) => vue.unref(modalOptions2).ongetallentity && vue.unref(modalOptions2).ongetallentity(...args))
  219. }, " 得到所有对象 "),
  220. vue.createElementVNode("button", {
  221. class: "button button2",
  222. onClick: _cache[26] || (_cache[26] = ($event) => vue.unref(modalOptions2).docommand("MxTest_SelectEntity"))
  223. }, " 交互选择对象 "),
  224. vue.createElementVNode("button", {
  225. class: "button button2",
  226. onClick: _cache[27] || (_cache[27] = ($event) => vue.unref(modalOptions2).docommand("Mx_Export_MxWeb"))
  227. }, " 保存mxweb到服务器 "),
  228. vue.createElementVNode("button", {
  229. class: "button button2",
  230. onClick: _cache[28] || (_cache[28] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetSysVars"))
  231. }, " 得到系统变量 ")
  232. ]),
  233. vue.createElementVNode("div", _hoisted_15, [
  234. vue.createElementVNode("button", {
  235. class: "button button2",
  236. onClick: _cache[29] || (_cache[29] = ($event) => vue.unref(modalOptions2).docommand("MxTest_NewFile"))
  237. }, " 新建图纸 "),
  238. vue.createElementVNode("button", {
  239. class: "button button2",
  240. onClick: _cache[30] || (_cache[30] = ($event) => vue.unref(modalOptions2).docommand("Mx_ViewBackgroundColor"))
  241. }, " 白色背景色 "),
  242. vue.createElementVNode("button", {
  243. class: "button button2",
  244. onClick: _cache[31] || (_cache[31] = ($event) => vue.unref(modalOptions2).docommand("MxTest_FindText"))
  245. }, " 文字查找定位 "),
  246. vue.createElementVNode("button", {
  247. class: "button button2",
  248. onClick: _cache[32] || (_cache[32] = ($event) => vue.unref(modalOptions2).docommand("MxTest_SelectEntitysToBlock"))
  249. }, " 选择实体做块 ")
  250. ]),
  251. vue.createElementVNode("div", _hoisted_16, [
  252. vue.createElementVNode("button", {
  253. class: "button button2",
  254. onClick: _cache[33] || (_cache[33] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_Text"))
  255. }, " 绘制单行文字 "),
  256. vue.createElementVNode("button", {
  257. class: "button button2",
  258. onClick: _cache[34] || (_cache[34] = ($event) => vue.unref(modalOptions2).docommand("MxTest_DrawHatchFormPoint"))
  259. }, " 选点填充 "),
  260. vue.createElementVNode("button", {
  261. class: "button button2",
  262. onClick: _cache[35] || (_cache[35] = ($event) => vue.unref(modalOptions2).docommand("Mx_TestExProp"))
  263. }, " 设置扩展属性 "),
  264. vue.createElementVNode("button", {
  265. class: "button button2",
  266. onClick: _cache[36] || (_cache[36] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DimAligned"))
  267. }, " 绘制对齐标注 ")
  268. ]),
  269. vue.createElementVNode("div", _hoisted_17, [
  270. vue.createElementVNode("button", {
  271. class: "button button2",
  272. onClick: _cache[37] || (_cache[37] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawDimRotated"))
  273. }, " 绘性线标注 "),
  274. vue.createElementVNode("button", {
  275. class: "button button2",
  276. onClick: _cache[38] || (_cache[38] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawDimAngular"))
  277. }, " 角度标注 "),
  278. vue.createElementVNode("button", {
  279. class: "button button2",
  280. onClick: _cache[39] || (_cache[39] = ($event) => vue.unref(modalOptions2).docommand("MxTest_LineTypeTest"))
  281. }, " 修改对象线型 "),
  282. vue.createElementVNode("button", {
  283. class: "button button2",
  284. onClick: _cache[40] || (_cache[40] = ($event) => vue.unref(modalOptions2).docommand("Mx_SelectEntitHideLayer"))
  285. }, " 选择隐藏对象层 ")
  286. ]),
  287. vue.createElementVNode("div", _hoisted_18, [
  288. vue.createElementVNode("button", {
  289. class: "button button2",
  290. onClick: _cache[41] || (_cache[41] = ($event) => vue.unref(modalOptions2).docommand("MxTest_TestAddCurrentSelect"))
  291. }, " 添加到当前选择 "),
  292. vue.createElementVNode("button", {
  293. class: "button button2",
  294. onClick: _cache[42] || (_cache[42] = ($event) => vue.unref(modalOptions2).docommand("MxTest_TestSetViewAngle"))
  295. }, " 视区旋转 "),
  296. vue.createElementVNode("button", {
  297. class: "button button2",
  298. onClick: _cache[43] || (_cache[43] = ($event) => vue.unref(modalOptions2).docommand("MxTest_WriteXRecord"))
  299. }, " 写扩展记录 "),
  300. vue.createElementVNode("button", {
  301. class: "button button2",
  302. onClick: _cache[44] || (_cache[44] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetNamedObjectsDictionary"))
  303. }, " 得到命名字典 ")
  304. ]),
  305. vue.createElementVNode("div", _hoisted_19, [
  306. vue.createElementVNode("button", {
  307. class: "button button2",
  308. onClick: _cache[45] || (_cache[45] = ($event) => vue.unref(modalOptions2).docommand("MxTest_AddTextStyleTable"))
  309. }, " 添加文字样式 "),
  310. vue.createElementVNode("button", {
  311. class: "button button2",
  312. onClick: _cache[46] || (_cache[46] = ($event) => vue.unref(modalOptions2).docommand("MxTest_DrawCustomEntity"))
  313. }, " 绘自定义实体 "),
  314. vue.createElementVNode("button", {
  315. class: "button button2",
  316. onClick: _cache[47] || (_cache[47] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_ChangeColor"))
  317. }, " 修改对象颜色 "),
  318. vue.createElementVNode("button", {
  319. class: "button button2",
  320. onClick: _cache[48] || (_cache[48] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_ChangeVisible"))
  321. }, " 修改对象不可见 ")
  322. ]),
  323. vue.createElementVNode("div", _hoisted_20, [
  324. vue.createElementVNode("button", {
  325. class: "button button2",
  326. onClick: _cache[49] || (_cache[49] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_ChangeEntityLayer"))
  327. }, " 修改对象层 "),
  328. vue.createElementVNode("button", {
  329. class: "button button2",
  330. onClick: _cache[50] || (_cache[50] = ($event) => vue.unref(modalOptions2).docommand("Mx_ChaneEntityDrawOrder"))
  331. }, " 修改对象显示顺序 "),
  332. vue.createElementVNode("button", {
  333. class: "button button2",
  334. onClick: _cache[51] || (_cache[51] = ($event) => vue.unref(modalOptions2).docommand("Mx_Export_Pdf"))
  335. }, " 指定范围输出pdf "),
  336. vue.createElementVNode("button", {
  337. class: "button button2",
  338. onClick: _cache[52] || (_cache[52] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawImage"))
  339. }, " 绘制image ")
  340. ]),
  341. vue.createElementVNode("div", _hoisted_21, [
  342. vue.createElementVNode("button", {
  343. class: "button button2",
  344. onClick: _cache[53] || (_cache[53] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetObjectExDictionaryData"))
  345. }, " 读取对象扩展字典 ")
  346. ])
  347. ])
  348. ])
  349. ])) : vue.createCommentVNode("", true)
  350. ]);
  351. };
  352. }
  353. });
  354. const Modal_vue_vue_type_style_index_0_scoped_9bd7093d_lang = "";
  355. const _export_sfc = (sfc, props) => {
  356. const target = sfc.__vccOpts || sfc;
  357. for (const [key, val] of props) {
  358. target[key] = val;
  359. }
  360. return target;
  361. };
  362. const Modal = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-9bd7093d"]]);
  363. const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  364. __name: "Test",
  365. setup(__props) {
  366. return (_ctx, _cache) => {
  367. return vue.openBlock(), vue.createElementBlock("div", null, [
  368. vue.createVNode(Modal)
  369. ]);
  370. };
  371. }
  372. });
  373. const MxIFrame = {
  374. init() {
  375. mxdraw.MxFun.setPostMessageToParentFrameFunction(function(param) {
  376. top.postMessage(param, "*");
  377. });
  378. window.addEventListener("message", function(event) {
  379. if (event.data.type === "sendStringToExecute") {
  380. mxdraw.MxFun.sendStringToExecute(event.data.cmd, event.data);
  381. } else {
  382. console.log("mx:unprocessed message:");
  383. console.log(event.data);
  384. }
  385. }, false);
  386. }
  387. };
  388. function init$p() {
  389. MxIFrame.init();
  390. }
  391. function BR_Comment() {
  392. return __async(this, null, function* () {
  393. const getPoint = new mxdraw.MrxDbgUiPrPoint();
  394. getPoint.setMessage("\n指定第一点:");
  395. getPoint.go((status) => {
  396. if (status != 0) {
  397. return;
  398. }
  399. const pt1 = getPoint.value();
  400. let leadComment = new mxdraw.MxDbLeadComment();
  401. leadComment.point1 = pt1.clone();
  402. leadComment.textHeight = mxdraw.MxFun.screenCoordLong2Doc(50);
  403. leadComment.text = "测试Test1";
  404. leadComment.textWidth = mxdraw.MxFun.screenCoordLong2Doc(300);
  405. leadComment.fixedSize = true;
  406. if (leadComment.fixedSize) {
  407. leadComment.textHeight = 50;
  408. leadComment.textWidth = 250;
  409. }
  410. leadComment.color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
  411. const worldDrawComment = new mxdraw.McEdGetPointWorldDrawObject();
  412. worldDrawComment.setDraw(
  413. (currentPoint, pWorldDraw) => {
  414. leadComment.point2 = currentPoint;
  415. pWorldDraw.drawCustomEntity(leadComment);
  416. }
  417. );
  418. getPoint.setBasePt(pt1);
  419. getPoint.setUseBasePt(true);
  420. getPoint.setUserDraw(worldDrawComment);
  421. getPoint.setMessage("\n指定第二点:");
  422. getPoint.go((status2) => {
  423. if (status2 != 0) {
  424. console.log(status2);
  425. return;
  426. }
  427. const currentPoint = getPoint.value();
  428. leadComment.point2 = currentPoint;
  429. mxdraw.MxFun.addToCurrentSpace(leadComment);
  430. });
  431. });
  432. });
  433. }
  434. function BR_Print() {
  435. mxdraw.MxFun.getCurrentDraw().createCanvasImageData(
  436. (imageData) => {
  437. const newWindow = window.open();
  438. if (newWindow != null) {
  439. newWindow.document.write('<img src="' + imageData + '"/>');
  440. setTimeout(() => {
  441. newWindow.print();
  442. }, 300);
  443. }
  444. },
  445. {
  446. width: 349,
  447. height: 536
  448. }
  449. );
  450. }
  451. function BR_CheckDraw() {
  452. return __async(this, null, function* () {
  453. let color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
  454. const point = new mxdraw.MrxDbgUiPrPoint();
  455. const mxDraw = mxdraw.MxFun.getCurrentDraw();
  456. const worldDrawComment = new mxdraw.McEdGetPointWorldDrawObject();
  457. const mxCheckDraw = new mxdraw.MxDbRectBoxLeadComment();
  458. mxCheckDraw.color = color.getHex();
  459. if (mxCheckDraw.color == 0)
  460. mxCheckDraw.color = 65793;
  461. mxCheckDraw.radius = mxdraw.MxFun.screenCoordLong2Doc(8);
  462. mxCheckDraw.setLineWidth(3);
  463. mxCheckDraw.setLineWidthByPixels(true);
  464. point.setMessage("\n云线框起始点:");
  465. point.go((status) => {
  466. if (status != mxdraw.MrxDbgUiPrBaseReturn.kOk) {
  467. return;
  468. }
  469. mxCheckDraw.point1 = point.value();
  470. worldDrawComment.setDraw((currentPoint) => {
  471. mxCheckDraw.point2 = currentPoint;
  472. worldDrawComment.drawCustomEntity(mxCheckDraw);
  473. });
  474. point.setUserDraw(worldDrawComment);
  475. point.setMessage("\n云线框结束点:");
  476. point.go((status2) => {
  477. if (status2 != mxdraw.MrxDbgUiPrBaseReturn.kOk) {
  478. return;
  479. }
  480. mxCheckDraw.point2 = point.value();
  481. worldDrawComment.setDraw((currentPoint) => {
  482. mxCheckDraw.point3 = currentPoint;
  483. worldDrawComment.drawCustomEntity(mxCheckDraw);
  484. });
  485. mxCheckDraw.text = "审图批注XXXXXXXXXX";
  486. mxCheckDraw.textWidth = mxdraw.MxFun.screenCoordLong2Doc(200);
  487. mxCheckDraw.textHeight = mxdraw.MxFun.screenCoordLong2Doc(50);
  488. mxCheckDraw.fixedSize = true;
  489. if (mxCheckDraw.fixedSize) {
  490. mxCheckDraw.textHeight = 20;
  491. mxCheckDraw.textWidth = 230;
  492. }
  493. point.setMessage("\n审图标注点:");
  494. point.go((status3) => {
  495. if (status3 != mxdraw.MrxDbgUiPrBaseReturn.kOk) {
  496. return;
  497. }
  498. mxCheckDraw.point3 = point.value();
  499. mxDraw.addMxEntity(mxCheckDraw);
  500. });
  501. });
  502. });
  503. });
  504. }
  505. function getScreenPixel(pixel, isFontSize) {
  506. let _pixel = mxdraw.MxFun.screenCoordLong2World(isFontSize ? pixel : pixel - pixel / 3);
  507. _pixel = mxdraw.MxFun.worldCoordLong2Doc(_pixel);
  508. return _pixel;
  509. }
  510. function BR_Arrow() {
  511. const worldDraw = new mxdraw.McEdGetPointWorldDrawObject();
  512. const lines = new mxdraw.MxDbArrow();
  513. const mxDraw = mxdraw.MxFun.getCurrentDraw();
  514. const point = new mxdraw.MrxDbgUiPrPoint();
  515. point.setUserDraw(worldDraw);
  516. lines.setLineWidth(10);
  517. lines.innerOffset = getScreenPixel(10);
  518. lines.outerOffset = getScreenPixel(22);
  519. lines.topOffset = getScreenPixel(36);
  520. lines.color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
  521. point.go(() => {
  522. lines.startPoint = point.value();
  523. worldDraw.setDraw((v) => {
  524. lines.endPoint = v;
  525. worldDraw.drawCustomEntity(lines);
  526. });
  527. point.go((status) => __async(this, null, function* () {
  528. lines.endPoint = point.value();
  529. mxDraw.addMxEntity(lines);
  530. }));
  531. });
  532. }
  533. function BR_CloudLine() {
  534. const point = new mxdraw.MrxDbgUiPrPoint();
  535. const mxDraw = mxdraw.MxFun.getCurrentDraw();
  536. const worldDrawComment = new mxdraw.McEdGetPointWorldDrawObject();
  537. const radius = mxdraw.MxFun.screenCoordLong2Doc(16);
  538. point.setMessage("\n点击开启绘制云线:");
  539. point.go(() => {
  540. let pt = point.value();
  541. const mxCloudLine = new mxdraw.MxDbCloudLine();
  542. mxCloudLine.setRadius(radius);
  543. mxCloudLine.addPoint(pt);
  544. mxCloudLine.color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
  545. worldDrawComment.setDraw((currentPoint) => {
  546. if (pt.distanceTo(currentPoint) > radius) {
  547. pt = currentPoint.clone();
  548. mxCloudLine.addPoint(currentPoint, true);
  549. }
  550. worldDrawComment.drawCustomEntity(mxCloudLine);
  551. });
  552. point.setUserDraw(worldDrawComment);
  553. point.setMessage("\n再次点击结束绘制云线:");
  554. point.go(() => {
  555. mxDraw.addMxEntity(mxCloudLine);
  556. });
  557. });
  558. }
  559. let sSaveData = "";
  560. function BR_SaveAllMxEntity() {
  561. let mxobj = mxdraw.MxFun.getCurrentDraw();
  562. sSaveData = mxobj.saveMxEntityToJson();
  563. console.log(sSaveData);
  564. }
  565. function BR_LoadAllMxEntity() {
  566. return __async(this, null, function* () {
  567. if (sSaveData.length == 0)
  568. return;
  569. let mxobj = mxdraw.MxFun.getCurrentDraw();
  570. yield mxobj.loadMxEntityFromJson(sSaveData, ["models/svg/mark.svg"]);
  571. mxobj.updateDisplay();
  572. });
  573. }
  574. function BR_Area() {
  575. const getPoint = new mxdraw.MrxDbgUiPrPoint();
  576. getPoint.setMessage("\n指定第一点:");
  577. getPoint.go((status) => {
  578. if (status != 0) {
  579. return;
  580. }
  581. const pt1 = getPoint.value();
  582. let area2 = new mxdraw.MxDbArea();
  583. area2.addPoint(pt1);
  584. area2.color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
  585. const worldDrawComment = new mxdraw.McEdGetPointWorldDrawObject();
  586. worldDrawComment.setDraw((currentPoint, pWorldDraw) => {
  587. let tmp2 = area2.clone();
  588. tmp2.addPoint(currentPoint);
  589. worldDrawComment.drawCustomEntity(tmp2);
  590. });
  591. getPoint.setUserDraw(worldDrawComment);
  592. getPoint.setMessage("\n指定下一点:");
  593. getPoint.goWhile(
  594. (status2) => {
  595. if (status2 == 0) {
  596. const pt2 = getPoint.value();
  597. area2.addPoint(pt2);
  598. }
  599. },
  600. (status2) => {
  601. area2.isFill = true;
  602. area2.fillOpacity = 0.7;
  603. area2.fillColor = 6697540;
  604. mxdraw.MxFun.getCurrentDraw().addMxEntity(area2);
  605. }
  606. );
  607. });
  608. }
  609. function init$o() {
  610. mxdraw.MxFun.addCommand("BR_Comment", BR_Comment);
  611. mxdraw.MxFun.addCommand("BR_CheckDraw", BR_CheckDraw);
  612. mxdraw.MxFun.addCommand("BR_Arrow", BR_Arrow);
  613. mxdraw.MxFun.addCommand("BR_CloudLine", BR_CloudLine);
  614. mxdraw.MxFun.addCommand("BR_Print", BR_Print);
  615. mxdraw.MxFun.addCommand("BR_SaveAllMxEntity", BR_SaveAllMxEntity);
  616. mxdraw.MxFun.addCommand("BR_LoadAllMxEntity", BR_LoadAllMxEntity);
  617. mxdraw.MxFun.addCommand("BR_Area", BR_Area);
  618. }
  619. function Mx_Test_DrawLine() {
  620. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  621. mxcad$1.newFile();
  622. mxcad$1.drawColorIndex = 0;
  623. mxcad$1.drawLinetype = "";
  624. mxcad$1.drawLineWidth = 0;
  625. mxcad$1.addLayer("LineLayer");
  626. mxcad$1.drawLayer = "LineLayer";
  627. mxcad$1.drawLine(0, 0, 100, 0);
  628. mxcad$1.drawLine(200, 0, 300, 100);
  629. mxcad$1.addLinetype("MyLineType", "6,-10");
  630. mxcad$1.drawLinetype = "MyLineType";
  631. mxcad$1.drawLine(0, 30, 100, 30);
  632. mxcad$1.drawLine(200, 30, 300, 130);
  633. mxcad$1.drawColor = new mxcad2.McCmColor(0, 0, 255);
  634. mxcad$1.drawLine(0, 60, 100, 60);
  635. mxcad$1.drawLine(200, 60, 300, 160);
  636. mxcad$1.drawColorIndex = 0;
  637. mxcad$1.drawLinetype = "";
  638. mxcad$1.drawLineWidth = 4;
  639. mxcad$1.drawLine(0, 90, 100, 90);
  640. mxcad$1.drawLine(200, 90, 300, 190);
  641. mxcad$1.addLinetype("MyLineType2", "10,-2,3,-2");
  642. mxcad$1.drawLinetype = "MyLineType2";
  643. mxcad$1.drawColor = new mxcad2.McCmColor(255, 0, 0);
  644. mxcad$1.drawLine(0, 120, 100, 120);
  645. mxcad$1.drawLine(200, 120, 300, 220);
  646. mxcad$1.addTextStyle("MyLineTypeTextStyle", "txt.shx", "hztxt.shx", 1);
  647. mxcad$1.addLinetypeEx("MyLineType3", '(12.7,("T=MxDraw","S=2.54","L=-5.08","R=0.0","X=-2.54","Y=-1.27"),-10.08)', "MyLineTypeTextStyle");
  648. mxcad$1.drawLinetype = "MyLineType3";
  649. mxcad$1.drawLineWidth = 0;
  650. mxcad$1.drawLine(350, 120, 600, 120);
  651. mxcad$1.drawColorIndex = 0;
  652. mxcad$1.drawLineWidth = 4;
  653. mxcad$1.drawLine(350, 220, 600, 220);
  654. mxcad$1.zoomAll();
  655. mxcad$1.updateDisplay();
  656. }
  657. function Mx_Test_DrawArc() {
  658. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  659. mxcad$1.newFile();
  660. mxcad$1.drawColorIndex = 0;
  661. mxcad$1.drawLinetype = "";
  662. mxcad$1.drawLineWidth = 0;
  663. mxcad$1.addLayer("ArcLayer");
  664. mxcad$1.drawLayer = "ArcLayer";
  665. mxcad$1.drawArc(0, 1e3, 100, 30, 200);
  666. mxcad$1.addLinetype("ArcLineType", "30,-5,7,-7");
  667. mxcad$1.drawLinetype = "ArcLineType";
  668. mxcad$1.drawColor = new mxcad2.McCmColor(255, 25, 0);
  669. mxcad$1.drawArc(300, 1e3, 100, 30, 200);
  670. mxcad$1.drawLineWidth = 15;
  671. mxcad$1.drawColorIndex = 255;
  672. mxcad$1.drawArc(600, 1e3, 100, 30, 200);
  673. mxcad$1.drawArc2(800, 1e3, 900, 1200, 1e3, 900);
  674. mxcad$1.drawLinetype = "";
  675. mxcad$1.drawLineWidth = 40;
  676. mxcad$1.drawArc3(1200, 1e3, 1400, 1e3, 0.6);
  677. mxcad$1.zoomAll();
  678. mxcad$1.regen();
  679. mxcad$1.updateDisplay();
  680. }
  681. function Mx_Test_DrawCircle() {
  682. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  683. mxcad$1.newFile();
  684. mxcad$1.drawColorIndex = 0;
  685. mxcad$1.drawLinetype = "";
  686. mxcad$1.drawLineWidth = 0;
  687. mxcad$1.addLayer("CircleLayer");
  688. mxcad$1.drawLayer = "CircleLayer";
  689. mxcad$1.drawCircle(0, 800, 120);
  690. mxcad$1.addLinetype("CircleLineType", "30,-5,7,-7");
  691. mxcad$1.drawLinetype = "CircleLineType";
  692. mxcad$1.drawColor = new mxcad2.McCmColor(0, 25, 255);
  693. mxcad$1.drawCircle(300, 800, 120);
  694. mxcad$1.addLinetype("CircleLineType", "30,-5,7,-7");
  695. mxcad$1.drawLinetype = "CircleLineType";
  696. mxcad$1.drawLineWidth = 40;
  697. mxcad$1.drawCircle(600, 800, 120);
  698. mxcad$1.zoomAll();
  699. mxcad$1.regen();
  700. mxcad$1.updateDisplay();
  701. }
  702. function Mx_Test_DrawPolyline() {
  703. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  704. mxcad$1.newFile();
  705. mxcad$1.drawColorIndex = 0;
  706. mxcad$1.drawLinetype = "";
  707. mxcad$1.drawLineWidth = 0;
  708. mxcad$1.addLayer("PolylineLayer");
  709. mxcad$1.drawLayer = "PolylineLayer";
  710. mxcad$1.pathMoveTo(0, 300);
  711. mxcad$1.pathLineTo(100, 300);
  712. mxcad$1.pathLineTo(100, 400);
  713. mxcad$1.pathLineTo(0, 400);
  714. mxcad$1.pathMakeClosed();
  715. mxcad$1.drawPathToPolyline();
  716. mxcad$1.pathMoveTo(200, 300);
  717. mxcad$1.pathLineTo(300, 300);
  718. mxcad$1.pathLineTo(300, 400);
  719. mxcad$1.pathLineTo(200, 400);
  720. mxcad$1.pathMakeClosed();
  721. mxcad$1.addLinetype("MyLineType3", "30,-10");
  722. mxcad$1.drawLinetype = "MyLineType3";
  723. mxcad$1.drawColorIndex = 255;
  724. mxcad$1.drawLineWidth = 5;
  725. mxcad$1.drawPathToPolyline();
  726. mxcad$1.pathMoveTo(400, 300);
  727. mxcad$1.pathLineTo(500, 300);
  728. mxcad$1.pathLineTo(500, 400);
  729. mxcad$1.pathLineTo(400, 400);
  730. mxcad$1.pathMakeClosed();
  731. mxcad$1.drawLinetype = "";
  732. mxcad$1.drawColor = new mxcad2.McCmColor(0, 25, 255);
  733. mxcad$1.drawLineWidth = 10;
  734. mxcad$1.drawPathToPolyline();
  735. mxcad$1.pathMoveTo(400, 300);
  736. mxcad$1.pathLineTo(500, 300);
  737. mxcad$1.pathLineTo(500, 400);
  738. mxcad$1.pathLineTo(400, 400);
  739. mxcad$1.pathMakeClosed();
  740. mxcad$1.drawLinetype = "";
  741. mxcad$1.drawColor = new mxcad2.McCmColor(255, 25, 0);
  742. mxcad$1.drawLineWidth = 10;
  743. mxcad$1.drawPathToPolyline();
  744. mxcad$1.pathMoveTo(600, 300);
  745. mxcad$1.pathLineTo(700, 300);
  746. mxcad$1.pathLineTo(700, 400);
  747. mxcad$1.pathLineTo(600, 400);
  748. mxcad$1.drawLinetype = "";
  749. mxcad$1.drawColor = new mxcad2.McCmColor(0, 255, 0);
  750. mxcad$1.drawLineWidth = 10;
  751. mxcad$1.drawPathToPolyline();
  752. mxcad$1.pathMoveTo(800, 300);
  753. mxcad$1.pathLineTo(900, 300);
  754. mxcad$1.pathLineTo(900, 400);
  755. mxcad$1.pathMakeClosed();
  756. mxcad$1.drawLinetype = "";
  757. mxcad$1.drawColor = new mxcad2.McCmColor(25, 255, 0);
  758. mxcad$1.drawLineWidth = 10;
  759. mxcad$1.drawPathToPolyline();
  760. mxcad$1.pathMoveToEx(1e3, 300, 10, 10, 0);
  761. mxcad$1.pathLineToEx(1e3, 500, 30, 0, 0);
  762. mxcad$1.pathLineTo(1e3, 580);
  763. mxcad$1.drawPathToPolyline();
  764. mxcad$1.pathMoveToEx(1200, 300, 10, 10, 0);
  765. mxcad$1.pathLineToEx(1200, 500, 30, 0, 0);
  766. mxcad$1.pathLineTo(1200, 580);
  767. mxcad$1.drawColor = new mxcad2.McCmColor(25, 255, 0);
  768. mxcad$1.drawLinetype = "MyLineType3";
  769. mxcad$1.drawPathToPolyline();
  770. mxcad$1.pathMoveToEx(1400, 300, 10, 10, -0.34);
  771. mxcad$1.pathLineToEx(1400, 500, 30, 0, 0.34);
  772. mxcad$1.pathLineTo(1400, 600);
  773. mxcad$1.drawColor = new mxcad2.McCmColor(255, 255, 25);
  774. mxcad$1.drawLinetype = "MyLineType3";
  775. mxcad$1.drawPathToPolyline();
  776. mxcad$1.zoomAll();
  777. mxcad$1.regen();
  778. mxcad$1.updateDisplay();
  779. }
  780. function Mx_Test_DrawHatch() {
  781. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  782. mxcad$1.newFile();
  783. mxcad$1.drawColorIndex = 0;
  784. mxcad$1.drawLinetype = "";
  785. mxcad$1.drawLineWidth = 0;
  786. mxcad$1.addLayer("HatchLayer");
  787. mxcad$1.drawLayer = "HatchLayer";
  788. mxcad$1.pathMoveToEx(200, 3300, 0, 0, 0.3);
  789. mxcad$1.pathLineTo(300, 3300);
  790. mxcad$1.pathLineTo(300, 3400);
  791. mxcad$1.pathLineTo(200, 3300);
  792. mxcad$1.drawColor = new mxcad2.McCmColor(25, 255, 0);
  793. mxcad$1.drawPathToHatch(1);
  794. mxcad$1.pathMoveTo(150, 3300);
  795. mxcad$1.pathLineTo(250, 3300);
  796. mxcad$1.pathLineTo(250, 3400);
  797. mxcad$1.pathLineTo(150, 3300);
  798. mxcad$1.drawColor = new mxcad2.McCmColor(255, 0, 0);
  799. mxcad$1.drawPathToHatch(1);
  800. mxcad$1.pathMoveToEx(440, 3310, 0, 0, 0);
  801. mxcad$1.pathLineTo(480, 3310);
  802. mxcad$1.pathLineTo(480, 3360);
  803. mxcad$1.pathLineTo(450, 3340);
  804. mxcad$1.pathMakeExclude(true);
  805. mxcad$1.pathMoveToEx(400, 3300, 0, 0, 0.3);
  806. mxcad$1.pathLineTo(500, 3300);
  807. mxcad$1.pathLineTo(500, 3400);
  808. mxcad$1.pathLineTo(400, 3300);
  809. mxcad$1.drawColor = new mxcad2.McCmColor(255, 25, 0);
  810. mxcad$1.drawPathToHatch(1);
  811. mxcad$1.addPatternDefinition("MyHatchPattern1", "((45, 0,0, 0,0.125))");
  812. mxcad$1.drawPatternDefinition = "MyHatchPattern1";
  813. mxcad$1.pathMoveToEx(600, 3300, 0, 0, 0.3);
  814. mxcad$1.pathLineTo(700, 3300);
  815. mxcad$1.pathLineTo(700, 3400);
  816. mxcad$1.pathLineTo(600, 3300);
  817. mxcad$1.drawPathToHatch(100);
  818. mxcad$1.addPatternDefinition("MyHatchPattern2", "((45, 0,0, 0,0.25) (45, 0.176776695,0, 0,0.25, 0.125,-0.0625))");
  819. mxcad$1.drawPatternDefinition = "MyHatchPattern2";
  820. mxcad$1.pathMoveToEx(800, 3300, 0, 0, 0.3);
  821. mxcad$1.pathLineTo(900, 3300);
  822. mxcad$1.pathLineTo(900, 3400);
  823. mxcad$1.pathLineTo(800, 3300);
  824. mxcad$1.drawPathToHatch(100);
  825. mxcad$1.zoomAll();
  826. mxcad$1.regen();
  827. mxcad$1.updateDisplay();
  828. }
  829. function Mx_Test_DrawText() {
  830. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  831. mxcad$1.newFile();
  832. mxcad$1.drawColorIndex = 0;
  833. mxcad$1.addLayer("TextLayer");
  834. mxcad$1.drawLayer = "TextLayer";
  835. mxcad$1.drawText(0, 1900, "绘图控件文字测试", 100, 0, 0, 1);
  836. mxcad$1.drawColor = new mxcad2.McCmColor(255, 25, 0);
  837. mxcad$1.drawText(3e3, 2100, "绘图控件文字测试", 100, -20, 2, 1);
  838. mxcad$1.addTextStyle("MyTextStyle", "italicc.shx", "gbcbig.shx", 0.7);
  839. mxcad$1.drawTextStyle = "MyTextStyle";
  840. mxcad$1.drawColor = new mxcad2.McCmColor(255, 0, 0);
  841. mxcad$1.drawText(0, 3e3, "绘图控件文字测试", 100, 0, 0, 1);
  842. mxcad$1.AddTureTypeTextStyle("MyTrueTypeTextStyle");
  843. mxcad$1.drawTextStyle = "MyTrueTypeTextStyle";
  844. mxcad$1.drawColor = new mxcad2.McCmColor(200, 255, 50);
  845. mxcad$1.drawText(0, 3500, "绘图控件TrueType文字测试", 100, 0, 0, 1);
  846. mxcad$1.zoomAll();
  847. mxcad$1.regen();
  848. mxcad$1.updateDisplay();
  849. }
  850. function Mx_Test_Ellipse() {
  851. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  852. mxcad$1.newFile();
  853. mxcad$1.drawColorIndex = 0;
  854. mxcad$1.drawLinetype = "";
  855. mxcad$1.drawLineWidth = 0;
  856. mxcad$1.addLayer("LineLayer");
  857. mxcad$1.drawLayer = "LineLayer";
  858. mxcad$1.drawEllipse(0, 1400, 100, 0, 0.7);
  859. mxcad$1.addLinetype("MyEllipseType", "6,-10");
  860. mxcad$1.drawLinetype = "MyEllipseType";
  861. mxcad$1.drawColor = new mxcad2.McCmColor(200, 0, 0);
  862. mxcad$1.drawEllipse(200, 1400, 80, 30, 0.5);
  863. mxcad$1.zoomAll();
  864. mxcad$1.regen();
  865. mxcad$1.updateDisplay();
  866. }
  867. function Mx_Test_EllipseArc() {
  868. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  869. mxcad$1.newFile();
  870. mxcad$1.drawColorIndex = 0;
  871. mxcad$1.drawLineWidth = 0;
  872. mxcad$1.addLayer("EllipseArcLayer");
  873. mxcad$1.drawLayer = "EllipseArcLayer";
  874. mxcad$1.drawEllipseArc(0, 1600, 80, 30, 0.4, 30, 200);
  875. mxcad$1.addLinetype("MyEllipseArcType", "6,-10");
  876. mxcad$1.drawLinetype = "MyEllipseArcType";
  877. mxcad$1.drawColor = new mxcad2.McCmColor(200, 200, 0);
  878. mxcad$1.drawEllipseArc(200, 1600, -80, 30, 0.5, 60, 300);
  879. mxcad$1.drawLinetype = "";
  880. mxcad$1.zoomAll();
  881. mxcad$1.regen();
  882. mxcad$1.updateDisplay();
  883. }
  884. function Mx_Test_MText() {
  885. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  886. mxcad$1.newFile();
  887. mxcad$1.drawColorIndex = 0;
  888. mxcad$1.addLayer("MtextLayer");
  889. mxcad$1.drawLayer = "MtextLayer";
  890. mxcad$1.drawTextStyle = "";
  891. mxcad$1.drawMText(0, -100, "控件:\\P多行文字测试", 50, 400, 0, 1);
  892. mxcad$1.zoomAll();
  893. mxcad$1.regen();
  894. mxcad$1.updateDisplay();
  895. }
  896. function Mx_ParamDrawLine(data) {
  897. if (!data || !data.param)
  898. return;
  899. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  900. mxcad$1.newFile();
  901. mxcad$1.drawColorIndex = 0;
  902. mxcad$1.drawLinetype = "";
  903. mxcad$1.drawLineWidth = 0;
  904. mxcad$1.addLayer("LineLayer");
  905. mxcad$1.drawLayer = "LineLayer";
  906. mxcad$1.drawLine(data.param.x1, data.param.y1, data.param.x2, data.param.y2);
  907. mxcad$1.zoomAll();
  908. mxcad$1.updateDisplay();
  909. mxdraw.MxFun.postMessageToParentFrame({ cmd: "Mx_ParamDrawLine", message: "ok" });
  910. }
  911. function Mx_Test_Text() {
  912. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  913. mxcad$1.newFile();
  914. mxcad$1.drawText(
  915. 350831.77,
  916. 1940511845e-2,
  917. "1.034",
  918. 10,
  919. 0,
  920. mxcad2.McDb.TextHorzMode.kTextLeft,
  921. mxcad2.McDb.TextVertMode.kTextVertMid
  922. );
  923. mxcad$1.zoomAll();
  924. mxcad$1.regen(100);
  925. }
  926. function Mx_Test_DimAligned() {
  927. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  928. mxcad$1.newFile();
  929. mxcad$1.addDimStyle("MyDimStyle", "41,0.18,141,0.09,40,200", "77,1,271,3", "", "");
  930. mxcad$1.drawDimStyle = "MyDimStyle";
  931. mxcad$1.drawColorIndex = 0;
  932. mxcad$1.drawLinetype = "";
  933. mxcad$1.drawLineWidth = 0;
  934. mxcad$1.drawDimAligned(0, 4e3, 300, 4500, 150, 4600);
  935. mxcad$1.zoomAll();
  936. mxcad$1.updateDisplay();
  937. }
  938. function Mx_Test_DrawDimRotated() {
  939. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  940. mxcad$1.newFile();
  941. mxcad$1.addDimStyle("MyDimStyle", "41,0.18,141,0.09,40,200", "77,1,271,3", "", "");
  942. mxcad$1.drawDimStyle = "MyDimStyle";
  943. mxcad$1.drawColorIndex = 0;
  944. mxcad$1.drawLinetype = "";
  945. mxcad$1.drawLineWidth = 0;
  946. mxcad$1.drawDimRotated(0, 7e3, 600, 7e3, 250, 7050, 0);
  947. mxcad$1.drawDimRotated(0, 7200, 0, 7600, 150, 7300, 0.771);
  948. mxcad$1.zoomAll();
  949. mxcad$1.updateDisplay();
  950. }
  951. function Mx_Test_DrawDimAngular() {
  952. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  953. mxcad$1.newFile();
  954. mxcad$1.addDimStyle("MyDimStyle2", "41,0.18,141,0.09,40,200", "77,1,271,3", "", "");
  955. mxcad$1.drawDimStyle = "MyDimStyle2";
  956. mxcad$1.drawColorIndex = 0;
  957. mxcad$1.drawLinetype = "";
  958. mxcad$1.drawLineWidth = 0;
  959. mxcad$1.drawDimAngular(500, 5e3, 0, 5500, 1e3, 5500, 500, 5500);
  960. mxcad$1.zoomAll();
  961. mxcad$1.updateDisplay();
  962. }
  963. function init$n() {
  964. mxdraw.MxFun.addCommand("Mx_Test_DrawLine", Mx_Test_DrawLine);
  965. mxdraw.MxFun.addCommand("Mx_Test_DrawArc", Mx_Test_DrawArc);
  966. mxdraw.MxFun.addCommand("Mx_Test_DrawCircle", Mx_Test_DrawCircle);
  967. mxdraw.MxFun.addCommand("Mx_Test_DrawPolyline", Mx_Test_DrawPolyline);
  968. mxdraw.MxFun.addCommand("Mx_Test_DrawHatch", Mx_Test_DrawHatch);
  969. mxdraw.MxFun.addCommand("Mx_Test_DrawText", Mx_Test_DrawText);
  970. mxdraw.MxFun.addCommand("Mx_Test_Ellipse", Mx_Test_Ellipse);
  971. mxdraw.MxFun.addCommand("Mx_Test_EllipseArc", Mx_Test_EllipseArc);
  972. mxdraw.MxFun.addCommand("Mx_Test_MText", Mx_Test_MText);
  973. mxdraw.MxFun.addCommand("Mx_Test_Text", Mx_Test_Text);
  974. mxdraw.MxFun.addCommand("Mx_ParamDrawLine", Mx_ParamDrawLine);
  975. mxdraw.MxFun.addCommand("Mx_Test_DimAligned", Mx_Test_DimAligned);
  976. mxdraw.MxFun.addCommand("Mx_Test_DrawDimRotated", Mx_Test_DrawDimRotated);
  977. mxdraw.MxFun.addCommand("Mx_Test_DrawDimAngular", Mx_Test_DrawDimAngular);
  978. }
  979. if (Number.EPSILON === void 0) {
  980. Number.EPSILON = Math.pow(2, -52);
  981. }
  982. if (Number.isInteger === void 0) {
  983. Number.isInteger = function(value) {
  984. return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
  985. };
  986. }
  987. if (Math.sign === void 0) {
  988. Math.sign = function(x) {
  989. return x < 0 ? -1 : x > 0 ? 1 : +x;
  990. };
  991. }
  992. if ("name" in Function.prototype === false) {
  993. Object.defineProperty(Function.prototype, "name", {
  994. get: function() {
  995. return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1];
  996. }
  997. });
  998. }
  999. if (Object.assign === void 0) {
  1000. Object.assign = function(target) {
  1001. if (target === void 0 || target === null) {
  1002. throw new TypeError("Cannot convert undefined or null to object");
  1003. }
  1004. var output = Object(target);
  1005. for (var index = 1; index < arguments.length; index++) {
  1006. var source = arguments[index];
  1007. if (source !== void 0 && source !== null) {
  1008. for (var nextKey in source) {
  1009. if (Object.prototype.hasOwnProperty.call(source, nextKey)) {
  1010. output[nextKey] = source[nextKey];
  1011. }
  1012. }
  1013. }
  1014. }
  1015. return output;
  1016. };
  1017. }
  1018. var REVISION = "113";
  1019. var CullFaceNone = 0;
  1020. var CullFaceBack = 1;
  1021. var CullFaceFront = 2;
  1022. var PCFShadowMap = 1;
  1023. var PCFSoftShadowMap = 2;
  1024. var VSMShadowMap = 3;
  1025. var FrontSide = 0;
  1026. var BackSide = 1;
  1027. var DoubleSide = 2;
  1028. var FlatShading = 1;
  1029. var NoColors = 0;
  1030. var FaceColors = 1;
  1031. var VertexColors = 2;
  1032. var NoBlending = 0;
  1033. var NormalBlending = 1;
  1034. var AdditiveBlending = 2;
  1035. var SubtractiveBlending = 3;
  1036. var MultiplyBlending = 4;
  1037. var CustomBlending = 5;
  1038. var AddEquation = 100;
  1039. var SubtractEquation = 101;
  1040. var ReverseSubtractEquation = 102;
  1041. var MinEquation = 103;
  1042. var MaxEquation = 104;
  1043. var ZeroFactor = 200;
  1044. var OneFactor = 201;
  1045. var SrcColorFactor = 202;
  1046. var OneMinusSrcColorFactor = 203;
  1047. var SrcAlphaFactor = 204;
  1048. var OneMinusSrcAlphaFactor = 205;
  1049. var DstAlphaFactor = 206;
  1050. var OneMinusDstAlphaFactor = 207;
  1051. var DstColorFactor = 208;
  1052. var OneMinusDstColorFactor = 209;
  1053. var SrcAlphaSaturateFactor = 210;
  1054. var NeverDepth = 0;
  1055. var AlwaysDepth = 1;
  1056. var LessDepth = 2;
  1057. var LessEqualDepth = 3;
  1058. var EqualDepth = 4;
  1059. var GreaterEqualDepth = 5;
  1060. var GreaterDepth = 6;
  1061. var NotEqualDepth = 7;
  1062. var MultiplyOperation = 0;
  1063. var MixOperation = 1;
  1064. var AddOperation = 2;
  1065. var NoToneMapping = 0;
  1066. var LinearToneMapping = 1;
  1067. var ReinhardToneMapping = 2;
  1068. var Uncharted2ToneMapping = 3;
  1069. var CineonToneMapping = 4;
  1070. var ACESFilmicToneMapping = 5;
  1071. var UVMapping = 300;
  1072. var CubeReflectionMapping = 301;
  1073. var CubeRefractionMapping = 302;
  1074. var EquirectangularReflectionMapping = 303;
  1075. var EquirectangularRefractionMapping = 304;
  1076. var SphericalReflectionMapping = 305;
  1077. var CubeUVReflectionMapping = 306;
  1078. var CubeUVRefractionMapping = 307;
  1079. var RepeatWrapping = 1e3;
  1080. var ClampToEdgeWrapping = 1001;
  1081. var MirroredRepeatWrapping = 1002;
  1082. var NearestFilter = 1003;
  1083. var NearestMipmapNearestFilter = 1004;
  1084. var NearestMipmapLinearFilter = 1005;
  1085. var LinearFilter = 1006;
  1086. var LinearMipmapNearestFilter = 1007;
  1087. var LinearMipmapLinearFilter = 1008;
  1088. var UnsignedByteType = 1009;
  1089. var ByteType = 1010;
  1090. var ShortType = 1011;
  1091. var UnsignedShortType = 1012;
  1092. var IntType = 1013;
  1093. var UnsignedIntType = 1014;
  1094. var FloatType = 1015;
  1095. var HalfFloatType = 1016;
  1096. var UnsignedShort4444Type = 1017;
  1097. var UnsignedShort5551Type = 1018;
  1098. var UnsignedShort565Type = 1019;
  1099. var UnsignedInt248Type = 1020;
  1100. var AlphaFormat = 1021;
  1101. var RGBFormat = 1022;
  1102. var RGBAFormat = 1023;
  1103. var LuminanceFormat = 1024;
  1104. var LuminanceAlphaFormat = 1025;
  1105. var RGBEFormat = RGBAFormat;
  1106. var DepthFormat = 1026;
  1107. var DepthStencilFormat = 1027;
  1108. var RedFormat = 1028;
  1109. var RedIntegerFormat = 1029;
  1110. var RGFormat = 1030;
  1111. var RGIntegerFormat = 1031;
  1112. var RGBIntegerFormat = 1032;
  1113. var RGBAIntegerFormat = 1033;
  1114. var RGB_S3TC_DXT1_Format = 33776;
  1115. var RGBA_S3TC_DXT1_Format = 33777;
  1116. var RGBA_S3TC_DXT3_Format = 33778;
  1117. var RGBA_S3TC_DXT5_Format = 33779;
  1118. var RGB_PVRTC_4BPPV1_Format = 35840;
  1119. var RGB_PVRTC_2BPPV1_Format = 35841;
  1120. var RGBA_PVRTC_4BPPV1_Format = 35842;
  1121. var RGBA_PVRTC_2BPPV1_Format = 35843;
  1122. var RGB_ETC1_Format = 36196;
  1123. var RGBA_ASTC_4x4_Format = 37808;
  1124. var RGBA_ASTC_5x4_Format = 37809;
  1125. var RGBA_ASTC_5x5_Format = 37810;
  1126. var RGBA_ASTC_6x5_Format = 37811;
  1127. var RGBA_ASTC_6x6_Format = 37812;
  1128. var RGBA_ASTC_8x5_Format = 37813;
  1129. var RGBA_ASTC_8x6_Format = 37814;
  1130. var RGBA_ASTC_8x8_Format = 37815;
  1131. var RGBA_ASTC_10x5_Format = 37816;
  1132. var RGBA_ASTC_10x6_Format = 37817;
  1133. var RGBA_ASTC_10x8_Format = 37818;
  1134. var RGBA_ASTC_10x10_Format = 37819;
  1135. var RGBA_ASTC_12x10_Format = 37820;
  1136. var RGBA_ASTC_12x12_Format = 37821;
  1137. var LoopOnce = 2200;
  1138. var LoopRepeat = 2201;
  1139. var LoopPingPong = 2202;
  1140. var InterpolateDiscrete = 2300;
  1141. var InterpolateLinear = 2301;
  1142. var InterpolateSmooth = 2302;
  1143. var ZeroCurvatureEnding = 2400;
  1144. var ZeroSlopeEnding = 2401;
  1145. var WrapAroundEnding = 2402;
  1146. var TrianglesDrawMode = 0;
  1147. var TriangleStripDrawMode = 1;
  1148. var TriangleFanDrawMode = 2;
  1149. var LinearEncoding = 3e3;
  1150. var sRGBEncoding = 3001;
  1151. var GammaEncoding = 3007;
  1152. var RGBEEncoding = 3002;
  1153. var LogLuvEncoding = 3003;
  1154. var RGBM7Encoding = 3004;
  1155. var RGBM16Encoding = 3005;
  1156. var RGBDEncoding = 3006;
  1157. var BasicDepthPacking = 3200;
  1158. var RGBADepthPacking = 3201;
  1159. var TangentSpaceNormalMap = 0;
  1160. var ObjectSpaceNormalMap = 1;
  1161. var KeepStencilOp = 7680;
  1162. var AlwaysStencilFunc = 519;
  1163. var StaticDrawUsage = 35044;
  1164. var DynamicDrawUsage = 35048;
  1165. function EventDispatcher() {
  1166. }
  1167. Object.assign(EventDispatcher.prototype, {
  1168. addEventListener: function(type, listener) {
  1169. if (this._listeners === void 0)
  1170. this._listeners = {};
  1171. var listeners = this._listeners;
  1172. if (listeners[type] === void 0) {
  1173. listeners[type] = [];
  1174. }
  1175. if (listeners[type].indexOf(listener) === -1) {
  1176. listeners[type].push(listener);
  1177. }
  1178. },
  1179. hasEventListener: function(type, listener) {
  1180. if (this._listeners === void 0)
  1181. return false;
  1182. var listeners = this._listeners;
  1183. return listeners[type] !== void 0 && listeners[type].indexOf(listener) !== -1;
  1184. },
  1185. removeEventListener: function(type, listener) {
  1186. if (this._listeners === void 0)
  1187. return;
  1188. var listeners = this._listeners;
  1189. var listenerArray = listeners[type];
  1190. if (listenerArray !== void 0) {
  1191. var index = listenerArray.indexOf(listener);
  1192. if (index !== -1) {
  1193. listenerArray.splice(index, 1);
  1194. }
  1195. }
  1196. },
  1197. dispatchEvent: function(event) {
  1198. if (this._listeners === void 0)
  1199. return;
  1200. var listeners = this._listeners;
  1201. var listenerArray = listeners[event.type];
  1202. if (listenerArray !== void 0) {
  1203. event.target = this;
  1204. var array = listenerArray.slice(0);
  1205. for (var i2 = 0, l = array.length; i2 < l; i2++) {
  1206. array[i2].call(this, event);
  1207. }
  1208. }
  1209. }
  1210. });
  1211. var _lut = [];
  1212. for (var i = 0; i < 256; i++) {
  1213. _lut[i] = (i < 16 ? "0" : "") + i.toString(16);
  1214. }
  1215. var MathUtils = {
  1216. DEG2RAD: Math.PI / 180,
  1217. RAD2DEG: 180 / Math.PI,
  1218. generateUUID: function() {
  1219. var d0 = Math.random() * 4294967295 | 0;
  1220. var d1 = Math.random() * 4294967295 | 0;
  1221. var d2 = Math.random() * 4294967295 | 0;
  1222. var d3 = Math.random() * 4294967295 | 0;
  1223. var uuid = _lut[d0 & 255] + _lut[d0 >> 8 & 255] + _lut[d0 >> 16 & 255] + _lut[d0 >> 24 & 255] + "-" + _lut[d1 & 255] + _lut[d1 >> 8 & 255] + "-" + _lut[d1 >> 16 & 15 | 64] + _lut[d1 >> 24 & 255] + "-" + _lut[d2 & 63 | 128] + _lut[d2 >> 8 & 255] + "-" + _lut[d2 >> 16 & 255] + _lut[d2 >> 24 & 255] + _lut[d3 & 255] + _lut[d3 >> 8 & 255] + _lut[d3 >> 16 & 255] + _lut[d3 >> 24 & 255];
  1224. return uuid.toUpperCase();
  1225. },
  1226. clamp: function(value, min, max) {
  1227. return Math.max(min, Math.min(max, value));
  1228. },
  1229. // compute euclidian modulo of m % n
  1230. // https://en.wikipedia.org/wiki/Modulo_operation
  1231. euclideanModulo: function(n, m) {
  1232. return (n % m + m) % m;
  1233. },
  1234. // Linear mapping from range <a1, a2> to range <b1, b2>
  1235. mapLinear: function(x, a1, a2, b1, b2) {
  1236. return b1 + (x - a1) * (b2 - b1) / (a2 - a1);
  1237. },
  1238. // https://en.wikipedia.org/wiki/Linear_interpolation
  1239. lerp: function(x, y, t) {
  1240. return (1 - t) * x + t * y;
  1241. },
  1242. // http://en.wikipedia.org/wiki/Smoothstep
  1243. smoothstep: function(x, min, max) {
  1244. if (x <= min)
  1245. return 0;
  1246. if (x >= max)
  1247. return 1;
  1248. x = (x - min) / (max - min);
  1249. return x * x * (3 - 2 * x);
  1250. },
  1251. smootherstep: function(x, min, max) {
  1252. if (x <= min)
  1253. return 0;
  1254. if (x >= max)
  1255. return 1;
  1256. x = (x - min) / (max - min);
  1257. return x * x * x * (x * (x * 6 - 15) + 10);
  1258. },
  1259. // Random integer from <low, high> interval
  1260. randInt: function(low, high) {
  1261. return low + Math.floor(Math.random() * (high - low + 1));
  1262. },
  1263. // Random float from <low, high> interval
  1264. randFloat: function(low, high) {
  1265. return low + Math.random() * (high - low);
  1266. },
  1267. // Random float from <-range/2, range/2> interval
  1268. randFloatSpread: function(range) {
  1269. return range * (0.5 - Math.random());
  1270. },
  1271. degToRad: function(degrees) {
  1272. return degrees * MathUtils.DEG2RAD;
  1273. },
  1274. radToDeg: function(radians) {
  1275. return radians * MathUtils.RAD2DEG;
  1276. },
  1277. isPowerOfTwo: function(value) {
  1278. return (value & value - 1) === 0 && value !== 0;
  1279. },
  1280. ceilPowerOfTwo: function(value) {
  1281. return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));
  1282. },
  1283. floorPowerOfTwo: function(value) {
  1284. return Math.pow(2, Math.floor(Math.log(value) / Math.LN2));
  1285. },
  1286. setQuaternionFromProperEuler: function(q, a, b, c, order) {
  1287. var cos = Math.cos;
  1288. var sin = Math.sin;
  1289. var c2 = cos(b / 2);
  1290. var s2 = sin(b / 2);
  1291. var c13 = cos((a + c) / 2);
  1292. var s13 = sin((a + c) / 2);
  1293. var c1_3 = cos((a - c) / 2);
  1294. var s1_3 = sin((a - c) / 2);
  1295. var c3_1 = cos((c - a) / 2);
  1296. var s3_1 = sin((c - a) / 2);
  1297. if (order === "XYX") {
  1298. q.set(c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13);
  1299. } else if (order === "YZY") {
  1300. q.set(s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13);
  1301. } else if (order === "ZXZ") {
  1302. q.set(s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13);
  1303. } else if (order === "XZX") {
  1304. q.set(c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13);
  1305. } else if (order === "YXY") {
  1306. q.set(s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13);
  1307. } else if (order === "ZYZ") {
  1308. q.set(s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13);
  1309. } else {
  1310. console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order.");
  1311. }
  1312. }
  1313. };
  1314. function Vector2(x, y) {
  1315. this.x = x || 0;
  1316. this.y = y || 0;
  1317. }
  1318. Object.defineProperties(Vector2.prototype, {
  1319. "width": {
  1320. get: function() {
  1321. return this.x;
  1322. },
  1323. set: function(value) {
  1324. this.x = value;
  1325. }
  1326. },
  1327. "height": {
  1328. get: function() {
  1329. return this.y;
  1330. },
  1331. set: function(value) {
  1332. this.y = value;
  1333. }
  1334. }
  1335. });
  1336. Object.assign(Vector2.prototype, {
  1337. isVector2: true,
  1338. set: function(x, y) {
  1339. this.x = x;
  1340. this.y = y;
  1341. return this;
  1342. },
  1343. setScalar: function(scalar) {
  1344. this.x = scalar;
  1345. this.y = scalar;
  1346. return this;
  1347. },
  1348. setX: function(x) {
  1349. this.x = x;
  1350. return this;
  1351. },
  1352. setY: function(y) {
  1353. this.y = y;
  1354. return this;
  1355. },
  1356. setComponent: function(index, value) {
  1357. switch (index) {
  1358. case 0:
  1359. this.x = value;
  1360. break;
  1361. case 1:
  1362. this.y = value;
  1363. break;
  1364. default:
  1365. throw new Error("index is out of range: " + index);
  1366. }
  1367. return this;
  1368. },
  1369. getComponent: function(index) {
  1370. switch (index) {
  1371. case 0:
  1372. return this.x;
  1373. case 1:
  1374. return this.y;
  1375. default:
  1376. throw new Error("index is out of range: " + index);
  1377. }
  1378. },
  1379. clone: function() {
  1380. return new this.constructor(this.x, this.y);
  1381. },
  1382. copy: function(v) {
  1383. this.x = v.x;
  1384. this.y = v.y;
  1385. return this;
  1386. },
  1387. add: function(v, w) {
  1388. if (w !== void 0) {
  1389. console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.");
  1390. return this.addVectors(v, w);
  1391. }
  1392. this.x += v.x;
  1393. this.y += v.y;
  1394. return this;
  1395. },
  1396. addScalar: function(s) {
  1397. this.x += s;
  1398. this.y += s;
  1399. return this;
  1400. },
  1401. addVectors: function(a, b) {
  1402. this.x = a.x + b.x;
  1403. this.y = a.y + b.y;
  1404. return this;
  1405. },
  1406. addScaledVector: function(v, s) {
  1407. this.x += v.x * s;
  1408. this.y += v.y * s;
  1409. return this;
  1410. },
  1411. sub: function(v, w) {
  1412. if (w !== void 0) {
  1413. console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.");
  1414. return this.subVectors(v, w);
  1415. }
  1416. this.x -= v.x;
  1417. this.y -= v.y;
  1418. return this;
  1419. },
  1420. subScalar: function(s) {
  1421. this.x -= s;
  1422. this.y -= s;
  1423. return this;
  1424. },
  1425. subVectors: function(a, b) {
  1426. this.x = a.x - b.x;
  1427. this.y = a.y - b.y;
  1428. return this;
  1429. },
  1430. multiply: function(v) {
  1431. this.x *= v.x;
  1432. this.y *= v.y;
  1433. return this;
  1434. },
  1435. multiplyScalar: function(scalar) {
  1436. this.x *= scalar;
  1437. this.y *= scalar;
  1438. return this;
  1439. },
  1440. divide: function(v) {
  1441. this.x /= v.x;
  1442. this.y /= v.y;
  1443. return this;
  1444. },
  1445. divideScalar: function(scalar) {
  1446. return this.multiplyScalar(1 / scalar);
  1447. },
  1448. applyMatrix3: function(m) {
  1449. var x = this.x, y = this.y;
  1450. var e = m.elements;
  1451. this.x = e[0] * x + e[3] * y + e[6];
  1452. this.y = e[1] * x + e[4] * y + e[7];
  1453. return this;
  1454. },
  1455. min: function(v) {
  1456. this.x = Math.min(this.x, v.x);
  1457. this.y = Math.min(this.y, v.y);
  1458. return this;
  1459. },
  1460. max: function(v) {
  1461. this.x = Math.max(this.x, v.x);
  1462. this.y = Math.max(this.y, v.y);
  1463. return this;
  1464. },
  1465. clamp: function(min, max) {
  1466. this.x = Math.max(min.x, Math.min(max.x, this.x));
  1467. this.y = Math.max(min.y, Math.min(max.y, this.y));
  1468. return this;
  1469. },
  1470. clampScalar: function(minVal, maxVal) {
  1471. this.x = Math.max(minVal, Math.min(maxVal, this.x));
  1472. this.y = Math.max(minVal, Math.min(maxVal, this.y));
  1473. return this;
  1474. },
  1475. clampLength: function(min, max) {
  1476. var length = this.length();
  1477. return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));
  1478. },
  1479. floor: function() {
  1480. this.x = Math.floor(this.x);
  1481. this.y = Math.floor(this.y);
  1482. return this;
  1483. },
  1484. ceil: function() {
  1485. this.x = Math.ceil(this.x);
  1486. this.y = Math.ceil(this.y);
  1487. return this;
  1488. },
  1489. round: function() {
  1490. this.x = Math.round(this.x);
  1491. this.y = Math.round(this.y);
  1492. return this;
  1493. },
  1494. roundToZero: function() {
  1495. this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);
  1496. this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);
  1497. return this;
  1498. },
  1499. negate: function() {
  1500. this.x = -this.x;
  1501. this.y = -this.y;
  1502. return this;
  1503. },
  1504. dot: function(v) {
  1505. return this.x * v.x + this.y * v.y;
  1506. },
  1507. cross: function(v) {
  1508. return this.x * v.y - this.y * v.x;
  1509. },
  1510. lengthSq: function() {
  1511. return this.x * this.x + this.y * this.y;
  1512. },
  1513. length: function() {
  1514. return Math.sqrt(this.x * this.x + this.y * this.y);
  1515. },
  1516. manhattanLength: function() {
  1517. return Math.abs(this.x) + Math.abs(this.y);
  1518. },
  1519. normalize: function() {
  1520. return this.divideScalar(this.length() || 1);
  1521. },
  1522. angle: function() {
  1523. var angle = Math.atan2(this.y, this.x);
  1524. if (angle < 0)
  1525. angle += 2 * Math.PI;
  1526. return angle;
  1527. },
  1528. distanceTo: function(v) {
  1529. return Math.sqrt(this.distanceToSquared(v));
  1530. },
  1531. distanceToSquared: function(v) {
  1532. var dx = this.x - v.x, dy = this.y - v.y;
  1533. return dx * dx + dy * dy;
  1534. },
  1535. manhattanDistanceTo: function(v) {
  1536. return Math.abs(this.x - v.x) + Math.abs(this.y - v.y);
  1537. },
  1538. setLength: function(length) {
  1539. return this.normalize().multiplyScalar(length);
  1540. },
  1541. lerp: function(v, alpha) {
  1542. this.x += (v.x - this.x) * alpha;
  1543. this.y += (v.y - this.y) * alpha;
  1544. return this;
  1545. },
  1546. lerpVectors: function(v1, v2, alpha) {
  1547. return this.subVectors(v2, v1).multiplyScalar(alpha).add(v1);
  1548. },
  1549. equals: function(v) {
  1550. return v.x === this.x && v.y === this.y;
  1551. },
  1552. fromArray: function(array, offset) {
  1553. if (offset === void 0)
  1554. offset = 0;
  1555. this.x = array[offset];
  1556. this.y = array[offset + 1];
  1557. return this;
  1558. },
  1559. toArray: function(array, offset) {
  1560. if (array === void 0)
  1561. array = [];
  1562. if (offset === void 0)
  1563. offset = 0;
  1564. array[offset] = this.x;
  1565. array[offset + 1] = this.y;
  1566. return array;
  1567. },
  1568. fromBufferAttribute: function(attribute, index, offset) {
  1569. if (offset !== void 0) {
  1570. console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute().");
  1571. }
  1572. this.x = attribute.getX(index);
  1573. this.y = attribute.getY(index);
  1574. return this;
  1575. },
  1576. rotateAround: function(center, angle) {
  1577. var c = Math.cos(angle), s = Math.sin(angle);
  1578. var x = this.x - center.x;
  1579. var y = this.y - center.y;
  1580. this.x = x * c - y * s + center.x;
  1581. this.y = x * s + y * c + center.y;
  1582. return this;
  1583. }
  1584. });
  1585. function Matrix3() {
  1586. this.elements = [
  1587. 1,
  1588. 0,
  1589. 0,
  1590. 0,
  1591. 1,
  1592. 0,
  1593. 0,
  1594. 0,
  1595. 1
  1596. ];
  1597. if (arguments.length > 0) {
  1598. console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.");
  1599. }
  1600. }
  1601. Object.assign(Matrix3.prototype, {
  1602. isMatrix3: true,
  1603. set: function(n11, n12, n13, n21, n22, n23, n31, n32, n33) {
  1604. var te = this.elements;
  1605. te[0] = n11;
  1606. te[1] = n21;
  1607. te[2] = n31;
  1608. te[3] = n12;
  1609. te[4] = n22;
  1610. te[5] = n32;
  1611. te[6] = n13;
  1612. te[7] = n23;
  1613. te[8] = n33;
  1614. return this;
  1615. },
  1616. identity: function() {
  1617. this.set(
  1618. 1,
  1619. 0,
  1620. 0,
  1621. 0,
  1622. 1,
  1623. 0,
  1624. 0,
  1625. 0,
  1626. 1
  1627. );
  1628. return this;
  1629. },
  1630. clone: function() {
  1631. return new this.constructor().fromArray(this.elements);
  1632. },
  1633. copy: function(m) {
  1634. var te = this.elements;
  1635. var me = m.elements;
  1636. te[0] = me[0];
  1637. te[1] = me[1];
  1638. te[2] = me[2];
  1639. te[3] = me[3];
  1640. te[4] = me[4];
  1641. te[5] = me[5];
  1642. te[6] = me[6];
  1643. te[7] = me[7];
  1644. te[8] = me[8];
  1645. return this;
  1646. },
  1647. setFromMatrix4: function(m) {
  1648. var me = m.elements;
  1649. this.set(
  1650. me[0],
  1651. me[4],
  1652. me[8],
  1653. me[1],
  1654. me[5],
  1655. me[9],
  1656. me[2],
  1657. me[6],
  1658. me[10]
  1659. );
  1660. return this;
  1661. },
  1662. multiply: function(m) {
  1663. return this.multiplyMatrices(this, m);
  1664. },
  1665. premultiply: function(m) {
  1666. return this.multiplyMatrices(m, this);
  1667. },
  1668. multiplyMatrices: function(a, b) {
  1669. var ae = a.elements;
  1670. var be = b.elements;
  1671. var te = this.elements;
  1672. var a11 = ae[0], a12 = ae[3], a13 = ae[6];
  1673. var a21 = ae[1], a22 = ae[4], a23 = ae[7];
  1674. var a31 = ae[2], a32 = ae[5], a33 = ae[8];
  1675. var b11 = be[0], b12 = be[3], b13 = be[6];
  1676. var b21 = be[1], b22 = be[4], b23 = be[7];
  1677. var b31 = be[2], b32 = be[5], b33 = be[8];
  1678. te[0] = a11 * b11 + a12 * b21 + a13 * b31;
  1679. te[3] = a11 * b12 + a12 * b22 + a13 * b32;
  1680. te[6] = a11 * b13 + a12 * b23 + a13 * b33;
  1681. te[1] = a21 * b11 + a22 * b21 + a23 * b31;
  1682. te[4] = a21 * b12 + a22 * b22 + a23 * b32;
  1683. te[7] = a21 * b13 + a22 * b23 + a23 * b33;
  1684. te[2] = a31 * b11 + a32 * b21 + a33 * b31;
  1685. te[5] = a31 * b12 + a32 * b22 + a33 * b32;
  1686. te[8] = a31 * b13 + a32 * b23 + a33 * b33;
  1687. return this;
  1688. },
  1689. multiplyScalar: function(s) {
  1690. var te = this.elements;
  1691. te[0] *= s;
  1692. te[3] *= s;
  1693. te[6] *= s;
  1694. te[1] *= s;
  1695. te[4] *= s;
  1696. te[7] *= s;
  1697. te[2] *= s;
  1698. te[5] *= s;
  1699. te[8] *= s;
  1700. return this;
  1701. },
  1702. determinant: function() {
  1703. var te = this.elements;
  1704. var a = te[0], b = te[1], c = te[2], d = te[3], e = te[4], f = te[5], g = te[6], h = te[7], i2 = te[8];
  1705. return a * e * i2 - a * f * h - b * d * i2 + b * f * g + c * d * h - c * e * g;
  1706. },
  1707. getInverse: function(matrix, throwOnDegenerate) {
  1708. if (matrix && matrix.isMatrix4) {
  1709. console.error("THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument.");
  1710. }
  1711. var me = matrix.elements, te = this.elements, n11 = me[0], n21 = me[1], n31 = me[2], n12 = me[3], n22 = me[4], n32 = me[5], n13 = me[6], n23 = me[7], n33 = me[8], t11 = n33 * n22 - n32 * n23, t12 = n32 * n13 - n33 * n12, t13 = n23 * n12 - n22 * n13, det = n11 * t11 + n21 * t12 + n31 * t13;
  1712. if (det === 0) {
  1713. var msg = "THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0";
  1714. if (throwOnDegenerate === true) {
  1715. throw new Error(msg);
  1716. } else {
  1717. console.warn(msg);
  1718. }
  1719. return this.identity();
  1720. }
  1721. var detInv = 1 / det;
  1722. te[0] = t11 * detInv;
  1723. te[1] = (n31 * n23 - n33 * n21) * detInv;
  1724. te[2] = (n32 * n21 - n31 * n22) * detInv;
  1725. te[3] = t12 * detInv;
  1726. te[4] = (n33 * n11 - n31 * n13) * detInv;
  1727. te[5] = (n31 * n12 - n32 * n11) * detInv;
  1728. te[6] = t13 * detInv;
  1729. te[7] = (n21 * n13 - n23 * n11) * detInv;
  1730. te[8] = (n22 * n11 - n21 * n12) * detInv;
  1731. return this;
  1732. },
  1733. transpose: function() {
  1734. var tmp2, m = this.elements;
  1735. tmp2 = m[1];
  1736. m[1] = m[3];
  1737. m[3] = tmp2;
  1738. tmp2 = m[2];
  1739. m[2] = m[6];
  1740. m[6] = tmp2;
  1741. tmp2 = m[5];
  1742. m[5] = m[7];
  1743. m[7] = tmp2;
  1744. return this;
  1745. },
  1746. getNormalMatrix: function(matrix4) {
  1747. return this.setFromMatrix4(matrix4).getInverse(this).transpose();
  1748. },
  1749. transposeIntoArray: function(r) {
  1750. var m = this.elements;
  1751. r[0] = m[0];
  1752. r[1] = m[3];
  1753. r[2] = m[6];
  1754. r[3] = m[1];
  1755. r[4] = m[4];
  1756. r[5] = m[7];
  1757. r[6] = m[2];
  1758. r[7] = m[5];
  1759. r[8] = m[8];
  1760. return this;
  1761. },
  1762. setUvTransform: function(tx, ty, sx, sy, rotation, cx, cy) {
  1763. var c = Math.cos(rotation);
  1764. var s = Math.sin(rotation);
  1765. this.set(
  1766. sx * c,
  1767. sx * s,
  1768. -sx * (c * cx + s * cy) + cx + tx,
  1769. -sy * s,
  1770. sy * c,
  1771. -sy * (-s * cx + c * cy) + cy + ty,
  1772. 0,
  1773. 0,
  1774. 1
  1775. );
  1776. },
  1777. scale: function(sx, sy) {
  1778. var te = this.elements;
  1779. te[0] *= sx;
  1780. te[3] *= sx;
  1781. te[6] *= sx;
  1782. te[1] *= sy;
  1783. te[4] *= sy;
  1784. te[7] *= sy;
  1785. return this;
  1786. },
  1787. rotate: function(theta) {
  1788. var c = Math.cos(theta);
  1789. var s = Math.sin(theta);
  1790. var te = this.elements;
  1791. var a11 = te[0], a12 = te[3], a13 = te[6];
  1792. var a21 = te[1], a22 = te[4], a23 = te[7];
  1793. te[0] = c * a11 + s * a21;
  1794. te[3] = c * a12 + s * a22;
  1795. te[6] = c * a13 + s * a23;
  1796. te[1] = -s * a11 + c * a21;
  1797. te[4] = -s * a12 + c * a22;
  1798. te[7] = -s * a13 + c * a23;
  1799. return this;
  1800. },
  1801. translate: function(tx, ty) {
  1802. var te = this.elements;
  1803. te[0] += tx * te[2];
  1804. te[3] += tx * te[5];
  1805. te[6] += tx * te[8];
  1806. te[1] += ty * te[2];
  1807. te[4] += ty * te[5];
  1808. te[7] += ty * te[8];
  1809. return this;
  1810. },
  1811. equals: function(matrix) {
  1812. var te = this.elements;
  1813. var me = matrix.elements;
  1814. for (var i2 = 0; i2 < 9; i2++) {
  1815. if (te[i2] !== me[i2])
  1816. return false;
  1817. }
  1818. return true;
  1819. },
  1820. fromArray: function(array, offset) {
  1821. if (offset === void 0)
  1822. offset = 0;
  1823. for (var i2 = 0; i2 < 9; i2++) {
  1824. this.elements[i2] = array[i2 + offset];
  1825. }
  1826. return this;
  1827. },
  1828. toArray: function(array, offset) {
  1829. if (array === void 0)
  1830. array = [];
  1831. if (offset === void 0)
  1832. offset = 0;
  1833. var te = this.elements;
  1834. array[offset] = te[0];
  1835. array[offset + 1] = te[1];
  1836. array[offset + 2] = te[2];
  1837. array[offset + 3] = te[3];
  1838. array[offset + 4] = te[4];
  1839. array[offset + 5] = te[5];
  1840. array[offset + 6] = te[6];
  1841. array[offset + 7] = te[7];
  1842. array[offset + 8] = te[8];
  1843. return array;
  1844. }
  1845. });
  1846. var _canvas;
  1847. var ImageUtils = {
  1848. getDataURL: function(image) {
  1849. var canvas;
  1850. if (typeof HTMLCanvasElement == "undefined") {
  1851. return image.src;
  1852. } else if (image instanceof HTMLCanvasElement) {
  1853. canvas = image;
  1854. } else {
  1855. if (_canvas === void 0)
  1856. _canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
  1857. _canvas.width = image.width;
  1858. _canvas.height = image.height;
  1859. var context = _canvas.getContext("2d");
  1860. if (image instanceof ImageData) {
  1861. context.putImageData(image, 0, 0);
  1862. } else {
  1863. context.drawImage(image, 0, 0, image.width, image.height);
  1864. }
  1865. canvas = _canvas;
  1866. }
  1867. if (canvas.width > 2048 || canvas.height > 2048) {
  1868. return canvas.toDataURL("image/jpeg", 0.6);
  1869. } else {
  1870. return canvas.toDataURL("image/png");
  1871. }
  1872. }
  1873. };
  1874. var textureId = 0;
  1875. function Texture(image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding) {
  1876. Object.defineProperty(this, "id", { value: textureId++ });
  1877. this.uuid = MathUtils.generateUUID();
  1878. this.name = "";
  1879. this.image = image !== void 0 ? image : Texture.DEFAULT_IMAGE;
  1880. this.mipmaps = [];
  1881. this.mapping = mapping !== void 0 ? mapping : Texture.DEFAULT_MAPPING;
  1882. this.wrapS = wrapS !== void 0 ? wrapS : ClampToEdgeWrapping;
  1883. this.wrapT = wrapT !== void 0 ? wrapT : ClampToEdgeWrapping;
  1884. this.magFilter = magFilter !== void 0 ? magFilter : LinearFilter;
  1885. this.minFilter = minFilter !== void 0 ? minFilter : LinearMipmapLinearFilter;
  1886. this.anisotropy = anisotropy !== void 0 ? anisotropy : 1;
  1887. this.format = format !== void 0 ? format : RGBAFormat;
  1888. this.internalFormat = null;
  1889. this.type = type !== void 0 ? type : UnsignedByteType;
  1890. this.offset = new Vector2(0, 0);
  1891. this.repeat = new Vector2(1, 1);
  1892. this.center = new Vector2(0, 0);
  1893. this.rotation = 0;
  1894. this.matrixAutoUpdate = true;
  1895. this.matrix = new Matrix3();
  1896. this.generateMipmaps = true;
  1897. this.premultiplyAlpha = false;
  1898. this.flipY = true;
  1899. this.unpackAlignment = 4;
  1900. this.encoding = encoding !== void 0 ? encoding : LinearEncoding;
  1901. this.version = 0;
  1902. this.onUpdate = null;
  1903. }
  1904. Texture.DEFAULT_IMAGE = void 0;
  1905. Texture.DEFAULT_MAPPING = UVMapping;
  1906. Texture.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
  1907. constructor: Texture,
  1908. isTexture: true,
  1909. updateMatrix: function() {
  1910. this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);
  1911. },
  1912. clone: function() {
  1913. return new this.constructor().copy(this);
  1914. },
  1915. copy: function(source) {
  1916. this.name = source.name;
  1917. this.image = source.image;
  1918. this.mipmaps = source.mipmaps.slice(0);
  1919. this.mapping = source.mapping;
  1920. this.wrapS = source.wrapS;
  1921. this.wrapT = source.wrapT;
  1922. this.magFilter = source.magFilter;
  1923. this.minFilter = source.minFilter;
  1924. this.anisotropy = source.anisotropy;
  1925. this.format = source.format;
  1926. this.internalFormat = source.internalFormat;
  1927. this.type = source.type;
  1928. this.offset.copy(source.offset);
  1929. this.repeat.copy(source.repeat);
  1930. this.center.copy(source.center);
  1931. this.rotation = source.rotation;
  1932. this.matrixAutoUpdate = source.matrixAutoUpdate;
  1933. this.matrix.copy(source.matrix);
  1934. this.generateMipmaps = source.generateMipmaps;
  1935. this.premultiplyAlpha = source.premultiplyAlpha;
  1936. this.flipY = source.flipY;
  1937. this.unpackAlignment = source.unpackAlignment;
  1938. this.encoding = source.encoding;
  1939. return this;
  1940. },
  1941. toJSON: function(meta) {
  1942. var isRootObject = meta === void 0 || typeof meta === "string";
  1943. if (!isRootObject && meta.textures[this.uuid] !== void 0) {
  1944. return meta.textures[this.uuid];
  1945. }
  1946. var output = {
  1947. metadata: {
  1948. version: 4.5,
  1949. type: "Texture",
  1950. generator: "Texture.toJSON"
  1951. },
  1952. uuid: this.uuid,
  1953. name: this.name,
  1954. mapping: this.mapping,
  1955. repeat: [this.repeat.x, this.repeat.y],
  1956. offset: [this.offset.x, this.offset.y],
  1957. center: [this.center.x, this.center.y],
  1958. rotation: this.rotation,
  1959. wrap: [this.wrapS, this.wrapT],
  1960. format: this.format,
  1961. type: this.type,
  1962. encoding: this.encoding,
  1963. minFilter: this.minFilter,
  1964. magFilter: this.magFilter,
  1965. anisotropy: this.anisotropy,
  1966. flipY: this.flipY,
  1967. premultiplyAlpha: this.premultiplyAlpha,
  1968. unpackAlignment: this.unpackAlignment
  1969. };
  1970. if (this.image !== void 0) {
  1971. var image = this.image;
  1972. if (image.uuid === void 0) {
  1973. image.uuid = MathUtils.generateUUID();
  1974. }
  1975. if (!isRootObject && meta.images[image.uuid] === void 0) {
  1976. var url;
  1977. if (Array.isArray(image)) {
  1978. url = [];
  1979. for (var i2 = 0, l = image.length; i2 < l; i2++) {
  1980. url.push(ImageUtils.getDataURL(image[i2]));
  1981. }
  1982. } else {
  1983. url = ImageUtils.getDataURL(image);
  1984. }
  1985. meta.images[image.uuid] = {
  1986. uuid: image.uuid,
  1987. url
  1988. };
  1989. }
  1990. output.image = image.uuid;
  1991. }
  1992. if (!isRootObject) {
  1993. meta.textures[this.uuid] = output;
  1994. }
  1995. return output;
  1996. },
  1997. dispose: function() {
  1998. this.dispatchEvent({ type: "dispose" });
  1999. },
  2000. transformUv: function(uv) {
  2001. if (this.mapping !== UVMapping)
  2002. return uv;
  2003. uv.applyMatrix3(this.matrix);
  2004. if (uv.x < 0 || uv.x > 1) {
  2005. switch (this.wrapS) {
  2006. case RepeatWrapping:
  2007. uv.x = uv.x - Math.floor(uv.x);
  2008. break;
  2009. case ClampToEdgeWrapping:
  2010. uv.x = uv.x < 0 ? 0 : 1;
  2011. break;
  2012. case MirroredRepeatWrapping:
  2013. if (Math.abs(Math.floor(uv.x) % 2) === 1) {
  2014. uv.x = Math.ceil(uv.x) - uv.x;
  2015. } else {
  2016. uv.x = uv.x - Math.floor(uv.x);
  2017. }
  2018. break;
  2019. }
  2020. }
  2021. if (uv.y < 0 || uv.y > 1) {
  2022. switch (this.wrapT) {
  2023. case RepeatWrapping:
  2024. uv.y = uv.y - Math.floor(uv.y);
  2025. break;
  2026. case ClampToEdgeWrapping:
  2027. uv.y = uv.y < 0 ? 0 : 1;
  2028. break;
  2029. case MirroredRepeatWrapping:
  2030. if (Math.abs(Math.floor(uv.y) % 2) === 1) {
  2031. uv.y = Math.ceil(uv.y) - uv.y;
  2032. } else {
  2033. uv.y = uv.y - Math.floor(uv.y);
  2034. }
  2035. break;
  2036. }
  2037. }
  2038. if (this.flipY) {
  2039. uv.y = 1 - uv.y;
  2040. }
  2041. return uv;
  2042. }
  2043. });
  2044. Object.defineProperty(Texture.prototype, "needsUpdate", {
  2045. set: function(value) {
  2046. if (value === true)
  2047. this.version++;
  2048. }
  2049. });
  2050. function Vector4(x, y, z, w) {
  2051. this.x = x || 0;
  2052. this.y = y || 0;
  2053. this.z = z || 0;
  2054. this.w = w !== void 0 ? w : 1;
  2055. }
  2056. Object.defineProperties(Vector4.prototype, {
  2057. "width": {
  2058. get: function() {
  2059. return this.z;
  2060. },
  2061. set: function(value) {
  2062. this.z = value;
  2063. }
  2064. },
  2065. "height": {
  2066. get: function() {
  2067. return this.w;
  2068. },
  2069. set: function(value) {
  2070. this.w = value;
  2071. }
  2072. }
  2073. });
  2074. Object.assign(Vector4.prototype, {
  2075. isVector4: true,
  2076. set: function(x, y, z, w) {
  2077. this.x = x;
  2078. this.y = y;
  2079. this.z = z;
  2080. this.w = w;
  2081. return this;
  2082. },
  2083. setScalar: function(scalar) {
  2084. this.x = scalar;
  2085. this.y = scalar;
  2086. this.z = scalar;
  2087. this.w = scalar;
  2088. return this;
  2089. },
  2090. setX: function(x) {
  2091. this.x = x;
  2092. return this;
  2093. },
  2094. setY: function(y) {
  2095. this.y = y;
  2096. return this;
  2097. },
  2098. setZ: function(z) {
  2099. this.z = z;
  2100. return this;
  2101. },
  2102. setW: function(w) {
  2103. this.w = w;
  2104. return this;
  2105. },
  2106. setComponent: function(index, value) {
  2107. switch (index) {
  2108. case 0:
  2109. this.x = value;
  2110. break;
  2111. case 1:
  2112. this.y = value;
  2113. break;
  2114. case 2:
  2115. this.z = value;
  2116. break;
  2117. case 3:
  2118. this.w = value;
  2119. break;
  2120. default:
  2121. throw new Error("index is out of range: " + index);
  2122. }
  2123. return this;
  2124. },
  2125. getComponent: function(index) {
  2126. switch (index) {
  2127. case 0:
  2128. return this.x;
  2129. case 1:
  2130. return this.y;
  2131. case 2:
  2132. return this.z;
  2133. case 3:
  2134. return this.w;
  2135. default:
  2136. throw new Error("index is out of range: " + index);
  2137. }
  2138. },
  2139. clone: function() {
  2140. return new this.constructor(this.x, this.y, this.z, this.w);
  2141. },
  2142. copy: function(v) {
  2143. this.x = v.x;
  2144. this.y = v.y;
  2145. this.z = v.z;
  2146. this.w = v.w !== void 0 ? v.w : 1;
  2147. return this;
  2148. },
  2149. add: function(v, w) {
  2150. if (w !== void 0) {
  2151. console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.");
  2152. return this.addVectors(v, w);
  2153. }
  2154. this.x += v.x;
  2155. this.y += v.y;
  2156. this.z += v.z;
  2157. this.w += v.w;
  2158. return this;
  2159. },
  2160. addScalar: function(s) {
  2161. this.x += s;
  2162. this.y += s;
  2163. this.z += s;
  2164. this.w += s;
  2165. return this;
  2166. },
  2167. addVectors: function(a, b) {
  2168. this.x = a.x + b.x;
  2169. this.y = a.y + b.y;
  2170. this.z = a.z + b.z;
  2171. this.w = a.w + b.w;
  2172. return this;
  2173. },
  2174. addScaledVector: function(v, s) {
  2175. this.x += v.x * s;
  2176. this.y += v.y * s;
  2177. this.z += v.z * s;
  2178. this.w += v.w * s;
  2179. return this;
  2180. },
  2181. sub: function(v, w) {
  2182. if (w !== void 0) {
  2183. console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.");
  2184. return this.subVectors(v, w);
  2185. }
  2186. this.x -= v.x;
  2187. this.y -= v.y;
  2188. this.z -= v.z;
  2189. this.w -= v.w;
  2190. return this;
  2191. },
  2192. subScalar: function(s) {
  2193. this.x -= s;
  2194. this.y -= s;
  2195. this.z -= s;
  2196. this.w -= s;
  2197. return this;
  2198. },
  2199. subVectors: function(a, b) {
  2200. this.x = a.x - b.x;
  2201. this.y = a.y - b.y;
  2202. this.z = a.z - b.z;
  2203. this.w = a.w - b.w;
  2204. return this;
  2205. },
  2206. multiplyScalar: function(scalar) {
  2207. this.x *= scalar;
  2208. this.y *= scalar;
  2209. this.z *= scalar;
  2210. this.w *= scalar;
  2211. return this;
  2212. },
  2213. applyMatrix4: function(m) {
  2214. var x = this.x, y = this.y, z = this.z, w = this.w;
  2215. var e = m.elements;
  2216. this.x = e[0] * x + e[4] * y + e[8] * z + e[12] * w;
  2217. this.y = e[1] * x + e[5] * y + e[9] * z + e[13] * w;
  2218. this.z = e[2] * x + e[6] * y + e[10] * z + e[14] * w;
  2219. this.w = e[3] * x + e[7] * y + e[11] * z + e[15] * w;
  2220. return this;
  2221. },
  2222. divideScalar: function(scalar) {
  2223. return this.multiplyScalar(1 / scalar);
  2224. },
  2225. setAxisAngleFromQuaternion: function(q) {
  2226. this.w = 2 * Math.acos(q.w);
  2227. var s = Math.sqrt(1 - q.w * q.w);
  2228. if (s < 1e-4) {
  2229. this.x = 1;
  2230. this.y = 0;
  2231. this.z = 0;
  2232. } else {
  2233. this.x = q.x / s;
  2234. this.y = q.y / s;
  2235. this.z = q.z / s;
  2236. }
  2237. return this;
  2238. },
  2239. setAxisAngleFromRotationMatrix: function(m) {
  2240. var angle, x, y, z, epsilon = 0.01, epsilon2 = 0.1, te = m.elements, m11 = te[0], m12 = te[4], m13 = te[8], m21 = te[1], m22 = te[5], m23 = te[9], m31 = te[2], m32 = te[6], m33 = te[10];
  2241. if (Math.abs(m12 - m21) < epsilon && Math.abs(m13 - m31) < epsilon && Math.abs(m23 - m32) < epsilon) {
  2242. if (Math.abs(m12 + m21) < epsilon2 && Math.abs(m13 + m31) < epsilon2 && Math.abs(m23 + m32) < epsilon2 && Math.abs(m11 + m22 + m33 - 3) < epsilon2) {
  2243. this.set(1, 0, 0, 0);
  2244. return this;
  2245. }
  2246. angle = Math.PI;
  2247. var xx = (m11 + 1) / 2;
  2248. var yy = (m22 + 1) / 2;
  2249. var zz = (m33 + 1) / 2;
  2250. var xy = (m12 + m21) / 4;
  2251. var xz = (m13 + m31) / 4;
  2252. var yz = (m23 + m32) / 4;
  2253. if (xx > yy && xx > zz) {
  2254. if (xx < epsilon) {
  2255. x = 0;
  2256. y = 0.707106781;
  2257. z = 0.707106781;
  2258. } else {
  2259. x = Math.sqrt(xx);
  2260. y = xy / x;
  2261. z = xz / x;
  2262. }
  2263. } else if (yy > zz) {
  2264. if (yy < epsilon) {
  2265. x = 0.707106781;
  2266. y = 0;
  2267. z = 0.707106781;
  2268. } else {
  2269. y = Math.sqrt(yy);
  2270. x = xy / y;
  2271. z = yz / y;
  2272. }
  2273. } else {
  2274. if (zz < epsilon) {
  2275. x = 0.707106781;
  2276. y = 0.707106781;
  2277. z = 0;
  2278. } else {
  2279. z = Math.sqrt(zz);
  2280. x = xz / z;
  2281. y = yz / z;
  2282. }
  2283. }
  2284. this.set(x, y, z, angle);
  2285. return this;
  2286. }
  2287. var s = Math.sqrt((m32 - m23) * (m32 - m23) + (m13 - m31) * (m13 - m31) + (m21 - m12) * (m21 - m12));
  2288. if (Math.abs(s) < 1e-3)
  2289. s = 1;
  2290. this.x = (m32 - m23) / s;
  2291. this.y = (m13 - m31) / s;
  2292. this.z = (m21 - m12) / s;
  2293. this.w = Math.acos((m11 + m22 + m33 - 1) / 2);
  2294. return this;
  2295. },
  2296. min: function(v) {
  2297. this.x = Math.min(this.x, v.x);
  2298. this.y = Math.min(this.y, v.y);
  2299. this.z = Math.min(this.z, v.z);
  2300. this.w = Math.min(this.w, v.w);
  2301. return this;
  2302. },
  2303. max: function(v) {
  2304. this.x = Math.max(this.x, v.x);
  2305. this.y = Math.max(this.y, v.y);
  2306. this.z = Math.max(this.z, v.z);
  2307. this.w = Math.max(this.w, v.w);
  2308. return this;
  2309. },
  2310. clamp: function(min, max) {
  2311. this.x = Math.max(min.x, Math.min(max.x, this.x));
  2312. this.y = Math.max(min.y, Math.min(max.y, this.y));
  2313. this.z = Math.max(min.z, Math.min(max.z, this.z));
  2314. this.w = Math.max(min.w, Math.min(max.w, this.w));
  2315. return this;
  2316. },
  2317. clampScalar: function(minVal, maxVal) {
  2318. this.x = Math.max(minVal, Math.min(maxVal, this.x));
  2319. this.y = Math.max(minVal, Math.min(maxVal, this.y));
  2320. this.z = Math.max(minVal, Math.min(maxVal, this.z));
  2321. this.w = Math.max(minVal, Math.min(maxVal, this.w));
  2322. return this;
  2323. },
  2324. clampLength: function(min, max) {
  2325. var length = this.length();
  2326. return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));
  2327. },
  2328. floor: function() {
  2329. this.x = Math.floor(this.x);
  2330. this.y = Math.floor(this.y);
  2331. this.z = Math.floor(this.z);
  2332. this.w = Math.floor(this.w);
  2333. return this;
  2334. },
  2335. ceil: function() {
  2336. this.x = Math.ceil(this.x);
  2337. this.y = Math.ceil(this.y);
  2338. this.z = Math.ceil(this.z);
  2339. this.w = Math.ceil(this.w);
  2340. return this;
  2341. },
  2342. round: function() {
  2343. this.x = Math.round(this.x);
  2344. this.y = Math.round(this.y);
  2345. this.z = Math.round(this.z);
  2346. this.w = Math.round(this.w);
  2347. return this;
  2348. },
  2349. roundToZero: function() {
  2350. this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);
  2351. this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);
  2352. this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z);
  2353. this.w = this.w < 0 ? Math.ceil(this.w) : Math.floor(this.w);
  2354. return this;
  2355. },
  2356. negate: function() {
  2357. this.x = -this.x;
  2358. this.y = -this.y;
  2359. this.z = -this.z;
  2360. this.w = -this.w;
  2361. return this;
  2362. },
  2363. dot: function(v) {
  2364. return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
  2365. },
  2366. lengthSq: function() {
  2367. return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
  2368. },
  2369. length: function() {
  2370. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  2371. },
  2372. manhattanLength: function() {
  2373. return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w);
  2374. },
  2375. normalize: function() {
  2376. return this.divideScalar(this.length() || 1);
  2377. },
  2378. setLength: function(length) {
  2379. return this.normalize().multiplyScalar(length);
  2380. },
  2381. lerp: function(v, alpha) {
  2382. this.x += (v.x - this.x) * alpha;
  2383. this.y += (v.y - this.y) * alpha;
  2384. this.z += (v.z - this.z) * alpha;
  2385. this.w += (v.w - this.w) * alpha;
  2386. return this;
  2387. },
  2388. lerpVectors: function(v1, v2, alpha) {
  2389. return this.subVectors(v2, v1).multiplyScalar(alpha).add(v1);
  2390. },
  2391. equals: function(v) {
  2392. return v.x === this.x && v.y === this.y && v.z === this.z && v.w === this.w;
  2393. },
  2394. fromArray: function(array, offset) {
  2395. if (offset === void 0)
  2396. offset = 0;
  2397. this.x = array[offset];
  2398. this.y = array[offset + 1];
  2399. this.z = array[offset + 2];
  2400. this.w = array[offset + 3];
  2401. return this;
  2402. },
  2403. toArray: function(array, offset) {
  2404. if (array === void 0)
  2405. array = [];
  2406. if (offset === void 0)
  2407. offset = 0;
  2408. array[offset] = this.x;
  2409. array[offset + 1] = this.y;
  2410. array[offset + 2] = this.z;
  2411. array[offset + 3] = this.w;
  2412. return array;
  2413. },
  2414. fromBufferAttribute: function(attribute, index, offset) {
  2415. if (offset !== void 0) {
  2416. console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute().");
  2417. }
  2418. this.x = attribute.getX(index);
  2419. this.y = attribute.getY(index);
  2420. this.z = attribute.getZ(index);
  2421. this.w = attribute.getW(index);
  2422. return this;
  2423. }
  2424. });
  2425. function WebGLRenderTarget(width, height, options) {
  2426. this.width = width;
  2427. this.height = height;
  2428. this.scissor = new Vector4(0, 0, width, height);
  2429. this.scissorTest = false;
  2430. this.viewport = new Vector4(0, 0, width, height);
  2431. options = options || {};
  2432. this.texture = new Texture(void 0, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding);
  2433. this.texture.image = {};
  2434. this.texture.image.width = width;
  2435. this.texture.image.height = height;
  2436. this.texture.generateMipmaps = options.generateMipmaps !== void 0 ? options.generateMipmaps : false;
  2437. this.texture.minFilter = options.minFilter !== void 0 ? options.minFilter : LinearFilter;
  2438. this.depthBuffer = options.depthBuffer !== void 0 ? options.depthBuffer : true;
  2439. this.stencilBuffer = options.stencilBuffer !== void 0 ? options.stencilBuffer : true;
  2440. this.depthTexture = options.depthTexture !== void 0 ? options.depthTexture : null;
  2441. }
  2442. WebGLRenderTarget.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
  2443. constructor: WebGLRenderTarget,
  2444. isWebGLRenderTarget: true,
  2445. setSize: function(width, height) {
  2446. if (this.width !== width || this.height !== height) {
  2447. this.width = width;
  2448. this.height = height;
  2449. this.texture.image.width = width;
  2450. this.texture.image.height = height;
  2451. this.dispose();
  2452. }
  2453. this.viewport.set(0, 0, width, height);
  2454. this.scissor.set(0, 0, width, height);
  2455. },
  2456. clone: function() {
  2457. return new this.constructor().copy(this);
  2458. },
  2459. copy: function(source) {
  2460. this.width = source.width;
  2461. this.height = source.height;
  2462. this.viewport.copy(source.viewport);
  2463. this.texture = source.texture.clone();
  2464. this.depthBuffer = source.depthBuffer;
  2465. this.stencilBuffer = source.stencilBuffer;
  2466. this.depthTexture = source.depthTexture;
  2467. return this;
  2468. },
  2469. dispose: function() {
  2470. this.dispatchEvent({ type: "dispose" });
  2471. }
  2472. });
  2473. function WebGLMultisampleRenderTarget(width, height, options) {
  2474. WebGLRenderTarget.call(this, width, height, options);
  2475. this.samples = 4;
  2476. }
  2477. WebGLMultisampleRenderTarget.prototype = Object.assign(Object.create(WebGLRenderTarget.prototype), {
  2478. constructor: WebGLMultisampleRenderTarget,
  2479. isWebGLMultisampleRenderTarget: true,
  2480. copy: function(source) {
  2481. WebGLRenderTarget.prototype.copy.call(this, source);
  2482. this.samples = source.samples;
  2483. return this;
  2484. }
  2485. });
  2486. function Quaternion(x, y, z, w) {
  2487. this._x = x || 0;
  2488. this._y = y || 0;
  2489. this._z = z || 0;
  2490. this._w = w !== void 0 ? w : 1;
  2491. }
  2492. Object.assign(Quaternion, {
  2493. slerp: function(qa, qb, qm, t) {
  2494. return qm.copy(qa).slerp(qb, t);
  2495. },
  2496. slerpFlat: function(dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t) {
  2497. var x0 = src0[srcOffset0 + 0], y0 = src0[srcOffset0 + 1], z0 = src0[srcOffset0 + 2], w0 = src0[srcOffset0 + 3], x1 = src1[srcOffset1 + 0], y1 = src1[srcOffset1 + 1], z1 = src1[srcOffset1 + 2], w1 = src1[srcOffset1 + 3];
  2498. if (w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1) {
  2499. var s = 1 - t, cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1, dir = cos >= 0 ? 1 : -1, sqrSin = 1 - cos * cos;
  2500. if (sqrSin > Number.EPSILON) {
  2501. var sin = Math.sqrt(sqrSin), len = Math.atan2(sin, cos * dir);
  2502. s = Math.sin(s * len) / sin;
  2503. t = Math.sin(t * len) / sin;
  2504. }
  2505. var tDir = t * dir;
  2506. x0 = x0 * s + x1 * tDir;
  2507. y0 = y0 * s + y1 * tDir;
  2508. z0 = z0 * s + z1 * tDir;
  2509. w0 = w0 * s + w1 * tDir;
  2510. if (s === 1 - t) {
  2511. var f = 1 / Math.sqrt(x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0);
  2512. x0 *= f;
  2513. y0 *= f;
  2514. z0 *= f;
  2515. w0 *= f;
  2516. }
  2517. }
  2518. dst[dstOffset] = x0;
  2519. dst[dstOffset + 1] = y0;
  2520. dst[dstOffset + 2] = z0;
  2521. dst[dstOffset + 3] = w0;
  2522. }
  2523. });
  2524. Object.defineProperties(Quaternion.prototype, {
  2525. x: {
  2526. get: function() {
  2527. return this._x;
  2528. },
  2529. set: function(value) {
  2530. this._x = value;
  2531. this._onChangeCallback();
  2532. }
  2533. },
  2534. y: {
  2535. get: function() {
  2536. return this._y;
  2537. },
  2538. set: function(value) {
  2539. this._y = value;
  2540. this._onChangeCallback();
  2541. }
  2542. },
  2543. z: {
  2544. get: function() {
  2545. return this._z;
  2546. },
  2547. set: function(value) {
  2548. this._z = value;
  2549. this._onChangeCallback();
  2550. }
  2551. },
  2552. w: {
  2553. get: function() {
  2554. return this._w;
  2555. },
  2556. set: function(value) {
  2557. this._w = value;
  2558. this._onChangeCallback();
  2559. }
  2560. }
  2561. });
  2562. Object.assign(Quaternion.prototype, {
  2563. isQuaternion: true,
  2564. set: function(x, y, z, w) {
  2565. this._x = x;
  2566. this._y = y;
  2567. this._z = z;
  2568. this._w = w;
  2569. this._onChangeCallback();
  2570. return this;
  2571. },
  2572. clone: function() {
  2573. return new this.constructor(this._x, this._y, this._z, this._w);
  2574. },
  2575. copy: function(quaternion) {
  2576. this._x = quaternion.x;
  2577. this._y = quaternion.y;
  2578. this._z = quaternion.z;
  2579. this._w = quaternion.w;
  2580. this._onChangeCallback();
  2581. return this;
  2582. },
  2583. setFromEuler: function(euler, update) {
  2584. if (!(euler && euler.isEuler)) {
  2585. throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");
  2586. }
  2587. var x = euler._x, y = euler._y, z = euler._z, order = euler.order;
  2588. var cos = Math.cos;
  2589. var sin = Math.sin;
  2590. var c1 = cos(x / 2);
  2591. var c2 = cos(y / 2);
  2592. var c3 = cos(z / 2);
  2593. var s1 = sin(x / 2);
  2594. var s2 = sin(y / 2);
  2595. var s3 = sin(z / 2);
  2596. if (order === "XYZ") {
  2597. this._x = s1 * c2 * c3 + c1 * s2 * s3;
  2598. this._y = c1 * s2 * c3 - s1 * c2 * s3;
  2599. this._z = c1 * c2 * s3 + s1 * s2 * c3;
  2600. this._w = c1 * c2 * c3 - s1 * s2 * s3;
  2601. } else if (order === "YXZ") {
  2602. this._x = s1 * c2 * c3 + c1 * s2 * s3;
  2603. this._y = c1 * s2 * c3 - s1 * c2 * s3;
  2604. this._z = c1 * c2 * s3 - s1 * s2 * c3;
  2605. this._w = c1 * c2 * c3 + s1 * s2 * s3;
  2606. } else if (order === "ZXY") {
  2607. this._x = s1 * c2 * c3 - c1 * s2 * s3;
  2608. this._y = c1 * s2 * c3 + s1 * c2 * s3;
  2609. this._z = c1 * c2 * s3 + s1 * s2 * c3;
  2610. this._w = c1 * c2 * c3 - s1 * s2 * s3;
  2611. } else if (order === "ZYX") {
  2612. this._x = s1 * c2 * c3 - c1 * s2 * s3;
  2613. this._y = c1 * s2 * c3 + s1 * c2 * s3;
  2614. this._z = c1 * c2 * s3 - s1 * s2 * c3;
  2615. this._w = c1 * c2 * c3 + s1 * s2 * s3;
  2616. } else if (order === "YZX") {
  2617. this._x = s1 * c2 * c3 + c1 * s2 * s3;
  2618. this._y = c1 * s2 * c3 + s1 * c2 * s3;
  2619. this._z = c1 * c2 * s3 - s1 * s2 * c3;
  2620. this._w = c1 * c2 * c3 - s1 * s2 * s3;
  2621. } else if (order === "XZY") {
  2622. this._x = s1 * c2 * c3 - c1 * s2 * s3;
  2623. this._y = c1 * s2 * c3 - s1 * c2 * s3;
  2624. this._z = c1 * c2 * s3 + s1 * s2 * c3;
  2625. this._w = c1 * c2 * c3 + s1 * s2 * s3;
  2626. }
  2627. if (update !== false)
  2628. this._onChangeCallback();
  2629. return this;
  2630. },
  2631. setFromAxisAngle: function(axis, angle) {
  2632. var halfAngle = angle / 2, s = Math.sin(halfAngle);
  2633. this._x = axis.x * s;
  2634. this._y = axis.y * s;
  2635. this._z = axis.z * s;
  2636. this._w = Math.cos(halfAngle);
  2637. this._onChangeCallback();
  2638. return this;
  2639. },
  2640. setFromRotationMatrix: function(m) {
  2641. var te = m.elements, m11 = te[0], m12 = te[4], m13 = te[8], m21 = te[1], m22 = te[5], m23 = te[9], m31 = te[2], m32 = te[6], m33 = te[10], trace = m11 + m22 + m33, s;
  2642. if (trace > 0) {
  2643. s = 0.5 / Math.sqrt(trace + 1);
  2644. this._w = 0.25 / s;
  2645. this._x = (m32 - m23) * s;
  2646. this._y = (m13 - m31) * s;
  2647. this._z = (m21 - m12) * s;
  2648. } else if (m11 > m22 && m11 > m33) {
  2649. s = 2 * Math.sqrt(1 + m11 - m22 - m33);
  2650. this._w = (m32 - m23) / s;
  2651. this._x = 0.25 * s;
  2652. this._y = (m12 + m21) / s;
  2653. this._z = (m13 + m31) / s;
  2654. } else if (m22 > m33) {
  2655. s = 2 * Math.sqrt(1 + m22 - m11 - m33);
  2656. this._w = (m13 - m31) / s;
  2657. this._x = (m12 + m21) / s;
  2658. this._y = 0.25 * s;
  2659. this._z = (m23 + m32) / s;
  2660. } else {
  2661. s = 2 * Math.sqrt(1 + m33 - m11 - m22);
  2662. this._w = (m21 - m12) / s;
  2663. this._x = (m13 + m31) / s;
  2664. this._y = (m23 + m32) / s;
  2665. this._z = 0.25 * s;
  2666. }
  2667. this._onChangeCallback();
  2668. return this;
  2669. },
  2670. setFromUnitVectors: function(vFrom, vTo) {
  2671. var EPS = 1e-6;
  2672. var r = vFrom.dot(vTo) + 1;
  2673. if (r < EPS) {
  2674. r = 0;
  2675. if (Math.abs(vFrom.x) > Math.abs(vFrom.z)) {
  2676. this._x = -vFrom.y;
  2677. this._y = vFrom.x;
  2678. this._z = 0;
  2679. this._w = r;
  2680. } else {
  2681. this._x = 0;
  2682. this._y = -vFrom.z;
  2683. this._z = vFrom.y;
  2684. this._w = r;
  2685. }
  2686. } else {
  2687. this._x = vFrom.y * vTo.z - vFrom.z * vTo.y;
  2688. this._y = vFrom.z * vTo.x - vFrom.x * vTo.z;
  2689. this._z = vFrom.x * vTo.y - vFrom.y * vTo.x;
  2690. this._w = r;
  2691. }
  2692. return this.normalize();
  2693. },
  2694. angleTo: function(q) {
  2695. return 2 * Math.acos(Math.abs(MathUtils.clamp(this.dot(q), -1, 1)));
  2696. },
  2697. rotateTowards: function(q, step) {
  2698. var angle = this.angleTo(q);
  2699. if (angle === 0)
  2700. return this;
  2701. var t = Math.min(1, step / angle);
  2702. this.slerp(q, t);
  2703. return this;
  2704. },
  2705. inverse: function() {
  2706. return this.conjugate();
  2707. },
  2708. conjugate: function() {
  2709. this._x *= -1;
  2710. this._y *= -1;
  2711. this._z *= -1;
  2712. this._onChangeCallback();
  2713. return this;
  2714. },
  2715. dot: function(v) {
  2716. return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
  2717. },
  2718. lengthSq: function() {
  2719. return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
  2720. },
  2721. length: function() {
  2722. return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
  2723. },
  2724. normalize: function() {
  2725. var l = this.length();
  2726. if (l === 0) {
  2727. this._x = 0;
  2728. this._y = 0;
  2729. this._z = 0;
  2730. this._w = 1;
  2731. } else {
  2732. l = 1 / l;
  2733. this._x = this._x * l;
  2734. this._y = this._y * l;
  2735. this._z = this._z * l;
  2736. this._w = this._w * l;
  2737. }
  2738. this._onChangeCallback();
  2739. return this;
  2740. },
  2741. multiply: function(q, p) {
  2742. if (p !== void 0) {
  2743. console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.");
  2744. return this.multiplyQuaternions(q, p);
  2745. }
  2746. return this.multiplyQuaternions(this, q);
  2747. },
  2748. premultiply: function(q) {
  2749. return this.multiplyQuaternions(q, this);
  2750. },
  2751. multiplyQuaternions: function(a, b) {
  2752. var qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;
  2753. var qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;
  2754. this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
  2755. this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
  2756. this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
  2757. this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
  2758. this._onChangeCallback();
  2759. return this;
  2760. },
  2761. slerp: function(qb, t) {
  2762. if (t === 0)
  2763. return this;
  2764. if (t === 1)
  2765. return this.copy(qb);
  2766. var x = this._x, y = this._y, z = this._z, w = this._w;
  2767. var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;
  2768. if (cosHalfTheta < 0) {
  2769. this._w = -qb._w;
  2770. this._x = -qb._x;
  2771. this._y = -qb._y;
  2772. this._z = -qb._z;
  2773. cosHalfTheta = -cosHalfTheta;
  2774. } else {
  2775. this.copy(qb);
  2776. }
  2777. if (cosHalfTheta >= 1) {
  2778. this._w = w;
  2779. this._x = x;
  2780. this._y = y;
  2781. this._z = z;
  2782. return this;
  2783. }
  2784. var sqrSinHalfTheta = 1 - cosHalfTheta * cosHalfTheta;
  2785. if (sqrSinHalfTheta <= Number.EPSILON) {
  2786. var s = 1 - t;
  2787. this._w = s * w + t * this._w;
  2788. this._x = s * x + t * this._x;
  2789. this._y = s * y + t * this._y;
  2790. this._z = s * z + t * this._z;
  2791. this.normalize();
  2792. this._onChangeCallback();
  2793. return this;
  2794. }
  2795. var sinHalfTheta = Math.sqrt(sqrSinHalfTheta);
  2796. var halfTheta = Math.atan2(sinHalfTheta, cosHalfTheta);
  2797. var ratioA = Math.sin((1 - t) * halfTheta) / sinHalfTheta, ratioB = Math.sin(t * halfTheta) / sinHalfTheta;
  2798. this._w = w * ratioA + this._w * ratioB;
  2799. this._x = x * ratioA + this._x * ratioB;
  2800. this._y = y * ratioA + this._y * ratioB;
  2801. this._z = z * ratioA + this._z * ratioB;
  2802. this._onChangeCallback();
  2803. return this;
  2804. },
  2805. equals: function(quaternion) {
  2806. return quaternion._x === this._x && quaternion._y === this._y && quaternion._z === this._z && quaternion._w === this._w;
  2807. },
  2808. fromArray: function(array, offset) {
  2809. if (offset === void 0)
  2810. offset = 0;
  2811. this._x = array[offset];
  2812. this._y = array[offset + 1];
  2813. this._z = array[offset + 2];
  2814. this._w = array[offset + 3];
  2815. this._onChangeCallback();
  2816. return this;
  2817. },
  2818. toArray: function(array, offset) {
  2819. if (array === void 0)
  2820. array = [];
  2821. if (offset === void 0)
  2822. offset = 0;
  2823. array[offset] = this._x;
  2824. array[offset + 1] = this._y;
  2825. array[offset + 2] = this._z;
  2826. array[offset + 3] = this._w;
  2827. return array;
  2828. },
  2829. _onChange: function(callback) {
  2830. this._onChangeCallback = callback;
  2831. return this;
  2832. },
  2833. _onChangeCallback: function() {
  2834. }
  2835. });
  2836. var _vector = new Vector3();
  2837. var _quaternion = new Quaternion();
  2838. function Vector3(x, y, z) {
  2839. this.x = x || 0;
  2840. this.y = y || 0;
  2841. this.z = z || 0;
  2842. }
  2843. Object.assign(Vector3.prototype, {
  2844. isVector3: true,
  2845. set: function(x, y, z) {
  2846. this.x = x;
  2847. this.y = y;
  2848. this.z = z;
  2849. return this;
  2850. },
  2851. setScalar: function(scalar) {
  2852. this.x = scalar;
  2853. this.y = scalar;
  2854. this.z = scalar;
  2855. return this;
  2856. },
  2857. setX: function(x) {
  2858. this.x = x;
  2859. return this;
  2860. },
  2861. setY: function(y) {
  2862. this.y = y;
  2863. return this;
  2864. },
  2865. setZ: function(z) {
  2866. this.z = z;
  2867. return this;
  2868. },
  2869. setComponent: function(index, value) {
  2870. switch (index) {
  2871. case 0:
  2872. this.x = value;
  2873. break;
  2874. case 1:
  2875. this.y = value;
  2876. break;
  2877. case 2:
  2878. this.z = value;
  2879. break;
  2880. default:
  2881. throw new Error("index is out of range: " + index);
  2882. }
  2883. return this;
  2884. },
  2885. getComponent: function(index) {
  2886. switch (index) {
  2887. case 0:
  2888. return this.x;
  2889. case 1:
  2890. return this.y;
  2891. case 2:
  2892. return this.z;
  2893. default:
  2894. throw new Error("index is out of range: " + index);
  2895. }
  2896. },
  2897. clone: function() {
  2898. return new this.constructor(this.x, this.y, this.z);
  2899. },
  2900. copy: function(v) {
  2901. this.x = v.x;
  2902. this.y = v.y;
  2903. this.z = v.z;
  2904. return this;
  2905. },
  2906. add: function(v, w) {
  2907. if (w !== void 0) {
  2908. console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.");
  2909. return this.addVectors(v, w);
  2910. }
  2911. this.x += v.x;
  2912. this.y += v.y;
  2913. this.z += v.z;
  2914. return this;
  2915. },
  2916. addScalar: function(s) {
  2917. this.x += s;
  2918. this.y += s;
  2919. this.z += s;
  2920. return this;
  2921. },
  2922. addVectors: function(a, b) {
  2923. this.x = a.x + b.x;
  2924. this.y = a.y + b.y;
  2925. this.z = a.z + b.z;
  2926. return this;
  2927. },
  2928. addScaledVector: function(v, s) {
  2929. this.x += v.x * s;
  2930. this.y += v.y * s;
  2931. this.z += v.z * s;
  2932. return this;
  2933. },
  2934. sub: function(v, w) {
  2935. if (w !== void 0) {
  2936. console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.");
  2937. return this.subVectors(v, w);
  2938. }
  2939. this.x -= v.x;
  2940. this.y -= v.y;
  2941. this.z -= v.z;
  2942. return this;
  2943. },
  2944. subScalar: function(s) {
  2945. this.x -= s;
  2946. this.y -= s;
  2947. this.z -= s;
  2948. return this;
  2949. },
  2950. subVectors: function(a, b) {
  2951. this.x = a.x - b.x;
  2952. this.y = a.y - b.y;
  2953. this.z = a.z - b.z;
  2954. return this;
  2955. },
  2956. multiply: function(v, w) {
  2957. if (w !== void 0) {
  2958. console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.");
  2959. return this.multiplyVectors(v, w);
  2960. }
  2961. this.x *= v.x;
  2962. this.y *= v.y;
  2963. this.z *= v.z;
  2964. return this;
  2965. },
  2966. multiplyScalar: function(scalar) {
  2967. this.x *= scalar;
  2968. this.y *= scalar;
  2969. this.z *= scalar;
  2970. return this;
  2971. },
  2972. multiplyVectors: function(a, b) {
  2973. this.x = a.x * b.x;
  2974. this.y = a.y * b.y;
  2975. this.z = a.z * b.z;
  2976. return this;
  2977. },
  2978. applyEuler: function(euler) {
  2979. if (!(euler && euler.isEuler)) {
  2980. console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");
  2981. }
  2982. return this.applyQuaternion(_quaternion.setFromEuler(euler));
  2983. },
  2984. applyAxisAngle: function(axis, angle) {
  2985. return this.applyQuaternion(_quaternion.setFromAxisAngle(axis, angle));
  2986. },
  2987. applyMatrix3: function(m) {
  2988. var x = this.x, y = this.y, z = this.z;
  2989. var e = m.elements;
  2990. this.x = e[0] * x + e[3] * y + e[6] * z;
  2991. this.y = e[1] * x + e[4] * y + e[7] * z;
  2992. this.z = e[2] * x + e[5] * y + e[8] * z;
  2993. return this;
  2994. },
  2995. applyNormalMatrix: function(m) {
  2996. return this.applyMatrix3(m).normalize();
  2997. },
  2998. applyMatrix4: function(m) {
  2999. var x = this.x, y = this.y, z = this.z;
  3000. var e = m.elements;
  3001. var w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);
  3002. this.x = (e[0] * x + e[4] * y + e[8] * z + e[12]) * w;
  3003. this.y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;
  3004. this.z = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;
  3005. return this;
  3006. },
  3007. applyQuaternion: function(q) {
  3008. var x = this.x, y = this.y, z = this.z;
  3009. var qx = q.x, qy = q.y, qz = q.z, qw = q.w;
  3010. var ix = qw * x + qy * z - qz * y;
  3011. var iy = qw * y + qz * x - qx * z;
  3012. var iz = qw * z + qx * y - qy * x;
  3013. var iw = -qx * x - qy * y - qz * z;
  3014. this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy;
  3015. this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
  3016. this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
  3017. return this;
  3018. },
  3019. project: function(camera) {
  3020. return this.applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix);
  3021. },
  3022. unproject: function(camera) {
  3023. return this.applyMatrix4(camera.projectionMatrixInverse).applyMatrix4(camera.matrixWorld);
  3024. },
  3025. transformDirection: function(m) {
  3026. var x = this.x, y = this.y, z = this.z;
  3027. var e = m.elements;
  3028. this.x = e[0] * x + e[4] * y + e[8] * z;
  3029. this.y = e[1] * x + e[5] * y + e[9] * z;
  3030. this.z = e[2] * x + e[6] * y + e[10] * z;
  3031. return this.normalize();
  3032. },
  3033. divide: function(v) {
  3034. this.x /= v.x;
  3035. this.y /= v.y;
  3036. this.z /= v.z;
  3037. return this;
  3038. },
  3039. divideScalar: function(scalar) {
  3040. return this.multiplyScalar(1 / scalar);
  3041. },
  3042. min: function(v) {
  3043. this.x = Math.min(this.x, v.x);
  3044. this.y = Math.min(this.y, v.y);
  3045. this.z = Math.min(this.z, v.z);
  3046. return this;
  3047. },
  3048. max: function(v) {
  3049. this.x = Math.max(this.x, v.x);
  3050. this.y = Math.max(this.y, v.y);
  3051. this.z = Math.max(this.z, v.z);
  3052. return this;
  3053. },
  3054. clamp: function(min, max) {
  3055. this.x = Math.max(min.x, Math.min(max.x, this.x));
  3056. this.y = Math.max(min.y, Math.min(max.y, this.y));
  3057. this.z = Math.max(min.z, Math.min(max.z, this.z));
  3058. return this;
  3059. },
  3060. clampScalar: function(minVal, maxVal) {
  3061. this.x = Math.max(minVal, Math.min(maxVal, this.x));
  3062. this.y = Math.max(minVal, Math.min(maxVal, this.y));
  3063. this.z = Math.max(minVal, Math.min(maxVal, this.z));
  3064. return this;
  3065. },
  3066. clampLength: function(min, max) {
  3067. var length = this.length();
  3068. return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));
  3069. },
  3070. floor: function() {
  3071. this.x = Math.floor(this.x);
  3072. this.y = Math.floor(this.y);
  3073. this.z = Math.floor(this.z);
  3074. return this;
  3075. },
  3076. ceil: function() {
  3077. this.x = Math.ceil(this.x);
  3078. this.y = Math.ceil(this.y);
  3079. this.z = Math.ceil(this.z);
  3080. return this;
  3081. },
  3082. round: function() {
  3083. this.x = Math.round(this.x);
  3084. this.y = Math.round(this.y);
  3085. this.z = Math.round(this.z);
  3086. return this;
  3087. },
  3088. roundToZero: function() {
  3089. this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);
  3090. this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);
  3091. this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z);
  3092. return this;
  3093. },
  3094. negate: function() {
  3095. this.x = -this.x;
  3096. this.y = -this.y;
  3097. this.z = -this.z;
  3098. return this;
  3099. },
  3100. dot: function(v) {
  3101. return this.x * v.x + this.y * v.y + this.z * v.z;
  3102. },
  3103. // TODO lengthSquared?
  3104. lengthSq: function() {
  3105. return this.x * this.x + this.y * this.y + this.z * this.z;
  3106. },
  3107. length: function() {
  3108. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  3109. },
  3110. manhattanLength: function() {
  3111. return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
  3112. },
  3113. normalize: function() {
  3114. return this.divideScalar(this.length() || 1);
  3115. },
  3116. setLength: function(length) {
  3117. return this.normalize().multiplyScalar(length);
  3118. },
  3119. lerp: function(v, alpha) {
  3120. this.x += (v.x - this.x) * alpha;
  3121. this.y += (v.y - this.y) * alpha;
  3122. this.z += (v.z - this.z) * alpha;
  3123. return this;
  3124. },
  3125. lerpVectors: function(v1, v2, alpha) {
  3126. return this.subVectors(v2, v1).multiplyScalar(alpha).add(v1);
  3127. },
  3128. cross: function(v, w) {
  3129. if (w !== void 0) {
  3130. console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.");
  3131. return this.crossVectors(v, w);
  3132. }
  3133. return this.crossVectors(this, v);
  3134. },
  3135. crossVectors: function(a, b) {
  3136. var ax = a.x, ay = a.y, az = a.z;
  3137. var bx = b.x, by = b.y, bz = b.z;
  3138. this.x = ay * bz - az * by;
  3139. this.y = az * bx - ax * bz;
  3140. this.z = ax * by - ay * bx;
  3141. return this;
  3142. },
  3143. projectOnVector: function(v) {
  3144. var denominator = v.lengthSq();
  3145. if (denominator === 0)
  3146. return this.set(0, 0, 0);
  3147. var scalar = v.dot(this) / denominator;
  3148. return this.copy(v).multiplyScalar(scalar);
  3149. },
  3150. projectOnPlane: function(planeNormal) {
  3151. _vector.copy(this).projectOnVector(planeNormal);
  3152. return this.sub(_vector);
  3153. },
  3154. reflect: function(normal) {
  3155. return this.sub(_vector.copy(normal).multiplyScalar(2 * this.dot(normal)));
  3156. },
  3157. angleTo: function(v) {
  3158. var denominator = Math.sqrt(this.lengthSq() * v.lengthSq());
  3159. if (denominator === 0)
  3160. return Math.PI / 2;
  3161. var theta = this.dot(v) / denominator;
  3162. return Math.acos(MathUtils.clamp(theta, -1, 1));
  3163. },
  3164. distanceTo: function(v) {
  3165. return Math.sqrt(this.distanceToSquared(v));
  3166. },
  3167. distanceToSquared: function(v) {
  3168. var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
  3169. return dx * dx + dy * dy + dz * dz;
  3170. },
  3171. manhattanDistanceTo: function(v) {
  3172. return Math.abs(this.x - v.x) + Math.abs(this.y - v.y) + Math.abs(this.z - v.z);
  3173. },
  3174. setFromSpherical: function(s) {
  3175. return this.setFromSphericalCoords(s.radius, s.phi, s.theta);
  3176. },
  3177. setFromSphericalCoords: function(radius, phi, theta) {
  3178. var sinPhiRadius = Math.sin(phi) * radius;
  3179. this.x = sinPhiRadius * Math.sin(theta);
  3180. this.y = Math.cos(phi) * radius;
  3181. this.z = sinPhiRadius * Math.cos(theta);
  3182. return this;
  3183. },
  3184. setFromCylindrical: function(c) {
  3185. return this.setFromCylindricalCoords(c.radius, c.theta, c.y);
  3186. },
  3187. setFromCylindricalCoords: function(radius, theta, y) {
  3188. this.x = radius * Math.sin(theta);
  3189. this.y = y;
  3190. this.z = radius * Math.cos(theta);
  3191. return this;
  3192. },
  3193. setFromMatrixPosition: function(m) {
  3194. var e = m.elements;
  3195. this.x = e[12];
  3196. this.y = e[13];
  3197. this.z = e[14];
  3198. return this;
  3199. },
  3200. setFromMatrixScale: function(m) {
  3201. var sx = this.setFromMatrixColumn(m, 0).length();
  3202. var sy = this.setFromMatrixColumn(m, 1).length();
  3203. var sz = this.setFromMatrixColumn(m, 2).length();
  3204. this.x = sx;
  3205. this.y = sy;
  3206. this.z = sz;
  3207. return this;
  3208. },
  3209. setFromMatrixColumn: function(m, index) {
  3210. return this.fromArray(m.elements, index * 4);
  3211. },
  3212. setFromMatrix3Column: function(m, index) {
  3213. return this.fromArray(m.elements, index * 3);
  3214. },
  3215. equals: function(v) {
  3216. return v.x === this.x && v.y === this.y && v.z === this.z;
  3217. },
  3218. fromArray: function(array, offset) {
  3219. if (offset === void 0)
  3220. offset = 0;
  3221. this.x = array[offset];
  3222. this.y = array[offset + 1];
  3223. this.z = array[offset + 2];
  3224. return this;
  3225. },
  3226. toArray: function(array, offset) {
  3227. if (array === void 0)
  3228. array = [];
  3229. if (offset === void 0)
  3230. offset = 0;
  3231. array[offset] = this.x;
  3232. array[offset + 1] = this.y;
  3233. array[offset + 2] = this.z;
  3234. return array;
  3235. },
  3236. fromBufferAttribute: function(attribute, index, offset) {
  3237. if (offset !== void 0) {
  3238. console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute().");
  3239. }
  3240. this.x = attribute.getX(index);
  3241. this.y = attribute.getY(index);
  3242. this.z = attribute.getZ(index);
  3243. return this;
  3244. }
  3245. });
  3246. var _v1 = new Vector3();
  3247. var _m1 = new Matrix4();
  3248. var _zero = new Vector3(0, 0, 0);
  3249. var _one = new Vector3(1, 1, 1);
  3250. var _x = new Vector3();
  3251. var _y = new Vector3();
  3252. var _z = new Vector3();
  3253. function Matrix4() {
  3254. this.elements = [
  3255. 1,
  3256. 0,
  3257. 0,
  3258. 0,
  3259. 0,
  3260. 1,
  3261. 0,
  3262. 0,
  3263. 0,
  3264. 0,
  3265. 1,
  3266. 0,
  3267. 0,
  3268. 0,
  3269. 0,
  3270. 1
  3271. ];
  3272. if (arguments.length > 0) {
  3273. console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.");
  3274. }
  3275. }
  3276. Object.assign(Matrix4.prototype, {
  3277. isMatrix4: true,
  3278. set: function(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
  3279. var te = this.elements;
  3280. te[0] = n11;
  3281. te[4] = n12;
  3282. te[8] = n13;
  3283. te[12] = n14;
  3284. te[1] = n21;
  3285. te[5] = n22;
  3286. te[9] = n23;
  3287. te[13] = n24;
  3288. te[2] = n31;
  3289. te[6] = n32;
  3290. te[10] = n33;
  3291. te[14] = n34;
  3292. te[3] = n41;
  3293. te[7] = n42;
  3294. te[11] = n43;
  3295. te[15] = n44;
  3296. return this;
  3297. },
  3298. identity: function() {
  3299. this.set(
  3300. 1,
  3301. 0,
  3302. 0,
  3303. 0,
  3304. 0,
  3305. 1,
  3306. 0,
  3307. 0,
  3308. 0,
  3309. 0,
  3310. 1,
  3311. 0,
  3312. 0,
  3313. 0,
  3314. 0,
  3315. 1
  3316. );
  3317. return this;
  3318. },
  3319. clone: function() {
  3320. return new Matrix4().fromArray(this.elements);
  3321. },
  3322. copy: function(m) {
  3323. var te = this.elements;
  3324. var me = m.elements;
  3325. te[0] = me[0];
  3326. te[1] = me[1];
  3327. te[2] = me[2];
  3328. te[3] = me[3];
  3329. te[4] = me[4];
  3330. te[5] = me[5];
  3331. te[6] = me[6];
  3332. te[7] = me[7];
  3333. te[8] = me[8];
  3334. te[9] = me[9];
  3335. te[10] = me[10];
  3336. te[11] = me[11];
  3337. te[12] = me[12];
  3338. te[13] = me[13];
  3339. te[14] = me[14];
  3340. te[15] = me[15];
  3341. return this;
  3342. },
  3343. copyPosition: function(m) {
  3344. var te = this.elements, me = m.elements;
  3345. te[12] = me[12];
  3346. te[13] = me[13];
  3347. te[14] = me[14];
  3348. return this;
  3349. },
  3350. extractBasis: function(xAxis, yAxis, zAxis) {
  3351. xAxis.setFromMatrixColumn(this, 0);
  3352. yAxis.setFromMatrixColumn(this, 1);
  3353. zAxis.setFromMatrixColumn(this, 2);
  3354. return this;
  3355. },
  3356. makeBasis: function(xAxis, yAxis, zAxis) {
  3357. this.set(
  3358. xAxis.x,
  3359. yAxis.x,
  3360. zAxis.x,
  3361. 0,
  3362. xAxis.y,
  3363. yAxis.y,
  3364. zAxis.y,
  3365. 0,
  3366. xAxis.z,
  3367. yAxis.z,
  3368. zAxis.z,
  3369. 0,
  3370. 0,
  3371. 0,
  3372. 0,
  3373. 1
  3374. );
  3375. return this;
  3376. },
  3377. extractRotation: function(m) {
  3378. var te = this.elements;
  3379. var me = m.elements;
  3380. var scaleX = 1 / _v1.setFromMatrixColumn(m, 0).length();
  3381. var scaleY = 1 / _v1.setFromMatrixColumn(m, 1).length();
  3382. var scaleZ = 1 / _v1.setFromMatrixColumn(m, 2).length();
  3383. te[0] = me[0] * scaleX;
  3384. te[1] = me[1] * scaleX;
  3385. te[2] = me[2] * scaleX;
  3386. te[3] = 0;
  3387. te[4] = me[4] * scaleY;
  3388. te[5] = me[5] * scaleY;
  3389. te[6] = me[6] * scaleY;
  3390. te[7] = 0;
  3391. te[8] = me[8] * scaleZ;
  3392. te[9] = me[9] * scaleZ;
  3393. te[10] = me[10] * scaleZ;
  3394. te[11] = 0;
  3395. te[12] = 0;
  3396. te[13] = 0;
  3397. te[14] = 0;
  3398. te[15] = 1;
  3399. return this;
  3400. },
  3401. makeRotationFromEuler: function(euler) {
  3402. if (!(euler && euler.isEuler)) {
  3403. console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");
  3404. }
  3405. var te = this.elements;
  3406. var x = euler.x, y = euler.y, z = euler.z;
  3407. var a = Math.cos(x), b = Math.sin(x);
  3408. var c = Math.cos(y), d = Math.sin(y);
  3409. var e = Math.cos(z), f = Math.sin(z);
  3410. if (euler.order === "XYZ") {
  3411. var ae = a * e, af = a * f, be = b * e, bf = b * f;
  3412. te[0] = c * e;
  3413. te[4] = -c * f;
  3414. te[8] = d;
  3415. te[1] = af + be * d;
  3416. te[5] = ae - bf * d;
  3417. te[9] = -b * c;
  3418. te[2] = bf - ae * d;
  3419. te[6] = be + af * d;
  3420. te[10] = a * c;
  3421. } else if (euler.order === "YXZ") {
  3422. var ce = c * e, cf = c * f, de = d * e, df = d * f;
  3423. te[0] = ce + df * b;
  3424. te[4] = de * b - cf;
  3425. te[8] = a * d;
  3426. te[1] = a * f;
  3427. te[5] = a * e;
  3428. te[9] = -b;
  3429. te[2] = cf * b - de;
  3430. te[6] = df + ce * b;
  3431. te[10] = a * c;
  3432. } else if (euler.order === "ZXY") {
  3433. var ce = c * e, cf = c * f, de = d * e, df = d * f;
  3434. te[0] = ce - df * b;
  3435. te[4] = -a * f;
  3436. te[8] = de + cf * b;
  3437. te[1] = cf + de * b;
  3438. te[5] = a * e;
  3439. te[9] = df - ce * b;
  3440. te[2] = -a * d;
  3441. te[6] = b;
  3442. te[10] = a * c;
  3443. } else if (euler.order === "ZYX") {
  3444. var ae = a * e, af = a * f, be = b * e, bf = b * f;
  3445. te[0] = c * e;
  3446. te[4] = be * d - af;
  3447. te[8] = ae * d + bf;
  3448. te[1] = c * f;
  3449. te[5] = bf * d + ae;
  3450. te[9] = af * d - be;
  3451. te[2] = -d;
  3452. te[6] = b * c;
  3453. te[10] = a * c;
  3454. } else if (euler.order === "YZX") {
  3455. var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
  3456. te[0] = c * e;
  3457. te[4] = bd - ac * f;
  3458. te[8] = bc * f + ad;
  3459. te[1] = f;
  3460. te[5] = a * e;
  3461. te[9] = -b * e;
  3462. te[2] = -d * e;
  3463. te[6] = ad * f + bc;
  3464. te[10] = ac - bd * f;
  3465. } else if (euler.order === "XZY") {
  3466. var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
  3467. te[0] = c * e;
  3468. te[4] = -f;
  3469. te[8] = d * e;
  3470. te[1] = ac * f + bd;
  3471. te[5] = a * e;
  3472. te[9] = ad * f - bc;
  3473. te[2] = bc * f - ad;
  3474. te[6] = b * e;
  3475. te[10] = bd * f + ac;
  3476. }
  3477. te[3] = 0;
  3478. te[7] = 0;
  3479. te[11] = 0;
  3480. te[12] = 0;
  3481. te[13] = 0;
  3482. te[14] = 0;
  3483. te[15] = 1;
  3484. return this;
  3485. },
  3486. makeRotationFromQuaternion: function(q) {
  3487. return this.compose(_zero, q, _one);
  3488. },
  3489. lookAt: function(eye, target, up) {
  3490. var te = this.elements;
  3491. _z.subVectors(eye, target);
  3492. if (_z.lengthSq() === 0) {
  3493. _z.z = 1;
  3494. }
  3495. _z.normalize();
  3496. _x.crossVectors(up, _z);
  3497. if (_x.lengthSq() === 0) {
  3498. if (Math.abs(up.z) === 1) {
  3499. _z.x += 1e-4;
  3500. } else {
  3501. _z.z += 1e-4;
  3502. }
  3503. _z.normalize();
  3504. _x.crossVectors(up, _z);
  3505. }
  3506. _x.normalize();
  3507. _y.crossVectors(_z, _x);
  3508. te[0] = _x.x;
  3509. te[4] = _y.x;
  3510. te[8] = _z.x;
  3511. te[1] = _x.y;
  3512. te[5] = _y.y;
  3513. te[9] = _z.y;
  3514. te[2] = _x.z;
  3515. te[6] = _y.z;
  3516. te[10] = _z.z;
  3517. return this;
  3518. },
  3519. multiply: function(m, n) {
  3520. if (n !== void 0) {
  3521. console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.");
  3522. return this.multiplyMatrices(m, n);
  3523. }
  3524. return this.multiplyMatrices(this, m);
  3525. },
  3526. premultiply: function(m) {
  3527. return this.multiplyMatrices(m, this);
  3528. },
  3529. multiplyMatrices: function(a, b) {
  3530. var ae = a.elements;
  3531. var be = b.elements;
  3532. var te = this.elements;
  3533. var a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
  3534. var a21 = ae[1], a22 = ae[5], a23 = ae[9], a24 = ae[13];
  3535. var a31 = ae[2], a32 = ae[6], a33 = ae[10], a34 = ae[14];
  3536. var a41 = ae[3], a42 = ae[7], a43 = ae[11], a44 = ae[15];
  3537. var b11 = be[0], b12 = be[4], b13 = be[8], b14 = be[12];
  3538. var b21 = be[1], b22 = be[5], b23 = be[9], b24 = be[13];
  3539. var b31 = be[2], b32 = be[6], b33 = be[10], b34 = be[14];
  3540. var b41 = be[3], b42 = be[7], b43 = be[11], b44 = be[15];
  3541. te[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
  3542. te[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
  3543. te[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
  3544. te[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
  3545. te[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
  3546. te[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
  3547. te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
  3548. te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
  3549. te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
  3550. te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
  3551. te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
  3552. te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
  3553. te[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
  3554. te[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
  3555. te[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
  3556. te[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
  3557. return this;
  3558. },
  3559. multiplyScalar: function(s) {
  3560. var te = this.elements;
  3561. te[0] *= s;
  3562. te[4] *= s;
  3563. te[8] *= s;
  3564. te[12] *= s;
  3565. te[1] *= s;
  3566. te[5] *= s;
  3567. te[9] *= s;
  3568. te[13] *= s;
  3569. te[2] *= s;
  3570. te[6] *= s;
  3571. te[10] *= s;
  3572. te[14] *= s;
  3573. te[3] *= s;
  3574. te[7] *= s;
  3575. te[11] *= s;
  3576. te[15] *= s;
  3577. return this;
  3578. },
  3579. determinant: function() {
  3580. var te = this.elements;
  3581. var n11 = te[0], n12 = te[4], n13 = te[8], n14 = te[12];
  3582. var n21 = te[1], n22 = te[5], n23 = te[9], n24 = te[13];
  3583. var n31 = te[2], n32 = te[6], n33 = te[10], n34 = te[14];
  3584. var n41 = te[3], n42 = te[7], n43 = te[11], n44 = te[15];
  3585. return n41 * (+n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34) + n42 * (+n11 * n23 * n34 - n11 * n24 * n33 + n14 * n21 * n33 - n13 * n21 * n34 + n13 * n24 * n31 - n14 * n23 * n31) + n43 * (+n11 * n24 * n32 - n11 * n22 * n34 - n14 * n21 * n32 + n12 * n21 * n34 + n14 * n22 * n31 - n12 * n24 * n31) + n44 * (-n13 * n22 * n31 - n11 * n23 * n32 + n11 * n22 * n33 + n13 * n21 * n32 - n12 * n21 * n33 + n12 * n23 * n31);
  3586. },
  3587. transpose: function() {
  3588. var te = this.elements;
  3589. var tmp2;
  3590. tmp2 = te[1];
  3591. te[1] = te[4];
  3592. te[4] = tmp2;
  3593. tmp2 = te[2];
  3594. te[2] = te[8];
  3595. te[8] = tmp2;
  3596. tmp2 = te[6];
  3597. te[6] = te[9];
  3598. te[9] = tmp2;
  3599. tmp2 = te[3];
  3600. te[3] = te[12];
  3601. te[12] = tmp2;
  3602. tmp2 = te[7];
  3603. te[7] = te[13];
  3604. te[13] = tmp2;
  3605. tmp2 = te[11];
  3606. te[11] = te[14];
  3607. te[14] = tmp2;
  3608. return this;
  3609. },
  3610. setPosition: function(x, y, z) {
  3611. var te = this.elements;
  3612. if (x.isVector3) {
  3613. te[12] = x.x;
  3614. te[13] = x.y;
  3615. te[14] = x.z;
  3616. } else {
  3617. te[12] = x;
  3618. te[13] = y;
  3619. te[14] = z;
  3620. }
  3621. return this;
  3622. },
  3623. getInverse: function(m, throwOnDegenerate) {
  3624. var te = this.elements, me = m.elements, n11 = me[0], n21 = me[1], n31 = me[2], n41 = me[3], n12 = me[4], n22 = me[5], n32 = me[6], n42 = me[7], n13 = me[8], n23 = me[9], n33 = me[10], n43 = me[11], n14 = me[12], n24 = me[13], n34 = me[14], n44 = me[15], t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44, t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44, t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44, t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;
  3625. var det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
  3626. if (det === 0) {
  3627. var msg = "THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0";
  3628. if (throwOnDegenerate === true) {
  3629. throw new Error(msg);
  3630. } else {
  3631. console.warn(msg);
  3632. }
  3633. return this.identity();
  3634. }
  3635. var detInv = 1 / det;
  3636. te[0] = t11 * detInv;
  3637. te[1] = (n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44) * detInv;
  3638. te[2] = (n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44) * detInv;
  3639. te[3] = (n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43) * detInv;
  3640. te[4] = t12 * detInv;
  3641. te[5] = (n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44) * detInv;
  3642. te[6] = (n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44) * detInv;
  3643. te[7] = (n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43) * detInv;
  3644. te[8] = t13 * detInv;
  3645. te[9] = (n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44) * detInv;
  3646. te[10] = (n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44) * detInv;
  3647. te[11] = (n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43) * detInv;
  3648. te[12] = t14 * detInv;
  3649. te[13] = (n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34) * detInv;
  3650. te[14] = (n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34) * detInv;
  3651. te[15] = (n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33) * detInv;
  3652. return this;
  3653. },
  3654. scale: function(v) {
  3655. var te = this.elements;
  3656. var x = v.x, y = v.y, z = v.z;
  3657. te[0] *= x;
  3658. te[4] *= y;
  3659. te[8] *= z;
  3660. te[1] *= x;
  3661. te[5] *= y;
  3662. te[9] *= z;
  3663. te[2] *= x;
  3664. te[6] *= y;
  3665. te[10] *= z;
  3666. te[3] *= x;
  3667. te[7] *= y;
  3668. te[11] *= z;
  3669. return this;
  3670. },
  3671. getMaxScaleOnAxis: function() {
  3672. var te = this.elements;
  3673. var scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2];
  3674. var scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6];
  3675. var scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10];
  3676. return Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));
  3677. },
  3678. makeTranslation: function(x, y, z) {
  3679. this.set(
  3680. 1,
  3681. 0,
  3682. 0,
  3683. x,
  3684. 0,
  3685. 1,
  3686. 0,
  3687. y,
  3688. 0,
  3689. 0,
  3690. 1,
  3691. z,
  3692. 0,
  3693. 0,
  3694. 0,
  3695. 1
  3696. );
  3697. return this;
  3698. },
  3699. makeRotationX: function(theta) {
  3700. var c = Math.cos(theta), s = Math.sin(theta);
  3701. this.set(
  3702. 1,
  3703. 0,
  3704. 0,
  3705. 0,
  3706. 0,
  3707. c,
  3708. -s,
  3709. 0,
  3710. 0,
  3711. s,
  3712. c,
  3713. 0,
  3714. 0,
  3715. 0,
  3716. 0,
  3717. 1
  3718. );
  3719. return this;
  3720. },
  3721. makeRotationY: function(theta) {
  3722. var c = Math.cos(theta), s = Math.sin(theta);
  3723. this.set(
  3724. c,
  3725. 0,
  3726. s,
  3727. 0,
  3728. 0,
  3729. 1,
  3730. 0,
  3731. 0,
  3732. -s,
  3733. 0,
  3734. c,
  3735. 0,
  3736. 0,
  3737. 0,
  3738. 0,
  3739. 1
  3740. );
  3741. return this;
  3742. },
  3743. makeRotationZ: function(theta) {
  3744. var c = Math.cos(theta), s = Math.sin(theta);
  3745. this.set(
  3746. c,
  3747. -s,
  3748. 0,
  3749. 0,
  3750. s,
  3751. c,
  3752. 0,
  3753. 0,
  3754. 0,
  3755. 0,
  3756. 1,
  3757. 0,
  3758. 0,
  3759. 0,
  3760. 0,
  3761. 1
  3762. );
  3763. return this;
  3764. },
  3765. makeRotationAxis: function(axis, angle) {
  3766. var c = Math.cos(angle);
  3767. var s = Math.sin(angle);
  3768. var t = 1 - c;
  3769. var x = axis.x, y = axis.y, z = axis.z;
  3770. var tx = t * x, ty = t * y;
  3771. this.set(
  3772. tx * x + c,
  3773. tx * y - s * z,
  3774. tx * z + s * y,
  3775. 0,
  3776. tx * y + s * z,
  3777. ty * y + c,
  3778. ty * z - s * x,
  3779. 0,
  3780. tx * z - s * y,
  3781. ty * z + s * x,
  3782. t * z * z + c,
  3783. 0,
  3784. 0,
  3785. 0,
  3786. 0,
  3787. 1
  3788. );
  3789. return this;
  3790. },
  3791. makeScale: function(x, y, z) {
  3792. this.set(
  3793. x,
  3794. 0,
  3795. 0,
  3796. 0,
  3797. 0,
  3798. y,
  3799. 0,
  3800. 0,
  3801. 0,
  3802. 0,
  3803. z,
  3804. 0,
  3805. 0,
  3806. 0,
  3807. 0,
  3808. 1
  3809. );
  3810. return this;
  3811. },
  3812. makeShear: function(x, y, z) {
  3813. this.set(
  3814. 1,
  3815. y,
  3816. z,
  3817. 0,
  3818. x,
  3819. 1,
  3820. z,
  3821. 0,
  3822. x,
  3823. y,
  3824. 1,
  3825. 0,
  3826. 0,
  3827. 0,
  3828. 0,
  3829. 1
  3830. );
  3831. return this;
  3832. },
  3833. compose: function(position, quaternion, scale) {
  3834. var te = this.elements;
  3835. var x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;
  3836. var x2 = x + x, y2 = y + y, z2 = z + z;
  3837. var xx = x * x2, xy = x * y2, xz = x * z2;
  3838. var yy = y * y2, yz = y * z2, zz = z * z2;
  3839. var wx = w * x2, wy = w * y2, wz = w * z2;
  3840. var sx = scale.x, sy = scale.y, sz = scale.z;
  3841. te[0] = (1 - (yy + zz)) * sx;
  3842. te[1] = (xy + wz) * sx;
  3843. te[2] = (xz - wy) * sx;
  3844. te[3] = 0;
  3845. te[4] = (xy - wz) * sy;
  3846. te[5] = (1 - (xx + zz)) * sy;
  3847. te[6] = (yz + wx) * sy;
  3848. te[7] = 0;
  3849. te[8] = (xz + wy) * sz;
  3850. te[9] = (yz - wx) * sz;
  3851. te[10] = (1 - (xx + yy)) * sz;
  3852. te[11] = 0;
  3853. te[12] = position.x;
  3854. te[13] = position.y;
  3855. te[14] = position.z;
  3856. te[15] = 1;
  3857. return this;
  3858. },
  3859. decompose: function(position, quaternion, scale) {
  3860. var te = this.elements;
  3861. var sx = _v1.set(te[0], te[1], te[2]).length();
  3862. var sy = _v1.set(te[4], te[5], te[6]).length();
  3863. var sz = _v1.set(te[8], te[9], te[10]).length();
  3864. var det = this.determinant();
  3865. if (det < 0)
  3866. sx = -sx;
  3867. position.x = te[12];
  3868. position.y = te[13];
  3869. position.z = te[14];
  3870. _m1.copy(this);
  3871. var invSX = 1 / sx;
  3872. var invSY = 1 / sy;
  3873. var invSZ = 1 / sz;
  3874. _m1.elements[0] *= invSX;
  3875. _m1.elements[1] *= invSX;
  3876. _m1.elements[2] *= invSX;
  3877. _m1.elements[4] *= invSY;
  3878. _m1.elements[5] *= invSY;
  3879. _m1.elements[6] *= invSY;
  3880. _m1.elements[8] *= invSZ;
  3881. _m1.elements[9] *= invSZ;
  3882. _m1.elements[10] *= invSZ;
  3883. quaternion.setFromRotationMatrix(_m1);
  3884. scale.x = sx;
  3885. scale.y = sy;
  3886. scale.z = sz;
  3887. return this;
  3888. },
  3889. makePerspective: function(left, right, top2, bottom, near, far) {
  3890. if (far === void 0) {
  3891. console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");
  3892. }
  3893. var te = this.elements;
  3894. var x = 2 * near / (right - left);
  3895. var y = 2 * near / (top2 - bottom);
  3896. var a = (right + left) / (right - left);
  3897. var b = (top2 + bottom) / (top2 - bottom);
  3898. var c = -(far + near) / (far - near);
  3899. var d = -2 * far * near / (far - near);
  3900. te[0] = x;
  3901. te[4] = 0;
  3902. te[8] = a;
  3903. te[12] = 0;
  3904. te[1] = 0;
  3905. te[5] = y;
  3906. te[9] = b;
  3907. te[13] = 0;
  3908. te[2] = 0;
  3909. te[6] = 0;
  3910. te[10] = c;
  3911. te[14] = d;
  3912. te[3] = 0;
  3913. te[7] = 0;
  3914. te[11] = -1;
  3915. te[15] = 0;
  3916. return this;
  3917. },
  3918. makeOrthographic: function(left, right, top2, bottom, near, far) {
  3919. var te = this.elements;
  3920. var w = 1 / (right - left);
  3921. var h = 1 / (top2 - bottom);
  3922. var p = 1 / (far - near);
  3923. var x = (right + left) * w;
  3924. var y = (top2 + bottom) * h;
  3925. var z = (far + near) * p;
  3926. te[0] = 2 * w;
  3927. te[4] = 0;
  3928. te[8] = 0;
  3929. te[12] = -x;
  3930. te[1] = 0;
  3931. te[5] = 2 * h;
  3932. te[9] = 0;
  3933. te[13] = -y;
  3934. te[2] = 0;
  3935. te[6] = 0;
  3936. te[10] = -2 * p;
  3937. te[14] = -z;
  3938. te[3] = 0;
  3939. te[7] = 0;
  3940. te[11] = 0;
  3941. te[15] = 1;
  3942. return this;
  3943. },
  3944. equals: function(matrix) {
  3945. var te = this.elements;
  3946. var me = matrix.elements;
  3947. for (var i2 = 0; i2 < 16; i2++) {
  3948. if (te[i2] !== me[i2])
  3949. return false;
  3950. }
  3951. return true;
  3952. },
  3953. fromArray: function(array, offset) {
  3954. if (offset === void 0)
  3955. offset = 0;
  3956. for (var i2 = 0; i2 < 16; i2++) {
  3957. this.elements[i2] = array[i2 + offset];
  3958. }
  3959. return this;
  3960. },
  3961. toArray: function(array, offset) {
  3962. if (array === void 0)
  3963. array = [];
  3964. if (offset === void 0)
  3965. offset = 0;
  3966. var te = this.elements;
  3967. array[offset] = te[0];
  3968. array[offset + 1] = te[1];
  3969. array[offset + 2] = te[2];
  3970. array[offset + 3] = te[3];
  3971. array[offset + 4] = te[4];
  3972. array[offset + 5] = te[5];
  3973. array[offset + 6] = te[6];
  3974. array[offset + 7] = te[7];
  3975. array[offset + 8] = te[8];
  3976. array[offset + 9] = te[9];
  3977. array[offset + 10] = te[10];
  3978. array[offset + 11] = te[11];
  3979. array[offset + 12] = te[12];
  3980. array[offset + 13] = te[13];
  3981. array[offset + 14] = te[14];
  3982. array[offset + 15] = te[15];
  3983. return array;
  3984. }
  3985. });
  3986. var _matrix = new Matrix4();
  3987. var _quaternion$1 = new Quaternion();
  3988. function Euler(x, y, z, order) {
  3989. this._x = x || 0;
  3990. this._y = y || 0;
  3991. this._z = z || 0;
  3992. this._order = order || Euler.DefaultOrder;
  3993. }
  3994. Euler.RotationOrders = ["XYZ", "YZX", "ZXY", "XZY", "YXZ", "ZYX"];
  3995. Euler.DefaultOrder = "XYZ";
  3996. Object.defineProperties(Euler.prototype, {
  3997. x: {
  3998. get: function() {
  3999. return this._x;
  4000. },
  4001. set: function(value) {
  4002. this._x = value;
  4003. this._onChangeCallback();
  4004. }
  4005. },
  4006. y: {
  4007. get: function() {
  4008. return this._y;
  4009. },
  4010. set: function(value) {
  4011. this._y = value;
  4012. this._onChangeCallback();
  4013. }
  4014. },
  4015. z: {
  4016. get: function() {
  4017. return this._z;
  4018. },
  4019. set: function(value) {
  4020. this._z = value;
  4021. this._onChangeCallback();
  4022. }
  4023. },
  4024. order: {
  4025. get: function() {
  4026. return this._order;
  4027. },
  4028. set: function(value) {
  4029. this._order = value;
  4030. this._onChangeCallback();
  4031. }
  4032. }
  4033. });
  4034. Object.assign(Euler.prototype, {
  4035. isEuler: true,
  4036. set: function(x, y, z, order) {
  4037. this._x = x;
  4038. this._y = y;
  4039. this._z = z;
  4040. this._order = order || this._order;
  4041. this._onChangeCallback();
  4042. return this;
  4043. },
  4044. clone: function() {
  4045. return new this.constructor(this._x, this._y, this._z, this._order);
  4046. },
  4047. copy: function(euler) {
  4048. this._x = euler._x;
  4049. this._y = euler._y;
  4050. this._z = euler._z;
  4051. this._order = euler._order;
  4052. this._onChangeCallback();
  4053. return this;
  4054. },
  4055. setFromRotationMatrix: function(m, order, update) {
  4056. var clamp = MathUtils.clamp;
  4057. var te = m.elements;
  4058. var m11 = te[0], m12 = te[4], m13 = te[8];
  4059. var m21 = te[1], m22 = te[5], m23 = te[9];
  4060. var m31 = te[2], m32 = te[6], m33 = te[10];
  4061. order = order || this._order;
  4062. if (order === "XYZ") {
  4063. this._y = Math.asin(clamp(m13, -1, 1));
  4064. if (Math.abs(m13) < 0.9999999) {
  4065. this._x = Math.atan2(-m23, m33);
  4066. this._z = Math.atan2(-m12, m11);
  4067. } else {
  4068. this._x = Math.atan2(m32, m22);
  4069. this._z = 0;
  4070. }
  4071. } else if (order === "YXZ") {
  4072. this._x = Math.asin(-clamp(m23, -1, 1));
  4073. if (Math.abs(m23) < 0.9999999) {
  4074. this._y = Math.atan2(m13, m33);
  4075. this._z = Math.atan2(m21, m22);
  4076. } else {
  4077. this._y = Math.atan2(-m31, m11);
  4078. this._z = 0;
  4079. }
  4080. } else if (order === "ZXY") {
  4081. this._x = Math.asin(clamp(m32, -1, 1));
  4082. if (Math.abs(m32) < 0.9999999) {
  4083. this._y = Math.atan2(-m31, m33);
  4084. this._z = Math.atan2(-m12, m22);
  4085. } else {
  4086. this._y = 0;
  4087. this._z = Math.atan2(m21, m11);
  4088. }
  4089. } else if (order === "ZYX") {
  4090. this._y = Math.asin(-clamp(m31, -1, 1));
  4091. if (Math.abs(m31) < 0.9999999) {
  4092. this._x = Math.atan2(m32, m33);
  4093. this._z = Math.atan2(m21, m11);
  4094. } else {
  4095. this._x = 0;
  4096. this._z = Math.atan2(-m12, m22);
  4097. }
  4098. } else if (order === "YZX") {
  4099. this._z = Math.asin(clamp(m21, -1, 1));
  4100. if (Math.abs(m21) < 0.9999999) {
  4101. this._x = Math.atan2(-m23, m22);
  4102. this._y = Math.atan2(-m31, m11);
  4103. } else {
  4104. this._x = 0;
  4105. this._y = Math.atan2(m13, m33);
  4106. }
  4107. } else if (order === "XZY") {
  4108. this._z = Math.asin(-clamp(m12, -1, 1));
  4109. if (Math.abs(m12) < 0.9999999) {
  4110. this._x = Math.atan2(m32, m22);
  4111. this._y = Math.atan2(m13, m11);
  4112. } else {
  4113. this._x = Math.atan2(-m23, m33);
  4114. this._y = 0;
  4115. }
  4116. } else {
  4117. console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: " + order);
  4118. }
  4119. this._order = order;
  4120. if (update !== false)
  4121. this._onChangeCallback();
  4122. return this;
  4123. },
  4124. setFromQuaternion: function(q, order, update) {
  4125. _matrix.makeRotationFromQuaternion(q);
  4126. return this.setFromRotationMatrix(_matrix, order, update);
  4127. },
  4128. setFromVector3: function(v, order) {
  4129. return this.set(v.x, v.y, v.z, order || this._order);
  4130. },
  4131. reorder: function(newOrder) {
  4132. _quaternion$1.setFromEuler(this);
  4133. return this.setFromQuaternion(_quaternion$1, newOrder);
  4134. },
  4135. equals: function(euler) {
  4136. return euler._x === this._x && euler._y === this._y && euler._z === this._z && euler._order === this._order;
  4137. },
  4138. fromArray: function(array) {
  4139. this._x = array[0];
  4140. this._y = array[1];
  4141. this._z = array[2];
  4142. if (array[3] !== void 0)
  4143. this._order = array[3];
  4144. this._onChangeCallback();
  4145. return this;
  4146. },
  4147. toArray: function(array, offset) {
  4148. if (array === void 0)
  4149. array = [];
  4150. if (offset === void 0)
  4151. offset = 0;
  4152. array[offset] = this._x;
  4153. array[offset + 1] = this._y;
  4154. array[offset + 2] = this._z;
  4155. array[offset + 3] = this._order;
  4156. return array;
  4157. },
  4158. toVector3: function(optionalResult) {
  4159. if (optionalResult) {
  4160. return optionalResult.set(this._x, this._y, this._z);
  4161. } else {
  4162. return new Vector3(this._x, this._y, this._z);
  4163. }
  4164. },
  4165. _onChange: function(callback) {
  4166. this._onChangeCallback = callback;
  4167. return this;
  4168. },
  4169. _onChangeCallback: function() {
  4170. }
  4171. });
  4172. function Layers() {
  4173. this.mask = 1 | 0;
  4174. }
  4175. Object.assign(Layers.prototype, {
  4176. set: function(channel) {
  4177. this.mask = 1 << channel | 0;
  4178. },
  4179. enable: function(channel) {
  4180. this.mask |= 1 << channel | 0;
  4181. },
  4182. enableAll: function() {
  4183. this.mask = 4294967295 | 0;
  4184. },
  4185. toggle: function(channel) {
  4186. this.mask ^= 1 << channel | 0;
  4187. },
  4188. disable: function(channel) {
  4189. this.mask &= ~(1 << channel | 0);
  4190. },
  4191. disableAll: function() {
  4192. this.mask = 0;
  4193. },
  4194. test: function(layers) {
  4195. return (this.mask & layers.mask) !== 0;
  4196. }
  4197. });
  4198. var _object3DId = 0;
  4199. var _v1$1 = new Vector3();
  4200. var _q1 = new Quaternion();
  4201. var _m1$1 = new Matrix4();
  4202. var _target = new Vector3();
  4203. var _position = new Vector3();
  4204. var _scale = new Vector3();
  4205. var _quaternion$2 = new Quaternion();
  4206. var _xAxis = new Vector3(1, 0, 0);
  4207. var _yAxis = new Vector3(0, 1, 0);
  4208. var _zAxis = new Vector3(0, 0, 1);
  4209. var _addedEvent = { type: "added" };
  4210. var _removedEvent = { type: "removed" };
  4211. function Object3D() {
  4212. Object.defineProperty(this, "id", { value: _object3DId++ });
  4213. this.uuid = MathUtils.generateUUID();
  4214. this.name = "";
  4215. this.type = "Object3D";
  4216. this.parent = null;
  4217. this.children = [];
  4218. this.up = Object3D.DefaultUp.clone();
  4219. var position = new Vector3();
  4220. var rotation = new Euler();
  4221. var quaternion = new Quaternion();
  4222. var scale = new Vector3(1, 1, 1);
  4223. function onRotationChange() {
  4224. quaternion.setFromEuler(rotation, false);
  4225. }
  4226. function onQuaternionChange() {
  4227. rotation.setFromQuaternion(quaternion, void 0, false);
  4228. }
  4229. rotation._onChange(onRotationChange);
  4230. quaternion._onChange(onQuaternionChange);
  4231. Object.defineProperties(this, {
  4232. position: {
  4233. configurable: true,
  4234. enumerable: true,
  4235. value: position
  4236. },
  4237. rotation: {
  4238. configurable: true,
  4239. enumerable: true,
  4240. value: rotation
  4241. },
  4242. quaternion: {
  4243. configurable: true,
  4244. enumerable: true,
  4245. value: quaternion
  4246. },
  4247. scale: {
  4248. configurable: true,
  4249. enumerable: true,
  4250. value: scale
  4251. },
  4252. modelViewMatrix: {
  4253. value: new Matrix4()
  4254. },
  4255. normalMatrix: {
  4256. value: new Matrix3()
  4257. }
  4258. });
  4259. this.matrix = new Matrix4();
  4260. this.matrixWorld = new Matrix4();
  4261. this.matrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate;
  4262. this.matrixWorldNeedsUpdate = false;
  4263. this.layers = new Layers();
  4264. this.visible = true;
  4265. this.castShadow = false;
  4266. this.receiveShadow = false;
  4267. this.frustumCulled = true;
  4268. this.renderOrder = 0;
  4269. this.userData = {};
  4270. }
  4271. Object3D.DefaultUp = new Vector3(0, 1, 0);
  4272. Object3D.DefaultMatrixAutoUpdate = true;
  4273. Object3D.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
  4274. constructor: Object3D,
  4275. isObject3D: true,
  4276. onBeforeRender: function() {
  4277. },
  4278. onAfterRender: function() {
  4279. },
  4280. applyMatrix4: function(matrix) {
  4281. if (this.matrixAutoUpdate)
  4282. this.updateMatrix();
  4283. this.matrix.premultiply(matrix);
  4284. this.matrix.decompose(this.position, this.quaternion, this.scale);
  4285. },
  4286. applyQuaternion: function(q) {
  4287. this.quaternion.premultiply(q);
  4288. return this;
  4289. },
  4290. setRotationFromAxisAngle: function(axis, angle) {
  4291. this.quaternion.setFromAxisAngle(axis, angle);
  4292. },
  4293. setRotationFromEuler: function(euler) {
  4294. this.quaternion.setFromEuler(euler, true);
  4295. },
  4296. setRotationFromMatrix: function(m) {
  4297. this.quaternion.setFromRotationMatrix(m);
  4298. },
  4299. setRotationFromQuaternion: function(q) {
  4300. this.quaternion.copy(q);
  4301. },
  4302. rotateOnAxis: function(axis, angle) {
  4303. _q1.setFromAxisAngle(axis, angle);
  4304. this.quaternion.multiply(_q1);
  4305. return this;
  4306. },
  4307. rotateOnWorldAxis: function(axis, angle) {
  4308. _q1.setFromAxisAngle(axis, angle);
  4309. this.quaternion.premultiply(_q1);
  4310. return this;
  4311. },
  4312. rotateX: function(angle) {
  4313. return this.rotateOnAxis(_xAxis, angle);
  4314. },
  4315. rotateY: function(angle) {
  4316. return this.rotateOnAxis(_yAxis, angle);
  4317. },
  4318. rotateZ: function(angle) {
  4319. return this.rotateOnAxis(_zAxis, angle);
  4320. },
  4321. translateOnAxis: function(axis, distance) {
  4322. _v1$1.copy(axis).applyQuaternion(this.quaternion);
  4323. this.position.add(_v1$1.multiplyScalar(distance));
  4324. return this;
  4325. },
  4326. translateX: function(distance) {
  4327. return this.translateOnAxis(_xAxis, distance);
  4328. },
  4329. translateY: function(distance) {
  4330. return this.translateOnAxis(_yAxis, distance);
  4331. },
  4332. translateZ: function(distance) {
  4333. return this.translateOnAxis(_zAxis, distance);
  4334. },
  4335. localToWorld: function(vector) {
  4336. return vector.applyMatrix4(this.matrixWorld);
  4337. },
  4338. worldToLocal: function(vector) {
  4339. return vector.applyMatrix4(_m1$1.getInverse(this.matrixWorld));
  4340. },
  4341. lookAt: function(x, y, z) {
  4342. if (x.isVector3) {
  4343. _target.copy(x);
  4344. } else {
  4345. _target.set(x, y, z);
  4346. }
  4347. var parent = this.parent;
  4348. this.updateWorldMatrix(true, false);
  4349. _position.setFromMatrixPosition(this.matrixWorld);
  4350. if (this.isCamera || this.isLight) {
  4351. _m1$1.lookAt(_position, _target, this.up);
  4352. } else {
  4353. _m1$1.lookAt(_target, _position, this.up);
  4354. }
  4355. this.quaternion.setFromRotationMatrix(_m1$1);
  4356. if (parent) {
  4357. _m1$1.extractRotation(parent.matrixWorld);
  4358. _q1.setFromRotationMatrix(_m1$1);
  4359. this.quaternion.premultiply(_q1.inverse());
  4360. }
  4361. },
  4362. add: function(object) {
  4363. if (arguments.length > 1) {
  4364. for (var i2 = 0; i2 < arguments.length; i2++) {
  4365. this.add(arguments[i2]);
  4366. }
  4367. return this;
  4368. }
  4369. if (object === this) {
  4370. console.error("THREE.Object3D.add: object can't be added as a child of itself.", object);
  4371. return this;
  4372. }
  4373. if (object && object.isObject3D) {
  4374. if (object.parent !== null) {
  4375. object.parent.remove(object);
  4376. }
  4377. object.parent = this;
  4378. this.children.push(object);
  4379. object.dispatchEvent(_addedEvent);
  4380. } else {
  4381. console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", object);
  4382. }
  4383. return this;
  4384. },
  4385. remove: function(object) {
  4386. if (arguments.length > 1) {
  4387. for (var i2 = 0; i2 < arguments.length; i2++) {
  4388. this.remove(arguments[i2]);
  4389. }
  4390. return this;
  4391. }
  4392. var index = this.children.indexOf(object);
  4393. if (index !== -1) {
  4394. object.parent = null;
  4395. this.children.splice(index, 1);
  4396. object.dispatchEvent(_removedEvent);
  4397. }
  4398. return this;
  4399. },
  4400. attach: function(object) {
  4401. this.updateWorldMatrix(true, false);
  4402. _m1$1.getInverse(this.matrixWorld);
  4403. if (object.parent !== null) {
  4404. object.parent.updateWorldMatrix(true, false);
  4405. _m1$1.multiply(object.parent.matrixWorld);
  4406. }
  4407. object.applyMatrix4(_m1$1);
  4408. object.updateWorldMatrix(false, false);
  4409. this.add(object);
  4410. return this;
  4411. },
  4412. getObjectById: function(id) {
  4413. return this.getObjectByProperty("id", id);
  4414. },
  4415. getObjectByName: function(name) {
  4416. return this.getObjectByProperty("name", name);
  4417. },
  4418. getObjectByProperty: function(name, value) {
  4419. if (this[name] === value)
  4420. return this;
  4421. for (var i2 = 0, l = this.children.length; i2 < l; i2++) {
  4422. var child = this.children[i2];
  4423. var object = child.getObjectByProperty(name, value);
  4424. if (object !== void 0) {
  4425. return object;
  4426. }
  4427. }
  4428. return void 0;
  4429. },
  4430. getWorldPosition: function(target) {
  4431. if (target === void 0) {
  4432. console.warn("THREE.Object3D: .getWorldPosition() target is now required");
  4433. target = new Vector3();
  4434. }
  4435. this.updateMatrixWorld(true);
  4436. return target.setFromMatrixPosition(this.matrixWorld);
  4437. },
  4438. getWorldQuaternion: function(target) {
  4439. if (target === void 0) {
  4440. console.warn("THREE.Object3D: .getWorldQuaternion() target is now required");
  4441. target = new Quaternion();
  4442. }
  4443. this.updateMatrixWorld(true);
  4444. this.matrixWorld.decompose(_position, target, _scale);
  4445. return target;
  4446. },
  4447. getWorldScale: function(target) {
  4448. if (target === void 0) {
  4449. console.warn("THREE.Object3D: .getWorldScale() target is now required");
  4450. target = new Vector3();
  4451. }
  4452. this.updateMatrixWorld(true);
  4453. this.matrixWorld.decompose(_position, _quaternion$2, target);
  4454. return target;
  4455. },
  4456. getWorldDirection: function(target) {
  4457. if (target === void 0) {
  4458. console.warn("THREE.Object3D: .getWorldDirection() target is now required");
  4459. target = new Vector3();
  4460. }
  4461. this.updateMatrixWorld(true);
  4462. var e = this.matrixWorld.elements;
  4463. return target.set(e[8], e[9], e[10]).normalize();
  4464. },
  4465. raycast: function() {
  4466. },
  4467. traverse: function(callback) {
  4468. callback(this);
  4469. var children = this.children;
  4470. for (var i2 = 0, l = children.length; i2 < l; i2++) {
  4471. children[i2].traverse(callback);
  4472. }
  4473. },
  4474. traverseVisible: function(callback) {
  4475. if (this.visible === false)
  4476. return;
  4477. callback(this);
  4478. var children = this.children;
  4479. for (var i2 = 0, l = children.length; i2 < l; i2++) {
  4480. children[i2].traverseVisible(callback);
  4481. }
  4482. },
  4483. traverseAncestors: function(callback) {
  4484. var parent = this.parent;
  4485. if (parent !== null) {
  4486. callback(parent);
  4487. parent.traverseAncestors(callback);
  4488. }
  4489. },
  4490. updateMatrix: function() {
  4491. this.matrix.compose(this.position, this.quaternion, this.scale);
  4492. this.matrixWorldNeedsUpdate = true;
  4493. },
  4494. updateMatrixWorld: function(force) {
  4495. if (this.matrixAutoUpdate)
  4496. this.updateMatrix();
  4497. if (this.matrixWorldNeedsUpdate || force) {
  4498. if (this.parent === null) {
  4499. this.matrixWorld.copy(this.matrix);
  4500. } else {
  4501. this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix);
  4502. }
  4503. this.matrixWorldNeedsUpdate = false;
  4504. force = true;
  4505. }
  4506. var children = this.children;
  4507. for (var i2 = 0, l = children.length; i2 < l; i2++) {
  4508. children[i2].updateMatrixWorld(force);
  4509. }
  4510. },
  4511. updateWorldMatrix: function(updateParents, updateChildren) {
  4512. var parent = this.parent;
  4513. if (updateParents === true && parent !== null) {
  4514. parent.updateWorldMatrix(true, false);
  4515. }
  4516. if (this.matrixAutoUpdate)
  4517. this.updateMatrix();
  4518. if (this.parent === null) {
  4519. this.matrixWorld.copy(this.matrix);
  4520. } else {
  4521. this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix);
  4522. }
  4523. if (updateChildren === true) {
  4524. var children = this.children;
  4525. for (var i2 = 0, l = children.length; i2 < l; i2++) {
  4526. children[i2].updateWorldMatrix(false, true);
  4527. }
  4528. }
  4529. },
  4530. toJSON: function(meta) {
  4531. var isRootObject = meta === void 0 || typeof meta === "string";
  4532. var output = {};
  4533. if (isRootObject) {
  4534. meta = {
  4535. geometries: {},
  4536. materials: {},
  4537. textures: {},
  4538. images: {},
  4539. shapes: {}
  4540. };
  4541. output.metadata = {
  4542. version: 4.5,
  4543. type: "Object",
  4544. generator: "Object3D.toJSON"
  4545. };
  4546. }
  4547. var object = {};
  4548. object.uuid = this.uuid;
  4549. object.type = this.type;
  4550. if (this.name !== "")
  4551. object.name = this.name;
  4552. if (this.castShadow === true)
  4553. object.castShadow = true;
  4554. if (this.receiveShadow === true)
  4555. object.receiveShadow = true;
  4556. if (this.visible === false)
  4557. object.visible = false;
  4558. if (this.frustumCulled === false)
  4559. object.frustumCulled = false;
  4560. if (this.renderOrder !== 0)
  4561. object.renderOrder = this.renderOrder;
  4562. if (JSON.stringify(this.userData) !== "{}")
  4563. object.userData = this.userData;
  4564. object.layers = this.layers.mask;
  4565. object.matrix = this.matrix.toArray();
  4566. if (this.matrixAutoUpdate === false)
  4567. object.matrixAutoUpdate = false;
  4568. if (this.isInstancedMesh) {
  4569. object.type = "InstancedMesh";
  4570. object.count = this.count;
  4571. object.instanceMatrix = this.instanceMatrix.toJSON();
  4572. }
  4573. function serialize(library, element) {
  4574. if (library[element.uuid] === void 0) {
  4575. library[element.uuid] = element.toJSON(meta);
  4576. }
  4577. return element.uuid;
  4578. }
  4579. if (this.isMesh || this.isLine || this.isPoints) {
  4580. object.geometry = serialize(meta.geometries, this.geometry);
  4581. var parameters = this.geometry.parameters;
  4582. if (parameters !== void 0 && parameters.shapes !== void 0) {
  4583. var shapes = parameters.shapes;
  4584. if (Array.isArray(shapes)) {
  4585. for (var i2 = 0, l = shapes.length; i2 < l; i2++) {
  4586. var shape = shapes[i2];
  4587. serialize(meta.shapes, shape);
  4588. }
  4589. } else {
  4590. serialize(meta.shapes, shapes);
  4591. }
  4592. }
  4593. }
  4594. if (this.material !== void 0) {
  4595. if (Array.isArray(this.material)) {
  4596. var uuids = [];
  4597. for (var i2 = 0, l = this.material.length; i2 < l; i2++) {
  4598. uuids.push(serialize(meta.materials, this.material[i2]));
  4599. }
  4600. object.material = uuids;
  4601. } else {
  4602. object.material = serialize(meta.materials, this.material);
  4603. }
  4604. }
  4605. if (this.children.length > 0) {
  4606. object.children = [];
  4607. for (var i2 = 0; i2 < this.children.length; i2++) {
  4608. object.children.push(this.children[i2].toJSON(meta).object);
  4609. }
  4610. }
  4611. if (isRootObject) {
  4612. var geometries = extractFromCache(meta.geometries);
  4613. var materials = extractFromCache(meta.materials);
  4614. var textures = extractFromCache(meta.textures);
  4615. var images = extractFromCache(meta.images);
  4616. var shapes = extractFromCache(meta.shapes);
  4617. if (geometries.length > 0)
  4618. output.geometries = geometries;
  4619. if (materials.length > 0)
  4620. output.materials = materials;
  4621. if (textures.length > 0)
  4622. output.textures = textures;
  4623. if (images.length > 0)
  4624. output.images = images;
  4625. if (shapes.length > 0)
  4626. output.shapes = shapes;
  4627. }
  4628. output.object = object;
  4629. return output;
  4630. function extractFromCache(cache) {
  4631. var values = [];
  4632. for (var key in cache) {
  4633. var data = cache[key];
  4634. delete data.metadata;
  4635. values.push(data);
  4636. }
  4637. return values;
  4638. }
  4639. },
  4640. clone: function(recursive) {
  4641. return new this.constructor().copy(this, recursive);
  4642. },
  4643. copy: function(source, recursive) {
  4644. if (recursive === void 0)
  4645. recursive = true;
  4646. this.name = source.name;
  4647. this.up.copy(source.up);
  4648. this.position.copy(source.position);
  4649. this.quaternion.copy(source.quaternion);
  4650. this.scale.copy(source.scale);
  4651. this.matrix.copy(source.matrix);
  4652. this.matrixWorld.copy(source.matrixWorld);
  4653. this.matrixAutoUpdate = source.matrixAutoUpdate;
  4654. this.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;
  4655. this.layers.mask = source.layers.mask;
  4656. this.visible = source.visible;
  4657. this.castShadow = source.castShadow;
  4658. this.receiveShadow = source.receiveShadow;
  4659. this.frustumCulled = source.frustumCulled;
  4660. this.renderOrder = source.renderOrder;
  4661. this.userData = JSON.parse(JSON.stringify(source.userData));
  4662. if (recursive === true) {
  4663. for (var i2 = 0; i2 < source.children.length; i2++) {
  4664. var child = source.children[i2];
  4665. this.add(child.clone());
  4666. }
  4667. }
  4668. return this;
  4669. }
  4670. });
  4671. function Scene() {
  4672. Object3D.call(this);
  4673. this.type = "Scene";
  4674. this.background = null;
  4675. this.environment = null;
  4676. this.fog = null;
  4677. this.overrideMaterial = null;
  4678. this.autoUpdate = true;
  4679. if (typeof __THREE_DEVTOOLS__ !== "undefined") {
  4680. __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
  4681. }
  4682. }
  4683. Scene.prototype = Object.assign(Object.create(Object3D.prototype), {
  4684. constructor: Scene,
  4685. isScene: true,
  4686. copy: function(source, recursive) {
  4687. Object3D.prototype.copy.call(this, source, recursive);
  4688. if (source.background !== null)
  4689. this.background = source.background.clone();
  4690. if (source.environment !== null)
  4691. this.environment = source.environment.clone();
  4692. if (source.fog !== null)
  4693. this.fog = source.fog.clone();
  4694. if (source.overrideMaterial !== null)
  4695. this.overrideMaterial = source.overrideMaterial.clone();
  4696. this.autoUpdate = source.autoUpdate;
  4697. this.matrixAutoUpdate = source.matrixAutoUpdate;
  4698. return this;
  4699. },
  4700. toJSON: function(meta) {
  4701. var data = Object3D.prototype.toJSON.call(this, meta);
  4702. if (this.background !== null)
  4703. data.object.background = this.background.toJSON(meta);
  4704. if (this.environment !== null)
  4705. data.object.environment = this.environment.toJSON(meta);
  4706. if (this.fog !== null)
  4707. data.object.fog = this.fog.toJSON();
  4708. return data;
  4709. },
  4710. dispose: function() {
  4711. this.dispatchEvent({ type: "dispose" });
  4712. }
  4713. });
  4714. var _points = [
  4715. new Vector3(),
  4716. new Vector3(),
  4717. new Vector3(),
  4718. new Vector3(),
  4719. new Vector3(),
  4720. new Vector3(),
  4721. new Vector3(),
  4722. new Vector3()
  4723. ];
  4724. var _vector$1 = new Vector3();
  4725. var _box = new Box3();
  4726. var _v0 = new Vector3();
  4727. var _v1$2 = new Vector3();
  4728. var _v2 = new Vector3();
  4729. var _f0 = new Vector3();
  4730. var _f1 = new Vector3();
  4731. var _f2 = new Vector3();
  4732. var _center = new Vector3();
  4733. var _extents = new Vector3();
  4734. var _triangleNormal = new Vector3();
  4735. var _testAxis = new Vector3();
  4736. function Box3(min, max) {
  4737. this.min = min !== void 0 ? min : new Vector3(Infinity, Infinity, Infinity);
  4738. this.max = max !== void 0 ? max : new Vector3(-Infinity, -Infinity, -Infinity);
  4739. }
  4740. Object.assign(Box3.prototype, {
  4741. isBox3: true,
  4742. set: function(min, max) {
  4743. this.min.copy(min);
  4744. this.max.copy(max);
  4745. return this;
  4746. },
  4747. setFromArray: function(array) {
  4748. var minX = Infinity;
  4749. var minY = Infinity;
  4750. var minZ = Infinity;
  4751. var maxX = -Infinity;
  4752. var maxY = -Infinity;
  4753. var maxZ = -Infinity;
  4754. for (var i2 = 0, l = array.length; i2 < l; i2 += 3) {
  4755. var x = array[i2];
  4756. var y = array[i2 + 1];
  4757. var z = array[i2 + 2];
  4758. if (x < minX)
  4759. minX = x;
  4760. if (y < minY)
  4761. minY = y;
  4762. if (z < minZ)
  4763. minZ = z;
  4764. if (x > maxX)
  4765. maxX = x;
  4766. if (y > maxY)
  4767. maxY = y;
  4768. if (z > maxZ)
  4769. maxZ = z;
  4770. }
  4771. this.min.set(minX, minY, minZ);
  4772. this.max.set(maxX, maxY, maxZ);
  4773. return this;
  4774. },
  4775. setFromBufferAttribute: function(attribute) {
  4776. var minX = Infinity;
  4777. var minY = Infinity;
  4778. var minZ = Infinity;
  4779. var maxX = -Infinity;
  4780. var maxY = -Infinity;
  4781. var maxZ = -Infinity;
  4782. for (var i2 = 0, l = attribute.count; i2 < l; i2++) {
  4783. var x = attribute.getX(i2);
  4784. var y = attribute.getY(i2);
  4785. var z = attribute.getZ(i2);
  4786. if (x < minX)
  4787. minX = x;
  4788. if (y < minY)
  4789. minY = y;
  4790. if (z < minZ)
  4791. minZ = z;
  4792. if (x > maxX)
  4793. maxX = x;
  4794. if (y > maxY)
  4795. maxY = y;
  4796. if (z > maxZ)
  4797. maxZ = z;
  4798. }
  4799. this.min.set(minX, minY, minZ);
  4800. this.max.set(maxX, maxY, maxZ);
  4801. return this;
  4802. },
  4803. setFromPoints: function(points) {
  4804. this.makeEmpty();
  4805. for (var i2 = 0, il = points.length; i2 < il; i2++) {
  4806. this.expandByPoint(points[i2]);
  4807. }
  4808. return this;
  4809. },
  4810. setFromCenterAndSize: function(center, size) {
  4811. var halfSize = _vector$1.copy(size).multiplyScalar(0.5);
  4812. this.min.copy(center).sub(halfSize);
  4813. this.max.copy(center).add(halfSize);
  4814. return this;
  4815. },
  4816. setFromObject: function(object) {
  4817. this.makeEmpty();
  4818. return this.expandByObject(object);
  4819. },
  4820. clone: function() {
  4821. return new this.constructor().copy(this);
  4822. },
  4823. copy: function(box) {
  4824. this.min.copy(box.min);
  4825. this.max.copy(box.max);
  4826. return this;
  4827. },
  4828. makeEmpty: function() {
  4829. this.min.x = this.min.y = this.min.z = Infinity;
  4830. this.max.x = this.max.y = this.max.z = -Infinity;
  4831. return this;
  4832. },
  4833. isEmpty: function() {
  4834. return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z;
  4835. },
  4836. getCenter: function(target) {
  4837. if (target === void 0) {
  4838. console.warn("THREE.Box3: .getCenter() target is now required");
  4839. target = new Vector3();
  4840. }
  4841. return this.isEmpty() ? target.set(0, 0, 0) : target.addVectors(this.min, this.max).multiplyScalar(0.5);
  4842. },
  4843. getSize: function(target) {
  4844. if (target === void 0) {
  4845. console.warn("THREE.Box3: .getSize() target is now required");
  4846. target = new Vector3();
  4847. }
  4848. return this.isEmpty() ? target.set(0, 0, 0) : target.subVectors(this.max, this.min);
  4849. },
  4850. expandByPoint: function(point) {
  4851. this.min.min(point);
  4852. this.max.max(point);
  4853. return this;
  4854. },
  4855. expandByVector: function(vector) {
  4856. this.min.sub(vector);
  4857. this.max.add(vector);
  4858. return this;
  4859. },
  4860. expandByScalar: function(scalar) {
  4861. this.min.addScalar(-scalar);
  4862. this.max.addScalar(scalar);
  4863. return this;
  4864. },
  4865. expandByObject: function(object) {
  4866. object.updateWorldMatrix(false, false);
  4867. var geometry = object.geometry;
  4868. if (geometry !== void 0) {
  4869. if (geometry.boundingBox === null) {
  4870. geometry.computeBoundingBox();
  4871. }
  4872. _box.copy(geometry.boundingBox);
  4873. _box.applyMatrix4(object.matrixWorld);
  4874. this.expandByPoint(_box.min);
  4875. this.expandByPoint(_box.max);
  4876. }
  4877. var children = object.children;
  4878. for (var i2 = 0, l = children.length; i2 < l; i2++) {
  4879. this.expandByObject(children[i2]);
  4880. }
  4881. return this;
  4882. },
  4883. containsPoint: function(point) {
  4884. return point.x < this.min.x || point.x > this.max.x || point.y < this.min.y || point.y > this.max.y || point.z < this.min.z || point.z > this.max.z ? false : true;
  4885. },
  4886. containsBox: function(box) {
  4887. return this.min.x <= box.min.x && box.max.x <= this.max.x && this.min.y <= box.min.y && box.max.y <= this.max.y && this.min.z <= box.min.z && box.max.z <= this.max.z;
  4888. },
  4889. getParameter: function(point, target) {
  4890. if (target === void 0) {
  4891. console.warn("THREE.Box3: .getParameter() target is now required");
  4892. target = new Vector3();
  4893. }
  4894. return target.set(
  4895. (point.x - this.min.x) / (this.max.x - this.min.x),
  4896. (point.y - this.min.y) / (this.max.y - this.min.y),
  4897. (point.z - this.min.z) / (this.max.z - this.min.z)
  4898. );
  4899. },
  4900. intersectsBox: function(box) {
  4901. return box.max.x < this.min.x || box.min.x > this.max.x || box.max.y < this.min.y || box.min.y > this.max.y || box.max.z < this.min.z || box.min.z > this.max.z ? false : true;
  4902. },
  4903. intersectsSphere: function(sphere) {
  4904. this.clampPoint(sphere.center, _vector$1);
  4905. return _vector$1.distanceToSquared(sphere.center) <= sphere.radius * sphere.radius;
  4906. },
  4907. intersectsPlane: function(plane) {
  4908. var min, max;
  4909. if (plane.normal.x > 0) {
  4910. min = plane.normal.x * this.min.x;
  4911. max = plane.normal.x * this.max.x;
  4912. } else {
  4913. min = plane.normal.x * this.max.x;
  4914. max = plane.normal.x * this.min.x;
  4915. }
  4916. if (plane.normal.y > 0) {
  4917. min += plane.normal.y * this.min.y;
  4918. max += plane.normal.y * this.max.y;
  4919. } else {
  4920. min += plane.normal.y * this.max.y;
  4921. max += plane.normal.y * this.min.y;
  4922. }
  4923. if (plane.normal.z > 0) {
  4924. min += plane.normal.z * this.min.z;
  4925. max += plane.normal.z * this.max.z;
  4926. } else {
  4927. min += plane.normal.z * this.max.z;
  4928. max += plane.normal.z * this.min.z;
  4929. }
  4930. return min <= -plane.constant && max >= -plane.constant;
  4931. },
  4932. intersectsTriangle: function(triangle) {
  4933. if (this.isEmpty()) {
  4934. return false;
  4935. }
  4936. this.getCenter(_center);
  4937. _extents.subVectors(this.max, _center);
  4938. _v0.subVectors(triangle.a, _center);
  4939. _v1$2.subVectors(triangle.b, _center);
  4940. _v2.subVectors(triangle.c, _center);
  4941. _f0.subVectors(_v1$2, _v0);
  4942. _f1.subVectors(_v2, _v1$2);
  4943. _f2.subVectors(_v0, _v2);
  4944. var axes = [
  4945. 0,
  4946. -_f0.z,
  4947. _f0.y,
  4948. 0,
  4949. -_f1.z,
  4950. _f1.y,
  4951. 0,
  4952. -_f2.z,
  4953. _f2.y,
  4954. _f0.z,
  4955. 0,
  4956. -_f0.x,
  4957. _f1.z,
  4958. 0,
  4959. -_f1.x,
  4960. _f2.z,
  4961. 0,
  4962. -_f2.x,
  4963. -_f0.y,
  4964. _f0.x,
  4965. 0,
  4966. -_f1.y,
  4967. _f1.x,
  4968. 0,
  4969. -_f2.y,
  4970. _f2.x,
  4971. 0
  4972. ];
  4973. if (!satForAxes(axes, _v0, _v1$2, _v2, _extents)) {
  4974. return false;
  4975. }
  4976. axes = [1, 0, 0, 0, 1, 0, 0, 0, 1];
  4977. if (!satForAxes(axes, _v0, _v1$2, _v2, _extents)) {
  4978. return false;
  4979. }
  4980. _triangleNormal.crossVectors(_f0, _f1);
  4981. axes = [_triangleNormal.x, _triangleNormal.y, _triangleNormal.z];
  4982. return satForAxes(axes, _v0, _v1$2, _v2, _extents);
  4983. },
  4984. clampPoint: function(point, target) {
  4985. if (target === void 0) {
  4986. console.warn("THREE.Box3: .clampPoint() target is now required");
  4987. target = new Vector3();
  4988. }
  4989. return target.copy(point).clamp(this.min, this.max);
  4990. },
  4991. distanceToPoint: function(point) {
  4992. var clampedPoint = _vector$1.copy(point).clamp(this.min, this.max);
  4993. return clampedPoint.sub(point).length();
  4994. },
  4995. getBoundingSphere: function(target) {
  4996. if (target === void 0) {
  4997. console.error("THREE.Box3: .getBoundingSphere() target is now required");
  4998. }
  4999. this.getCenter(target.center);
  5000. target.radius = this.getSize(_vector$1).length() * 0.5;
  5001. return target;
  5002. },
  5003. intersect: function(box) {
  5004. this.min.max(box.min);
  5005. this.max.min(box.max);
  5006. if (this.isEmpty())
  5007. this.makeEmpty();
  5008. return this;
  5009. },
  5010. union: function(box) {
  5011. this.min.min(box.min);
  5012. this.max.max(box.max);
  5013. return this;
  5014. },
  5015. applyMatrix4: function(matrix) {
  5016. if (this.isEmpty())
  5017. return this;
  5018. _points[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(matrix);
  5019. _points[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(matrix);
  5020. _points[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(matrix);
  5021. _points[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(matrix);
  5022. _points[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(matrix);
  5023. _points[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(matrix);
  5024. _points[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(matrix);
  5025. _points[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(matrix);
  5026. this.setFromPoints(_points);
  5027. return this;
  5028. },
  5029. translate: function(offset) {
  5030. this.min.add(offset);
  5031. this.max.add(offset);
  5032. return this;
  5033. },
  5034. equals: function(box) {
  5035. return box.min.equals(this.min) && box.max.equals(this.max);
  5036. }
  5037. });
  5038. function satForAxes(axes, v0, v1, v2, extents) {
  5039. var i2, j;
  5040. for (i2 = 0, j = axes.length - 3; i2 <= j; i2 += 3) {
  5041. _testAxis.fromArray(axes, i2);
  5042. var r = extents.x * Math.abs(_testAxis.x) + extents.y * Math.abs(_testAxis.y) + extents.z * Math.abs(_testAxis.z);
  5043. var p0 = v0.dot(_testAxis);
  5044. var p1 = v1.dot(_testAxis);
  5045. var p2 = v2.dot(_testAxis);
  5046. if (Math.max(-Math.max(p0, p1, p2), Math.min(p0, p1, p2)) > r) {
  5047. return false;
  5048. }
  5049. }
  5050. return true;
  5051. }
  5052. var _box$1 = new Box3();
  5053. function Sphere(center, radius) {
  5054. this.center = center !== void 0 ? center : new Vector3();
  5055. this.radius = radius !== void 0 ? radius : 0;
  5056. }
  5057. Object.assign(Sphere.prototype, {
  5058. set: function(center, radius) {
  5059. this.center.copy(center);
  5060. this.radius = radius;
  5061. return this;
  5062. },
  5063. setFromPoints: function(points, optionalCenter) {
  5064. var center = this.center;
  5065. if (optionalCenter !== void 0) {
  5066. center.copy(optionalCenter);
  5067. } else {
  5068. _box$1.setFromPoints(points).getCenter(center);
  5069. }
  5070. var maxRadiusSq = 0;
  5071. for (var i2 = 0, il = points.length; i2 < il; i2++) {
  5072. maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(points[i2]));
  5073. }
  5074. this.radius = Math.sqrt(maxRadiusSq);
  5075. return this;
  5076. },
  5077. clone: function() {
  5078. return new this.constructor().copy(this);
  5079. },
  5080. copy: function(sphere) {
  5081. this.center.copy(sphere.center);
  5082. this.radius = sphere.radius;
  5083. return this;
  5084. },
  5085. empty: function() {
  5086. return this.radius <= 0;
  5087. },
  5088. containsPoint: function(point) {
  5089. return point.distanceToSquared(this.center) <= this.radius * this.radius;
  5090. },
  5091. distanceToPoint: function(point) {
  5092. return point.distanceTo(this.center) - this.radius;
  5093. },
  5094. intersectsSphere: function(sphere) {
  5095. var radiusSum = this.radius + sphere.radius;
  5096. return sphere.center.distanceToSquared(this.center) <= radiusSum * radiusSum;
  5097. },
  5098. intersectsBox: function(box) {
  5099. return box.intersectsSphere(this);
  5100. },
  5101. intersectsPlane: function(plane) {
  5102. return Math.abs(plane.distanceToPoint(this.center)) <= this.radius;
  5103. },
  5104. clampPoint: function(point, target) {
  5105. var deltaLengthSq = this.center.distanceToSquared(point);
  5106. if (target === void 0) {
  5107. console.warn("THREE.Sphere: .clampPoint() target is now required");
  5108. target = new Vector3();
  5109. }
  5110. target.copy(point);
  5111. if (deltaLengthSq > this.radius * this.radius) {
  5112. target.sub(this.center).normalize();
  5113. target.multiplyScalar(this.radius).add(this.center);
  5114. }
  5115. return target;
  5116. },
  5117. getBoundingBox: function(target) {
  5118. if (target === void 0) {
  5119. console.warn("THREE.Sphere: .getBoundingBox() target is now required");
  5120. target = new Box3();
  5121. }
  5122. target.set(this.center, this.center);
  5123. target.expandByScalar(this.radius);
  5124. return target;
  5125. },
  5126. applyMatrix4: function(matrix) {
  5127. this.center.applyMatrix4(matrix);
  5128. this.radius = this.radius * matrix.getMaxScaleOnAxis();
  5129. return this;
  5130. },
  5131. translate: function(offset) {
  5132. this.center.add(offset);
  5133. return this;
  5134. },
  5135. equals: function(sphere) {
  5136. return sphere.center.equals(this.center) && sphere.radius === this.radius;
  5137. }
  5138. });
  5139. var _vector$2 = new Vector3();
  5140. var _segCenter = new Vector3();
  5141. var _segDir = new Vector3();
  5142. var _diff = new Vector3();
  5143. var _edge1 = new Vector3();
  5144. var _edge2 = new Vector3();
  5145. var _normal = new Vector3();
  5146. function Ray(origin, direction) {
  5147. this.origin = origin !== void 0 ? origin : new Vector3();
  5148. this.direction = direction !== void 0 ? direction : new Vector3(0, 0, -1);
  5149. }
  5150. Object.assign(Ray.prototype, {
  5151. set: function(origin, direction) {
  5152. this.origin.copy(origin);
  5153. this.direction.copy(direction);
  5154. return this;
  5155. },
  5156. clone: function() {
  5157. return new this.constructor().copy(this);
  5158. },
  5159. copy: function(ray) {
  5160. this.origin.copy(ray.origin);
  5161. this.direction.copy(ray.direction);
  5162. return this;
  5163. },
  5164. at: function(t, target) {
  5165. if (target === void 0) {
  5166. console.warn("THREE.Ray: .at() target is now required");
  5167. target = new Vector3();
  5168. }
  5169. return target.copy(this.direction).multiplyScalar(t).add(this.origin);
  5170. },
  5171. lookAt: function(v) {
  5172. this.direction.copy(v).sub(this.origin).normalize();
  5173. return this;
  5174. },
  5175. recast: function(t) {
  5176. this.origin.copy(this.at(t, _vector$2));
  5177. return this;
  5178. },
  5179. closestPointToPoint: function(point, target) {
  5180. if (target === void 0) {
  5181. console.warn("THREE.Ray: .closestPointToPoint() target is now required");
  5182. target = new Vector3();
  5183. }
  5184. target.subVectors(point, this.origin);
  5185. var directionDistance = target.dot(this.direction);
  5186. if (directionDistance < 0) {
  5187. return target.copy(this.origin);
  5188. }
  5189. return target.copy(this.direction).multiplyScalar(directionDistance).add(this.origin);
  5190. },
  5191. distanceToPoint: function(point) {
  5192. return Math.sqrt(this.distanceSqToPoint(point));
  5193. },
  5194. distanceSqToPoint: function(point) {
  5195. var directionDistance = _vector$2.subVectors(point, this.origin).dot(this.direction);
  5196. if (directionDistance < 0) {
  5197. return this.origin.distanceToSquared(point);
  5198. }
  5199. _vector$2.copy(this.direction).multiplyScalar(directionDistance).add(this.origin);
  5200. return _vector$2.distanceToSquared(point);
  5201. },
  5202. distanceSqToSegment: function(v0, v1, optionalPointOnRay, optionalPointOnSegment) {
  5203. _segCenter.copy(v0).add(v1).multiplyScalar(0.5);
  5204. _segDir.copy(v1).sub(v0).normalize();
  5205. _diff.copy(this.origin).sub(_segCenter);
  5206. var segExtent = v0.distanceTo(v1) * 0.5;
  5207. var a01 = -this.direction.dot(_segDir);
  5208. var b0 = _diff.dot(this.direction);
  5209. var b1 = -_diff.dot(_segDir);
  5210. var c = _diff.lengthSq();
  5211. var det = Math.abs(1 - a01 * a01);
  5212. var s0, s1, sqrDist, extDet;
  5213. if (det > 0) {
  5214. s0 = a01 * b1 - b0;
  5215. s1 = a01 * b0 - b1;
  5216. extDet = segExtent * det;
  5217. if (s0 >= 0) {
  5218. if (s1 >= -extDet) {
  5219. if (s1 <= extDet) {
  5220. var invDet = 1 / det;
  5221. s0 *= invDet;
  5222. s1 *= invDet;
  5223. sqrDist = s0 * (s0 + a01 * s1 + 2 * b0) + s1 * (a01 * s0 + s1 + 2 * b1) + c;
  5224. } else {
  5225. s1 = segExtent;
  5226. s0 = Math.max(0, -(a01 * s1 + b0));
  5227. sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
  5228. }
  5229. } else {
  5230. s1 = -segExtent;
  5231. s0 = Math.max(0, -(a01 * s1 + b0));
  5232. sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
  5233. }
  5234. } else {
  5235. if (s1 <= -extDet) {
  5236. s0 = Math.max(0, -(-a01 * segExtent + b0));
  5237. s1 = s0 > 0 ? -segExtent : Math.min(Math.max(-segExtent, -b1), segExtent);
  5238. sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
  5239. } else if (s1 <= extDet) {
  5240. s0 = 0;
  5241. s1 = Math.min(Math.max(-segExtent, -b1), segExtent);
  5242. sqrDist = s1 * (s1 + 2 * b1) + c;
  5243. } else {
  5244. s0 = Math.max(0, -(a01 * segExtent + b0));
  5245. s1 = s0 > 0 ? segExtent : Math.min(Math.max(-segExtent, -b1), segExtent);
  5246. sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
  5247. }
  5248. }
  5249. } else {
  5250. s1 = a01 > 0 ? -segExtent : segExtent;
  5251. s0 = Math.max(0, -(a01 * s1 + b0));
  5252. sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
  5253. }
  5254. if (optionalPointOnRay) {
  5255. optionalPointOnRay.copy(this.direction).multiplyScalar(s0).add(this.origin);
  5256. }
  5257. if (optionalPointOnSegment) {
  5258. optionalPointOnSegment.copy(_segDir).multiplyScalar(s1).add(_segCenter);
  5259. }
  5260. return sqrDist;
  5261. },
  5262. intersectSphere: function(sphere, target) {
  5263. _vector$2.subVectors(sphere.center, this.origin);
  5264. var tca = _vector$2.dot(this.direction);
  5265. var d2 = _vector$2.dot(_vector$2) - tca * tca;
  5266. var radius2 = sphere.radius * sphere.radius;
  5267. if (d2 > radius2)
  5268. return null;
  5269. var thc = Math.sqrt(radius2 - d2);
  5270. var t0 = tca - thc;
  5271. var t1 = tca + thc;
  5272. if (t0 < 0 && t1 < 0)
  5273. return null;
  5274. if (t0 < 0)
  5275. return this.at(t1, target);
  5276. return this.at(t0, target);
  5277. },
  5278. intersectsSphere: function(sphere) {
  5279. return this.distanceSqToPoint(sphere.center) <= sphere.radius * sphere.radius;
  5280. },
  5281. distanceToPlane: function(plane) {
  5282. var denominator = plane.normal.dot(this.direction);
  5283. if (denominator === 0) {
  5284. if (plane.distanceToPoint(this.origin) === 0) {
  5285. return 0;
  5286. }
  5287. return null;
  5288. }
  5289. var t = -(this.origin.dot(plane.normal) + plane.constant) / denominator;
  5290. return t >= 0 ? t : null;
  5291. },
  5292. intersectPlane: function(plane, target) {
  5293. var t = this.distanceToPlane(plane);
  5294. if (t === null) {
  5295. return null;
  5296. }
  5297. return this.at(t, target);
  5298. },
  5299. intersectsPlane: function(plane) {
  5300. var distToPoint = plane.distanceToPoint(this.origin);
  5301. if (distToPoint === 0) {
  5302. return true;
  5303. }
  5304. var denominator = plane.normal.dot(this.direction);
  5305. if (denominator * distToPoint < 0) {
  5306. return true;
  5307. }
  5308. return false;
  5309. },
  5310. intersectBox: function(box, target) {
  5311. var tmin, tmax, tymin, tymax, tzmin, tzmax;
  5312. var invdirx = 1 / this.direction.x, invdiry = 1 / this.direction.y, invdirz = 1 / this.direction.z;
  5313. var origin = this.origin;
  5314. if (invdirx >= 0) {
  5315. tmin = (box.min.x - origin.x) * invdirx;
  5316. tmax = (box.max.x - origin.x) * invdirx;
  5317. } else {
  5318. tmin = (box.max.x - origin.x) * invdirx;
  5319. tmax = (box.min.x - origin.x) * invdirx;
  5320. }
  5321. if (invdiry >= 0) {
  5322. tymin = (box.min.y - origin.y) * invdiry;
  5323. tymax = (box.max.y - origin.y) * invdiry;
  5324. } else {
  5325. tymin = (box.max.y - origin.y) * invdiry;
  5326. tymax = (box.min.y - origin.y) * invdiry;
  5327. }
  5328. if (tmin > tymax || tymin > tmax)
  5329. return null;
  5330. if (tymin > tmin || tmin !== tmin)
  5331. tmin = tymin;
  5332. if (tymax < tmax || tmax !== tmax)
  5333. tmax = tymax;
  5334. if (invdirz >= 0) {
  5335. tzmin = (box.min.z - origin.z) * invdirz;
  5336. tzmax = (box.max.z - origin.z) * invdirz;
  5337. } else {
  5338. tzmin = (box.max.z - origin.z) * invdirz;
  5339. tzmax = (box.min.z - origin.z) * invdirz;
  5340. }
  5341. if (tmin > tzmax || tzmin > tmax)
  5342. return null;
  5343. if (tzmin > tmin || tmin !== tmin)
  5344. tmin = tzmin;
  5345. if (tzmax < tmax || tmax !== tmax)
  5346. tmax = tzmax;
  5347. if (tmax < 0)
  5348. return null;
  5349. return this.at(tmin >= 0 ? tmin : tmax, target);
  5350. },
  5351. intersectsBox: function(box) {
  5352. return this.intersectBox(box, _vector$2) !== null;
  5353. },
  5354. intersectTriangle: function(a, b, c, backfaceCulling, target) {
  5355. _edge1.subVectors(b, a);
  5356. _edge2.subVectors(c, a);
  5357. _normal.crossVectors(_edge1, _edge2);
  5358. var DdN = this.direction.dot(_normal);
  5359. var sign;
  5360. if (DdN > 0) {
  5361. if (backfaceCulling)
  5362. return null;
  5363. sign = 1;
  5364. } else if (DdN < 0) {
  5365. sign = -1;
  5366. DdN = -DdN;
  5367. } else {
  5368. return null;
  5369. }
  5370. _diff.subVectors(this.origin, a);
  5371. var DdQxE2 = sign * this.direction.dot(_edge2.crossVectors(_diff, _edge2));
  5372. if (DdQxE2 < 0) {
  5373. return null;
  5374. }
  5375. var DdE1xQ = sign * this.direction.dot(_edge1.cross(_diff));
  5376. if (DdE1xQ < 0) {
  5377. return null;
  5378. }
  5379. if (DdQxE2 + DdE1xQ > DdN) {
  5380. return null;
  5381. }
  5382. var QdN = -sign * _diff.dot(_normal);
  5383. if (QdN < 0) {
  5384. return null;
  5385. }
  5386. return this.at(QdN / DdN, target);
  5387. },
  5388. applyMatrix4: function(matrix4) {
  5389. this.origin.applyMatrix4(matrix4);
  5390. this.direction.transformDirection(matrix4);
  5391. return this;
  5392. },
  5393. equals: function(ray) {
  5394. return ray.origin.equals(this.origin) && ray.direction.equals(this.direction);
  5395. }
  5396. });
  5397. var _vector1 = new Vector3();
  5398. var _vector2 = new Vector3();
  5399. var _normalMatrix = new Matrix3();
  5400. function Plane(normal, constant) {
  5401. this.normal = normal !== void 0 ? normal : new Vector3(1, 0, 0);
  5402. this.constant = constant !== void 0 ? constant : 0;
  5403. }
  5404. Object.assign(Plane.prototype, {
  5405. isPlane: true,
  5406. set: function(normal, constant) {
  5407. this.normal.copy(normal);
  5408. this.constant = constant;
  5409. return this;
  5410. },
  5411. setComponents: function(x, y, z, w) {
  5412. this.normal.set(x, y, z);
  5413. this.constant = w;
  5414. return this;
  5415. },
  5416. setFromNormalAndCoplanarPoint: function(normal, point) {
  5417. this.normal.copy(normal);
  5418. this.constant = -point.dot(this.normal);
  5419. return this;
  5420. },
  5421. setFromCoplanarPoints: function(a, b, c) {
  5422. var normal = _vector1.subVectors(c, b).cross(_vector2.subVectors(a, b)).normalize();
  5423. this.setFromNormalAndCoplanarPoint(normal, a);
  5424. return this;
  5425. },
  5426. clone: function() {
  5427. return new this.constructor().copy(this);
  5428. },
  5429. copy: function(plane) {
  5430. this.normal.copy(plane.normal);
  5431. this.constant = plane.constant;
  5432. return this;
  5433. },
  5434. normalize: function() {
  5435. var inverseNormalLength = 1 / this.normal.length();
  5436. this.normal.multiplyScalar(inverseNormalLength);
  5437. this.constant *= inverseNormalLength;
  5438. return this;
  5439. },
  5440. negate: function() {
  5441. this.constant *= -1;
  5442. this.normal.negate();
  5443. return this;
  5444. },
  5445. distanceToPoint: function(point) {
  5446. return this.normal.dot(point) + this.constant;
  5447. },
  5448. distanceToSphere: function(sphere) {
  5449. return this.distanceToPoint(sphere.center) - sphere.radius;
  5450. },
  5451. projectPoint: function(point, target) {
  5452. if (target === void 0) {
  5453. console.warn("THREE.Plane: .projectPoint() target is now required");
  5454. target = new Vector3();
  5455. }
  5456. return target.copy(this.normal).multiplyScalar(-this.distanceToPoint(point)).add(point);
  5457. },
  5458. intersectLine: function(line, target) {
  5459. if (target === void 0) {
  5460. console.warn("THREE.Plane: .intersectLine() target is now required");
  5461. target = new Vector3();
  5462. }
  5463. var direction = line.delta(_vector1);
  5464. var denominator = this.normal.dot(direction);
  5465. if (denominator === 0) {
  5466. if (this.distanceToPoint(line.start) === 0) {
  5467. return target.copy(line.start);
  5468. }
  5469. return void 0;
  5470. }
  5471. var t = -(line.start.dot(this.normal) + this.constant) / denominator;
  5472. if (t < 0 || t > 1) {
  5473. return void 0;
  5474. }
  5475. return target.copy(direction).multiplyScalar(t).add(line.start);
  5476. },
  5477. intersectsLine: function(line) {
  5478. var startSign = this.distanceToPoint(line.start);
  5479. var endSign = this.distanceToPoint(line.end);
  5480. return startSign < 0 && endSign > 0 || endSign < 0 && startSign > 0;
  5481. },
  5482. intersectsBox: function(box) {
  5483. return box.intersectsPlane(this);
  5484. },
  5485. intersectsSphere: function(sphere) {
  5486. return sphere.intersectsPlane(this);
  5487. },
  5488. coplanarPoint: function(target) {
  5489. if (target === void 0) {
  5490. console.warn("THREE.Plane: .coplanarPoint() target is now required");
  5491. target = new Vector3();
  5492. }
  5493. return target.copy(this.normal).multiplyScalar(-this.constant);
  5494. },
  5495. applyMatrix4: function(matrix, optionalNormalMatrix) {
  5496. var normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix(matrix);
  5497. var referencePoint = this.coplanarPoint(_vector1).applyMatrix4(matrix);
  5498. var normal = this.normal.applyMatrix3(normalMatrix).normalize();
  5499. this.constant = -referencePoint.dot(normal);
  5500. return this;
  5501. },
  5502. translate: function(offset) {
  5503. this.constant -= offset.dot(this.normal);
  5504. return this;
  5505. },
  5506. equals: function(plane) {
  5507. return plane.normal.equals(this.normal) && plane.constant === this.constant;
  5508. }
  5509. });
  5510. var _v0$1 = new Vector3();
  5511. var _v1$3 = new Vector3();
  5512. var _v2$1 = new Vector3();
  5513. var _v3 = new Vector3();
  5514. var _vab = new Vector3();
  5515. var _vac = new Vector3();
  5516. var _vbc = new Vector3();
  5517. var _vap = new Vector3();
  5518. var _vbp = new Vector3();
  5519. var _vcp = new Vector3();
  5520. function Triangle(a, b, c) {
  5521. this.a = a !== void 0 ? a : new Vector3();
  5522. this.b = b !== void 0 ? b : new Vector3();
  5523. this.c = c !== void 0 ? c : new Vector3();
  5524. }
  5525. Object.assign(Triangle, {
  5526. getNormal: function(a, b, c, target) {
  5527. if (target === void 0) {
  5528. console.warn("THREE.Triangle: .getNormal() target is now required");
  5529. target = new Vector3();
  5530. }
  5531. target.subVectors(c, b);
  5532. _v0$1.subVectors(a, b);
  5533. target.cross(_v0$1);
  5534. var targetLengthSq = target.lengthSq();
  5535. if (targetLengthSq > 0) {
  5536. return target.multiplyScalar(1 / Math.sqrt(targetLengthSq));
  5537. }
  5538. return target.set(0, 0, 0);
  5539. },
  5540. // static/instance method to calculate barycentric coordinates
  5541. // based on: http://www.blackpawn.com/texts/pointinpoly/default.html
  5542. getBarycoord: function(point, a, b, c, target) {
  5543. _v0$1.subVectors(c, a);
  5544. _v1$3.subVectors(b, a);
  5545. _v2$1.subVectors(point, a);
  5546. var dot00 = _v0$1.dot(_v0$1);
  5547. var dot01 = _v0$1.dot(_v1$3);
  5548. var dot02 = _v0$1.dot(_v2$1);
  5549. var dot11 = _v1$3.dot(_v1$3);
  5550. var dot12 = _v1$3.dot(_v2$1);
  5551. var denom = dot00 * dot11 - dot01 * dot01;
  5552. if (target === void 0) {
  5553. console.warn("THREE.Triangle: .getBarycoord() target is now required");
  5554. target = new Vector3();
  5555. }
  5556. if (denom === 0) {
  5557. return target.set(-2, -1, -1);
  5558. }
  5559. var invDenom = 1 / denom;
  5560. var u = (dot11 * dot02 - dot01 * dot12) * invDenom;
  5561. var v = (dot00 * dot12 - dot01 * dot02) * invDenom;
  5562. return target.set(1 - u - v, v, u);
  5563. },
  5564. containsPoint: function(point, a, b, c) {
  5565. Triangle.getBarycoord(point, a, b, c, _v3);
  5566. return _v3.x >= 0 && _v3.y >= 0 && _v3.x + _v3.y <= 1;
  5567. },
  5568. getUV: function(point, p1, p2, p3, uv1, uv2, uv3, target) {
  5569. this.getBarycoord(point, p1, p2, p3, _v3);
  5570. target.set(0, 0);
  5571. target.addScaledVector(uv1, _v3.x);
  5572. target.addScaledVector(uv2, _v3.y);
  5573. target.addScaledVector(uv3, _v3.z);
  5574. return target;
  5575. },
  5576. isFrontFacing: function(a, b, c, direction) {
  5577. _v0$1.subVectors(c, b);
  5578. _v1$3.subVectors(a, b);
  5579. return _v0$1.cross(_v1$3).dot(direction) < 0 ? true : false;
  5580. }
  5581. });
  5582. Object.assign(Triangle.prototype, {
  5583. set: function(a, b, c) {
  5584. this.a.copy(a);
  5585. this.b.copy(b);
  5586. this.c.copy(c);
  5587. return this;
  5588. },
  5589. setFromPointsAndIndices: function(points, i0, i1, i2) {
  5590. this.a.copy(points[i0]);
  5591. this.b.copy(points[i1]);
  5592. this.c.copy(points[i2]);
  5593. return this;
  5594. },
  5595. clone: function() {
  5596. return new this.constructor().copy(this);
  5597. },
  5598. copy: function(triangle) {
  5599. this.a.copy(triangle.a);
  5600. this.b.copy(triangle.b);
  5601. this.c.copy(triangle.c);
  5602. return this;
  5603. },
  5604. getArea: function() {
  5605. _v0$1.subVectors(this.c, this.b);
  5606. _v1$3.subVectors(this.a, this.b);
  5607. return _v0$1.cross(_v1$3).length() * 0.5;
  5608. },
  5609. getMidpoint: function(target) {
  5610. if (target === void 0) {
  5611. console.warn("THREE.Triangle: .getMidpoint() target is now required");
  5612. target = new Vector3();
  5613. }
  5614. return target.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3);
  5615. },
  5616. getNormal: function(target) {
  5617. return Triangle.getNormal(this.a, this.b, this.c, target);
  5618. },
  5619. getPlane: function(target) {
  5620. if (target === void 0) {
  5621. console.warn("THREE.Triangle: .getPlane() target is now required");
  5622. target = new Plane();
  5623. }
  5624. return target.setFromCoplanarPoints(this.a, this.b, this.c);
  5625. },
  5626. getBarycoord: function(point, target) {
  5627. return Triangle.getBarycoord(point, this.a, this.b, this.c, target);
  5628. },
  5629. getUV: function(point, uv1, uv2, uv3, target) {
  5630. return Triangle.getUV(point, this.a, this.b, this.c, uv1, uv2, uv3, target);
  5631. },
  5632. containsPoint: function(point) {
  5633. return Triangle.containsPoint(point, this.a, this.b, this.c);
  5634. },
  5635. isFrontFacing: function(direction) {
  5636. return Triangle.isFrontFacing(this.a, this.b, this.c, direction);
  5637. },
  5638. intersectsBox: function(box) {
  5639. return box.intersectsTriangle(this);
  5640. },
  5641. closestPointToPoint: function(p, target) {
  5642. if (target === void 0) {
  5643. console.warn("THREE.Triangle: .closestPointToPoint() target is now required");
  5644. target = new Vector3();
  5645. }
  5646. var a = this.a, b = this.b, c = this.c;
  5647. var v, w;
  5648. _vab.subVectors(b, a);
  5649. _vac.subVectors(c, a);
  5650. _vap.subVectors(p, a);
  5651. var d1 = _vab.dot(_vap);
  5652. var d2 = _vac.dot(_vap);
  5653. if (d1 <= 0 && d2 <= 0) {
  5654. return target.copy(a);
  5655. }
  5656. _vbp.subVectors(p, b);
  5657. var d3 = _vab.dot(_vbp);
  5658. var d4 = _vac.dot(_vbp);
  5659. if (d3 >= 0 && d4 <= d3) {
  5660. return target.copy(b);
  5661. }
  5662. var vc = d1 * d4 - d3 * d2;
  5663. if (vc <= 0 && d1 >= 0 && d3 <= 0) {
  5664. v = d1 / (d1 - d3);
  5665. return target.copy(a).addScaledVector(_vab, v);
  5666. }
  5667. _vcp.subVectors(p, c);
  5668. var d5 = _vab.dot(_vcp);
  5669. var d6 = _vac.dot(_vcp);
  5670. if (d6 >= 0 && d5 <= d6) {
  5671. return target.copy(c);
  5672. }
  5673. var vb = d5 * d2 - d1 * d6;
  5674. if (vb <= 0 && d2 >= 0 && d6 <= 0) {
  5675. w = d2 / (d2 - d6);
  5676. return target.copy(a).addScaledVector(_vac, w);
  5677. }
  5678. var va = d3 * d6 - d5 * d4;
  5679. if (va <= 0 && d4 - d3 >= 0 && d5 - d6 >= 0) {
  5680. _vbc.subVectors(c, b);
  5681. w = (d4 - d3) / (d4 - d3 + (d5 - d6));
  5682. return target.copy(b).addScaledVector(_vbc, w);
  5683. }
  5684. var denom = 1 / (va + vb + vc);
  5685. v = vb * denom;
  5686. w = vc * denom;
  5687. return target.copy(a).addScaledVector(_vab, v).addScaledVector(_vac, w);
  5688. },
  5689. equals: function(triangle) {
  5690. return triangle.a.equals(this.a) && triangle.b.equals(this.b) && triangle.c.equals(this.c);
  5691. }
  5692. });
  5693. var _colorKeywords = {
  5694. "aliceblue": 15792383,
  5695. "antiquewhite": 16444375,
  5696. "aqua": 65535,
  5697. "aquamarine": 8388564,
  5698. "azure": 15794175,
  5699. "beige": 16119260,
  5700. "bisque": 16770244,
  5701. "black": 0,
  5702. "blanchedalmond": 16772045,
  5703. "blue": 255,
  5704. "blueviolet": 9055202,
  5705. "brown": 10824234,
  5706. "burlywood": 14596231,
  5707. "cadetblue": 6266528,
  5708. "chartreuse": 8388352,
  5709. "chocolate": 13789470,
  5710. "coral": 16744272,
  5711. "cornflowerblue": 6591981,
  5712. "cornsilk": 16775388,
  5713. "crimson": 14423100,
  5714. "cyan": 65535,
  5715. "darkblue": 139,
  5716. "darkcyan": 35723,
  5717. "darkgoldenrod": 12092939,
  5718. "darkgray": 11119017,
  5719. "darkgreen": 25600,
  5720. "darkgrey": 11119017,
  5721. "darkkhaki": 12433259,
  5722. "darkmagenta": 9109643,
  5723. "darkolivegreen": 5597999,
  5724. "darkorange": 16747520,
  5725. "darkorchid": 10040012,
  5726. "darkred": 9109504,
  5727. "darksalmon": 15308410,
  5728. "darkseagreen": 9419919,
  5729. "darkslateblue": 4734347,
  5730. "darkslategray": 3100495,
  5731. "darkslategrey": 3100495,
  5732. "darkturquoise": 52945,
  5733. "darkviolet": 9699539,
  5734. "deeppink": 16716947,
  5735. "deepskyblue": 49151,
  5736. "dimgray": 6908265,
  5737. "dimgrey": 6908265,
  5738. "dodgerblue": 2003199,
  5739. "firebrick": 11674146,
  5740. "floralwhite": 16775920,
  5741. "forestgreen": 2263842,
  5742. "fuchsia": 16711935,
  5743. "gainsboro": 14474460,
  5744. "ghostwhite": 16316671,
  5745. "gold": 16766720,
  5746. "goldenrod": 14329120,
  5747. "gray": 8421504,
  5748. "green": 32768,
  5749. "greenyellow": 11403055,
  5750. "grey": 8421504,
  5751. "honeydew": 15794160,
  5752. "hotpink": 16738740,
  5753. "indianred": 13458524,
  5754. "indigo": 4915330,
  5755. "ivory": 16777200,
  5756. "khaki": 15787660,
  5757. "lavender": 15132410,
  5758. "lavenderblush": 16773365,
  5759. "lawngreen": 8190976,
  5760. "lemonchiffon": 16775885,
  5761. "lightblue": 11393254,
  5762. "lightcoral": 15761536,
  5763. "lightcyan": 14745599,
  5764. "lightgoldenrodyellow": 16448210,
  5765. "lightgray": 13882323,
  5766. "lightgreen": 9498256,
  5767. "lightgrey": 13882323,
  5768. "lightpink": 16758465,
  5769. "lightsalmon": 16752762,
  5770. "lightseagreen": 2142890,
  5771. "lightskyblue": 8900346,
  5772. "lightslategray": 7833753,
  5773. "lightslategrey": 7833753,
  5774. "lightsteelblue": 11584734,
  5775. "lightyellow": 16777184,
  5776. "lime": 65280,
  5777. "limegreen": 3329330,
  5778. "linen": 16445670,
  5779. "magenta": 16711935,
  5780. "maroon": 8388608,
  5781. "mediumaquamarine": 6737322,
  5782. "mediumblue": 205,
  5783. "mediumorchid": 12211667,
  5784. "mediumpurple": 9662683,
  5785. "mediumseagreen": 3978097,
  5786. "mediumslateblue": 8087790,
  5787. "mediumspringgreen": 64154,
  5788. "mediumturquoise": 4772300,
  5789. "mediumvioletred": 13047173,
  5790. "midnightblue": 1644912,
  5791. "mintcream": 16121850,
  5792. "mistyrose": 16770273,
  5793. "moccasin": 16770229,
  5794. "navajowhite": 16768685,
  5795. "navy": 128,
  5796. "oldlace": 16643558,
  5797. "olive": 8421376,
  5798. "olivedrab": 7048739,
  5799. "orange": 16753920,
  5800. "orangered": 16729344,
  5801. "orchid": 14315734,
  5802. "palegoldenrod": 15657130,
  5803. "palegreen": 10025880,
  5804. "paleturquoise": 11529966,
  5805. "palevioletred": 14381203,
  5806. "papayawhip": 16773077,
  5807. "peachpuff": 16767673,
  5808. "peru": 13468991,
  5809. "pink": 16761035,
  5810. "plum": 14524637,
  5811. "powderblue": 11591910,
  5812. "purple": 8388736,
  5813. "rebeccapurple": 6697881,
  5814. "red": 16711680,
  5815. "rosybrown": 12357519,
  5816. "royalblue": 4286945,
  5817. "saddlebrown": 9127187,
  5818. "salmon": 16416882,
  5819. "sandybrown": 16032864,
  5820. "seagreen": 3050327,
  5821. "seashell": 16774638,
  5822. "sienna": 10506797,
  5823. "silver": 12632256,
  5824. "skyblue": 8900331,
  5825. "slateblue": 6970061,
  5826. "slategray": 7372944,
  5827. "slategrey": 7372944,
  5828. "snow": 16775930,
  5829. "springgreen": 65407,
  5830. "steelblue": 4620980,
  5831. "tan": 13808780,
  5832. "teal": 32896,
  5833. "thistle": 14204888,
  5834. "tomato": 16737095,
  5835. "turquoise": 4251856,
  5836. "violet": 15631086,
  5837. "wheat": 16113331,
  5838. "white": 16777215,
  5839. "whitesmoke": 16119285,
  5840. "yellow": 16776960,
  5841. "yellowgreen": 10145074
  5842. };
  5843. var _hslA = { h: 0, s: 0, l: 0 };
  5844. var _hslB = { h: 0, s: 0, l: 0 };
  5845. function Color(r, g, b) {
  5846. if (g === void 0 && b === void 0) {
  5847. return this.set(r);
  5848. }
  5849. return this.setRGB(r, g, b);
  5850. }
  5851. function hue2rgb(p, q, t) {
  5852. if (t < 0)
  5853. t += 1;
  5854. if (t > 1)
  5855. t -= 1;
  5856. if (t < 1 / 6)
  5857. return p + (q - p) * 6 * t;
  5858. if (t < 1 / 2)
  5859. return q;
  5860. if (t < 2 / 3)
  5861. return p + (q - p) * 6 * (2 / 3 - t);
  5862. return p;
  5863. }
  5864. function SRGBToLinear(c) {
  5865. return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
  5866. }
  5867. function LinearToSRGB(c) {
  5868. return c < 31308e-7 ? c * 12.92 : 1.055 * Math.pow(c, 0.41666) - 0.055;
  5869. }
  5870. Object.assign(Color.prototype, {
  5871. isColor: true,
  5872. r: 1,
  5873. g: 1,
  5874. b: 1,
  5875. set: function(value) {
  5876. if (value && value.isColor) {
  5877. this.copy(value);
  5878. } else if (typeof value === "number") {
  5879. this.setHex(value);
  5880. } else if (typeof value === "string") {
  5881. this.setStyle(value);
  5882. }
  5883. return this;
  5884. },
  5885. setScalar: function(scalar) {
  5886. this.r = scalar;
  5887. this.g = scalar;
  5888. this.b = scalar;
  5889. return this;
  5890. },
  5891. setHex: function(hex) {
  5892. hex = Math.floor(hex);
  5893. this.r = (hex >> 16 & 255) / 255;
  5894. this.g = (hex >> 8 & 255) / 255;
  5895. this.b = (hex & 255) / 255;
  5896. return this;
  5897. },
  5898. setRGB: function(r, g, b) {
  5899. this.r = r;
  5900. this.g = g;
  5901. this.b = b;
  5902. return this;
  5903. },
  5904. setHSL: function(h, s, l) {
  5905. h = MathUtils.euclideanModulo(h, 1);
  5906. s = MathUtils.clamp(s, 0, 1);
  5907. l = MathUtils.clamp(l, 0, 1);
  5908. if (s === 0) {
  5909. this.r = this.g = this.b = l;
  5910. } else {
  5911. var p = l <= 0.5 ? l * (1 + s) : l + s - l * s;
  5912. var q = 2 * l - p;
  5913. this.r = hue2rgb(q, p, h + 1 / 3);
  5914. this.g = hue2rgb(q, p, h);
  5915. this.b = hue2rgb(q, p, h - 1 / 3);
  5916. }
  5917. return this;
  5918. },
  5919. setStyle: function(style) {
  5920. function handleAlpha(string) {
  5921. if (string === void 0)
  5922. return;
  5923. if (parseFloat(string) < 1) {
  5924. console.warn("THREE.Color: Alpha component of " + style + " will be ignored.");
  5925. }
  5926. }
  5927. var m;
  5928. if (m = /^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(style)) {
  5929. var color;
  5930. var name = m[1];
  5931. var components = m[2];
  5932. switch (name) {
  5933. case "rgb":
  5934. case "rgba":
  5935. if (color = /^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(components)) {
  5936. this.r = Math.min(255, parseInt(color[1], 10)) / 255;
  5937. this.g = Math.min(255, parseInt(color[2], 10)) / 255;
  5938. this.b = Math.min(255, parseInt(color[3], 10)) / 255;
  5939. handleAlpha(color[5]);
  5940. return this;
  5941. }
  5942. if (color = /^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(components)) {
  5943. this.r = Math.min(100, parseInt(color[1], 10)) / 100;
  5944. this.g = Math.min(100, parseInt(color[2], 10)) / 100;
  5945. this.b = Math.min(100, parseInt(color[3], 10)) / 100;
  5946. handleAlpha(color[5]);
  5947. return this;
  5948. }
  5949. break;
  5950. case "hsl":
  5951. case "hsla":
  5952. if (color = /^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(components)) {
  5953. var h = parseFloat(color[1]) / 360;
  5954. var s = parseInt(color[2], 10) / 100;
  5955. var l = parseInt(color[3], 10) / 100;
  5956. handleAlpha(color[5]);
  5957. return this.setHSL(h, s, l);
  5958. }
  5959. break;
  5960. }
  5961. } else if (m = /^\#([A-Fa-f0-9]+)$/.exec(style)) {
  5962. var hex = m[1];
  5963. var size = hex.length;
  5964. if (size === 3) {
  5965. this.r = parseInt(hex.charAt(0) + hex.charAt(0), 16) / 255;
  5966. this.g = parseInt(hex.charAt(1) + hex.charAt(1), 16) / 255;
  5967. this.b = parseInt(hex.charAt(2) + hex.charAt(2), 16) / 255;
  5968. return this;
  5969. } else if (size === 6) {
  5970. this.r = parseInt(hex.charAt(0) + hex.charAt(1), 16) / 255;
  5971. this.g = parseInt(hex.charAt(2) + hex.charAt(3), 16) / 255;
  5972. this.b = parseInt(hex.charAt(4) + hex.charAt(5), 16) / 255;
  5973. return this;
  5974. }
  5975. }
  5976. if (style && style.length > 0) {
  5977. return this.setColorName(style);
  5978. }
  5979. return this;
  5980. },
  5981. setColorName: function(style) {
  5982. var hex = _colorKeywords[style];
  5983. if (hex !== void 0) {
  5984. this.setHex(hex);
  5985. } else {
  5986. console.warn("THREE.Color: Unknown color " + style);
  5987. }
  5988. return this;
  5989. },
  5990. clone: function() {
  5991. return new this.constructor(this.r, this.g, this.b);
  5992. },
  5993. copy: function(color) {
  5994. this.r = color.r;
  5995. this.g = color.g;
  5996. this.b = color.b;
  5997. return this;
  5998. },
  5999. copyGammaToLinear: function(color, gammaFactor) {
  6000. if (gammaFactor === void 0)
  6001. gammaFactor = 2;
  6002. this.r = Math.pow(color.r, gammaFactor);
  6003. this.g = Math.pow(color.g, gammaFactor);
  6004. this.b = Math.pow(color.b, gammaFactor);
  6005. return this;
  6006. },
  6007. copyLinearToGamma: function(color, gammaFactor) {
  6008. if (gammaFactor === void 0)
  6009. gammaFactor = 2;
  6010. var safeInverse = gammaFactor > 0 ? 1 / gammaFactor : 1;
  6011. this.r = Math.pow(color.r, safeInverse);
  6012. this.g = Math.pow(color.g, safeInverse);
  6013. this.b = Math.pow(color.b, safeInverse);
  6014. return this;
  6015. },
  6016. convertGammaToLinear: function(gammaFactor) {
  6017. this.copyGammaToLinear(this, gammaFactor);
  6018. return this;
  6019. },
  6020. convertLinearToGamma: function(gammaFactor) {
  6021. this.copyLinearToGamma(this, gammaFactor);
  6022. return this;
  6023. },
  6024. copySRGBToLinear: function(color) {
  6025. this.r = SRGBToLinear(color.r);
  6026. this.g = SRGBToLinear(color.g);
  6027. this.b = SRGBToLinear(color.b);
  6028. return this;
  6029. },
  6030. copyLinearToSRGB: function(color) {
  6031. this.r = LinearToSRGB(color.r);
  6032. this.g = LinearToSRGB(color.g);
  6033. this.b = LinearToSRGB(color.b);
  6034. return this;
  6035. },
  6036. convertSRGBToLinear: function() {
  6037. this.copySRGBToLinear(this);
  6038. return this;
  6039. },
  6040. convertLinearToSRGB: function() {
  6041. this.copyLinearToSRGB(this);
  6042. return this;
  6043. },
  6044. getHex: function() {
  6045. return this.r * 255 << 16 ^ this.g * 255 << 8 ^ this.b * 255 << 0;
  6046. },
  6047. getHexString: function() {
  6048. return ("000000" + this.getHex().toString(16)).slice(-6);
  6049. },
  6050. getHSL: function(target) {
  6051. if (target === void 0) {
  6052. console.warn("THREE.Color: .getHSL() target is now required");
  6053. target = { h: 0, s: 0, l: 0 };
  6054. }
  6055. var r = this.r, g = this.g, b = this.b;
  6056. var max = Math.max(r, g, b);
  6057. var min = Math.min(r, g, b);
  6058. var hue, saturation;
  6059. var lightness = (min + max) / 2;
  6060. if (min === max) {
  6061. hue = 0;
  6062. saturation = 0;
  6063. } else {
  6064. var delta = max - min;
  6065. saturation = lightness <= 0.5 ? delta / (max + min) : delta / (2 - max - min);
  6066. switch (max) {
  6067. case r:
  6068. hue = (g - b) / delta + (g < b ? 6 : 0);
  6069. break;
  6070. case g:
  6071. hue = (b - r) / delta + 2;
  6072. break;
  6073. case b:
  6074. hue = (r - g) / delta + 4;
  6075. break;
  6076. }
  6077. hue /= 6;
  6078. }
  6079. target.h = hue;
  6080. target.s = saturation;
  6081. target.l = lightness;
  6082. return target;
  6083. },
  6084. getStyle: function() {
  6085. return "rgb(" + (this.r * 255 | 0) + "," + (this.g * 255 | 0) + "," + (this.b * 255 | 0) + ")";
  6086. },
  6087. offsetHSL: function(h, s, l) {
  6088. this.getHSL(_hslA);
  6089. _hslA.h += h;
  6090. _hslA.s += s;
  6091. _hslA.l += l;
  6092. this.setHSL(_hslA.h, _hslA.s, _hslA.l);
  6093. return this;
  6094. },
  6095. add: function(color) {
  6096. this.r += color.r;
  6097. this.g += color.g;
  6098. this.b += color.b;
  6099. return this;
  6100. },
  6101. addColors: function(color1, color2) {
  6102. this.r = color1.r + color2.r;
  6103. this.g = color1.g + color2.g;
  6104. this.b = color1.b + color2.b;
  6105. return this;
  6106. },
  6107. addScalar: function(s) {
  6108. this.r += s;
  6109. this.g += s;
  6110. this.b += s;
  6111. return this;
  6112. },
  6113. sub: function(color) {
  6114. this.r = Math.max(0, this.r - color.r);
  6115. this.g = Math.max(0, this.g - color.g);
  6116. this.b = Math.max(0, this.b - color.b);
  6117. return this;
  6118. },
  6119. multiply: function(color) {
  6120. this.r *= color.r;
  6121. this.g *= color.g;
  6122. this.b *= color.b;
  6123. return this;
  6124. },
  6125. multiplyScalar: function(s) {
  6126. this.r *= s;
  6127. this.g *= s;
  6128. this.b *= s;
  6129. return this;
  6130. },
  6131. lerp: function(color, alpha) {
  6132. this.r += (color.r - this.r) * alpha;
  6133. this.g += (color.g - this.g) * alpha;
  6134. this.b += (color.b - this.b) * alpha;
  6135. return this;
  6136. },
  6137. lerpHSL: function(color, alpha) {
  6138. this.getHSL(_hslA);
  6139. color.getHSL(_hslB);
  6140. var h = MathUtils.lerp(_hslA.h, _hslB.h, alpha);
  6141. var s = MathUtils.lerp(_hslA.s, _hslB.s, alpha);
  6142. var l = MathUtils.lerp(_hslA.l, _hslB.l, alpha);
  6143. this.setHSL(h, s, l);
  6144. return this;
  6145. },
  6146. equals: function(c) {
  6147. return c.r === this.r && c.g === this.g && c.b === this.b;
  6148. },
  6149. fromArray: function(array, offset) {
  6150. if (offset === void 0)
  6151. offset = 0;
  6152. this.r = array[offset];
  6153. this.g = array[offset + 1];
  6154. this.b = array[offset + 2];
  6155. return this;
  6156. },
  6157. toArray: function(array, offset) {
  6158. if (array === void 0)
  6159. array = [];
  6160. if (offset === void 0)
  6161. offset = 0;
  6162. array[offset] = this.r;
  6163. array[offset + 1] = this.g;
  6164. array[offset + 2] = this.b;
  6165. return array;
  6166. },
  6167. toJSON: function() {
  6168. return this.getHex();
  6169. }
  6170. });
  6171. Color.NAMES = _colorKeywords;
  6172. function Face3(a, b, c, normal, color, materialIndex) {
  6173. this.a = a;
  6174. this.b = b;
  6175. this.c = c;
  6176. this.normal = normal && normal.isVector3 ? normal : new Vector3();
  6177. this.vertexNormals = Array.isArray(normal) ? normal : [];
  6178. this.color = color && color.isColor ? color : new Color();
  6179. this.vertexColors = Array.isArray(color) ? color : [];
  6180. this.materialIndex = materialIndex !== void 0 ? materialIndex : 0;
  6181. }
  6182. Object.assign(Face3.prototype, {
  6183. clone: function() {
  6184. return new this.constructor().copy(this);
  6185. },
  6186. copy: function(source) {
  6187. this.a = source.a;
  6188. this.b = source.b;
  6189. this.c = source.c;
  6190. this.normal.copy(source.normal);
  6191. this.color.copy(source.color);
  6192. this.materialIndex = source.materialIndex;
  6193. for (var i2 = 0, il = source.vertexNormals.length; i2 < il; i2++) {
  6194. this.vertexNormals[i2] = source.vertexNormals[i2].clone();
  6195. }
  6196. for (var i2 = 0, il = source.vertexColors.length; i2 < il; i2++) {
  6197. this.vertexColors[i2] = source.vertexColors[i2].clone();
  6198. }
  6199. return this;
  6200. }
  6201. });
  6202. var materialId = 0;
  6203. function Material() {
  6204. Object.defineProperty(this, "id", { value: materialId++ });
  6205. this.uuid = MathUtils.generateUUID();
  6206. this.name = "";
  6207. this.type = "Material";
  6208. this.fog = true;
  6209. this.blending = NormalBlending;
  6210. this.side = FrontSide;
  6211. this.flatShading = false;
  6212. this.vertexTangents = false;
  6213. this.vertexColors = NoColors;
  6214. this.opacity = 1;
  6215. this.transparent = false;
  6216. this.blendSrc = SrcAlphaFactor;
  6217. this.blendDst = OneMinusSrcAlphaFactor;
  6218. this.blendEquation = AddEquation;
  6219. this.blendSrcAlpha = null;
  6220. this.blendDstAlpha = null;
  6221. this.blendEquationAlpha = null;
  6222. this.depthFunc = LessEqualDepth;
  6223. this.depthTest = true;
  6224. this.depthWrite = true;
  6225. this.stencilWriteMask = 255;
  6226. this.stencilFunc = AlwaysStencilFunc;
  6227. this.stencilRef = 0;
  6228. this.stencilFuncMask = 255;
  6229. this.stencilFail = KeepStencilOp;
  6230. this.stencilZFail = KeepStencilOp;
  6231. this.stencilZPass = KeepStencilOp;
  6232. this.stencilWrite = false;
  6233. this.clippingPlanes = null;
  6234. this.clipIntersection = false;
  6235. this.clipShadows = false;
  6236. this.shadowSide = null;
  6237. this.colorWrite = true;
  6238. this.precision = null;
  6239. this.polygonOffset = false;
  6240. this.polygonOffsetFactor = 0;
  6241. this.polygonOffsetUnits = 0;
  6242. this.dithering = false;
  6243. this.alphaTest = 0;
  6244. this.premultipliedAlpha = false;
  6245. this.visible = true;
  6246. this.toneMapped = true;
  6247. this.userData = {};
  6248. this.version = 0;
  6249. }
  6250. Material.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
  6251. constructor: Material,
  6252. isMaterial: true,
  6253. onBeforeCompile: function() {
  6254. },
  6255. setValues: function(values) {
  6256. if (values === void 0)
  6257. return;
  6258. for (var key in values) {
  6259. var newValue = values[key];
  6260. if (newValue === void 0) {
  6261. console.warn("THREE.Material: '" + key + "' parameter is undefined.");
  6262. continue;
  6263. }
  6264. if (key === "shading") {
  6265. console.warn("THREE." + this.type + ": .shading has been removed. Use the boolean .flatShading instead.");
  6266. this.flatShading = newValue === FlatShading ? true : false;
  6267. continue;
  6268. }
  6269. var currentValue = this[key];
  6270. if (currentValue === void 0) {
  6271. console.warn("THREE." + this.type + ": '" + key + "' is not a property of this material.");
  6272. continue;
  6273. }
  6274. if (currentValue && currentValue.isColor) {
  6275. currentValue.set(newValue);
  6276. } else if (currentValue && currentValue.isVector3 && (newValue && newValue.isVector3)) {
  6277. currentValue.copy(newValue);
  6278. } else {
  6279. this[key] = newValue;
  6280. }
  6281. }
  6282. },
  6283. toJSON: function(meta) {
  6284. var isRoot = meta === void 0 || typeof meta === "string";
  6285. if (isRoot) {
  6286. meta = {
  6287. textures: {},
  6288. images: {}
  6289. };
  6290. }
  6291. var data = {
  6292. metadata: {
  6293. version: 4.5,
  6294. type: "Material",
  6295. generator: "Material.toJSON"
  6296. }
  6297. };
  6298. data.uuid = this.uuid;
  6299. data.type = this.type;
  6300. if (this.name !== "")
  6301. data.name = this.name;
  6302. if (this.color && this.color.isColor)
  6303. data.color = this.color.getHex();
  6304. if (this.roughness !== void 0)
  6305. data.roughness = this.roughness;
  6306. if (this.metalness !== void 0)
  6307. data.metalness = this.metalness;
  6308. if (this.sheen && this.sheen.isColor)
  6309. data.sheen = this.sheen.getHex();
  6310. if (this.emissive && this.emissive.isColor)
  6311. data.emissive = this.emissive.getHex();
  6312. if (this.emissiveIntensity && this.emissiveIntensity !== 1)
  6313. data.emissiveIntensity = this.emissiveIntensity;
  6314. if (this.specular && this.specular.isColor)
  6315. data.specular = this.specular.getHex();
  6316. if (this.shininess !== void 0)
  6317. data.shininess = this.shininess;
  6318. if (this.clearcoat !== void 0)
  6319. data.clearcoat = this.clearcoat;
  6320. if (this.clearcoatRoughness !== void 0)
  6321. data.clearcoatRoughness = this.clearcoatRoughness;
  6322. if (this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture) {
  6323. data.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(meta).uuid;
  6324. data.clearcoatNormalScale = this.clearcoatNormalScale.toArray();
  6325. }
  6326. if (this.map && this.map.isTexture)
  6327. data.map = this.map.toJSON(meta).uuid;
  6328. if (this.matcap && this.matcap.isTexture)
  6329. data.matcap = this.matcap.toJSON(meta).uuid;
  6330. if (this.alphaMap && this.alphaMap.isTexture)
  6331. data.alphaMap = this.alphaMap.toJSON(meta).uuid;
  6332. if (this.lightMap && this.lightMap.isTexture)
  6333. data.lightMap = this.lightMap.toJSON(meta).uuid;
  6334. if (this.aoMap && this.aoMap.isTexture) {
  6335. data.aoMap = this.aoMap.toJSON(meta).uuid;
  6336. data.aoMapIntensity = this.aoMapIntensity;
  6337. }
  6338. if (this.bumpMap && this.bumpMap.isTexture) {
  6339. data.bumpMap = this.bumpMap.toJSON(meta).uuid;
  6340. data.bumpScale = this.bumpScale;
  6341. }
  6342. if (this.normalMap && this.normalMap.isTexture) {
  6343. data.normalMap = this.normalMap.toJSON(meta).uuid;
  6344. data.normalMapType = this.normalMapType;
  6345. data.normalScale = this.normalScale.toArray();
  6346. }
  6347. if (this.displacementMap && this.displacementMap.isTexture) {
  6348. data.displacementMap = this.displacementMap.toJSON(meta).uuid;
  6349. data.displacementScale = this.displacementScale;
  6350. data.displacementBias = this.displacementBias;
  6351. }
  6352. if (this.roughnessMap && this.roughnessMap.isTexture)
  6353. data.roughnessMap = this.roughnessMap.toJSON(meta).uuid;
  6354. if (this.metalnessMap && this.metalnessMap.isTexture)
  6355. data.metalnessMap = this.metalnessMap.toJSON(meta).uuid;
  6356. if (this.emissiveMap && this.emissiveMap.isTexture)
  6357. data.emissiveMap = this.emissiveMap.toJSON(meta).uuid;
  6358. if (this.specularMap && this.specularMap.isTexture)
  6359. data.specularMap = this.specularMap.toJSON(meta).uuid;
  6360. if (this.envMap && this.envMap.isTexture) {
  6361. data.envMap = this.envMap.toJSON(meta).uuid;
  6362. data.reflectivity = this.reflectivity;
  6363. data.refractionRatio = this.refractionRatio;
  6364. if (this.combine !== void 0)
  6365. data.combine = this.combine;
  6366. if (this.envMapIntensity !== void 0)
  6367. data.envMapIntensity = this.envMapIntensity;
  6368. }
  6369. if (this.gradientMap && this.gradientMap.isTexture) {
  6370. data.gradientMap = this.gradientMap.toJSON(meta).uuid;
  6371. }
  6372. if (this.size !== void 0)
  6373. data.size = this.size;
  6374. if (this.sizeAttenuation !== void 0)
  6375. data.sizeAttenuation = this.sizeAttenuation;
  6376. if (this.blending !== NormalBlending)
  6377. data.blending = this.blending;
  6378. if (this.flatShading === true)
  6379. data.flatShading = this.flatShading;
  6380. if (this.side !== FrontSide)
  6381. data.side = this.side;
  6382. if (this.vertexColors !== NoColors)
  6383. data.vertexColors = this.vertexColors;
  6384. if (this.opacity < 1)
  6385. data.opacity = this.opacity;
  6386. if (this.transparent === true)
  6387. data.transparent = this.transparent;
  6388. data.depthFunc = this.depthFunc;
  6389. data.depthTest = this.depthTest;
  6390. data.depthWrite = this.depthWrite;
  6391. data.stencilWrite = this.stencilWrite;
  6392. data.stencilWriteMask = this.stencilWriteMask;
  6393. data.stencilFunc = this.stencilFunc;
  6394. data.stencilRef = this.stencilRef;
  6395. data.stencilFuncMask = this.stencilFuncMask;
  6396. data.stencilFail = this.stencilFail;
  6397. data.stencilZFail = this.stencilZFail;
  6398. data.stencilZPass = this.stencilZPass;
  6399. if (this.rotation && this.rotation !== 0)
  6400. data.rotation = this.rotation;
  6401. if (this.polygonOffset === true)
  6402. data.polygonOffset = true;
  6403. if (this.polygonOffsetFactor !== 0)
  6404. data.polygonOffsetFactor = this.polygonOffsetFactor;
  6405. if (this.polygonOffsetUnits !== 0)
  6406. data.polygonOffsetUnits = this.polygonOffsetUnits;
  6407. if (this.linewidth && this.linewidth !== 1)
  6408. data.linewidth = this.linewidth;
  6409. if (this.dashSize !== void 0)
  6410. data.dashSize = this.dashSize;
  6411. if (this.gapSize !== void 0)
  6412. data.gapSize = this.gapSize;
  6413. if (this.scale !== void 0)
  6414. data.scale = this.scale;
  6415. if (this.dithering === true)
  6416. data.dithering = true;
  6417. if (this.alphaTest > 0)
  6418. data.alphaTest = this.alphaTest;
  6419. if (this.premultipliedAlpha === true)
  6420. data.premultipliedAlpha = this.premultipliedAlpha;
  6421. if (this.wireframe === true)
  6422. data.wireframe = this.wireframe;
  6423. if (this.wireframeLinewidth > 1)
  6424. data.wireframeLinewidth = this.wireframeLinewidth;
  6425. if (this.wireframeLinecap !== "round")
  6426. data.wireframeLinecap = this.wireframeLinecap;
  6427. if (this.wireframeLinejoin !== "round")
  6428. data.wireframeLinejoin = this.wireframeLinejoin;
  6429. if (this.morphTargets === true)
  6430. data.morphTargets = true;
  6431. if (this.morphNormals === true)
  6432. data.morphNormals = true;
  6433. if (this.skinning === true)
  6434. data.skinning = true;
  6435. if (this.visible === false)
  6436. data.visible = false;
  6437. if (this.toneMapped === false)
  6438. data.toneMapped = false;
  6439. if (JSON.stringify(this.userData) !== "{}")
  6440. data.userData = this.userData;
  6441. function extractFromCache(cache) {
  6442. var values = [];
  6443. for (var key in cache) {
  6444. var data2 = cache[key];
  6445. delete data2.metadata;
  6446. values.push(data2);
  6447. }
  6448. return values;
  6449. }
  6450. if (isRoot) {
  6451. var textures = extractFromCache(meta.textures);
  6452. var images = extractFromCache(meta.images);
  6453. if (textures.length > 0)
  6454. data.textures = textures;
  6455. if (images.length > 0)
  6456. data.images = images;
  6457. }
  6458. return data;
  6459. },
  6460. clone: function() {
  6461. return new this.constructor().copy(this);
  6462. },
  6463. copy: function(source) {
  6464. this.name = source.name;
  6465. this.fog = source.fog;
  6466. this.blending = source.blending;
  6467. this.side = source.side;
  6468. this.flatShading = source.flatShading;
  6469. this.vertexTangents = source.vertexTangents;
  6470. this.vertexColors = source.vertexColors;
  6471. this.opacity = source.opacity;
  6472. this.transparent = source.transparent;
  6473. this.blendSrc = source.blendSrc;
  6474. this.blendDst = source.blendDst;
  6475. this.blendEquation = source.blendEquation;
  6476. this.blendSrcAlpha = source.blendSrcAlpha;
  6477. this.blendDstAlpha = source.blendDstAlpha;
  6478. this.blendEquationAlpha = source.blendEquationAlpha;
  6479. this.depthFunc = source.depthFunc;
  6480. this.depthTest = source.depthTest;
  6481. this.depthWrite = source.depthWrite;
  6482. this.stencilWriteMask = source.stencilWriteMask;
  6483. this.stencilFunc = source.stencilFunc;
  6484. this.stencilRef = source.stencilRef;
  6485. this.stencilFuncMask = source.stencilFuncMask;
  6486. this.stencilFail = source.stencilFail;
  6487. this.stencilZFail = source.stencilZFail;
  6488. this.stencilZPass = source.stencilZPass;
  6489. this.stencilWrite = source.stencilWrite;
  6490. var srcPlanes = source.clippingPlanes, dstPlanes = null;
  6491. if (srcPlanes !== null) {
  6492. var n = srcPlanes.length;
  6493. dstPlanes = new Array(n);
  6494. for (var i2 = 0; i2 !== n; ++i2)
  6495. dstPlanes[i2] = srcPlanes[i2].clone();
  6496. }
  6497. this.clippingPlanes = dstPlanes;
  6498. this.clipIntersection = source.clipIntersection;
  6499. this.clipShadows = source.clipShadows;
  6500. this.shadowSide = source.shadowSide;
  6501. this.colorWrite = source.colorWrite;
  6502. this.precision = source.precision;
  6503. this.polygonOffset = source.polygonOffset;
  6504. this.polygonOffsetFactor = source.polygonOffsetFactor;
  6505. this.polygonOffsetUnits = source.polygonOffsetUnits;
  6506. this.dithering = source.dithering;
  6507. this.alphaTest = source.alphaTest;
  6508. this.premultipliedAlpha = source.premultipliedAlpha;
  6509. this.visible = source.visible;
  6510. this.toneMapped = source.toneMapped;
  6511. this.userData = JSON.parse(JSON.stringify(source.userData));
  6512. return this;
  6513. },
  6514. dispose: function() {
  6515. this.dispatchEvent({ type: "dispose" });
  6516. }
  6517. });
  6518. Object.defineProperty(Material.prototype, "needsUpdate", {
  6519. set: function(value) {
  6520. if (value === true)
  6521. this.version++;
  6522. }
  6523. });
  6524. function MeshBasicMaterial(parameters) {
  6525. Material.call(this);
  6526. this.type = "MeshBasicMaterial";
  6527. this.color = new Color(16777215);
  6528. this.map = null;
  6529. this.lightMap = null;
  6530. this.lightMapIntensity = 1;
  6531. this.aoMap = null;
  6532. this.aoMapIntensity = 1;
  6533. this.specularMap = null;
  6534. this.alphaMap = null;
  6535. this.envMap = null;
  6536. this.combine = MultiplyOperation;
  6537. this.reflectivity = 1;
  6538. this.refractionRatio = 0.98;
  6539. this.wireframe = false;
  6540. this.wireframeLinewidth = 1;
  6541. this.wireframeLinecap = "round";
  6542. this.wireframeLinejoin = "round";
  6543. this.skinning = false;
  6544. this.morphTargets = false;
  6545. this.setValues(parameters);
  6546. }
  6547. MeshBasicMaterial.prototype = Object.create(Material.prototype);
  6548. MeshBasicMaterial.prototype.constructor = MeshBasicMaterial;
  6549. MeshBasicMaterial.prototype.isMeshBasicMaterial = true;
  6550. MeshBasicMaterial.prototype.copy = function(source) {
  6551. Material.prototype.copy.call(this, source);
  6552. this.color.copy(source.color);
  6553. this.map = source.map;
  6554. this.lightMap = source.lightMap;
  6555. this.lightMapIntensity = source.lightMapIntensity;
  6556. this.aoMap = source.aoMap;
  6557. this.aoMapIntensity = source.aoMapIntensity;
  6558. this.specularMap = source.specularMap;
  6559. this.alphaMap = source.alphaMap;
  6560. this.envMap = source.envMap;
  6561. this.combine = source.combine;
  6562. this.reflectivity = source.reflectivity;
  6563. this.refractionRatio = source.refractionRatio;
  6564. this.wireframe = source.wireframe;
  6565. this.wireframeLinewidth = source.wireframeLinewidth;
  6566. this.wireframeLinecap = source.wireframeLinecap;
  6567. this.wireframeLinejoin = source.wireframeLinejoin;
  6568. this.skinning = source.skinning;
  6569. this.morphTargets = source.morphTargets;
  6570. return this;
  6571. };
  6572. var _vector$3 = new Vector3();
  6573. function BufferAttribute(array, itemSize, normalized) {
  6574. if (Array.isArray(array)) {
  6575. throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");
  6576. }
  6577. this.name = "";
  6578. this.array = array;
  6579. this.itemSize = itemSize;
  6580. this.count = array !== void 0 ? array.length / itemSize : 0;
  6581. this.normalized = normalized === true;
  6582. this.usage = StaticDrawUsage;
  6583. this.updateRange = { offset: 0, count: -1 };
  6584. this.version = 0;
  6585. }
  6586. Object.defineProperty(BufferAttribute.prototype, "needsUpdate", {
  6587. set: function(value) {
  6588. if (value === true)
  6589. this.version++;
  6590. }
  6591. });
  6592. Object.assign(BufferAttribute.prototype, {
  6593. isBufferAttribute: true,
  6594. onUploadCallback: function() {
  6595. },
  6596. setUsage: function(value) {
  6597. this.usage = value;
  6598. return this;
  6599. },
  6600. copy: function(source) {
  6601. this.name = source.name;
  6602. this.array = new source.array.constructor(source.array);
  6603. this.itemSize = source.itemSize;
  6604. this.count = source.count;
  6605. this.normalized = source.normalized;
  6606. this.usage = source.usage;
  6607. return this;
  6608. },
  6609. copyAt: function(index1, attribute, index2) {
  6610. index1 *= this.itemSize;
  6611. index2 *= attribute.itemSize;
  6612. for (var i2 = 0, l = this.itemSize; i2 < l; i2++) {
  6613. this.array[index1 + i2] = attribute.array[index2 + i2];
  6614. }
  6615. return this;
  6616. },
  6617. copyArray: function(array) {
  6618. this.array.set(array);
  6619. return this;
  6620. },
  6621. copyColorsArray: function(colors) {
  6622. var array = this.array, offset = 0;
  6623. for (var i2 = 0, l = colors.length; i2 < l; i2++) {
  6624. var color = colors[i2];
  6625. if (color === void 0) {
  6626. console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined", i2);
  6627. color = new Color();
  6628. }
  6629. array[offset++] = color.r;
  6630. array[offset++] = color.g;
  6631. array[offset++] = color.b;
  6632. }
  6633. return this;
  6634. },
  6635. copyVector2sArray: function(vectors) {
  6636. var array = this.array, offset = 0;
  6637. for (var i2 = 0, l = vectors.length; i2 < l; i2++) {
  6638. var vector = vectors[i2];
  6639. if (vector === void 0) {
  6640. console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined", i2);
  6641. vector = new Vector2();
  6642. }
  6643. array[offset++] = vector.x;
  6644. array[offset++] = vector.y;
  6645. }
  6646. return this;
  6647. },
  6648. copyVector3sArray: function(vectors) {
  6649. var array = this.array, offset = 0;
  6650. for (var i2 = 0, l = vectors.length; i2 < l; i2++) {
  6651. var vector = vectors[i2];
  6652. if (vector === void 0) {
  6653. console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined", i2);
  6654. vector = new Vector3();
  6655. }
  6656. array[offset++] = vector.x;
  6657. array[offset++] = vector.y;
  6658. array[offset++] = vector.z;
  6659. }
  6660. return this;
  6661. },
  6662. copyVector4sArray: function(vectors) {
  6663. var array = this.array, offset = 0;
  6664. for (var i2 = 0, l = vectors.length; i2 < l; i2++) {
  6665. var vector = vectors[i2];
  6666. if (vector === void 0) {
  6667. console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined", i2);
  6668. vector = new Vector4();
  6669. }
  6670. array[offset++] = vector.x;
  6671. array[offset++] = vector.y;
  6672. array[offset++] = vector.z;
  6673. array[offset++] = vector.w;
  6674. }
  6675. return this;
  6676. },
  6677. applyMatrix3: function(m) {
  6678. for (var i2 = 0, l = this.count; i2 < l; i2++) {
  6679. _vector$3.x = this.getX(i2);
  6680. _vector$3.y = this.getY(i2);
  6681. _vector$3.z = this.getZ(i2);
  6682. _vector$3.applyMatrix3(m);
  6683. this.setXYZ(i2, _vector$3.x, _vector$3.y, _vector$3.z);
  6684. }
  6685. return this;
  6686. },
  6687. applyMatrix4: function(m) {
  6688. for (var i2 = 0, l = this.count; i2 < l; i2++) {
  6689. _vector$3.x = this.getX(i2);
  6690. _vector$3.y = this.getY(i2);
  6691. _vector$3.z = this.getZ(i2);
  6692. _vector$3.applyMatrix4(m);
  6693. this.setXYZ(i2, _vector$3.x, _vector$3.y, _vector$3.z);
  6694. }
  6695. return this;
  6696. },
  6697. applyNormalMatrix: function(m) {
  6698. for (var i2 = 0, l = this.count; i2 < l; i2++) {
  6699. _vector$3.x = this.getX(i2);
  6700. _vector$3.y = this.getY(i2);
  6701. _vector$3.z = this.getZ(i2);
  6702. _vector$3.applyNormalMatrix(m);
  6703. this.setXYZ(i2, _vector$3.x, _vector$3.y, _vector$3.z);
  6704. }
  6705. return this;
  6706. },
  6707. transformDirection: function(m) {
  6708. for (var i2 = 0, l = this.count; i2 < l; i2++) {
  6709. _vector$3.x = this.getX(i2);
  6710. _vector$3.y = this.getY(i2);
  6711. _vector$3.z = this.getZ(i2);
  6712. _vector$3.transformDirection(m);
  6713. this.setXYZ(i2, _vector$3.x, _vector$3.y, _vector$3.z);
  6714. }
  6715. return this;
  6716. },
  6717. set: function(value, offset) {
  6718. if (offset === void 0)
  6719. offset = 0;
  6720. this.array.set(value, offset);
  6721. return this;
  6722. },
  6723. getX: function(index) {
  6724. return this.array[index * this.itemSize];
  6725. },
  6726. setX: function(index, x) {
  6727. this.array[index * this.itemSize] = x;
  6728. return this;
  6729. },
  6730. getY: function(index) {
  6731. return this.array[index * this.itemSize + 1];
  6732. },
  6733. setY: function(index, y) {
  6734. this.array[index * this.itemSize + 1] = y;
  6735. return this;
  6736. },
  6737. getZ: function(index) {
  6738. return this.array[index * this.itemSize + 2];
  6739. },
  6740. setZ: function(index, z) {
  6741. this.array[index * this.itemSize + 2] = z;
  6742. return this;
  6743. },
  6744. getW: function(index) {
  6745. return this.array[index * this.itemSize + 3];
  6746. },
  6747. setW: function(index, w) {
  6748. this.array[index * this.itemSize + 3] = w;
  6749. return this;
  6750. },
  6751. setXY: function(index, x, y) {
  6752. index *= this.itemSize;
  6753. this.array[index + 0] = x;
  6754. this.array[index + 1] = y;
  6755. return this;
  6756. },
  6757. setXYZ: function(index, x, y, z) {
  6758. index *= this.itemSize;
  6759. this.array[index + 0] = x;
  6760. this.array[index + 1] = y;
  6761. this.array[index + 2] = z;
  6762. return this;
  6763. },
  6764. setXYZW: function(index, x, y, z, w) {
  6765. index *= this.itemSize;
  6766. this.array[index + 0] = x;
  6767. this.array[index + 1] = y;
  6768. this.array[index + 2] = z;
  6769. this.array[index + 3] = w;
  6770. return this;
  6771. },
  6772. onUpload: function(callback) {
  6773. this.onUploadCallback = callback;
  6774. return this;
  6775. },
  6776. clone: function() {
  6777. return new this.constructor(this.array, this.itemSize).copy(this);
  6778. },
  6779. toJSON: function() {
  6780. return {
  6781. itemSize: this.itemSize,
  6782. type: this.array.constructor.name,
  6783. array: Array.prototype.slice.call(this.array),
  6784. normalized: this.normalized
  6785. };
  6786. }
  6787. });
  6788. function Int8BufferAttribute(array, itemSize, normalized) {
  6789. BufferAttribute.call(this, new Int8Array(array), itemSize, normalized);
  6790. }
  6791. Int8BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
  6792. Int8BufferAttribute.prototype.constructor = Int8BufferAttribute;
  6793. function Uint8BufferAttribute(array, itemSize, normalized) {
  6794. BufferAttribute.call(this, new Uint8Array(array), itemSize, normalized);
  6795. }
  6796. Uint8BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
  6797. Uint8BufferAttribute.prototype.constructor = Uint8BufferAttribute;
  6798. function Uint8ClampedBufferAttribute(array, itemSize, normalized) {
  6799. BufferAttribute.call(this, new Uint8ClampedArray(array), itemSize, normalized);
  6800. }
  6801. Uint8ClampedBufferAttribute.prototype = Object.create(BufferAttribute.prototype);
  6802. Uint8ClampedBufferAttribute.prototype.constructor = Uint8ClampedBufferAttribute;
  6803. function Int16BufferAttribute(array, itemSize, normalized) {
  6804. BufferAttribute.call(this, new Int16Array(array), itemSize, normalized);
  6805. }
  6806. Int16BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
  6807. Int16BufferAttribute.prototype.constructor = Int16BufferAttribute;
  6808. function Uint16BufferAttribute(array, itemSize, normalized) {
  6809. BufferAttribute.call(this, new Uint16Array(array), itemSize, normalized);
  6810. }
  6811. Uint16BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
  6812. Uint16BufferAttribute.prototype.constructor = Uint16BufferAttribute;
  6813. function Int32BufferAttribute(array, itemSize, normalized) {
  6814. BufferAttribute.call(this, new Int32Array(array), itemSize, normalized);
  6815. }
  6816. Int32BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
  6817. Int32BufferAttribute.prototype.constructor = Int32BufferAttribute;
  6818. function Uint32BufferAttribute(array, itemSize, normalized) {
  6819. BufferAttribute.call(this, new Uint32Array(array), itemSize, normalized);
  6820. }
  6821. Uint32BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
  6822. Uint32BufferAttribute.prototype.constructor = Uint32BufferAttribute;
  6823. function Float32BufferAttribute(array, itemSize, normalized) {
  6824. BufferAttribute.call(this, new Float32Array(array), itemSize, normalized);
  6825. }
  6826. Float32BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
  6827. Float32BufferAttribute.prototype.constructor = Float32BufferAttribute;
  6828. function Float64BufferAttribute(array, itemSize, normalized) {
  6829. BufferAttribute.call(this, new Float64Array(array), itemSize, normalized);
  6830. }
  6831. Float64BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
  6832. Float64BufferAttribute.prototype.constructor = Float64BufferAttribute;
  6833. function DirectGeometry() {
  6834. this.vertices = [];
  6835. this.normals = [];
  6836. this.colors = [];
  6837. this.uvs = [];
  6838. this.uvs2 = [];
  6839. this.groups = [];
  6840. this.morphTargets = {};
  6841. this.skinWeights = [];
  6842. this.skinIndices = [];
  6843. this.boundingBox = null;
  6844. this.boundingSphere = null;
  6845. this.verticesNeedUpdate = false;
  6846. this.normalsNeedUpdate = false;
  6847. this.colorsNeedUpdate = false;
  6848. this.uvsNeedUpdate = false;
  6849. this.groupsNeedUpdate = false;
  6850. }
  6851. Object.assign(DirectGeometry.prototype, {
  6852. computeGroups: function(geometry) {
  6853. var group;
  6854. var groups = [];
  6855. var materialIndex = void 0;
  6856. var faces = geometry.faces;
  6857. for (var i2 = 0; i2 < faces.length; i2++) {
  6858. var face = faces[i2];
  6859. if (face.materialIndex !== materialIndex) {
  6860. materialIndex = face.materialIndex;
  6861. if (group !== void 0) {
  6862. group.count = i2 * 3 - group.start;
  6863. groups.push(group);
  6864. }
  6865. group = {
  6866. start: i2 * 3,
  6867. materialIndex
  6868. };
  6869. }
  6870. }
  6871. if (group !== void 0) {
  6872. group.count = i2 * 3 - group.start;
  6873. groups.push(group);
  6874. }
  6875. this.groups = groups;
  6876. },
  6877. fromGeometry: function(geometry) {
  6878. var faces = geometry.faces;
  6879. var vertices = geometry.vertices;
  6880. var faceVertexUvs = geometry.faceVertexUvs;
  6881. var hasFaceVertexUv = faceVertexUvs[0] && faceVertexUvs[0].length > 0;
  6882. var hasFaceVertexUv2 = faceVertexUvs[1] && faceVertexUvs[1].length > 0;
  6883. var morphTargets = geometry.morphTargets;
  6884. var morphTargetsLength = morphTargets.length;
  6885. var morphTargetsPosition;
  6886. if (morphTargetsLength > 0) {
  6887. morphTargetsPosition = [];
  6888. for (var i2 = 0; i2 < morphTargetsLength; i2++) {
  6889. morphTargetsPosition[i2] = {
  6890. name: morphTargets[i2].name,
  6891. data: []
  6892. };
  6893. }
  6894. this.morphTargets.position = morphTargetsPosition;
  6895. }
  6896. var morphNormals = geometry.morphNormals;
  6897. var morphNormalsLength = morphNormals.length;
  6898. var morphTargetsNormal;
  6899. if (morphNormalsLength > 0) {
  6900. morphTargetsNormal = [];
  6901. for (var i2 = 0; i2 < morphNormalsLength; i2++) {
  6902. morphTargetsNormal[i2] = {
  6903. name: morphNormals[i2].name,
  6904. data: []
  6905. };
  6906. }
  6907. this.morphTargets.normal = morphTargetsNormal;
  6908. }
  6909. var skinIndices = geometry.skinIndices;
  6910. var skinWeights = geometry.skinWeights;
  6911. var hasSkinIndices = skinIndices.length === vertices.length;
  6912. var hasSkinWeights = skinWeights.length === vertices.length;
  6913. if (vertices.length > 0 && faces.length === 0) {
  6914. console.error("THREE.DirectGeometry: Faceless geometries are not supported.");
  6915. }
  6916. for (var i2 = 0; i2 < faces.length; i2++) {
  6917. var face = faces[i2];
  6918. this.vertices.push(vertices[face.a], vertices[face.b], vertices[face.c]);
  6919. var vertexNormals = face.vertexNormals;
  6920. if (vertexNormals.length === 3) {
  6921. this.normals.push(vertexNormals[0], vertexNormals[1], vertexNormals[2]);
  6922. } else {
  6923. var normal = face.normal;
  6924. this.normals.push(normal, normal, normal);
  6925. }
  6926. var vertexColors = face.vertexColors;
  6927. if (vertexColors.length === 3) {
  6928. this.colors.push(vertexColors[0], vertexColors[1], vertexColors[2]);
  6929. } else {
  6930. var color = face.color;
  6931. this.colors.push(color, color, color);
  6932. }
  6933. if (hasFaceVertexUv === true) {
  6934. var vertexUvs = faceVertexUvs[0][i2];
  6935. if (vertexUvs !== void 0) {
  6936. this.uvs.push(vertexUvs[0], vertexUvs[1], vertexUvs[2]);
  6937. } else {
  6938. console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ", i2);
  6939. this.uvs.push(new Vector2(), new Vector2(), new Vector2());
  6940. }
  6941. }
  6942. if (hasFaceVertexUv2 === true) {
  6943. var vertexUvs = faceVertexUvs[1][i2];
  6944. if (vertexUvs !== void 0) {
  6945. this.uvs2.push(vertexUvs[0], vertexUvs[1], vertexUvs[2]);
  6946. } else {
  6947. console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ", i2);
  6948. this.uvs2.push(new Vector2(), new Vector2(), new Vector2());
  6949. }
  6950. }
  6951. for (var j = 0; j < morphTargetsLength; j++) {
  6952. var morphTarget = morphTargets[j].vertices;
  6953. morphTargetsPosition[j].data.push(morphTarget[face.a], morphTarget[face.b], morphTarget[face.c]);
  6954. }
  6955. for (var j = 0; j < morphNormalsLength; j++) {
  6956. var morphNormal = morphNormals[j].vertexNormals[i2];
  6957. morphTargetsNormal[j].data.push(morphNormal.a, morphNormal.b, morphNormal.c);
  6958. }
  6959. if (hasSkinIndices) {
  6960. this.skinIndices.push(skinIndices[face.a], skinIndices[face.b], skinIndices[face.c]);
  6961. }
  6962. if (hasSkinWeights) {
  6963. this.skinWeights.push(skinWeights[face.a], skinWeights[face.b], skinWeights[face.c]);
  6964. }
  6965. }
  6966. this.computeGroups(geometry);
  6967. this.verticesNeedUpdate = geometry.verticesNeedUpdate;
  6968. this.normalsNeedUpdate = geometry.normalsNeedUpdate;
  6969. this.colorsNeedUpdate = geometry.colorsNeedUpdate;
  6970. this.uvsNeedUpdate = geometry.uvsNeedUpdate;
  6971. this.groupsNeedUpdate = geometry.groupsNeedUpdate;
  6972. if (geometry.boundingSphere !== null) {
  6973. this.boundingSphere = geometry.boundingSphere.clone();
  6974. }
  6975. if (geometry.boundingBox !== null) {
  6976. this.boundingBox = geometry.boundingBox.clone();
  6977. }
  6978. return this;
  6979. }
  6980. });
  6981. function arrayMax(array) {
  6982. if (array.length === 0)
  6983. return -Infinity;
  6984. var max = array[0];
  6985. for (var i2 = 1, l = array.length; i2 < l; ++i2) {
  6986. if (array[i2] > max)
  6987. max = array[i2];
  6988. }
  6989. return max;
  6990. }
  6991. var _bufferGeometryId = 1;
  6992. var _m1$2 = new Matrix4();
  6993. var _obj = new Object3D();
  6994. var _offset = new Vector3();
  6995. var _box$2 = new Box3();
  6996. var _boxMorphTargets = new Box3();
  6997. var _vector$4 = new Vector3();
  6998. function BufferGeometry() {
  6999. Object.defineProperty(this, "id", { value: _bufferGeometryId += 2 });
  7000. this.uuid = MathUtils.generateUUID();
  7001. this.name = "";
  7002. this.type = "BufferGeometry";
  7003. this.index = null;
  7004. this.attributes = {};
  7005. this.morphAttributes = {};
  7006. this.morphTargetsRelative = false;
  7007. this.groups = [];
  7008. this.boundingBox = null;
  7009. this.boundingSphere = null;
  7010. this.drawRange = { start: 0, count: Infinity };
  7011. this.userData = {};
  7012. }
  7013. BufferGeometry.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
  7014. constructor: BufferGeometry,
  7015. isBufferGeometry: true,
  7016. getIndex: function() {
  7017. return this.index;
  7018. },
  7019. setIndex: function(index) {
  7020. if (Array.isArray(index)) {
  7021. this.index = new (arrayMax(index) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute)(index, 1);
  7022. } else {
  7023. this.index = index;
  7024. }
  7025. },
  7026. getAttribute: function(name) {
  7027. return this.attributes[name];
  7028. },
  7029. setAttribute: function(name, attribute) {
  7030. this.attributes[name] = attribute;
  7031. return this;
  7032. },
  7033. deleteAttribute: function(name) {
  7034. delete this.attributes[name];
  7035. return this;
  7036. },
  7037. addGroup: function(start, count, materialIndex) {
  7038. this.groups.push({
  7039. start,
  7040. count,
  7041. materialIndex: materialIndex !== void 0 ? materialIndex : 0
  7042. });
  7043. },
  7044. clearGroups: function() {
  7045. this.groups = [];
  7046. },
  7047. setDrawRange: function(start, count) {
  7048. this.drawRange.start = start;
  7049. this.drawRange.count = count;
  7050. },
  7051. applyMatrix4: function(matrix) {
  7052. var position = this.attributes.position;
  7053. if (position !== void 0) {
  7054. position.applyMatrix4(matrix);
  7055. position.needsUpdate = true;
  7056. }
  7057. var normal = this.attributes.normal;
  7058. if (normal !== void 0) {
  7059. var normalMatrix = new Matrix3().getNormalMatrix(matrix);
  7060. normal.applyNormalMatrix(normalMatrix);
  7061. normal.needsUpdate = true;
  7062. }
  7063. var tangent = this.attributes.tangent;
  7064. if (tangent !== void 0) {
  7065. tangent.transformDirection(matrix);
  7066. tangent.needsUpdate = true;
  7067. }
  7068. if (this.boundingBox !== null) {
  7069. this.computeBoundingBox();
  7070. }
  7071. if (this.boundingSphere !== null) {
  7072. this.computeBoundingSphere();
  7073. }
  7074. return this;
  7075. },
  7076. rotateX: function(angle) {
  7077. _m1$2.makeRotationX(angle);
  7078. this.applyMatrix4(_m1$2);
  7079. return this;
  7080. },
  7081. rotateY: function(angle) {
  7082. _m1$2.makeRotationY(angle);
  7083. this.applyMatrix4(_m1$2);
  7084. return this;
  7085. },
  7086. rotateZ: function(angle) {
  7087. _m1$2.makeRotationZ(angle);
  7088. this.applyMatrix4(_m1$2);
  7089. return this;
  7090. },
  7091. translate: function(x, y, z) {
  7092. _m1$2.makeTranslation(x, y, z);
  7093. this.applyMatrix4(_m1$2);
  7094. return this;
  7095. },
  7096. scale: function(x, y, z) {
  7097. _m1$2.makeScale(x, y, z);
  7098. this.applyMatrix4(_m1$2);
  7099. return this;
  7100. },
  7101. lookAt: function(vector) {
  7102. _obj.lookAt(vector);
  7103. _obj.updateMatrix();
  7104. this.applyMatrix4(_obj.matrix);
  7105. return this;
  7106. },
  7107. center: function() {
  7108. this.computeBoundingBox();
  7109. this.boundingBox.getCenter(_offset).negate();
  7110. this.translate(_offset.x, _offset.y, _offset.z);
  7111. return this;
  7112. },
  7113. setFromObject: function(object) {
  7114. var geometry = object.geometry;
  7115. if (object.isPoints || object.isLine) {
  7116. var positions = new Float32BufferAttribute(geometry.vertices.length * 3, 3);
  7117. var colors = new Float32BufferAttribute(geometry.colors.length * 3, 3);
  7118. this.setAttribute("position", positions.copyVector3sArray(geometry.vertices));
  7119. this.setAttribute("color", colors.copyColorsArray(geometry.colors));
  7120. if (geometry.lineDistances && geometry.lineDistances.length === geometry.vertices.length) {
  7121. var lineDistances = new Float32BufferAttribute(geometry.lineDistances.length, 1);
  7122. this.setAttribute("lineDistance", lineDistances.copyArray(geometry.lineDistances));
  7123. }
  7124. if (geometry.boundingSphere !== null) {
  7125. this.boundingSphere = geometry.boundingSphere.clone();
  7126. }
  7127. if (geometry.boundingBox !== null) {
  7128. this.boundingBox = geometry.boundingBox.clone();
  7129. }
  7130. } else if (object.isMesh) {
  7131. if (geometry && geometry.isGeometry) {
  7132. this.fromGeometry(geometry);
  7133. }
  7134. }
  7135. return this;
  7136. },
  7137. setFromPoints: function(points) {
  7138. var position = [];
  7139. for (var i2 = 0, l = points.length; i2 < l; i2++) {
  7140. var point = points[i2];
  7141. position.push(point.x, point.y, point.z || 0);
  7142. }
  7143. this.setAttribute("position", new Float32BufferAttribute(position, 3));
  7144. return this;
  7145. },
  7146. updateFromObject: function(object) {
  7147. var geometry = object.geometry;
  7148. if (object.isMesh) {
  7149. var direct = geometry.__directGeometry;
  7150. if (geometry.elementsNeedUpdate === true) {
  7151. direct = void 0;
  7152. geometry.elementsNeedUpdate = false;
  7153. }
  7154. if (direct === void 0) {
  7155. return this.fromGeometry(geometry);
  7156. }
  7157. direct.verticesNeedUpdate = geometry.verticesNeedUpdate;
  7158. direct.normalsNeedUpdate = geometry.normalsNeedUpdate;
  7159. direct.colorsNeedUpdate = geometry.colorsNeedUpdate;
  7160. direct.uvsNeedUpdate = geometry.uvsNeedUpdate;
  7161. direct.groupsNeedUpdate = geometry.groupsNeedUpdate;
  7162. geometry.verticesNeedUpdate = false;
  7163. geometry.normalsNeedUpdate = false;
  7164. geometry.colorsNeedUpdate = false;
  7165. geometry.uvsNeedUpdate = false;
  7166. geometry.groupsNeedUpdate = false;
  7167. geometry = direct;
  7168. }
  7169. var attribute;
  7170. if (geometry.verticesNeedUpdate === true) {
  7171. attribute = this.attributes.position;
  7172. if (attribute !== void 0) {
  7173. attribute.copyVector3sArray(geometry.vertices);
  7174. attribute.needsUpdate = true;
  7175. }
  7176. geometry.verticesNeedUpdate = false;
  7177. }
  7178. if (geometry.normalsNeedUpdate === true) {
  7179. attribute = this.attributes.normal;
  7180. if (attribute !== void 0) {
  7181. attribute.copyVector3sArray(geometry.normals);
  7182. attribute.needsUpdate = true;
  7183. }
  7184. geometry.normalsNeedUpdate = false;
  7185. }
  7186. if (geometry.colorsNeedUpdate === true) {
  7187. attribute = this.attributes.color;
  7188. if (attribute !== void 0) {
  7189. attribute.copyColorsArray(geometry.colors);
  7190. attribute.needsUpdate = true;
  7191. }
  7192. geometry.colorsNeedUpdate = false;
  7193. }
  7194. if (geometry.uvsNeedUpdate) {
  7195. attribute = this.attributes.uv;
  7196. if (attribute !== void 0) {
  7197. attribute.copyVector2sArray(geometry.uvs);
  7198. attribute.needsUpdate = true;
  7199. }
  7200. geometry.uvsNeedUpdate = false;
  7201. }
  7202. if (geometry.lineDistancesNeedUpdate) {
  7203. attribute = this.attributes.lineDistance;
  7204. if (attribute !== void 0) {
  7205. attribute.copyArray(geometry.lineDistances);
  7206. attribute.needsUpdate = true;
  7207. }
  7208. geometry.lineDistancesNeedUpdate = false;
  7209. }
  7210. if (geometry.groupsNeedUpdate) {
  7211. geometry.computeGroups(object.geometry);
  7212. this.groups = geometry.groups;
  7213. geometry.groupsNeedUpdate = false;
  7214. }
  7215. return this;
  7216. },
  7217. fromGeometry: function(geometry) {
  7218. geometry.__directGeometry = new DirectGeometry().fromGeometry(geometry);
  7219. return this.fromDirectGeometry(geometry.__directGeometry);
  7220. },
  7221. fromDirectGeometry: function(geometry) {
  7222. var positions = new Float32Array(geometry.vertices.length * 3);
  7223. this.setAttribute("position", new BufferAttribute(positions, 3).copyVector3sArray(geometry.vertices));
  7224. if (geometry.normals.length > 0) {
  7225. var normals = new Float32Array(geometry.normals.length * 3);
  7226. this.setAttribute("normal", new BufferAttribute(normals, 3).copyVector3sArray(geometry.normals));
  7227. }
  7228. if (geometry.colors.length > 0) {
  7229. var colors = new Float32Array(geometry.colors.length * 3);
  7230. this.setAttribute("color", new BufferAttribute(colors, 3).copyColorsArray(geometry.colors));
  7231. }
  7232. if (geometry.uvs.length > 0) {
  7233. var uvs = new Float32Array(geometry.uvs.length * 2);
  7234. this.setAttribute("uv", new BufferAttribute(uvs, 2).copyVector2sArray(geometry.uvs));
  7235. }
  7236. if (geometry.uvs2.length > 0) {
  7237. var uvs2 = new Float32Array(geometry.uvs2.length * 2);
  7238. this.setAttribute("uv2", new BufferAttribute(uvs2, 2).copyVector2sArray(geometry.uvs2));
  7239. }
  7240. this.groups = geometry.groups;
  7241. for (var name in geometry.morphTargets) {
  7242. var array = [];
  7243. var morphTargets = geometry.morphTargets[name];
  7244. for (var i2 = 0, l = morphTargets.length; i2 < l; i2++) {
  7245. var morphTarget = morphTargets[i2];
  7246. var attribute = new Float32BufferAttribute(morphTarget.data.length * 3, 3);
  7247. attribute.name = morphTarget.name;
  7248. array.push(attribute.copyVector3sArray(morphTarget.data));
  7249. }
  7250. this.morphAttributes[name] = array;
  7251. }
  7252. if (geometry.skinIndices.length > 0) {
  7253. var skinIndices = new Float32BufferAttribute(geometry.skinIndices.length * 4, 4);
  7254. this.setAttribute("skinIndex", skinIndices.copyVector4sArray(geometry.skinIndices));
  7255. }
  7256. if (geometry.skinWeights.length > 0) {
  7257. var skinWeights = new Float32BufferAttribute(geometry.skinWeights.length * 4, 4);
  7258. this.setAttribute("skinWeight", skinWeights.copyVector4sArray(geometry.skinWeights));
  7259. }
  7260. if (geometry.boundingSphere !== null) {
  7261. this.boundingSphere = geometry.boundingSphere.clone();
  7262. }
  7263. if (geometry.boundingBox !== null) {
  7264. this.boundingBox = geometry.boundingBox.clone();
  7265. }
  7266. return this;
  7267. },
  7268. computeBoundingBox: function() {
  7269. if (this.boundingBox === null) {
  7270. this.boundingBox = new Box3();
  7271. }
  7272. var position = this.attributes.position;
  7273. var morphAttributesPosition = this.morphAttributes.position;
  7274. if (position !== void 0) {
  7275. this.boundingBox.setFromBufferAttribute(position);
  7276. if (morphAttributesPosition) {
  7277. for (var i2 = 0, il = morphAttributesPosition.length; i2 < il; i2++) {
  7278. var morphAttribute = morphAttributesPosition[i2];
  7279. _box$2.setFromBufferAttribute(morphAttribute);
  7280. if (this.morphTargetsRelative) {
  7281. _vector$4.addVectors(this.boundingBox.min, _box$2.min);
  7282. this.boundingBox.expandByPoint(_vector$4);
  7283. _vector$4.addVectors(this.boundingBox.max, _box$2.max);
  7284. this.boundingBox.expandByPoint(_vector$4);
  7285. } else {
  7286. this.boundingBox.expandByPoint(_box$2.min);
  7287. this.boundingBox.expandByPoint(_box$2.max);
  7288. }
  7289. }
  7290. }
  7291. } else {
  7292. this.boundingBox.makeEmpty();
  7293. }
  7294. if (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) {
  7295. console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this);
  7296. }
  7297. },
  7298. computeBoundingSphere: function() {
  7299. if (this.boundingSphere === null) {
  7300. this.boundingSphere = new Sphere();
  7301. }
  7302. var position = this.attributes.position;
  7303. var morphAttributesPosition = this.morphAttributes.position;
  7304. if (position) {
  7305. var center = this.boundingSphere.center;
  7306. _box$2.setFromBufferAttribute(position);
  7307. if (morphAttributesPosition) {
  7308. for (var i2 = 0, il = morphAttributesPosition.length; i2 < il; i2++) {
  7309. var morphAttribute = morphAttributesPosition[i2];
  7310. _boxMorphTargets.setFromBufferAttribute(morphAttribute);
  7311. if (this.morphTargetsRelative) {
  7312. _vector$4.addVectors(_box$2.min, _boxMorphTargets.min);
  7313. _box$2.expandByPoint(_vector$4);
  7314. _vector$4.addVectors(_box$2.max, _boxMorphTargets.max);
  7315. _box$2.expandByPoint(_vector$4);
  7316. } else {
  7317. _box$2.expandByPoint(_boxMorphTargets.min);
  7318. _box$2.expandByPoint(_boxMorphTargets.max);
  7319. }
  7320. }
  7321. }
  7322. _box$2.getCenter(center);
  7323. var maxRadiusSq = 0;
  7324. for (var i2 = 0, il = position.count; i2 < il; i2++) {
  7325. _vector$4.fromBufferAttribute(position, i2);
  7326. maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_vector$4));
  7327. }
  7328. if (morphAttributesPosition) {
  7329. for (var i2 = 0, il = morphAttributesPosition.length; i2 < il; i2++) {
  7330. var morphAttribute = morphAttributesPosition[i2];
  7331. var morphTargetsRelative = this.morphTargetsRelative;
  7332. for (var j = 0, jl = morphAttribute.count; j < jl; j++) {
  7333. _vector$4.fromBufferAttribute(morphAttribute, j);
  7334. if (morphTargetsRelative) {
  7335. _offset.fromBufferAttribute(position, j);
  7336. _vector$4.add(_offset);
  7337. }
  7338. maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_vector$4));
  7339. }
  7340. }
  7341. }
  7342. this.boundingSphere.radius = Math.sqrt(maxRadiusSq);
  7343. if (isNaN(this.boundingSphere.radius)) {
  7344. console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this);
  7345. }
  7346. }
  7347. },
  7348. computeFaceNormals: function() {
  7349. },
  7350. computeVertexNormals: function() {
  7351. var index = this.index;
  7352. var attributes = this.attributes;
  7353. if (attributes.position) {
  7354. var positions = attributes.position.array;
  7355. if (attributes.normal === void 0) {
  7356. this.setAttribute("normal", new BufferAttribute(new Float32Array(positions.length), 3));
  7357. } else {
  7358. var array = attributes.normal.array;
  7359. for (var i2 = 0, il = array.length; i2 < il; i2++) {
  7360. array[i2] = 0;
  7361. }
  7362. }
  7363. var normals = attributes.normal.array;
  7364. var vA, vB, vC;
  7365. var pA = new Vector3(), pB = new Vector3(), pC = new Vector3();
  7366. var cb = new Vector3(), ab = new Vector3();
  7367. if (index) {
  7368. var indices = index.array;
  7369. for (var i2 = 0, il = index.count; i2 < il; i2 += 3) {
  7370. vA = indices[i2 + 0] * 3;
  7371. vB = indices[i2 + 1] * 3;
  7372. vC = indices[i2 + 2] * 3;
  7373. pA.fromArray(positions, vA);
  7374. pB.fromArray(positions, vB);
  7375. pC.fromArray(positions, vC);
  7376. cb.subVectors(pC, pB);
  7377. ab.subVectors(pA, pB);
  7378. cb.cross(ab);
  7379. normals[vA] += cb.x;
  7380. normals[vA + 1] += cb.y;
  7381. normals[vA + 2] += cb.z;
  7382. normals[vB] += cb.x;
  7383. normals[vB + 1] += cb.y;
  7384. normals[vB + 2] += cb.z;
  7385. normals[vC] += cb.x;
  7386. normals[vC + 1] += cb.y;
  7387. normals[vC + 2] += cb.z;
  7388. }
  7389. } else {
  7390. for (var i2 = 0, il = positions.length; i2 < il; i2 += 9) {
  7391. pA.fromArray(positions, i2);
  7392. pB.fromArray(positions, i2 + 3);
  7393. pC.fromArray(positions, i2 + 6);
  7394. cb.subVectors(pC, pB);
  7395. ab.subVectors(pA, pB);
  7396. cb.cross(ab);
  7397. normals[i2] = cb.x;
  7398. normals[i2 + 1] = cb.y;
  7399. normals[i2 + 2] = cb.z;
  7400. normals[i2 + 3] = cb.x;
  7401. normals[i2 + 4] = cb.y;
  7402. normals[i2 + 5] = cb.z;
  7403. normals[i2 + 6] = cb.x;
  7404. normals[i2 + 7] = cb.y;
  7405. normals[i2 + 8] = cb.z;
  7406. }
  7407. }
  7408. this.normalizeNormals();
  7409. attributes.normal.needsUpdate = true;
  7410. }
  7411. },
  7412. merge: function(geometry, offset) {
  7413. if (!(geometry && geometry.isBufferGeometry)) {
  7414. console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.", geometry);
  7415. return;
  7416. }
  7417. if (offset === void 0) {
  7418. offset = 0;
  7419. console.warn(
  7420. "THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."
  7421. );
  7422. }
  7423. var attributes = this.attributes;
  7424. for (var key in attributes) {
  7425. if (geometry.attributes[key] === void 0)
  7426. continue;
  7427. var attribute1 = attributes[key];
  7428. var attributeArray1 = attribute1.array;
  7429. var attribute2 = geometry.attributes[key];
  7430. var attributeArray2 = attribute2.array;
  7431. var attributeOffset = attribute2.itemSize * offset;
  7432. var length = Math.min(attributeArray2.length, attributeArray1.length - attributeOffset);
  7433. for (var i2 = 0, j = attributeOffset; i2 < length; i2++, j++) {
  7434. attributeArray1[j] = attributeArray2[i2];
  7435. }
  7436. }
  7437. return this;
  7438. },
  7439. normalizeNormals: function() {
  7440. var normals = this.attributes.normal;
  7441. for (var i2 = 0, il = normals.count; i2 < il; i2++) {
  7442. _vector$4.x = normals.getX(i2);
  7443. _vector$4.y = normals.getY(i2);
  7444. _vector$4.z = normals.getZ(i2);
  7445. _vector$4.normalize();
  7446. normals.setXYZ(i2, _vector$4.x, _vector$4.y, _vector$4.z);
  7447. }
  7448. },
  7449. toNonIndexed: function() {
  7450. function convertBufferAttribute(attribute2, indices2) {
  7451. var array = attribute2.array;
  7452. var itemSize = attribute2.itemSize;
  7453. var array2 = new array.constructor(indices2.length * itemSize);
  7454. var index = 0, index2 = 0;
  7455. for (var i3 = 0, l2 = indices2.length; i3 < l2; i3++) {
  7456. index = indices2[i3] * itemSize;
  7457. for (var j = 0; j < itemSize; j++) {
  7458. array2[index2++] = array[index++];
  7459. }
  7460. }
  7461. return new BufferAttribute(array2, itemSize);
  7462. }
  7463. if (this.index === null) {
  7464. console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed.");
  7465. return this;
  7466. }
  7467. var geometry2 = new BufferGeometry();
  7468. var indices = this.index.array;
  7469. var attributes = this.attributes;
  7470. for (var name in attributes) {
  7471. var attribute = attributes[name];
  7472. var newAttribute = convertBufferAttribute(attribute, indices);
  7473. geometry2.setAttribute(name, newAttribute);
  7474. }
  7475. var morphAttributes = this.morphAttributes;
  7476. for (name in morphAttributes) {
  7477. var morphArray = [];
  7478. var morphAttribute = morphAttributes[name];
  7479. for (var i2 = 0, il = morphAttribute.length; i2 < il; i2++) {
  7480. var attribute = morphAttribute[i2];
  7481. var newAttribute = convertBufferAttribute(attribute, indices);
  7482. morphArray.push(newAttribute);
  7483. }
  7484. geometry2.morphAttributes[name] = morphArray;
  7485. }
  7486. geometry2.morphTargetsRelative = this.morphTargetsRelative;
  7487. var groups = this.groups;
  7488. for (var i2 = 0, l = groups.length; i2 < l; i2++) {
  7489. var group = groups[i2];
  7490. geometry2.addGroup(group.start, group.count, group.materialIndex);
  7491. }
  7492. return geometry2;
  7493. },
  7494. toJSON: function() {
  7495. var data = {
  7496. metadata: {
  7497. version: 4.5,
  7498. type: "BufferGeometry",
  7499. generator: "BufferGeometry.toJSON"
  7500. }
  7501. };
  7502. data.uuid = this.uuid;
  7503. data.type = this.type;
  7504. if (this.name !== "")
  7505. data.name = this.name;
  7506. if (Object.keys(this.userData).length > 0)
  7507. data.userData = this.userData;
  7508. if (this.parameters !== void 0) {
  7509. var parameters = this.parameters;
  7510. for (var key in parameters) {
  7511. if (parameters[key] !== void 0)
  7512. data[key] = parameters[key];
  7513. }
  7514. return data;
  7515. }
  7516. data.data = { attributes: {} };
  7517. var index = this.index;
  7518. if (index !== null) {
  7519. data.data.index = {
  7520. type: index.array.constructor.name,
  7521. array: Array.prototype.slice.call(index.array)
  7522. };
  7523. }
  7524. var attributes = this.attributes;
  7525. for (var key in attributes) {
  7526. var attribute = attributes[key];
  7527. var attributeData = attribute.toJSON();
  7528. if (attribute.name !== "")
  7529. attributeData.name = attribute.name;
  7530. data.data.attributes[key] = attributeData;
  7531. }
  7532. var morphAttributes = {};
  7533. var hasMorphAttributes = false;
  7534. for (var key in this.morphAttributes) {
  7535. var attributeArray = this.morphAttributes[key];
  7536. var array = [];
  7537. for (var i2 = 0, il = attributeArray.length; i2 < il; i2++) {
  7538. var attribute = attributeArray[i2];
  7539. var attributeData = attribute.toJSON();
  7540. if (attribute.name !== "")
  7541. attributeData.name = attribute.name;
  7542. array.push(attributeData);
  7543. }
  7544. if (array.length > 0) {
  7545. morphAttributes[key] = array;
  7546. hasMorphAttributes = true;
  7547. }
  7548. }
  7549. if (hasMorphAttributes) {
  7550. data.data.morphAttributes = morphAttributes;
  7551. data.data.morphTargetsRelative = this.morphTargetsRelative;
  7552. }
  7553. var groups = this.groups;
  7554. if (groups.length > 0) {
  7555. data.data.groups = JSON.parse(JSON.stringify(groups));
  7556. }
  7557. var boundingSphere = this.boundingSphere;
  7558. if (boundingSphere !== null) {
  7559. data.data.boundingSphere = {
  7560. center: boundingSphere.center.toArray(),
  7561. radius: boundingSphere.radius
  7562. };
  7563. }
  7564. return data;
  7565. },
  7566. clone: function() {
  7567. return new BufferGeometry().copy(this);
  7568. },
  7569. copy: function(source) {
  7570. var name, i2, l;
  7571. this.index = null;
  7572. this.attributes = {};
  7573. this.morphAttributes = {};
  7574. this.groups = [];
  7575. this.boundingBox = null;
  7576. this.boundingSphere = null;
  7577. this.name = source.name;
  7578. var index = source.index;
  7579. if (index !== null) {
  7580. this.setIndex(index.clone());
  7581. }
  7582. var attributes = source.attributes;
  7583. for (name in attributes) {
  7584. var attribute = attributes[name];
  7585. this.setAttribute(name, attribute.clone());
  7586. }
  7587. var morphAttributes = source.morphAttributes;
  7588. for (name in morphAttributes) {
  7589. var array = [];
  7590. var morphAttribute = morphAttributes[name];
  7591. for (i2 = 0, l = morphAttribute.length; i2 < l; i2++) {
  7592. array.push(morphAttribute[i2].clone());
  7593. }
  7594. this.morphAttributes[name] = array;
  7595. }
  7596. this.morphTargetsRelative = source.morphTargetsRelative;
  7597. var groups = source.groups;
  7598. for (i2 = 0, l = groups.length; i2 < l; i2++) {
  7599. var group = groups[i2];
  7600. this.addGroup(group.start, group.count, group.materialIndex);
  7601. }
  7602. var boundingBox = source.boundingBox;
  7603. if (boundingBox !== null) {
  7604. this.boundingBox = boundingBox.clone();
  7605. }
  7606. var boundingSphere = source.boundingSphere;
  7607. if (boundingSphere !== null) {
  7608. this.boundingSphere = boundingSphere.clone();
  7609. }
  7610. this.drawRange.start = source.drawRange.start;
  7611. this.drawRange.count = source.drawRange.count;
  7612. this.userData = source.userData;
  7613. return this;
  7614. },
  7615. dispose: function() {
  7616. this.dispatchEvent({ type: "dispose" });
  7617. }
  7618. });
  7619. var _inverseMatrix = new Matrix4();
  7620. var _ray = new Ray();
  7621. var _sphere = new Sphere();
  7622. var _vA = new Vector3();
  7623. var _vB = new Vector3();
  7624. var _vC = new Vector3();
  7625. var _tempA = new Vector3();
  7626. var _tempB = new Vector3();
  7627. var _tempC = new Vector3();
  7628. var _morphA = new Vector3();
  7629. var _morphB = new Vector3();
  7630. var _morphC = new Vector3();
  7631. var _uvA = new Vector2();
  7632. var _uvB = new Vector2();
  7633. var _uvC = new Vector2();
  7634. var _intersectionPoint = new Vector3();
  7635. var _intersectionPointWorld = new Vector3();
  7636. function Mesh(geometry, material) {
  7637. Object3D.call(this);
  7638. this.type = "Mesh";
  7639. this.geometry = geometry !== void 0 ? geometry : new BufferGeometry();
  7640. this.material = material !== void 0 ? material : new MeshBasicMaterial();
  7641. this.updateMorphTargets();
  7642. }
  7643. Mesh.prototype = Object.assign(Object.create(Object3D.prototype), {
  7644. constructor: Mesh,
  7645. isMesh: true,
  7646. copy: function(source) {
  7647. Object3D.prototype.copy.call(this, source);
  7648. if (source.morphTargetInfluences !== void 0) {
  7649. this.morphTargetInfluences = source.morphTargetInfluences.slice();
  7650. }
  7651. if (source.morphTargetDictionary !== void 0) {
  7652. this.morphTargetDictionary = Object.assign({}, source.morphTargetDictionary);
  7653. }
  7654. return this;
  7655. },
  7656. updateMorphTargets: function() {
  7657. var geometry = this.geometry;
  7658. var m, ml, name;
  7659. if (geometry.isBufferGeometry) {
  7660. var morphAttributes = geometry.morphAttributes;
  7661. var keys = Object.keys(morphAttributes);
  7662. if (keys.length > 0) {
  7663. var morphAttribute = morphAttributes[keys[0]];
  7664. if (morphAttribute !== void 0) {
  7665. this.morphTargetInfluences = [];
  7666. this.morphTargetDictionary = {};
  7667. for (m = 0, ml = morphAttribute.length; m < ml; m++) {
  7668. name = morphAttribute[m].name || String(m);
  7669. this.morphTargetInfluences.push(0);
  7670. this.morphTargetDictionary[name] = m;
  7671. }
  7672. }
  7673. }
  7674. } else {
  7675. var morphTargets = geometry.morphTargets;
  7676. if (morphTargets !== void 0 && morphTargets.length > 0) {
  7677. console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");
  7678. }
  7679. }
  7680. },
  7681. raycast: function(raycaster, intersects2) {
  7682. var geometry = this.geometry;
  7683. var material = this.material;
  7684. var matrixWorld = this.matrixWorld;
  7685. if (material === void 0)
  7686. return;
  7687. if (geometry.boundingSphere === null)
  7688. geometry.computeBoundingSphere();
  7689. _sphere.copy(geometry.boundingSphere);
  7690. _sphere.applyMatrix4(matrixWorld);
  7691. if (raycaster.ray.intersectsSphere(_sphere) === false)
  7692. return;
  7693. _inverseMatrix.getInverse(matrixWorld);
  7694. _ray.copy(raycaster.ray).applyMatrix4(_inverseMatrix);
  7695. if (geometry.boundingBox !== null) {
  7696. if (_ray.intersectsBox(geometry.boundingBox) === false)
  7697. return;
  7698. }
  7699. var intersection;
  7700. if (geometry.isBufferGeometry) {
  7701. var a, b, c;
  7702. var index = geometry.index;
  7703. var position = geometry.attributes.position;
  7704. var morphPosition = geometry.morphAttributes.position;
  7705. var morphTargetsRelative = geometry.morphTargetsRelative;
  7706. var uv = geometry.attributes.uv;
  7707. var uv2 = geometry.attributes.uv2;
  7708. var groups = geometry.groups;
  7709. var drawRange = geometry.drawRange;
  7710. var i2, j, il, jl;
  7711. var group, groupMaterial;
  7712. var start, end;
  7713. if (index !== null) {
  7714. if (Array.isArray(material)) {
  7715. for (i2 = 0, il = groups.length; i2 < il; i2++) {
  7716. group = groups[i2];
  7717. groupMaterial = material[group.materialIndex];
  7718. start = Math.max(group.start, drawRange.start);
  7719. end = Math.min(group.start + group.count, drawRange.start + drawRange.count);
  7720. for (j = start, jl = end; j < jl; j += 3) {
  7721. a = index.getX(j);
  7722. b = index.getX(j + 1);
  7723. c = index.getX(j + 2);
  7724. intersection = checkBufferGeometryIntersection(this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c);
  7725. if (intersection) {
  7726. intersection.faceIndex = Math.floor(j / 3);
  7727. intersection.face.materialIndex = group.materialIndex;
  7728. intersects2.push(intersection);
  7729. }
  7730. }
  7731. }
  7732. } else {
  7733. start = Math.max(0, drawRange.start);
  7734. end = Math.min(index.count, drawRange.start + drawRange.count);
  7735. for (i2 = start, il = end; i2 < il; i2 += 3) {
  7736. a = index.getX(i2);
  7737. b = index.getX(i2 + 1);
  7738. c = index.getX(i2 + 2);
  7739. intersection = checkBufferGeometryIntersection(this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c);
  7740. if (intersection) {
  7741. intersection.faceIndex = Math.floor(i2 / 3);
  7742. intersects2.push(intersection);
  7743. }
  7744. }
  7745. }
  7746. } else if (position !== void 0) {
  7747. if (Array.isArray(material)) {
  7748. for (i2 = 0, il = groups.length; i2 < il; i2++) {
  7749. group = groups[i2];
  7750. groupMaterial = material[group.materialIndex];
  7751. start = Math.max(group.start, drawRange.start);
  7752. end = Math.min(group.start + group.count, drawRange.start + drawRange.count);
  7753. for (j = start, jl = end; j < jl; j += 3) {
  7754. a = j;
  7755. b = j + 1;
  7756. c = j + 2;
  7757. intersection = checkBufferGeometryIntersection(this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c);
  7758. if (intersection) {
  7759. intersection.faceIndex = Math.floor(j / 3);
  7760. intersection.face.materialIndex = group.materialIndex;
  7761. intersects2.push(intersection);
  7762. }
  7763. }
  7764. }
  7765. } else {
  7766. start = Math.max(0, drawRange.start);
  7767. end = Math.min(position.count, drawRange.start + drawRange.count);
  7768. for (i2 = start, il = end; i2 < il; i2 += 3) {
  7769. a = i2;
  7770. b = i2 + 1;
  7771. c = i2 + 2;
  7772. intersection = checkBufferGeometryIntersection(this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c);
  7773. if (intersection) {
  7774. intersection.faceIndex = Math.floor(i2 / 3);
  7775. intersects2.push(intersection);
  7776. }
  7777. }
  7778. }
  7779. }
  7780. } else if (geometry.isGeometry) {
  7781. var fvA, fvB, fvC;
  7782. var isMultiMaterial = Array.isArray(material);
  7783. var vertices = geometry.vertices;
  7784. var faces = geometry.faces;
  7785. var uvs;
  7786. var faceVertexUvs = geometry.faceVertexUvs[0];
  7787. if (faceVertexUvs.length > 0)
  7788. uvs = faceVertexUvs;
  7789. for (var f = 0, fl = faces.length; f < fl; f++) {
  7790. var face = faces[f];
  7791. var faceMaterial = isMultiMaterial ? material[face.materialIndex] : material;
  7792. if (faceMaterial === void 0)
  7793. continue;
  7794. fvA = vertices[face.a];
  7795. fvB = vertices[face.b];
  7796. fvC = vertices[face.c];
  7797. intersection = checkIntersection(this, faceMaterial, raycaster, _ray, fvA, fvB, fvC, _intersectionPoint);
  7798. if (intersection) {
  7799. if (uvs && uvs[f]) {
  7800. var uvs_f = uvs[f];
  7801. _uvA.copy(uvs_f[0]);
  7802. _uvB.copy(uvs_f[1]);
  7803. _uvC.copy(uvs_f[2]);
  7804. intersection.uv = Triangle.getUV(_intersectionPoint, fvA, fvB, fvC, _uvA, _uvB, _uvC, new Vector2());
  7805. }
  7806. intersection.face = face;
  7807. intersection.faceIndex = f;
  7808. intersects2.push(intersection);
  7809. }
  7810. }
  7811. }
  7812. },
  7813. clone: function() {
  7814. return new this.constructor(this.geometry, this.material).copy(this);
  7815. }
  7816. });
  7817. function checkIntersection(object, material, raycaster, ray, pA, pB, pC, point) {
  7818. var intersect;
  7819. if (material.side === BackSide) {
  7820. intersect = ray.intersectTriangle(pC, pB, pA, true, point);
  7821. } else {
  7822. intersect = ray.intersectTriangle(pA, pB, pC, material.side !== DoubleSide, point);
  7823. }
  7824. if (intersect === null)
  7825. return null;
  7826. _intersectionPointWorld.copy(point);
  7827. _intersectionPointWorld.applyMatrix4(object.matrixWorld);
  7828. var distance = raycaster.ray.origin.distanceTo(_intersectionPointWorld);
  7829. if (distance < raycaster.near || distance > raycaster.far)
  7830. return null;
  7831. return {
  7832. distance,
  7833. point: _intersectionPointWorld.clone(),
  7834. object
  7835. };
  7836. }
  7837. function checkBufferGeometryIntersection(object, material, raycaster, ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c) {
  7838. _vA.fromBufferAttribute(position, a);
  7839. _vB.fromBufferAttribute(position, b);
  7840. _vC.fromBufferAttribute(position, c);
  7841. var morphInfluences = object.morphTargetInfluences;
  7842. if (material.morphTargets && morphPosition && morphInfluences) {
  7843. _morphA.set(0, 0, 0);
  7844. _morphB.set(0, 0, 0);
  7845. _morphC.set(0, 0, 0);
  7846. for (var i2 = 0, il = morphPosition.length; i2 < il; i2++) {
  7847. var influence = morphInfluences[i2];
  7848. var morphAttribute = morphPosition[i2];
  7849. if (influence === 0)
  7850. continue;
  7851. _tempA.fromBufferAttribute(morphAttribute, a);
  7852. _tempB.fromBufferAttribute(morphAttribute, b);
  7853. _tempC.fromBufferAttribute(morphAttribute, c);
  7854. if (morphTargetsRelative) {
  7855. _morphA.addScaledVector(_tempA, influence);
  7856. _morphB.addScaledVector(_tempB, influence);
  7857. _morphC.addScaledVector(_tempC, influence);
  7858. } else {
  7859. _morphA.addScaledVector(_tempA.sub(_vA), influence);
  7860. _morphB.addScaledVector(_tempB.sub(_vB), influence);
  7861. _morphC.addScaledVector(_tempC.sub(_vC), influence);
  7862. }
  7863. }
  7864. _vA.add(_morphA);
  7865. _vB.add(_morphB);
  7866. _vC.add(_morphC);
  7867. }
  7868. var intersection = checkIntersection(object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint);
  7869. if (intersection) {
  7870. if (uv) {
  7871. _uvA.fromBufferAttribute(uv, a);
  7872. _uvB.fromBufferAttribute(uv, b);
  7873. _uvC.fromBufferAttribute(uv, c);
  7874. intersection.uv = Triangle.getUV(_intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2());
  7875. }
  7876. if (uv2) {
  7877. _uvA.fromBufferAttribute(uv2, a);
  7878. _uvB.fromBufferAttribute(uv2, b);
  7879. _uvC.fromBufferAttribute(uv2, c);
  7880. intersection.uv2 = Triangle.getUV(_intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2());
  7881. }
  7882. var face = new Face3(a, b, c);
  7883. Triangle.getNormal(_vA, _vB, _vC, face.normal);
  7884. intersection.face = face;
  7885. }
  7886. return intersection;
  7887. }
  7888. var _geometryId = 0;
  7889. var _m1$3 = new Matrix4();
  7890. var _obj$1 = new Object3D();
  7891. var _offset$1 = new Vector3();
  7892. function Geometry() {
  7893. Object.defineProperty(this, "id", { value: _geometryId += 2 });
  7894. this.uuid = MathUtils.generateUUID();
  7895. this.name = "";
  7896. this.type = "Geometry";
  7897. this.vertices = [];
  7898. this.colors = [];
  7899. this.faces = [];
  7900. this.faceVertexUvs = [[]];
  7901. this.morphTargets = [];
  7902. this.morphNormals = [];
  7903. this.skinWeights = [];
  7904. this.skinIndices = [];
  7905. this.lineDistances = [];
  7906. this.boundingBox = null;
  7907. this.boundingSphere = null;
  7908. this.elementsNeedUpdate = false;
  7909. this.verticesNeedUpdate = false;
  7910. this.uvsNeedUpdate = false;
  7911. this.normalsNeedUpdate = false;
  7912. this.colorsNeedUpdate = false;
  7913. this.lineDistancesNeedUpdate = false;
  7914. this.groupsNeedUpdate = false;
  7915. }
  7916. Geometry.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
  7917. constructor: Geometry,
  7918. isGeometry: true,
  7919. applyMatrix4: function(matrix) {
  7920. var normalMatrix = new Matrix3().getNormalMatrix(matrix);
  7921. for (var i2 = 0, il = this.vertices.length; i2 < il; i2++) {
  7922. var vertex = this.vertices[i2];
  7923. vertex.applyMatrix4(matrix);
  7924. }
  7925. for (var i2 = 0, il = this.faces.length; i2 < il; i2++) {
  7926. var face = this.faces[i2];
  7927. face.normal.applyMatrix3(normalMatrix).normalize();
  7928. for (var j = 0, jl = face.vertexNormals.length; j < jl; j++) {
  7929. face.vertexNormals[j].applyMatrix3(normalMatrix).normalize();
  7930. }
  7931. }
  7932. if (this.boundingBox !== null) {
  7933. this.computeBoundingBox();
  7934. }
  7935. if (this.boundingSphere !== null) {
  7936. this.computeBoundingSphere();
  7937. }
  7938. this.verticesNeedUpdate = true;
  7939. this.normalsNeedUpdate = true;
  7940. return this;
  7941. },
  7942. rotateX: function(angle) {
  7943. _m1$3.makeRotationX(angle);
  7944. this.applyMatrix4(_m1$3);
  7945. return this;
  7946. },
  7947. rotateY: function(angle) {
  7948. _m1$3.makeRotationY(angle);
  7949. this.applyMatrix4(_m1$3);
  7950. return this;
  7951. },
  7952. rotateZ: function(angle) {
  7953. _m1$3.makeRotationZ(angle);
  7954. this.applyMatrix4(_m1$3);
  7955. return this;
  7956. },
  7957. translate: function(x, y, z) {
  7958. _m1$3.makeTranslation(x, y, z);
  7959. this.applyMatrix4(_m1$3);
  7960. return this;
  7961. },
  7962. scale: function(x, y, z) {
  7963. _m1$3.makeScale(x, y, z);
  7964. this.applyMatrix4(_m1$3);
  7965. return this;
  7966. },
  7967. lookAt: function(vector) {
  7968. _obj$1.lookAt(vector);
  7969. _obj$1.updateMatrix();
  7970. this.applyMatrix4(_obj$1.matrix);
  7971. return this;
  7972. },
  7973. fromBufferGeometry: function(geometry) {
  7974. var scope = this;
  7975. var indices = geometry.index !== null ? geometry.index.array : void 0;
  7976. var attributes = geometry.attributes;
  7977. if (attributes.position === void 0) {
  7978. console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion.");
  7979. return this;
  7980. }
  7981. var positions = attributes.position.array;
  7982. var normals = attributes.normal !== void 0 ? attributes.normal.array : void 0;
  7983. var colors = attributes.color !== void 0 ? attributes.color.array : void 0;
  7984. var uvs = attributes.uv !== void 0 ? attributes.uv.array : void 0;
  7985. var uvs2 = attributes.uv2 !== void 0 ? attributes.uv2.array : void 0;
  7986. if (uvs2 !== void 0)
  7987. this.faceVertexUvs[1] = [];
  7988. for (var i2 = 0; i2 < positions.length; i2 += 3) {
  7989. scope.vertices.push(new Vector3().fromArray(positions, i2));
  7990. if (colors !== void 0) {
  7991. scope.colors.push(new Color().fromArray(colors, i2));
  7992. }
  7993. }
  7994. function addFace(a, b, c, materialIndex) {
  7995. var vertexColors = colors === void 0 ? [] : [
  7996. scope.colors[a].clone(),
  7997. scope.colors[b].clone(),
  7998. scope.colors[c].clone()
  7999. ];
  8000. var vertexNormals = normals === void 0 ? [] : [
  8001. new Vector3().fromArray(normals, a * 3),
  8002. new Vector3().fromArray(normals, b * 3),
  8003. new Vector3().fromArray(normals, c * 3)
  8004. ];
  8005. var face = new Face3(a, b, c, vertexNormals, vertexColors, materialIndex);
  8006. scope.faces.push(face);
  8007. if (uvs !== void 0) {
  8008. scope.faceVertexUvs[0].push([
  8009. new Vector2().fromArray(uvs, a * 2),
  8010. new Vector2().fromArray(uvs, b * 2),
  8011. new Vector2().fromArray(uvs, c * 2)
  8012. ]);
  8013. }
  8014. if (uvs2 !== void 0) {
  8015. scope.faceVertexUvs[1].push([
  8016. new Vector2().fromArray(uvs2, a * 2),
  8017. new Vector2().fromArray(uvs2, b * 2),
  8018. new Vector2().fromArray(uvs2, c * 2)
  8019. ]);
  8020. }
  8021. }
  8022. var groups = geometry.groups;
  8023. if (groups.length > 0) {
  8024. for (var i2 = 0; i2 < groups.length; i2++) {
  8025. var group = groups[i2];
  8026. var start = group.start;
  8027. var count = group.count;
  8028. for (var j = start, jl = start + count; j < jl; j += 3) {
  8029. if (indices !== void 0) {
  8030. addFace(indices[j], indices[j + 1], indices[j + 2], group.materialIndex);
  8031. } else {
  8032. addFace(j, j + 1, j + 2, group.materialIndex);
  8033. }
  8034. }
  8035. }
  8036. } else {
  8037. if (indices !== void 0) {
  8038. for (var i2 = 0; i2 < indices.length; i2 += 3) {
  8039. addFace(indices[i2], indices[i2 + 1], indices[i2 + 2]);
  8040. }
  8041. } else {
  8042. for (var i2 = 0; i2 < positions.length / 3; i2 += 3) {
  8043. addFace(i2, i2 + 1, i2 + 2);
  8044. }
  8045. }
  8046. }
  8047. this.computeFaceNormals();
  8048. if (geometry.boundingBox !== null) {
  8049. this.boundingBox = geometry.boundingBox.clone();
  8050. }
  8051. if (geometry.boundingSphere !== null) {
  8052. this.boundingSphere = geometry.boundingSphere.clone();
  8053. }
  8054. return this;
  8055. },
  8056. center: function() {
  8057. this.computeBoundingBox();
  8058. this.boundingBox.getCenter(_offset$1).negate();
  8059. this.translate(_offset$1.x, _offset$1.y, _offset$1.z);
  8060. return this;
  8061. },
  8062. normalize: function() {
  8063. this.computeBoundingSphere();
  8064. var center = this.boundingSphere.center;
  8065. var radius = this.boundingSphere.radius;
  8066. var s = radius === 0 ? 1 : 1 / radius;
  8067. var matrix = new Matrix4();
  8068. matrix.set(
  8069. s,
  8070. 0,
  8071. 0,
  8072. -s * center.x,
  8073. 0,
  8074. s,
  8075. 0,
  8076. -s * center.y,
  8077. 0,
  8078. 0,
  8079. s,
  8080. -s * center.z,
  8081. 0,
  8082. 0,
  8083. 0,
  8084. 1
  8085. );
  8086. this.applyMatrix4(matrix);
  8087. return this;
  8088. },
  8089. computeFaceNormals: function() {
  8090. var cb = new Vector3(), ab = new Vector3();
  8091. for (var f = 0, fl = this.faces.length; f < fl; f++) {
  8092. var face = this.faces[f];
  8093. var vA = this.vertices[face.a];
  8094. var vB = this.vertices[face.b];
  8095. var vC = this.vertices[face.c];
  8096. cb.subVectors(vC, vB);
  8097. ab.subVectors(vA, vB);
  8098. cb.cross(ab);
  8099. cb.normalize();
  8100. face.normal.copy(cb);
  8101. }
  8102. },
  8103. computeVertexNormals: function(areaWeighted) {
  8104. if (areaWeighted === void 0)
  8105. areaWeighted = true;
  8106. var v, vl, f, fl, face, vertices;
  8107. vertices = new Array(this.vertices.length);
  8108. for (v = 0, vl = this.vertices.length; v < vl; v++) {
  8109. vertices[v] = new Vector3();
  8110. }
  8111. if (areaWeighted) {
  8112. var vA, vB, vC;
  8113. var cb = new Vector3(), ab = new Vector3();
  8114. for (f = 0, fl = this.faces.length; f < fl; f++) {
  8115. face = this.faces[f];
  8116. vA = this.vertices[face.a];
  8117. vB = this.vertices[face.b];
  8118. vC = this.vertices[face.c];
  8119. cb.subVectors(vC, vB);
  8120. ab.subVectors(vA, vB);
  8121. cb.cross(ab);
  8122. vertices[face.a].add(cb);
  8123. vertices[face.b].add(cb);
  8124. vertices[face.c].add(cb);
  8125. }
  8126. } else {
  8127. this.computeFaceNormals();
  8128. for (f = 0, fl = this.faces.length; f < fl; f++) {
  8129. face = this.faces[f];
  8130. vertices[face.a].add(face.normal);
  8131. vertices[face.b].add(face.normal);
  8132. vertices[face.c].add(face.normal);
  8133. }
  8134. }
  8135. for (v = 0, vl = this.vertices.length; v < vl; v++) {
  8136. vertices[v].normalize();
  8137. }
  8138. for (f = 0, fl = this.faces.length; f < fl; f++) {
  8139. face = this.faces[f];
  8140. var vertexNormals = face.vertexNormals;
  8141. if (vertexNormals.length === 3) {
  8142. vertexNormals[0].copy(vertices[face.a]);
  8143. vertexNormals[1].copy(vertices[face.b]);
  8144. vertexNormals[2].copy(vertices[face.c]);
  8145. } else {
  8146. vertexNormals[0] = vertices[face.a].clone();
  8147. vertexNormals[1] = vertices[face.b].clone();
  8148. vertexNormals[2] = vertices[face.c].clone();
  8149. }
  8150. }
  8151. if (this.faces.length > 0) {
  8152. this.normalsNeedUpdate = true;
  8153. }
  8154. },
  8155. computeFlatVertexNormals: function() {
  8156. var f, fl, face;
  8157. this.computeFaceNormals();
  8158. for (f = 0, fl = this.faces.length; f < fl; f++) {
  8159. face = this.faces[f];
  8160. var vertexNormals = face.vertexNormals;
  8161. if (vertexNormals.length === 3) {
  8162. vertexNormals[0].copy(face.normal);
  8163. vertexNormals[1].copy(face.normal);
  8164. vertexNormals[2].copy(face.normal);
  8165. } else {
  8166. vertexNormals[0] = face.normal.clone();
  8167. vertexNormals[1] = face.normal.clone();
  8168. vertexNormals[2] = face.normal.clone();
  8169. }
  8170. }
  8171. if (this.faces.length > 0) {
  8172. this.normalsNeedUpdate = true;
  8173. }
  8174. },
  8175. computeMorphNormals: function() {
  8176. var i2, il, f, fl, face;
  8177. for (f = 0, fl = this.faces.length; f < fl; f++) {
  8178. face = this.faces[f];
  8179. if (!face.__originalFaceNormal) {
  8180. face.__originalFaceNormal = face.normal.clone();
  8181. } else {
  8182. face.__originalFaceNormal.copy(face.normal);
  8183. }
  8184. if (!face.__originalVertexNormals)
  8185. face.__originalVertexNormals = [];
  8186. for (i2 = 0, il = face.vertexNormals.length; i2 < il; i2++) {
  8187. if (!face.__originalVertexNormals[i2]) {
  8188. face.__originalVertexNormals[i2] = face.vertexNormals[i2].clone();
  8189. } else {
  8190. face.__originalVertexNormals[i2].copy(face.vertexNormals[i2]);
  8191. }
  8192. }
  8193. }
  8194. var tmpGeo = new Geometry();
  8195. tmpGeo.faces = this.faces;
  8196. for (i2 = 0, il = this.morphTargets.length; i2 < il; i2++) {
  8197. if (!this.morphNormals[i2]) {
  8198. this.morphNormals[i2] = {};
  8199. this.morphNormals[i2].faceNormals = [];
  8200. this.morphNormals[i2].vertexNormals = [];
  8201. var dstNormalsFace = this.morphNormals[i2].faceNormals;
  8202. var dstNormalsVertex = this.morphNormals[i2].vertexNormals;
  8203. var faceNormal, vertexNormals;
  8204. for (f = 0, fl = this.faces.length; f < fl; f++) {
  8205. faceNormal = new Vector3();
  8206. vertexNormals = { a: new Vector3(), b: new Vector3(), c: new Vector3() };
  8207. dstNormalsFace.push(faceNormal);
  8208. dstNormalsVertex.push(vertexNormals);
  8209. }
  8210. }
  8211. var morphNormals = this.morphNormals[i2];
  8212. tmpGeo.vertices = this.morphTargets[i2].vertices;
  8213. tmpGeo.computeFaceNormals();
  8214. tmpGeo.computeVertexNormals();
  8215. var faceNormal, vertexNormals;
  8216. for (f = 0, fl = this.faces.length; f < fl; f++) {
  8217. face = this.faces[f];
  8218. faceNormal = morphNormals.faceNormals[f];
  8219. vertexNormals = morphNormals.vertexNormals[f];
  8220. faceNormal.copy(face.normal);
  8221. vertexNormals.a.copy(face.vertexNormals[0]);
  8222. vertexNormals.b.copy(face.vertexNormals[1]);
  8223. vertexNormals.c.copy(face.vertexNormals[2]);
  8224. }
  8225. }
  8226. for (f = 0, fl = this.faces.length; f < fl; f++) {
  8227. face = this.faces[f];
  8228. face.normal = face.__originalFaceNormal;
  8229. face.vertexNormals = face.__originalVertexNormals;
  8230. }
  8231. },
  8232. computeBoundingBox: function() {
  8233. if (this.boundingBox === null) {
  8234. this.boundingBox = new Box3();
  8235. }
  8236. this.boundingBox.setFromPoints(this.vertices);
  8237. },
  8238. computeBoundingSphere: function() {
  8239. if (this.boundingSphere === null) {
  8240. this.boundingSphere = new Sphere();
  8241. }
  8242. this.boundingSphere.setFromPoints(this.vertices);
  8243. },
  8244. merge: function(geometry, matrix, materialIndexOffset) {
  8245. if (!(geometry && geometry.isGeometry)) {
  8246. console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.", geometry);
  8247. return;
  8248. }
  8249. var normalMatrix, vertexOffset = this.vertices.length, vertices1 = this.vertices, vertices2 = geometry.vertices, faces1 = this.faces, faces2 = geometry.faces, colors1 = this.colors, colors2 = geometry.colors;
  8250. if (materialIndexOffset === void 0)
  8251. materialIndexOffset = 0;
  8252. if (matrix !== void 0) {
  8253. normalMatrix = new Matrix3().getNormalMatrix(matrix);
  8254. }
  8255. for (var i2 = 0, il = vertices2.length; i2 < il; i2++) {
  8256. var vertex = vertices2[i2];
  8257. var vertexCopy = vertex.clone();
  8258. if (matrix !== void 0)
  8259. vertexCopy.applyMatrix4(matrix);
  8260. vertices1.push(vertexCopy);
  8261. }
  8262. for (var i2 = 0, il = colors2.length; i2 < il; i2++) {
  8263. colors1.push(colors2[i2].clone());
  8264. }
  8265. for (i2 = 0, il = faces2.length; i2 < il; i2++) {
  8266. var face = faces2[i2], faceCopy, normal, color, faceVertexNormals = face.vertexNormals, faceVertexColors = face.vertexColors;
  8267. faceCopy = new Face3(face.a + vertexOffset, face.b + vertexOffset, face.c + vertexOffset);
  8268. faceCopy.normal.copy(face.normal);
  8269. if (normalMatrix !== void 0) {
  8270. faceCopy.normal.applyMatrix3(normalMatrix).normalize();
  8271. }
  8272. for (var j = 0, jl = faceVertexNormals.length; j < jl; j++) {
  8273. normal = faceVertexNormals[j].clone();
  8274. if (normalMatrix !== void 0) {
  8275. normal.applyMatrix3(normalMatrix).normalize();
  8276. }
  8277. faceCopy.vertexNormals.push(normal);
  8278. }
  8279. faceCopy.color.copy(face.color);
  8280. for (var j = 0, jl = faceVertexColors.length; j < jl; j++) {
  8281. color = faceVertexColors[j];
  8282. faceCopy.vertexColors.push(color.clone());
  8283. }
  8284. faceCopy.materialIndex = face.materialIndex + materialIndexOffset;
  8285. faces1.push(faceCopy);
  8286. }
  8287. for (var i2 = 0, il = geometry.faceVertexUvs.length; i2 < il; i2++) {
  8288. var faceVertexUvs2 = geometry.faceVertexUvs[i2];
  8289. if (this.faceVertexUvs[i2] === void 0)
  8290. this.faceVertexUvs[i2] = [];
  8291. for (var j = 0, jl = faceVertexUvs2.length; j < jl; j++) {
  8292. var uvs2 = faceVertexUvs2[j], uvsCopy = [];
  8293. for (var k = 0, kl = uvs2.length; k < kl; k++) {
  8294. uvsCopy.push(uvs2[k].clone());
  8295. }
  8296. this.faceVertexUvs[i2].push(uvsCopy);
  8297. }
  8298. }
  8299. },
  8300. mergeMesh: function(mesh) {
  8301. if (!(mesh && mesh.isMesh)) {
  8302. console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.", mesh);
  8303. return;
  8304. }
  8305. if (mesh.matrixAutoUpdate)
  8306. mesh.updateMatrix();
  8307. this.merge(mesh.geometry, mesh.matrix);
  8308. },
  8309. /*
  8310. * Checks for duplicate vertices with hashmap.
  8311. * Duplicated vertices are removed
  8312. * and faces' vertices are updated.
  8313. */
  8314. mergeVertices: function() {
  8315. var verticesMap = {};
  8316. var unique = [], changes = [];
  8317. var v, key;
  8318. var precisionPoints = 4;
  8319. var precision = Math.pow(10, precisionPoints);
  8320. var i2, il, face;
  8321. var indices, j, jl;
  8322. for (i2 = 0, il = this.vertices.length; i2 < il; i2++) {
  8323. v = this.vertices[i2];
  8324. key = Math.round(v.x * precision) + "_" + Math.round(v.y * precision) + "_" + Math.round(v.z * precision);
  8325. if (verticesMap[key] === void 0) {
  8326. verticesMap[key] = i2;
  8327. unique.push(this.vertices[i2]);
  8328. changes[i2] = unique.length - 1;
  8329. } else {
  8330. changes[i2] = changes[verticesMap[key]];
  8331. }
  8332. }
  8333. var faceIndicesToRemove = [];
  8334. for (i2 = 0, il = this.faces.length; i2 < il; i2++) {
  8335. face = this.faces[i2];
  8336. face.a = changes[face.a];
  8337. face.b = changes[face.b];
  8338. face.c = changes[face.c];
  8339. indices = [face.a, face.b, face.c];
  8340. for (var n = 0; n < 3; n++) {
  8341. if (indices[n] === indices[(n + 1) % 3]) {
  8342. faceIndicesToRemove.push(i2);
  8343. break;
  8344. }
  8345. }
  8346. }
  8347. for (i2 = faceIndicesToRemove.length - 1; i2 >= 0; i2--) {
  8348. var idx = faceIndicesToRemove[i2];
  8349. this.faces.splice(idx, 1);
  8350. for (j = 0, jl = this.faceVertexUvs.length; j < jl; j++) {
  8351. this.faceVertexUvs[j].splice(idx, 1);
  8352. }
  8353. }
  8354. var diff = this.vertices.length - unique.length;
  8355. this.vertices = unique;
  8356. return diff;
  8357. },
  8358. setFromPoints: function(points) {
  8359. this.vertices = [];
  8360. for (var i2 = 0, l = points.length; i2 < l; i2++) {
  8361. var point = points[i2];
  8362. this.vertices.push(new Vector3(point.x, point.y, point.z || 0));
  8363. }
  8364. return this;
  8365. },
  8366. sortFacesByMaterialIndex: function() {
  8367. var faces = this.faces;
  8368. var length = faces.length;
  8369. for (var i2 = 0; i2 < length; i2++) {
  8370. faces[i2]._id = i2;
  8371. }
  8372. function materialIndexSort(a, b) {
  8373. return a.materialIndex - b.materialIndex;
  8374. }
  8375. faces.sort(materialIndexSort);
  8376. var uvs1 = this.faceVertexUvs[0];
  8377. var uvs2 = this.faceVertexUvs[1];
  8378. var newUvs1, newUvs2;
  8379. if (uvs1 && uvs1.length === length)
  8380. newUvs1 = [];
  8381. if (uvs2 && uvs2.length === length)
  8382. newUvs2 = [];
  8383. for (var i2 = 0; i2 < length; i2++) {
  8384. var id = faces[i2]._id;
  8385. if (newUvs1)
  8386. newUvs1.push(uvs1[id]);
  8387. if (newUvs2)
  8388. newUvs2.push(uvs2[id]);
  8389. }
  8390. if (newUvs1)
  8391. this.faceVertexUvs[0] = newUvs1;
  8392. if (newUvs2)
  8393. this.faceVertexUvs[1] = newUvs2;
  8394. },
  8395. toJSON: function() {
  8396. var data = {
  8397. metadata: {
  8398. version: 4.5,
  8399. type: "Geometry",
  8400. generator: "Geometry.toJSON"
  8401. }
  8402. };
  8403. data.uuid = this.uuid;
  8404. data.type = this.type;
  8405. if (this.name !== "")
  8406. data.name = this.name;
  8407. if (this.parameters !== void 0) {
  8408. var parameters = this.parameters;
  8409. for (var key in parameters) {
  8410. if (parameters[key] !== void 0)
  8411. data[key] = parameters[key];
  8412. }
  8413. return data;
  8414. }
  8415. var vertices = [];
  8416. for (var i2 = 0; i2 < this.vertices.length; i2++) {
  8417. var vertex = this.vertices[i2];
  8418. vertices.push(vertex.x, vertex.y, vertex.z);
  8419. }
  8420. var faces = [];
  8421. var normals = [];
  8422. var normalsHash = {};
  8423. var colors = [];
  8424. var colorsHash = {};
  8425. var uvs = [];
  8426. var uvsHash = {};
  8427. for (var i2 = 0; i2 < this.faces.length; i2++) {
  8428. var face = this.faces[i2];
  8429. var hasMaterial = true;
  8430. var hasFaceUv = false;
  8431. var hasFaceVertexUv = this.faceVertexUvs[0][i2] !== void 0;
  8432. var hasFaceNormal = face.normal.length() > 0;
  8433. var hasFaceVertexNormal = face.vertexNormals.length > 0;
  8434. var hasFaceColor = face.color.r !== 1 || face.color.g !== 1 || face.color.b !== 1;
  8435. var hasFaceVertexColor = face.vertexColors.length > 0;
  8436. var faceType = 0;
  8437. faceType = setBit(faceType, 0, 0);
  8438. faceType = setBit(faceType, 1, hasMaterial);
  8439. faceType = setBit(faceType, 2, hasFaceUv);
  8440. faceType = setBit(faceType, 3, hasFaceVertexUv);
  8441. faceType = setBit(faceType, 4, hasFaceNormal);
  8442. faceType = setBit(faceType, 5, hasFaceVertexNormal);
  8443. faceType = setBit(faceType, 6, hasFaceColor);
  8444. faceType = setBit(faceType, 7, hasFaceVertexColor);
  8445. faces.push(faceType);
  8446. faces.push(face.a, face.b, face.c);
  8447. faces.push(face.materialIndex);
  8448. if (hasFaceVertexUv) {
  8449. var faceVertexUvs = this.faceVertexUvs[0][i2];
  8450. faces.push(
  8451. getUvIndex(faceVertexUvs[0]),
  8452. getUvIndex(faceVertexUvs[1]),
  8453. getUvIndex(faceVertexUvs[2])
  8454. );
  8455. }
  8456. if (hasFaceNormal) {
  8457. faces.push(getNormalIndex(face.normal));
  8458. }
  8459. if (hasFaceVertexNormal) {
  8460. var vertexNormals = face.vertexNormals;
  8461. faces.push(
  8462. getNormalIndex(vertexNormals[0]),
  8463. getNormalIndex(vertexNormals[1]),
  8464. getNormalIndex(vertexNormals[2])
  8465. );
  8466. }
  8467. if (hasFaceColor) {
  8468. faces.push(getColorIndex(face.color));
  8469. }
  8470. if (hasFaceVertexColor) {
  8471. var vertexColors = face.vertexColors;
  8472. faces.push(
  8473. getColorIndex(vertexColors[0]),
  8474. getColorIndex(vertexColors[1]),
  8475. getColorIndex(vertexColors[2])
  8476. );
  8477. }
  8478. }
  8479. function setBit(value, position, enabled) {
  8480. return enabled ? value | 1 << position : value & ~(1 << position);
  8481. }
  8482. function getNormalIndex(normal) {
  8483. var hash = normal.x.toString() + normal.y.toString() + normal.z.toString();
  8484. if (normalsHash[hash] !== void 0) {
  8485. return normalsHash[hash];
  8486. }
  8487. normalsHash[hash] = normals.length / 3;
  8488. normals.push(normal.x, normal.y, normal.z);
  8489. return normalsHash[hash];
  8490. }
  8491. function getColorIndex(color) {
  8492. var hash = color.r.toString() + color.g.toString() + color.b.toString();
  8493. if (colorsHash[hash] !== void 0) {
  8494. return colorsHash[hash];
  8495. }
  8496. colorsHash[hash] = colors.length;
  8497. colors.push(color.getHex());
  8498. return colorsHash[hash];
  8499. }
  8500. function getUvIndex(uv) {
  8501. var hash = uv.x.toString() + uv.y.toString();
  8502. if (uvsHash[hash] !== void 0) {
  8503. return uvsHash[hash];
  8504. }
  8505. uvsHash[hash] = uvs.length / 2;
  8506. uvs.push(uv.x, uv.y);
  8507. return uvsHash[hash];
  8508. }
  8509. data.data = {};
  8510. data.data.vertices = vertices;
  8511. data.data.normals = normals;
  8512. if (colors.length > 0)
  8513. data.data.colors = colors;
  8514. if (uvs.length > 0)
  8515. data.data.uvs = [uvs];
  8516. data.data.faces = faces;
  8517. return data;
  8518. },
  8519. clone: function() {
  8520. return new Geometry().copy(this);
  8521. },
  8522. copy: function(source) {
  8523. var i2, il, j, jl, k, kl;
  8524. this.vertices = [];
  8525. this.colors = [];
  8526. this.faces = [];
  8527. this.faceVertexUvs = [[]];
  8528. this.morphTargets = [];
  8529. this.morphNormals = [];
  8530. this.skinWeights = [];
  8531. this.skinIndices = [];
  8532. this.lineDistances = [];
  8533. this.boundingBox = null;
  8534. this.boundingSphere = null;
  8535. this.name = source.name;
  8536. var vertices = source.vertices;
  8537. for (i2 = 0, il = vertices.length; i2 < il; i2++) {
  8538. this.vertices.push(vertices[i2].clone());
  8539. }
  8540. var colors = source.colors;
  8541. for (i2 = 0, il = colors.length; i2 < il; i2++) {
  8542. this.colors.push(colors[i2].clone());
  8543. }
  8544. var faces = source.faces;
  8545. for (i2 = 0, il = faces.length; i2 < il; i2++) {
  8546. this.faces.push(faces[i2].clone());
  8547. }
  8548. for (i2 = 0, il = source.faceVertexUvs.length; i2 < il; i2++) {
  8549. var faceVertexUvs = source.faceVertexUvs[i2];
  8550. if (this.faceVertexUvs[i2] === void 0) {
  8551. this.faceVertexUvs[i2] = [];
  8552. }
  8553. for (j = 0, jl = faceVertexUvs.length; j < jl; j++) {
  8554. var uvs = faceVertexUvs[j], uvsCopy = [];
  8555. for (k = 0, kl = uvs.length; k < kl; k++) {
  8556. var uv = uvs[k];
  8557. uvsCopy.push(uv.clone());
  8558. }
  8559. this.faceVertexUvs[i2].push(uvsCopy);
  8560. }
  8561. }
  8562. var morphTargets = source.morphTargets;
  8563. for (i2 = 0, il = morphTargets.length; i2 < il; i2++) {
  8564. var morphTarget = {};
  8565. morphTarget.name = morphTargets[i2].name;
  8566. if (morphTargets[i2].vertices !== void 0) {
  8567. morphTarget.vertices = [];
  8568. for (j = 0, jl = morphTargets[i2].vertices.length; j < jl; j++) {
  8569. morphTarget.vertices.push(morphTargets[i2].vertices[j].clone());
  8570. }
  8571. }
  8572. if (morphTargets[i2].normals !== void 0) {
  8573. morphTarget.normals = [];
  8574. for (j = 0, jl = morphTargets[i2].normals.length; j < jl; j++) {
  8575. morphTarget.normals.push(morphTargets[i2].normals[j].clone());
  8576. }
  8577. }
  8578. this.morphTargets.push(morphTarget);
  8579. }
  8580. var morphNormals = source.morphNormals;
  8581. for (i2 = 0, il = morphNormals.length; i2 < il; i2++) {
  8582. var morphNormal = {};
  8583. if (morphNormals[i2].vertexNormals !== void 0) {
  8584. morphNormal.vertexNormals = [];
  8585. for (j = 0, jl = morphNormals[i2].vertexNormals.length; j < jl; j++) {
  8586. var srcVertexNormal = morphNormals[i2].vertexNormals[j];
  8587. var destVertexNormal = {};
  8588. destVertexNormal.a = srcVertexNormal.a.clone();
  8589. destVertexNormal.b = srcVertexNormal.b.clone();
  8590. destVertexNormal.c = srcVertexNormal.c.clone();
  8591. morphNormal.vertexNormals.push(destVertexNormal);
  8592. }
  8593. }
  8594. if (morphNormals[i2].faceNormals !== void 0) {
  8595. morphNormal.faceNormals = [];
  8596. for (j = 0, jl = morphNormals[i2].faceNormals.length; j < jl; j++) {
  8597. morphNormal.faceNormals.push(morphNormals[i2].faceNormals[j].clone());
  8598. }
  8599. }
  8600. this.morphNormals.push(morphNormal);
  8601. }
  8602. var skinWeights = source.skinWeights;
  8603. for (i2 = 0, il = skinWeights.length; i2 < il; i2++) {
  8604. this.skinWeights.push(skinWeights[i2].clone());
  8605. }
  8606. var skinIndices = source.skinIndices;
  8607. for (i2 = 0, il = skinIndices.length; i2 < il; i2++) {
  8608. this.skinIndices.push(skinIndices[i2].clone());
  8609. }
  8610. var lineDistances = source.lineDistances;
  8611. for (i2 = 0, il = lineDistances.length; i2 < il; i2++) {
  8612. this.lineDistances.push(lineDistances[i2]);
  8613. }
  8614. var boundingBox = source.boundingBox;
  8615. if (boundingBox !== null) {
  8616. this.boundingBox = boundingBox.clone();
  8617. }
  8618. var boundingSphere = source.boundingSphere;
  8619. if (boundingSphere !== null) {
  8620. this.boundingSphere = boundingSphere.clone();
  8621. }
  8622. this.elementsNeedUpdate = source.elementsNeedUpdate;
  8623. this.verticesNeedUpdate = source.verticesNeedUpdate;
  8624. this.uvsNeedUpdate = source.uvsNeedUpdate;
  8625. this.normalsNeedUpdate = source.normalsNeedUpdate;
  8626. this.colorsNeedUpdate = source.colorsNeedUpdate;
  8627. this.lineDistancesNeedUpdate = source.lineDistancesNeedUpdate;
  8628. this.groupsNeedUpdate = source.groupsNeedUpdate;
  8629. return this;
  8630. },
  8631. dispose: function() {
  8632. this.dispatchEvent({ type: "dispose" });
  8633. }
  8634. });
  8635. class BoxGeometry extends Geometry {
  8636. constructor(width, height, depth, widthSegments, heightSegments, depthSegments) {
  8637. super();
  8638. this.type = "BoxGeometry";
  8639. this.parameters = {
  8640. width,
  8641. height,
  8642. depth,
  8643. widthSegments,
  8644. heightSegments,
  8645. depthSegments
  8646. };
  8647. this.fromBufferGeometry(new BoxBufferGeometry(width, height, depth, widthSegments, heightSegments, depthSegments));
  8648. this.mergeVertices();
  8649. }
  8650. }
  8651. class BoxBufferGeometry extends BufferGeometry {
  8652. constructor(width, height, depth, widthSegments, heightSegments, depthSegments) {
  8653. super();
  8654. this.type = "BoxBufferGeometry";
  8655. this.parameters = {
  8656. width,
  8657. height,
  8658. depth,
  8659. widthSegments,
  8660. heightSegments,
  8661. depthSegments
  8662. };
  8663. var scope = this;
  8664. width = width || 1;
  8665. height = height || 1;
  8666. depth = depth || 1;
  8667. widthSegments = Math.floor(widthSegments) || 1;
  8668. heightSegments = Math.floor(heightSegments) || 1;
  8669. depthSegments = Math.floor(depthSegments) || 1;
  8670. var indices = [];
  8671. var vertices = [];
  8672. var normals = [];
  8673. var uvs = [];
  8674. var numberOfVertices = 0;
  8675. var groupStart = 0;
  8676. buildPlane("z", "y", "x", -1, -1, depth, height, width, depthSegments, heightSegments, 0);
  8677. buildPlane("z", "y", "x", 1, -1, depth, height, -width, depthSegments, heightSegments, 1);
  8678. buildPlane("x", "z", "y", 1, 1, width, depth, height, widthSegments, depthSegments, 2);
  8679. buildPlane("x", "z", "y", 1, -1, width, depth, -height, widthSegments, depthSegments, 3);
  8680. buildPlane("x", "y", "z", 1, -1, width, height, depth, widthSegments, heightSegments, 4);
  8681. buildPlane("x", "y", "z", -1, -1, width, height, -depth, widthSegments, heightSegments, 5);
  8682. this.setIndex(indices);
  8683. this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  8684. this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
  8685. this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
  8686. function buildPlane(u, v, w, udir, vdir, width2, height2, depth2, gridX, gridY, materialIndex) {
  8687. var segmentWidth = width2 / gridX;
  8688. var segmentHeight = height2 / gridY;
  8689. var widthHalf = width2 / 2;
  8690. var heightHalf = height2 / 2;
  8691. var depthHalf = depth2 / 2;
  8692. var gridX1 = gridX + 1;
  8693. var gridY1 = gridY + 1;
  8694. var vertexCounter = 0;
  8695. var groupCount = 0;
  8696. var ix, iy;
  8697. var vector = new Vector3();
  8698. for (iy = 0; iy < gridY1; iy++) {
  8699. var y = iy * segmentHeight - heightHalf;
  8700. for (ix = 0; ix < gridX1; ix++) {
  8701. var x = ix * segmentWidth - widthHalf;
  8702. vector[u] = x * udir;
  8703. vector[v] = y * vdir;
  8704. vector[w] = depthHalf;
  8705. vertices.push(vector.x, vector.y, vector.z);
  8706. vector[u] = 0;
  8707. vector[v] = 0;
  8708. vector[w] = depth2 > 0 ? 1 : -1;
  8709. normals.push(vector.x, vector.y, vector.z);
  8710. uvs.push(ix / gridX);
  8711. uvs.push(1 - iy / gridY);
  8712. vertexCounter += 1;
  8713. }
  8714. }
  8715. for (iy = 0; iy < gridY; iy++) {
  8716. for (ix = 0; ix < gridX; ix++) {
  8717. var a = numberOfVertices + ix + gridX1 * iy;
  8718. var b = numberOfVertices + ix + gridX1 * (iy + 1);
  8719. var c = numberOfVertices + (ix + 1) + gridX1 * (iy + 1);
  8720. var d = numberOfVertices + (ix + 1) + gridX1 * iy;
  8721. indices.push(a, b, d);
  8722. indices.push(b, c, d);
  8723. groupCount += 6;
  8724. }
  8725. }
  8726. scope.addGroup(groupStart, groupCount, materialIndex);
  8727. groupStart += groupCount;
  8728. numberOfVertices += vertexCounter;
  8729. }
  8730. }
  8731. }
  8732. function cloneUniforms(src) {
  8733. var dst = {};
  8734. for (var u in src) {
  8735. dst[u] = {};
  8736. for (var p in src[u]) {
  8737. var property = src[u][p];
  8738. if (property && (property.isColor || property.isMatrix3 || property.isMatrix4 || property.isVector2 || property.isVector3 || property.isVector4 || property.isTexture)) {
  8739. dst[u][p] = property.clone();
  8740. } else if (Array.isArray(property)) {
  8741. dst[u][p] = property.slice();
  8742. } else {
  8743. dst[u][p] = property;
  8744. }
  8745. }
  8746. }
  8747. return dst;
  8748. }
  8749. function mergeUniforms(uniforms) {
  8750. var merged = {};
  8751. for (var u = 0; u < uniforms.length; u++) {
  8752. var tmp2 = cloneUniforms(uniforms[u]);
  8753. for (var p in tmp2) {
  8754. merged[p] = tmp2[p];
  8755. }
  8756. }
  8757. return merged;
  8758. }
  8759. var UniformsUtils = { clone: cloneUniforms, merge: mergeUniforms };
  8760. var default_vertex = "void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}";
  8761. var default_fragment = "void main() {\n gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}";
  8762. function ShaderMaterial(parameters) {
  8763. Material.call(this);
  8764. this.type = "ShaderMaterial";
  8765. this.defines = {};
  8766. this.uniforms = {};
  8767. this.vertexShader = default_vertex;
  8768. this.fragmentShader = default_fragment;
  8769. this.linewidth = 1;
  8770. this.wireframe = false;
  8771. this.wireframeLinewidth = 1;
  8772. this.fog = false;
  8773. this.lights = false;
  8774. this.clipping = false;
  8775. this.skinning = false;
  8776. this.morphTargets = false;
  8777. this.morphNormals = false;
  8778. this.extensions = {
  8779. derivatives: false,
  8780. // set to use derivatives
  8781. fragDepth: false,
  8782. // set to use fragment depth values
  8783. drawBuffers: false,
  8784. // set to use draw buffers
  8785. shaderTextureLOD: false
  8786. // set to use shader texture LOD
  8787. };
  8788. this.defaultAttributeValues = {
  8789. "color": [1, 1, 1],
  8790. "uv": [0, 0],
  8791. "uv2": [0, 0]
  8792. };
  8793. this.index0AttributeName = void 0;
  8794. this.uniformsNeedUpdate = false;
  8795. if (parameters !== void 0) {
  8796. if (parameters.attributes !== void 0) {
  8797. console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead.");
  8798. }
  8799. this.setValues(parameters);
  8800. }
  8801. }
  8802. ShaderMaterial.prototype = Object.create(Material.prototype);
  8803. ShaderMaterial.prototype.constructor = ShaderMaterial;
  8804. ShaderMaterial.prototype.isShaderMaterial = true;
  8805. ShaderMaterial.prototype.copy = function(source) {
  8806. Material.prototype.copy.call(this, source);
  8807. this.fragmentShader = source.fragmentShader;
  8808. this.vertexShader = source.vertexShader;
  8809. this.uniforms = cloneUniforms(source.uniforms);
  8810. this.defines = Object.assign({}, source.defines);
  8811. this.wireframe = source.wireframe;
  8812. this.wireframeLinewidth = source.wireframeLinewidth;
  8813. this.lights = source.lights;
  8814. this.clipping = source.clipping;
  8815. this.skinning = source.skinning;
  8816. this.morphTargets = source.morphTargets;
  8817. this.morphNormals = source.morphNormals;
  8818. this.extensions = source.extensions;
  8819. return this;
  8820. };
  8821. ShaderMaterial.prototype.toJSON = function(meta) {
  8822. var data = Material.prototype.toJSON.call(this, meta);
  8823. data.uniforms = {};
  8824. for (var name in this.uniforms) {
  8825. var uniform = this.uniforms[name];
  8826. var value = uniform.value;
  8827. if (value && value.isTexture) {
  8828. data.uniforms[name] = {
  8829. type: "t",
  8830. value: value.toJSON(meta).uuid
  8831. };
  8832. } else if (value && value.isColor) {
  8833. data.uniforms[name] = {
  8834. type: "c",
  8835. value: value.getHex()
  8836. };
  8837. } else if (value && value.isVector2) {
  8838. data.uniforms[name] = {
  8839. type: "v2",
  8840. value: value.toArray()
  8841. };
  8842. } else if (value && value.isVector3) {
  8843. data.uniforms[name] = {
  8844. type: "v3",
  8845. value: value.toArray()
  8846. };
  8847. } else if (value && value.isVector4) {
  8848. data.uniforms[name] = {
  8849. type: "v4",
  8850. value: value.toArray()
  8851. };
  8852. } else if (value && value.isMatrix3) {
  8853. data.uniforms[name] = {
  8854. type: "m3",
  8855. value: value.toArray()
  8856. };
  8857. } else if (value && value.isMatrix4) {
  8858. data.uniforms[name] = {
  8859. type: "m4",
  8860. value: value.toArray()
  8861. };
  8862. } else {
  8863. data.uniforms[name] = {
  8864. value
  8865. };
  8866. }
  8867. }
  8868. if (Object.keys(this.defines).length > 0)
  8869. data.defines = this.defines;
  8870. data.vertexShader = this.vertexShader;
  8871. data.fragmentShader = this.fragmentShader;
  8872. var extensions = {};
  8873. for (var key in this.extensions) {
  8874. if (this.extensions[key] === true)
  8875. extensions[key] = true;
  8876. }
  8877. if (Object.keys(extensions).length > 0)
  8878. data.extensions = extensions;
  8879. return data;
  8880. };
  8881. function Camera() {
  8882. Object3D.call(this);
  8883. this.type = "Camera";
  8884. this.matrixWorldInverse = new Matrix4();
  8885. this.projectionMatrix = new Matrix4();
  8886. this.projectionMatrixInverse = new Matrix4();
  8887. }
  8888. Camera.prototype = Object.assign(Object.create(Object3D.prototype), {
  8889. constructor: Camera,
  8890. isCamera: true,
  8891. copy: function(source, recursive) {
  8892. Object3D.prototype.copy.call(this, source, recursive);
  8893. this.matrixWorldInverse.copy(source.matrixWorldInverse);
  8894. this.projectionMatrix.copy(source.projectionMatrix);
  8895. this.projectionMatrixInverse.copy(source.projectionMatrixInverse);
  8896. return this;
  8897. },
  8898. getWorldDirection: function(target) {
  8899. if (target === void 0) {
  8900. console.warn("THREE.Camera: .getWorldDirection() target is now required");
  8901. target = new Vector3();
  8902. }
  8903. this.updateMatrixWorld(true);
  8904. var e = this.matrixWorld.elements;
  8905. return target.set(-e[8], -e[9], -e[10]).normalize();
  8906. },
  8907. updateMatrixWorld: function(force) {
  8908. Object3D.prototype.updateMatrixWorld.call(this, force);
  8909. this.matrixWorldInverse.getInverse(this.matrixWorld);
  8910. },
  8911. updateWorldMatrix: function(updateParents, updateChildren) {
  8912. Object3D.prototype.updateWorldMatrix.call(this, updateParents, updateChildren);
  8913. this.matrixWorldInverse.getInverse(this.matrixWorld);
  8914. },
  8915. clone: function() {
  8916. return new this.constructor().copy(this);
  8917. }
  8918. });
  8919. function PerspectiveCamera(fov2, aspect2, near, far) {
  8920. Camera.call(this);
  8921. this.type = "PerspectiveCamera";
  8922. this.fov = fov2 !== void 0 ? fov2 : 50;
  8923. this.zoom = 1;
  8924. this.near = near !== void 0 ? near : 0.1;
  8925. this.far = far !== void 0 ? far : 2e3;
  8926. this.focus = 10;
  8927. this.aspect = aspect2 !== void 0 ? aspect2 : 1;
  8928. this.view = null;
  8929. this.filmGauge = 35;
  8930. this.filmOffset = 0;
  8931. this.updateProjectionMatrix();
  8932. }
  8933. PerspectiveCamera.prototype = Object.assign(Object.create(Camera.prototype), {
  8934. constructor: PerspectiveCamera,
  8935. isPerspectiveCamera: true,
  8936. copy: function(source, recursive) {
  8937. Camera.prototype.copy.call(this, source, recursive);
  8938. this.fov = source.fov;
  8939. this.zoom = source.zoom;
  8940. this.near = source.near;
  8941. this.far = source.far;
  8942. this.focus = source.focus;
  8943. this.aspect = source.aspect;
  8944. this.view = source.view === null ? null : Object.assign({}, source.view);
  8945. this.filmGauge = source.filmGauge;
  8946. this.filmOffset = source.filmOffset;
  8947. return this;
  8948. },
  8949. /**
  8950. * Sets the FOV by focal length in respect to the current .filmGauge.
  8951. *
  8952. * The default film gauge is 35, so that the focal length can be specified for
  8953. * a 35mm (full frame) camera.
  8954. *
  8955. * Values for focal length and film gauge must have the same unit.
  8956. */
  8957. setFocalLength: function(focalLength) {
  8958. var vExtentSlope = 0.5 * this.getFilmHeight() / focalLength;
  8959. this.fov = MathUtils.RAD2DEG * 2 * Math.atan(vExtentSlope);
  8960. this.updateProjectionMatrix();
  8961. },
  8962. /**
  8963. * Calculates the focal length from the current .fov and .filmGauge.
  8964. */
  8965. getFocalLength: function() {
  8966. var vExtentSlope = Math.tan(MathUtils.DEG2RAD * 0.5 * this.fov);
  8967. return 0.5 * this.getFilmHeight() / vExtentSlope;
  8968. },
  8969. getEffectiveFOV: function() {
  8970. return MathUtils.RAD2DEG * 2 * Math.atan(
  8971. Math.tan(MathUtils.DEG2RAD * 0.5 * this.fov) / this.zoom
  8972. );
  8973. },
  8974. getFilmWidth: function() {
  8975. return this.filmGauge * Math.min(this.aspect, 1);
  8976. },
  8977. getFilmHeight: function() {
  8978. return this.filmGauge / Math.max(this.aspect, 1);
  8979. },
  8980. /**
  8981. * Sets an offset in a larger frustum. This is useful for multi-window or
  8982. * multi-monitor/multi-machine setups.
  8983. *
  8984. * For example, if you have 3x2 monitors and each monitor is 1920x1080 and
  8985. * the monitors are in grid like this
  8986. *
  8987. * +---+---+---+
  8988. * | A | B | C |
  8989. * +---+---+---+
  8990. * | D | E | F |
  8991. * +---+---+---+
  8992. *
  8993. * then for each monitor you would call it like this
  8994. *
  8995. * var w = 1920;
  8996. * var h = 1080;
  8997. * var fullWidth = w * 3;
  8998. * var fullHeight = h * 2;
  8999. *
  9000. * --A--
  9001. * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
  9002. * --B--
  9003. * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );
  9004. * --C--
  9005. * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );
  9006. * --D--
  9007. * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );
  9008. * --E--
  9009. * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
  9010. * --F--
  9011. * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );
  9012. *
  9013. * Note there is no reason monitors have to be the same size or in a grid.
  9014. */
  9015. setViewOffset: function(fullWidth, fullHeight, x, y, width, height) {
  9016. this.aspect = fullWidth / fullHeight;
  9017. if (this.view === null) {
  9018. this.view = {
  9019. enabled: true,
  9020. fullWidth: 1,
  9021. fullHeight: 1,
  9022. offsetX: 0,
  9023. offsetY: 0,
  9024. width: 1,
  9025. height: 1
  9026. };
  9027. }
  9028. this.view.enabled = true;
  9029. this.view.fullWidth = fullWidth;
  9030. this.view.fullHeight = fullHeight;
  9031. this.view.offsetX = x;
  9032. this.view.offsetY = y;
  9033. this.view.width = width;
  9034. this.view.height = height;
  9035. this.updateProjectionMatrix();
  9036. },
  9037. clearViewOffset: function() {
  9038. if (this.view !== null) {
  9039. this.view.enabled = false;
  9040. }
  9041. this.updateProjectionMatrix();
  9042. },
  9043. updateProjectionMatrix: function() {
  9044. var near = this.near, top2 = near * Math.tan(MathUtils.DEG2RAD * 0.5 * this.fov) / this.zoom, height = 2 * top2, width = this.aspect * height, left = -0.5 * width, view = this.view;
  9045. if (this.view !== null && this.view.enabled) {
  9046. var fullWidth = view.fullWidth, fullHeight = view.fullHeight;
  9047. left += view.offsetX * width / fullWidth;
  9048. top2 -= view.offsetY * height / fullHeight;
  9049. width *= view.width / fullWidth;
  9050. height *= view.height / fullHeight;
  9051. }
  9052. var skew = this.filmOffset;
  9053. if (skew !== 0)
  9054. left += near * skew / this.getFilmWidth();
  9055. this.projectionMatrix.makePerspective(left, left + width, top2, top2 - height, near, this.far);
  9056. this.projectionMatrixInverse.getInverse(this.projectionMatrix);
  9057. },
  9058. toJSON: function(meta) {
  9059. var data = Object3D.prototype.toJSON.call(this, meta);
  9060. data.object.fov = this.fov;
  9061. data.object.zoom = this.zoom;
  9062. data.object.near = this.near;
  9063. data.object.far = this.far;
  9064. data.object.focus = this.focus;
  9065. data.object.aspect = this.aspect;
  9066. if (this.view !== null)
  9067. data.object.view = Object.assign({}, this.view);
  9068. data.object.filmGauge = this.filmGauge;
  9069. data.object.filmOffset = this.filmOffset;
  9070. return data;
  9071. }
  9072. });
  9073. var fov = 90, aspect = 1;
  9074. function CubeCamera(near, far, cubeResolution, options) {
  9075. Object3D.call(this);
  9076. this.type = "CubeCamera";
  9077. var cameraPX = new PerspectiveCamera(fov, aspect, near, far);
  9078. cameraPX.up.set(0, -1, 0);
  9079. cameraPX.lookAt(new Vector3(1, 0, 0));
  9080. this.add(cameraPX);
  9081. var cameraNX = new PerspectiveCamera(fov, aspect, near, far);
  9082. cameraNX.up.set(0, -1, 0);
  9083. cameraNX.lookAt(new Vector3(-1, 0, 0));
  9084. this.add(cameraNX);
  9085. var cameraPY = new PerspectiveCamera(fov, aspect, near, far);
  9086. cameraPY.up.set(0, 0, 1);
  9087. cameraPY.lookAt(new Vector3(0, 1, 0));
  9088. this.add(cameraPY);
  9089. var cameraNY = new PerspectiveCamera(fov, aspect, near, far);
  9090. cameraNY.up.set(0, 0, -1);
  9091. cameraNY.lookAt(new Vector3(0, -1, 0));
  9092. this.add(cameraNY);
  9093. var cameraPZ = new PerspectiveCamera(fov, aspect, near, far);
  9094. cameraPZ.up.set(0, -1, 0);
  9095. cameraPZ.lookAt(new Vector3(0, 0, 1));
  9096. this.add(cameraPZ);
  9097. var cameraNZ = new PerspectiveCamera(fov, aspect, near, far);
  9098. cameraNZ.up.set(0, -1, 0);
  9099. cameraNZ.lookAt(new Vector3(0, 0, -1));
  9100. this.add(cameraNZ);
  9101. options = options || { format: RGBFormat, magFilter: LinearFilter, minFilter: LinearFilter };
  9102. this.renderTarget = new WebGLCubeRenderTarget(cubeResolution, options);
  9103. this.renderTarget.texture.name = "CubeCamera";
  9104. this.update = function(renderer, scene) {
  9105. if (this.parent === null)
  9106. this.updateMatrixWorld();
  9107. var currentRenderTarget = renderer.getRenderTarget();
  9108. var renderTarget = this.renderTarget;
  9109. var generateMipmaps = renderTarget.texture.generateMipmaps;
  9110. renderTarget.texture.generateMipmaps = false;
  9111. renderer.setRenderTarget(renderTarget, 0);
  9112. renderer.render(scene, cameraPX);
  9113. renderer.setRenderTarget(renderTarget, 1);
  9114. renderer.render(scene, cameraNX);
  9115. renderer.setRenderTarget(renderTarget, 2);
  9116. renderer.render(scene, cameraPY);
  9117. renderer.setRenderTarget(renderTarget, 3);
  9118. renderer.render(scene, cameraNY);
  9119. renderer.setRenderTarget(renderTarget, 4);
  9120. renderer.render(scene, cameraPZ);
  9121. renderTarget.texture.generateMipmaps = generateMipmaps;
  9122. renderer.setRenderTarget(renderTarget, 5);
  9123. renderer.render(scene, cameraNZ);
  9124. renderer.setRenderTarget(currentRenderTarget);
  9125. };
  9126. this.clear = function(renderer, color, depth, stencil) {
  9127. var currentRenderTarget = renderer.getRenderTarget();
  9128. var renderTarget = this.renderTarget;
  9129. for (var i2 = 0; i2 < 6; i2++) {
  9130. renderer.setRenderTarget(renderTarget, i2);
  9131. renderer.clear(color, depth, stencil);
  9132. }
  9133. renderer.setRenderTarget(currentRenderTarget);
  9134. };
  9135. }
  9136. CubeCamera.prototype = Object.create(Object3D.prototype);
  9137. CubeCamera.prototype.constructor = CubeCamera;
  9138. function WebGLCubeRenderTarget(size, options, dummy) {
  9139. if (Number.isInteger(options)) {
  9140. console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )");
  9141. options = dummy;
  9142. }
  9143. WebGLRenderTarget.call(this, size, size, options);
  9144. }
  9145. WebGLCubeRenderTarget.prototype = Object.create(WebGLRenderTarget.prototype);
  9146. WebGLCubeRenderTarget.prototype.constructor = WebGLCubeRenderTarget;
  9147. WebGLCubeRenderTarget.prototype.isWebGLCubeRenderTarget = true;
  9148. WebGLCubeRenderTarget.prototype.fromEquirectangularTexture = function(renderer, texture) {
  9149. this.texture.type = texture.type;
  9150. this.texture.format = texture.format;
  9151. this.texture.encoding = texture.encoding;
  9152. var scene = new Scene();
  9153. var shader = {
  9154. uniforms: {
  9155. tEquirect: { value: null }
  9156. },
  9157. vertexShader: [
  9158. "varying vec3 vWorldDirection;",
  9159. "vec3 transformDirection( in vec3 dir, in mat4 matrix ) {",
  9160. " return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );",
  9161. "}",
  9162. "void main() {",
  9163. " vWorldDirection = transformDirection( position, modelMatrix );",
  9164. " #include <begin_vertex>",
  9165. " #include <project_vertex>",
  9166. "}"
  9167. ].join("\n"),
  9168. fragmentShader: [
  9169. "uniform sampler2D tEquirect;",
  9170. "varying vec3 vWorldDirection;",
  9171. "#define RECIPROCAL_PI 0.31830988618",
  9172. "#define RECIPROCAL_PI2 0.15915494",
  9173. "void main() {",
  9174. " vec3 direction = normalize( vWorldDirection );",
  9175. " vec2 sampleUV;",
  9176. " sampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;",
  9177. " sampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;",
  9178. " gl_FragColor = texture2D( tEquirect, sampleUV );",
  9179. "}"
  9180. ].join("\n")
  9181. };
  9182. var material = new ShaderMaterial({
  9183. type: "CubemapFromEquirect",
  9184. uniforms: cloneUniforms(shader.uniforms),
  9185. vertexShader: shader.vertexShader,
  9186. fragmentShader: shader.fragmentShader,
  9187. side: BackSide,
  9188. blending: NoBlending
  9189. });
  9190. material.uniforms.tEquirect.value = texture;
  9191. var mesh = new Mesh(new BoxBufferGeometry(5, 5, 5), material);
  9192. scene.add(mesh);
  9193. var camera = new CubeCamera(1, 10, 1);
  9194. camera.renderTarget = this;
  9195. camera.renderTarget.texture.name = "CubeCameraTexture";
  9196. camera.update(renderer, scene);
  9197. mesh.geometry.dispose();
  9198. mesh.material.dispose();
  9199. return this;
  9200. };
  9201. function DataTexture(data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding) {
  9202. Texture.call(this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);
  9203. this.image = { data: data || null, width: width || 1, height: height || 1 };
  9204. this.magFilter = magFilter !== void 0 ? magFilter : NearestFilter;
  9205. this.minFilter = minFilter !== void 0 ? minFilter : NearestFilter;
  9206. this.generateMipmaps = false;
  9207. this.flipY = false;
  9208. this.unpackAlignment = 1;
  9209. this.needsUpdate = true;
  9210. }
  9211. DataTexture.prototype = Object.create(Texture.prototype);
  9212. DataTexture.prototype.constructor = DataTexture;
  9213. DataTexture.prototype.isDataTexture = true;
  9214. var _sphere$1 = new Sphere();
  9215. var _vector$5 = new Vector3();
  9216. function Frustum(p0, p1, p2, p3, p4, p5) {
  9217. this.planes = [
  9218. p0 !== void 0 ? p0 : new Plane(),
  9219. p1 !== void 0 ? p1 : new Plane(),
  9220. p2 !== void 0 ? p2 : new Plane(),
  9221. p3 !== void 0 ? p3 : new Plane(),
  9222. p4 !== void 0 ? p4 : new Plane(),
  9223. p5 !== void 0 ? p5 : new Plane()
  9224. ];
  9225. }
  9226. Object.assign(Frustum.prototype, {
  9227. set: function(p0, p1, p2, p3, p4, p5) {
  9228. var planes = this.planes;
  9229. planes[0].copy(p0);
  9230. planes[1].copy(p1);
  9231. planes[2].copy(p2);
  9232. planes[3].copy(p3);
  9233. planes[4].copy(p4);
  9234. planes[5].copy(p5);
  9235. return this;
  9236. },
  9237. clone: function() {
  9238. return new this.constructor().copy(this);
  9239. },
  9240. copy: function(frustum) {
  9241. var planes = this.planes;
  9242. for (var i2 = 0; i2 < 6; i2++) {
  9243. planes[i2].copy(frustum.planes[i2]);
  9244. }
  9245. return this;
  9246. },
  9247. setFromProjectionMatrix: function(m) {
  9248. var planes = this.planes;
  9249. var me = m.elements;
  9250. var me0 = me[0], me1 = me[1], me2 = me[2], me3 = me[3];
  9251. var me4 = me[4], me5 = me[5], me6 = me[6], me7 = me[7];
  9252. var me8 = me[8], me9 = me[9], me10 = me[10], me11 = me[11];
  9253. var me12 = me[12], me13 = me[13], me14 = me[14], me15 = me[15];
  9254. planes[0].setComponents(me3 - me0, me7 - me4, me11 - me8, me15 - me12).normalize();
  9255. planes[1].setComponents(me3 + me0, me7 + me4, me11 + me8, me15 + me12).normalize();
  9256. planes[2].setComponents(me3 + me1, me7 + me5, me11 + me9, me15 + me13).normalize();
  9257. planes[3].setComponents(me3 - me1, me7 - me5, me11 - me9, me15 - me13).normalize();
  9258. planes[4].setComponents(me3 - me2, me7 - me6, me11 - me10, me15 - me14).normalize();
  9259. planes[5].setComponents(me3 + me2, me7 + me6, me11 + me10, me15 + me14).normalize();
  9260. return this;
  9261. },
  9262. intersectsObject: function(object) {
  9263. var geometry = object.geometry;
  9264. if (geometry.boundingSphere === null)
  9265. geometry.computeBoundingSphere();
  9266. _sphere$1.copy(geometry.boundingSphere).applyMatrix4(object.matrixWorld);
  9267. return this.intersectsSphere(_sphere$1);
  9268. },
  9269. intersectsSprite: function(sprite) {
  9270. _sphere$1.center.set(0, 0, 0);
  9271. _sphere$1.radius = 0.7071067811865476;
  9272. _sphere$1.applyMatrix4(sprite.matrixWorld);
  9273. return this.intersectsSphere(_sphere$1);
  9274. },
  9275. intersectsSphere: function(sphere) {
  9276. var planes = this.planes;
  9277. var center = sphere.center;
  9278. var negRadius = -sphere.radius;
  9279. for (var i2 = 0; i2 < 6; i2++) {
  9280. var distance = planes[i2].distanceToPoint(center);
  9281. if (distance < negRadius) {
  9282. return false;
  9283. }
  9284. }
  9285. return true;
  9286. },
  9287. intersectsBox: function(box) {
  9288. var planes = this.planes;
  9289. for (var i2 = 0; i2 < 6; i2++) {
  9290. var plane = planes[i2];
  9291. _vector$5.x = plane.normal.x > 0 ? box.max.x : box.min.x;
  9292. _vector$5.y = plane.normal.y > 0 ? box.max.y : box.min.y;
  9293. _vector$5.z = plane.normal.z > 0 ? box.max.z : box.min.z;
  9294. if (plane.distanceToPoint(_vector$5) < 0) {
  9295. return false;
  9296. }
  9297. }
  9298. return true;
  9299. },
  9300. containsPoint: function(point) {
  9301. var planes = this.planes;
  9302. for (var i2 = 0; i2 < 6; i2++) {
  9303. if (planes[i2].distanceToPoint(point) < 0) {
  9304. return false;
  9305. }
  9306. }
  9307. return true;
  9308. }
  9309. });
  9310. var UniformsLib = {
  9311. common: {
  9312. diffuse: { value: new Color(15658734) },
  9313. opacity: { value: 1 },
  9314. map: { value: null },
  9315. uvTransform: { value: new Matrix3() },
  9316. uv2Transform: { value: new Matrix3() },
  9317. alphaMap: { value: null }
  9318. },
  9319. specularmap: {
  9320. specularMap: { value: null }
  9321. },
  9322. envmap: {
  9323. envMap: { value: null },
  9324. flipEnvMap: { value: -1 },
  9325. reflectivity: { value: 1 },
  9326. refractionRatio: { value: 0.98 },
  9327. maxMipLevel: { value: 0 }
  9328. },
  9329. aomap: {
  9330. aoMap: { value: null },
  9331. aoMapIntensity: { value: 1 }
  9332. },
  9333. lightmap: {
  9334. lightMap: { value: null },
  9335. lightMapIntensity: { value: 1 }
  9336. },
  9337. emissivemap: {
  9338. emissiveMap: { value: null }
  9339. },
  9340. bumpmap: {
  9341. bumpMap: { value: null },
  9342. bumpScale: { value: 1 }
  9343. },
  9344. normalmap: {
  9345. normalMap: { value: null },
  9346. normalScale: { value: new Vector2(1, 1) }
  9347. },
  9348. displacementmap: {
  9349. displacementMap: { value: null },
  9350. displacementScale: { value: 1 },
  9351. displacementBias: { value: 0 }
  9352. },
  9353. roughnessmap: {
  9354. roughnessMap: { value: null }
  9355. },
  9356. metalnessmap: {
  9357. metalnessMap: { value: null }
  9358. },
  9359. gradientmap: {
  9360. gradientMap: { value: null }
  9361. },
  9362. fog: {
  9363. fogDensity: { value: 25e-5 },
  9364. fogNear: { value: 1 },
  9365. fogFar: { value: 2e3 },
  9366. fogColor: { value: new Color(16777215) }
  9367. },
  9368. lights: {
  9369. ambientLightColor: { value: [] },
  9370. lightProbe: { value: [] },
  9371. directionalLights: { value: [], properties: {
  9372. direction: {},
  9373. color: {},
  9374. shadow: {},
  9375. shadowBias: {},
  9376. shadowRadius: {},
  9377. shadowMapSize: {}
  9378. } },
  9379. directionalShadowMap: { value: [] },
  9380. directionalShadowMatrix: { value: [] },
  9381. spotLights: { value: [], properties: {
  9382. color: {},
  9383. position: {},
  9384. direction: {},
  9385. distance: {},
  9386. coneCos: {},
  9387. penumbraCos: {},
  9388. decay: {},
  9389. shadow: {},
  9390. shadowBias: {},
  9391. shadowRadius: {},
  9392. shadowMapSize: {}
  9393. } },
  9394. spotShadowMap: { value: [] },
  9395. spotShadowMatrix: { value: [] },
  9396. pointLights: { value: [], properties: {
  9397. color: {},
  9398. position: {},
  9399. decay: {},
  9400. distance: {},
  9401. shadow: {},
  9402. shadowBias: {},
  9403. shadowRadius: {},
  9404. shadowMapSize: {},
  9405. shadowCameraNear: {},
  9406. shadowCameraFar: {}
  9407. } },
  9408. pointShadowMap: { value: [] },
  9409. pointShadowMatrix: { value: [] },
  9410. hemisphereLights: { value: [], properties: {
  9411. direction: {},
  9412. skyColor: {},
  9413. groundColor: {}
  9414. } },
  9415. // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src
  9416. rectAreaLights: { value: [], properties: {
  9417. color: {},
  9418. position: {},
  9419. width: {},
  9420. height: {}
  9421. } }
  9422. },
  9423. points: {
  9424. diffuse: { value: new Color(15658734) },
  9425. opacity: { value: 1 },
  9426. size: { value: 1 },
  9427. scale: { value: 1 },
  9428. map: { value: null },
  9429. alphaMap: { value: null },
  9430. uvTransform: { value: new Matrix3() }
  9431. },
  9432. sprite: {
  9433. diffuse: { value: new Color(15658734) },
  9434. opacity: { value: 1 },
  9435. center: { value: new Vector2(0.5, 0.5) },
  9436. rotation: { value: 0 },
  9437. map: { value: null },
  9438. alphaMap: { value: null },
  9439. uvTransform: { value: new Matrix3() }
  9440. }
  9441. };
  9442. function WebGLAnimation() {
  9443. var context = null;
  9444. var isAnimating = false;
  9445. var animationLoop = null;
  9446. function onAnimationFrame(time, frame) {
  9447. if (isAnimating === false)
  9448. return;
  9449. animationLoop(time, frame);
  9450. context.requestAnimationFrame(onAnimationFrame);
  9451. }
  9452. return {
  9453. start: function() {
  9454. if (isAnimating === true)
  9455. return;
  9456. if (animationLoop === null)
  9457. return;
  9458. context.requestAnimationFrame(onAnimationFrame);
  9459. isAnimating = true;
  9460. },
  9461. stop: function() {
  9462. isAnimating = false;
  9463. },
  9464. setAnimationLoop: function(callback) {
  9465. animationLoop = callback;
  9466. },
  9467. setContext: function(value) {
  9468. context = value;
  9469. }
  9470. };
  9471. }
  9472. function WebGLAttributes(gl, capabilities) {
  9473. var isWebGL2 = capabilities.isWebGL2;
  9474. var buffers = /* @__PURE__ */ new WeakMap();
  9475. function createBuffer(attribute, bufferType) {
  9476. var array = attribute.array;
  9477. var usage = attribute.usage;
  9478. var buffer = gl.createBuffer();
  9479. gl.bindBuffer(bufferType, buffer);
  9480. gl.bufferData(bufferType, array, usage);
  9481. attribute.onUploadCallback();
  9482. var type = 5126;
  9483. if (array instanceof Float32Array) {
  9484. type = 5126;
  9485. } else if (array instanceof Float64Array) {
  9486. console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.");
  9487. } else if (array instanceof Uint16Array) {
  9488. type = 5123;
  9489. } else if (array instanceof Int16Array) {
  9490. type = 5122;
  9491. } else if (array instanceof Uint32Array) {
  9492. type = 5125;
  9493. } else if (array instanceof Int32Array) {
  9494. type = 5124;
  9495. } else if (array instanceof Int8Array) {
  9496. type = 5120;
  9497. } else if (array instanceof Uint8Array) {
  9498. type = 5121;
  9499. }
  9500. return {
  9501. buffer,
  9502. type,
  9503. bytesPerElement: array.BYTES_PER_ELEMENT,
  9504. version: attribute.version
  9505. };
  9506. }
  9507. function updateBuffer(buffer, attribute, bufferType) {
  9508. var array = attribute.array;
  9509. var updateRange = attribute.updateRange;
  9510. gl.bindBuffer(bufferType, buffer);
  9511. if (updateRange.count === -1) {
  9512. gl.bufferSubData(bufferType, 0, array);
  9513. } else {
  9514. if (isWebGL2) {
  9515. gl.bufferSubData(
  9516. bufferType,
  9517. updateRange.offset * array.BYTES_PER_ELEMENT,
  9518. array,
  9519. updateRange.offset,
  9520. updateRange.count
  9521. );
  9522. } else {
  9523. gl.bufferSubData(
  9524. bufferType,
  9525. updateRange.offset * array.BYTES_PER_ELEMENT,
  9526. array.subarray(updateRange.offset, updateRange.offset + updateRange.count)
  9527. );
  9528. }
  9529. updateRange.count = -1;
  9530. }
  9531. }
  9532. function get(attribute) {
  9533. if (attribute.isInterleavedBufferAttribute)
  9534. attribute = attribute.data;
  9535. return buffers.get(attribute);
  9536. }
  9537. function remove(attribute) {
  9538. if (attribute.isInterleavedBufferAttribute)
  9539. attribute = attribute.data;
  9540. var data = buffers.get(attribute);
  9541. if (data) {
  9542. gl.deleteBuffer(data.buffer);
  9543. buffers.delete(attribute);
  9544. }
  9545. }
  9546. function update(attribute, bufferType) {
  9547. if (attribute.isInterleavedBufferAttribute)
  9548. attribute = attribute.data;
  9549. var data = buffers.get(attribute);
  9550. if (data === void 0) {
  9551. buffers.set(attribute, createBuffer(attribute, bufferType));
  9552. } else if (data.version < attribute.version) {
  9553. updateBuffer(data.buffer, attribute, bufferType);
  9554. data.version = attribute.version;
  9555. }
  9556. }
  9557. return {
  9558. get,
  9559. remove,
  9560. update
  9561. };
  9562. }
  9563. function PlaneGeometry(width, height, widthSegments, heightSegments) {
  9564. Geometry.call(this);
  9565. this.type = "PlaneGeometry";
  9566. this.parameters = {
  9567. width,
  9568. height,
  9569. widthSegments,
  9570. heightSegments
  9571. };
  9572. this.fromBufferGeometry(new PlaneBufferGeometry(width, height, widthSegments, heightSegments));
  9573. this.mergeVertices();
  9574. }
  9575. PlaneGeometry.prototype = Object.create(Geometry.prototype);
  9576. PlaneGeometry.prototype.constructor = PlaneGeometry;
  9577. function PlaneBufferGeometry(width, height, widthSegments, heightSegments) {
  9578. BufferGeometry.call(this);
  9579. this.type = "PlaneBufferGeometry";
  9580. this.parameters = {
  9581. width,
  9582. height,
  9583. widthSegments,
  9584. heightSegments
  9585. };
  9586. width = width || 1;
  9587. height = height || 1;
  9588. var width_half = width / 2;
  9589. var height_half = height / 2;
  9590. var gridX = Math.floor(widthSegments) || 1;
  9591. var gridY = Math.floor(heightSegments) || 1;
  9592. var gridX1 = gridX + 1;
  9593. var gridY1 = gridY + 1;
  9594. var segment_width = width / gridX;
  9595. var segment_height = height / gridY;
  9596. var ix, iy;
  9597. var indices = [];
  9598. var vertices = [];
  9599. var normals = [];
  9600. var uvs = [];
  9601. for (iy = 0; iy < gridY1; iy++) {
  9602. var y = iy * segment_height - height_half;
  9603. for (ix = 0; ix < gridX1; ix++) {
  9604. var x = ix * segment_width - width_half;
  9605. vertices.push(x, -y, 0);
  9606. normals.push(0, 0, 1);
  9607. uvs.push(ix / gridX);
  9608. uvs.push(1 - iy / gridY);
  9609. }
  9610. }
  9611. for (iy = 0; iy < gridY; iy++) {
  9612. for (ix = 0; ix < gridX; ix++) {
  9613. var a = ix + gridX1 * iy;
  9614. var b = ix + gridX1 * (iy + 1);
  9615. var c = ix + 1 + gridX1 * (iy + 1);
  9616. var d = ix + 1 + gridX1 * iy;
  9617. indices.push(a, b, d);
  9618. indices.push(b, c, d);
  9619. }
  9620. }
  9621. this.setIndex(indices);
  9622. this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  9623. this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
  9624. this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
  9625. }
  9626. PlaneBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
  9627. PlaneBufferGeometry.prototype.constructor = PlaneBufferGeometry;
  9628. var alphamap_fragment = "#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif";
  9629. var alphamap_pars_fragment = "#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif";
  9630. var alphatest_fragment = "#ifdef ALPHATEST\n if ( diffuseColor.a < ALPHATEST ) discard;\n#endif";
  9631. var aomap_fragment = "#ifdef USE_AOMAP\n float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n reflectedLight.indirectDiffuse *= ambientOcclusion;\n #if defined( USE_ENVMAP ) && defined( STANDARD )\n float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n #endif\n#endif";
  9632. var aomap_pars_fragment = "#ifdef USE_AOMAP\n uniform sampler2D aoMap;\n uniform float aoMapIntensity;\n#endif";
  9633. var begin_vertex = "vec3 transformed = vec3( position );";
  9634. var beginnormal_vertex = "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n vec3 objectTangent = vec3( tangent.xyz );\n#endif";
  9635. var bsdfs = "vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n return vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n#else\n if( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n }\n return 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n return ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n float fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n vec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n return Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n return 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( incidentLight.direction + viewDir );\n float dotNL = saturate( dot( normal, incidentLight.direction ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n vec3 F = F_Schlick( specularColor, dotLH );\n float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n return specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n vec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n vec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n vec3 FssEss = F * brdf.x + brdf.y;\n float Ess = brdf.x + brdf.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n return 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n float dotNH = saturate( dot( geometry.normal, halfDir ) );\n float dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n vec3 F = F_Schlick( specularColor, dotLH );\n float G = G_BlinnPhong_Implicit( );\n float D = D_BlinnPhong( shininess, dotNH );\n return F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n return ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n return sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n float invAlpha = 1.0 / roughness;\n float cos2h = NoH * NoH;\n float sin2h = max(1.0 - cos2h, 0.0078125); return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n vec3 N = geometry.normal;\n vec3 V = geometry.viewDir;\n vec3 H = normalize( V + L );\n float dotNH = saturate( dot( N, H ) );\n return specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif";
  9636. var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n uniform sampler2D bumpMap;\n uniform float bumpScale;\n vec2 dHdxy_fwd() {\n vec2 dSTdx = dFdx( vUv );\n vec2 dSTdy = dFdy( vUv );\n float Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n return vec2( dBx, dBy );\n }\n vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n vec3 vN = surf_norm;\n vec3 R1 = cross( vSigmaY, vN );\n vec3 R2 = cross( vN, vSigmaX );\n float fDet = dot( vSigmaX, R1 );\n fDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n return normalize( abs( fDet ) * surf_norm - vGrad );\n }\n#endif";
  9637. var clipping_planes_fragment = "#if NUM_CLIPPING_PLANES > 0\n vec4 plane;\n #pragma unroll_loop\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n if ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n }\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n bool clipped = true;\n #pragma unroll_loop\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n clipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n }\n if ( clipped ) discard;\n #endif\n#endif";
  9638. var clipping_planes_pars_fragment = "#if NUM_CLIPPING_PLANES > 0\n #if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n varying vec3 vViewPosition;\n #endif\n uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif";
  9639. var clipping_planes_pars_vertex = "#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n varying vec3 vViewPosition;\n#endif";
  9640. var clipping_planes_vertex = "#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n vViewPosition = - mvPosition.xyz;\n#endif";
  9641. var color_fragment = "#ifdef USE_COLOR\n diffuseColor.rgb *= vColor;\n#endif";
  9642. var color_pars_fragment = "#ifdef USE_COLOR\n varying vec3 vColor;\n#endif";
  9643. var color_pars_vertex = "#ifdef USE_COLOR\n varying vec3 vColor;\n#endif";
  9644. var color_vertex = "#ifdef USE_COLOR\n vColor.xyz = color.xyz;\n#endif";
  9645. var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n return fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n float precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n float max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n float precisionSafeLength( vec3 v ) {\n float maxComponent = max3( abs( v ) );\n return length( v / maxComponent ) * maxComponent;\n }\n#endif\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n bool visible;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\nstruct GeometricContext {\n vec3 position;\n vec3 normal;\n vec3 viewDir;\n#ifdef CLEARCOAT\n vec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n float distance = dot( planeNormal, point - pointOnPlane );\n return - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n mat3 tmp;\n tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n return tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n return dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}";
  9646. var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\nfloat getFace(vec3 direction) {\n vec3 absDirection = abs(direction);\n float face = -1.0;\n if (absDirection.x > absDirection.z) {\n if (absDirection.x > absDirection.y)\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if (absDirection.z > absDirection.y)\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n}\nvec2 getUV(vec3 direction, float face) {\n vec2 uv;\n if (face == 0.0) {\n uv = vec2(-direction.z, direction.y) / abs(direction.x);\n } else if (face == 1.0) {\n uv = vec2(direction.x, -direction.z) / abs(direction.y);\n } else if (face == 2.0) {\n uv = direction.xy / abs(direction.z);\n } else if (face == 3.0) {\n uv = vec2(direction.z, direction.y) / abs(direction.x);\n } else if (face == 4.0) {\n uv = direction.xz / abs(direction.y);\n } else {\n uv = vec2(-direction.x, direction.y) / abs(direction.z);\n }\n return 0.5 * (uv + 1.0);\n}\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if(mipInt < cubeUV_maxMipLevel){\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize;\n vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize;\n vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize;\n vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n return mix(tm, bm, f.y);\n}\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\nfloat roughnessToMip(float roughness) {\n float mip = 0.0;\n if (roughness >= r1) {\n mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n } else if (roughness >= r4) {\n mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n } else if (roughness >= r5) {\n mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n } else if (roughness >= r6) {\n mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n } else {\n mip = -2.0 * log2(1.16 * roughness); }\n return mip;\n}\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\n#endif";
  9647. var defaultnormal_vertex = "vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n transformedNormal = mat3( instanceMatrix ) * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n#endif";
  9648. var displacementmap_pars_vertex = "#ifdef USE_DISPLACEMENTMAP\n uniform sampler2D displacementMap;\n uniform float displacementScale;\n uniform float displacementBias;\n#endif";
  9649. var displacementmap_vertex = "#ifdef USE_DISPLACEMENTMAP\n transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif";
  9650. var emissivemap_fragment = "#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = texture2D( emissiveMap, vUv );\n emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n totalEmissiveRadiance *= emissiveColor.rgb;\n#endif";
  9651. var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif";
  9652. var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
  9653. var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n return value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n 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 );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n 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 );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n float maxComponent = max( max( value.r, value.g ), value.b );\n float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.r, max( value.g, value.b ) );\n float M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n M = ceil( M * 255.0 ) / 255.0;\n return vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.r, max( value.g, value.b ) );\n float D = max( maxRange / maxRGB, 1.0 );\n D = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n vec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n Xp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n vec4 vResult;\n vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n vResult.w = fract( Le );\n vResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n return vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n float Le = value.z * 255.0 + value.w;\n vec3 Xp_Y_XYZp;\n Xp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n return vec4( max( vRGB, 0.0 ), 1.0 );\n}";
  9654. var envmap_fragment = "#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n \n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n #elif defined( ENVMAP_TYPE_EQUIREC )\n vec2 sampleUV;\n reflectVec = normalize( reflectVec );\n sampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n sampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n vec4 envColor = texture2D( envMap, sampleUV );\n #elif defined( ENVMAP_TYPE_SPHERE )\n reflectVec = normalize( reflectVec );\n vec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n vec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n #else\n vec4 envColor = vec4( 0.0 );\n #endif\n #ifndef ENVMAP_TYPE_CUBE_UV\n envColor = envMapTexelToLinear( envColor );\n #endif\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n#endif";
  9655. var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform float flipEnvMap;\n uniform int maxMipLevel;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n \n#endif";
  9656. var envmap_pars_fragment = "#ifdef USE_ENVMAP\n uniform float reflectivity;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n varying vec3 vWorldPosition;\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif";
  9657. var envmap_pars_vertex = "#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n \n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif";
  9658. var envmap_vertex = "#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex;\n if ( isOrthographic ) { \n cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect( cameraToVertex, worldNormal );\n #else\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #endif\n#endif";
  9659. var fog_vertex = "#ifdef USE_FOG\n fogDepth = -mvPosition.z;\n#endif";
  9660. var fog_pars_vertex = "#ifdef USE_FOG\n varying float fogDepth;\n#endif";
  9661. var fog_fragment = "#ifdef USE_FOG\n #ifdef FOG_EXP2\n float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n #else\n float fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n #endif\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif";
  9662. var fog_pars_fragment = "#ifdef USE_FOG\n uniform vec3 fogColor;\n varying float fogDepth;\n #ifdef FOG_EXP2\n uniform float fogDensity;\n #else\n uniform float fogNear;\n uniform float fogFar;\n #endif\n#endif";
  9663. var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n uniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n float dotNL = dot( normal, lightDirection );\n vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n #ifdef USE_GRADIENTMAP\n return texture2D( gradientMap, coord ).rgb;\n #else\n return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n #endif\n}";
  9664. var lightmap_fragment = "#ifdef USE_LIGHTMAP\n vec4 lightMapTexel= texture2D( lightMap, vUv2 );\n reflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif";
  9665. var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif";
  9666. var lights_lambert_vertex = "vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n vLightBack = vec3( 0.0 );\n vIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n #pragma unroll_loop\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n getPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n #pragma unroll_loop\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n getSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_DIR_LIGHTS > 0\n #pragma unroll_loop\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_HEMI_LIGHTS > 0\n #pragma unroll_loop\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n #ifdef DOUBLE_SIDED\n vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n #endif\n }\n#endif";
  9667. var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n return irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n directLight.color = directionalLight.color;\n directLight.direction = directionalLight.direction;\n directLight.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n vec3 lVector = pointLight.position - geometry.position;\n directLight.direction = normalize( lVector );\n float lightDistance = length( lVector );\n directLight.color = pointLight.color;\n directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n directLight.visible = ( directLight.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n vec3 lVector = spotLight.position - geometry.position;\n directLight.direction = normalize( lVector );\n float lightDistance = length( lVector );\n float angleCos = dot( directLight.direction, spotLight.direction );\n if ( angleCos > spotLight.coneCos ) {\n float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n directLight.color = spotLight.color;\n directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n directLight.visible = true;\n } else {\n directLight.color = vec3( 0.0 );\n directLight.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n float dotNL = dot( geometry.normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n return irradiance;\n }\n#endif";
  9668. var envmap_physical_pars_fragment = "#if defined( USE_ENVMAP )\n #ifdef ENVMAP_MODE_REFRACTION\n uniform float refractionRatio;\n #endif\n vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n #ifdef ENVMAP_TYPE_CUBE\n vec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n #else\n vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n #endif\n envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n #else\n vec4 envMapColor = vec4( 0.0 );\n #endif\n return PI * envMapColor.rgb * envMapIntensity;\n }\n float getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n float maxMIPLevelScalar = float( maxMIPLevel );\n float sigma = PI * roughness * roughness / ( 1.0 + roughness );\n float desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n }\n vec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( -viewDir, normal );\n reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n #else\n vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n #endif\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n float specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n #ifdef ENVMAP_TYPE_CUBE\n vec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n #else\n vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n #endif\n envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n #elif defined( ENVMAP_TYPE_EQUIREC )\n vec2 sampleUV;\n sampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n sampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n #else\n vec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n #endif\n envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #elif defined( ENVMAP_TYPE_SPHERE )\n vec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n #else\n vec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n #endif\n envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #endif\n return envMapColor.rgb * envMapIntensity;\n }\n#endif";
  9669. var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
  9670. var lights_toon_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material ) (0)";
  9671. var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
  9672. var lights_phong_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material ) (0)";
  9673. var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n material.clearcoat = saturate( clearcoat ); material.clearcoatRoughness = max( clearcoatRoughness, 0.0525 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheen;\n#endif";
  9674. var lights_physical_pars_fragment = "struct PhysicalMaterial {\n vec3 diffuseColor;\n float specularRoughness;\n vec3 specularColor;\n#ifdef CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n vec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n return DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 normal = geometry.normal;\n vec3 viewDir = geometry.viewDir;\n vec3 position = geometry.position;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.specularRoughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n }\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n #ifdef CLEARCOAT\n float ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = ccDotNL * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n ccIrradiance *= PI;\n #endif\n float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n reflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n #else\n float clearcoatDHR = 0.0;\n #endif\n #ifdef USE_SHEEN\n reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n material.specularRoughness,\n directLight.direction,\n geometry,\n material.sheenColor\n );\n #else\n reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n #endif\n reflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid 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) {\n #ifdef CLEARCOAT\n float ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n reflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n float ccDotNL = ccDotNV;\n float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n #else\n float clearcoatDHR = 0.0;\n #endif\n float clearcoatInv = 1.0 - clearcoatDHR;\n vec3 singleScattering = vec3( 0.0 );\n vec3 multiScattering = vec3( 0.0 );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n BRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n reflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
  9675. var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n geometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #pragma unroll_loop\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointDirectLightIrradiance( pointLight, geometry, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n directLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n #pragma unroll_loop\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotDirectLightIrradiance( spotLight, geometry, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n directLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #pragma unroll_loop\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n }\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n irradiance += getLightProbeIrradiance( lightProbe, geometry );\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n }\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
  9676. var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel= texture2D( lightMap, vUv2 );\n vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n lightMapIrradiance *= PI;\n #endif\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n iblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n radiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n #ifdef CLEARCOAT\n clearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n #endif\n#endif";
  9677. var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif";
  9678. var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif";
  9679. var logdepthbuf_pars_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif";
  9680. var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n #ifdef USE_LOGDEPTHBUF_EXT\n varying float vFragDepth;\n varying float vIsPerspective;\n #else\n uniform float logDepthBufFC;\n #endif\n#endif";
  9681. var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n #ifdef USE_LOGDEPTHBUF_EXT\n vFragDepth = 1.0 + gl_Position.w;\n vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n #else\n if ( isPerspectiveMatrix( projectionMatrix ) ) {\n gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n gl_Position.z *= gl_Position.w;\n }\n #endif\n#endif";
  9682. var map_fragment = "#ifdef USE_MAP\n vec4 texelColor = texture2D( map, vUv );\n texelColor = mapTexelToLinear( texelColor );\n diffuseColor *= texelColor;\n#endif";
  9683. var map_pars_fragment = "#ifdef USE_MAP\n uniform sampler2D map;\n#endif";
  9684. var map_particle_fragment = "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n vec4 mapTexel = texture2D( map, uv );\n diffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif";
  9685. var map_particle_pars_fragment = "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n uniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n uniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif";
  9686. var metalnessmap_fragment = "float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, vUv );\n metalnessFactor *= texelMetalness.b;\n#endif";
  9687. var metalnessmap_pars_fragment = "#ifdef USE_METALNESSMAP\n uniform sampler2D metalnessMap;\n#endif";
  9688. var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n objectNormal *= morphTargetBaseInfluence;\n objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif";
  9689. var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n uniform float morphTargetBaseInfluence;\n #ifndef USE_MORPHNORMALS\n uniform float morphTargetInfluences[ 8 ];\n #else\n uniform float morphTargetInfluences[ 4 ];\n #endif\n#endif";
  9690. var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n transformed *= morphTargetBaseInfluence;\n transformed += morphTarget0 * morphTargetInfluences[ 0 ];\n transformed += morphTarget1 * morphTargetInfluences[ 1 ];\n transformed += morphTarget2 * morphTargetInfluences[ 2 ];\n transformed += morphTarget3 * morphTargetInfluences[ 3 ];\n #ifndef USE_MORPHNORMALS\n transformed += morphTarget4 * morphTargetInfluences[ 4 ];\n transformed += morphTarget5 * morphTargetInfluences[ 5 ];\n transformed += morphTarget6 * morphTargetInfluences[ 6 ];\n transformed += morphTarget7 * morphTargetInfluences[ 7 ];\n #endif\n#endif";
  9691. var normal_fragment_begin = "#ifdef FLAT_SHADED\n vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n #endif\n #ifdef USE_TANGENT\n vec3 tangent = normalize( vTangent );\n vec3 bitangent = normalize( vBitangent );\n #ifdef DOUBLE_SIDED\n tangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n bitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n #endif\n #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n mat3 vTBN = mat3( tangent, bitangent, normal );\n #endif\n #endif\n#endif\nvec3 geometryNormal = normal;";
  9692. var normal_fragment_maps = "#ifdef OBJECTSPACE_NORMALMAP\n normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n #ifdef USE_TANGENT\n normal = normalize( vTBN * mapN );\n #else\n normal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n #endif\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif";
  9693. var normalmap_pars_fragment = "#ifdef USE_NORMALMAP\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n uniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n vec2 st0 = dFdx( vUv.st );\n vec2 st1 = dFdy( vUv.st );\n float scale = sign( st1.t * st0.s - st0.t * st1.s );\n vec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n vec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n vec3 N = normalize( surf_norm );\n mat3 tsn = mat3( S, T, N );\n mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n return normalize( tsn * mapN );\n }\n#endif";
  9694. var clearcoat_normal_fragment_begin = "#ifdef CLEARCOAT\n vec3 clearcoatNormal = geometryNormal;\n#endif";
  9695. var clearcoat_normal_fragment_maps = "#ifdef USE_CLEARCOAT_NORMALMAP\n vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n clearcoatMapN.xy *= clearcoatNormalScale;\n #ifdef USE_TANGENT\n clearcoatNormal = normalize( vTBN * clearcoatMapN );\n #else\n clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n #endif\n#endif";
  9696. var clearcoat_normalmap_pars_fragment = "#ifdef USE_CLEARCOAT_NORMALMAP\n uniform sampler2D clearcoatNormalMap;\n uniform vec2 clearcoatNormalScale;\n#endif";
  9697. var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n vec4 r = vec4( fract( v * PackFactors ), v );\n r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n return dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n return linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * invClipZ - far );\n}";
  9698. var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif";
  9699. var project_vertex = "vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;";
  9700. var dithering_fragment = "#ifdef DITHERING\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif";
  9701. var dithering_pars_fragment = "#ifdef DITHERING\n vec3 dithering( vec3 color ) {\n float grid_position = rand( gl_FragCoord.xy );\n vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n return color + dither_shift_RGB;\n }\n#endif";
  9702. var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, vUv );\n roughnessFactor *= texelRoughness.g;\n#endif";
  9703. var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif";
  9704. var shadowmap_pars_fragment = "#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n }\n vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n return unpackRGBATo2Half( texture2D( shadow, uv ) );\n }\n float VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n float occlusion = 1.0;\n vec2 distribution = texture2DDistribution( shadow, uv );\n float hard_shadow = step( compare , distribution.x );\n if (hard_shadow != 1.0 ) {\n float distance = compare - distribution.x ;\n float variance = max( 0.00000, distribution.y * distribution.y );\n 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 );\n }\n return occlusion;\n }\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n bool inFrustum = all( inFrustumVec );\n bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n bool frustumTest = all( frustumTestVec );\n if ( frustumTest ) {\n #if defined( SHADOWMAP_TYPE_PCF )\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx0 = - texelSize.x * shadowRadius;\n float dy0 = - texelSize.y * shadowRadius;\n float dx1 = + texelSize.x * shadowRadius;\n float dy1 = + texelSize.y * shadowRadius;\n float dx2 = dx0 / 2.0;\n float dy2 = dy0 / 2.0;\n float dx3 = dx1 / 2.0;\n float dy3 = dy1 / 2.0;\n shadow = (\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n ) * ( 1.0 / 17.0 );\n #elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx = texelSize.x;\n float dy = texelSize.y;\n vec2 uv = shadowCoord.xy;\n vec2 f = fract( uv * shadowMapSize + 0.5 );\n uv -= f * texelSize;\n shadow = (\n texture2DCompare( shadowMap, uv, shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n f.x ) +\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n f.x ) +\n mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n f.y ) +\n mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n f.y ) +\n mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n f.x ),\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n texture2DCompare( shadowMap, uv + + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n f.x ),\n f.y )\n ) * ( 1.0 / 9.0 );\n #elif defined( SHADOWMAP_TYPE_VSM )\n shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n #else\n shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n #endif\n }\n return shadow;\n }\n vec2 cubeToUV( vec3 v, float texelSizeY ) {\n vec3 absV = abs( v );\n float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n absV *= scaleToCube;\n v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n vec2 planar = v.xy;\n float almostATexel = 1.5 * texelSizeY;\n float almostOne = 1.0 - almostATexel;\n if ( absV.z >= almostOne ) {\n if ( v.z > 0.0 )\n planar.x = 4.0 - v.x;\n } else if ( absV.x >= almostOne ) {\n float signX = sign( v.x );\n planar.x = v.z * signX + 2.0 * signX;\n } else if ( absV.y >= almostOne ) {\n float signY = sign( v.y );\n planar.x = v.x + 2.0 * signY + 2.0;\n planar.y = v.z * signY - 2.0;\n }\n return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n }\n float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n vec3 lightToPosition = shadowCoord.xyz;\n float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;\n vec3 bd3D = normalize( lightToPosition );\n #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n return (\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n ) * ( 1.0 / 9.0 );\n #else\n return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n #endif\n }\n#endif";
  9705. var shadowmap_pars_vertex = "#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n#endif";
  9706. var shadowmap_vertex = "#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n }\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n #pragma unroll_loop\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n }\n #endif\n#endif";
  9707. var shadowmask_pars_fragment = "float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLight directionalLight;\n #pragma unroll_loop\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLights[ i ];\n shadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLight spotLight;\n #pragma unroll_loop\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLights[ i ];\n shadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n PointLight pointLight;\n #pragma unroll_loop\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLights[ i ];\n shadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #endif\n #endif\n return shadow;\n}";
  9708. var skinbase_vertex = "#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";
  9709. var skinning_pars_vertex = "#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n #ifdef BONE_TEXTURE\n uniform highp sampler2D boneTexture;\n uniform int boneTextureSize;\n mat4 getBoneMatrix( const in float i ) {\n float j = i * 4.0;\n float x = mod( j, float( boneTextureSize ) );\n float y = floor( j / float( boneTextureSize ) );\n float dx = 1.0 / float( boneTextureSize );\n float dy = 1.0 / float( boneTextureSize );\n y = dy * ( y + 0.5 );\n vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n mat4 bone = mat4( v1, v2, v3, v4 );\n return bone;\n }\n #else\n uniform mat4 boneMatrices[ MAX_BONES ];\n mat4 getBoneMatrix( const in float i ) {\n mat4 bone = boneMatrices[ int(i) ];\n return bone;\n }\n #endif\n#endif";
  9710. var skinning_vertex = "#ifdef USE_SKINNING\n vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n vec4 skinned = vec4( 0.0 );\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n transformed = ( bindMatrixInverse * skinned ).xyz;\n#endif";
  9711. var skinnormal_vertex = "#ifdef USE_SKINNING\n mat4 skinMatrix = mat4( 0.0 );\n skinMatrix += skinWeight.x * boneMatX;\n skinMatrix += skinWeight.y * boneMatY;\n skinMatrix += skinWeight.z * boneMatZ;\n skinMatrix += skinWeight.w * boneMatW;\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n #ifdef USE_TANGENT\n objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #endif\n#endif";
  9712. var specularmap_fragment = "float specularStrength;\n#ifdef USE_SPECULARMAP\n vec4 texelSpecular = texture2D( specularMap, vUv );\n specularStrength = texelSpecular.r;\n#else\n specularStrength = 1.0;\n#endif";
  9713. var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n uniform sampler2D specularMap;\n#endif";
  9714. var tonemapping_fragment = "#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif";
  9715. var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n return toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}";
  9716. var uv_pars_fragment = "#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n varying vec2 vUv;\n#endif";
  9717. var uv_pars_vertex = "#ifdef USE_UV\n #ifdef UVS_VERTEX_ONLY\n vec2 vUv;\n #else\n varying vec2 vUv;\n #endif\n uniform mat3 uvTransform;\n#endif";
  9718. var uv_vertex = "#ifdef USE_UV\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif";
  9719. var uv2_pars_fragment = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n varying vec2 vUv2;\n#endif";
  9720. var uv2_pars_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n attribute vec2 uv2;\n varying vec2 vUv2;\n uniform mat3 uv2Transform;\n#endif";
  9721. var uv2_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif";
  9722. var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n vec4 worldPosition = vec4( transformed, 1.0 );\n #ifdef USE_INSTANCING\n worldPosition = instanceMatrix * worldPosition;\n #endif\n worldPosition = modelMatrix * worldPosition;\n#endif";
  9723. var background_frag = "uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n vec4 texColor = texture2D( t2D, vUv );\n gl_FragColor = mapTexelToLinear( texColor );\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n}";
  9724. var background_vert = "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n gl_Position = vec4( position.xy, 1.0, 1.0 );\n}";
  9725. var cube_frag = "#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n vec3 vReflect = vWorldDirection;\n #include <envmap_fragment>\n gl_FragColor = envColor;\n gl_FragColor.a *= opacity;\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n}";
  9726. var cube_vert = "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n gl_Position.z = gl_Position.w;\n}";
  9727. var depth_frag = "#if DEPTH_PACKING == 3200\n uniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n vec4 diffuseColor = vec4( 1.0 );\n #if DEPTH_PACKING == 3200\n diffuseColor.a = opacity;\n #endif\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <logdepthbuf_fragment>\n #if DEPTH_PACKING == 3200\n gl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n #elif DEPTH_PACKING == 3201\n gl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n #endif\n}";
  9728. var depth_vert = "#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <skinbase_vertex>\n #ifdef USE_DISPLACEMENTMAP\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n}";
  9729. var distanceRGBA_frag = "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n #include <clipping_planes_fragment>\n vec4 diffuseColor = vec4( 1.0 );\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n float dist = length( vWorldPosition - referencePosition );\n dist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n dist = saturate( dist );\n gl_FragColor = packDepthToRGBA( dist );\n}";
  9730. var distanceRGBA_vert = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <skinbase_vertex>\n #ifdef USE_DISPLACEMENTMAP\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <worldpos_vertex>\n #include <clipping_planes_vertex>\n vWorldPosition = worldPosition.xyz;\n}";
  9731. var equirect_frag = "uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vec3 direction = normalize( vWorldDirection );\n vec2 sampleUV;\n sampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n sampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n vec4 texColor = texture2D( tEquirect, sampleUV );\n gl_FragColor = mapTexelToLinear( texColor );\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n}";
  9732. var equirect_vert = "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n}";
  9733. var linedashed_frag = "uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n if ( mod( vLineDistance, totalSize ) > dashSize ) {\n discard;\n }\n vec3 outgoingLight = vec3( 0.0 );\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <logdepthbuf_fragment>\n #include <color_fragment>\n outgoingLight = diffuseColor.rgb;\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n}";
  9734. var linedashed_vert = "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <color_vertex>\n vLineDistance = scale * lineDistance;\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n gl_Position = projectionMatrix * mvPosition;\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n}";
  9735. var meshbasic_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <specularmap_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n #ifdef USE_LIGHTMAP\n \n vec4 lightMapTexel= texture2D( lightMap, vUv2 );\n reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n #else\n reflectedLight.indirectDiffuse += vec3( 1.0 );\n #endif\n #include <aomap_fragment>\n reflectedLight.indirectDiffuse *= diffuseColor.rgb;\n vec3 outgoingLight = reflectedLight.indirectDiffuse;\n #include <envmap_fragment>\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n}";
  9736. var meshbasic_vert = "#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <uv2_vertex>\n #include <color_vertex>\n #include <skinbase_vertex>\n #ifdef USE_ENVMAP\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <worldpos_vertex>\n #include <clipping_planes_vertex>\n #include <envmap_vertex>\n #include <fog_vertex>\n}";
  9737. var meshlambert_frag = "uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n varying vec3 vLightBack;\n varying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <specularmap_fragment>\n #include <emissivemap_fragment>\n reflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n #ifdef DOUBLE_SIDED\n reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n #else\n reflectedLight.indirectDiffuse += vIndirectFront;\n #endif\n #include <lightmap_fragment>\n reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n #ifdef DOUBLE_SIDED\n reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n #else\n reflectedLight.directDiffuse = vLightFront;\n #endif\n reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include <envmap_fragment>\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}";
  9738. var meshlambert_vert = "#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n varying vec3 vLightBack;\n varying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <uv2_vertex>\n #include <color_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <lights_lambert_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}";
  9739. var meshmatcap_frag = "#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n vec3 viewDir = normalize( vViewPosition );\n vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n vec3 y = cross( viewDir, x );\n vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n #ifdef USE_MATCAP\n vec4 matcapColor = texture2D( matcap, uv );\n matcapColor = matcapTexelToLinear( matcapColor );\n #else\n vec4 matcapColor = vec4( 1.0 );\n #endif\n vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n}";
  9740. var meshmatcap_vert = "#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n vViewPosition = - mvPosition.xyz;\n}";
  9741. var meshtoon_frag = "#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <specularmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_toon_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}";
  9742. var meshtoon_vert = "#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <uv2_vertex>\n #include <color_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n#endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}";
  9743. var meshphong_frag = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <specularmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_phong_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #include <envmap_fragment>\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}";
  9744. var meshphong_vert = "#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <uv2_vertex>\n #include <color_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n#endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}";
  9745. var meshphysical_frag = "#define STANDARD\n#ifdef PHYSICAL\n #define REFLECTIVITY\n #define CLEARCOAT\n #define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n uniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n uniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n uniform float clearcoat;\n uniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n uniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <roughnessmap_fragment>\n #include <metalnessmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <clearcoat_normal_fragment_begin>\n #include <clearcoat_normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_physical_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #ifdef TRANSPARENCY\n diffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n #endif\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}";
  9746. var meshphysical_vert = "#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <uv2_vertex>\n #include <color_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #ifdef USE_TANGENT\n vTangent = normalize( transformedTangent );\n vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n #endif\n#endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}";
  9747. var normal_frag = "#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n varying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n #include <logdepthbuf_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n gl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}";
  9748. var normal_vert = "#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n varying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #ifdef USE_TANGENT\n vTangent = normalize( transformedTangent );\n vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n #endif\n#endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n vViewPosition = - mvPosition.xyz;\n#endif\n}";
  9749. var points_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n vec3 outgoingLight = vec3( 0.0 );\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <logdepthbuf_fragment>\n #include <map_particle_fragment>\n #include <color_fragment>\n #include <alphatest_fragment>\n outgoingLight = diffuseColor.rgb;\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n}";
  9750. var points_vert = "uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <color_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <project_vertex>\n gl_PointSize = size;\n #ifdef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n #endif\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <worldpos_vertex>\n #include <fog_vertex>\n}";
  9751. var shadow_frag = "uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n}";
  9752. var shadow_vert = "#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n #include <begin_vertex>\n #include <project_vertex>\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}";
  9753. var sprite_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n vec3 outgoingLight = vec3( 0.0 );\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n outgoingLight = diffuseColor.rgb;\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n}";
  9754. var sprite_vert = "uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n vec2 scale;\n scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n #ifndef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) scale *= - mvPosition.z;\n #endif\n vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n mvPosition.xy += rotatedPosition;\n gl_Position = projectionMatrix * mvPosition;\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n}";
  9755. var ShaderChunk = {
  9756. alphamap_fragment,
  9757. alphamap_pars_fragment,
  9758. alphatest_fragment,
  9759. aomap_fragment,
  9760. aomap_pars_fragment,
  9761. begin_vertex,
  9762. beginnormal_vertex,
  9763. bsdfs,
  9764. bumpmap_pars_fragment,
  9765. clipping_planes_fragment,
  9766. clipping_planes_pars_fragment,
  9767. clipping_planes_pars_vertex,
  9768. clipping_planes_vertex,
  9769. color_fragment,
  9770. color_pars_fragment,
  9771. color_pars_vertex,
  9772. color_vertex,
  9773. common,
  9774. cube_uv_reflection_fragment,
  9775. defaultnormal_vertex,
  9776. displacementmap_pars_vertex,
  9777. displacementmap_vertex,
  9778. emissivemap_fragment,
  9779. emissivemap_pars_fragment,
  9780. encodings_fragment,
  9781. encodings_pars_fragment,
  9782. envmap_fragment,
  9783. envmap_common_pars_fragment,
  9784. envmap_pars_fragment,
  9785. envmap_pars_vertex,
  9786. envmap_physical_pars_fragment,
  9787. envmap_vertex,
  9788. fog_vertex,
  9789. fog_pars_vertex,
  9790. fog_fragment,
  9791. fog_pars_fragment,
  9792. gradientmap_pars_fragment,
  9793. lightmap_fragment,
  9794. lightmap_pars_fragment,
  9795. lights_lambert_vertex,
  9796. lights_pars_begin,
  9797. lights_toon_fragment,
  9798. lights_toon_pars_fragment,
  9799. lights_phong_fragment,
  9800. lights_phong_pars_fragment,
  9801. lights_physical_fragment,
  9802. lights_physical_pars_fragment,
  9803. lights_fragment_begin,
  9804. lights_fragment_maps,
  9805. lights_fragment_end,
  9806. logdepthbuf_fragment,
  9807. logdepthbuf_pars_fragment,
  9808. logdepthbuf_pars_vertex,
  9809. logdepthbuf_vertex,
  9810. map_fragment,
  9811. map_pars_fragment,
  9812. map_particle_fragment,
  9813. map_particle_pars_fragment,
  9814. metalnessmap_fragment,
  9815. metalnessmap_pars_fragment,
  9816. morphnormal_vertex,
  9817. morphtarget_pars_vertex,
  9818. morphtarget_vertex,
  9819. normal_fragment_begin,
  9820. normal_fragment_maps,
  9821. normalmap_pars_fragment,
  9822. clearcoat_normal_fragment_begin,
  9823. clearcoat_normal_fragment_maps,
  9824. clearcoat_normalmap_pars_fragment,
  9825. packing,
  9826. premultiplied_alpha_fragment,
  9827. project_vertex,
  9828. dithering_fragment,
  9829. dithering_pars_fragment,
  9830. roughnessmap_fragment,
  9831. roughnessmap_pars_fragment,
  9832. shadowmap_pars_fragment,
  9833. shadowmap_pars_vertex,
  9834. shadowmap_vertex,
  9835. shadowmask_pars_fragment,
  9836. skinbase_vertex,
  9837. skinning_pars_vertex,
  9838. skinning_vertex,
  9839. skinnormal_vertex,
  9840. specularmap_fragment,
  9841. specularmap_pars_fragment,
  9842. tonemapping_fragment,
  9843. tonemapping_pars_fragment,
  9844. uv_pars_fragment,
  9845. uv_pars_vertex,
  9846. uv_vertex,
  9847. uv2_pars_fragment,
  9848. uv2_pars_vertex,
  9849. uv2_vertex,
  9850. worldpos_vertex,
  9851. background_frag,
  9852. background_vert,
  9853. cube_frag,
  9854. cube_vert,
  9855. depth_frag,
  9856. depth_vert,
  9857. distanceRGBA_frag,
  9858. distanceRGBA_vert,
  9859. equirect_frag,
  9860. equirect_vert,
  9861. linedashed_frag,
  9862. linedashed_vert,
  9863. meshbasic_frag,
  9864. meshbasic_vert,
  9865. meshlambert_frag,
  9866. meshlambert_vert,
  9867. meshmatcap_frag,
  9868. meshmatcap_vert,
  9869. meshtoon_frag,
  9870. meshtoon_vert,
  9871. meshphong_frag,
  9872. meshphong_vert,
  9873. meshphysical_frag,
  9874. meshphysical_vert,
  9875. normal_frag,
  9876. normal_vert,
  9877. points_frag,
  9878. points_vert,
  9879. shadow_frag,
  9880. shadow_vert,
  9881. sprite_frag,
  9882. sprite_vert
  9883. };
  9884. var ShaderLib = {
  9885. basic: {
  9886. uniforms: mergeUniforms([
  9887. UniformsLib.common,
  9888. UniformsLib.specularmap,
  9889. UniformsLib.envmap,
  9890. UniformsLib.aomap,
  9891. UniformsLib.lightmap,
  9892. UniformsLib.fog
  9893. ]),
  9894. vertexShader: ShaderChunk.meshbasic_vert,
  9895. fragmentShader: ShaderChunk.meshbasic_frag
  9896. },
  9897. lambert: {
  9898. uniforms: mergeUniforms([
  9899. UniformsLib.common,
  9900. UniformsLib.specularmap,
  9901. UniformsLib.envmap,
  9902. UniformsLib.aomap,
  9903. UniformsLib.lightmap,
  9904. UniformsLib.emissivemap,
  9905. UniformsLib.fog,
  9906. UniformsLib.lights,
  9907. {
  9908. emissive: { value: new Color(0) }
  9909. }
  9910. ]),
  9911. vertexShader: ShaderChunk.meshlambert_vert,
  9912. fragmentShader: ShaderChunk.meshlambert_frag
  9913. },
  9914. phong: {
  9915. uniforms: mergeUniforms([
  9916. UniformsLib.common,
  9917. UniformsLib.specularmap,
  9918. UniformsLib.envmap,
  9919. UniformsLib.aomap,
  9920. UniformsLib.lightmap,
  9921. UniformsLib.emissivemap,
  9922. UniformsLib.bumpmap,
  9923. UniformsLib.normalmap,
  9924. UniformsLib.displacementmap,
  9925. UniformsLib.fog,
  9926. UniformsLib.lights,
  9927. {
  9928. emissive: { value: new Color(0) },
  9929. specular: { value: new Color(1118481) },
  9930. shininess: { value: 30 }
  9931. }
  9932. ]),
  9933. vertexShader: ShaderChunk.meshphong_vert,
  9934. fragmentShader: ShaderChunk.meshphong_frag
  9935. },
  9936. standard: {
  9937. uniforms: mergeUniforms([
  9938. UniformsLib.common,
  9939. UniformsLib.envmap,
  9940. UniformsLib.aomap,
  9941. UniformsLib.lightmap,
  9942. UniformsLib.emissivemap,
  9943. UniformsLib.bumpmap,
  9944. UniformsLib.normalmap,
  9945. UniformsLib.displacementmap,
  9946. UniformsLib.roughnessmap,
  9947. UniformsLib.metalnessmap,
  9948. UniformsLib.fog,
  9949. UniformsLib.lights,
  9950. {
  9951. emissive: { value: new Color(0) },
  9952. roughness: { value: 0.5 },
  9953. metalness: { value: 0.5 },
  9954. envMapIntensity: { value: 1 }
  9955. // temporary
  9956. }
  9957. ]),
  9958. vertexShader: ShaderChunk.meshphysical_vert,
  9959. fragmentShader: ShaderChunk.meshphysical_frag
  9960. },
  9961. toon: {
  9962. uniforms: mergeUniforms([
  9963. UniformsLib.common,
  9964. UniformsLib.specularmap,
  9965. UniformsLib.aomap,
  9966. UniformsLib.lightmap,
  9967. UniformsLib.emissivemap,
  9968. UniformsLib.bumpmap,
  9969. UniformsLib.normalmap,
  9970. UniformsLib.displacementmap,
  9971. UniformsLib.gradientmap,
  9972. UniformsLib.fog,
  9973. UniformsLib.lights,
  9974. {
  9975. emissive: { value: new Color(0) },
  9976. specular: { value: new Color(1118481) },
  9977. shininess: { value: 30 }
  9978. }
  9979. ]),
  9980. vertexShader: ShaderChunk.meshtoon_vert,
  9981. fragmentShader: ShaderChunk.meshtoon_frag
  9982. },
  9983. matcap: {
  9984. uniforms: mergeUniforms([
  9985. UniformsLib.common,
  9986. UniformsLib.bumpmap,
  9987. UniformsLib.normalmap,
  9988. UniformsLib.displacementmap,
  9989. UniformsLib.fog,
  9990. {
  9991. matcap: { value: null }
  9992. }
  9993. ]),
  9994. vertexShader: ShaderChunk.meshmatcap_vert,
  9995. fragmentShader: ShaderChunk.meshmatcap_frag
  9996. },
  9997. points: {
  9998. uniforms: mergeUniforms([
  9999. UniformsLib.points,
  10000. UniformsLib.fog
  10001. ]),
  10002. vertexShader: ShaderChunk.points_vert,
  10003. fragmentShader: ShaderChunk.points_frag
  10004. },
  10005. dashed: {
  10006. uniforms: mergeUniforms([
  10007. UniformsLib.common,
  10008. UniformsLib.fog,
  10009. {
  10010. scale: { value: 1 },
  10011. dashSize: { value: 1 },
  10012. totalSize: { value: 2 }
  10013. }
  10014. ]),
  10015. vertexShader: ShaderChunk.linedashed_vert,
  10016. fragmentShader: ShaderChunk.linedashed_frag
  10017. },
  10018. depth: {
  10019. uniforms: mergeUniforms([
  10020. UniformsLib.common,
  10021. UniformsLib.displacementmap
  10022. ]),
  10023. vertexShader: ShaderChunk.depth_vert,
  10024. fragmentShader: ShaderChunk.depth_frag
  10025. },
  10026. normal: {
  10027. uniforms: mergeUniforms([
  10028. UniformsLib.common,
  10029. UniformsLib.bumpmap,
  10030. UniformsLib.normalmap,
  10031. UniformsLib.displacementmap,
  10032. {
  10033. opacity: { value: 1 }
  10034. }
  10035. ]),
  10036. vertexShader: ShaderChunk.normal_vert,
  10037. fragmentShader: ShaderChunk.normal_frag
  10038. },
  10039. sprite: {
  10040. uniforms: mergeUniforms([
  10041. UniformsLib.sprite,
  10042. UniformsLib.fog
  10043. ]),
  10044. vertexShader: ShaderChunk.sprite_vert,
  10045. fragmentShader: ShaderChunk.sprite_frag
  10046. },
  10047. background: {
  10048. uniforms: {
  10049. uvTransform: { value: new Matrix3() },
  10050. t2D: { value: null }
  10051. },
  10052. vertexShader: ShaderChunk.background_vert,
  10053. fragmentShader: ShaderChunk.background_frag
  10054. },
  10055. /* -------------------------------------------------------------------------
  10056. // Cube map shader
  10057. ------------------------------------------------------------------------- */
  10058. cube: {
  10059. uniforms: mergeUniforms([
  10060. UniformsLib.envmap,
  10061. {
  10062. opacity: { value: 1 }
  10063. }
  10064. ]),
  10065. vertexShader: ShaderChunk.cube_vert,
  10066. fragmentShader: ShaderChunk.cube_frag
  10067. },
  10068. equirect: {
  10069. uniforms: {
  10070. tEquirect: { value: null }
  10071. },
  10072. vertexShader: ShaderChunk.equirect_vert,
  10073. fragmentShader: ShaderChunk.equirect_frag
  10074. },
  10075. distanceRGBA: {
  10076. uniforms: mergeUniforms([
  10077. UniformsLib.common,
  10078. UniformsLib.displacementmap,
  10079. {
  10080. referencePosition: { value: new Vector3() },
  10081. nearDistance: { value: 1 },
  10082. farDistance: { value: 1e3 }
  10083. }
  10084. ]),
  10085. vertexShader: ShaderChunk.distanceRGBA_vert,
  10086. fragmentShader: ShaderChunk.distanceRGBA_frag
  10087. },
  10088. shadow: {
  10089. uniforms: mergeUniforms([
  10090. UniformsLib.lights,
  10091. UniformsLib.fog,
  10092. {
  10093. color: { value: new Color(0) },
  10094. opacity: { value: 1 }
  10095. }
  10096. ]),
  10097. vertexShader: ShaderChunk.shadow_vert,
  10098. fragmentShader: ShaderChunk.shadow_frag
  10099. }
  10100. };
  10101. ShaderLib.physical = {
  10102. uniforms: mergeUniforms([
  10103. ShaderLib.standard.uniforms,
  10104. {
  10105. transparency: { value: 0 },
  10106. clearcoat: { value: 0 },
  10107. clearcoatRoughness: { value: 0 },
  10108. sheen: { value: new Color(0) },
  10109. clearcoatNormalScale: { value: new Vector2(1, 1) },
  10110. clearcoatNormalMap: { value: null }
  10111. }
  10112. ]),
  10113. vertexShader: ShaderChunk.meshphysical_vert,
  10114. fragmentShader: ShaderChunk.meshphysical_frag
  10115. };
  10116. function WebGLBackground(renderer, state, objects, premultipliedAlpha) {
  10117. var clearColor = new Color(0);
  10118. var clearAlpha = 0;
  10119. var planeMesh;
  10120. var boxMesh;
  10121. var currentBackground = null;
  10122. var currentBackgroundVersion = 0;
  10123. var currentTonemapping = null;
  10124. function render(renderList, scene, camera, forceClear) {
  10125. var background = scene.background;
  10126. var xr = renderer.xr;
  10127. var session = xr.getSession && xr.getSession();
  10128. if (session && session.environmentBlendMode === "additive") {
  10129. background = null;
  10130. }
  10131. if (background === null) {
  10132. setClear(clearColor, clearAlpha);
  10133. } else if (background && background.isColor) {
  10134. setClear(background, 1);
  10135. forceClear = true;
  10136. }
  10137. if (renderer.autoClear || forceClear) {
  10138. renderer.clear(renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil);
  10139. }
  10140. if (background && (background.isCubeTexture || background.isWebGLCubeRenderTarget || background.mapping === CubeUVReflectionMapping)) {
  10141. if (boxMesh === void 0) {
  10142. boxMesh = new Mesh(
  10143. new BoxBufferGeometry(1, 1, 1),
  10144. new ShaderMaterial({
  10145. type: "BackgroundCubeMaterial",
  10146. uniforms: cloneUniforms(ShaderLib.cube.uniforms),
  10147. vertexShader: ShaderLib.cube.vertexShader,
  10148. fragmentShader: ShaderLib.cube.fragmentShader,
  10149. side: BackSide,
  10150. depthTest: false,
  10151. depthWrite: false,
  10152. fog: false
  10153. })
  10154. );
  10155. boxMesh.geometry.deleteAttribute("normal");
  10156. boxMesh.geometry.deleteAttribute("uv");
  10157. boxMesh.onBeforeRender = function(renderer2, scene2, camera2) {
  10158. this.matrixWorld.copyPosition(camera2.matrixWorld);
  10159. };
  10160. Object.defineProperty(boxMesh.material, "envMap", {
  10161. get: function() {
  10162. return this.uniforms.envMap.value;
  10163. }
  10164. });
  10165. objects.update(boxMesh);
  10166. }
  10167. var texture = background.isWebGLCubeRenderTarget ? background.texture : background;
  10168. boxMesh.material.uniforms.envMap.value = texture;
  10169. boxMesh.material.uniforms.flipEnvMap.value = texture.isCubeTexture ? -1 : 1;
  10170. if (currentBackground !== background || currentBackgroundVersion !== texture.version || currentTonemapping !== renderer.toneMapping) {
  10171. boxMesh.material.needsUpdate = true;
  10172. currentBackground = background;
  10173. currentBackgroundVersion = texture.version;
  10174. currentTonemapping = renderer.toneMapping;
  10175. }
  10176. renderList.unshift(boxMesh, boxMesh.geometry, boxMesh.material, 0, 0, null);
  10177. } else if (background && background.isTexture) {
  10178. if (planeMesh === void 0) {
  10179. planeMesh = new Mesh(
  10180. new PlaneBufferGeometry(2, 2),
  10181. new ShaderMaterial({
  10182. type: "BackgroundMaterial",
  10183. uniforms: cloneUniforms(ShaderLib.background.uniforms),
  10184. vertexShader: ShaderLib.background.vertexShader,
  10185. fragmentShader: ShaderLib.background.fragmentShader,
  10186. side: FrontSide,
  10187. depthTest: false,
  10188. depthWrite: false,
  10189. fog: false
  10190. })
  10191. );
  10192. planeMesh.geometry.deleteAttribute("normal");
  10193. Object.defineProperty(planeMesh.material, "map", {
  10194. get: function() {
  10195. return this.uniforms.t2D.value;
  10196. }
  10197. });
  10198. objects.update(planeMesh);
  10199. }
  10200. planeMesh.material.uniforms.t2D.value = background;
  10201. if (background.matrixAutoUpdate === true) {
  10202. background.updateMatrix();
  10203. }
  10204. planeMesh.material.uniforms.uvTransform.value.copy(background.matrix);
  10205. if (currentBackground !== background || currentBackgroundVersion !== background.version || currentTonemapping !== renderer.toneMapping) {
  10206. planeMesh.material.needsUpdate = true;
  10207. currentBackground = background;
  10208. currentBackgroundVersion = background.version;
  10209. currentTonemapping = renderer.toneMapping;
  10210. }
  10211. renderList.unshift(planeMesh, planeMesh.geometry, planeMesh.material, 0, 0, null);
  10212. }
  10213. }
  10214. function setClear(color, alpha) {
  10215. state.buffers.color.setClear(color.r, color.g, color.b, alpha, premultipliedAlpha);
  10216. }
  10217. return {
  10218. getClearColor: function() {
  10219. return clearColor;
  10220. },
  10221. setClearColor: function(color, alpha) {
  10222. clearColor.set(color);
  10223. clearAlpha = alpha !== void 0 ? alpha : 1;
  10224. setClear(clearColor, clearAlpha);
  10225. },
  10226. getClearAlpha: function() {
  10227. return clearAlpha;
  10228. },
  10229. setClearAlpha: function(alpha) {
  10230. clearAlpha = alpha;
  10231. setClear(clearColor, clearAlpha);
  10232. },
  10233. render
  10234. };
  10235. }
  10236. function WebGLBufferRenderer(gl, extensions, info, capabilities) {
  10237. var isWebGL2 = capabilities.isWebGL2;
  10238. var mode;
  10239. function setMode(value) {
  10240. mode = value;
  10241. }
  10242. function render(start, count) {
  10243. gl.drawArrays(mode, start, count);
  10244. info.update(count, mode);
  10245. }
  10246. function renderInstances(geometry, start, count, primcount) {
  10247. if (primcount === 0)
  10248. return;
  10249. var extension, methodName;
  10250. if (isWebGL2) {
  10251. extension = gl;
  10252. methodName = "drawArraysInstanced";
  10253. } else {
  10254. extension = extensions.get("ANGLE_instanced_arrays");
  10255. methodName = "drawArraysInstancedANGLE";
  10256. if (extension === null) {
  10257. console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");
  10258. return;
  10259. }
  10260. }
  10261. extension[methodName](mode, start, count, primcount);
  10262. info.update(count, mode, primcount);
  10263. }
  10264. this.setMode = setMode;
  10265. this.render = render;
  10266. this.renderInstances = renderInstances;
  10267. }
  10268. function WebGLCapabilities(gl, extensions, parameters) {
  10269. var maxAnisotropy;
  10270. function getMaxAnisotropy() {
  10271. if (maxAnisotropy !== void 0)
  10272. return maxAnisotropy;
  10273. var extension = extensions.get("EXT_texture_filter_anisotropic");
  10274. if (extension !== null) {
  10275. maxAnisotropy = gl.getParameter(extension.MAX_TEXTURE_MAX_ANISOTROPY_EXT);
  10276. } else {
  10277. maxAnisotropy = 0;
  10278. }
  10279. return maxAnisotropy;
  10280. }
  10281. function getMaxPrecision(precision2) {
  10282. if (precision2 === "highp") {
  10283. if (gl.getShaderPrecisionFormat(35633, 36338).precision > 0 && gl.getShaderPrecisionFormat(35632, 36338).precision > 0) {
  10284. return "highp";
  10285. }
  10286. precision2 = "mediump";
  10287. }
  10288. if (precision2 === "mediump") {
  10289. if (gl.getShaderPrecisionFormat(35633, 36337).precision > 0 && gl.getShaderPrecisionFormat(35632, 36337).precision > 0) {
  10290. return "mediump";
  10291. }
  10292. }
  10293. return "lowp";
  10294. }
  10295. var isWebGL2 = typeof WebGL2RenderingContext !== "undefined" && gl instanceof WebGL2RenderingContext || typeof WebGL2ComputeRenderingContext !== "undefined" && gl instanceof WebGL2ComputeRenderingContext;
  10296. var precision = parameters.precision !== void 0 ? parameters.precision : "highp";
  10297. var maxPrecision = getMaxPrecision(precision);
  10298. if (maxPrecision !== precision) {
  10299. console.warn("THREE.WebGLRenderer:", precision, "not supported, using", maxPrecision, "instead.");
  10300. precision = maxPrecision;
  10301. }
  10302. var logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
  10303. var maxTextures = gl.getParameter(34930);
  10304. var maxVertexTextures = gl.getParameter(35660);
  10305. var maxTextureSize = gl.getParameter(3379);
  10306. var maxCubemapSize = gl.getParameter(34076);
  10307. var maxAttributes = gl.getParameter(34921);
  10308. var maxVertexUniforms = gl.getParameter(36347);
  10309. var maxVaryings = gl.getParameter(36348);
  10310. var maxFragmentUniforms = gl.getParameter(36349);
  10311. var vertexTextures = maxVertexTextures > 0;
  10312. var floatFragmentTextures = isWebGL2 || !!extensions.get("OES_texture_float");
  10313. var floatVertexTextures = vertexTextures && floatFragmentTextures;
  10314. var maxSamples = isWebGL2 ? gl.getParameter(36183) : 0;
  10315. return {
  10316. isWebGL2,
  10317. getMaxAnisotropy,
  10318. getMaxPrecision,
  10319. precision,
  10320. logarithmicDepthBuffer,
  10321. maxTextures,
  10322. maxVertexTextures,
  10323. maxTextureSize,
  10324. maxCubemapSize,
  10325. maxAttributes,
  10326. maxVertexUniforms,
  10327. maxVaryings,
  10328. maxFragmentUniforms,
  10329. vertexTextures,
  10330. floatFragmentTextures,
  10331. floatVertexTextures,
  10332. maxSamples
  10333. };
  10334. }
  10335. function WebGLClipping() {
  10336. var scope = this, globalState = null, numGlobalPlanes = 0, localClippingEnabled = false, renderingShadows = false, plane = new Plane(), viewNormalMatrix = new Matrix3(), uniform = { value: null, needsUpdate: false };
  10337. this.uniform = uniform;
  10338. this.numPlanes = 0;
  10339. this.numIntersection = 0;
  10340. this.init = function(planes, enableLocalClipping, camera) {
  10341. var enabled = planes.length !== 0 || enableLocalClipping || // enable state of previous frame - the clipping code has to
  10342. // run another frame in order to reset the state:
  10343. numGlobalPlanes !== 0 || localClippingEnabled;
  10344. localClippingEnabled = enableLocalClipping;
  10345. globalState = projectPlanes(planes, camera, 0);
  10346. numGlobalPlanes = planes.length;
  10347. return enabled;
  10348. };
  10349. this.beginShadows = function() {
  10350. renderingShadows = true;
  10351. projectPlanes(null);
  10352. };
  10353. this.endShadows = function() {
  10354. renderingShadows = false;
  10355. resetGlobalState();
  10356. };
  10357. this.setState = function(planes, clipIntersection, clipShadows, camera, cache, fromCache) {
  10358. if (!localClippingEnabled || planes === null || planes.length === 0 || renderingShadows && !clipShadows) {
  10359. if (renderingShadows) {
  10360. projectPlanes(null);
  10361. } else {
  10362. resetGlobalState();
  10363. }
  10364. } else {
  10365. var nGlobal = renderingShadows ? 0 : numGlobalPlanes, lGlobal = nGlobal * 4, dstArray = cache.clippingState || null;
  10366. uniform.value = dstArray;
  10367. dstArray = projectPlanes(planes, camera, lGlobal, fromCache);
  10368. for (var i2 = 0; i2 !== lGlobal; ++i2) {
  10369. dstArray[i2] = globalState[i2];
  10370. }
  10371. cache.clippingState = dstArray;
  10372. this.numIntersection = clipIntersection ? this.numPlanes : 0;
  10373. this.numPlanes += nGlobal;
  10374. }
  10375. };
  10376. function resetGlobalState() {
  10377. if (uniform.value !== globalState) {
  10378. uniform.value = globalState;
  10379. uniform.needsUpdate = numGlobalPlanes > 0;
  10380. }
  10381. scope.numPlanes = numGlobalPlanes;
  10382. scope.numIntersection = 0;
  10383. }
  10384. function projectPlanes(planes, camera, dstOffset, skipTransform) {
  10385. var nPlanes = planes !== null ? planes.length : 0, dstArray = null;
  10386. if (nPlanes !== 0) {
  10387. dstArray = uniform.value;
  10388. if (skipTransform !== true || dstArray === null) {
  10389. var flatSize = dstOffset + nPlanes * 4, viewMatrix = camera.matrixWorldInverse;
  10390. viewNormalMatrix.getNormalMatrix(viewMatrix);
  10391. if (dstArray === null || dstArray.length < flatSize) {
  10392. dstArray = new Float32Array(flatSize);
  10393. }
  10394. for (var i2 = 0, i4 = dstOffset; i2 !== nPlanes; ++i2, i4 += 4) {
  10395. plane.copy(planes[i2]).applyMatrix4(viewMatrix, viewNormalMatrix);
  10396. plane.normal.toArray(dstArray, i4);
  10397. dstArray[i4 + 3] = plane.constant;
  10398. }
  10399. }
  10400. uniform.value = dstArray;
  10401. uniform.needsUpdate = true;
  10402. }
  10403. scope.numPlanes = nPlanes;
  10404. return dstArray;
  10405. }
  10406. }
  10407. function WebGLExtensions(gl) {
  10408. var extensions = {};
  10409. return {
  10410. get: function(name) {
  10411. if (extensions[name] !== void 0) {
  10412. return extensions[name];
  10413. }
  10414. var extension;
  10415. switch (name) {
  10416. case "WEBGL_depth_texture":
  10417. extension = gl.getExtension("WEBGL_depth_texture") || gl.getExtension("MOZ_WEBGL_depth_texture") || gl.getExtension("WEBKIT_WEBGL_depth_texture");
  10418. break;
  10419. case "EXT_texture_filter_anisotropic":
  10420. extension = gl.getExtension("EXT_texture_filter_anisotropic") || gl.getExtension("MOZ_EXT_texture_filter_anisotropic") || gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic");
  10421. break;
  10422. case "WEBGL_compressed_texture_s3tc":
  10423. extension = gl.getExtension("WEBGL_compressed_texture_s3tc") || gl.getExtension("MOZ_WEBGL_compressed_texture_s3tc") || gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");
  10424. break;
  10425. case "WEBGL_compressed_texture_pvrtc":
  10426. extension = gl.getExtension("WEBGL_compressed_texture_pvrtc") || gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");
  10427. break;
  10428. default:
  10429. extension = gl.getExtension(name);
  10430. }
  10431. if (extension === null) {
  10432. console.warn("THREE.WebGLRenderer: " + name + " extension not supported.");
  10433. }
  10434. extensions[name] = extension;
  10435. return extension;
  10436. }
  10437. };
  10438. }
  10439. function WebGLGeometries(gl, attributes, info) {
  10440. var geometries = /* @__PURE__ */ new WeakMap();
  10441. var wireframeAttributes = /* @__PURE__ */ new WeakMap();
  10442. function onGeometryDispose(event) {
  10443. var geometry = event.target;
  10444. var buffergeometry = geometries.get(geometry);
  10445. if (buffergeometry.index !== null) {
  10446. attributes.remove(buffergeometry.index);
  10447. }
  10448. for (var name in buffergeometry.attributes) {
  10449. attributes.remove(buffergeometry.attributes[name]);
  10450. }
  10451. geometry.removeEventListener("dispose", onGeometryDispose);
  10452. geometries.delete(geometry);
  10453. var attribute = wireframeAttributes.get(buffergeometry);
  10454. if (attribute) {
  10455. attributes.remove(attribute);
  10456. wireframeAttributes.delete(buffergeometry);
  10457. }
  10458. info.memory.geometries--;
  10459. }
  10460. function get(object, geometry) {
  10461. var buffergeometry = geometries.get(geometry);
  10462. if (buffergeometry)
  10463. return buffergeometry;
  10464. geometry.addEventListener("dispose", onGeometryDispose);
  10465. if (geometry.isBufferGeometry) {
  10466. buffergeometry = geometry;
  10467. } else if (geometry.isGeometry) {
  10468. if (geometry._bufferGeometry === void 0) {
  10469. geometry._bufferGeometry = new BufferGeometry().setFromObject(object);
  10470. }
  10471. buffergeometry = geometry._bufferGeometry;
  10472. }
  10473. geometries.set(geometry, buffergeometry);
  10474. info.memory.geometries++;
  10475. return buffergeometry;
  10476. }
  10477. function update(geometry) {
  10478. var index = geometry.index;
  10479. var geometryAttributes = geometry.attributes;
  10480. if (index !== null) {
  10481. attributes.update(index, 34963);
  10482. }
  10483. for (var name in geometryAttributes) {
  10484. attributes.update(geometryAttributes[name], 34962);
  10485. }
  10486. var morphAttributes = geometry.morphAttributes;
  10487. for (var name in morphAttributes) {
  10488. var array = morphAttributes[name];
  10489. for (var i2 = 0, l = array.length; i2 < l; i2++) {
  10490. attributes.update(array[i2], 34962);
  10491. }
  10492. }
  10493. }
  10494. function updateWireframeAttribute(geometry) {
  10495. var indices = [];
  10496. var geometryIndex = geometry.index;
  10497. var geometryPosition = geometry.attributes.position;
  10498. var version = 0;
  10499. if (geometryIndex !== null) {
  10500. var array = geometryIndex.array;
  10501. version = geometryIndex.version;
  10502. for (var i2 = 0, l = array.length; i2 < l; i2 += 3) {
  10503. var a = array[i2 + 0];
  10504. var b = array[i2 + 1];
  10505. var c = array[i2 + 2];
  10506. indices.push(a, b, b, c, c, a);
  10507. }
  10508. } else {
  10509. var array = geometryPosition.array;
  10510. version = geometryPosition.version;
  10511. for (var i2 = 0, l = array.length / 3 - 1; i2 < l; i2 += 3) {
  10512. var a = i2 + 0;
  10513. var b = i2 + 1;
  10514. var c = i2 + 2;
  10515. indices.push(a, b, b, c, c, a);
  10516. }
  10517. }
  10518. var attribute = new (arrayMax(indices) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute)(indices, 1);
  10519. attribute.version = version;
  10520. attributes.update(attribute, 34963);
  10521. var previousAttribute = wireframeAttributes.get(geometry);
  10522. if (previousAttribute)
  10523. attributes.remove(previousAttribute);
  10524. wireframeAttributes.set(geometry, attribute);
  10525. }
  10526. function getWireframeAttribute(geometry) {
  10527. var currentAttribute = wireframeAttributes.get(geometry);
  10528. if (currentAttribute) {
  10529. var geometryIndex = geometry.index;
  10530. if (geometryIndex !== null) {
  10531. if (currentAttribute.version < geometryIndex.version) {
  10532. updateWireframeAttribute(geometry);
  10533. }
  10534. }
  10535. } else {
  10536. updateWireframeAttribute(geometry);
  10537. }
  10538. return wireframeAttributes.get(geometry);
  10539. }
  10540. return {
  10541. get,
  10542. update,
  10543. getWireframeAttribute
  10544. };
  10545. }
  10546. function WebGLIndexedBufferRenderer(gl, extensions, info, capabilities) {
  10547. var isWebGL2 = capabilities.isWebGL2;
  10548. var mode;
  10549. function setMode(value) {
  10550. mode = value;
  10551. }
  10552. var type, bytesPerElement;
  10553. function setIndex(value) {
  10554. type = value.type;
  10555. bytesPerElement = value.bytesPerElement;
  10556. }
  10557. function render(start, count) {
  10558. gl.drawElements(mode, count, type, start * bytesPerElement);
  10559. info.update(count, mode);
  10560. }
  10561. function renderInstances(geometry, start, count, primcount) {
  10562. if (primcount === 0)
  10563. return;
  10564. var extension, methodName;
  10565. if (isWebGL2) {
  10566. extension = gl;
  10567. methodName = "drawElementsInstanced";
  10568. } else {
  10569. extension = extensions.get("ANGLE_instanced_arrays");
  10570. methodName = "drawElementsInstancedANGLE";
  10571. if (extension === null) {
  10572. console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");
  10573. return;
  10574. }
  10575. }
  10576. extension[methodName](mode, count, type, start * bytesPerElement, primcount);
  10577. info.update(count, mode, primcount);
  10578. }
  10579. this.setMode = setMode;
  10580. this.setIndex = setIndex;
  10581. this.render = render;
  10582. this.renderInstances = renderInstances;
  10583. }
  10584. function WebGLInfo(gl) {
  10585. var memory = {
  10586. geometries: 0,
  10587. textures: 0
  10588. };
  10589. var render = {
  10590. frame: 0,
  10591. calls: 0,
  10592. triangles: 0,
  10593. points: 0,
  10594. lines: 0
  10595. };
  10596. function update(count, mode, instanceCount) {
  10597. instanceCount = instanceCount || 1;
  10598. render.calls++;
  10599. switch (mode) {
  10600. case 4:
  10601. render.triangles += instanceCount * (count / 3);
  10602. break;
  10603. case 1:
  10604. render.lines += instanceCount * (count / 2);
  10605. break;
  10606. case 3:
  10607. render.lines += instanceCount * (count - 1);
  10608. break;
  10609. case 2:
  10610. render.lines += instanceCount * count;
  10611. break;
  10612. case 0:
  10613. render.points += instanceCount * count;
  10614. break;
  10615. default:
  10616. console.error("THREE.WebGLInfo: Unknown draw mode:", mode);
  10617. break;
  10618. }
  10619. }
  10620. function reset() {
  10621. render.frame++;
  10622. render.calls = 0;
  10623. render.triangles = 0;
  10624. render.points = 0;
  10625. render.lines = 0;
  10626. }
  10627. return {
  10628. memory,
  10629. render,
  10630. programs: null,
  10631. autoReset: true,
  10632. reset,
  10633. update
  10634. };
  10635. }
  10636. function absNumericalSort(a, b) {
  10637. return Math.abs(b[1]) - Math.abs(a[1]);
  10638. }
  10639. function WebGLMorphtargets(gl) {
  10640. var influencesList = {};
  10641. var morphInfluences = new Float32Array(8);
  10642. function update(object, geometry, material, program) {
  10643. var objectInfluences = object.morphTargetInfluences;
  10644. var length = objectInfluences === void 0 ? 0 : objectInfluences.length;
  10645. var influences = influencesList[geometry.id];
  10646. if (influences === void 0) {
  10647. influences = [];
  10648. for (var i2 = 0; i2 < length; i2++) {
  10649. influences[i2] = [i2, 0];
  10650. }
  10651. influencesList[geometry.id] = influences;
  10652. }
  10653. var morphTargets = material.morphTargets && geometry.morphAttributes.position;
  10654. var morphNormals = material.morphNormals && geometry.morphAttributes.normal;
  10655. for (var i2 = 0; i2 < length; i2++) {
  10656. var influence = influences[i2];
  10657. if (influence[1] !== 0) {
  10658. if (morphTargets)
  10659. geometry.deleteAttribute("morphTarget" + i2);
  10660. if (morphNormals)
  10661. geometry.deleteAttribute("morphNormal" + i2);
  10662. }
  10663. }
  10664. for (var i2 = 0; i2 < length; i2++) {
  10665. var influence = influences[i2];
  10666. influence[0] = i2;
  10667. influence[1] = objectInfluences[i2];
  10668. }
  10669. influences.sort(absNumericalSort);
  10670. var morphInfluencesSum = 0;
  10671. for (var i2 = 0; i2 < 8; i2++) {
  10672. var influence = influences[i2];
  10673. if (influence) {
  10674. var index = influence[0];
  10675. var value = influence[1];
  10676. if (value) {
  10677. if (morphTargets)
  10678. geometry.setAttribute("morphTarget" + i2, morphTargets[index]);
  10679. if (morphNormals)
  10680. geometry.setAttribute("morphNormal" + i2, morphNormals[index]);
  10681. morphInfluences[i2] = value;
  10682. morphInfluencesSum += value;
  10683. continue;
  10684. }
  10685. }
  10686. morphInfluences[i2] = 0;
  10687. }
  10688. var morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;
  10689. program.getUniforms().setValue(gl, "morphTargetBaseInfluence", morphBaseInfluence);
  10690. program.getUniforms().setValue(gl, "morphTargetInfluences", morphInfluences);
  10691. }
  10692. return {
  10693. update
  10694. };
  10695. }
  10696. function WebGLObjects(gl, geometries, attributes, info) {
  10697. var updateList = {};
  10698. function update(object) {
  10699. var frame = info.render.frame;
  10700. var geometry = object.geometry;
  10701. var buffergeometry = geometries.get(object, geometry);
  10702. if (updateList[buffergeometry.id] !== frame) {
  10703. if (geometry.isGeometry) {
  10704. buffergeometry.updateFromObject(object);
  10705. }
  10706. geometries.update(buffergeometry);
  10707. updateList[buffergeometry.id] = frame;
  10708. }
  10709. if (object.isInstancedMesh) {
  10710. attributes.update(object.instanceMatrix, 34962);
  10711. }
  10712. return buffergeometry;
  10713. }
  10714. function dispose() {
  10715. updateList = {};
  10716. }
  10717. return {
  10718. update,
  10719. dispose
  10720. };
  10721. }
  10722. function CubeTexture(images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding) {
  10723. images = images !== void 0 ? images : [];
  10724. mapping = mapping !== void 0 ? mapping : CubeReflectionMapping;
  10725. format = format !== void 0 ? format : RGBFormat;
  10726. Texture.call(this, images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);
  10727. this.flipY = false;
  10728. }
  10729. CubeTexture.prototype = Object.create(Texture.prototype);
  10730. CubeTexture.prototype.constructor = CubeTexture;
  10731. CubeTexture.prototype.isCubeTexture = true;
  10732. Object.defineProperty(CubeTexture.prototype, "images", {
  10733. get: function() {
  10734. return this.image;
  10735. },
  10736. set: function(value) {
  10737. this.image = value;
  10738. }
  10739. });
  10740. function DataTexture2DArray(data, width, height, depth) {
  10741. Texture.call(this, null);
  10742. this.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 };
  10743. this.magFilter = NearestFilter;
  10744. this.minFilter = NearestFilter;
  10745. this.wrapR = ClampToEdgeWrapping;
  10746. this.generateMipmaps = false;
  10747. this.flipY = false;
  10748. this.needsUpdate = true;
  10749. }
  10750. DataTexture2DArray.prototype = Object.create(Texture.prototype);
  10751. DataTexture2DArray.prototype.constructor = DataTexture2DArray;
  10752. DataTexture2DArray.prototype.isDataTexture2DArray = true;
  10753. function DataTexture3D(data, width, height, depth) {
  10754. Texture.call(this, null);
  10755. this.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 };
  10756. this.magFilter = NearestFilter;
  10757. this.minFilter = NearestFilter;
  10758. this.wrapR = ClampToEdgeWrapping;
  10759. this.generateMipmaps = false;
  10760. this.flipY = false;
  10761. this.needsUpdate = true;
  10762. }
  10763. DataTexture3D.prototype = Object.create(Texture.prototype);
  10764. DataTexture3D.prototype.constructor = DataTexture3D;
  10765. DataTexture3D.prototype.isDataTexture3D = true;
  10766. var emptyTexture = new Texture();
  10767. var emptyTexture2dArray = new DataTexture2DArray();
  10768. var emptyTexture3d = new DataTexture3D();
  10769. var emptyCubeTexture = new CubeTexture();
  10770. var arrayCacheF32 = [];
  10771. var arrayCacheI32 = [];
  10772. var mat4array = new Float32Array(16);
  10773. var mat3array = new Float32Array(9);
  10774. var mat2array = new Float32Array(4);
  10775. function flatten(array, nBlocks, blockSize) {
  10776. var firstElem = array[0];
  10777. if (firstElem <= 0 || firstElem > 0)
  10778. return array;
  10779. var n = nBlocks * blockSize, r = arrayCacheF32[n];
  10780. if (r === void 0) {
  10781. r = new Float32Array(n);
  10782. arrayCacheF32[n] = r;
  10783. }
  10784. if (nBlocks !== 0) {
  10785. firstElem.toArray(r, 0);
  10786. for (var i2 = 1, offset = 0; i2 !== nBlocks; ++i2) {
  10787. offset += blockSize;
  10788. array[i2].toArray(r, offset);
  10789. }
  10790. }
  10791. return r;
  10792. }
  10793. function arraysEqual(a, b) {
  10794. if (a.length !== b.length)
  10795. return false;
  10796. for (var i2 = 0, l = a.length; i2 < l; i2++) {
  10797. if (a[i2] !== b[i2])
  10798. return false;
  10799. }
  10800. return true;
  10801. }
  10802. function copyArray(a, b) {
  10803. for (var i2 = 0, l = b.length; i2 < l; i2++) {
  10804. a[i2] = b[i2];
  10805. }
  10806. }
  10807. function allocTexUnits(textures, n) {
  10808. var r = arrayCacheI32[n];
  10809. if (r === void 0) {
  10810. r = new Int32Array(n);
  10811. arrayCacheI32[n] = r;
  10812. }
  10813. for (var i2 = 0; i2 !== n; ++i2)
  10814. r[i2] = textures.allocateTextureUnit();
  10815. return r;
  10816. }
  10817. function setValueV1f(gl, v) {
  10818. var cache = this.cache;
  10819. if (cache[0] === v)
  10820. return;
  10821. gl.uniform1f(this.addr, v);
  10822. cache[0] = v;
  10823. }
  10824. function setValueV2f(gl, v) {
  10825. var cache = this.cache;
  10826. if (v.x !== void 0) {
  10827. if (cache[0] !== v.x || cache[1] !== v.y) {
  10828. gl.uniform2f(this.addr, v.x, v.y);
  10829. cache[0] = v.x;
  10830. cache[1] = v.y;
  10831. }
  10832. } else {
  10833. if (arraysEqual(cache, v))
  10834. return;
  10835. gl.uniform2fv(this.addr, v);
  10836. copyArray(cache, v);
  10837. }
  10838. }
  10839. function setValueV3f(gl, v) {
  10840. var cache = this.cache;
  10841. if (v.x !== void 0) {
  10842. if (cache[0] !== v.x || cache[1] !== v.y || cache[2] !== v.z) {
  10843. gl.uniform3f(this.addr, v.x, v.y, v.z);
  10844. cache[0] = v.x;
  10845. cache[1] = v.y;
  10846. cache[2] = v.z;
  10847. }
  10848. } else if (v.r !== void 0) {
  10849. if (cache[0] !== v.r || cache[1] !== v.g || cache[2] !== v.b) {
  10850. gl.uniform3f(this.addr, v.r, v.g, v.b);
  10851. cache[0] = v.r;
  10852. cache[1] = v.g;
  10853. cache[2] = v.b;
  10854. }
  10855. } else {
  10856. if (arraysEqual(cache, v))
  10857. return;
  10858. gl.uniform3fv(this.addr, v);
  10859. copyArray(cache, v);
  10860. }
  10861. }
  10862. function setValueV4f(gl, v) {
  10863. var cache = this.cache;
  10864. if (v.x !== void 0) {
  10865. if (cache[0] !== v.x || cache[1] !== v.y || cache[2] !== v.z || cache[3] !== v.w) {
  10866. gl.uniform4f(this.addr, v.x, v.y, v.z, v.w);
  10867. cache[0] = v.x;
  10868. cache[1] = v.y;
  10869. cache[2] = v.z;
  10870. cache[3] = v.w;
  10871. }
  10872. } else {
  10873. if (arraysEqual(cache, v))
  10874. return;
  10875. gl.uniform4fv(this.addr, v);
  10876. copyArray(cache, v);
  10877. }
  10878. }
  10879. function setValueM2(gl, v) {
  10880. var cache = this.cache;
  10881. var elements = v.elements;
  10882. if (elements === void 0) {
  10883. if (arraysEqual(cache, v))
  10884. return;
  10885. gl.uniformMatrix2fv(this.addr, false, v);
  10886. copyArray(cache, v);
  10887. } else {
  10888. if (arraysEqual(cache, elements))
  10889. return;
  10890. mat2array.set(elements);
  10891. gl.uniformMatrix2fv(this.addr, false, mat2array);
  10892. copyArray(cache, elements);
  10893. }
  10894. }
  10895. function setValueM3(gl, v) {
  10896. var cache = this.cache;
  10897. var elements = v.elements;
  10898. if (elements === void 0) {
  10899. if (arraysEqual(cache, v))
  10900. return;
  10901. gl.uniformMatrix3fv(this.addr, false, v);
  10902. copyArray(cache, v);
  10903. } else {
  10904. if (arraysEqual(cache, elements))
  10905. return;
  10906. mat3array.set(elements);
  10907. gl.uniformMatrix3fv(this.addr, false, mat3array);
  10908. copyArray(cache, elements);
  10909. }
  10910. }
  10911. function setValueM4(gl, v) {
  10912. var cache = this.cache;
  10913. var elements = v.elements;
  10914. if (elements === void 0) {
  10915. if (arraysEqual(cache, v))
  10916. return;
  10917. gl.uniformMatrix4fv(this.addr, false, v);
  10918. copyArray(cache, v);
  10919. } else {
  10920. if (arraysEqual(cache, elements))
  10921. return;
  10922. mat4array.set(elements);
  10923. gl.uniformMatrix4fv(this.addr, false, mat4array);
  10924. copyArray(cache, elements);
  10925. }
  10926. }
  10927. function setValueT1(gl, v, textures) {
  10928. var cache = this.cache;
  10929. var unit = textures.allocateTextureUnit();
  10930. if (cache[0] !== unit) {
  10931. gl.uniform1i(this.addr, unit);
  10932. cache[0] = unit;
  10933. }
  10934. textures.safeSetTexture2D(v || emptyTexture, unit);
  10935. }
  10936. function setValueT2DArray1(gl, v, textures) {
  10937. var cache = this.cache;
  10938. var unit = textures.allocateTextureUnit();
  10939. if (cache[0] !== unit) {
  10940. gl.uniform1i(this.addr, unit);
  10941. cache[0] = unit;
  10942. }
  10943. textures.setTexture2DArray(v || emptyTexture2dArray, unit);
  10944. }
  10945. function setValueT3D1(gl, v, textures) {
  10946. var cache = this.cache;
  10947. var unit = textures.allocateTextureUnit();
  10948. if (cache[0] !== unit) {
  10949. gl.uniform1i(this.addr, unit);
  10950. cache[0] = unit;
  10951. }
  10952. textures.setTexture3D(v || emptyTexture3d, unit);
  10953. }
  10954. function setValueT6(gl, v, textures) {
  10955. var cache = this.cache;
  10956. var unit = textures.allocateTextureUnit();
  10957. if (cache[0] !== unit) {
  10958. gl.uniform1i(this.addr, unit);
  10959. cache[0] = unit;
  10960. }
  10961. textures.safeSetTextureCube(v || emptyCubeTexture, unit);
  10962. }
  10963. function setValueV1i(gl, v) {
  10964. var cache = this.cache;
  10965. if (cache[0] === v)
  10966. return;
  10967. gl.uniform1i(this.addr, v);
  10968. cache[0] = v;
  10969. }
  10970. function setValueV2i(gl, v) {
  10971. var cache = this.cache;
  10972. if (arraysEqual(cache, v))
  10973. return;
  10974. gl.uniform2iv(this.addr, v);
  10975. copyArray(cache, v);
  10976. }
  10977. function setValueV3i(gl, v) {
  10978. var cache = this.cache;
  10979. if (arraysEqual(cache, v))
  10980. return;
  10981. gl.uniform3iv(this.addr, v);
  10982. copyArray(cache, v);
  10983. }
  10984. function setValueV4i(gl, v) {
  10985. var cache = this.cache;
  10986. if (arraysEqual(cache, v))
  10987. return;
  10988. gl.uniform4iv(this.addr, v);
  10989. copyArray(cache, v);
  10990. }
  10991. function setValueV1ui(gl, v) {
  10992. var cache = this.cache;
  10993. if (cache[0] === v)
  10994. return;
  10995. gl.uniform1ui(this.addr, v);
  10996. cache[0] = v;
  10997. }
  10998. function getSingularSetter(type) {
  10999. switch (type) {
  11000. case 5126:
  11001. return setValueV1f;
  11002. case 35664:
  11003. return setValueV2f;
  11004. case 35665:
  11005. return setValueV3f;
  11006. case 35666:
  11007. return setValueV4f;
  11008. case 35674:
  11009. return setValueM2;
  11010. case 35675:
  11011. return setValueM3;
  11012. case 35676:
  11013. return setValueM4;
  11014. case 5124:
  11015. case 35670:
  11016. return setValueV1i;
  11017. case 35667:
  11018. case 35671:
  11019. return setValueV2i;
  11020. case 35668:
  11021. case 35672:
  11022. return setValueV3i;
  11023. case 35669:
  11024. case 35673:
  11025. return setValueV4i;
  11026. case 5125:
  11027. return setValueV1ui;
  11028. case 35678:
  11029. case 36198:
  11030. case 36298:
  11031. case 36306:
  11032. case 35682:
  11033. return setValueT1;
  11034. case 35679:
  11035. case 36299:
  11036. case 36307:
  11037. return setValueT3D1;
  11038. case 35680:
  11039. case 36300:
  11040. case 36308:
  11041. case 36293:
  11042. return setValueT6;
  11043. case 36289:
  11044. case 36303:
  11045. case 36311:
  11046. case 36292:
  11047. return setValueT2DArray1;
  11048. }
  11049. }
  11050. function setValueV1fArray(gl, v) {
  11051. gl.uniform1fv(this.addr, v);
  11052. }
  11053. function setValueV1iArray(gl, v) {
  11054. gl.uniform1iv(this.addr, v);
  11055. }
  11056. function setValueV2iArray(gl, v) {
  11057. gl.uniform2iv(this.addr, v);
  11058. }
  11059. function setValueV3iArray(gl, v) {
  11060. gl.uniform3iv(this.addr, v);
  11061. }
  11062. function setValueV4iArray(gl, v) {
  11063. gl.uniform4iv(this.addr, v);
  11064. }
  11065. function setValueV2fArray(gl, v) {
  11066. var data = flatten(v, this.size, 2);
  11067. gl.uniform2fv(this.addr, data);
  11068. }
  11069. function setValueV3fArray(gl, v) {
  11070. var data = flatten(v, this.size, 3);
  11071. gl.uniform3fv(this.addr, data);
  11072. }
  11073. function setValueV4fArray(gl, v) {
  11074. var data = flatten(v, this.size, 4);
  11075. gl.uniform4fv(this.addr, data);
  11076. }
  11077. function setValueM2Array(gl, v) {
  11078. var data = flatten(v, this.size, 4);
  11079. gl.uniformMatrix2fv(this.addr, false, data);
  11080. }
  11081. function setValueM3Array(gl, v) {
  11082. var data = flatten(v, this.size, 9);
  11083. gl.uniformMatrix3fv(this.addr, false, data);
  11084. }
  11085. function setValueM4Array(gl, v) {
  11086. var data = flatten(v, this.size, 16);
  11087. gl.uniformMatrix4fv(this.addr, false, data);
  11088. }
  11089. function setValueT1Array(gl, v, textures) {
  11090. var n = v.length;
  11091. var units = allocTexUnits(textures, n);
  11092. gl.uniform1iv(this.addr, units);
  11093. for (var i2 = 0; i2 !== n; ++i2) {
  11094. textures.safeSetTexture2D(v[i2] || emptyTexture, units[i2]);
  11095. }
  11096. }
  11097. function setValueT6Array(gl, v, textures) {
  11098. var n = v.length;
  11099. var units = allocTexUnits(textures, n);
  11100. gl.uniform1iv(this.addr, units);
  11101. for (var i2 = 0; i2 !== n; ++i2) {
  11102. textures.safeSetTextureCube(v[i2] || emptyCubeTexture, units[i2]);
  11103. }
  11104. }
  11105. function getPureArraySetter(type) {
  11106. switch (type) {
  11107. case 5126:
  11108. return setValueV1fArray;
  11109. case 35664:
  11110. return setValueV2fArray;
  11111. case 35665:
  11112. return setValueV3fArray;
  11113. case 35666:
  11114. return setValueV4fArray;
  11115. case 35674:
  11116. return setValueM2Array;
  11117. case 35675:
  11118. return setValueM3Array;
  11119. case 35676:
  11120. return setValueM4Array;
  11121. case 5124:
  11122. case 35670:
  11123. return setValueV1iArray;
  11124. case 35667:
  11125. case 35671:
  11126. return setValueV2iArray;
  11127. case 35668:
  11128. case 35672:
  11129. return setValueV3iArray;
  11130. case 35669:
  11131. case 35673:
  11132. return setValueV4iArray;
  11133. case 35678:
  11134. case 36198:
  11135. case 36298:
  11136. case 36306:
  11137. case 35682:
  11138. return setValueT1Array;
  11139. case 35680:
  11140. case 36300:
  11141. case 36308:
  11142. case 36293:
  11143. return setValueT6Array;
  11144. }
  11145. }
  11146. function SingleUniform(id, activeInfo, addr) {
  11147. this.id = id;
  11148. this.addr = addr;
  11149. this.cache = [];
  11150. this.setValue = getSingularSetter(activeInfo.type);
  11151. }
  11152. function PureArrayUniform(id, activeInfo, addr) {
  11153. this.id = id;
  11154. this.addr = addr;
  11155. this.cache = [];
  11156. this.size = activeInfo.size;
  11157. this.setValue = getPureArraySetter(activeInfo.type);
  11158. }
  11159. PureArrayUniform.prototype.updateCache = function(data) {
  11160. var cache = this.cache;
  11161. if (data instanceof Float32Array && cache.length !== data.length) {
  11162. this.cache = new Float32Array(data.length);
  11163. }
  11164. copyArray(cache, data);
  11165. };
  11166. function StructuredUniform(id) {
  11167. this.id = id;
  11168. this.seq = [];
  11169. this.map = {};
  11170. }
  11171. StructuredUniform.prototype.setValue = function(gl, value, textures) {
  11172. var seq = this.seq;
  11173. for (var i2 = 0, n = seq.length; i2 !== n; ++i2) {
  11174. var u = seq[i2];
  11175. u.setValue(gl, value[u.id], textures);
  11176. }
  11177. };
  11178. var RePathPart = /([\w\d_]+)(\])?(\[|\.)?/g;
  11179. function addUniform(container, uniformObject) {
  11180. container.seq.push(uniformObject);
  11181. container.map[uniformObject.id] = uniformObject;
  11182. }
  11183. function parseUniform(activeInfo, addr, container) {
  11184. var path = activeInfo.name, pathLength = path.length;
  11185. RePathPart.lastIndex = 0;
  11186. while (true) {
  11187. var match = RePathPart.exec(path), matchEnd = RePathPart.lastIndex, id = match[1], idIsIndex = match[2] === "]", subscript = match[3];
  11188. if (idIsIndex)
  11189. id = id | 0;
  11190. if (subscript === void 0 || subscript === "[" && matchEnd + 2 === pathLength) {
  11191. addUniform(container, subscript === void 0 ? new SingleUniform(id, activeInfo, addr) : new PureArrayUniform(id, activeInfo, addr));
  11192. break;
  11193. } else {
  11194. var map2 = container.map, next = map2[id];
  11195. if (next === void 0) {
  11196. next = new StructuredUniform(id);
  11197. addUniform(container, next);
  11198. }
  11199. container = next;
  11200. }
  11201. }
  11202. }
  11203. function WebGLUniforms(gl, program) {
  11204. this.seq = [];
  11205. this.map = {};
  11206. var n = gl.getProgramParameter(program, 35718);
  11207. for (var i2 = 0; i2 < n; ++i2) {
  11208. var info = gl.getActiveUniform(program, i2), addr = gl.getUniformLocation(program, info.name);
  11209. parseUniform(info, addr, this);
  11210. }
  11211. }
  11212. WebGLUniforms.prototype.setValue = function(gl, name, value, textures) {
  11213. var u = this.map[name];
  11214. if (u !== void 0)
  11215. u.setValue(gl, value, textures);
  11216. };
  11217. WebGLUniforms.prototype.setOptional = function(gl, object, name) {
  11218. var v = object[name];
  11219. if (v !== void 0)
  11220. this.setValue(gl, name, v);
  11221. };
  11222. WebGLUniforms.upload = function(gl, seq, values, textures) {
  11223. for (var i2 = 0, n = seq.length; i2 !== n; ++i2) {
  11224. var u = seq[i2], v = values[u.id];
  11225. if (v.needsUpdate !== false) {
  11226. u.setValue(gl, v.value, textures);
  11227. }
  11228. }
  11229. };
  11230. WebGLUniforms.seqWithValue = function(seq, values) {
  11231. var r = [];
  11232. for (var i2 = 0, n = seq.length; i2 !== n; ++i2) {
  11233. var u = seq[i2];
  11234. if (u.id in values)
  11235. r.push(u);
  11236. }
  11237. return r;
  11238. };
  11239. function WebGLShader(gl, type, string) {
  11240. var shader = gl.createShader(type);
  11241. gl.shaderSource(shader, string);
  11242. gl.compileShader(shader);
  11243. return shader;
  11244. }
  11245. var programIdCount = 0;
  11246. function addLineNumbers(string) {
  11247. var lines = string.split("\n");
  11248. for (var i2 = 0; i2 < lines.length; i2++) {
  11249. lines[i2] = i2 + 1 + ": " + lines[i2];
  11250. }
  11251. return lines.join("\n");
  11252. }
  11253. function getEncodingComponents(encoding) {
  11254. switch (encoding) {
  11255. case LinearEncoding:
  11256. return ["Linear", "( value )"];
  11257. case sRGBEncoding:
  11258. return ["sRGB", "( value )"];
  11259. case RGBEEncoding:
  11260. return ["RGBE", "( value )"];
  11261. case RGBM7Encoding:
  11262. return ["RGBM", "( value, 7.0 )"];
  11263. case RGBM16Encoding:
  11264. return ["RGBM", "( value, 16.0 )"];
  11265. case RGBDEncoding:
  11266. return ["RGBD", "( value, 256.0 )"];
  11267. case GammaEncoding:
  11268. return ["Gamma", "( value, float( GAMMA_FACTOR ) )"];
  11269. case LogLuvEncoding:
  11270. return ["LogLuv", "( value )"];
  11271. default:
  11272. throw new Error("unsupported encoding: " + encoding);
  11273. }
  11274. }
  11275. function getShaderErrors(gl, shader, type) {
  11276. var status = gl.getShaderParameter(shader, 35713);
  11277. var log = gl.getShaderInfoLog(shader).trim();
  11278. if (status && log === "")
  11279. return "";
  11280. var source = gl.getShaderSource(shader);
  11281. return "THREE.WebGLShader: gl.getShaderInfoLog() " + type + "\n" + log + addLineNumbers(source);
  11282. }
  11283. function getTexelDecodingFunction(functionName, encoding) {
  11284. var components = getEncodingComponents(encoding);
  11285. return "vec4 " + functionName + "( vec4 value ) { return " + components[0] + "ToLinear" + components[1] + "; }";
  11286. }
  11287. function getTexelEncodingFunction(functionName, encoding) {
  11288. var components = getEncodingComponents(encoding);
  11289. return "vec4 " + functionName + "( vec4 value ) { return LinearTo" + components[0] + components[1] + "; }";
  11290. }
  11291. function getToneMappingFunction(functionName, toneMapping) {
  11292. var toneMappingName;
  11293. switch (toneMapping) {
  11294. case LinearToneMapping:
  11295. toneMappingName = "Linear";
  11296. break;
  11297. case ReinhardToneMapping:
  11298. toneMappingName = "Reinhard";
  11299. break;
  11300. case Uncharted2ToneMapping:
  11301. toneMappingName = "Uncharted2";
  11302. break;
  11303. case CineonToneMapping:
  11304. toneMappingName = "OptimizedCineon";
  11305. break;
  11306. case ACESFilmicToneMapping:
  11307. toneMappingName = "ACESFilmic";
  11308. break;
  11309. default:
  11310. throw new Error("unsupported toneMapping: " + toneMapping);
  11311. }
  11312. return "vec3 " + functionName + "( vec3 color ) { return " + toneMappingName + "ToneMapping( color ); }";
  11313. }
  11314. function generateExtensions(parameters) {
  11315. var chunks = [
  11316. parameters.extensionDerivatives || parameters.envMapCubeUV || parameters.bumpMap || parameters.tangentSpaceNormalMap || parameters.clearcoatNormalMap || parameters.flatShading || parameters.shaderID === "physical" ? "#extension GL_OES_standard_derivatives : enable" : "",
  11317. (parameters.extensionFragDepth || parameters.logarithmicDepthBuffer) && parameters.rendererExtensionFragDepth ? "#extension GL_EXT_frag_depth : enable" : "",
  11318. parameters.extensionDrawBuffers && parameters.rendererExtensionDrawBuffers ? "#extension GL_EXT_draw_buffers : require" : "",
  11319. (parameters.extensionShaderTextureLOD || parameters.envMap) && parameters.rendererExtensionShaderTextureLod ? "#extension GL_EXT_shader_texture_lod : enable" : ""
  11320. ];
  11321. return chunks.filter(filterEmptyLine).join("\n");
  11322. }
  11323. function generateDefines(defines) {
  11324. var chunks = [];
  11325. for (var name in defines) {
  11326. var value = defines[name];
  11327. if (value === false)
  11328. continue;
  11329. chunks.push("#define " + name + " " + value);
  11330. }
  11331. return chunks.join("\n");
  11332. }
  11333. function fetchAttributeLocations(gl, program) {
  11334. var attributes = {};
  11335. var n = gl.getProgramParameter(program, 35721);
  11336. for (var i2 = 0; i2 < n; i2++) {
  11337. var info = gl.getActiveAttrib(program, i2);
  11338. var name = info.name;
  11339. attributes[name] = gl.getAttribLocation(program, name);
  11340. }
  11341. return attributes;
  11342. }
  11343. function filterEmptyLine(string) {
  11344. return string !== "";
  11345. }
  11346. function replaceLightNums(string, parameters) {
  11347. return string.replace(/NUM_DIR_LIGHTS/g, parameters.numDirLights).replace(/NUM_SPOT_LIGHTS/g, parameters.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g, parameters.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g, parameters.numPointLights).replace(/NUM_HEMI_LIGHTS/g, parameters.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g, parameters.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g, parameters.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g, parameters.numPointLightShadows);
  11348. }
  11349. function replaceClippingPlaneNums(string, parameters) {
  11350. return string.replace(/NUM_CLIPPING_PLANES/g, parameters.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, parameters.numClippingPlanes - parameters.numClipIntersection);
  11351. }
  11352. var includePattern = /^[ \t]*#include +<([\w\d./]+)>/gm;
  11353. function resolveIncludes(string) {
  11354. return string.replace(includePattern, includeReplacer);
  11355. }
  11356. function includeReplacer(match, include) {
  11357. var string = ShaderChunk[include];
  11358. if (string === void 0) {
  11359. throw new Error("Can not resolve #include <" + include + ">");
  11360. }
  11361. return resolveIncludes(string);
  11362. }
  11363. var loopPattern = /#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;
  11364. function unrollLoops(string) {
  11365. return string.replace(loopPattern, loopReplacer);
  11366. }
  11367. function loopReplacer(match, start, end, snippet) {
  11368. var string = "";
  11369. for (var i2 = parseInt(start); i2 < parseInt(end); i2++) {
  11370. string += snippet.replace(/\[ i \]/g, "[ " + i2 + " ]").replace(/UNROLLED_LOOP_INDEX/g, i2);
  11371. }
  11372. return string;
  11373. }
  11374. function generatePrecision(parameters) {
  11375. var precisionstring = "precision " + parameters.precision + " float;\nprecision " + parameters.precision + " int;";
  11376. if (parameters.precision === "highp") {
  11377. precisionstring += "\n#define HIGH_PRECISION";
  11378. } else if (parameters.precision === "mediump") {
  11379. precisionstring += "\n#define MEDIUM_PRECISION";
  11380. } else if (parameters.precision === "lowp") {
  11381. precisionstring += "\n#define LOW_PRECISION";
  11382. }
  11383. return precisionstring;
  11384. }
  11385. function generateShadowMapTypeDefine(parameters) {
  11386. var shadowMapTypeDefine = "SHADOWMAP_TYPE_BASIC";
  11387. if (parameters.shadowMapType === PCFShadowMap) {
  11388. shadowMapTypeDefine = "SHADOWMAP_TYPE_PCF";
  11389. } else if (parameters.shadowMapType === PCFSoftShadowMap) {
  11390. shadowMapTypeDefine = "SHADOWMAP_TYPE_PCF_SOFT";
  11391. } else if (parameters.shadowMapType === VSMShadowMap) {
  11392. shadowMapTypeDefine = "SHADOWMAP_TYPE_VSM";
  11393. }
  11394. return shadowMapTypeDefine;
  11395. }
  11396. function generateEnvMapTypeDefine(parameters) {
  11397. var envMapTypeDefine = "ENVMAP_TYPE_CUBE";
  11398. if (parameters.envMap) {
  11399. switch (parameters.envMapMode) {
  11400. case CubeReflectionMapping:
  11401. case CubeRefractionMapping:
  11402. envMapTypeDefine = "ENVMAP_TYPE_CUBE";
  11403. break;
  11404. case CubeUVReflectionMapping:
  11405. case CubeUVRefractionMapping:
  11406. envMapTypeDefine = "ENVMAP_TYPE_CUBE_UV";
  11407. break;
  11408. case EquirectangularReflectionMapping:
  11409. case EquirectangularRefractionMapping:
  11410. envMapTypeDefine = "ENVMAP_TYPE_EQUIREC";
  11411. break;
  11412. case SphericalReflectionMapping:
  11413. envMapTypeDefine = "ENVMAP_TYPE_SPHERE";
  11414. break;
  11415. }
  11416. }
  11417. return envMapTypeDefine;
  11418. }
  11419. function generateEnvMapModeDefine(parameters) {
  11420. var envMapModeDefine = "ENVMAP_MODE_REFLECTION";
  11421. if (parameters.envMap) {
  11422. switch (parameters.envMapMode) {
  11423. case CubeRefractionMapping:
  11424. case EquirectangularRefractionMapping:
  11425. envMapModeDefine = "ENVMAP_MODE_REFRACTION";
  11426. break;
  11427. }
  11428. }
  11429. return envMapModeDefine;
  11430. }
  11431. function generateEnvMapBlendingDefine(parameters) {
  11432. var envMapBlendingDefine = "ENVMAP_BLENDING_NONE";
  11433. if (parameters.envMap) {
  11434. switch (parameters.combine) {
  11435. case MultiplyOperation:
  11436. envMapBlendingDefine = "ENVMAP_BLENDING_MULTIPLY";
  11437. break;
  11438. case MixOperation:
  11439. envMapBlendingDefine = "ENVMAP_BLENDING_MIX";
  11440. break;
  11441. case AddOperation:
  11442. envMapBlendingDefine = "ENVMAP_BLENDING_ADD";
  11443. break;
  11444. }
  11445. }
  11446. return envMapBlendingDefine;
  11447. }
  11448. function WebGLProgram(renderer, cacheKey, parameters) {
  11449. var gl = renderer.getContext();
  11450. var defines = parameters.defines;
  11451. var vertexShader = parameters.vertexShader;
  11452. var fragmentShader = parameters.fragmentShader;
  11453. var shadowMapTypeDefine = generateShadowMapTypeDefine(parameters);
  11454. var envMapTypeDefine = generateEnvMapTypeDefine(parameters);
  11455. var envMapModeDefine = generateEnvMapModeDefine(parameters);
  11456. var envMapBlendingDefine = generateEnvMapBlendingDefine(parameters);
  11457. var gammaFactorDefine = renderer.gammaFactor > 0 ? renderer.gammaFactor : 1;
  11458. var customExtensions = parameters.isWebGL2 ? "" : generateExtensions(parameters);
  11459. var customDefines = generateDefines(defines);
  11460. var program = gl.createProgram();
  11461. var prefixVertex, prefixFragment;
  11462. var numMultiviewViews = parameters.numMultiviewViews;
  11463. if (parameters.isRawShaderMaterial) {
  11464. prefixVertex = [
  11465. customDefines
  11466. ].filter(filterEmptyLine).join("\n");
  11467. if (prefixVertex.length > 0) {
  11468. prefixVertex += "\n";
  11469. }
  11470. prefixFragment = [
  11471. customExtensions,
  11472. customDefines
  11473. ].filter(filterEmptyLine).join("\n");
  11474. if (prefixFragment.length > 0) {
  11475. prefixFragment += "\n";
  11476. }
  11477. } else {
  11478. prefixVertex = [
  11479. generatePrecision(parameters),
  11480. "#define SHADER_NAME " + parameters.shaderName,
  11481. customDefines,
  11482. parameters.instancing ? "#define USE_INSTANCING" : "",
  11483. parameters.supportsVertexTextures ? "#define VERTEX_TEXTURES" : "",
  11484. "#define GAMMA_FACTOR " + gammaFactorDefine,
  11485. "#define MAX_BONES " + parameters.maxBones,
  11486. parameters.useFog && parameters.fog ? "#define USE_FOG" : "",
  11487. parameters.useFog && parameters.fogExp2 ? "#define FOG_EXP2" : "",
  11488. parameters.map ? "#define USE_MAP" : "",
  11489. parameters.envMap ? "#define USE_ENVMAP" : "",
  11490. parameters.envMap ? "#define " + envMapModeDefine : "",
  11491. parameters.lightMap ? "#define USE_LIGHTMAP" : "",
  11492. parameters.aoMap ? "#define USE_AOMAP" : "",
  11493. parameters.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
  11494. parameters.bumpMap ? "#define USE_BUMPMAP" : "",
  11495. parameters.normalMap ? "#define USE_NORMALMAP" : "",
  11496. parameters.normalMap && parameters.objectSpaceNormalMap ? "#define OBJECTSPACE_NORMALMAP" : "",
  11497. parameters.normalMap && parameters.tangentSpaceNormalMap ? "#define TANGENTSPACE_NORMALMAP" : "",
  11498. parameters.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "",
  11499. parameters.displacementMap && parameters.supportsVertexTextures ? "#define USE_DISPLACEMENTMAP" : "",
  11500. parameters.specularMap ? "#define USE_SPECULARMAP" : "",
  11501. parameters.roughnessMap ? "#define USE_ROUGHNESSMAP" : "",
  11502. parameters.metalnessMap ? "#define USE_METALNESSMAP" : "",
  11503. parameters.alphaMap ? "#define USE_ALPHAMAP" : "",
  11504. parameters.vertexTangents ? "#define USE_TANGENT" : "",
  11505. parameters.vertexColors ? "#define USE_COLOR" : "",
  11506. parameters.vertexUvs ? "#define USE_UV" : "",
  11507. parameters.uvsVertexOnly ? "#define UVS_VERTEX_ONLY" : "",
  11508. parameters.flatShading ? "#define FLAT_SHADED" : "",
  11509. parameters.skinning ? "#define USE_SKINNING" : "",
  11510. parameters.useVertexTexture ? "#define BONE_TEXTURE" : "",
  11511. parameters.morphTargets ? "#define USE_MORPHTARGETS" : "",
  11512. parameters.morphNormals && parameters.flatShading === false ? "#define USE_MORPHNORMALS" : "",
  11513. parameters.doubleSided ? "#define DOUBLE_SIDED" : "",
  11514. parameters.flipSided ? "#define FLIP_SIDED" : "",
  11515. parameters.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
  11516. parameters.shadowMapEnabled ? "#define " + shadowMapTypeDefine : "",
  11517. parameters.sizeAttenuation ? "#define USE_SIZEATTENUATION" : "",
  11518. parameters.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "",
  11519. parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? "#define USE_LOGDEPTHBUF_EXT" : "",
  11520. "uniform mat4 modelMatrix;",
  11521. "uniform mat4 modelViewMatrix;",
  11522. "uniform mat4 projectionMatrix;",
  11523. "uniform mat4 viewMatrix;",
  11524. "uniform mat3 normalMatrix;",
  11525. "uniform vec3 cameraPosition;",
  11526. "uniform bool isOrthographic;",
  11527. "#ifdef USE_INSTANCING",
  11528. " attribute mat4 instanceMatrix;",
  11529. "#endif",
  11530. "attribute vec3 position;",
  11531. "attribute vec3 normal;",
  11532. "attribute vec2 uv;",
  11533. "#ifdef USE_TANGENT",
  11534. " attribute vec4 tangent;",
  11535. "#endif",
  11536. "#ifdef USE_COLOR",
  11537. " attribute vec3 color;",
  11538. "#endif",
  11539. "#ifdef USE_MORPHTARGETS",
  11540. " attribute vec3 morphTarget0;",
  11541. " attribute vec3 morphTarget1;",
  11542. " attribute vec3 morphTarget2;",
  11543. " attribute vec3 morphTarget3;",
  11544. " #ifdef USE_MORPHNORMALS",
  11545. " attribute vec3 morphNormal0;",
  11546. " attribute vec3 morphNormal1;",
  11547. " attribute vec3 morphNormal2;",
  11548. " attribute vec3 morphNormal3;",
  11549. " #else",
  11550. " attribute vec3 morphTarget4;",
  11551. " attribute vec3 morphTarget5;",
  11552. " attribute vec3 morphTarget6;",
  11553. " attribute vec3 morphTarget7;",
  11554. " #endif",
  11555. "#endif",
  11556. "#ifdef USE_SKINNING",
  11557. " attribute vec4 skinIndex;",
  11558. " attribute vec4 skinWeight;",
  11559. "#endif",
  11560. "\n"
  11561. ].filter(filterEmptyLine).join("\n");
  11562. prefixFragment = [
  11563. customExtensions,
  11564. generatePrecision(parameters),
  11565. "#define SHADER_NAME " + parameters.shaderName,
  11566. customDefines,
  11567. parameters.alphaTest ? "#define ALPHATEST " + parameters.alphaTest + (parameters.alphaTest % 1 ? "" : ".0") : "",
  11568. // add '.0' if integer
  11569. "#define GAMMA_FACTOR " + gammaFactorDefine,
  11570. parameters.useFog && parameters.fog ? "#define USE_FOG" : "",
  11571. parameters.useFog && parameters.fogExp2 ? "#define FOG_EXP2" : "",
  11572. parameters.map ? "#define USE_MAP" : "",
  11573. parameters.matcap ? "#define USE_MATCAP" : "",
  11574. parameters.envMap ? "#define USE_ENVMAP" : "",
  11575. parameters.envMap ? "#define " + envMapTypeDefine : "",
  11576. parameters.envMap ? "#define " + envMapModeDefine : "",
  11577. parameters.envMap ? "#define " + envMapBlendingDefine : "",
  11578. parameters.lightMap ? "#define USE_LIGHTMAP" : "",
  11579. parameters.aoMap ? "#define USE_AOMAP" : "",
  11580. parameters.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
  11581. parameters.bumpMap ? "#define USE_BUMPMAP" : "",
  11582. parameters.normalMap ? "#define USE_NORMALMAP" : "",
  11583. parameters.normalMap && parameters.objectSpaceNormalMap ? "#define OBJECTSPACE_NORMALMAP" : "",
  11584. parameters.normalMap && parameters.tangentSpaceNormalMap ? "#define TANGENTSPACE_NORMALMAP" : "",
  11585. parameters.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "",
  11586. parameters.specularMap ? "#define USE_SPECULARMAP" : "",
  11587. parameters.roughnessMap ? "#define USE_ROUGHNESSMAP" : "",
  11588. parameters.metalnessMap ? "#define USE_METALNESSMAP" : "",
  11589. parameters.alphaMap ? "#define USE_ALPHAMAP" : "",
  11590. parameters.sheen ? "#define USE_SHEEN" : "",
  11591. parameters.vertexTangents ? "#define USE_TANGENT" : "",
  11592. parameters.vertexColors ? "#define USE_COLOR" : "",
  11593. parameters.vertexUvs ? "#define USE_UV" : "",
  11594. parameters.uvsVertexOnly ? "#define UVS_VERTEX_ONLY" : "",
  11595. parameters.gradientMap ? "#define USE_GRADIENTMAP" : "",
  11596. parameters.flatShading ? "#define FLAT_SHADED" : "",
  11597. parameters.doubleSided ? "#define DOUBLE_SIDED" : "",
  11598. parameters.flipSided ? "#define FLIP_SIDED" : "",
  11599. parameters.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
  11600. parameters.shadowMapEnabled ? "#define " + shadowMapTypeDefine : "",
  11601. parameters.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "",
  11602. parameters.physicallyCorrectLights ? "#define PHYSICALLY_CORRECT_LIGHTS" : "",
  11603. parameters.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "",
  11604. parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? "#define USE_LOGDEPTHBUF_EXT" : "",
  11605. (parameters.extensionShaderTextureLOD || parameters.envMap) && parameters.rendererExtensionShaderTextureLod ? "#define TEXTURE_LOD_EXT" : "",
  11606. "uniform mat4 viewMatrix;",
  11607. "uniform vec3 cameraPosition;",
  11608. "uniform bool isOrthographic;",
  11609. parameters.toneMapping !== NoToneMapping ? "#define TONE_MAPPING" : "",
  11610. parameters.toneMapping !== NoToneMapping ? ShaderChunk["tonemapping_pars_fragment"] : "",
  11611. // this code is required here because it is used by the toneMapping() function defined below
  11612. parameters.toneMapping !== NoToneMapping ? getToneMappingFunction("toneMapping", parameters.toneMapping) : "",
  11613. parameters.dithering ? "#define DITHERING" : "",
  11614. parameters.outputEncoding || parameters.mapEncoding || parameters.matcapEncoding || parameters.envMapEncoding || parameters.emissiveMapEncoding || parameters.lightMapEncoding ? ShaderChunk["encodings_pars_fragment"] : "",
  11615. // this code is required here because it is used by the various encoding/decoding function defined below
  11616. parameters.mapEncoding ? getTexelDecodingFunction("mapTexelToLinear", parameters.mapEncoding) : "",
  11617. parameters.matcapEncoding ? getTexelDecodingFunction("matcapTexelToLinear", parameters.matcapEncoding) : "",
  11618. parameters.envMapEncoding ? getTexelDecodingFunction("envMapTexelToLinear", parameters.envMapEncoding) : "",
  11619. parameters.emissiveMapEncoding ? getTexelDecodingFunction("emissiveMapTexelToLinear", parameters.emissiveMapEncoding) : "",
  11620. parameters.lightMapEncoding ? getTexelDecodingFunction("lightMapTexelToLinear", parameters.lightMapEncoding) : "",
  11621. parameters.outputEncoding ? getTexelEncodingFunction("linearToOutputTexel", parameters.outputEncoding) : "",
  11622. parameters.depthPacking ? "#define DEPTH_PACKING " + parameters.depthPacking : "",
  11623. "\n"
  11624. ].filter(filterEmptyLine).join("\n");
  11625. }
  11626. vertexShader = resolveIncludes(vertexShader);
  11627. vertexShader = replaceLightNums(vertexShader, parameters);
  11628. vertexShader = replaceClippingPlaneNums(vertexShader, parameters);
  11629. fragmentShader = resolveIncludes(fragmentShader);
  11630. fragmentShader = replaceLightNums(fragmentShader, parameters);
  11631. fragmentShader = replaceClippingPlaneNums(fragmentShader, parameters);
  11632. vertexShader = unrollLoops(vertexShader);
  11633. fragmentShader = unrollLoops(fragmentShader);
  11634. if (parameters.isWebGL2 && !parameters.isRawShaderMaterial) {
  11635. var isGLSL3ShaderMaterial = false;
  11636. var versionRegex = /^\s*#version\s+300\s+es\s*\n/;
  11637. if (parameters.isShaderMaterial && vertexShader.match(versionRegex) !== null && fragmentShader.match(versionRegex) !== null) {
  11638. isGLSL3ShaderMaterial = true;
  11639. vertexShader = vertexShader.replace(versionRegex, "");
  11640. fragmentShader = fragmentShader.replace(versionRegex, "");
  11641. }
  11642. prefixVertex = [
  11643. "#version 300 es\n",
  11644. "#define attribute in",
  11645. "#define varying out",
  11646. "#define texture2D texture"
  11647. ].join("\n") + "\n" + prefixVertex;
  11648. prefixFragment = [
  11649. "#version 300 es\n",
  11650. "#define varying in",
  11651. isGLSL3ShaderMaterial ? "" : "out highp vec4 pc_fragColor;",
  11652. isGLSL3ShaderMaterial ? "" : "#define gl_FragColor pc_fragColor",
  11653. "#define gl_FragDepthEXT gl_FragDepth",
  11654. "#define texture2D texture",
  11655. "#define textureCube texture",
  11656. "#define texture2DProj textureProj",
  11657. "#define texture2DLodEXT textureLod",
  11658. "#define texture2DProjLodEXT textureProjLod",
  11659. "#define textureCubeLodEXT textureLod",
  11660. "#define texture2DGradEXT textureGrad",
  11661. "#define texture2DProjGradEXT textureProjGrad",
  11662. "#define textureCubeGradEXT textureGrad"
  11663. ].join("\n") + "\n" + prefixFragment;
  11664. if (numMultiviewViews > 0) {
  11665. prefixVertex = prefixVertex.replace(
  11666. "#version 300 es\n",
  11667. [
  11668. "#version 300 es\n",
  11669. "#extension GL_OVR_multiview2 : require",
  11670. "layout(num_views = " + numMultiviewViews + ") in;",
  11671. "#define VIEW_ID gl_ViewID_OVR"
  11672. ].join("\n")
  11673. );
  11674. prefixVertex = prefixVertex.replace(
  11675. [
  11676. "uniform mat4 modelViewMatrix;",
  11677. "uniform mat4 projectionMatrix;",
  11678. "uniform mat4 viewMatrix;",
  11679. "uniform mat3 normalMatrix;"
  11680. ].join("\n"),
  11681. [
  11682. "uniform mat4 modelViewMatrices[" + numMultiviewViews + "];",
  11683. "uniform mat4 projectionMatrices[" + numMultiviewViews + "];",
  11684. "uniform mat4 viewMatrices[" + numMultiviewViews + "];",
  11685. "uniform mat3 normalMatrices[" + numMultiviewViews + "];",
  11686. "#define modelViewMatrix modelViewMatrices[VIEW_ID]",
  11687. "#define projectionMatrix projectionMatrices[VIEW_ID]",
  11688. "#define viewMatrix viewMatrices[VIEW_ID]",
  11689. "#define normalMatrix normalMatrices[VIEW_ID]"
  11690. ].join("\n")
  11691. );
  11692. prefixFragment = prefixFragment.replace(
  11693. "#version 300 es\n",
  11694. [
  11695. "#version 300 es\n",
  11696. "#extension GL_OVR_multiview2 : require",
  11697. "#define VIEW_ID gl_ViewID_OVR"
  11698. ].join("\n")
  11699. );
  11700. prefixFragment = prefixFragment.replace(
  11701. "uniform mat4 viewMatrix;",
  11702. [
  11703. "uniform mat4 viewMatrices[" + numMultiviewViews + "];",
  11704. "#define viewMatrix viewMatrices[VIEW_ID]"
  11705. ].join("\n")
  11706. );
  11707. }
  11708. }
  11709. var vertexGlsl = prefixVertex + vertexShader;
  11710. var fragmentGlsl = prefixFragment + fragmentShader;
  11711. var glVertexShader = WebGLShader(gl, 35633, vertexGlsl);
  11712. var glFragmentShader = WebGLShader(gl, 35632, fragmentGlsl);
  11713. gl.attachShader(program, glVertexShader);
  11714. gl.attachShader(program, glFragmentShader);
  11715. if (parameters.index0AttributeName !== void 0) {
  11716. gl.bindAttribLocation(program, 0, parameters.index0AttributeName);
  11717. } else if (parameters.morphTargets === true) {
  11718. gl.bindAttribLocation(program, 0, "position");
  11719. }
  11720. gl.linkProgram(program);
  11721. if (renderer.debug.checkShaderErrors) {
  11722. var programLog = gl.getProgramInfoLog(program).trim();
  11723. var vertexLog = gl.getShaderInfoLog(glVertexShader).trim();
  11724. var fragmentLog = gl.getShaderInfoLog(glFragmentShader).trim();
  11725. var runnable = true;
  11726. var haveDiagnostics = true;
  11727. if (gl.getProgramParameter(program, 35714) === false) {
  11728. runnable = false;
  11729. var vertexErrors = getShaderErrors(gl, glVertexShader, "vertex");
  11730. var fragmentErrors = getShaderErrors(gl, glFragmentShader, "fragment");
  11731. console.error("THREE.WebGLProgram: shader error: ", gl.getError(), "35715", gl.getProgramParameter(program, 35715), "gl.getProgramInfoLog", programLog, vertexErrors, fragmentErrors);
  11732. } else if (programLog !== "") {
  11733. console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()", programLog);
  11734. } else if (vertexLog === "" || fragmentLog === "") {
  11735. haveDiagnostics = false;
  11736. }
  11737. if (haveDiagnostics) {
  11738. this.diagnostics = {
  11739. runnable,
  11740. programLog,
  11741. vertexShader: {
  11742. log: vertexLog,
  11743. prefix: prefixVertex
  11744. },
  11745. fragmentShader: {
  11746. log: fragmentLog,
  11747. prefix: prefixFragment
  11748. }
  11749. };
  11750. }
  11751. }
  11752. gl.deleteShader(glVertexShader);
  11753. gl.deleteShader(glFragmentShader);
  11754. var cachedUniforms;
  11755. this.getUniforms = function() {
  11756. if (cachedUniforms === void 0) {
  11757. cachedUniforms = new WebGLUniforms(gl, program);
  11758. }
  11759. return cachedUniforms;
  11760. };
  11761. var cachedAttributes;
  11762. this.getAttributes = function() {
  11763. if (cachedAttributes === void 0) {
  11764. cachedAttributes = fetchAttributeLocations(gl, program);
  11765. }
  11766. return cachedAttributes;
  11767. };
  11768. this.destroy = function() {
  11769. gl.deleteProgram(program);
  11770. this.program = void 0;
  11771. };
  11772. this.name = parameters.shaderName;
  11773. this.id = programIdCount++;
  11774. this.cacheKey = cacheKey;
  11775. this.usedTimes = 1;
  11776. this.program = program;
  11777. this.vertexShader = glVertexShader;
  11778. this.fragmentShader = glFragmentShader;
  11779. this.numMultiviewViews = numMultiviewViews;
  11780. return this;
  11781. }
  11782. function WebGLPrograms(renderer, extensions, capabilities) {
  11783. var programs = [];
  11784. var isWebGL2 = capabilities.isWebGL2;
  11785. var logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
  11786. var floatVertexTextures = capabilities.floatVertexTextures;
  11787. var precision = capabilities.precision;
  11788. var maxVertexUniforms = capabilities.maxVertexUniforms;
  11789. var vertexTextures = capabilities.vertexTextures;
  11790. var shaderIDs = {
  11791. MeshDepthMaterial: "depth",
  11792. MeshDistanceMaterial: "distanceRGBA",
  11793. MeshNormalMaterial: "normal",
  11794. MeshBasicMaterial: "basic",
  11795. MeshLambertMaterial: "lambert",
  11796. MeshPhongMaterial: "phong",
  11797. MeshToonMaterial: "toon",
  11798. MeshStandardMaterial: "physical",
  11799. MeshPhysicalMaterial: "physical",
  11800. MeshMatcapMaterial: "matcap",
  11801. LineBasicMaterial: "basic",
  11802. LineDashedMaterial: "dashed",
  11803. PointsMaterial: "points",
  11804. ShadowMaterial: "shadow",
  11805. SpriteMaterial: "sprite"
  11806. };
  11807. var parameterNames = [
  11808. "precision",
  11809. "isWebGL2",
  11810. "supportsVertexTextures",
  11811. "outputEncoding",
  11812. "instancing",
  11813. "numMultiviewViews",
  11814. "map",
  11815. "mapEncoding",
  11816. "matcap",
  11817. "matcapEncoding",
  11818. "envMap",
  11819. "envMapMode",
  11820. "envMapEncoding",
  11821. "envMapCubeUV",
  11822. "lightMap",
  11823. "lightMapEncoding",
  11824. "aoMap",
  11825. "emissiveMap",
  11826. "emissiveMapEncoding",
  11827. "bumpMap",
  11828. "normalMap",
  11829. "objectSpaceNormalMap",
  11830. "tangentSpaceNormalMap",
  11831. "clearcoatNormalMap",
  11832. "displacementMap",
  11833. "specularMap",
  11834. "roughnessMap",
  11835. "metalnessMap",
  11836. "gradientMap",
  11837. "alphaMap",
  11838. "combine",
  11839. "vertexColors",
  11840. "vertexTangents",
  11841. "vertexUvs",
  11842. "uvsVertexOnly",
  11843. "fog",
  11844. "useFog",
  11845. "fogExp2",
  11846. "flatShading",
  11847. "sizeAttenuation",
  11848. "logarithmicDepthBuffer",
  11849. "skinning",
  11850. "maxBones",
  11851. "useVertexTexture",
  11852. "morphTargets",
  11853. "morphNormals",
  11854. "maxMorphTargets",
  11855. "maxMorphNormals",
  11856. "premultipliedAlpha",
  11857. "numDirLights",
  11858. "numPointLights",
  11859. "numSpotLights",
  11860. "numHemiLights",
  11861. "numRectAreaLights",
  11862. "numDirLightShadows",
  11863. "numPointLightShadows",
  11864. "numSpotLightShadows",
  11865. "shadowMapEnabled",
  11866. "shadowMapType",
  11867. "toneMapping",
  11868. "physicallyCorrectLights",
  11869. "alphaTest",
  11870. "doubleSided",
  11871. "flipSided",
  11872. "numClippingPlanes",
  11873. "numClipIntersection",
  11874. "depthPacking",
  11875. "dithering",
  11876. "sheen"
  11877. ];
  11878. function getShaderObject(material, shaderID) {
  11879. var shaderobject;
  11880. if (shaderID) {
  11881. var shader = ShaderLib[shaderID];
  11882. shaderobject = {
  11883. name: material.type,
  11884. uniforms: UniformsUtils.clone(shader.uniforms),
  11885. vertexShader: shader.vertexShader,
  11886. fragmentShader: shader.fragmentShader
  11887. };
  11888. } else {
  11889. shaderobject = {
  11890. name: material.type,
  11891. uniforms: material.uniforms,
  11892. vertexShader: material.vertexShader,
  11893. fragmentShader: material.fragmentShader
  11894. };
  11895. }
  11896. return shaderobject;
  11897. }
  11898. function allocateBones(object) {
  11899. var skeleton = object.skeleton;
  11900. var bones = skeleton.bones;
  11901. if (floatVertexTextures) {
  11902. return 1024;
  11903. } else {
  11904. var nVertexUniforms = maxVertexUniforms;
  11905. var nVertexMatrices = Math.floor((nVertexUniforms - 20) / 4);
  11906. var maxBones = Math.min(nVertexMatrices, bones.length);
  11907. if (maxBones < bones.length) {
  11908. console.warn("THREE.WebGLRenderer: Skeleton has " + bones.length + " bones. This GPU supports " + maxBones + ".");
  11909. return 0;
  11910. }
  11911. return maxBones;
  11912. }
  11913. }
  11914. function getTextureEncodingFromMap(map2) {
  11915. var encoding;
  11916. if (!map2) {
  11917. encoding = LinearEncoding;
  11918. } else if (map2.isTexture) {
  11919. encoding = map2.encoding;
  11920. } else if (map2.isWebGLRenderTarget) {
  11921. console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead.");
  11922. encoding = map2.texture.encoding;
  11923. }
  11924. return encoding;
  11925. }
  11926. this.getParameters = function(material, lights, shadows, scene, nClipPlanes, nClipIntersection, object) {
  11927. var fog = scene.fog;
  11928. var environment = material.isMeshStandardMaterial ? scene.environment : null;
  11929. var envMap = material.envMap || environment;
  11930. var shaderID = shaderIDs[material.type];
  11931. var maxBones = object.isSkinnedMesh ? allocateBones(object) : 0;
  11932. if (material.precision !== null) {
  11933. precision = capabilities.getMaxPrecision(material.precision);
  11934. if (precision !== material.precision) {
  11935. console.warn("THREE.WebGLProgram.getParameters:", material.precision, "not supported, using", precision, "instead.");
  11936. }
  11937. }
  11938. var shaderobject = getShaderObject(material, shaderID);
  11939. material.onBeforeCompile(shaderobject, renderer);
  11940. var currentRenderTarget = renderer.getRenderTarget();
  11941. var numMultiviewViews = currentRenderTarget && currentRenderTarget.isWebGLMultiviewRenderTarget ? currentRenderTarget.numViews : 0;
  11942. var parameters = {
  11943. isWebGL2,
  11944. shaderID,
  11945. shaderName: shaderobject.name,
  11946. uniforms: shaderobject.uniforms,
  11947. vertexShader: shaderobject.vertexShader,
  11948. fragmentShader: shaderobject.fragmentShader,
  11949. defines: material.defines,
  11950. isRawShaderMaterial: material.isRawShaderMaterial,
  11951. isShaderMaterial: material.isShaderMaterial,
  11952. precision,
  11953. instancing: object.isInstancedMesh === true,
  11954. supportsVertexTextures: vertexTextures,
  11955. numMultiviewViews,
  11956. outputEncoding: currentRenderTarget !== null ? getTextureEncodingFromMap(currentRenderTarget.texture) : renderer.outputEncoding,
  11957. map: !!material.map,
  11958. mapEncoding: getTextureEncodingFromMap(material.map),
  11959. matcap: !!material.matcap,
  11960. matcapEncoding: getTextureEncodingFromMap(material.matcap),
  11961. envMap: !!envMap,
  11962. envMapMode: envMap && envMap.mapping,
  11963. envMapEncoding: getTextureEncodingFromMap(envMap),
  11964. envMapCubeUV: !!envMap && (envMap.mapping === CubeUVReflectionMapping || envMap.mapping === CubeUVRefractionMapping),
  11965. lightMap: !!material.lightMap,
  11966. lightMapEncoding: getTextureEncodingFromMap(material.lightMap),
  11967. aoMap: !!material.aoMap,
  11968. emissiveMap: !!material.emissiveMap,
  11969. emissiveMapEncoding: getTextureEncodingFromMap(material.emissiveMap),
  11970. bumpMap: !!material.bumpMap,
  11971. normalMap: !!material.normalMap,
  11972. objectSpaceNormalMap: material.normalMapType === ObjectSpaceNormalMap,
  11973. tangentSpaceNormalMap: material.normalMapType === TangentSpaceNormalMap,
  11974. clearcoatNormalMap: !!material.clearcoatNormalMap,
  11975. displacementMap: !!material.displacementMap,
  11976. roughnessMap: !!material.roughnessMap,
  11977. metalnessMap: !!material.metalnessMap,
  11978. specularMap: !!material.specularMap,
  11979. alphaMap: !!material.alphaMap,
  11980. gradientMap: !!material.gradientMap,
  11981. sheen: !!material.sheen,
  11982. combine: material.combine,
  11983. vertexTangents: material.normalMap && material.vertexTangents,
  11984. vertexColors: material.vertexColors,
  11985. vertexUvs: !!material.map || !!material.bumpMap || !!material.normalMap || !!material.specularMap || !!material.alphaMap || !!material.emissiveMap || !!material.roughnessMap || !!material.metalnessMap || !!material.clearcoatNormalMap || !!material.displacementMap,
  11986. uvsVertexOnly: !(!!material.map || !!material.bumpMap || !!material.normalMap || !!material.specularMap || !!material.alphaMap || !!material.emissiveMap || !!material.roughnessMap || !!material.metalnessMap || !!material.clearcoatNormalMap) && !!material.displacementMap,
  11987. fog: !!fog,
  11988. useFog: material.fog,
  11989. fogExp2: fog && fog.isFogExp2,
  11990. flatShading: material.flatShading,
  11991. sizeAttenuation: material.sizeAttenuation,
  11992. logarithmicDepthBuffer,
  11993. skinning: material.skinning && maxBones > 0,
  11994. maxBones,
  11995. useVertexTexture: floatVertexTextures,
  11996. morphTargets: material.morphTargets,
  11997. morphNormals: material.morphNormals,
  11998. maxMorphTargets: renderer.maxMorphTargets,
  11999. maxMorphNormals: renderer.maxMorphNormals,
  12000. numDirLights: lights.directional.length,
  12001. numPointLights: lights.point.length,
  12002. numSpotLights: lights.spot.length,
  12003. numRectAreaLights: lights.rectArea.length,
  12004. numHemiLights: lights.hemi.length,
  12005. numDirLightShadows: lights.directionalShadowMap.length,
  12006. numPointLightShadows: lights.pointShadowMap.length,
  12007. numSpotLightShadows: lights.spotShadowMap.length,
  12008. numClippingPlanes: nClipPlanes,
  12009. numClipIntersection: nClipIntersection,
  12010. dithering: material.dithering,
  12011. shadowMapEnabled: renderer.shadowMap.enabled && shadows.length > 0,
  12012. shadowMapType: renderer.shadowMap.type,
  12013. toneMapping: material.toneMapped ? renderer.toneMapping : NoToneMapping,
  12014. physicallyCorrectLights: renderer.physicallyCorrectLights,
  12015. premultipliedAlpha: material.premultipliedAlpha,
  12016. alphaTest: material.alphaTest,
  12017. doubleSided: material.side === DoubleSide,
  12018. flipSided: material.side === BackSide,
  12019. depthPacking: material.depthPacking !== void 0 ? material.depthPacking : false,
  12020. index0AttributeName: material.index0AttributeName,
  12021. extensionDerivatives: material.extensions && material.extensions.derivatives,
  12022. extensionFragDepth: material.extensions && material.extensions.frawbuffers,
  12023. extensionDrawbuffers: material.extensions && material.extensions.drawbuffers,
  12024. extensionShaderTextureLOD: material.extensions && material.extensions.shaderTextureLOD,
  12025. rendererExtensionFragDepth: isWebGL2 || extensions.get("EXT_frag_depth") !== null,
  12026. rendererExtensionDrawBuffers: isWebGL2 || extensions.get("WEBGL_draw_buffers") !== null,
  12027. rendererExtensionShaderTextureLod: isWebGL2 || extensions.get("EXT_shader_texture_lod") !== null,
  12028. onBeforeCompile: material.onBeforeCompile
  12029. };
  12030. return parameters;
  12031. };
  12032. this.getProgramCacheKey = function(parameters) {
  12033. var array = [];
  12034. if (parameters.shaderID) {
  12035. array.push(parameters.shaderID);
  12036. } else {
  12037. array.push(parameters.fragmentShader);
  12038. array.push(parameters.vertexShader);
  12039. }
  12040. if (parameters.defines !== void 0) {
  12041. for (var name in parameters.defines) {
  12042. array.push(name);
  12043. array.push(parameters.defines[name]);
  12044. }
  12045. }
  12046. if (parameters.isRawShaderMaterial === void 0) {
  12047. for (var i2 = 0; i2 < parameterNames.length; i2++) {
  12048. array.push(parameters[parameterNames[i2]]);
  12049. }
  12050. array.push(renderer.outputEncoding);
  12051. array.push(renderer.gammaFactor);
  12052. }
  12053. array.push(parameters.onBeforeCompile.toString());
  12054. return array.join();
  12055. };
  12056. this.acquireProgram = function(parameters, cacheKey) {
  12057. var program;
  12058. for (var p = 0, pl = programs.length; p < pl; p++) {
  12059. var preexistingProgram = programs[p];
  12060. if (preexistingProgram.cacheKey === cacheKey) {
  12061. program = preexistingProgram;
  12062. ++program.usedTimes;
  12063. break;
  12064. }
  12065. }
  12066. if (program === void 0) {
  12067. program = new WebGLProgram(renderer, cacheKey, parameters);
  12068. programs.push(program);
  12069. }
  12070. return program;
  12071. };
  12072. this.releaseProgram = function(program) {
  12073. if (--program.usedTimes === 0) {
  12074. var i2 = programs.indexOf(program);
  12075. programs[i2] = programs[programs.length - 1];
  12076. programs.pop();
  12077. program.destroy();
  12078. }
  12079. };
  12080. this.programs = programs;
  12081. }
  12082. function WebGLProperties() {
  12083. var properties = /* @__PURE__ */ new WeakMap();
  12084. function get(object) {
  12085. var map2 = properties.get(object);
  12086. if (map2 === void 0) {
  12087. map2 = {};
  12088. properties.set(object, map2);
  12089. }
  12090. return map2;
  12091. }
  12092. function remove(object) {
  12093. properties.delete(object);
  12094. }
  12095. function update(object, key, value) {
  12096. properties.get(object)[key] = value;
  12097. }
  12098. function dispose() {
  12099. properties = /* @__PURE__ */ new WeakMap();
  12100. }
  12101. return {
  12102. get,
  12103. remove,
  12104. update,
  12105. dispose
  12106. };
  12107. }
  12108. function painterSortStable(a, b) {
  12109. if (a.groupOrder !== b.groupOrder) {
  12110. return a.groupOrder - b.groupOrder;
  12111. } else if (a.renderOrder !== b.renderOrder) {
  12112. return a.renderOrder - b.renderOrder;
  12113. } else if (a.program !== b.program) {
  12114. return a.program.id - b.program.id;
  12115. } else if (a.material.id !== b.material.id) {
  12116. return a.material.id - b.material.id;
  12117. } else if (a.z !== b.z) {
  12118. return a.z - b.z;
  12119. } else {
  12120. return a.id - b.id;
  12121. }
  12122. }
  12123. function reversePainterSortStable(a, b) {
  12124. if (a.groupOrder !== b.groupOrder) {
  12125. return a.groupOrder - b.groupOrder;
  12126. } else if (a.renderOrder !== b.renderOrder) {
  12127. return a.renderOrder - b.renderOrder;
  12128. } else if (a.z !== b.z) {
  12129. return b.z - a.z;
  12130. } else {
  12131. return a.id - b.id;
  12132. }
  12133. }
  12134. function WebGLRenderList() {
  12135. var renderItems = [];
  12136. var renderItemsIndex = 0;
  12137. var opaque = [];
  12138. var transparent = [];
  12139. var defaultProgram = { id: -1 };
  12140. function init2() {
  12141. renderItemsIndex = 0;
  12142. opaque.length = 0;
  12143. transparent.length = 0;
  12144. }
  12145. function getNextRenderItem(object, geometry, material, groupOrder, z, group) {
  12146. var renderItem = renderItems[renderItemsIndex];
  12147. if (renderItem === void 0) {
  12148. renderItem = {
  12149. id: object.id,
  12150. object,
  12151. geometry,
  12152. material,
  12153. program: material.program || defaultProgram,
  12154. groupOrder,
  12155. renderOrder: object.renderOrder,
  12156. z,
  12157. group
  12158. };
  12159. renderItems[renderItemsIndex] = renderItem;
  12160. } else {
  12161. renderItem.id = object.id;
  12162. renderItem.object = object;
  12163. renderItem.geometry = geometry;
  12164. renderItem.material = material;
  12165. renderItem.program = material.program || defaultProgram;
  12166. renderItem.groupOrder = groupOrder;
  12167. renderItem.renderOrder = object.renderOrder;
  12168. renderItem.z = z;
  12169. renderItem.group = group;
  12170. }
  12171. renderItemsIndex++;
  12172. return renderItem;
  12173. }
  12174. function push(object, geometry, material, groupOrder, z, group) {
  12175. var renderItem = getNextRenderItem(object, geometry, material, groupOrder, z, group);
  12176. (material.transparent === true ? transparent : opaque).push(renderItem);
  12177. }
  12178. function unshift(object, geometry, material, groupOrder, z, group) {
  12179. var renderItem = getNextRenderItem(object, geometry, material, groupOrder, z, group);
  12180. (material.transparent === true ? transparent : opaque).unshift(renderItem);
  12181. }
  12182. function sort(customOpaqueSort, customTransparentSort) {
  12183. if (opaque.length > 1)
  12184. opaque.sort(customOpaqueSort || painterSortStable);
  12185. if (transparent.length > 1)
  12186. transparent.sort(customTransparentSort || reversePainterSortStable);
  12187. }
  12188. return {
  12189. opaque,
  12190. transparent,
  12191. init: init2,
  12192. push,
  12193. unshift,
  12194. sort
  12195. };
  12196. }
  12197. function WebGLRenderLists() {
  12198. var lists = /* @__PURE__ */ new WeakMap();
  12199. function onSceneDispose(event) {
  12200. var scene = event.target;
  12201. scene.removeEventListener("dispose", onSceneDispose);
  12202. lists.delete(scene);
  12203. }
  12204. function get(scene, camera) {
  12205. var cameras = lists.get(scene);
  12206. var list;
  12207. if (cameras === void 0) {
  12208. list = new WebGLRenderList();
  12209. lists.set(scene, /* @__PURE__ */ new WeakMap());
  12210. lists.get(scene).set(camera, list);
  12211. scene.addEventListener("dispose", onSceneDispose);
  12212. } else {
  12213. list = cameras.get(camera);
  12214. if (list === void 0) {
  12215. list = new WebGLRenderList();
  12216. cameras.set(camera, list);
  12217. }
  12218. }
  12219. return list;
  12220. }
  12221. function dispose() {
  12222. lists = /* @__PURE__ */ new WeakMap();
  12223. }
  12224. return {
  12225. get,
  12226. dispose
  12227. };
  12228. }
  12229. function UniformsCache() {
  12230. var lights = {};
  12231. return {
  12232. get: function(light) {
  12233. if (lights[light.id] !== void 0) {
  12234. return lights[light.id];
  12235. }
  12236. var uniforms;
  12237. switch (light.type) {
  12238. case "DirectionalLight":
  12239. uniforms = {
  12240. direction: new Vector3(),
  12241. color: new Color(),
  12242. shadow: false,
  12243. shadowBias: 0,
  12244. shadowRadius: 1,
  12245. shadowMapSize: new Vector2()
  12246. };
  12247. break;
  12248. case "SpotLight":
  12249. uniforms = {
  12250. position: new Vector3(),
  12251. direction: new Vector3(),
  12252. color: new Color(),
  12253. distance: 0,
  12254. coneCos: 0,
  12255. penumbraCos: 0,
  12256. decay: 0,
  12257. shadow: false,
  12258. shadowBias: 0,
  12259. shadowRadius: 1,
  12260. shadowMapSize: new Vector2()
  12261. };
  12262. break;
  12263. case "PointLight":
  12264. uniforms = {
  12265. position: new Vector3(),
  12266. color: new Color(),
  12267. distance: 0,
  12268. decay: 0,
  12269. shadow: false,
  12270. shadowBias: 0,
  12271. shadowRadius: 1,
  12272. shadowMapSize: new Vector2(),
  12273. shadowCameraNear: 1,
  12274. shadowCameraFar: 1e3
  12275. };
  12276. break;
  12277. case "HemisphereLight":
  12278. uniforms = {
  12279. direction: new Vector3(),
  12280. skyColor: new Color(),
  12281. groundColor: new Color()
  12282. };
  12283. break;
  12284. case "RectAreaLight":
  12285. uniforms = {
  12286. color: new Color(),
  12287. position: new Vector3(),
  12288. halfWidth: new Vector3(),
  12289. halfHeight: new Vector3()
  12290. // TODO (abelnation): set RectAreaLight shadow uniforms
  12291. };
  12292. break;
  12293. }
  12294. lights[light.id] = uniforms;
  12295. return uniforms;
  12296. }
  12297. };
  12298. }
  12299. var nextVersion = 0;
  12300. function shadowCastingLightsFirst(lightA, lightB) {
  12301. return (lightB.castShadow ? 1 : 0) - (lightA.castShadow ? 1 : 0);
  12302. }
  12303. function WebGLLights() {
  12304. var cache = new UniformsCache();
  12305. var state = {
  12306. version: 0,
  12307. hash: {
  12308. directionalLength: -1,
  12309. pointLength: -1,
  12310. spotLength: -1,
  12311. rectAreaLength: -1,
  12312. hemiLength: -1,
  12313. numDirectionalShadows: -1,
  12314. numPointShadows: -1,
  12315. numSpotShadows: -1
  12316. },
  12317. ambient: [0, 0, 0],
  12318. probe: [],
  12319. directional: [],
  12320. directionalShadowMap: [],
  12321. directionalShadowMatrix: [],
  12322. spot: [],
  12323. spotShadowMap: [],
  12324. spotShadowMatrix: [],
  12325. rectArea: [],
  12326. point: [],
  12327. pointShadowMap: [],
  12328. pointShadowMatrix: [],
  12329. hemi: [],
  12330. numDirectionalShadows: -1,
  12331. numPointShadows: -1,
  12332. numSpotShadows: -1
  12333. };
  12334. for (var i2 = 0; i2 < 9; i2++)
  12335. state.probe.push(new Vector3());
  12336. var vector3 = new Vector3();
  12337. var matrix4 = new Matrix4();
  12338. var matrix42 = new Matrix4();
  12339. function setup(lights, shadows, camera) {
  12340. var r = 0, g = 0, b = 0;
  12341. for (var i3 = 0; i3 < 9; i3++)
  12342. state.probe[i3].set(0, 0, 0);
  12343. var directionalLength = 0;
  12344. var pointLength = 0;
  12345. var spotLength = 0;
  12346. var rectAreaLength = 0;
  12347. var hemiLength = 0;
  12348. var numDirectionalShadows = 0;
  12349. var numPointShadows = 0;
  12350. var numSpotShadows = 0;
  12351. var viewMatrix = camera.matrixWorldInverse;
  12352. lights.sort(shadowCastingLightsFirst);
  12353. for (var i3 = 0, l = lights.length; i3 < l; i3++) {
  12354. var light = lights[i3];
  12355. var color = light.color;
  12356. var intensity = light.intensity;
  12357. var distance = light.distance;
  12358. var shadowMap = light.shadow && light.shadow.map ? light.shadow.map.texture : null;
  12359. if (light.isAmbientLight) {
  12360. r += color.r * intensity;
  12361. g += color.g * intensity;
  12362. b += color.b * intensity;
  12363. } else if (light.isLightProbe) {
  12364. for (var j = 0; j < 9; j++) {
  12365. state.probe[j].addScaledVector(light.sh.coefficients[j], intensity);
  12366. }
  12367. } else if (light.isDirectionalLight) {
  12368. var uniforms = cache.get(light);
  12369. uniforms.color.copy(light.color).multiplyScalar(light.intensity);
  12370. uniforms.direction.setFromMatrixPosition(light.matrixWorld);
  12371. vector3.setFromMatrixPosition(light.target.matrixWorld);
  12372. uniforms.direction.sub(vector3);
  12373. uniforms.direction.transformDirection(viewMatrix);
  12374. uniforms.shadow = light.castShadow;
  12375. if (light.castShadow) {
  12376. var shadow = light.shadow;
  12377. uniforms.shadowBias = shadow.bias;
  12378. uniforms.shadowRadius = shadow.radius;
  12379. uniforms.shadowMapSize = shadow.mapSize;
  12380. state.directionalShadowMap[directionalLength] = shadowMap;
  12381. state.directionalShadowMatrix[directionalLength] = light.shadow.matrix;
  12382. numDirectionalShadows++;
  12383. }
  12384. state.directional[directionalLength] = uniforms;
  12385. directionalLength++;
  12386. } else if (light.isSpotLight) {
  12387. var uniforms = cache.get(light);
  12388. uniforms.position.setFromMatrixPosition(light.matrixWorld);
  12389. uniforms.position.applyMatrix4(viewMatrix);
  12390. uniforms.color.copy(color).multiplyScalar(intensity);
  12391. uniforms.distance = distance;
  12392. uniforms.direction.setFromMatrixPosition(light.matrixWorld);
  12393. vector3.setFromMatrixPosition(light.target.matrixWorld);
  12394. uniforms.direction.sub(vector3);
  12395. uniforms.direction.transformDirection(viewMatrix);
  12396. uniforms.coneCos = Math.cos(light.angle);
  12397. uniforms.penumbraCos = Math.cos(light.angle * (1 - light.penumbra));
  12398. uniforms.decay = light.decay;
  12399. uniforms.shadow = light.castShadow;
  12400. if (light.castShadow) {
  12401. var shadow = light.shadow;
  12402. uniforms.shadowBias = shadow.bias;
  12403. uniforms.shadowRadius = shadow.radius;
  12404. uniforms.shadowMapSize = shadow.mapSize;
  12405. state.spotShadowMap[spotLength] = shadowMap;
  12406. state.spotShadowMatrix[spotLength] = light.shadow.matrix;
  12407. numSpotShadows++;
  12408. }
  12409. state.spot[spotLength] = uniforms;
  12410. spotLength++;
  12411. } else if (light.isRectAreaLight) {
  12412. var uniforms = cache.get(light);
  12413. uniforms.color.copy(color).multiplyScalar(intensity);
  12414. uniforms.position.setFromMatrixPosition(light.matrixWorld);
  12415. uniforms.position.applyMatrix4(viewMatrix);
  12416. matrix42.identity();
  12417. matrix4.copy(light.matrixWorld);
  12418. matrix4.premultiply(viewMatrix);
  12419. matrix42.extractRotation(matrix4);
  12420. uniforms.halfWidth.set(light.width * 0.5, 0, 0);
  12421. uniforms.halfHeight.set(0, light.height * 0.5, 0);
  12422. uniforms.halfWidth.applyMatrix4(matrix42);
  12423. uniforms.halfHeight.applyMatrix4(matrix42);
  12424. state.rectArea[rectAreaLength] = uniforms;
  12425. rectAreaLength++;
  12426. } else if (light.isPointLight) {
  12427. var uniforms = cache.get(light);
  12428. uniforms.position.setFromMatrixPosition(light.matrixWorld);
  12429. uniforms.position.applyMatrix4(viewMatrix);
  12430. uniforms.color.copy(light.color).multiplyScalar(light.intensity);
  12431. uniforms.distance = light.distance;
  12432. uniforms.decay = light.decay;
  12433. uniforms.shadow = light.castShadow;
  12434. if (light.castShadow) {
  12435. var shadow = light.shadow;
  12436. uniforms.shadowBias = shadow.bias;
  12437. uniforms.shadowRadius = shadow.radius;
  12438. uniforms.shadowMapSize = shadow.mapSize;
  12439. uniforms.shadowCameraNear = shadow.camera.near;
  12440. uniforms.shadowCameraFar = shadow.camera.far;
  12441. state.pointShadowMap[pointLength] = shadowMap;
  12442. state.pointShadowMatrix[pointLength] = light.shadow.matrix;
  12443. numPointShadows++;
  12444. }
  12445. state.point[pointLength] = uniforms;
  12446. pointLength++;
  12447. } else if (light.isHemisphereLight) {
  12448. var uniforms = cache.get(light);
  12449. uniforms.direction.setFromMatrixPosition(light.matrixWorld);
  12450. uniforms.direction.transformDirection(viewMatrix);
  12451. uniforms.direction.normalize();
  12452. uniforms.skyColor.copy(light.color).multiplyScalar(intensity);
  12453. uniforms.groundColor.copy(light.groundColor).multiplyScalar(intensity);
  12454. state.hemi[hemiLength] = uniforms;
  12455. hemiLength++;
  12456. }
  12457. }
  12458. state.ambient[0] = r;
  12459. state.ambient[1] = g;
  12460. state.ambient[2] = b;
  12461. var hash = state.hash;
  12462. if (hash.directionalLength !== directionalLength || hash.pointLength !== pointLength || hash.spotLength !== spotLength || hash.rectAreaLength !== rectAreaLength || hash.hemiLength !== hemiLength || hash.numDirectionalShadows !== numDirectionalShadows || hash.numPointShadows !== numPointShadows || hash.numSpotShadows !== numSpotShadows) {
  12463. state.directional.length = directionalLength;
  12464. state.spot.length = spotLength;
  12465. state.rectArea.length = rectAreaLength;
  12466. state.point.length = pointLength;
  12467. state.hemi.length = hemiLength;
  12468. state.directionalShadowMap.length = numDirectionalShadows;
  12469. state.pointShadowMap.length = numPointShadows;
  12470. state.spotShadowMap.length = numSpotShadows;
  12471. state.directionalShadowMatrix.length = numDirectionalShadows;
  12472. state.pointShadowMatrix.length = numPointShadows;
  12473. state.spotShadowMatrix.length = numSpotShadows;
  12474. hash.directionalLength = directionalLength;
  12475. hash.pointLength = pointLength;
  12476. hash.spotLength = spotLength;
  12477. hash.rectAreaLength = rectAreaLength;
  12478. hash.hemiLength = hemiLength;
  12479. hash.numDirectionalShadows = numDirectionalShadows;
  12480. hash.numPointShadows = numPointShadows;
  12481. hash.numSpotShadows = numSpotShadows;
  12482. state.version = nextVersion++;
  12483. }
  12484. }
  12485. return {
  12486. setup,
  12487. state
  12488. };
  12489. }
  12490. function WebGLRenderState() {
  12491. var lights = new WebGLLights();
  12492. var lightsArray = [];
  12493. var shadowsArray = [];
  12494. function init2() {
  12495. lightsArray.length = 0;
  12496. shadowsArray.length = 0;
  12497. }
  12498. function pushLight(light) {
  12499. lightsArray.push(light);
  12500. }
  12501. function pushShadow(shadowLight) {
  12502. shadowsArray.push(shadowLight);
  12503. }
  12504. function setupLights(camera) {
  12505. lights.setup(lightsArray, shadowsArray, camera);
  12506. }
  12507. var state = {
  12508. lightsArray,
  12509. shadowsArray,
  12510. lights
  12511. };
  12512. return {
  12513. init: init2,
  12514. state,
  12515. setupLights,
  12516. pushLight,
  12517. pushShadow
  12518. };
  12519. }
  12520. function WebGLRenderStates() {
  12521. var renderStates = /* @__PURE__ */ new WeakMap();
  12522. function onSceneDispose(event) {
  12523. var scene = event.target;
  12524. scene.removeEventListener("dispose", onSceneDispose);
  12525. renderStates.delete(scene);
  12526. }
  12527. function get(scene, camera) {
  12528. var renderState;
  12529. if (renderStates.has(scene) === false) {
  12530. renderState = new WebGLRenderState();
  12531. renderStates.set(scene, /* @__PURE__ */ new WeakMap());
  12532. renderStates.get(scene).set(camera, renderState);
  12533. scene.addEventListener("dispose", onSceneDispose);
  12534. } else {
  12535. if (renderStates.get(scene).has(camera) === false) {
  12536. renderState = new WebGLRenderState();
  12537. renderStates.get(scene).set(camera, renderState);
  12538. } else {
  12539. renderState = renderStates.get(scene).get(camera);
  12540. }
  12541. }
  12542. return renderState;
  12543. }
  12544. function dispose() {
  12545. renderStates = /* @__PURE__ */ new WeakMap();
  12546. }
  12547. return {
  12548. get,
  12549. dispose
  12550. };
  12551. }
  12552. function MeshDepthMaterial(parameters) {
  12553. Material.call(this);
  12554. this.type = "MeshDepthMaterial";
  12555. this.depthPacking = BasicDepthPacking;
  12556. this.skinning = false;
  12557. this.morphTargets = false;
  12558. this.map = null;
  12559. this.alphaMap = null;
  12560. this.displacementMap = null;
  12561. this.displacementScale = 1;
  12562. this.displacementBias = 0;
  12563. this.wireframe = false;
  12564. this.wireframeLinewidth = 1;
  12565. this.fog = false;
  12566. this.setValues(parameters);
  12567. }
  12568. MeshDepthMaterial.prototype = Object.create(Material.prototype);
  12569. MeshDepthMaterial.prototype.constructor = MeshDepthMaterial;
  12570. MeshDepthMaterial.prototype.isMeshDepthMaterial = true;
  12571. MeshDepthMaterial.prototype.copy = function(source) {
  12572. Material.prototype.copy.call(this, source);
  12573. this.depthPacking = source.depthPacking;
  12574. this.skinning = source.skinning;
  12575. this.morphTargets = source.morphTargets;
  12576. this.map = source.map;
  12577. this.alphaMap = source.alphaMap;
  12578. this.displacementMap = source.displacementMap;
  12579. this.displacementScale = source.displacementScale;
  12580. this.displacementBias = source.displacementBias;
  12581. this.wireframe = source.wireframe;
  12582. this.wireframeLinewidth = source.wireframeLinewidth;
  12583. return this;
  12584. };
  12585. function MeshDistanceMaterial(parameters) {
  12586. Material.call(this);
  12587. this.type = "MeshDistanceMaterial";
  12588. this.referencePosition = new Vector3();
  12589. this.nearDistance = 1;
  12590. this.farDistance = 1e3;
  12591. this.skinning = false;
  12592. this.morphTargets = false;
  12593. this.map = null;
  12594. this.alphaMap = null;
  12595. this.displacementMap = null;
  12596. this.displacementScale = 1;
  12597. this.displacementBias = 0;
  12598. this.fog = false;
  12599. this.setValues(parameters);
  12600. }
  12601. MeshDistanceMaterial.prototype = Object.create(Material.prototype);
  12602. MeshDistanceMaterial.prototype.constructor = MeshDistanceMaterial;
  12603. MeshDistanceMaterial.prototype.isMeshDistanceMaterial = true;
  12604. MeshDistanceMaterial.prototype.copy = function(source) {
  12605. Material.prototype.copy.call(this, source);
  12606. this.referencePosition.copy(source.referencePosition);
  12607. this.nearDistance = source.nearDistance;
  12608. this.farDistance = source.farDistance;
  12609. this.skinning = source.skinning;
  12610. this.morphTargets = source.morphTargets;
  12611. this.map = source.map;
  12612. this.alphaMap = source.alphaMap;
  12613. this.displacementMap = source.displacementMap;
  12614. this.displacementScale = source.displacementScale;
  12615. this.displacementBias = source.displacementBias;
  12616. return this;
  12617. };
  12618. var vsm_frag = "uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n float mean = 0.0;\n float squared_mean = 0.0;\n float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n #ifdef HORIZONAL_PASS\n vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n #else\n float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n mean += depth;\n squared_mean += depth * depth;\n #endif\n }\n mean = mean * HALF_SAMPLE_RATE;\n squared_mean = squared_mean * HALF_SAMPLE_RATE;\n float std_dev = sqrt( squared_mean - mean * mean );\n gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}";
  12619. var vsm_vert = "void main() {\n gl_Position = vec4( position, 1.0 );\n}";
  12620. function WebGLShadowMap(_renderer2, _objects, maxTextureSize) {
  12621. var _frustum = new Frustum(), _shadowMapSize = new Vector2(), _viewportSize = new Vector2(), _viewport = new Vector4(), _depthMaterials = [], _distanceMaterials = [], _materialCache = {};
  12622. var shadowSide = { 0: BackSide, 1: FrontSide, 2: DoubleSide };
  12623. var shadowMaterialVertical = new ShaderMaterial({
  12624. defines: {
  12625. SAMPLE_RATE: 2 / 8,
  12626. HALF_SAMPLE_RATE: 1 / 8
  12627. },
  12628. uniforms: {
  12629. shadow_pass: { value: null },
  12630. resolution: { value: new Vector2() },
  12631. radius: { value: 4 }
  12632. },
  12633. vertexShader: vsm_vert,
  12634. fragmentShader: vsm_frag
  12635. });
  12636. var shadowMaterialHorizonal = shadowMaterialVertical.clone();
  12637. shadowMaterialHorizonal.defines.HORIZONAL_PASS = 1;
  12638. var fullScreenTri = new BufferGeometry();
  12639. fullScreenTri.setAttribute(
  12640. "position",
  12641. new BufferAttribute(
  12642. new Float32Array([-1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5]),
  12643. 3
  12644. )
  12645. );
  12646. var fullScreenMesh = new Mesh(fullScreenTri, shadowMaterialVertical);
  12647. var scope = this;
  12648. this.enabled = false;
  12649. this.autoUpdate = true;
  12650. this.needsUpdate = false;
  12651. this.type = PCFShadowMap;
  12652. this.render = function(lights, scene, camera) {
  12653. if (scope.enabled === false)
  12654. return;
  12655. if (scope.autoUpdate === false && scope.needsUpdate === false)
  12656. return;
  12657. if (lights.length === 0)
  12658. return;
  12659. var currentRenderTarget = _renderer2.getRenderTarget();
  12660. var activeCubeFace = _renderer2.getActiveCubeFace();
  12661. var activeMipmapLevel = _renderer2.getActiveMipmapLevel();
  12662. var _state = _renderer2.state;
  12663. _state.setBlending(NoBlending);
  12664. _state.buffers.color.setClear(1, 1, 1, 1);
  12665. _state.buffers.depth.setTest(true);
  12666. _state.setScissorTest(false);
  12667. for (var i2 = 0, il = lights.length; i2 < il; i2++) {
  12668. var light = lights[i2];
  12669. var shadow = light.shadow;
  12670. if (shadow === void 0) {
  12671. console.warn("THREE.WebGLShadowMap:", light, "has no shadow.");
  12672. continue;
  12673. }
  12674. _shadowMapSize.copy(shadow.mapSize);
  12675. var shadowFrameExtents = shadow.getFrameExtents();
  12676. _shadowMapSize.multiply(shadowFrameExtents);
  12677. _viewportSize.copy(shadow.mapSize);
  12678. if (_shadowMapSize.x > maxTextureSize || _shadowMapSize.y > maxTextureSize) {
  12679. console.warn("THREE.WebGLShadowMap:", light, "has shadow exceeding max texture size, reducing");
  12680. if (_shadowMapSize.x > maxTextureSize) {
  12681. _viewportSize.x = Math.floor(maxTextureSize / shadowFrameExtents.x);
  12682. _shadowMapSize.x = _viewportSize.x * shadowFrameExtents.x;
  12683. shadow.mapSize.x = _viewportSize.x;
  12684. }
  12685. if (_shadowMapSize.y > maxTextureSize) {
  12686. _viewportSize.y = Math.floor(maxTextureSize / shadowFrameExtents.y);
  12687. _shadowMapSize.y = _viewportSize.y * shadowFrameExtents.y;
  12688. shadow.mapSize.y = _viewportSize.y;
  12689. }
  12690. }
  12691. if (shadow.map === null && !shadow.isPointLightShadow && this.type === VSMShadowMap) {
  12692. var pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat };
  12693. shadow.map = new WebGLRenderTarget(_shadowMapSize.x, _shadowMapSize.y, pars);
  12694. shadow.map.texture.name = light.name + ".shadowMap";
  12695. shadow.mapPass = new WebGLRenderTarget(_shadowMapSize.x, _shadowMapSize.y, pars);
  12696. shadow.camera.updateProjectionMatrix();
  12697. }
  12698. if (shadow.map === null) {
  12699. var pars = { minFilter: NearestFilter, magFilter: NearestFilter, format: RGBAFormat };
  12700. shadow.map = new WebGLRenderTarget(_shadowMapSize.x, _shadowMapSize.y, pars);
  12701. shadow.map.texture.name = light.name + ".shadowMap";
  12702. shadow.camera.updateProjectionMatrix();
  12703. }
  12704. _renderer2.setRenderTarget(shadow.map);
  12705. _renderer2.clear();
  12706. var viewportCount = shadow.getViewportCount();
  12707. for (var vp = 0; vp < viewportCount; vp++) {
  12708. var viewport = shadow.getViewport(vp);
  12709. _viewport.set(
  12710. _viewportSize.x * viewport.x,
  12711. _viewportSize.y * viewport.y,
  12712. _viewportSize.x * viewport.z,
  12713. _viewportSize.y * viewport.w
  12714. );
  12715. _state.viewport(_viewport);
  12716. shadow.updateMatrices(light, vp);
  12717. _frustum = shadow.getFrustum();
  12718. renderObject(scene, camera, shadow.camera, light, this.type);
  12719. }
  12720. if (!shadow.isPointLightShadow && this.type === VSMShadowMap) {
  12721. VSMPass(shadow, camera);
  12722. }
  12723. }
  12724. scope.needsUpdate = false;
  12725. _renderer2.setRenderTarget(currentRenderTarget, activeCubeFace, activeMipmapLevel);
  12726. };
  12727. function VSMPass(shadow, camera) {
  12728. var geometry = _objects.update(fullScreenMesh);
  12729. shadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture;
  12730. shadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;
  12731. shadowMaterialVertical.uniforms.radius.value = shadow.radius;
  12732. _renderer2.setRenderTarget(shadow.mapPass);
  12733. _renderer2.clear();
  12734. _renderer2.renderBufferDirect(camera, null, geometry, shadowMaterialVertical, fullScreenMesh, null);
  12735. shadowMaterialHorizonal.uniforms.shadow_pass.value = shadow.mapPass.texture;
  12736. shadowMaterialHorizonal.uniforms.resolution.value = shadow.mapSize;
  12737. shadowMaterialHorizonal.uniforms.radius.value = shadow.radius;
  12738. _renderer2.setRenderTarget(shadow.map);
  12739. _renderer2.clear();
  12740. _renderer2.renderBufferDirect(camera, null, geometry, shadowMaterialHorizonal, fullScreenMesh, null);
  12741. }
  12742. function getDepthMaterialVariant(useMorphing, useSkinning, useInstancing) {
  12743. var index = useMorphing << 0 | useSkinning << 1 | useInstancing << 2;
  12744. var material = _depthMaterials[index];
  12745. if (material === void 0) {
  12746. material = new MeshDepthMaterial({
  12747. depthPacking: RGBADepthPacking,
  12748. morphTargets: useMorphing,
  12749. skinning: useSkinning
  12750. });
  12751. _depthMaterials[index] = material;
  12752. }
  12753. return material;
  12754. }
  12755. function getDistanceMaterialVariant(useMorphing, useSkinning, useInstancing) {
  12756. var index = useMorphing << 0 | useSkinning << 1 | useInstancing << 2;
  12757. var material = _distanceMaterials[index];
  12758. if (material === void 0) {
  12759. material = new MeshDistanceMaterial({
  12760. morphTargets: useMorphing,
  12761. skinning: useSkinning
  12762. });
  12763. _distanceMaterials[index] = material;
  12764. }
  12765. return material;
  12766. }
  12767. function getDepthMaterial(object, material, light, shadowCameraNear, shadowCameraFar, type) {
  12768. var geometry = object.geometry;
  12769. var result = null;
  12770. var getMaterialVariant = getDepthMaterialVariant;
  12771. var customMaterial = object.customDepthMaterial;
  12772. if (light.isPointLight === true) {
  12773. getMaterialVariant = getDistanceMaterialVariant;
  12774. customMaterial = object.customDistanceMaterial;
  12775. }
  12776. if (customMaterial === void 0) {
  12777. var useMorphing = false;
  12778. if (material.morphTargets === true) {
  12779. if (geometry.isBufferGeometry === true) {
  12780. useMorphing = geometry.morphAttributes && geometry.morphAttributes.position && geometry.morphAttributes.position.length > 0;
  12781. } else if (geometry.isGeometry === true) {
  12782. useMorphing = geometry.morphTargets && geometry.morphTargets.length > 0;
  12783. }
  12784. }
  12785. var useSkinning = false;
  12786. if (object.isSkinnedMesh === true) {
  12787. if (material.skinning === true) {
  12788. useSkinning = true;
  12789. } else {
  12790. console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:", object);
  12791. }
  12792. }
  12793. var useInstancing = object.isInstancedMesh === true;
  12794. result = getMaterialVariant(useMorphing, useSkinning, useInstancing);
  12795. } else {
  12796. result = customMaterial;
  12797. }
  12798. if (_renderer2.localClippingEnabled && material.clipShadows === true && material.clippingPlanes.length !== 0) {
  12799. var keyA = result.uuid, keyB = material.uuid;
  12800. var materialsForVariant = _materialCache[keyA];
  12801. if (materialsForVariant === void 0) {
  12802. materialsForVariant = {};
  12803. _materialCache[keyA] = materialsForVariant;
  12804. }
  12805. var cachedMaterial = materialsForVariant[keyB];
  12806. if (cachedMaterial === void 0) {
  12807. cachedMaterial = result.clone();
  12808. materialsForVariant[keyB] = cachedMaterial;
  12809. }
  12810. result = cachedMaterial;
  12811. }
  12812. result.visible = material.visible;
  12813. result.wireframe = material.wireframe;
  12814. if (type === VSMShadowMap) {
  12815. result.side = material.shadowSide !== null ? material.shadowSide : material.side;
  12816. } else {
  12817. result.side = material.shadowSide !== null ? material.shadowSide : shadowSide[material.side];
  12818. }
  12819. result.clipShadows = material.clipShadows;
  12820. result.clippingPlanes = material.clippingPlanes;
  12821. result.clipIntersection = material.clipIntersection;
  12822. result.wireframeLinewidth = material.wireframeLinewidth;
  12823. result.linewidth = material.linewidth;
  12824. if (light.isPointLight === true && result.isMeshDistanceMaterial === true) {
  12825. result.referencePosition.setFromMatrixPosition(light.matrixWorld);
  12826. result.nearDistance = shadowCameraNear;
  12827. result.farDistance = shadowCameraFar;
  12828. }
  12829. return result;
  12830. }
  12831. function renderObject(object, camera, shadowCamera, light, type) {
  12832. if (object.visible === false)
  12833. return;
  12834. var visible = object.layers.test(camera.layers);
  12835. if (visible && (object.isMesh || object.isLine || object.isPoints)) {
  12836. if ((object.castShadow || object.receiveShadow && type === VSMShadowMap) && (!object.frustumCulled || _frustum.intersectsObject(object))) {
  12837. object.modelViewMatrix.multiplyMatrices(shadowCamera.matrixWorldInverse, object.matrixWorld);
  12838. var geometry = _objects.update(object);
  12839. var material = object.material;
  12840. if (Array.isArray(material)) {
  12841. var groups = geometry.groups;
  12842. for (var k = 0, kl = groups.length; k < kl; k++) {
  12843. var group = groups[k];
  12844. var groupMaterial = material[group.materialIndex];
  12845. if (groupMaterial && groupMaterial.visible) {
  12846. var depthMaterial = getDepthMaterial(object, groupMaterial, light, shadowCamera.near, shadowCamera.far, type);
  12847. _renderer2.renderBufferDirect(shadowCamera, null, geometry, depthMaterial, object, group);
  12848. }
  12849. }
  12850. } else if (material.visible) {
  12851. var depthMaterial = getDepthMaterial(object, material, light, shadowCamera.near, shadowCamera.far, type);
  12852. _renderer2.renderBufferDirect(shadowCamera, null, geometry, depthMaterial, object, null);
  12853. }
  12854. }
  12855. }
  12856. var children = object.children;
  12857. for (var i2 = 0, l = children.length; i2 < l; i2++) {
  12858. renderObject(children[i2], camera, shadowCamera, light, type);
  12859. }
  12860. }
  12861. }
  12862. function WebGLState(gl, extensions, capabilities) {
  12863. var isWebGL2 = capabilities.isWebGL2;
  12864. function ColorBuffer() {
  12865. var locked = false;
  12866. var color = new Vector4();
  12867. var currentColorMask = null;
  12868. var currentColorClear = new Vector4(0, 0, 0, 0);
  12869. return {
  12870. setMask: function(colorMask) {
  12871. if (currentColorMask !== colorMask && !locked) {
  12872. gl.colorMask(colorMask, colorMask, colorMask, colorMask);
  12873. currentColorMask = colorMask;
  12874. }
  12875. },
  12876. setLocked: function(lock) {
  12877. locked = lock;
  12878. },
  12879. setClear: function(r, g, b, a, premultipliedAlpha) {
  12880. if (premultipliedAlpha === true) {
  12881. r *= a;
  12882. g *= a;
  12883. b *= a;
  12884. }
  12885. color.set(r, g, b, a);
  12886. if (currentColorClear.equals(color) === false) {
  12887. gl.clearColor(r, g, b, a);
  12888. currentColorClear.copy(color);
  12889. }
  12890. },
  12891. reset: function() {
  12892. locked = false;
  12893. currentColorMask = null;
  12894. currentColorClear.set(-1, 0, 0, 0);
  12895. }
  12896. };
  12897. }
  12898. function DepthBuffer() {
  12899. var locked = false;
  12900. var currentDepthMask = null;
  12901. var currentDepthFunc = null;
  12902. var currentDepthClear = null;
  12903. return {
  12904. setTest: function(depthTest) {
  12905. if (depthTest) {
  12906. enable(2929);
  12907. } else {
  12908. disable(2929);
  12909. }
  12910. },
  12911. setMask: function(depthMask) {
  12912. if (currentDepthMask !== depthMask && !locked) {
  12913. gl.depthMask(depthMask);
  12914. currentDepthMask = depthMask;
  12915. }
  12916. },
  12917. setFunc: function(depthFunc) {
  12918. if (currentDepthFunc !== depthFunc) {
  12919. if (depthFunc) {
  12920. switch (depthFunc) {
  12921. case NeverDepth:
  12922. gl.depthFunc(512);
  12923. break;
  12924. case AlwaysDepth:
  12925. gl.depthFunc(519);
  12926. break;
  12927. case LessDepth:
  12928. gl.depthFunc(513);
  12929. break;
  12930. case LessEqualDepth:
  12931. gl.depthFunc(515);
  12932. break;
  12933. case EqualDepth:
  12934. gl.depthFunc(514);
  12935. break;
  12936. case GreaterEqualDepth:
  12937. gl.depthFunc(518);
  12938. break;
  12939. case GreaterDepth:
  12940. gl.depthFunc(516);
  12941. break;
  12942. case NotEqualDepth:
  12943. gl.depthFunc(517);
  12944. break;
  12945. default:
  12946. gl.depthFunc(515);
  12947. }
  12948. } else {
  12949. gl.depthFunc(515);
  12950. }
  12951. currentDepthFunc = depthFunc;
  12952. }
  12953. },
  12954. setLocked: function(lock) {
  12955. locked = lock;
  12956. },
  12957. setClear: function(depth) {
  12958. if (currentDepthClear !== depth) {
  12959. gl.clearDepth(depth);
  12960. currentDepthClear = depth;
  12961. }
  12962. },
  12963. reset: function() {
  12964. locked = false;
  12965. currentDepthMask = null;
  12966. currentDepthFunc = null;
  12967. currentDepthClear = null;
  12968. }
  12969. };
  12970. }
  12971. function StencilBuffer() {
  12972. var locked = false;
  12973. var currentStencilMask = null;
  12974. var currentStencilFunc = null;
  12975. var currentStencilRef = null;
  12976. var currentStencilFuncMask = null;
  12977. var currentStencilFail = null;
  12978. var currentStencilZFail = null;
  12979. var currentStencilZPass = null;
  12980. var currentStencilClear = null;
  12981. return {
  12982. setTest: function(stencilTest) {
  12983. if (!locked) {
  12984. if (stencilTest) {
  12985. enable(2960);
  12986. } else {
  12987. disable(2960);
  12988. }
  12989. }
  12990. },
  12991. setMask: function(stencilMask) {
  12992. if (currentStencilMask !== stencilMask && !locked) {
  12993. gl.stencilMask(stencilMask);
  12994. currentStencilMask = stencilMask;
  12995. }
  12996. },
  12997. setFunc: function(stencilFunc, stencilRef, stencilMask) {
  12998. if (currentStencilFunc !== stencilFunc || currentStencilRef !== stencilRef || currentStencilFuncMask !== stencilMask) {
  12999. gl.stencilFunc(stencilFunc, stencilRef, stencilMask);
  13000. currentStencilFunc = stencilFunc;
  13001. currentStencilRef = stencilRef;
  13002. currentStencilFuncMask = stencilMask;
  13003. }
  13004. },
  13005. setOp: function(stencilFail, stencilZFail, stencilZPass) {
  13006. if (currentStencilFail !== stencilFail || currentStencilZFail !== stencilZFail || currentStencilZPass !== stencilZPass) {
  13007. gl.stencilOp(stencilFail, stencilZFail, stencilZPass);
  13008. currentStencilFail = stencilFail;
  13009. currentStencilZFail = stencilZFail;
  13010. currentStencilZPass = stencilZPass;
  13011. }
  13012. },
  13013. setLocked: function(lock) {
  13014. locked = lock;
  13015. },
  13016. setClear: function(stencil) {
  13017. if (currentStencilClear !== stencil) {
  13018. gl.clearStencil(stencil);
  13019. currentStencilClear = stencil;
  13020. }
  13021. },
  13022. reset: function() {
  13023. locked = false;
  13024. currentStencilMask = null;
  13025. currentStencilFunc = null;
  13026. currentStencilRef = null;
  13027. currentStencilFuncMask = null;
  13028. currentStencilFail = null;
  13029. currentStencilZFail = null;
  13030. currentStencilZPass = null;
  13031. currentStencilClear = null;
  13032. }
  13033. };
  13034. }
  13035. var colorBuffer = new ColorBuffer();
  13036. var depthBuffer = new DepthBuffer();
  13037. var stencilBuffer = new StencilBuffer();
  13038. var maxVertexAttributes = gl.getParameter(34921);
  13039. var newAttributes = new Uint8Array(maxVertexAttributes);
  13040. var enabledAttributes = new Uint8Array(maxVertexAttributes);
  13041. var attributeDivisors = new Uint8Array(maxVertexAttributes);
  13042. var enabledCapabilities = {};
  13043. var currentProgram = null;
  13044. var currentBlendingEnabled = null;
  13045. var currentBlending = null;
  13046. var currentBlendEquation = null;
  13047. var currentBlendSrc = null;
  13048. var currentBlendDst = null;
  13049. var currentBlendEquationAlpha = null;
  13050. var currentBlendSrcAlpha = null;
  13051. var currentBlendDstAlpha = null;
  13052. var currentPremultipledAlpha = false;
  13053. var currentFlipSided = null;
  13054. var currentCullFace = null;
  13055. var currentLineWidth = null;
  13056. var currentPolygonOffsetFactor = null;
  13057. var currentPolygonOffsetUnits = null;
  13058. var maxTextures = gl.getParameter(35661);
  13059. var lineWidthAvailable = false;
  13060. var version = 0;
  13061. var glVersion = gl.getParameter(7938);
  13062. if (glVersion.indexOf("WebGL") !== -1) {
  13063. version = parseFloat(/^WebGL\ ([0-9])/.exec(glVersion)[1]);
  13064. lineWidthAvailable = version >= 1;
  13065. } else if (glVersion.indexOf("OpenGL ES") !== -1) {
  13066. version = parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(glVersion)[1]);
  13067. lineWidthAvailable = version >= 2;
  13068. }
  13069. var currentTextureSlot = null;
  13070. var currentBoundTextures = {};
  13071. var currentScissor = new Vector4();
  13072. var currentViewport = new Vector4();
  13073. function createTexture(type, target, count) {
  13074. var data = new Uint8Array(4);
  13075. var texture = gl.createTexture();
  13076. gl.bindTexture(type, texture);
  13077. gl.texParameteri(type, 10241, 9728);
  13078. gl.texParameteri(type, 10240, 9728);
  13079. for (var i2 = 0; i2 < count; i2++) {
  13080. gl.texImage2D(target + i2, 0, 6408, 1, 1, 0, 6408, 5121, data);
  13081. }
  13082. return texture;
  13083. }
  13084. var emptyTextures = {};
  13085. emptyTextures[3553] = createTexture(3553, 3553, 1);
  13086. emptyTextures[34067] = createTexture(34067, 34069, 6);
  13087. colorBuffer.setClear(0, 0, 0, 1);
  13088. depthBuffer.setClear(1);
  13089. stencilBuffer.setClear(0);
  13090. enable(2929);
  13091. depthBuffer.setFunc(LessEqualDepth);
  13092. setFlipSided(false);
  13093. setCullFace(CullFaceBack);
  13094. enable(2884);
  13095. setBlending(NoBlending);
  13096. function initAttributes() {
  13097. for (var i2 = 0, l = newAttributes.length; i2 < l; i2++) {
  13098. newAttributes[i2] = 0;
  13099. }
  13100. }
  13101. function enableAttribute(attribute) {
  13102. enableAttributeAndDivisor(attribute, 0);
  13103. }
  13104. function enableAttributeAndDivisor(attribute, meshPerAttribute) {
  13105. newAttributes[attribute] = 1;
  13106. if (enabledAttributes[attribute] === 0) {
  13107. gl.enableVertexAttribArray(attribute);
  13108. enabledAttributes[attribute] = 1;
  13109. }
  13110. if (attributeDivisors[attribute] !== meshPerAttribute) {
  13111. var extension2 = isWebGL2 ? gl : extensions.get("ANGLE_instanced_arrays");
  13112. extension2[isWebGL2 ? "vertexAttribDivisor" : "vertexAttribDivisorANGLE"](attribute, meshPerAttribute);
  13113. attributeDivisors[attribute] = meshPerAttribute;
  13114. }
  13115. }
  13116. function disableUnusedAttributes() {
  13117. for (var i2 = 0, l = enabledAttributes.length; i2 !== l; ++i2) {
  13118. if (enabledAttributes[i2] !== newAttributes[i2]) {
  13119. gl.disableVertexAttribArray(i2);
  13120. enabledAttributes[i2] = 0;
  13121. }
  13122. }
  13123. }
  13124. function enable(id) {
  13125. if (enabledCapabilities[id] !== true) {
  13126. gl.enable(id);
  13127. enabledCapabilities[id] = true;
  13128. }
  13129. }
  13130. function disable(id) {
  13131. if (enabledCapabilities[id] !== false) {
  13132. gl.disable(id);
  13133. enabledCapabilities[id] = false;
  13134. }
  13135. }
  13136. function useProgram(program) {
  13137. if (currentProgram !== program) {
  13138. gl.useProgram(program);
  13139. currentProgram = program;
  13140. return true;
  13141. }
  13142. return false;
  13143. }
  13144. var equationToGL = {
  13145. [AddEquation]: 32774,
  13146. [SubtractEquation]: 32778,
  13147. [ReverseSubtractEquation]: 32779
  13148. };
  13149. if (isWebGL2) {
  13150. equationToGL[MinEquation] = 32775;
  13151. equationToGL[MaxEquation] = 32776;
  13152. } else {
  13153. var extension = extensions.get("EXT_blend_minmax");
  13154. if (extension !== null) {
  13155. equationToGL[MinEquation] = extension.MIN_EXT;
  13156. equationToGL[MaxEquation] = extension.MAX_EXT;
  13157. }
  13158. }
  13159. var factorToGL = {
  13160. [ZeroFactor]: 0,
  13161. [OneFactor]: 1,
  13162. [SrcColorFactor]: 768,
  13163. [SrcAlphaFactor]: 770,
  13164. [SrcAlphaSaturateFactor]: 776,
  13165. [DstColorFactor]: 774,
  13166. [DstAlphaFactor]: 772,
  13167. [OneMinusSrcColorFactor]: 769,
  13168. [OneMinusSrcAlphaFactor]: 771,
  13169. [OneMinusDstColorFactor]: 775,
  13170. [OneMinusDstAlphaFactor]: 773
  13171. };
  13172. function setBlending(blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha) {
  13173. if (blending === NoBlending) {
  13174. if (currentBlendingEnabled) {
  13175. disable(3042);
  13176. currentBlendingEnabled = false;
  13177. }
  13178. return;
  13179. }
  13180. if (!currentBlendingEnabled) {
  13181. enable(3042);
  13182. currentBlendingEnabled = true;
  13183. }
  13184. if (blending !== CustomBlending) {
  13185. if (blending !== currentBlending || premultipliedAlpha !== currentPremultipledAlpha) {
  13186. if (currentBlendEquation !== AddEquation || currentBlendEquationAlpha !== AddEquation) {
  13187. gl.blendEquation(32774);
  13188. currentBlendEquation = AddEquation;
  13189. currentBlendEquationAlpha = AddEquation;
  13190. }
  13191. if (premultipliedAlpha) {
  13192. switch (blending) {
  13193. case NormalBlending:
  13194. gl.blendFuncSeparate(1, 771, 1, 771);
  13195. break;
  13196. case AdditiveBlending:
  13197. gl.blendFunc(1, 1);
  13198. break;
  13199. case SubtractiveBlending:
  13200. gl.blendFuncSeparate(0, 0, 769, 771);
  13201. break;
  13202. case MultiplyBlending:
  13203. gl.blendFuncSeparate(0, 768, 0, 770);
  13204. break;
  13205. default:
  13206. console.error("THREE.WebGLState: Invalid blending: ", blending);
  13207. break;
  13208. }
  13209. } else {
  13210. switch (blending) {
  13211. case NormalBlending:
  13212. gl.blendFuncSeparate(770, 771, 1, 771);
  13213. break;
  13214. case AdditiveBlending:
  13215. gl.blendFunc(770, 1);
  13216. break;
  13217. case SubtractiveBlending:
  13218. gl.blendFunc(0, 769);
  13219. break;
  13220. case MultiplyBlending:
  13221. gl.blendFunc(0, 768);
  13222. break;
  13223. default:
  13224. console.error("THREE.WebGLState: Invalid blending: ", blending);
  13225. break;
  13226. }
  13227. }
  13228. currentBlendSrc = null;
  13229. currentBlendDst = null;
  13230. currentBlendSrcAlpha = null;
  13231. currentBlendDstAlpha = null;
  13232. currentBlending = blending;
  13233. currentPremultipledAlpha = premultipliedAlpha;
  13234. }
  13235. return;
  13236. }
  13237. blendEquationAlpha = blendEquationAlpha || blendEquation;
  13238. blendSrcAlpha = blendSrcAlpha || blendSrc;
  13239. blendDstAlpha = blendDstAlpha || blendDst;
  13240. if (blendEquation !== currentBlendEquation || blendEquationAlpha !== currentBlendEquationAlpha) {
  13241. gl.blendEquationSeparate(equationToGL[blendEquation], equationToGL[blendEquationAlpha]);
  13242. currentBlendEquation = blendEquation;
  13243. currentBlendEquationAlpha = blendEquationAlpha;
  13244. }
  13245. if (blendSrc !== currentBlendSrc || blendDst !== currentBlendDst || blendSrcAlpha !== currentBlendSrcAlpha || blendDstAlpha !== currentBlendDstAlpha) {
  13246. gl.blendFuncSeparate(factorToGL[blendSrc], factorToGL[blendDst], factorToGL[blendSrcAlpha], factorToGL[blendDstAlpha]);
  13247. currentBlendSrc = blendSrc;
  13248. currentBlendDst = blendDst;
  13249. currentBlendSrcAlpha = blendSrcAlpha;
  13250. currentBlendDstAlpha = blendDstAlpha;
  13251. }
  13252. currentBlending = blending;
  13253. currentPremultipledAlpha = null;
  13254. }
  13255. function setMaterial(material, frontFaceCW) {
  13256. material.side === DoubleSide ? disable(2884) : enable(2884);
  13257. var flipSided = material.side === BackSide;
  13258. if (frontFaceCW)
  13259. flipSided = !flipSided;
  13260. setFlipSided(flipSided);
  13261. material.blending === NormalBlending && material.transparent === false ? setBlending(NoBlending) : setBlending(material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.premultipliedAlpha);
  13262. depthBuffer.setFunc(material.depthFunc);
  13263. depthBuffer.setTest(material.depthTest);
  13264. depthBuffer.setMask(material.depthWrite);
  13265. colorBuffer.setMask(material.colorWrite);
  13266. var stencilWrite = material.stencilWrite;
  13267. stencilBuffer.setTest(stencilWrite);
  13268. if (stencilWrite) {
  13269. stencilBuffer.setMask(material.stencilWriteMask);
  13270. stencilBuffer.setFunc(material.stencilFunc, material.stencilRef, material.stencilFuncMask);
  13271. stencilBuffer.setOp(material.stencilFail, material.stencilZFail, material.stencilZPass);
  13272. }
  13273. setPolygonOffset(material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits);
  13274. }
  13275. function setFlipSided(flipSided) {
  13276. if (currentFlipSided !== flipSided) {
  13277. if (flipSided) {
  13278. gl.frontFace(2304);
  13279. } else {
  13280. gl.frontFace(2305);
  13281. }
  13282. currentFlipSided = flipSided;
  13283. }
  13284. }
  13285. function setCullFace(cullFace) {
  13286. if (cullFace !== CullFaceNone) {
  13287. enable(2884);
  13288. if (cullFace !== currentCullFace) {
  13289. if (cullFace === CullFaceBack) {
  13290. gl.cullFace(1029);
  13291. } else if (cullFace === CullFaceFront) {
  13292. gl.cullFace(1028);
  13293. } else {
  13294. gl.cullFace(1032);
  13295. }
  13296. }
  13297. } else {
  13298. disable(2884);
  13299. }
  13300. currentCullFace = cullFace;
  13301. }
  13302. function setLineWidth(width) {
  13303. if (width !== currentLineWidth) {
  13304. if (lineWidthAvailable)
  13305. gl.lineWidth(width);
  13306. currentLineWidth = width;
  13307. }
  13308. }
  13309. function setPolygonOffset(polygonOffset, factor, units) {
  13310. if (polygonOffset) {
  13311. enable(32823);
  13312. if (currentPolygonOffsetFactor !== factor || currentPolygonOffsetUnits !== units) {
  13313. gl.polygonOffset(factor, units);
  13314. currentPolygonOffsetFactor = factor;
  13315. currentPolygonOffsetUnits = units;
  13316. }
  13317. } else {
  13318. disable(32823);
  13319. }
  13320. }
  13321. function setScissorTest(scissorTest) {
  13322. if (scissorTest) {
  13323. enable(3089);
  13324. } else {
  13325. disable(3089);
  13326. }
  13327. }
  13328. function activeTexture(webglSlot) {
  13329. if (webglSlot === void 0)
  13330. webglSlot = 33984 + maxTextures - 1;
  13331. if (currentTextureSlot !== webglSlot) {
  13332. gl.activeTexture(webglSlot);
  13333. currentTextureSlot = webglSlot;
  13334. }
  13335. }
  13336. function bindTexture(webglType, webglTexture) {
  13337. if (currentTextureSlot === null) {
  13338. activeTexture();
  13339. }
  13340. var boundTexture = currentBoundTextures[currentTextureSlot];
  13341. if (boundTexture === void 0) {
  13342. boundTexture = { type: void 0, texture: void 0 };
  13343. currentBoundTextures[currentTextureSlot] = boundTexture;
  13344. }
  13345. if (boundTexture.type !== webglType || boundTexture.texture !== webglTexture) {
  13346. gl.bindTexture(webglType, webglTexture || emptyTextures[webglType]);
  13347. boundTexture.type = webglType;
  13348. boundTexture.texture = webglTexture;
  13349. }
  13350. }
  13351. function unbindTexture() {
  13352. var boundTexture = currentBoundTextures[currentTextureSlot];
  13353. if (boundTexture !== void 0 && boundTexture.type !== void 0) {
  13354. gl.bindTexture(boundTexture.type, null);
  13355. boundTexture.type = void 0;
  13356. boundTexture.texture = void 0;
  13357. }
  13358. }
  13359. function compressedTexImage2D() {
  13360. try {
  13361. gl.compressedTexImage2D.apply(gl, arguments);
  13362. } catch (error) {
  13363. console.error("THREE.WebGLState:", error);
  13364. }
  13365. }
  13366. function texImage2D() {
  13367. try {
  13368. gl.texImage2D.apply(gl, arguments);
  13369. } catch (error) {
  13370. console.error("THREE.WebGLState:", error);
  13371. }
  13372. }
  13373. function texImage3D() {
  13374. try {
  13375. gl.texImage3D.apply(gl, arguments);
  13376. } catch (error) {
  13377. console.error("THREE.WebGLState:", error);
  13378. }
  13379. }
  13380. function scissor(scissor2) {
  13381. if (currentScissor.equals(scissor2) === false) {
  13382. gl.scissor(scissor2.x, scissor2.y, scissor2.z, scissor2.w);
  13383. currentScissor.copy(scissor2);
  13384. }
  13385. }
  13386. function viewport(viewport2) {
  13387. if (currentViewport.equals(viewport2) === false) {
  13388. gl.viewport(viewport2.x, viewport2.y, viewport2.z, viewport2.w);
  13389. currentViewport.copy(viewport2);
  13390. }
  13391. }
  13392. function reset() {
  13393. for (var i2 = 0; i2 < enabledAttributes.length; i2++) {
  13394. if (enabledAttributes[i2] === 1) {
  13395. gl.disableVertexAttribArray(i2);
  13396. enabledAttributes[i2] = 0;
  13397. }
  13398. }
  13399. enabledCapabilities = {};
  13400. currentTextureSlot = null;
  13401. currentBoundTextures = {};
  13402. currentProgram = null;
  13403. currentBlending = null;
  13404. currentFlipSided = null;
  13405. currentCullFace = null;
  13406. colorBuffer.reset();
  13407. depthBuffer.reset();
  13408. stencilBuffer.reset();
  13409. }
  13410. return {
  13411. buffers: {
  13412. color: colorBuffer,
  13413. depth: depthBuffer,
  13414. stencil: stencilBuffer
  13415. },
  13416. initAttributes,
  13417. enableAttribute,
  13418. enableAttributeAndDivisor,
  13419. disableUnusedAttributes,
  13420. enable,
  13421. disable,
  13422. useProgram,
  13423. setBlending,
  13424. setMaterial,
  13425. setFlipSided,
  13426. setCullFace,
  13427. setLineWidth,
  13428. setPolygonOffset,
  13429. setScissorTest,
  13430. activeTexture,
  13431. bindTexture,
  13432. unbindTexture,
  13433. compressedTexImage2D,
  13434. texImage2D,
  13435. texImage3D,
  13436. scissor,
  13437. viewport,
  13438. reset
  13439. };
  13440. }
  13441. function WebGLTextures(_gl, extensions, state, properties, capabilities, utils, info) {
  13442. var isWebGL2 = capabilities.isWebGL2;
  13443. var maxTextures = capabilities.maxTextures;
  13444. var maxCubemapSize = capabilities.maxCubemapSize;
  13445. var maxTextureSize = capabilities.maxTextureSize;
  13446. var maxSamples = capabilities.maxSamples;
  13447. var _videoTextures = /* @__PURE__ */ new WeakMap();
  13448. var _canvas2;
  13449. var useOffscreenCanvas = false;
  13450. try {
  13451. useOffscreenCanvas = typeof OffscreenCanvas !== "undefined" && new OffscreenCanvas(1, 1).getContext("2d") !== null;
  13452. } catch (err) {
  13453. }
  13454. function createCanvas(width, height) {
  13455. return useOffscreenCanvas ? new OffscreenCanvas(width, height) : document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
  13456. }
  13457. function resizeImage(image, needsPowerOfTwo, needsNewCanvas, maxSize) {
  13458. var scale = 1;
  13459. if (image.width > maxSize || image.height > maxSize) {
  13460. scale = maxSize / Math.max(image.width, image.height);
  13461. }
  13462. if (scale < 1 || needsPowerOfTwo === true) {
  13463. if (typeof HTMLImageElement !== "undefined" && image instanceof HTMLImageElement || typeof HTMLCanvasElement !== "undefined" && image instanceof HTMLCanvasElement || typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) {
  13464. var floor = needsPowerOfTwo ? MathUtils.floorPowerOfTwo : Math.floor;
  13465. var width = floor(scale * image.width);
  13466. var height = floor(scale * image.height);
  13467. if (_canvas2 === void 0)
  13468. _canvas2 = createCanvas(width, height);
  13469. var canvas = needsNewCanvas ? createCanvas(width, height) : _canvas2;
  13470. canvas.width = width;
  13471. canvas.height = height;
  13472. var context = canvas.getContext("2d");
  13473. context.drawImage(image, 0, 0, width, height);
  13474. console.warn("THREE.WebGLRenderer: Texture has been resized from (" + image.width + "x" + image.height + ") to (" + width + "x" + height + ").");
  13475. return canvas;
  13476. } else {
  13477. if ("data" in image) {
  13478. console.warn("THREE.WebGLRenderer: Image in DataTexture is too big (" + image.width + "x" + image.height + ").");
  13479. }
  13480. return image;
  13481. }
  13482. }
  13483. return image;
  13484. }
  13485. function isPowerOfTwo(image) {
  13486. return MathUtils.isPowerOfTwo(image.width) && MathUtils.isPowerOfTwo(image.height);
  13487. }
  13488. function textureNeedsPowerOfTwo(texture) {
  13489. if (isWebGL2)
  13490. return false;
  13491. return texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping || texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
  13492. }
  13493. function textureNeedsGenerateMipmaps(texture, supportsMips) {
  13494. return texture.generateMipmaps && supportsMips && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
  13495. }
  13496. function generateMipmap(target, texture, width, height) {
  13497. _gl.generateMipmap(target);
  13498. var textureProperties = properties.get(texture);
  13499. textureProperties.__maxMipLevel = Math.log(Math.max(width, height)) * Math.LOG2E;
  13500. }
  13501. function getInternalFormat(internalFormatName, glFormat, glType) {
  13502. if (isWebGL2 === false)
  13503. return glFormat;
  13504. if (internalFormatName !== null) {
  13505. if (_gl[internalFormatName] !== void 0)
  13506. return _gl[internalFormatName];
  13507. console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '" + internalFormatName + "'");
  13508. }
  13509. var internalFormat = glFormat;
  13510. if (glFormat === 6403) {
  13511. if (glType === 5126)
  13512. internalFormat = 33326;
  13513. if (glType === 5131)
  13514. internalFormat = 33325;
  13515. if (glType === 5121)
  13516. internalFormat = 33321;
  13517. }
  13518. if (glFormat === 6407) {
  13519. if (glType === 5126)
  13520. internalFormat = 34837;
  13521. if (glType === 5131)
  13522. internalFormat = 34843;
  13523. if (glType === 5121)
  13524. internalFormat = 32849;
  13525. }
  13526. if (glFormat === 6408) {
  13527. if (glType === 5126)
  13528. internalFormat = 34836;
  13529. if (glType === 5131)
  13530. internalFormat = 34842;
  13531. if (glType === 5121)
  13532. internalFormat = 32856;
  13533. }
  13534. if (internalFormat === 33325 || internalFormat === 33326 || internalFormat === 34842 || internalFormat === 34836) {
  13535. extensions.get("EXT_color_buffer_float");
  13536. } else if (internalFormat === 34843 || internalFormat === 34837) {
  13537. console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead.");
  13538. }
  13539. return internalFormat;
  13540. }
  13541. function filterFallback(f) {
  13542. if (f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter) {
  13543. return 9728;
  13544. }
  13545. return 9729;
  13546. }
  13547. function onTextureDispose(event) {
  13548. var texture = event.target;
  13549. texture.removeEventListener("dispose", onTextureDispose);
  13550. deallocateTexture(texture);
  13551. if (texture.isVideoTexture) {
  13552. _videoTextures.delete(texture);
  13553. }
  13554. info.memory.textures--;
  13555. }
  13556. function onRenderTargetDispose(event) {
  13557. var renderTarget = event.target;
  13558. renderTarget.removeEventListener("dispose", onRenderTargetDispose);
  13559. deallocateRenderTarget(renderTarget);
  13560. info.memory.textures--;
  13561. }
  13562. function deallocateTexture(texture) {
  13563. var textureProperties = properties.get(texture);
  13564. if (textureProperties.__webglInit === void 0)
  13565. return;
  13566. _gl.deleteTexture(textureProperties.__webglTexture);
  13567. properties.remove(texture);
  13568. }
  13569. function deallocateRenderTarget(renderTarget) {
  13570. var renderTargetProperties = properties.get(renderTarget);
  13571. var textureProperties = properties.get(renderTarget.texture);
  13572. if (!renderTarget)
  13573. return;
  13574. if (textureProperties.__webglTexture !== void 0) {
  13575. _gl.deleteTexture(textureProperties.__webglTexture);
  13576. }
  13577. if (renderTarget.depthTexture) {
  13578. renderTarget.depthTexture.dispose();
  13579. }
  13580. if (renderTarget.isWebGLCubeRenderTarget) {
  13581. for (var i2 = 0; i2 < 6; i2++) {
  13582. _gl.deleteFramebuffer(renderTargetProperties.__webglFramebuffer[i2]);
  13583. if (renderTargetProperties.__webglDepthbuffer)
  13584. _gl.deleteRenderbuffer(renderTargetProperties.__webglDepthbuffer[i2]);
  13585. }
  13586. } else {
  13587. _gl.deleteFramebuffer(renderTargetProperties.__webglFramebuffer);
  13588. if (renderTargetProperties.__webglDepthbuffer)
  13589. _gl.deleteRenderbuffer(renderTargetProperties.__webglDepthbuffer);
  13590. }
  13591. if (renderTarget.isWebGLMultiviewRenderTarget) {
  13592. _gl.deleteTexture(renderTargetProperties.__webglColorTexture);
  13593. _gl.deleteTexture(renderTargetProperties.__webglDepthStencilTexture);
  13594. info.memory.textures -= 2;
  13595. for (var i2 = 0, il = renderTargetProperties.__webglViewFramebuffers.length; i2 < il; i2++) {
  13596. _gl.deleteFramebuffer(renderTargetProperties.__webglViewFramebuffers[i2]);
  13597. }
  13598. }
  13599. properties.remove(renderTarget.texture);
  13600. properties.remove(renderTarget);
  13601. }
  13602. var textureUnits = 0;
  13603. function resetTextureUnits() {
  13604. textureUnits = 0;
  13605. }
  13606. function allocateTextureUnit() {
  13607. var textureUnit = textureUnits;
  13608. if (textureUnit >= maxTextures) {
  13609. console.warn("THREE.WebGLTextures: Trying to use " + textureUnit + " texture units while this GPU supports only " + maxTextures);
  13610. }
  13611. textureUnits += 1;
  13612. return textureUnit;
  13613. }
  13614. function setTexture2D(texture, slot) {
  13615. var textureProperties = properties.get(texture);
  13616. if (texture.isVideoTexture)
  13617. updateVideoTexture(texture);
  13618. if (texture.version > 0 && textureProperties.__version !== texture.version) {
  13619. var image = texture.image;
  13620. if (image === void 0) {
  13621. console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");
  13622. } else if (image.complete === false) {
  13623. console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");
  13624. } else {
  13625. uploadTexture(textureProperties, texture, slot);
  13626. return;
  13627. }
  13628. }
  13629. state.activeTexture(33984 + slot);
  13630. state.bindTexture(3553, textureProperties.__webglTexture);
  13631. }
  13632. function setTexture2DArray(texture, slot) {
  13633. var textureProperties = properties.get(texture);
  13634. if (texture.version > 0 && textureProperties.__version !== texture.version) {
  13635. uploadTexture(textureProperties, texture, slot);
  13636. return;
  13637. }
  13638. state.activeTexture(33984 + slot);
  13639. state.bindTexture(35866, textureProperties.__webglTexture);
  13640. }
  13641. function setTexture3D(texture, slot) {
  13642. var textureProperties = properties.get(texture);
  13643. if (texture.version > 0 && textureProperties.__version !== texture.version) {
  13644. uploadTexture(textureProperties, texture, slot);
  13645. return;
  13646. }
  13647. state.activeTexture(33984 + slot);
  13648. state.bindTexture(32879, textureProperties.__webglTexture);
  13649. }
  13650. function setTextureCube(texture, slot) {
  13651. if (texture.image.length !== 6)
  13652. return;
  13653. var textureProperties = properties.get(texture);
  13654. if (texture.version > 0 && textureProperties.__version !== texture.version) {
  13655. initTexture(textureProperties, texture);
  13656. state.activeTexture(33984 + slot);
  13657. state.bindTexture(34067, textureProperties.__webglTexture);
  13658. _gl.pixelStorei(37440, texture.flipY);
  13659. var isCompressed = texture && (texture.isCompressedTexture || texture.image[0].isCompressedTexture);
  13660. var isDataTexture = texture.image[0] && texture.image[0].isDataTexture;
  13661. var cubeImage = [];
  13662. for (var i2 = 0; i2 < 6; i2++) {
  13663. if (!isCompressed && !isDataTexture) {
  13664. cubeImage[i2] = resizeImage(texture.image[i2], false, true, maxCubemapSize);
  13665. } else {
  13666. cubeImage[i2] = isDataTexture ? texture.image[i2].image : texture.image[i2];
  13667. }
  13668. }
  13669. var image = cubeImage[0], supportsMips = isPowerOfTwo(image) || isWebGL2, glFormat = utils.convert(texture.format), glType = utils.convert(texture.type), glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType);
  13670. setTextureParameters(34067, texture, supportsMips);
  13671. var mipmaps;
  13672. if (isCompressed) {
  13673. for (var i2 = 0; i2 < 6; i2++) {
  13674. mipmaps = cubeImage[i2].mipmaps;
  13675. for (var j = 0; j < mipmaps.length; j++) {
  13676. var mipmap = mipmaps[j];
  13677. if (texture.format !== RGBAFormat && texture.format !== RGBFormat) {
  13678. if (glFormat !== null) {
  13679. state.compressedTexImage2D(34069 + i2, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
  13680. } else {
  13681. console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");
  13682. }
  13683. } else {
  13684. state.texImage2D(34069 + i2, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
  13685. }
  13686. }
  13687. }
  13688. textureProperties.__maxMipLevel = mipmaps.length - 1;
  13689. } else {
  13690. mipmaps = texture.mipmaps;
  13691. for (var i2 = 0; i2 < 6; i2++) {
  13692. if (isDataTexture) {
  13693. state.texImage2D(34069 + i2, 0, glInternalFormat, cubeImage[i2].width, cubeImage[i2].height, 0, glFormat, glType, cubeImage[i2].data);
  13694. for (var j = 0; j < mipmaps.length; j++) {
  13695. var mipmap = mipmaps[j];
  13696. var mipmapImage = mipmap.image[i2].image;
  13697. state.texImage2D(34069 + i2, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data);
  13698. }
  13699. } else {
  13700. state.texImage2D(34069 + i2, 0, glInternalFormat, glFormat, glType, cubeImage[i2]);
  13701. for (var j = 0; j < mipmaps.length; j++) {
  13702. var mipmap = mipmaps[j];
  13703. state.texImage2D(34069 + i2, j + 1, glInternalFormat, glFormat, glType, mipmap.image[i2]);
  13704. }
  13705. }
  13706. }
  13707. textureProperties.__maxMipLevel = mipmaps.length;
  13708. }
  13709. if (textureNeedsGenerateMipmaps(texture, supportsMips)) {
  13710. generateMipmap(34067, texture, image.width, image.height);
  13711. }
  13712. textureProperties.__version = texture.version;
  13713. if (texture.onUpdate)
  13714. texture.onUpdate(texture);
  13715. } else {
  13716. state.activeTexture(33984 + slot);
  13717. state.bindTexture(34067, textureProperties.__webglTexture);
  13718. }
  13719. }
  13720. function setTextureCubeDynamic(texture, slot) {
  13721. state.activeTexture(33984 + slot);
  13722. state.bindTexture(34067, properties.get(texture).__webglTexture);
  13723. }
  13724. var wrappingToGL = {
  13725. [RepeatWrapping]: 10497,
  13726. [ClampToEdgeWrapping]: 33071,
  13727. [MirroredRepeatWrapping]: 33648
  13728. };
  13729. var filterToGL = {
  13730. [NearestFilter]: 9728,
  13731. [NearestMipmapNearestFilter]: 9984,
  13732. [NearestMipmapLinearFilter]: 9986,
  13733. [LinearFilter]: 9729,
  13734. [LinearMipmapNearestFilter]: 9985,
  13735. [LinearMipmapLinearFilter]: 9987
  13736. };
  13737. function setTextureParameters(textureType, texture, supportsMips) {
  13738. if (supportsMips) {
  13739. _gl.texParameteri(textureType, 10242, wrappingToGL[texture.wrapS]);
  13740. _gl.texParameteri(textureType, 10243, wrappingToGL[texture.wrapT]);
  13741. if (textureType === 32879 || textureType === 35866) {
  13742. _gl.texParameteri(textureType, 32882, wrappingToGL[texture.wrapR]);
  13743. }
  13744. _gl.texParameteri(textureType, 10240, filterToGL[texture.magFilter]);
  13745. _gl.texParameteri(textureType, 10241, filterToGL[texture.minFilter]);
  13746. } else {
  13747. _gl.texParameteri(textureType, 10242, 33071);
  13748. _gl.texParameteri(textureType, 10243, 33071);
  13749. if (textureType === 32879 || textureType === 35866) {
  13750. _gl.texParameteri(textureType, 32882, 33071);
  13751. }
  13752. if (texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping) {
  13753. console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.");
  13754. }
  13755. _gl.texParameteri(textureType, 10240, filterFallback(texture.magFilter));
  13756. _gl.texParameteri(textureType, 10241, filterFallback(texture.minFilter));
  13757. if (texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter) {
  13758. console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.");
  13759. }
  13760. }
  13761. var extension = extensions.get("EXT_texture_filter_anisotropic");
  13762. if (extension) {
  13763. if (texture.type === FloatType && extensions.get("OES_texture_float_linear") === null)
  13764. return;
  13765. if (texture.type === HalfFloatType && (isWebGL2 || extensions.get("OES_texture_half_float_linear")) === null)
  13766. return;
  13767. if (texture.anisotropy > 1 || properties.get(texture).__currentAnisotropy) {
  13768. _gl.texParameterf(textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(texture.anisotropy, capabilities.getMaxAnisotropy()));
  13769. properties.get(texture).__currentAnisotropy = texture.anisotropy;
  13770. }
  13771. }
  13772. }
  13773. function initTexture(textureProperties, texture) {
  13774. if (textureProperties.__webglInit === void 0) {
  13775. textureProperties.__webglInit = true;
  13776. texture.addEventListener("dispose", onTextureDispose);
  13777. textureProperties.__webglTexture = _gl.createTexture();
  13778. info.memory.textures++;
  13779. }
  13780. }
  13781. function uploadTexture(textureProperties, texture, slot) {
  13782. var textureType = 3553;
  13783. if (texture.isDataTexture2DArray)
  13784. textureType = 35866;
  13785. if (texture.isDataTexture3D)
  13786. textureType = 32879;
  13787. initTexture(textureProperties, texture);
  13788. state.activeTexture(33984 + slot);
  13789. state.bindTexture(textureType, textureProperties.__webglTexture);
  13790. _gl.pixelStorei(37440, texture.flipY);
  13791. _gl.pixelStorei(37441, texture.premultiplyAlpha);
  13792. _gl.pixelStorei(3317, texture.unpackAlignment);
  13793. var needsPowerOfTwo = textureNeedsPowerOfTwo(texture) && isPowerOfTwo(texture.image) === false;
  13794. var image = resizeImage(texture.image, needsPowerOfTwo, false, maxTextureSize);
  13795. var supportsMips = isPowerOfTwo(image) || isWebGL2, glFormat = utils.convert(texture.format), glType = utils.convert(texture.type), glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType);
  13796. setTextureParameters(textureType, texture, supportsMips);
  13797. var mipmap, mipmaps = texture.mipmaps;
  13798. if (texture.isDepthTexture) {
  13799. glInternalFormat = 6402;
  13800. if (texture.type === FloatType) {
  13801. if (isWebGL2 === false)
  13802. throw new Error("Float Depth Texture only supported in WebGL2.0");
  13803. glInternalFormat = 36012;
  13804. } else if (isWebGL2) {
  13805. glInternalFormat = 33189;
  13806. }
  13807. if (texture.format === DepthFormat && glInternalFormat === 6402) {
  13808. if (texture.type !== UnsignedShortType && texture.type !== UnsignedIntType) {
  13809. console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.");
  13810. texture.type = UnsignedShortType;
  13811. glType = utils.convert(texture.type);
  13812. }
  13813. }
  13814. if (texture.format === DepthStencilFormat) {
  13815. glInternalFormat = 34041;
  13816. if (texture.type !== UnsignedInt248Type) {
  13817. console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.");
  13818. texture.type = UnsignedInt248Type;
  13819. glType = utils.convert(texture.type);
  13820. }
  13821. }
  13822. state.texImage2D(3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null);
  13823. } else if (texture.isDataTexture) {
  13824. if (mipmaps.length > 0 && supportsMips) {
  13825. for (var i2 = 0, il = mipmaps.length; i2 < il; i2++) {
  13826. mipmap = mipmaps[i2];
  13827. state.texImage2D(3553, i2, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
  13828. }
  13829. texture.generateMipmaps = false;
  13830. textureProperties.__maxMipLevel = mipmaps.length - 1;
  13831. } else {
  13832. state.texImage2D(3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data);
  13833. textureProperties.__maxMipLevel = 0;
  13834. }
  13835. } else if (texture.isCompressedTexture) {
  13836. for (var i2 = 0, il = mipmaps.length; i2 < il; i2++) {
  13837. mipmap = mipmaps[i2];
  13838. if (texture.format !== RGBAFormat && texture.format !== RGBFormat) {
  13839. if (glFormat !== null) {
  13840. state.compressedTexImage2D(3553, i2, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
  13841. } else {
  13842. console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");
  13843. }
  13844. } else {
  13845. state.texImage2D(3553, i2, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
  13846. }
  13847. }
  13848. textureProperties.__maxMipLevel = mipmaps.length - 1;
  13849. } else if (texture.isDataTexture2DArray) {
  13850. state.texImage3D(35866, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
  13851. textureProperties.__maxMipLevel = 0;
  13852. } else if (texture.isDataTexture3D) {
  13853. state.texImage3D(32879, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
  13854. textureProperties.__maxMipLevel = 0;
  13855. } else {
  13856. if (mipmaps.length > 0 && supportsMips) {
  13857. for (var i2 = 0, il = mipmaps.length; i2 < il; i2++) {
  13858. mipmap = mipmaps[i2];
  13859. state.texImage2D(3553, i2, glInternalFormat, glFormat, glType, mipmap);
  13860. }
  13861. texture.generateMipmaps = false;
  13862. textureProperties.__maxMipLevel = mipmaps.length - 1;
  13863. } else {
  13864. state.texImage2D(3553, 0, glInternalFormat, glFormat, glType, image);
  13865. textureProperties.__maxMipLevel = 0;
  13866. }
  13867. }
  13868. if (textureNeedsGenerateMipmaps(texture, supportsMips)) {
  13869. generateMipmap(textureType, texture, image.width, image.height);
  13870. }
  13871. textureProperties.__version = texture.version;
  13872. if (texture.onUpdate)
  13873. texture.onUpdate(texture);
  13874. }
  13875. function setupFrameBufferTexture(framebuffer, renderTarget, attachment, textureTarget) {
  13876. var glFormat = utils.convert(renderTarget.texture.format);
  13877. var glType = utils.convert(renderTarget.texture.type);
  13878. var glInternalFormat = getInternalFormat(renderTarget.texture.internalFormat, glFormat, glType);
  13879. state.texImage2D(textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null);
  13880. _gl.bindFramebuffer(36160, framebuffer);
  13881. _gl.framebufferTexture2D(36160, attachment, textureTarget, properties.get(renderTarget.texture).__webglTexture, 0);
  13882. _gl.bindFramebuffer(36160, null);
  13883. }
  13884. function setupRenderBufferStorage(renderbuffer, renderTarget, isMultisample) {
  13885. _gl.bindRenderbuffer(36161, renderbuffer);
  13886. if (renderTarget.depthBuffer && !renderTarget.stencilBuffer) {
  13887. if (isMultisample) {
  13888. var samples = getRenderTargetSamples(renderTarget);
  13889. _gl.renderbufferStorageMultisample(36161, samples, 33189, renderTarget.width, renderTarget.height);
  13890. } else {
  13891. _gl.renderbufferStorage(36161, 33189, renderTarget.width, renderTarget.height);
  13892. }
  13893. _gl.framebufferRenderbuffer(36160, 36096, 36161, renderbuffer);
  13894. } else if (renderTarget.depthBuffer && renderTarget.stencilBuffer) {
  13895. if (isMultisample) {
  13896. var samples = getRenderTargetSamples(renderTarget);
  13897. _gl.renderbufferStorageMultisample(36161, samples, 35056, renderTarget.width, renderTarget.height);
  13898. } else {
  13899. _gl.renderbufferStorage(36161, 34041, renderTarget.width, renderTarget.height);
  13900. }
  13901. _gl.framebufferRenderbuffer(36160, 33306, 36161, renderbuffer);
  13902. } else {
  13903. var glFormat = utils.convert(renderTarget.texture.format);
  13904. var glType = utils.convert(renderTarget.texture.type);
  13905. var glInternalFormat = getInternalFormat(renderTarget.texture.internalFormat, glFormat, glType);
  13906. if (isMultisample) {
  13907. var samples = getRenderTargetSamples(renderTarget);
  13908. _gl.renderbufferStorageMultisample(36161, samples, glInternalFormat, renderTarget.width, renderTarget.height);
  13909. } else {
  13910. _gl.renderbufferStorage(36161, glInternalFormat, renderTarget.width, renderTarget.height);
  13911. }
  13912. }
  13913. _gl.bindRenderbuffer(36161, null);
  13914. }
  13915. function setupDepthTexture(framebuffer, renderTarget) {
  13916. var isCube = renderTarget && renderTarget.isWebGLCubeRenderTarget;
  13917. if (isCube)
  13918. throw new Error("Depth Texture with cube render targets is not supported");
  13919. _gl.bindFramebuffer(36160, framebuffer);
  13920. if (!(renderTarget.depthTexture && renderTarget.depthTexture.isDepthTexture)) {
  13921. throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");
  13922. }
  13923. if (!properties.get(renderTarget.depthTexture).__webglTexture || renderTarget.depthTexture.image.width !== renderTarget.width || renderTarget.depthTexture.image.height !== renderTarget.height) {
  13924. renderTarget.depthTexture.image.width = renderTarget.width;
  13925. renderTarget.depthTexture.image.height = renderTarget.height;
  13926. renderTarget.depthTexture.needsUpdate = true;
  13927. }
  13928. setTexture2D(renderTarget.depthTexture, 0);
  13929. var webglDepthTexture = properties.get(renderTarget.depthTexture).__webglTexture;
  13930. if (renderTarget.depthTexture.format === DepthFormat) {
  13931. _gl.framebufferTexture2D(36160, 36096, 3553, webglDepthTexture, 0);
  13932. } else if (renderTarget.depthTexture.format === DepthStencilFormat) {
  13933. _gl.framebufferTexture2D(36160, 33306, 3553, webglDepthTexture, 0);
  13934. } else {
  13935. throw new Error("Unknown depthTexture format");
  13936. }
  13937. }
  13938. function setupDepthRenderbuffer(renderTarget) {
  13939. var renderTargetProperties = properties.get(renderTarget);
  13940. var isCube = renderTarget.isWebGLCubeRenderTarget === true;
  13941. if (renderTarget.depthTexture) {
  13942. if (isCube)
  13943. throw new Error("target.depthTexture not supported in Cube render targets");
  13944. setupDepthTexture(renderTargetProperties.__webglFramebuffer, renderTarget);
  13945. } else {
  13946. if (isCube) {
  13947. renderTargetProperties.__webglDepthbuffer = [];
  13948. for (var i2 = 0; i2 < 6; i2++) {
  13949. _gl.bindFramebuffer(36160, renderTargetProperties.__webglFramebuffer[i2]);
  13950. renderTargetProperties.__webglDepthbuffer[i2] = _gl.createRenderbuffer();
  13951. setupRenderBufferStorage(renderTargetProperties.__webglDepthbuffer[i2], renderTarget);
  13952. }
  13953. } else {
  13954. _gl.bindFramebuffer(36160, renderTargetProperties.__webglFramebuffer);
  13955. renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();
  13956. setupRenderBufferStorage(renderTargetProperties.__webglDepthbuffer, renderTarget);
  13957. }
  13958. }
  13959. _gl.bindFramebuffer(36160, null);
  13960. }
  13961. function setupRenderTarget(renderTarget) {
  13962. var renderTargetProperties = properties.get(renderTarget);
  13963. var textureProperties = properties.get(renderTarget.texture);
  13964. renderTarget.addEventListener("dispose", onRenderTargetDispose);
  13965. textureProperties.__webglTexture = _gl.createTexture();
  13966. info.memory.textures++;
  13967. var isCube = renderTarget.isWebGLCubeRenderTarget === true;
  13968. var isMultisample = renderTarget.isWebGLMultisampleRenderTarget === true;
  13969. var isMultiview = renderTarget.isWebGLMultiviewRenderTarget === true;
  13970. var supportsMips = isPowerOfTwo(renderTarget) || isWebGL2;
  13971. if (isCube) {
  13972. renderTargetProperties.__webglFramebuffer = [];
  13973. for (var i2 = 0; i2 < 6; i2++) {
  13974. renderTargetProperties.__webglFramebuffer[i2] = _gl.createFramebuffer();
  13975. }
  13976. } else {
  13977. renderTargetProperties.__webglFramebuffer = _gl.createFramebuffer();
  13978. if (isMultisample) {
  13979. if (isWebGL2) {
  13980. renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
  13981. renderTargetProperties.__webglColorRenderbuffer = _gl.createRenderbuffer();
  13982. _gl.bindRenderbuffer(36161, renderTargetProperties.__webglColorRenderbuffer);
  13983. var glFormat = utils.convert(renderTarget.texture.format);
  13984. var glType = utils.convert(renderTarget.texture.type);
  13985. var glInternalFormat = getInternalFormat(renderTarget.texture.internalFormat, glFormat, glType);
  13986. var samples = getRenderTargetSamples(renderTarget);
  13987. _gl.renderbufferStorageMultisample(36161, samples, glInternalFormat, renderTarget.width, renderTarget.height);
  13988. _gl.bindFramebuffer(36160, renderTargetProperties.__webglMultisampledFramebuffer);
  13989. _gl.framebufferRenderbuffer(36160, 36064, 36161, renderTargetProperties.__webglColorRenderbuffer);
  13990. _gl.bindRenderbuffer(36161, null);
  13991. if (renderTarget.depthBuffer) {
  13992. renderTargetProperties.__webglDepthRenderbuffer = _gl.createRenderbuffer();
  13993. setupRenderBufferStorage(renderTargetProperties.__webglDepthRenderbuffer, renderTarget, true);
  13994. }
  13995. _gl.bindFramebuffer(36160, null);
  13996. } else {
  13997. console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");
  13998. }
  13999. } else if (isMultiview) {
  14000. var width = renderTarget.width;
  14001. var height = renderTarget.height;
  14002. var numViews = renderTarget.numViews;
  14003. _gl.bindFramebuffer(36160, renderTargetProperties.__webglFramebuffer);
  14004. var ext = extensions.get("OVR_multiview2");
  14005. info.memory.textures += 2;
  14006. var colorTexture = _gl.createTexture();
  14007. _gl.bindTexture(35866, colorTexture);
  14008. _gl.texParameteri(35866, 10240, 9728);
  14009. _gl.texParameteri(35866, 10241, 9728);
  14010. _gl.texImage3D(35866, 0, 32856, width, height, numViews, 0, 6408, 5121, null);
  14011. ext.framebufferTextureMultiviewOVR(36160, 36064, colorTexture, 0, 0, numViews);
  14012. var depthStencilTexture = _gl.createTexture();
  14013. _gl.bindTexture(35866, depthStencilTexture);
  14014. _gl.texParameteri(35866, 10240, 9728);
  14015. _gl.texParameteri(35866, 10241, 9728);
  14016. _gl.texImage3D(35866, 0, 35056, width, height, numViews, 0, 34041, 34042, null);
  14017. ext.framebufferTextureMultiviewOVR(36160, 33306, depthStencilTexture, 0, 0, numViews);
  14018. var viewFramebuffers = new Array(numViews);
  14019. for (var i2 = 0; i2 < numViews; ++i2) {
  14020. viewFramebuffers[i2] = _gl.createFramebuffer();
  14021. _gl.bindFramebuffer(36160, viewFramebuffers[i2]);
  14022. _gl.framebufferTextureLayer(36160, 36064, colorTexture, 0, i2);
  14023. }
  14024. renderTargetProperties.__webglColorTexture = colorTexture;
  14025. renderTargetProperties.__webglDepthStencilTexture = depthStencilTexture;
  14026. renderTargetProperties.__webglViewFramebuffers = viewFramebuffers;
  14027. _gl.bindFramebuffer(36160, null);
  14028. _gl.bindTexture(35866, null);
  14029. }
  14030. }
  14031. if (isCube) {
  14032. state.bindTexture(34067, textureProperties.__webglTexture);
  14033. setTextureParameters(34067, renderTarget.texture, supportsMips);
  14034. for (var i2 = 0; i2 < 6; i2++) {
  14035. setupFrameBufferTexture(renderTargetProperties.__webglFramebuffer[i2], renderTarget, 36064, 34069 + i2);
  14036. }
  14037. if (textureNeedsGenerateMipmaps(renderTarget.texture, supportsMips)) {
  14038. generateMipmap(34067, renderTarget.texture, renderTarget.width, renderTarget.height);
  14039. }
  14040. state.bindTexture(34067, null);
  14041. } else if (!isMultiview) {
  14042. state.bindTexture(3553, textureProperties.__webglTexture);
  14043. setTextureParameters(3553, renderTarget.texture, supportsMips);
  14044. setupFrameBufferTexture(renderTargetProperties.__webglFramebuffer, renderTarget, 36064, 3553);
  14045. if (textureNeedsGenerateMipmaps(renderTarget.texture, supportsMips)) {
  14046. generateMipmap(3553, renderTarget.texture, renderTarget.width, renderTarget.height);
  14047. }
  14048. state.bindTexture(3553, null);
  14049. }
  14050. if (renderTarget.depthBuffer) {
  14051. setupDepthRenderbuffer(renderTarget);
  14052. }
  14053. }
  14054. function updateRenderTargetMipmap(renderTarget) {
  14055. var texture = renderTarget.texture;
  14056. var supportsMips = isPowerOfTwo(renderTarget) || isWebGL2;
  14057. if (textureNeedsGenerateMipmaps(texture, supportsMips)) {
  14058. var target = renderTarget.isWebGLCubeRenderTarget ? 34067 : 3553;
  14059. var webglTexture = properties.get(texture).__webglTexture;
  14060. state.bindTexture(target, webglTexture);
  14061. generateMipmap(target, texture, renderTarget.width, renderTarget.height);
  14062. state.bindTexture(target, null);
  14063. }
  14064. }
  14065. function updateMultisampleRenderTarget(renderTarget) {
  14066. if (renderTarget.isWebGLMultisampleRenderTarget) {
  14067. if (isWebGL2) {
  14068. var renderTargetProperties = properties.get(renderTarget);
  14069. _gl.bindFramebuffer(36008, renderTargetProperties.__webglMultisampledFramebuffer);
  14070. _gl.bindFramebuffer(36009, renderTargetProperties.__webglFramebuffer);
  14071. var width = renderTarget.width;
  14072. var height = renderTarget.height;
  14073. var mask = 16384;
  14074. if (renderTarget.depthBuffer)
  14075. mask |= 256;
  14076. if (renderTarget.stencilBuffer)
  14077. mask |= 1024;
  14078. _gl.blitFramebuffer(0, 0, width, height, 0, 0, width, height, mask, 9728);
  14079. } else {
  14080. console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");
  14081. }
  14082. }
  14083. }
  14084. function getRenderTargetSamples(renderTarget) {
  14085. return isWebGL2 && renderTarget.isWebGLMultisampleRenderTarget ? Math.min(maxSamples, renderTarget.samples) : 0;
  14086. }
  14087. function updateVideoTexture(texture) {
  14088. var frame = info.render.frame;
  14089. if (_videoTextures.get(texture) !== frame) {
  14090. _videoTextures.set(texture, frame);
  14091. texture.update();
  14092. }
  14093. }
  14094. var warnedTexture2D = false;
  14095. var warnedTextureCube = false;
  14096. function safeSetTexture2D(texture, slot) {
  14097. if (texture && texture.isWebGLRenderTarget) {
  14098. if (warnedTexture2D === false) {
  14099. console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead.");
  14100. warnedTexture2D = true;
  14101. }
  14102. texture = texture.texture;
  14103. }
  14104. setTexture2D(texture, slot);
  14105. }
  14106. function safeSetTextureCube(texture, slot) {
  14107. if (texture && texture.isWebGLCubeRenderTarget) {
  14108. if (warnedTextureCube === false) {
  14109. console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead.");
  14110. warnedTextureCube = true;
  14111. }
  14112. texture = texture.texture;
  14113. }
  14114. if (texture && texture.isCubeTexture || Array.isArray(texture.image) && texture.image.length === 6) {
  14115. setTextureCube(texture, slot);
  14116. } else {
  14117. setTextureCubeDynamic(texture, slot);
  14118. }
  14119. }
  14120. this.allocateTextureUnit = allocateTextureUnit;
  14121. this.resetTextureUnits = resetTextureUnits;
  14122. this.setTexture2D = setTexture2D;
  14123. this.setTexture2DArray = setTexture2DArray;
  14124. this.setTexture3D = setTexture3D;
  14125. this.setTextureCube = setTextureCube;
  14126. this.setTextureCubeDynamic = setTextureCubeDynamic;
  14127. this.setupRenderTarget = setupRenderTarget;
  14128. this.updateRenderTargetMipmap = updateRenderTargetMipmap;
  14129. this.updateMultisampleRenderTarget = updateMultisampleRenderTarget;
  14130. this.safeSetTexture2D = safeSetTexture2D;
  14131. this.safeSetTextureCube = safeSetTextureCube;
  14132. }
  14133. function WebGLUtils(gl, extensions, capabilities) {
  14134. var isWebGL2 = capabilities.isWebGL2;
  14135. function convert(p) {
  14136. var extension;
  14137. if (p === UnsignedByteType)
  14138. return 5121;
  14139. if (p === UnsignedShort4444Type)
  14140. return 32819;
  14141. if (p === UnsignedShort5551Type)
  14142. return 32820;
  14143. if (p === UnsignedShort565Type)
  14144. return 33635;
  14145. if (p === ByteType)
  14146. return 5120;
  14147. if (p === ShortType)
  14148. return 5122;
  14149. if (p === UnsignedShortType)
  14150. return 5123;
  14151. if (p === IntType)
  14152. return 5124;
  14153. if (p === UnsignedIntType)
  14154. return 5125;
  14155. if (p === FloatType)
  14156. return 5126;
  14157. if (p === HalfFloatType) {
  14158. if (isWebGL2)
  14159. return 5131;
  14160. extension = extensions.get("OES_texture_half_float");
  14161. if (extension !== null) {
  14162. return extension.HALF_FLOAT_OES;
  14163. } else {
  14164. return null;
  14165. }
  14166. }
  14167. if (p === AlphaFormat)
  14168. return 6406;
  14169. if (p === RGBFormat)
  14170. return 6407;
  14171. if (p === RGBAFormat)
  14172. return 6408;
  14173. if (p === LuminanceFormat)
  14174. return 6409;
  14175. if (p === LuminanceAlphaFormat)
  14176. return 6410;
  14177. if (p === DepthFormat)
  14178. return 6402;
  14179. if (p === DepthStencilFormat)
  14180. return 34041;
  14181. if (p === RedFormat)
  14182. return 6403;
  14183. if (p === RedIntegerFormat)
  14184. return 36244;
  14185. if (p === RGFormat)
  14186. return 33319;
  14187. if (p === RGIntegerFormat)
  14188. return 33320;
  14189. if (p === RGBIntegerFormat)
  14190. return 36248;
  14191. if (p === RGBAIntegerFormat)
  14192. return 36249;
  14193. if (p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format || p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format) {
  14194. extension = extensions.get("WEBGL_compressed_texture_s3tc");
  14195. if (extension !== null) {
  14196. if (p === RGB_S3TC_DXT1_Format)
  14197. return extension.COMPRESSED_RGB_S3TC_DXT1_EXT;
  14198. if (p === RGBA_S3TC_DXT1_Format)
  14199. return extension.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  14200. if (p === RGBA_S3TC_DXT3_Format)
  14201. return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  14202. if (p === RGBA_S3TC_DXT5_Format)
  14203. return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  14204. } else {
  14205. return null;
  14206. }
  14207. }
  14208. if (p === RGB_PVRTC_4BPPV1_Format || p === RGB_PVRTC_2BPPV1_Format || p === RGBA_PVRTC_4BPPV1_Format || p === RGBA_PVRTC_2BPPV1_Format) {
  14209. extension = extensions.get("WEBGL_compressed_texture_pvrtc");
  14210. if (extension !== null) {
  14211. if (p === RGB_PVRTC_4BPPV1_Format)
  14212. return extension.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
  14213. if (p === RGB_PVRTC_2BPPV1_Format)
  14214. return extension.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
  14215. if (p === RGBA_PVRTC_4BPPV1_Format)
  14216. return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
  14217. if (p === RGBA_PVRTC_2BPPV1_Format)
  14218. return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
  14219. } else {
  14220. return null;
  14221. }
  14222. }
  14223. if (p === RGB_ETC1_Format) {
  14224. extension = extensions.get("WEBGL_compressed_texture_etc1");
  14225. if (extension !== null) {
  14226. return extension.COMPRESSED_RGB_ETC1_WEBGL;
  14227. } else {
  14228. return null;
  14229. }
  14230. }
  14231. if (p === RGBA_ASTC_4x4_Format || p === RGBA_ASTC_5x4_Format || p === RGBA_ASTC_5x5_Format || p === RGBA_ASTC_6x5_Format || p === RGBA_ASTC_6x6_Format || p === RGBA_ASTC_8x5_Format || p === RGBA_ASTC_8x6_Format || p === RGBA_ASTC_8x8_Format || p === RGBA_ASTC_10x5_Format || p === RGBA_ASTC_10x6_Format || p === RGBA_ASTC_10x8_Format || p === RGBA_ASTC_10x10_Format || p === RGBA_ASTC_12x10_Format || p === RGBA_ASTC_12x12_Format) {
  14232. extension = extensions.get("WEBGL_compressed_texture_astc");
  14233. if (extension !== null) {
  14234. return p;
  14235. } else {
  14236. return null;
  14237. }
  14238. }
  14239. if (p === UnsignedInt248Type) {
  14240. if (isWebGL2)
  14241. return 34042;
  14242. extension = extensions.get("WEBGL_depth_texture");
  14243. if (extension !== null) {
  14244. return extension.UNSIGNED_INT_24_8_WEBGL;
  14245. } else {
  14246. return null;
  14247. }
  14248. }
  14249. }
  14250. return { convert };
  14251. }
  14252. function WebGLMultiviewRenderTarget(width, height, numViews, options) {
  14253. WebGLRenderTarget.call(this, width, height, options);
  14254. this.depthBuffer = false;
  14255. this.stencilBuffer = false;
  14256. this.numViews = numViews;
  14257. }
  14258. WebGLMultiviewRenderTarget.prototype = Object.assign(Object.create(WebGLRenderTarget.prototype), {
  14259. constructor: WebGLMultiviewRenderTarget,
  14260. isWebGLMultiviewRenderTarget: true,
  14261. copy: function(source) {
  14262. WebGLRenderTarget.prototype.copy.call(this, source);
  14263. this.numViews = source.numViews;
  14264. return this;
  14265. },
  14266. setNumViews: function(numViews) {
  14267. if (this.numViews !== numViews) {
  14268. this.numViews = numViews;
  14269. this.dispose();
  14270. }
  14271. return this;
  14272. }
  14273. });
  14274. function WebGLMultiview(renderer, gl) {
  14275. var DEFAULT_NUMVIEWS = 2;
  14276. var extensions = renderer.extensions;
  14277. var properties = renderer.properties;
  14278. var renderTarget, currentRenderTarget;
  14279. var mat3, mat4, cameraArray, renderSize;
  14280. var available;
  14281. var maxNumViews = 0;
  14282. function isAvailable() {
  14283. if (available === void 0) {
  14284. var extension = extensions.get("OVR_multiview2");
  14285. available = extension !== null && gl.getContextAttributes().antialias === false;
  14286. if (available) {
  14287. maxNumViews = gl.getParameter(extension.MAX_VIEWS_OVR);
  14288. renderTarget = new WebGLMultiviewRenderTarget(0, 0, DEFAULT_NUMVIEWS);
  14289. renderSize = new Vector2();
  14290. mat4 = [];
  14291. mat3 = [];
  14292. cameraArray = [];
  14293. for (var i2 = 0; i2 < maxNumViews; i2++) {
  14294. mat4[i2] = new Matrix4();
  14295. mat3[i2] = new Matrix3();
  14296. }
  14297. }
  14298. }
  14299. return available;
  14300. }
  14301. function getCameraArray(camera) {
  14302. if (camera.isArrayCamera)
  14303. return camera.cameras;
  14304. cameraArray[0] = camera;
  14305. return cameraArray;
  14306. }
  14307. function updateCameraProjectionMatricesUniform(camera, uniforms) {
  14308. var cameras = getCameraArray(camera);
  14309. for (var i2 = 0; i2 < cameras.length; i2++) {
  14310. mat4[i2].copy(cameras[i2].projectionMatrix);
  14311. }
  14312. uniforms.setValue(gl, "projectionMatrices", mat4);
  14313. }
  14314. function updateCameraViewMatricesUniform(camera, uniforms) {
  14315. var cameras = getCameraArray(camera);
  14316. for (var i2 = 0; i2 < cameras.length; i2++) {
  14317. mat4[i2].copy(cameras[i2].matrixWorldInverse);
  14318. }
  14319. uniforms.setValue(gl, "viewMatrices", mat4);
  14320. }
  14321. function updateObjectMatricesUniforms(object, camera, uniforms) {
  14322. var cameras = getCameraArray(camera);
  14323. for (var i2 = 0; i2 < cameras.length; i2++) {
  14324. mat4[i2].multiplyMatrices(cameras[i2].matrixWorldInverse, object.matrixWorld);
  14325. mat3[i2].getNormalMatrix(mat4[i2]);
  14326. }
  14327. uniforms.setValue(gl, "modelViewMatrices", mat4);
  14328. uniforms.setValue(gl, "normalMatrices", mat3);
  14329. }
  14330. function isMultiviewCompatible(camera) {
  14331. if (camera.isArrayCamera === void 0)
  14332. return true;
  14333. var cameras = camera.cameras;
  14334. if (cameras.length > maxNumViews)
  14335. return false;
  14336. for (var i2 = 1, il = cameras.length; i2 < il; i2++) {
  14337. if (cameras[0].viewport.z !== cameras[i2].viewport.z || cameras[0].viewport.w !== cameras[i2].viewport.w)
  14338. return false;
  14339. }
  14340. return true;
  14341. }
  14342. function resizeRenderTarget(camera) {
  14343. if (currentRenderTarget) {
  14344. renderSize.set(currentRenderTarget.width, currentRenderTarget.height);
  14345. } else {
  14346. renderer.getDrawingBufferSize(renderSize);
  14347. }
  14348. if (camera.isArrayCamera) {
  14349. var viewport = camera.cameras[0].viewport;
  14350. renderTarget.setSize(viewport.z, viewport.w);
  14351. renderTarget.setNumViews(camera.cameras.length);
  14352. } else {
  14353. renderTarget.setSize(renderSize.x, renderSize.y);
  14354. renderTarget.setNumViews(DEFAULT_NUMVIEWS);
  14355. }
  14356. }
  14357. function attachCamera(camera) {
  14358. if (isMultiviewCompatible(camera) === false)
  14359. return;
  14360. currentRenderTarget = renderer.getRenderTarget();
  14361. resizeRenderTarget(camera);
  14362. renderer.setRenderTarget(renderTarget);
  14363. }
  14364. function detachCamera(camera) {
  14365. if (renderTarget !== renderer.getRenderTarget())
  14366. return;
  14367. renderer.setRenderTarget(currentRenderTarget);
  14368. flush(camera);
  14369. }
  14370. function flush(camera) {
  14371. var srcRenderTarget = renderTarget;
  14372. var numViews = srcRenderTarget.numViews;
  14373. var srcFramebuffers = properties.get(srcRenderTarget).__webglViewFramebuffers;
  14374. var viewWidth = srcRenderTarget.width;
  14375. var viewHeight = srcRenderTarget.height;
  14376. if (camera.isArrayCamera) {
  14377. for (var i2 = 0; i2 < numViews; i2++) {
  14378. var viewport = camera.cameras[i2].viewport;
  14379. var x1 = viewport.x;
  14380. var y1 = viewport.y;
  14381. var x2 = x1 + viewport.z;
  14382. var y2 = y1 + viewport.w;
  14383. gl.bindFramebuffer(36008, srcFramebuffers[i2]);
  14384. gl.blitFramebuffer(0, 0, viewWidth, viewHeight, x1, y1, x2, y2, 16384, 9728);
  14385. }
  14386. } else {
  14387. gl.bindFramebuffer(36008, srcFramebuffers[0]);
  14388. gl.blitFramebuffer(0, 0, viewWidth, viewHeight, 0, 0, renderSize.x, renderSize.y, 16384, 9728);
  14389. }
  14390. }
  14391. this.isAvailable = isAvailable;
  14392. this.attachCamera = attachCamera;
  14393. this.detachCamera = detachCamera;
  14394. this.updateCameraProjectionMatricesUniform = updateCameraProjectionMatricesUniform;
  14395. this.updateCameraViewMatricesUniform = updateCameraViewMatricesUniform;
  14396. this.updateObjectMatricesUniforms = updateObjectMatricesUniforms;
  14397. }
  14398. function ArrayCamera(array) {
  14399. PerspectiveCamera.call(this);
  14400. this.cameras = array || [];
  14401. }
  14402. ArrayCamera.prototype = Object.assign(Object.create(PerspectiveCamera.prototype), {
  14403. constructor: ArrayCamera,
  14404. isArrayCamera: true
  14405. });
  14406. function Group() {
  14407. Object3D.call(this);
  14408. this.type = "Group";
  14409. }
  14410. Group.prototype = Object.assign(Object.create(Object3D.prototype), {
  14411. constructor: Group,
  14412. isGroup: true
  14413. });
  14414. function WebXRManager(renderer, gl) {
  14415. var scope = this;
  14416. var session = null;
  14417. var referenceSpace = null;
  14418. var referenceSpaceType = "local-floor";
  14419. var pose = null;
  14420. var controllers = [];
  14421. var inputSourcesMap = /* @__PURE__ */ new Map();
  14422. var cameraL = new PerspectiveCamera();
  14423. cameraL.layers.enable(1);
  14424. cameraL.viewport = new Vector4();
  14425. var cameraR = new PerspectiveCamera();
  14426. cameraR.layers.enable(2);
  14427. cameraR.viewport = new Vector4();
  14428. var cameraVR = new ArrayCamera([cameraL, cameraR]);
  14429. cameraVR.layers.enable(1);
  14430. cameraVR.layers.enable(2);
  14431. var _currentDepthNear = null;
  14432. var _currentDepthFar = null;
  14433. this.enabled = false;
  14434. this.isPresenting = false;
  14435. this.getController = function(id) {
  14436. var controller = controllers[id];
  14437. if (controller === void 0) {
  14438. controller = {};
  14439. controllers[id] = controller;
  14440. }
  14441. if (controller.targetRay === void 0) {
  14442. controller.targetRay = new Group();
  14443. controller.targetRay.matrixAutoUpdate = false;
  14444. controller.targetRay.visible = false;
  14445. }
  14446. return controller.targetRay;
  14447. };
  14448. this.getControllerGrip = function(id) {
  14449. var controller = controllers[id];
  14450. if (controller === void 0) {
  14451. controller = {};
  14452. controllers[id] = controller;
  14453. }
  14454. if (controller.grip === void 0) {
  14455. controller.grip = new Group();
  14456. controller.grip.matrixAutoUpdate = false;
  14457. controller.grip.visible = false;
  14458. }
  14459. return controller.grip;
  14460. };
  14461. function onSessionEvent(event) {
  14462. var controller = inputSourcesMap.get(event.inputSource);
  14463. if (controller) {
  14464. if (controller.targetRay) {
  14465. controller.targetRay.dispatchEvent({ type: event.type });
  14466. }
  14467. if (controller.grip) {
  14468. controller.grip.dispatchEvent({ type: event.type });
  14469. }
  14470. }
  14471. }
  14472. function onSessionEnd() {
  14473. inputSourcesMap.forEach(function(controller, inputSource) {
  14474. if (controller.targetRay) {
  14475. controller.targetRay.dispatchEvent({ type: "disconnected", data: inputSource });
  14476. controller.targetRay.visible = false;
  14477. }
  14478. if (controller.grip) {
  14479. controller.grip.dispatchEvent({ type: "disconnected", data: inputSource });
  14480. controller.grip.visible = false;
  14481. }
  14482. });
  14483. inputSourcesMap.clear();
  14484. renderer.setFramebuffer(null);
  14485. renderer.setRenderTarget(renderer.getRenderTarget());
  14486. animation.stop();
  14487. scope.isPresenting = false;
  14488. scope.dispatchEvent({ type: "sessionend" });
  14489. }
  14490. function onRequestReferenceSpace(value) {
  14491. referenceSpace = value;
  14492. animation.setContext(session);
  14493. animation.start();
  14494. scope.isPresenting = true;
  14495. scope.dispatchEvent({ type: "sessionstart" });
  14496. }
  14497. this.setFramebufferScaleFactor = function() {
  14498. };
  14499. this.setReferenceSpaceType = function(value) {
  14500. referenceSpaceType = value;
  14501. };
  14502. this.getReferenceSpace = function() {
  14503. return referenceSpace;
  14504. };
  14505. this.getSession = function() {
  14506. return session;
  14507. };
  14508. this.setSession = function(value) {
  14509. session = value;
  14510. if (session !== null) {
  14511. session.addEventListener("select", onSessionEvent);
  14512. session.addEventListener("selectstart", onSessionEvent);
  14513. session.addEventListener("selectend", onSessionEvent);
  14514. session.addEventListener("squeeze", onSessionEvent);
  14515. session.addEventListener("squeezestart", onSessionEvent);
  14516. session.addEventListener("squeezeend", onSessionEvent);
  14517. session.addEventListener("end", onSessionEnd);
  14518. var attributes = gl.getContextAttributes();
  14519. var layerInit = {
  14520. antialias: attributes.antialias,
  14521. alpha: attributes.alpha,
  14522. depth: attributes.depth,
  14523. stencil: attributes.stencil
  14524. };
  14525. var baseLayer = new XRWebGLLayer(session, gl, layerInit);
  14526. session.updateRenderState({ baseLayer });
  14527. session.requestReferenceSpace(referenceSpaceType).then(onRequestReferenceSpace);
  14528. session.addEventListener("inputsourceschange", updateInputSources);
  14529. }
  14530. };
  14531. function updateInputSources(event) {
  14532. var inputSources = session.inputSources;
  14533. for (var i2 = 0; i2 < controllers.length; i2++) {
  14534. inputSourcesMap.set(inputSources[i2], controllers[i2]);
  14535. }
  14536. for (var i2 = 0; i2 < event.removed.length; i2++) {
  14537. var inputSource = event.removed[i2];
  14538. var controller = inputSourcesMap.get(inputSource);
  14539. if (controller) {
  14540. if (controller.targetRay) {
  14541. controller.targetRay.dispatchEvent({ type: "disconnected", data: inputSource });
  14542. }
  14543. if (controller.grip) {
  14544. controller.grip.dispatchEvent({ type: "disconnected", data: inputSource });
  14545. }
  14546. inputSourcesMap.delete(inputSource);
  14547. }
  14548. }
  14549. for (var i2 = 0; i2 < event.added.length; i2++) {
  14550. var inputSource = event.added[i2];
  14551. var controller = inputSourcesMap.get(inputSource);
  14552. if (controller) {
  14553. if (controller.targetRay) {
  14554. controller.targetRay.dispatchEvent({ type: "connected", data: inputSource });
  14555. }
  14556. if (controller.grip) {
  14557. controller.grip.dispatchEvent({ type: "connected", data: inputSource });
  14558. }
  14559. }
  14560. }
  14561. }
  14562. var cameraLPos = new Vector3();
  14563. var cameraRPos = new Vector3();
  14564. function setProjectionFromUnion(camera, cameraL2, cameraR2) {
  14565. cameraLPos.setFromMatrixPosition(cameraL2.matrixWorld);
  14566. cameraRPos.setFromMatrixPosition(cameraR2.matrixWorld);
  14567. var ipd = cameraLPos.distanceTo(cameraRPos);
  14568. var projL = cameraL2.projectionMatrix.elements;
  14569. var projR = cameraR2.projectionMatrix.elements;
  14570. var near = projL[14] / (projL[10] - 1);
  14571. var far = projL[14] / (projL[10] + 1);
  14572. var topFov = (projL[9] + 1) / projL[5];
  14573. var bottomFov = (projL[9] - 1) / projL[5];
  14574. var leftFov = (projL[8] - 1) / projL[0];
  14575. var rightFov = (projR[8] + 1) / projR[0];
  14576. var left = near * leftFov;
  14577. var right = near * rightFov;
  14578. var zOffset = ipd / (-leftFov + rightFov);
  14579. var xOffset = zOffset * -leftFov;
  14580. cameraL2.matrixWorld.decompose(camera.position, camera.quaternion, camera.scale);
  14581. camera.translateX(xOffset);
  14582. camera.translateZ(zOffset);
  14583. camera.matrixWorld.compose(camera.position, camera.quaternion, camera.scale);
  14584. camera.matrixWorldInverse.getInverse(camera.matrixWorld);
  14585. var near2 = near + zOffset;
  14586. var far2 = far + zOffset;
  14587. var left2 = left - xOffset;
  14588. var right2 = right + (ipd - xOffset);
  14589. var top2 = topFov * far / far2 * near2;
  14590. var bottom2 = bottomFov * far / far2 * near2;
  14591. camera.projectionMatrix.makePerspective(left2, right2, top2, bottom2, near2, far2);
  14592. }
  14593. function updateCamera(camera, parent) {
  14594. if (parent === null) {
  14595. camera.matrixWorld.copy(camera.matrix);
  14596. } else {
  14597. camera.matrixWorld.multiplyMatrices(parent.matrixWorld, camera.matrix);
  14598. }
  14599. camera.matrixWorldInverse.getInverse(camera.matrixWorld);
  14600. }
  14601. this.getCamera = function(camera) {
  14602. cameraVR.near = cameraR.near = cameraL.near = camera.near;
  14603. cameraVR.far = cameraR.far = cameraL.far = camera.far;
  14604. if (_currentDepthNear !== cameraVR.near || _currentDepthFar !== cameraVR.far) {
  14605. session.updateRenderState({
  14606. depthNear: cameraVR.near,
  14607. depthFar: cameraVR.far
  14608. });
  14609. _currentDepthNear = cameraVR.near;
  14610. _currentDepthFar = cameraVR.far;
  14611. }
  14612. var parent = camera.parent;
  14613. var cameras = cameraVR.cameras;
  14614. updateCamera(cameraVR, parent);
  14615. for (var i2 = 0; i2 < cameras.length; i2++) {
  14616. updateCamera(cameras[i2], parent);
  14617. }
  14618. camera.matrixWorld.copy(cameraVR.matrixWorld);
  14619. var children = camera.children;
  14620. for (var i2 = 0, l = children.length; i2 < l; i2++) {
  14621. children[i2].updateMatrixWorld(true);
  14622. }
  14623. setProjectionFromUnion(cameraVR, cameraL, cameraR);
  14624. return cameraVR;
  14625. };
  14626. var onAnimationFrameCallback = null;
  14627. function onAnimationFrame(time, frame) {
  14628. pose = frame.getViewerPose(referenceSpace);
  14629. if (pose !== null) {
  14630. var views = pose.views;
  14631. var baseLayer = session.renderState.baseLayer;
  14632. renderer.setFramebuffer(baseLayer.framebuffer);
  14633. for (var i2 = 0; i2 < views.length; i2++) {
  14634. var view = views[i2];
  14635. var viewport = baseLayer.getViewport(view);
  14636. var camera = cameraVR.cameras[i2];
  14637. camera.matrix.fromArray(view.transform.matrix);
  14638. camera.projectionMatrix.fromArray(view.projectionMatrix);
  14639. camera.viewport.set(viewport.x, viewport.y, viewport.width, viewport.height);
  14640. if (i2 === 0) {
  14641. cameraVR.matrix.copy(camera.matrix);
  14642. }
  14643. }
  14644. }
  14645. var inputSources = session.inputSources;
  14646. for (var i2 = 0; i2 < controllers.length; i2++) {
  14647. var controller = controllers[i2];
  14648. var inputSource = inputSources[i2];
  14649. var inputPose = null;
  14650. var gripPose = null;
  14651. if (inputSource) {
  14652. if (controller.targetRay) {
  14653. inputPose = frame.getPose(inputSource.targetRaySpace, referenceSpace);
  14654. if (inputPose !== null) {
  14655. controller.targetRay.matrix.fromArray(inputPose.transform.matrix);
  14656. controller.targetRay.matrix.decompose(controller.targetRay.position, controller.targetRay.rotation, controller.targetRay.scale);
  14657. }
  14658. }
  14659. if (controller.grip && inputSource.gripSpace) {
  14660. gripPose = frame.getPose(inputSource.gripSpace, referenceSpace);
  14661. if (gripPose !== null) {
  14662. controller.grip.matrix.fromArray(gripPose.transform.matrix);
  14663. controller.grip.matrix.decompose(controller.grip.position, controller.grip.rotation, controller.grip.scale);
  14664. }
  14665. }
  14666. }
  14667. if (controller.targetRay) {
  14668. controller.targetRay.visible = inputPose !== null;
  14669. }
  14670. if (controller.grip) {
  14671. controller.grip.visible = gripPose !== null;
  14672. }
  14673. }
  14674. if (onAnimationFrameCallback)
  14675. onAnimationFrameCallback(time, frame);
  14676. }
  14677. var animation = new WebGLAnimation();
  14678. animation.setAnimationLoop(onAnimationFrame);
  14679. this.setAnimationLoop = function(callback) {
  14680. onAnimationFrameCallback = callback;
  14681. };
  14682. this.dispose = function() {
  14683. };
  14684. }
  14685. Object.assign(WebXRManager.prototype, EventDispatcher.prototype);
  14686. function WebGLRenderer(parameters) {
  14687. parameters = parameters || {};
  14688. var _canvas2 = parameters.canvas !== void 0 ? parameters.canvas : document.createElementNS("http://www.w3.org/1999/xhtml", "canvas"), _context2 = parameters.context !== void 0 ? parameters.context : null, _alpha = parameters.alpha !== void 0 ? parameters.alpha : false, _depth = parameters.depth !== void 0 ? parameters.depth : true, _stencil = parameters.stencil !== void 0 ? parameters.stencil : true, _antialias = parameters.antialias !== void 0 ? parameters.antialias : false, _premultipliedAlpha = parameters.premultipliedAlpha !== void 0 ? parameters.premultipliedAlpha : true, _preserveDrawingBuffer = parameters.preserveDrawingBuffer !== void 0 ? parameters.preserveDrawingBuffer : false, _powerPreference = parameters.powerPreference !== void 0 ? parameters.powerPreference : "default", _failIfMajorPerformanceCaveat = parameters.failIfMajorPerformanceCaveat !== void 0 ? parameters.failIfMajorPerformanceCaveat : false;
  14689. var currentRenderList = null;
  14690. var currentRenderState = null;
  14691. this.domElement = _canvas2;
  14692. this.debug = {
  14693. /**
  14694. * Enables error checking and reporting when shader programs are being compiled
  14695. * @type {boolean}
  14696. */
  14697. checkShaderErrors: true
  14698. };
  14699. this.autoClear = true;
  14700. this.autoClearColor = true;
  14701. this.autoClearDepth = true;
  14702. this.autoClearStencil = true;
  14703. this.sortObjects = true;
  14704. this.clippingPlanes = [];
  14705. this.localClippingEnabled = false;
  14706. this.gammaFactor = 2;
  14707. this.outputEncoding = LinearEncoding;
  14708. this.physicallyCorrectLights = false;
  14709. this.toneMapping = LinearToneMapping;
  14710. this.toneMappingExposure = 1;
  14711. this.toneMappingWhitePoint = 1;
  14712. this.maxMorphTargets = 8;
  14713. this.maxMorphNormals = 4;
  14714. var _this = this, _isContextLost = false, _framebuffer = null, _currentActiveCubeFace = 0, _currentActiveMipmapLevel = 0, _currentRenderTarget = null, _currentFramebuffer = null, _currentMaterialId = -1, _currentGeometryProgram = {
  14715. geometry: null,
  14716. program: null,
  14717. wireframe: false
  14718. }, _currentCamera = null, _currentArrayCamera = null, _currentViewport = new Vector4(), _currentScissor = new Vector4(), _currentScissorTest = null, _width = _canvas2.width, _height = _canvas2.height, _pixelRatio = 1, _opaqueSort = null, _transparentSort = null, _viewport = new Vector4(0, 0, _width, _height), _scissor = new Vector4(0, 0, _width, _height), _scissorTest = false, _frustum = new Frustum(), _clipping = new WebGLClipping(), _clippingEnabled = false, _localClippingEnabled = false, _projScreenMatrix = new Matrix4(), _vector3 = new Vector3();
  14719. function getTargetPixelRatio() {
  14720. return _currentRenderTarget === null ? _pixelRatio : 1;
  14721. }
  14722. var _gl;
  14723. try {
  14724. var contextAttributes = {
  14725. alpha: _alpha,
  14726. depth: _depth,
  14727. stencil: _stencil,
  14728. antialias: _antialias,
  14729. premultipliedAlpha: _premultipliedAlpha,
  14730. preserveDrawingBuffer: _preserveDrawingBuffer,
  14731. powerPreference: _powerPreference,
  14732. failIfMajorPerformanceCaveat: _failIfMajorPerformanceCaveat,
  14733. xrCompatible: true
  14734. };
  14735. _canvas2.addEventListener("webglcontextlost", onContextLost, false);
  14736. _canvas2.addEventListener("webglcontextrestored", onContextRestore, false);
  14737. _gl = _context2 || _canvas2.getContext("webgl", contextAttributes) || _canvas2.getContext("experimental-webgl", contextAttributes);
  14738. if (_gl === null) {
  14739. if (_canvas2.getContext("webgl") !== null) {
  14740. throw new Error("Error creating WebGL context with your selected attributes.");
  14741. } else {
  14742. throw new Error("Error creating WebGL context.");
  14743. }
  14744. }
  14745. if (_gl.getShaderPrecisionFormat === void 0) {
  14746. _gl.getShaderPrecisionFormat = function() {
  14747. return { "rangeMin": 1, "rangeMax": 1, "precision": 1 };
  14748. };
  14749. }
  14750. } catch (error) {
  14751. console.error("THREE.WebGLRenderer: " + error.message);
  14752. throw error;
  14753. }
  14754. var extensions, capabilities, state, info;
  14755. var properties, textures, attributes, geometries, objects;
  14756. var programCache, renderLists, renderStates;
  14757. var background, morphtargets, bufferRenderer, indexedBufferRenderer;
  14758. var utils;
  14759. function initGLContext() {
  14760. extensions = new WebGLExtensions(_gl);
  14761. capabilities = new WebGLCapabilities(_gl, extensions, parameters);
  14762. if (capabilities.isWebGL2 === false) {
  14763. extensions.get("WEBGL_depth_texture");
  14764. extensions.get("OES_texture_float");
  14765. extensions.get("OES_texture_half_float");
  14766. extensions.get("OES_texture_half_float_linear");
  14767. extensions.get("OES_standard_derivatives");
  14768. extensions.get("OES_element_index_uint");
  14769. extensions.get("ANGLE_instanced_arrays");
  14770. }
  14771. extensions.get("OES_texture_float_linear");
  14772. utils = new WebGLUtils(_gl, extensions, capabilities);
  14773. state = new WebGLState(_gl, extensions, capabilities);
  14774. state.scissor(_currentScissor.copy(_scissor).multiplyScalar(_pixelRatio).floor());
  14775. state.viewport(_currentViewport.copy(_viewport).multiplyScalar(_pixelRatio).floor());
  14776. info = new WebGLInfo();
  14777. properties = new WebGLProperties();
  14778. textures = new WebGLTextures(_gl, extensions, state, properties, capabilities, utils, info);
  14779. attributes = new WebGLAttributes(_gl, capabilities);
  14780. geometries = new WebGLGeometries(_gl, attributes, info);
  14781. objects = new WebGLObjects(_gl, geometries, attributes, info);
  14782. morphtargets = new WebGLMorphtargets(_gl);
  14783. programCache = new WebGLPrograms(_this, extensions, capabilities);
  14784. renderLists = new WebGLRenderLists();
  14785. renderStates = new WebGLRenderStates();
  14786. background = new WebGLBackground(_this, state, objects, _premultipliedAlpha);
  14787. bufferRenderer = new WebGLBufferRenderer(_gl, extensions, info, capabilities);
  14788. indexedBufferRenderer = new WebGLIndexedBufferRenderer(_gl, extensions, info, capabilities);
  14789. info.programs = programCache.programs;
  14790. _this.capabilities = capabilities;
  14791. _this.extensions = extensions;
  14792. _this.properties = properties;
  14793. _this.renderLists = renderLists;
  14794. _this.state = state;
  14795. _this.info = info;
  14796. }
  14797. initGLContext();
  14798. var xr = new WebXRManager(_this, _gl);
  14799. this.xr = xr;
  14800. var multiview = new WebGLMultiview(_this, _gl);
  14801. var shadowMap = new WebGLShadowMap(_this, objects, capabilities.maxTextureSize);
  14802. this.shadowMap = shadowMap;
  14803. this.getContext = function() {
  14804. return _gl;
  14805. };
  14806. this.getContextAttributes = function() {
  14807. return _gl.getContextAttributes();
  14808. };
  14809. this.forceContextLoss = function() {
  14810. var extension = extensions.get("WEBGL_lose_context");
  14811. if (extension)
  14812. extension.loseContext();
  14813. };
  14814. this.forceContextRestore = function() {
  14815. var extension = extensions.get("WEBGL_lose_context");
  14816. if (extension)
  14817. extension.restoreContext();
  14818. };
  14819. this.getPixelRatio = function() {
  14820. return _pixelRatio;
  14821. };
  14822. this.setPixelRatio = function(value) {
  14823. if (value === void 0)
  14824. return;
  14825. _pixelRatio = value;
  14826. this.setSize(_width, _height, false);
  14827. };
  14828. this.getSize = function(target) {
  14829. if (target === void 0) {
  14830. console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument");
  14831. target = new Vector2();
  14832. }
  14833. return target.set(_width, _height);
  14834. };
  14835. this.setSize = function(width, height, updateStyle) {
  14836. if (xr.isPresenting) {
  14837. console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");
  14838. return;
  14839. }
  14840. _width = width;
  14841. _height = height;
  14842. _canvas2.width = Math.floor(width * _pixelRatio);
  14843. _canvas2.height = Math.floor(height * _pixelRatio);
  14844. if (updateStyle !== false) {
  14845. _canvas2.style.width = width + "px";
  14846. _canvas2.style.height = height + "px";
  14847. }
  14848. this.setViewport(0, 0, width, height);
  14849. };
  14850. this.getDrawingBufferSize = function(target) {
  14851. if (target === void 0) {
  14852. console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument");
  14853. target = new Vector2();
  14854. }
  14855. return target.set(_width * _pixelRatio, _height * _pixelRatio).floor();
  14856. };
  14857. this.setDrawingBufferSize = function(width, height, pixelRatio) {
  14858. _width = width;
  14859. _height = height;
  14860. _pixelRatio = pixelRatio;
  14861. _canvas2.width = Math.floor(width * pixelRatio);
  14862. _canvas2.height = Math.floor(height * pixelRatio);
  14863. this.setViewport(0, 0, width, height);
  14864. };
  14865. this.getCurrentViewport = function(target) {
  14866. if (target === void 0) {
  14867. console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument");
  14868. target = new Vector4();
  14869. }
  14870. return target.copy(_currentViewport);
  14871. };
  14872. this.getViewport = function(target) {
  14873. return target.copy(_viewport);
  14874. };
  14875. this.setViewport = function(x, y, width, height) {
  14876. if (x.isVector4) {
  14877. _viewport.set(x.x, x.y, x.z, x.w);
  14878. } else {
  14879. _viewport.set(x, y, width, height);
  14880. }
  14881. state.viewport(_currentViewport.copy(_viewport).multiplyScalar(_pixelRatio).floor());
  14882. };
  14883. this.getScissor = function(target) {
  14884. return target.copy(_scissor);
  14885. };
  14886. this.setScissor = function(x, y, width, height) {
  14887. if (x.isVector4) {
  14888. _scissor.set(x.x, x.y, x.z, x.w);
  14889. } else {
  14890. _scissor.set(x, y, width, height);
  14891. }
  14892. state.scissor(_currentScissor.copy(_scissor).multiplyScalar(_pixelRatio).floor());
  14893. };
  14894. this.getScissorTest = function() {
  14895. return _scissorTest;
  14896. };
  14897. this.setScissorTest = function(boolean) {
  14898. state.setScissorTest(_scissorTest = boolean);
  14899. };
  14900. this.setOpaqueSort = function(method) {
  14901. _opaqueSort = method;
  14902. };
  14903. this.setTransparentSort = function(method) {
  14904. _transparentSort = method;
  14905. };
  14906. this.getClearColor = function() {
  14907. return background.getClearColor();
  14908. };
  14909. this.setClearColor = function() {
  14910. background.setClearColor.apply(background, arguments);
  14911. };
  14912. this.getClearAlpha = function() {
  14913. return background.getClearAlpha();
  14914. };
  14915. this.setClearAlpha = function() {
  14916. background.setClearAlpha.apply(background, arguments);
  14917. };
  14918. this.clear = function(color, depth, stencil) {
  14919. var bits = 0;
  14920. if (color === void 0 || color)
  14921. bits |= 16384;
  14922. if (depth === void 0 || depth)
  14923. bits |= 256;
  14924. if (stencil === void 0 || stencil)
  14925. bits |= 1024;
  14926. _gl.clear(bits);
  14927. };
  14928. this.clearColor = function() {
  14929. this.clear(true, false, false);
  14930. };
  14931. this.clearDepth = function() {
  14932. this.clear(false, true, false);
  14933. };
  14934. this.clearStencil = function() {
  14935. this.clear(false, false, true);
  14936. };
  14937. this.dispose = function() {
  14938. _canvas2.removeEventListener("webglcontextlost", onContextLost, false);
  14939. _canvas2.removeEventListener("webglcontextrestored", onContextRestore, false);
  14940. renderLists.dispose();
  14941. renderStates.dispose();
  14942. properties.dispose();
  14943. objects.dispose();
  14944. xr.dispose();
  14945. animation.stop();
  14946. };
  14947. function onContextLost(event) {
  14948. event.preventDefault();
  14949. console.log("THREE.WebGLRenderer: Context Lost.");
  14950. _isContextLost = true;
  14951. }
  14952. function onContextRestore() {
  14953. console.log("THREE.WebGLRenderer: Context Restored.");
  14954. _isContextLost = false;
  14955. initGLContext();
  14956. }
  14957. function onMaterialDispose(event) {
  14958. var material = event.target;
  14959. material.removeEventListener("dispose", onMaterialDispose);
  14960. deallocateMaterial(material);
  14961. }
  14962. function deallocateMaterial(material) {
  14963. releaseMaterialProgramReference(material);
  14964. properties.remove(material);
  14965. }
  14966. function releaseMaterialProgramReference(material) {
  14967. var programInfo = properties.get(material).program;
  14968. material.program = void 0;
  14969. if (programInfo !== void 0) {
  14970. programCache.releaseProgram(programInfo);
  14971. }
  14972. }
  14973. function renderObjectImmediate(object, program) {
  14974. object.render(function(object2) {
  14975. _this.renderBufferImmediate(object2, program);
  14976. });
  14977. }
  14978. this.renderBufferImmediate = function(object, program) {
  14979. state.initAttributes();
  14980. var buffers = properties.get(object);
  14981. if (object.hasPositions && !buffers.position)
  14982. buffers.position = _gl.createBuffer();
  14983. if (object.hasNormals && !buffers.normal)
  14984. buffers.normal = _gl.createBuffer();
  14985. if (object.hasUvs && !buffers.uv)
  14986. buffers.uv = _gl.createBuffer();
  14987. if (object.hasColors && !buffers.color)
  14988. buffers.color = _gl.createBuffer();
  14989. var programAttributes = program.getAttributes();
  14990. if (object.hasPositions) {
  14991. _gl.bindBuffer(34962, buffers.position);
  14992. _gl.bufferData(34962, object.positionArray, 35048);
  14993. state.enableAttribute(programAttributes.position);
  14994. _gl.vertexAttribPointer(programAttributes.position, 3, 5126, false, 0, 0);
  14995. }
  14996. if (object.hasNormals) {
  14997. _gl.bindBuffer(34962, buffers.normal);
  14998. _gl.bufferData(34962, object.normalArray, 35048);
  14999. state.enableAttribute(programAttributes.normal);
  15000. _gl.vertexAttribPointer(programAttributes.normal, 3, 5126, false, 0, 0);
  15001. }
  15002. if (object.hasUvs) {
  15003. _gl.bindBuffer(34962, buffers.uv);
  15004. _gl.bufferData(34962, object.uvArray, 35048);
  15005. state.enableAttribute(programAttributes.uv);
  15006. _gl.vertexAttribPointer(programAttributes.uv, 2, 5126, false, 0, 0);
  15007. }
  15008. if (object.hasColors) {
  15009. _gl.bindBuffer(34962, buffers.color);
  15010. _gl.bufferData(34962, object.colorArray, 35048);
  15011. state.enableAttribute(programAttributes.color);
  15012. _gl.vertexAttribPointer(programAttributes.color, 3, 5126, false, 0, 0);
  15013. }
  15014. state.disableUnusedAttributes();
  15015. _gl.drawArrays(4, 0, object.count);
  15016. object.count = 0;
  15017. };
  15018. var tempScene = new Scene();
  15019. this.renderBufferDirect = function(camera, scene, geometry, material, object, group) {
  15020. if (scene === null)
  15021. scene = tempScene;
  15022. var frontFaceCW = object.isMesh && object.matrixWorld.determinant() < 0;
  15023. var program = setProgram(camera, scene, material, object);
  15024. state.setMaterial(material, frontFaceCW);
  15025. var updateBuffers = false;
  15026. if (_currentGeometryProgram.geometry !== geometry.id || _currentGeometryProgram.program !== program.id || _currentGeometryProgram.wireframe !== (material.wireframe === true)) {
  15027. _currentGeometryProgram.geometry = geometry.id;
  15028. _currentGeometryProgram.program = program.id;
  15029. _currentGeometryProgram.wireframe = material.wireframe === true;
  15030. updateBuffers = true;
  15031. }
  15032. if (material.morphTargets || material.morphNormals) {
  15033. morphtargets.update(object, geometry, material, program);
  15034. updateBuffers = true;
  15035. }
  15036. var index = geometry.index;
  15037. var position = geometry.attributes.position;
  15038. if (index === null) {
  15039. if (position === void 0 || position.count === 0)
  15040. return;
  15041. } else if (index.count === 0) {
  15042. return;
  15043. }
  15044. var rangeFactor = 1;
  15045. if (material.wireframe === true) {
  15046. index = geometries.getWireframeAttribute(geometry);
  15047. rangeFactor = 2;
  15048. }
  15049. var attribute;
  15050. var renderer = bufferRenderer;
  15051. if (index !== null) {
  15052. attribute = attributes.get(index);
  15053. renderer = indexedBufferRenderer;
  15054. renderer.setIndex(attribute);
  15055. }
  15056. if (updateBuffers) {
  15057. setupVertexAttributes(object, geometry, material, program);
  15058. if (index !== null) {
  15059. _gl.bindBuffer(34963, attribute.buffer);
  15060. }
  15061. }
  15062. var dataCount = index !== null ? index.count : position.count;
  15063. var rangeStart = geometry.drawRange.start * rangeFactor;
  15064. var rangeCount = geometry.drawRange.count * rangeFactor;
  15065. var groupStart = group !== null ? group.start * rangeFactor : 0;
  15066. var groupCount = group !== null ? group.count * rangeFactor : Infinity;
  15067. var drawStart = Math.max(rangeStart, groupStart);
  15068. var drawEnd = Math.min(dataCount, rangeStart + rangeCount, groupStart + groupCount) - 1;
  15069. var drawCount = Math.max(0, drawEnd - drawStart + 1);
  15070. if (drawCount === 0)
  15071. return;
  15072. if (object.isMesh) {
  15073. if (material.wireframe === true) {
  15074. state.setLineWidth(material.wireframeLinewidth * getTargetPixelRatio());
  15075. renderer.setMode(1);
  15076. } else {
  15077. renderer.setMode(4);
  15078. }
  15079. } else if (object.isLine) {
  15080. var lineWidth = material.linewidth;
  15081. if (lineWidth === void 0)
  15082. lineWidth = 1;
  15083. state.setLineWidth(lineWidth * getTargetPixelRatio());
  15084. if (object.isLineSegments) {
  15085. renderer.setMode(1);
  15086. } else if (object.isLineLoop) {
  15087. renderer.setMode(2);
  15088. } else {
  15089. renderer.setMode(3);
  15090. }
  15091. } else if (object.isPoints) {
  15092. renderer.setMode(0);
  15093. } else if (object.isSprite) {
  15094. renderer.setMode(4);
  15095. }
  15096. if (object.isInstancedMesh) {
  15097. renderer.renderInstances(geometry, drawStart, drawCount, object.count);
  15098. } else if (geometry.isInstancedBufferGeometry) {
  15099. renderer.renderInstances(geometry, drawStart, drawCount, geometry.maxInstancedCount);
  15100. } else {
  15101. renderer.render(drawStart, drawCount);
  15102. }
  15103. };
  15104. function setupVertexAttributes(object, geometry, material, program) {
  15105. if (capabilities.isWebGL2 === false && (object.isInstancedMesh || geometry.isInstancedBufferGeometry)) {
  15106. if (extensions.get("ANGLE_instanced_arrays") === null)
  15107. return;
  15108. }
  15109. state.initAttributes();
  15110. var geometryAttributes = geometry.attributes;
  15111. var programAttributes = program.getAttributes();
  15112. var materialDefaultAttributeValues = material.defaultAttributeValues;
  15113. for (var name in programAttributes) {
  15114. var programAttribute = programAttributes[name];
  15115. if (programAttribute >= 0) {
  15116. var geometryAttribute = geometryAttributes[name];
  15117. if (geometryAttribute !== void 0) {
  15118. var normalized = geometryAttribute.normalized;
  15119. var size = geometryAttribute.itemSize;
  15120. var attribute = attributes.get(geometryAttribute);
  15121. if (attribute === void 0)
  15122. continue;
  15123. var buffer = attribute.buffer;
  15124. var type = attribute.type;
  15125. var bytesPerElement = attribute.bytesPerElement;
  15126. if (geometryAttribute.isInterleavedBufferAttribute) {
  15127. var data = geometryAttribute.data;
  15128. var stride = data.stride;
  15129. var offset = geometryAttribute.offset;
  15130. if (data && data.isInstancedInterleavedBuffer) {
  15131. state.enableAttributeAndDivisor(programAttribute, data.meshPerAttribute);
  15132. if (geometry.maxInstancedCount === void 0) {
  15133. geometry.maxInstancedCount = data.meshPerAttribute * data.count;
  15134. }
  15135. } else {
  15136. state.enableAttribute(programAttribute);
  15137. }
  15138. _gl.bindBuffer(34962, buffer);
  15139. _gl.vertexAttribPointer(programAttribute, size, type, normalized, stride * bytesPerElement, offset * bytesPerElement);
  15140. } else {
  15141. if (geometryAttribute.isInstancedBufferAttribute) {
  15142. state.enableAttributeAndDivisor(programAttribute, geometryAttribute.meshPerAttribute);
  15143. if (geometry.maxInstancedCount === void 0) {
  15144. geometry.maxInstancedCount = geometryAttribute.meshPerAttribute * geometryAttribute.count;
  15145. }
  15146. } else {
  15147. state.enableAttribute(programAttribute);
  15148. }
  15149. _gl.bindBuffer(34962, buffer);
  15150. _gl.vertexAttribPointer(programAttribute, size, type, normalized, 0, 0);
  15151. }
  15152. } else if (name === "instanceMatrix") {
  15153. var attribute = attributes.get(object.instanceMatrix);
  15154. if (attribute === void 0)
  15155. continue;
  15156. var buffer = attribute.buffer;
  15157. var type = attribute.type;
  15158. state.enableAttributeAndDivisor(programAttribute + 0, 1);
  15159. state.enableAttributeAndDivisor(programAttribute + 1, 1);
  15160. state.enableAttributeAndDivisor(programAttribute + 2, 1);
  15161. state.enableAttributeAndDivisor(programAttribute + 3, 1);
  15162. _gl.bindBuffer(34962, buffer);
  15163. _gl.vertexAttribPointer(programAttribute + 0, 4, type, false, 64, 0);
  15164. _gl.vertexAttribPointer(programAttribute + 1, 4, type, false, 64, 16);
  15165. _gl.vertexAttribPointer(programAttribute + 2, 4, type, false, 64, 32);
  15166. _gl.vertexAttribPointer(programAttribute + 3, 4, type, false, 64, 48);
  15167. } else if (materialDefaultAttributeValues !== void 0) {
  15168. var value = materialDefaultAttributeValues[name];
  15169. if (value !== void 0) {
  15170. switch (value.length) {
  15171. case 2:
  15172. _gl.vertexAttrib2fv(programAttribute, value);
  15173. break;
  15174. case 3:
  15175. _gl.vertexAttrib3fv(programAttribute, value);
  15176. break;
  15177. case 4:
  15178. _gl.vertexAttrib4fv(programAttribute, value);
  15179. break;
  15180. default:
  15181. _gl.vertexAttrib1fv(programAttribute, value);
  15182. }
  15183. }
  15184. }
  15185. }
  15186. }
  15187. state.disableUnusedAttributes();
  15188. }
  15189. this.compile = function(scene, camera) {
  15190. currentRenderState = renderStates.get(scene, camera);
  15191. currentRenderState.init();
  15192. scene.traverse(function(object) {
  15193. if (object.isLight) {
  15194. currentRenderState.pushLight(object);
  15195. if (object.castShadow) {
  15196. currentRenderState.pushShadow(object);
  15197. }
  15198. }
  15199. });
  15200. currentRenderState.setupLights(camera);
  15201. var compiled = {};
  15202. scene.traverse(function(object) {
  15203. if (object.material) {
  15204. if (Array.isArray(object.material)) {
  15205. for (var i2 = 0; i2 < object.material.length; i2++) {
  15206. if (object.material[i2].uuid in compiled === false) {
  15207. initMaterial(object.material[i2], scene, object);
  15208. compiled[object.material[i2].uuid] = true;
  15209. }
  15210. }
  15211. } else if (object.material.uuid in compiled === false) {
  15212. initMaterial(object.material, scene, object);
  15213. compiled[object.material.uuid] = true;
  15214. }
  15215. }
  15216. });
  15217. };
  15218. var onAnimationFrameCallback = null;
  15219. function onAnimationFrame(time) {
  15220. if (xr.isPresenting)
  15221. return;
  15222. if (onAnimationFrameCallback)
  15223. onAnimationFrameCallback(time);
  15224. }
  15225. var animation = new WebGLAnimation();
  15226. animation.setAnimationLoop(onAnimationFrame);
  15227. if (typeof window !== "undefined")
  15228. animation.setContext(window);
  15229. this.setAnimationLoop = function(callback) {
  15230. onAnimationFrameCallback = callback;
  15231. xr.setAnimationLoop(callback);
  15232. animation.start();
  15233. };
  15234. this.render = function(scene, camera) {
  15235. var renderTarget, forceClear;
  15236. if (arguments[2] !== void 0) {
  15237. console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead.");
  15238. renderTarget = arguments[2];
  15239. }
  15240. if (arguments[3] !== void 0) {
  15241. console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead.");
  15242. forceClear = arguments[3];
  15243. }
  15244. if (!(camera && camera.isCamera)) {
  15245. console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");
  15246. return;
  15247. }
  15248. if (_isContextLost)
  15249. return;
  15250. _currentGeometryProgram.geometry = null;
  15251. _currentGeometryProgram.program = null;
  15252. _currentGeometryProgram.wireframe = false;
  15253. _currentMaterialId = -1;
  15254. _currentCamera = null;
  15255. if (scene.autoUpdate === true)
  15256. scene.updateMatrixWorld();
  15257. if (camera.parent === null)
  15258. camera.updateMatrixWorld();
  15259. if (xr.enabled && xr.isPresenting) {
  15260. camera = xr.getCamera(camera);
  15261. }
  15262. currentRenderState = renderStates.get(scene, camera);
  15263. currentRenderState.init();
  15264. scene.onBeforeRender(_this, scene, camera, renderTarget || _currentRenderTarget);
  15265. _projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
  15266. _frustum.setFromProjectionMatrix(_projScreenMatrix);
  15267. _localClippingEnabled = this.localClippingEnabled;
  15268. _clippingEnabled = _clipping.init(this.clippingPlanes, _localClippingEnabled, camera);
  15269. currentRenderList = renderLists.get(scene, camera);
  15270. currentRenderList.init();
  15271. projectObject(scene, camera, 0, _this.sortObjects);
  15272. if (_this.sortObjects === true) {
  15273. currentRenderList.sort(_opaqueSort, _transparentSort);
  15274. }
  15275. if (_clippingEnabled)
  15276. _clipping.beginShadows();
  15277. var shadowsArray = currentRenderState.state.shadowsArray;
  15278. shadowMap.render(shadowsArray, scene, camera);
  15279. currentRenderState.setupLights(camera);
  15280. if (_clippingEnabled)
  15281. _clipping.endShadows();
  15282. if (this.info.autoReset)
  15283. this.info.reset();
  15284. if (renderTarget !== void 0) {
  15285. this.setRenderTarget(renderTarget);
  15286. }
  15287. if (xr.enabled && multiview.isAvailable()) {
  15288. multiview.attachCamera(camera);
  15289. }
  15290. background.render(currentRenderList, scene, camera, forceClear);
  15291. var opaqueObjects = currentRenderList.opaque;
  15292. var transparentObjects = currentRenderList.transparent;
  15293. if (scene.overrideMaterial) {
  15294. var overrideMaterial = scene.overrideMaterial;
  15295. if (opaqueObjects.length)
  15296. renderObjects(opaqueObjects, scene, camera, overrideMaterial);
  15297. if (transparentObjects.length)
  15298. renderObjects(transparentObjects, scene, camera, overrideMaterial);
  15299. } else {
  15300. if (opaqueObjects.length)
  15301. renderObjects(opaqueObjects, scene, camera);
  15302. if (transparentObjects.length)
  15303. renderObjects(transparentObjects, scene, camera);
  15304. }
  15305. scene.onAfterRender(_this, scene, camera);
  15306. if (_currentRenderTarget !== null) {
  15307. textures.updateRenderTargetMipmap(_currentRenderTarget);
  15308. textures.updateMultisampleRenderTarget(_currentRenderTarget);
  15309. }
  15310. state.buffers.depth.setTest(true);
  15311. state.buffers.depth.setMask(true);
  15312. state.buffers.color.setMask(true);
  15313. state.setPolygonOffset(false);
  15314. if (xr.enabled) {
  15315. if (multiview.isAvailable()) {
  15316. multiview.detachCamera(camera);
  15317. }
  15318. }
  15319. currentRenderList = null;
  15320. currentRenderState = null;
  15321. };
  15322. function projectObject(object, camera, groupOrder, sortObjects) {
  15323. if (object.visible === false)
  15324. return;
  15325. var visible = object.layers.test(camera.layers);
  15326. if (visible) {
  15327. if (object.isGroup) {
  15328. groupOrder = object.renderOrder;
  15329. } else if (object.isLOD) {
  15330. if (object.autoUpdate === true)
  15331. object.update(camera);
  15332. } else if (object.isLight) {
  15333. currentRenderState.pushLight(object);
  15334. if (object.castShadow) {
  15335. currentRenderState.pushShadow(object);
  15336. }
  15337. } else if (object.isSprite) {
  15338. if (!object.frustumCulled || _frustum.intersectsSprite(object)) {
  15339. if (sortObjects) {
  15340. _vector3.setFromMatrixPosition(object.matrixWorld).applyMatrix4(_projScreenMatrix);
  15341. }
  15342. var geometry = objects.update(object);
  15343. var material = object.material;
  15344. if (material.visible) {
  15345. currentRenderList.push(object, geometry, material, groupOrder, _vector3.z, null);
  15346. }
  15347. }
  15348. } else if (object.isImmediateRenderObject) {
  15349. if (sortObjects) {
  15350. _vector3.setFromMatrixPosition(object.matrixWorld).applyMatrix4(_projScreenMatrix);
  15351. }
  15352. currentRenderList.push(object, null, object.material, groupOrder, _vector3.z, null);
  15353. } else if (object.isMesh || object.isLine || object.isPoints) {
  15354. if (object.isSkinnedMesh) {
  15355. if (object.skeleton.frame !== info.render.frame) {
  15356. object.skeleton.update();
  15357. object.skeleton.frame = info.render.frame;
  15358. }
  15359. }
  15360. if (!object.frustumCulled || _frustum.intersectsObject(object)) {
  15361. if (sortObjects) {
  15362. _vector3.setFromMatrixPosition(object.matrixWorld).applyMatrix4(_projScreenMatrix);
  15363. }
  15364. var geometry = objects.update(object);
  15365. var material = object.material;
  15366. if (Array.isArray(material)) {
  15367. var groups = geometry.groups;
  15368. for (var i2 = 0, l = groups.length; i2 < l; i2++) {
  15369. var group = groups[i2];
  15370. var groupMaterial = material[group.materialIndex];
  15371. if (groupMaterial && groupMaterial.visible) {
  15372. currentRenderList.push(object, geometry, groupMaterial, groupOrder, _vector3.z, group);
  15373. }
  15374. }
  15375. } else if (material.visible) {
  15376. currentRenderList.push(object, geometry, material, groupOrder, _vector3.z, null);
  15377. }
  15378. }
  15379. }
  15380. }
  15381. var children = object.children;
  15382. for (var i2 = 0, l = children.length; i2 < l; i2++) {
  15383. projectObject(children[i2], camera, groupOrder, sortObjects);
  15384. }
  15385. }
  15386. function renderObjects(renderList, scene, camera, overrideMaterial) {
  15387. for (var i2 = 0, l = renderList.length; i2 < l; i2++) {
  15388. var renderItem = renderList[i2];
  15389. var object = renderItem.object;
  15390. var geometry = renderItem.geometry;
  15391. var material = overrideMaterial === void 0 ? renderItem.material : overrideMaterial;
  15392. var group = renderItem.group;
  15393. if (camera.isArrayCamera) {
  15394. _currentArrayCamera = camera;
  15395. if (xr.enabled && multiview.isAvailable()) {
  15396. renderObject(object, scene, camera, geometry, material, group);
  15397. } else {
  15398. var cameras = camera.cameras;
  15399. for (var j = 0, jl = cameras.length; j < jl; j++) {
  15400. var camera2 = cameras[j];
  15401. if (object.layers.test(camera2.layers)) {
  15402. state.viewport(_currentViewport.copy(camera2.viewport));
  15403. currentRenderState.setupLights(camera2);
  15404. renderObject(object, scene, camera2, geometry, material, group);
  15405. }
  15406. }
  15407. }
  15408. } else {
  15409. _currentArrayCamera = null;
  15410. renderObject(object, scene, camera, geometry, material, group);
  15411. }
  15412. }
  15413. }
  15414. function renderObject(object, scene, camera, geometry, material, group) {
  15415. object.onBeforeRender(_this, scene, camera, geometry, material, group);
  15416. currentRenderState = renderStates.get(scene, _currentArrayCamera || camera);
  15417. object.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, object.matrixWorld);
  15418. object.normalMatrix.getNormalMatrix(object.modelViewMatrix);
  15419. if (object.isImmediateRenderObject) {
  15420. var program = setProgram(camera, scene, material, object);
  15421. state.setMaterial(material);
  15422. _currentGeometryProgram.geometry = null;
  15423. _currentGeometryProgram.program = null;
  15424. _currentGeometryProgram.wireframe = false;
  15425. renderObjectImmediate(object, program);
  15426. } else {
  15427. _this.renderBufferDirect(camera, scene, geometry, material, object, group);
  15428. }
  15429. object.onAfterRender(_this, scene, camera, geometry, material, group);
  15430. currentRenderState = renderStates.get(scene, _currentArrayCamera || camera);
  15431. }
  15432. function initMaterial(material, scene, object) {
  15433. var materialProperties = properties.get(material);
  15434. var lights = currentRenderState.state.lights;
  15435. var shadowsArray = currentRenderState.state.shadowsArray;
  15436. var lightsStateVersion = lights.state.version;
  15437. var parameters2 = programCache.getParameters(material, lights.state, shadowsArray, scene, _clipping.numPlanes, _clipping.numIntersection, object);
  15438. var programCacheKey = programCache.getProgramCacheKey(parameters2);
  15439. var program = materialProperties.program;
  15440. var programChange = true;
  15441. if (program === void 0) {
  15442. material.addEventListener("dispose", onMaterialDispose);
  15443. } else if (program.cacheKey !== programCacheKey) {
  15444. releaseMaterialProgramReference(material);
  15445. } else if (materialProperties.lightsStateVersion !== lightsStateVersion) {
  15446. materialProperties.lightsStateVersion = lightsStateVersion;
  15447. programChange = false;
  15448. } else if (parameters2.shaderID !== void 0) {
  15449. return;
  15450. } else {
  15451. programChange = false;
  15452. }
  15453. if (programChange) {
  15454. program = programCache.acquireProgram(parameters2, programCacheKey);
  15455. materialProperties.program = program;
  15456. materialProperties.uniforms = parameters2.uniforms;
  15457. materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;
  15458. materialProperties.outputEncoding = _this.outputEncoding;
  15459. material.program = program;
  15460. }
  15461. var programAttributes = program.getAttributes();
  15462. if (material.morphTargets) {
  15463. material.numSupportedMorphTargets = 0;
  15464. for (var i2 = 0; i2 < _this.maxMorphTargets; i2++) {
  15465. if (programAttributes["morphTarget" + i2] >= 0) {
  15466. material.numSupportedMorphTargets++;
  15467. }
  15468. }
  15469. }
  15470. if (material.morphNormals) {
  15471. material.numSupportedMorphNormals = 0;
  15472. for (var i2 = 0; i2 < _this.maxMorphNormals; i2++) {
  15473. if (programAttributes["morphNormal" + i2] >= 0) {
  15474. material.numSupportedMorphNormals++;
  15475. }
  15476. }
  15477. }
  15478. var uniforms = materialProperties.uniforms;
  15479. if (!material.isShaderMaterial && !material.isRawShaderMaterial || material.clipping === true) {
  15480. materialProperties.numClippingPlanes = _clipping.numPlanes;
  15481. materialProperties.numIntersection = _clipping.numIntersection;
  15482. uniforms.clippingPlanes = _clipping.uniform;
  15483. }
  15484. materialProperties.fog = scene.fog;
  15485. materialProperties.needsLights = materialNeedsLights(material);
  15486. materialProperties.lightsStateVersion = lightsStateVersion;
  15487. if (materialProperties.needsLights) {
  15488. uniforms.ambientLightColor.value = lights.state.ambient;
  15489. uniforms.lightProbe.value = lights.state.probe;
  15490. uniforms.directionalLights.value = lights.state.directional;
  15491. uniforms.spotLights.value = lights.state.spot;
  15492. uniforms.rectAreaLights.value = lights.state.rectArea;
  15493. uniforms.pointLights.value = lights.state.point;
  15494. uniforms.hemisphereLights.value = lights.state.hemi;
  15495. uniforms.directionalShadowMap.value = lights.state.directionalShadowMap;
  15496. uniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix;
  15497. uniforms.spotShadowMap.value = lights.state.spotShadowMap;
  15498. uniforms.spotShadowMatrix.value = lights.state.spotShadowMatrix;
  15499. uniforms.pointShadowMap.value = lights.state.pointShadowMap;
  15500. uniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;
  15501. }
  15502. var progUniforms = materialProperties.program.getUniforms(), uniformsList = WebGLUniforms.seqWithValue(progUniforms.seq, uniforms);
  15503. materialProperties.uniformsList = uniformsList;
  15504. }
  15505. function setProgram(camera, scene, material, object) {
  15506. textures.resetTextureUnits();
  15507. var fog = scene.fog;
  15508. var environment = material.isMeshStandardMaterial ? scene.environment : null;
  15509. var materialProperties = properties.get(material);
  15510. var lights = currentRenderState.state.lights;
  15511. if (_clippingEnabled) {
  15512. if (_localClippingEnabled || camera !== _currentCamera) {
  15513. var useCache = camera === _currentCamera && material.id === _currentMaterialId;
  15514. _clipping.setState(
  15515. material.clippingPlanes,
  15516. material.clipIntersection,
  15517. material.clipShadows,
  15518. camera,
  15519. materialProperties,
  15520. useCache
  15521. );
  15522. }
  15523. }
  15524. if (material.version === materialProperties.__version) {
  15525. if (materialProperties.program === void 0) {
  15526. initMaterial(material, scene, object);
  15527. } else if (material.fog && materialProperties.fog !== fog) {
  15528. initMaterial(material, scene, object);
  15529. } else if (materialProperties.environment !== environment) {
  15530. initMaterial(material, scene, object);
  15531. } else if (materialProperties.needsLights && materialProperties.lightsStateVersion !== lights.state.version) {
  15532. initMaterial(material, scene, object);
  15533. } else if (materialProperties.numClippingPlanes !== void 0 && (materialProperties.numClippingPlanes !== _clipping.numPlanes || materialProperties.numIntersection !== _clipping.numIntersection)) {
  15534. initMaterial(material, scene, object);
  15535. } else if (materialProperties.outputEncoding !== _this.outputEncoding) {
  15536. initMaterial(material, scene, object);
  15537. }
  15538. } else {
  15539. initMaterial(material, scene, object);
  15540. materialProperties.__version = material.version;
  15541. }
  15542. var refreshProgram = false;
  15543. var refreshMaterial = false;
  15544. var refreshLights = false;
  15545. var program = materialProperties.program, p_uniforms = program.getUniforms(), m_uniforms = materialProperties.uniforms;
  15546. if (state.useProgram(program.program)) {
  15547. refreshProgram = true;
  15548. refreshMaterial = true;
  15549. refreshLights = true;
  15550. }
  15551. if (material.id !== _currentMaterialId) {
  15552. _currentMaterialId = material.id;
  15553. refreshMaterial = true;
  15554. }
  15555. if (refreshProgram || _currentCamera !== camera) {
  15556. if (program.numMultiviewViews > 0) {
  15557. multiview.updateCameraProjectionMatricesUniform(camera, p_uniforms);
  15558. } else {
  15559. p_uniforms.setValue(_gl, "projectionMatrix", camera.projectionMatrix);
  15560. }
  15561. if (capabilities.logarithmicDepthBuffer) {
  15562. p_uniforms.setValue(
  15563. _gl,
  15564. "logDepthBufFC",
  15565. 2 / (Math.log(camera.far + 1) / Math.LN2)
  15566. );
  15567. }
  15568. if (_currentCamera !== camera) {
  15569. _currentCamera = camera;
  15570. refreshMaterial = true;
  15571. refreshLights = true;
  15572. }
  15573. if (material.isShaderMaterial || material.isMeshPhongMaterial || material.isMeshToonMaterial || material.isMeshStandardMaterial || material.envMap) {
  15574. var uCamPos = p_uniforms.map.cameraPosition;
  15575. if (uCamPos !== void 0) {
  15576. uCamPos.setValue(
  15577. _gl,
  15578. _vector3.setFromMatrixPosition(camera.matrixWorld)
  15579. );
  15580. }
  15581. }
  15582. if (material.isMeshPhongMaterial || material.isMeshToonMaterial || material.isMeshLambertMaterial || material.isMeshBasicMaterial || material.isMeshStandardMaterial || material.isShaderMaterial) {
  15583. p_uniforms.setValue(_gl, "isOrthographic", camera.isOrthographicCamera === true);
  15584. }
  15585. if (material.isMeshPhongMaterial || material.isMeshToonMaterial || material.isMeshLambertMaterial || material.isMeshBasicMaterial || material.isMeshStandardMaterial || material.isShaderMaterial || material.skinning) {
  15586. if (program.numMultiviewViews > 0) {
  15587. multiview.updateCameraViewMatricesUniform(camera, p_uniforms);
  15588. } else {
  15589. p_uniforms.setValue(_gl, "viewMatrix", camera.matrixWorldInverse);
  15590. }
  15591. }
  15592. }
  15593. if (material.skinning) {
  15594. p_uniforms.setOptional(_gl, object, "bindMatrix");
  15595. p_uniforms.setOptional(_gl, object, "bindMatrixInverse");
  15596. var skeleton = object.skeleton;
  15597. if (skeleton) {
  15598. var bones = skeleton.bones;
  15599. if (capabilities.floatVertexTextures) {
  15600. if (skeleton.boneTexture === void 0) {
  15601. var size = Math.sqrt(bones.length * 4);
  15602. size = MathUtils.ceilPowerOfTwo(size);
  15603. size = Math.max(size, 4);
  15604. var boneMatrices = new Float32Array(size * size * 4);
  15605. boneMatrices.set(skeleton.boneMatrices);
  15606. var boneTexture = new DataTexture(boneMatrices, size, size, RGBAFormat, FloatType);
  15607. skeleton.boneMatrices = boneMatrices;
  15608. skeleton.boneTexture = boneTexture;
  15609. skeleton.boneTextureSize = size;
  15610. }
  15611. p_uniforms.setValue(_gl, "boneTexture", skeleton.boneTexture, textures);
  15612. p_uniforms.setValue(_gl, "boneTextureSize", skeleton.boneTextureSize);
  15613. } else {
  15614. p_uniforms.setOptional(_gl, skeleton, "boneMatrices");
  15615. }
  15616. }
  15617. }
  15618. if (refreshMaterial || materialProperties.receiveShadow !== object.receiveShadow) {
  15619. materialProperties.receiveShadow = object.receiveShadow;
  15620. p_uniforms.setValue(_gl, "receiveShadow", object.receiveShadow);
  15621. }
  15622. if (refreshMaterial) {
  15623. p_uniforms.setValue(_gl, "toneMappingExposure", _this.toneMappingExposure);
  15624. p_uniforms.setValue(_gl, "toneMappingWhitePoint", _this.toneMappingWhitePoint);
  15625. if (materialProperties.needsLights) {
  15626. markUniformsLightsNeedsUpdate(m_uniforms, refreshLights);
  15627. }
  15628. if (fog && material.fog) {
  15629. refreshUniformsFog(m_uniforms, fog);
  15630. }
  15631. if (material.isMeshBasicMaterial) {
  15632. refreshUniformsCommon(m_uniforms, material);
  15633. } else if (material.isMeshLambertMaterial) {
  15634. refreshUniformsCommon(m_uniforms, material);
  15635. refreshUniformsLambert(m_uniforms, material);
  15636. } else if (material.isMeshToonMaterial) {
  15637. refreshUniformsCommon(m_uniforms, material);
  15638. refreshUniformsToon(m_uniforms, material);
  15639. } else if (material.isMeshPhongMaterial) {
  15640. refreshUniformsCommon(m_uniforms, material);
  15641. refreshUniformsPhong(m_uniforms, material);
  15642. } else if (material.isMeshStandardMaterial) {
  15643. refreshUniformsCommon(m_uniforms, material, environment);
  15644. if (material.isMeshPhysicalMaterial) {
  15645. refreshUniformsPhysical(m_uniforms, material, environment);
  15646. } else {
  15647. refreshUniformsStandard(m_uniforms, material, environment);
  15648. }
  15649. } else if (material.isMeshMatcapMaterial) {
  15650. refreshUniformsCommon(m_uniforms, material);
  15651. refreshUniformsMatcap(m_uniforms, material);
  15652. } else if (material.isMeshDepthMaterial) {
  15653. refreshUniformsCommon(m_uniforms, material);
  15654. refreshUniformsDepth(m_uniforms, material);
  15655. } else if (material.isMeshDistanceMaterial) {
  15656. refreshUniformsCommon(m_uniforms, material);
  15657. refreshUniformsDistance(m_uniforms, material);
  15658. } else if (material.isMeshNormalMaterial) {
  15659. refreshUniformsCommon(m_uniforms, material);
  15660. refreshUniformsNormal(m_uniforms, material);
  15661. } else if (material.isLineBasicMaterial) {
  15662. refreshUniformsLine(m_uniforms, material);
  15663. if (material.isLineDashedMaterial) {
  15664. refreshUniformsDash(m_uniforms, material);
  15665. }
  15666. } else if (material.isPointsMaterial) {
  15667. refreshUniformsPoints(m_uniforms, material);
  15668. } else if (material.isSpriteMaterial) {
  15669. refreshUniformsSprites(m_uniforms, material);
  15670. } else if (material.isShadowMaterial) {
  15671. m_uniforms.color.value.copy(material.color);
  15672. m_uniforms.opacity.value = material.opacity;
  15673. }
  15674. if (m_uniforms.ltc_1 !== void 0)
  15675. m_uniforms.ltc_1.value = UniformsLib.LTC_1;
  15676. if (m_uniforms.ltc_2 !== void 0)
  15677. m_uniforms.ltc_2.value = UniformsLib.LTC_2;
  15678. WebGLUniforms.upload(_gl, materialProperties.uniformsList, m_uniforms, textures);
  15679. if (material.isShaderMaterial) {
  15680. material.uniformsNeedUpdate = false;
  15681. }
  15682. }
  15683. if (material.isShaderMaterial && material.uniformsNeedUpdate === true) {
  15684. WebGLUniforms.upload(_gl, materialProperties.uniformsList, m_uniforms, textures);
  15685. material.uniformsNeedUpdate = false;
  15686. }
  15687. if (material.isSpriteMaterial) {
  15688. p_uniforms.setValue(_gl, "center", object.center);
  15689. }
  15690. if (program.numMultiviewViews > 0) {
  15691. multiview.updateObjectMatricesUniforms(object, camera, p_uniforms);
  15692. } else {
  15693. p_uniforms.setValue(_gl, "modelViewMatrix", object.modelViewMatrix);
  15694. p_uniforms.setValue(_gl, "normalMatrix", object.normalMatrix);
  15695. }
  15696. p_uniforms.setValue(_gl, "modelMatrix", object.matrixWorld);
  15697. return program;
  15698. }
  15699. function refreshUniformsCommon(uniforms, material, environment) {
  15700. uniforms.opacity.value = material.opacity;
  15701. if (material.color) {
  15702. uniforms.diffuse.value.copy(material.color);
  15703. }
  15704. if (material.emissive) {
  15705. uniforms.emissive.value.copy(material.emissive).multiplyScalar(material.emissiveIntensity);
  15706. }
  15707. if (material.map) {
  15708. uniforms.map.value = material.map;
  15709. }
  15710. if (material.alphaMap) {
  15711. uniforms.alphaMap.value = material.alphaMap;
  15712. }
  15713. if (material.specularMap) {
  15714. uniforms.specularMap.value = material.specularMap;
  15715. }
  15716. var envMap = material.envMap || environment;
  15717. if (envMap) {
  15718. uniforms.envMap.value = envMap;
  15719. uniforms.flipEnvMap.value = envMap.isCubeTexture ? -1 : 1;
  15720. uniforms.reflectivity.value = material.reflectivity;
  15721. uniforms.refractionRatio.value = material.refractionRatio;
  15722. uniforms.maxMipLevel.value = properties.get(envMap).__maxMipLevel;
  15723. }
  15724. if (material.lightMap) {
  15725. uniforms.lightMap.value = material.lightMap;
  15726. uniforms.lightMapIntensity.value = material.lightMapIntensity;
  15727. }
  15728. if (material.aoMap) {
  15729. uniforms.aoMap.value = material.aoMap;
  15730. uniforms.aoMapIntensity.value = material.aoMapIntensity;
  15731. }
  15732. var uvScaleMap;
  15733. if (material.map) {
  15734. uvScaleMap = material.map;
  15735. } else if (material.specularMap) {
  15736. uvScaleMap = material.specularMap;
  15737. } else if (material.displacementMap) {
  15738. uvScaleMap = material.displacementMap;
  15739. } else if (material.normalMap) {
  15740. uvScaleMap = material.normalMap;
  15741. } else if (material.bumpMap) {
  15742. uvScaleMap = material.bumpMap;
  15743. } else if (material.roughnessMap) {
  15744. uvScaleMap = material.roughnessMap;
  15745. } else if (material.metalnessMap) {
  15746. uvScaleMap = material.metalnessMap;
  15747. } else if (material.alphaMap) {
  15748. uvScaleMap = material.alphaMap;
  15749. } else if (material.emissiveMap) {
  15750. uvScaleMap = material.emissiveMap;
  15751. }
  15752. if (uvScaleMap !== void 0) {
  15753. if (uvScaleMap.isWebGLRenderTarget) {
  15754. uvScaleMap = uvScaleMap.texture;
  15755. }
  15756. if (uvScaleMap.matrixAutoUpdate === true) {
  15757. uvScaleMap.updateMatrix();
  15758. }
  15759. uniforms.uvTransform.value.copy(uvScaleMap.matrix);
  15760. }
  15761. var uv2ScaleMap;
  15762. if (material.aoMap) {
  15763. uv2ScaleMap = material.aoMap;
  15764. } else if (material.lightMap) {
  15765. uv2ScaleMap = material.lightMap;
  15766. }
  15767. if (uv2ScaleMap !== void 0) {
  15768. if (uv2ScaleMap.isWebGLRenderTarget) {
  15769. uv2ScaleMap = uv2ScaleMap.texture;
  15770. }
  15771. if (uv2ScaleMap.matrixAutoUpdate === true) {
  15772. uv2ScaleMap.updateMatrix();
  15773. }
  15774. uniforms.uv2Transform.value.copy(uv2ScaleMap.matrix);
  15775. }
  15776. }
  15777. function refreshUniformsLine(uniforms, material) {
  15778. uniforms.diffuse.value.copy(material.color);
  15779. uniforms.opacity.value = material.opacity;
  15780. }
  15781. function refreshUniformsDash(uniforms, material) {
  15782. uniforms.dashSize.value = material.dashSize;
  15783. uniforms.totalSize.value = material.dashSize + material.gapSize;
  15784. uniforms.scale.value = material.scale;
  15785. }
  15786. function refreshUniformsPoints(uniforms, material) {
  15787. uniforms.diffuse.value.copy(material.color);
  15788. uniforms.opacity.value = material.opacity;
  15789. uniforms.size.value = material.size * _pixelRatio;
  15790. uniforms.scale.value = _height * 0.5;
  15791. if (material.map) {
  15792. uniforms.map.value = material.map;
  15793. }
  15794. if (material.alphaMap) {
  15795. uniforms.alphaMap.value = material.alphaMap;
  15796. }
  15797. var uvScaleMap;
  15798. if (material.map) {
  15799. uvScaleMap = material.map;
  15800. } else if (material.alphaMap) {
  15801. uvScaleMap = material.alphaMap;
  15802. }
  15803. if (uvScaleMap !== void 0) {
  15804. if (uvScaleMap.matrixAutoUpdate === true) {
  15805. uvScaleMap.updateMatrix();
  15806. }
  15807. uniforms.uvTransform.value.copy(uvScaleMap.matrix);
  15808. }
  15809. }
  15810. function refreshUniformsSprites(uniforms, material) {
  15811. uniforms.diffuse.value.copy(material.color);
  15812. uniforms.opacity.value = material.opacity;
  15813. uniforms.rotation.value = material.rotation;
  15814. if (material.map) {
  15815. uniforms.map.value = material.map;
  15816. }
  15817. if (material.alphaMap) {
  15818. uniforms.alphaMap.value = material.alphaMap;
  15819. }
  15820. var uvScaleMap;
  15821. if (material.map) {
  15822. uvScaleMap = material.map;
  15823. } else if (material.alphaMap) {
  15824. uvScaleMap = material.alphaMap;
  15825. }
  15826. if (uvScaleMap !== void 0) {
  15827. if (uvScaleMap.matrixAutoUpdate === true) {
  15828. uvScaleMap.updateMatrix();
  15829. }
  15830. uniforms.uvTransform.value.copy(uvScaleMap.matrix);
  15831. }
  15832. }
  15833. function refreshUniformsFog(uniforms, fog) {
  15834. uniforms.fogColor.value.copy(fog.color);
  15835. if (fog.isFog) {
  15836. uniforms.fogNear.value = fog.near;
  15837. uniforms.fogFar.value = fog.far;
  15838. } else if (fog.isFogExp2) {
  15839. uniforms.fogDensity.value = fog.density;
  15840. }
  15841. }
  15842. function refreshUniformsLambert(uniforms, material) {
  15843. if (material.emissiveMap) {
  15844. uniforms.emissiveMap.value = material.emissiveMap;
  15845. }
  15846. }
  15847. function refreshUniformsPhong(uniforms, material) {
  15848. uniforms.specular.value.copy(material.specular);
  15849. uniforms.shininess.value = Math.max(material.shininess, 1e-4);
  15850. if (material.emissiveMap) {
  15851. uniforms.emissiveMap.value = material.emissiveMap;
  15852. }
  15853. if (material.bumpMap) {
  15854. uniforms.bumpMap.value = material.bumpMap;
  15855. uniforms.bumpScale.value = material.bumpScale;
  15856. if (material.side === BackSide)
  15857. uniforms.bumpScale.value *= -1;
  15858. }
  15859. if (material.normalMap) {
  15860. uniforms.normalMap.value = material.normalMap;
  15861. uniforms.normalScale.value.copy(material.normalScale);
  15862. if (material.side === BackSide)
  15863. uniforms.normalScale.value.negate();
  15864. }
  15865. if (material.displacementMap) {
  15866. uniforms.displacementMap.value = material.displacementMap;
  15867. uniforms.displacementScale.value = material.displacementScale;
  15868. uniforms.displacementBias.value = material.displacementBias;
  15869. }
  15870. }
  15871. function refreshUniformsToon(uniforms, material) {
  15872. uniforms.specular.value.copy(material.specular);
  15873. uniforms.shininess.value = Math.max(material.shininess, 1e-4);
  15874. if (material.gradientMap) {
  15875. uniforms.gradientMap.value = material.gradientMap;
  15876. }
  15877. if (material.emissiveMap) {
  15878. uniforms.emissiveMap.value = material.emissiveMap;
  15879. }
  15880. if (material.bumpMap) {
  15881. uniforms.bumpMap.value = material.bumpMap;
  15882. uniforms.bumpScale.value = material.bumpScale;
  15883. if (material.side === BackSide)
  15884. uniforms.bumpScale.value *= -1;
  15885. }
  15886. if (material.normalMap) {
  15887. uniforms.normalMap.value = material.normalMap;
  15888. uniforms.normalScale.value.copy(material.normalScale);
  15889. if (material.side === BackSide)
  15890. uniforms.normalScale.value.negate();
  15891. }
  15892. if (material.displacementMap) {
  15893. uniforms.displacementMap.value = material.displacementMap;
  15894. uniforms.displacementScale.value = material.displacementScale;
  15895. uniforms.displacementBias.value = material.displacementBias;
  15896. }
  15897. }
  15898. function refreshUniformsStandard(uniforms, material, environment) {
  15899. uniforms.roughness.value = material.roughness;
  15900. uniforms.metalness.value = material.metalness;
  15901. if (material.roughnessMap) {
  15902. uniforms.roughnessMap.value = material.roughnessMap;
  15903. }
  15904. if (material.metalnessMap) {
  15905. uniforms.metalnessMap.value = material.metalnessMap;
  15906. }
  15907. if (material.emissiveMap) {
  15908. uniforms.emissiveMap.value = material.emissiveMap;
  15909. }
  15910. if (material.bumpMap) {
  15911. uniforms.bumpMap.value = material.bumpMap;
  15912. uniforms.bumpScale.value = material.bumpScale;
  15913. if (material.side === BackSide)
  15914. uniforms.bumpScale.value *= -1;
  15915. }
  15916. if (material.normalMap) {
  15917. uniforms.normalMap.value = material.normalMap;
  15918. uniforms.normalScale.value.copy(material.normalScale);
  15919. if (material.side === BackSide)
  15920. uniforms.normalScale.value.negate();
  15921. }
  15922. if (material.displacementMap) {
  15923. uniforms.displacementMap.value = material.displacementMap;
  15924. uniforms.displacementScale.value = material.displacementScale;
  15925. uniforms.displacementBias.value = material.displacementBias;
  15926. }
  15927. if (material.envMap || environment) {
  15928. uniforms.envMapIntensity.value = material.envMapIntensity;
  15929. }
  15930. }
  15931. function refreshUniformsPhysical(uniforms, material, environment) {
  15932. refreshUniformsStandard(uniforms, material, environment);
  15933. uniforms.reflectivity.value = material.reflectivity;
  15934. uniforms.clearcoat.value = material.clearcoat;
  15935. uniforms.clearcoatRoughness.value = material.clearcoatRoughness;
  15936. if (material.sheen)
  15937. uniforms.sheen.value.copy(material.sheen);
  15938. if (material.clearcoatNormalMap) {
  15939. uniforms.clearcoatNormalScale.value.copy(material.clearcoatNormalScale);
  15940. uniforms.clearcoatNormalMap.value = material.clearcoatNormalMap;
  15941. if (material.side === BackSide) {
  15942. uniforms.clearcoatNormalScale.value.negate();
  15943. }
  15944. }
  15945. uniforms.transparency.value = material.transparency;
  15946. }
  15947. function refreshUniformsMatcap(uniforms, material) {
  15948. if (material.matcap) {
  15949. uniforms.matcap.value = material.matcap;
  15950. }
  15951. if (material.bumpMap) {
  15952. uniforms.bumpMap.value = material.bumpMap;
  15953. uniforms.bumpScale.value = material.bumpScale;
  15954. if (material.side === BackSide)
  15955. uniforms.bumpScale.value *= -1;
  15956. }
  15957. if (material.normalMap) {
  15958. uniforms.normalMap.value = material.normalMap;
  15959. uniforms.normalScale.value.copy(material.normalScale);
  15960. if (material.side === BackSide)
  15961. uniforms.normalScale.value.negate();
  15962. }
  15963. if (material.displacementMap) {
  15964. uniforms.displacementMap.value = material.displacementMap;
  15965. uniforms.displacementScale.value = material.displacementScale;
  15966. uniforms.displacementBias.value = material.displacementBias;
  15967. }
  15968. }
  15969. function refreshUniformsDepth(uniforms, material) {
  15970. if (material.displacementMap) {
  15971. uniforms.displacementMap.value = material.displacementMap;
  15972. uniforms.displacementScale.value = material.displacementScale;
  15973. uniforms.displacementBias.value = material.displacementBias;
  15974. }
  15975. }
  15976. function refreshUniformsDistance(uniforms, material) {
  15977. if (material.displacementMap) {
  15978. uniforms.displacementMap.value = material.displacementMap;
  15979. uniforms.displacementScale.value = material.displacementScale;
  15980. uniforms.displacementBias.value = material.displacementBias;
  15981. }
  15982. uniforms.referencePosition.value.copy(material.referencePosition);
  15983. uniforms.nearDistance.value = material.nearDistance;
  15984. uniforms.farDistance.value = material.farDistance;
  15985. }
  15986. function refreshUniformsNormal(uniforms, material) {
  15987. if (material.bumpMap) {
  15988. uniforms.bumpMap.value = material.bumpMap;
  15989. uniforms.bumpScale.value = material.bumpScale;
  15990. if (material.side === BackSide)
  15991. uniforms.bumpScale.value *= -1;
  15992. }
  15993. if (material.normalMap) {
  15994. uniforms.normalMap.value = material.normalMap;
  15995. uniforms.normalScale.value.copy(material.normalScale);
  15996. if (material.side === BackSide)
  15997. uniforms.normalScale.value.negate();
  15998. }
  15999. if (material.displacementMap) {
  16000. uniforms.displacementMap.value = material.displacementMap;
  16001. uniforms.displacementScale.value = material.displacementScale;
  16002. uniforms.displacementBias.value = material.displacementBias;
  16003. }
  16004. }
  16005. function markUniformsLightsNeedsUpdate(uniforms, value) {
  16006. uniforms.ambientLightColor.needsUpdate = value;
  16007. uniforms.lightProbe.needsUpdate = value;
  16008. uniforms.directionalLights.needsUpdate = value;
  16009. uniforms.pointLights.needsUpdate = value;
  16010. uniforms.spotLights.needsUpdate = value;
  16011. uniforms.rectAreaLights.needsUpdate = value;
  16012. uniforms.hemisphereLights.needsUpdate = value;
  16013. }
  16014. function materialNeedsLights(material) {
  16015. return material.isMeshLambertMaterial || material.isMeshToonMaterial || material.isMeshPhongMaterial || material.isMeshStandardMaterial || material.isShadowMaterial || material.isShaderMaterial && material.lights === true;
  16016. }
  16017. this.setFramebuffer = function(value) {
  16018. if (_framebuffer !== value && _currentRenderTarget === null)
  16019. _gl.bindFramebuffer(36160, value);
  16020. _framebuffer = value;
  16021. };
  16022. this.getActiveCubeFace = function() {
  16023. return _currentActiveCubeFace;
  16024. };
  16025. this.getActiveMipmapLevel = function() {
  16026. return _currentActiveMipmapLevel;
  16027. };
  16028. this.getRenderTarget = function() {
  16029. return _currentRenderTarget;
  16030. };
  16031. this.setRenderTarget = function(renderTarget, activeCubeFace, activeMipmapLevel) {
  16032. _currentRenderTarget = renderTarget;
  16033. _currentActiveCubeFace = activeCubeFace;
  16034. _currentActiveMipmapLevel = activeMipmapLevel;
  16035. if (renderTarget && properties.get(renderTarget).__webglFramebuffer === void 0) {
  16036. textures.setupRenderTarget(renderTarget);
  16037. }
  16038. var framebuffer = _framebuffer;
  16039. var isCube = false;
  16040. if (renderTarget) {
  16041. var __webglFramebuffer = properties.get(renderTarget).__webglFramebuffer;
  16042. if (renderTarget.isWebGLCubeRenderTarget) {
  16043. framebuffer = __webglFramebuffer[activeCubeFace || 0];
  16044. isCube = true;
  16045. } else if (renderTarget.isWebGLMultisampleRenderTarget) {
  16046. framebuffer = properties.get(renderTarget).__webglMultisampledFramebuffer;
  16047. } else {
  16048. framebuffer = __webglFramebuffer;
  16049. }
  16050. _currentViewport.copy(renderTarget.viewport);
  16051. _currentScissor.copy(renderTarget.scissor);
  16052. _currentScissorTest = renderTarget.scissorTest;
  16053. } else {
  16054. _currentViewport.copy(_viewport).multiplyScalar(_pixelRatio).floor();
  16055. _currentScissor.copy(_scissor).multiplyScalar(_pixelRatio).floor();
  16056. _currentScissorTest = _scissorTest;
  16057. }
  16058. if (_currentFramebuffer !== framebuffer) {
  16059. _gl.bindFramebuffer(36160, framebuffer);
  16060. _currentFramebuffer = framebuffer;
  16061. }
  16062. state.viewport(_currentViewport);
  16063. state.scissor(_currentScissor);
  16064. state.setScissorTest(_currentScissorTest);
  16065. if (isCube) {
  16066. var textureProperties = properties.get(renderTarget.texture);
  16067. _gl.framebufferTexture2D(36160, 36064, 34069 + (activeCubeFace || 0), textureProperties.__webglTexture, activeMipmapLevel || 0);
  16068. }
  16069. };
  16070. this.readRenderTargetPixels = function(renderTarget, x, y, width, height, buffer, activeCubeFaceIndex) {
  16071. if (!(renderTarget && renderTarget.isWebGLRenderTarget)) {
  16072. console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
  16073. return;
  16074. }
  16075. var framebuffer = properties.get(renderTarget).__webglFramebuffer;
  16076. if (renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== void 0) {
  16077. framebuffer = framebuffer[activeCubeFaceIndex];
  16078. }
  16079. if (framebuffer) {
  16080. var restore = false;
  16081. if (framebuffer !== _currentFramebuffer) {
  16082. _gl.bindFramebuffer(36160, framebuffer);
  16083. restore = true;
  16084. }
  16085. try {
  16086. var texture = renderTarget.texture;
  16087. var textureFormat = texture.format;
  16088. var textureType = texture.type;
  16089. if (textureFormat !== RGBAFormat && utils.convert(textureFormat) !== _gl.getParameter(35739)) {
  16090. console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");
  16091. return;
  16092. }
  16093. if (textureType !== UnsignedByteType && utils.convert(textureType) !== _gl.getParameter(35738) && // IE11, Edge and Chrome Mac < 52 (#9513)
  16094. !(textureType === FloatType && (capabilities.isWebGL2 || extensions.get("OES_texture_float") || extensions.get("WEBGL_color_buffer_float"))) && // Chrome Mac >= 52 and Firefox
  16095. !(textureType === HalfFloatType && (capabilities.isWebGL2 ? extensions.get("EXT_color_buffer_float") : extensions.get("EXT_color_buffer_half_float")))) {
  16096. console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");
  16097. return;
  16098. }
  16099. if (_gl.checkFramebufferStatus(36160) === 36053) {
  16100. if (x >= 0 && x <= renderTarget.width - width && (y >= 0 && y <= renderTarget.height - height)) {
  16101. _gl.readPixels(x, y, width, height, utils.convert(textureFormat), utils.convert(textureType), buffer);
  16102. }
  16103. } else {
  16104. console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.");
  16105. }
  16106. } finally {
  16107. if (restore) {
  16108. _gl.bindFramebuffer(36160, _currentFramebuffer);
  16109. }
  16110. }
  16111. }
  16112. };
  16113. this.copyFramebufferToTexture = function(position, texture, level) {
  16114. if (level === void 0)
  16115. level = 0;
  16116. var levelScale = Math.pow(2, -level);
  16117. var width = Math.floor(texture.image.width * levelScale);
  16118. var height = Math.floor(texture.image.height * levelScale);
  16119. var glFormat = utils.convert(texture.format);
  16120. textures.setTexture2D(texture, 0);
  16121. _gl.copyTexImage2D(3553, level, glFormat, position.x, position.y, width, height, 0);
  16122. state.unbindTexture();
  16123. };
  16124. this.copyTextureToTexture = function(position, srcTexture, dstTexture, level) {
  16125. var width = srcTexture.image.width;
  16126. var height = srcTexture.image.height;
  16127. var glFormat = utils.convert(dstTexture.format);
  16128. var glType = utils.convert(dstTexture.type);
  16129. textures.setTexture2D(dstTexture, 0);
  16130. if (srcTexture.isDataTexture) {
  16131. _gl.texSubImage2D(3553, level || 0, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data);
  16132. } else {
  16133. _gl.texSubImage2D(3553, level || 0, position.x, position.y, glFormat, glType, srcTexture.image);
  16134. }
  16135. state.unbindTexture();
  16136. };
  16137. this.initTexture = function(texture) {
  16138. textures.setTexture2D(texture, 0);
  16139. state.unbindTexture();
  16140. };
  16141. if (typeof __THREE_DEVTOOLS__ !== "undefined") {
  16142. __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
  16143. }
  16144. }
  16145. function FogExp2(color, density) {
  16146. this.name = "";
  16147. this.color = new Color(color);
  16148. this.density = density !== void 0 ? density : 25e-5;
  16149. }
  16150. Object.assign(FogExp2.prototype, {
  16151. isFogExp2: true,
  16152. clone: function() {
  16153. return new FogExp2(this.color, this.density);
  16154. },
  16155. toJSON: function() {
  16156. return {
  16157. type: "FogExp2",
  16158. color: this.color.getHex(),
  16159. density: this.density
  16160. };
  16161. }
  16162. });
  16163. function Fog(color, near, far) {
  16164. this.name = "";
  16165. this.color = new Color(color);
  16166. this.near = near !== void 0 ? near : 1;
  16167. this.far = far !== void 0 ? far : 1e3;
  16168. }
  16169. Object.assign(Fog.prototype, {
  16170. isFog: true,
  16171. clone: function() {
  16172. return new Fog(this.color, this.near, this.far);
  16173. },
  16174. toJSON: function() {
  16175. return {
  16176. type: "Fog",
  16177. color: this.color.getHex(),
  16178. near: this.near,
  16179. far: this.far
  16180. };
  16181. }
  16182. });
  16183. function InterleavedBuffer(array, stride) {
  16184. this.array = array;
  16185. this.stride = stride;
  16186. this.count = array !== void 0 ? array.length / stride : 0;
  16187. this.usage = StaticDrawUsage;
  16188. this.updateRange = { offset: 0, count: -1 };
  16189. this.version = 0;
  16190. }
  16191. Object.defineProperty(InterleavedBuffer.prototype, "needsUpdate", {
  16192. set: function(value) {
  16193. if (value === true)
  16194. this.version++;
  16195. }
  16196. });
  16197. Object.assign(InterleavedBuffer.prototype, {
  16198. isInterleavedBuffer: true,
  16199. onUploadCallback: function() {
  16200. },
  16201. setUsage: function(value) {
  16202. this.usage = value;
  16203. return this;
  16204. },
  16205. copy: function(source) {
  16206. this.array = new source.array.constructor(source.array);
  16207. this.count = source.count;
  16208. this.stride = source.stride;
  16209. this.usage = source.usage;
  16210. return this;
  16211. },
  16212. copyAt: function(index1, attribute, index2) {
  16213. index1 *= this.stride;
  16214. index2 *= attribute.stride;
  16215. for (var i2 = 0, l = this.stride; i2 < l; i2++) {
  16216. this.array[index1 + i2] = attribute.array[index2 + i2];
  16217. }
  16218. return this;
  16219. },
  16220. set: function(value, offset) {
  16221. if (offset === void 0)
  16222. offset = 0;
  16223. this.array.set(value, offset);
  16224. return this;
  16225. },
  16226. clone: function() {
  16227. return new this.constructor().copy(this);
  16228. },
  16229. onUpload: function(callback) {
  16230. this.onUploadCallback = callback;
  16231. return this;
  16232. }
  16233. });
  16234. var _vector$6 = new Vector3();
  16235. function InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, normalized) {
  16236. this.data = interleavedBuffer;
  16237. this.itemSize = itemSize;
  16238. this.offset = offset;
  16239. this.normalized = normalized === true;
  16240. }
  16241. Object.defineProperties(InterleavedBufferAttribute.prototype, {
  16242. count: {
  16243. get: function() {
  16244. return this.data.count;
  16245. }
  16246. },
  16247. array: {
  16248. get: function() {
  16249. return this.data.array;
  16250. }
  16251. }
  16252. });
  16253. Object.assign(InterleavedBufferAttribute.prototype, {
  16254. isInterleavedBufferAttribute: true,
  16255. applyMatrix4: function(m) {
  16256. for (var i2 = 0, l = this.data.count; i2 < l; i2++) {
  16257. _vector$6.x = this.getX(i2);
  16258. _vector$6.y = this.getY(i2);
  16259. _vector$6.z = this.getZ(i2);
  16260. _vector$6.applyMatrix4(m);
  16261. this.setXYZ(i2, _vector$6.x, _vector$6.y, _vector$6.z);
  16262. }
  16263. return this;
  16264. },
  16265. setX: function(index, x) {
  16266. this.data.array[index * this.data.stride + this.offset] = x;
  16267. return this;
  16268. },
  16269. setY: function(index, y) {
  16270. this.data.array[index * this.data.stride + this.offset + 1] = y;
  16271. return this;
  16272. },
  16273. setZ: function(index, z) {
  16274. this.data.array[index * this.data.stride + this.offset + 2] = z;
  16275. return this;
  16276. },
  16277. setW: function(index, w) {
  16278. this.data.array[index * this.data.stride + this.offset + 3] = w;
  16279. return this;
  16280. },
  16281. getX: function(index) {
  16282. return this.data.array[index * this.data.stride + this.offset];
  16283. },
  16284. getY: function(index) {
  16285. return this.data.array[index * this.data.stride + this.offset + 1];
  16286. },
  16287. getZ: function(index) {
  16288. return this.data.array[index * this.data.stride + this.offset + 2];
  16289. },
  16290. getW: function(index) {
  16291. return this.data.array[index * this.data.stride + this.offset + 3];
  16292. },
  16293. setXY: function(index, x, y) {
  16294. index = index * this.data.stride + this.offset;
  16295. this.data.array[index + 0] = x;
  16296. this.data.array[index + 1] = y;
  16297. return this;
  16298. },
  16299. setXYZ: function(index, x, y, z) {
  16300. index = index * this.data.stride + this.offset;
  16301. this.data.array[index + 0] = x;
  16302. this.data.array[index + 1] = y;
  16303. this.data.array[index + 2] = z;
  16304. return this;
  16305. },
  16306. setXYZW: function(index, x, y, z, w) {
  16307. index = index * this.data.stride + this.offset;
  16308. this.data.array[index + 0] = x;
  16309. this.data.array[index + 1] = y;
  16310. this.data.array[index + 2] = z;
  16311. this.data.array[index + 3] = w;
  16312. return this;
  16313. }
  16314. });
  16315. function SpriteMaterial(parameters) {
  16316. Material.call(this);
  16317. this.type = "SpriteMaterial";
  16318. this.color = new Color(16777215);
  16319. this.map = null;
  16320. this.alphaMap = null;
  16321. this.rotation = 0;
  16322. this.sizeAttenuation = true;
  16323. this.transparent = true;
  16324. this.setValues(parameters);
  16325. }
  16326. SpriteMaterial.prototype = Object.create(Material.prototype);
  16327. SpriteMaterial.prototype.constructor = SpriteMaterial;
  16328. SpriteMaterial.prototype.isSpriteMaterial = true;
  16329. SpriteMaterial.prototype.copy = function(source) {
  16330. Material.prototype.copy.call(this, source);
  16331. this.color.copy(source.color);
  16332. this.map = source.map;
  16333. this.alphaMap = source.alphaMap;
  16334. this.rotation = source.rotation;
  16335. this.sizeAttenuation = source.sizeAttenuation;
  16336. return this;
  16337. };
  16338. var _geometry;
  16339. var _intersectPoint = new Vector3();
  16340. var _worldScale = new Vector3();
  16341. var _mvPosition = new Vector3();
  16342. var _alignedPosition = new Vector2();
  16343. var _rotatedPosition = new Vector2();
  16344. var _viewWorldMatrix = new Matrix4();
  16345. var _vA$1 = new Vector3();
  16346. var _vB$1 = new Vector3();
  16347. var _vC$1 = new Vector3();
  16348. var _uvA$1 = new Vector2();
  16349. var _uvB$1 = new Vector2();
  16350. var _uvC$1 = new Vector2();
  16351. function Sprite(material) {
  16352. Object3D.call(this);
  16353. this.type = "Sprite";
  16354. if (_geometry === void 0) {
  16355. _geometry = new BufferGeometry();
  16356. var float32Array = new Float32Array([
  16357. -0.5,
  16358. -0.5,
  16359. 0,
  16360. 0,
  16361. 0,
  16362. 0.5,
  16363. -0.5,
  16364. 0,
  16365. 1,
  16366. 0,
  16367. 0.5,
  16368. 0.5,
  16369. 0,
  16370. 1,
  16371. 1,
  16372. -0.5,
  16373. 0.5,
  16374. 0,
  16375. 0,
  16376. 1
  16377. ]);
  16378. var interleavedBuffer = new InterleavedBuffer(float32Array, 5);
  16379. _geometry.setIndex([0, 1, 2, 0, 2, 3]);
  16380. _geometry.setAttribute("position", new InterleavedBufferAttribute(interleavedBuffer, 3, 0, false));
  16381. _geometry.setAttribute("uv", new InterleavedBufferAttribute(interleavedBuffer, 2, 3, false));
  16382. }
  16383. this.geometry = _geometry;
  16384. this.material = material !== void 0 ? material : new SpriteMaterial();
  16385. this.center = new Vector2(0.5, 0.5);
  16386. }
  16387. Sprite.prototype = Object.assign(Object.create(Object3D.prototype), {
  16388. constructor: Sprite,
  16389. isSprite: true,
  16390. raycast: function(raycaster, intersects2) {
  16391. if (raycaster.camera === null) {
  16392. console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.');
  16393. }
  16394. _worldScale.setFromMatrixScale(this.matrixWorld);
  16395. _viewWorldMatrix.copy(raycaster.camera.matrixWorld);
  16396. this.modelViewMatrix.multiplyMatrices(raycaster.camera.matrixWorldInverse, this.matrixWorld);
  16397. _mvPosition.setFromMatrixPosition(this.modelViewMatrix);
  16398. if (raycaster.camera.isPerspectiveCamera && this.material.sizeAttenuation === false) {
  16399. _worldScale.multiplyScalar(-_mvPosition.z);
  16400. }
  16401. var rotation = this.material.rotation;
  16402. var sin, cos;
  16403. if (rotation !== 0) {
  16404. cos = Math.cos(rotation);
  16405. sin = Math.sin(rotation);
  16406. }
  16407. var center = this.center;
  16408. transformVertex(_vA$1.set(-0.5, -0.5, 0), _mvPosition, center, _worldScale, sin, cos);
  16409. transformVertex(_vB$1.set(0.5, -0.5, 0), _mvPosition, center, _worldScale, sin, cos);
  16410. transformVertex(_vC$1.set(0.5, 0.5, 0), _mvPosition, center, _worldScale, sin, cos);
  16411. _uvA$1.set(0, 0);
  16412. _uvB$1.set(1, 0);
  16413. _uvC$1.set(1, 1);
  16414. var intersect = raycaster.ray.intersectTriangle(_vA$1, _vB$1, _vC$1, false, _intersectPoint);
  16415. if (intersect === null) {
  16416. transformVertex(_vB$1.set(-0.5, 0.5, 0), _mvPosition, center, _worldScale, sin, cos);
  16417. _uvB$1.set(0, 1);
  16418. intersect = raycaster.ray.intersectTriangle(_vA$1, _vC$1, _vB$1, false, _intersectPoint);
  16419. if (intersect === null) {
  16420. return;
  16421. }
  16422. }
  16423. var distance = raycaster.ray.origin.distanceTo(_intersectPoint);
  16424. if (distance < raycaster.near || distance > raycaster.far)
  16425. return;
  16426. intersects2.push({
  16427. distance,
  16428. point: _intersectPoint.clone(),
  16429. uv: Triangle.getUV(_intersectPoint, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2()),
  16430. face: null,
  16431. object: this
  16432. });
  16433. },
  16434. clone: function() {
  16435. return new this.constructor(this.material).copy(this);
  16436. },
  16437. copy: function(source) {
  16438. Object3D.prototype.copy.call(this, source);
  16439. if (source.center !== void 0)
  16440. this.center.copy(source.center);
  16441. return this;
  16442. }
  16443. });
  16444. function transformVertex(vertexPosition, mvPosition, center, scale, sin, cos) {
  16445. _alignedPosition.subVectors(vertexPosition, center).addScalar(0.5).multiply(scale);
  16446. if (sin !== void 0) {
  16447. _rotatedPosition.x = cos * _alignedPosition.x - sin * _alignedPosition.y;
  16448. _rotatedPosition.y = sin * _alignedPosition.x + cos * _alignedPosition.y;
  16449. } else {
  16450. _rotatedPosition.copy(_alignedPosition);
  16451. }
  16452. vertexPosition.copy(mvPosition);
  16453. vertexPosition.x += _rotatedPosition.x;
  16454. vertexPosition.y += _rotatedPosition.y;
  16455. vertexPosition.applyMatrix4(_viewWorldMatrix);
  16456. }
  16457. var _v1$4 = new Vector3();
  16458. var _v2$2 = new Vector3();
  16459. function LOD() {
  16460. Object3D.call(this);
  16461. this.type = "LOD";
  16462. Object.defineProperties(this, {
  16463. levels: {
  16464. enumerable: true,
  16465. value: []
  16466. }
  16467. });
  16468. this.autoUpdate = true;
  16469. }
  16470. LOD.prototype = Object.assign(Object.create(Object3D.prototype), {
  16471. constructor: LOD,
  16472. isLOD: true,
  16473. copy: function(source) {
  16474. Object3D.prototype.copy.call(this, source, false);
  16475. var levels = source.levels;
  16476. for (var i2 = 0, l = levels.length; i2 < l; i2++) {
  16477. var level = levels[i2];
  16478. this.addLevel(level.object.clone(), level.distance);
  16479. }
  16480. this.autoUpdate = source.autoUpdate;
  16481. return this;
  16482. },
  16483. addLevel: function(object, distance) {
  16484. if (distance === void 0)
  16485. distance = 0;
  16486. distance = Math.abs(distance);
  16487. var levels = this.levels;
  16488. for (var l = 0; l < levels.length; l++) {
  16489. if (distance < levels[l].distance) {
  16490. break;
  16491. }
  16492. }
  16493. levels.splice(l, 0, { distance, object });
  16494. this.add(object);
  16495. return this;
  16496. },
  16497. getObjectForDistance: function(distance) {
  16498. var levels = this.levels;
  16499. if (levels.length > 0) {
  16500. for (var i2 = 1, l = levels.length; i2 < l; i2++) {
  16501. if (distance < levels[i2].distance) {
  16502. break;
  16503. }
  16504. }
  16505. return levels[i2 - 1].object;
  16506. }
  16507. return null;
  16508. },
  16509. raycast: function(raycaster, intersects2) {
  16510. var levels = this.levels;
  16511. if (levels.length > 0) {
  16512. _v1$4.setFromMatrixPosition(this.matrixWorld);
  16513. var distance = raycaster.ray.origin.distanceTo(_v1$4);
  16514. this.getObjectForDistance(distance).raycast(raycaster, intersects2);
  16515. }
  16516. },
  16517. update: function(camera) {
  16518. var levels = this.levels;
  16519. if (levels.length > 1) {
  16520. _v1$4.setFromMatrixPosition(camera.matrixWorld);
  16521. _v2$2.setFromMatrixPosition(this.matrixWorld);
  16522. var distance = _v1$4.distanceTo(_v2$2);
  16523. levels[0].object.visible = true;
  16524. for (var i2 = 1, l = levels.length; i2 < l; i2++) {
  16525. if (distance >= levels[i2].distance) {
  16526. levels[i2 - 1].object.visible = false;
  16527. levels[i2].object.visible = true;
  16528. } else {
  16529. break;
  16530. }
  16531. }
  16532. for (; i2 < l; i2++) {
  16533. levels[i2].object.visible = false;
  16534. }
  16535. }
  16536. },
  16537. toJSON: function(meta) {
  16538. var data = Object3D.prototype.toJSON.call(this, meta);
  16539. if (this.autoUpdate === false)
  16540. data.object.autoUpdate = false;
  16541. data.object.levels = [];
  16542. var levels = this.levels;
  16543. for (var i2 = 0, l = levels.length; i2 < l; i2++) {
  16544. var level = levels[i2];
  16545. data.object.levels.push({
  16546. object: level.object.uuid,
  16547. distance: level.distance
  16548. });
  16549. }
  16550. return data;
  16551. }
  16552. });
  16553. function SkinnedMesh(geometry, material) {
  16554. if (geometry && geometry.isGeometry) {
  16555. console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");
  16556. }
  16557. Mesh.call(this, geometry, material);
  16558. this.type = "SkinnedMesh";
  16559. this.bindMode = "attached";
  16560. this.bindMatrix = new Matrix4();
  16561. this.bindMatrixInverse = new Matrix4();
  16562. }
  16563. SkinnedMesh.prototype = Object.assign(Object.create(Mesh.prototype), {
  16564. constructor: SkinnedMesh,
  16565. isSkinnedMesh: true,
  16566. bind: function(skeleton, bindMatrix) {
  16567. this.skeleton = skeleton;
  16568. if (bindMatrix === void 0) {
  16569. this.updateMatrixWorld(true);
  16570. this.skeleton.calculateInverses();
  16571. bindMatrix = this.matrixWorld;
  16572. }
  16573. this.bindMatrix.copy(bindMatrix);
  16574. this.bindMatrixInverse.getInverse(bindMatrix);
  16575. },
  16576. pose: function() {
  16577. this.skeleton.pose();
  16578. },
  16579. normalizeSkinWeights: function() {
  16580. var vector = new Vector4();
  16581. var skinWeight = this.geometry.attributes.skinWeight;
  16582. for (var i2 = 0, l = skinWeight.count; i2 < l; i2++) {
  16583. vector.x = skinWeight.getX(i2);
  16584. vector.y = skinWeight.getY(i2);
  16585. vector.z = skinWeight.getZ(i2);
  16586. vector.w = skinWeight.getW(i2);
  16587. var scale = 1 / vector.manhattanLength();
  16588. if (scale !== Infinity) {
  16589. vector.multiplyScalar(scale);
  16590. } else {
  16591. vector.set(1, 0, 0, 0);
  16592. }
  16593. skinWeight.setXYZW(i2, vector.x, vector.y, vector.z, vector.w);
  16594. }
  16595. },
  16596. updateMatrixWorld: function(force) {
  16597. Mesh.prototype.updateMatrixWorld.call(this, force);
  16598. if (this.bindMode === "attached") {
  16599. this.bindMatrixInverse.getInverse(this.matrixWorld);
  16600. } else if (this.bindMode === "detached") {
  16601. this.bindMatrixInverse.getInverse(this.bindMatrix);
  16602. } else {
  16603. console.warn("THREE.SkinnedMesh: Unrecognized bindMode: " + this.bindMode);
  16604. }
  16605. },
  16606. clone: function() {
  16607. return new this.constructor(this.geometry, this.material).copy(this);
  16608. }
  16609. });
  16610. var _offsetMatrix = new Matrix4();
  16611. var _identityMatrix = new Matrix4();
  16612. function Skeleton(bones, boneInverses) {
  16613. bones = bones || [];
  16614. this.bones = bones.slice(0);
  16615. this.boneMatrices = new Float32Array(this.bones.length * 16);
  16616. this.frame = -1;
  16617. if (boneInverses === void 0) {
  16618. this.calculateInverses();
  16619. } else {
  16620. if (this.bones.length === boneInverses.length) {
  16621. this.boneInverses = boneInverses.slice(0);
  16622. } else {
  16623. console.warn("THREE.Skeleton boneInverses is the wrong length.");
  16624. this.boneInverses = [];
  16625. for (var i2 = 0, il = this.bones.length; i2 < il; i2++) {
  16626. this.boneInverses.push(new Matrix4());
  16627. }
  16628. }
  16629. }
  16630. }
  16631. Object.assign(Skeleton.prototype, {
  16632. calculateInverses: function() {
  16633. this.boneInverses = [];
  16634. for (var i2 = 0, il = this.bones.length; i2 < il; i2++) {
  16635. var inverse = new Matrix4();
  16636. if (this.bones[i2]) {
  16637. inverse.getInverse(this.bones[i2].matrixWorld);
  16638. }
  16639. this.boneInverses.push(inverse);
  16640. }
  16641. },
  16642. pose: function() {
  16643. var bone, i2, il;
  16644. for (i2 = 0, il = this.bones.length; i2 < il; i2++) {
  16645. bone = this.bones[i2];
  16646. if (bone) {
  16647. bone.matrixWorld.getInverse(this.boneInverses[i2]);
  16648. }
  16649. }
  16650. for (i2 = 0, il = this.bones.length; i2 < il; i2++) {
  16651. bone = this.bones[i2];
  16652. if (bone) {
  16653. if (bone.parent && bone.parent.isBone) {
  16654. bone.matrix.getInverse(bone.parent.matrixWorld);
  16655. bone.matrix.multiply(bone.matrixWorld);
  16656. } else {
  16657. bone.matrix.copy(bone.matrixWorld);
  16658. }
  16659. bone.matrix.decompose(bone.position, bone.quaternion, bone.scale);
  16660. }
  16661. }
  16662. },
  16663. update: function() {
  16664. var bones = this.bones;
  16665. var boneInverses = this.boneInverses;
  16666. var boneMatrices = this.boneMatrices;
  16667. var boneTexture = this.boneTexture;
  16668. for (var i2 = 0, il = bones.length; i2 < il; i2++) {
  16669. var matrix = bones[i2] ? bones[i2].matrixWorld : _identityMatrix;
  16670. _offsetMatrix.multiplyMatrices(matrix, boneInverses[i2]);
  16671. _offsetMatrix.toArray(boneMatrices, i2 * 16);
  16672. }
  16673. if (boneTexture !== void 0) {
  16674. boneTexture.needsUpdate = true;
  16675. }
  16676. },
  16677. clone: function() {
  16678. return new Skeleton(this.bones, this.boneInverses);
  16679. },
  16680. getBoneByName: function(name) {
  16681. for (var i2 = 0, il = this.bones.length; i2 < il; i2++) {
  16682. var bone = this.bones[i2];
  16683. if (bone.name === name) {
  16684. return bone;
  16685. }
  16686. }
  16687. return void 0;
  16688. }
  16689. });
  16690. function Bone() {
  16691. Object3D.call(this);
  16692. this.type = "Bone";
  16693. }
  16694. Bone.prototype = Object.assign(Object.create(Object3D.prototype), {
  16695. constructor: Bone,
  16696. isBone: true
  16697. });
  16698. var _instanceLocalMatrix = new Matrix4();
  16699. var _instanceWorldMatrix = new Matrix4();
  16700. var _instanceIntersects = [];
  16701. var _mesh = new Mesh();
  16702. function InstancedMesh(geometry, material, count) {
  16703. Mesh.call(this, geometry, material);
  16704. this.instanceMatrix = new BufferAttribute(new Float32Array(count * 16), 16);
  16705. this.count = count;
  16706. this.frustumCulled = false;
  16707. }
  16708. InstancedMesh.prototype = Object.assign(Object.create(Mesh.prototype), {
  16709. constructor: InstancedMesh,
  16710. isInstancedMesh: true,
  16711. getMatrixAt: function(index, matrix) {
  16712. matrix.fromArray(this.instanceMatrix.array, index * 16);
  16713. },
  16714. raycast: function(raycaster, intersects2) {
  16715. var matrixWorld = this.matrixWorld;
  16716. var raycastTimes = this.count;
  16717. _mesh.geometry = this.geometry;
  16718. _mesh.material = this.material;
  16719. if (_mesh.material === void 0)
  16720. return;
  16721. for (var instanceId = 0; instanceId < raycastTimes; instanceId++) {
  16722. this.getMatrixAt(instanceId, _instanceLocalMatrix);
  16723. _instanceWorldMatrix.multiplyMatrices(matrixWorld, _instanceLocalMatrix);
  16724. _mesh.matrixWorld = _instanceWorldMatrix;
  16725. _mesh.raycast(raycaster, _instanceIntersects);
  16726. if (_instanceIntersects.length > 0) {
  16727. _instanceIntersects[0].instanceId = instanceId;
  16728. _instanceIntersects[0].object = this;
  16729. intersects2.push(_instanceIntersects[0]);
  16730. _instanceIntersects.length = 0;
  16731. }
  16732. }
  16733. },
  16734. setMatrixAt: function(index, matrix) {
  16735. matrix.toArray(this.instanceMatrix.array, index * 16);
  16736. },
  16737. updateMorphTargets: function() {
  16738. }
  16739. });
  16740. function LineBasicMaterial(parameters) {
  16741. Material.call(this);
  16742. this.type = "LineBasicMaterial";
  16743. this.color = new Color(16777215);
  16744. this.linewidth = 1;
  16745. this.linecap = "round";
  16746. this.linejoin = "round";
  16747. this.setValues(parameters);
  16748. }
  16749. LineBasicMaterial.prototype = Object.create(Material.prototype);
  16750. LineBasicMaterial.prototype.constructor = LineBasicMaterial;
  16751. LineBasicMaterial.prototype.isLineBasicMaterial = true;
  16752. LineBasicMaterial.prototype.copy = function(source) {
  16753. Material.prototype.copy.call(this, source);
  16754. this.color.copy(source.color);
  16755. this.linewidth = source.linewidth;
  16756. this.linecap = source.linecap;
  16757. this.linejoin = source.linejoin;
  16758. return this;
  16759. };
  16760. var _start = new Vector3();
  16761. var _end = new Vector3();
  16762. var _inverseMatrix$1 = new Matrix4();
  16763. var _ray$1 = new Ray();
  16764. var _sphere$2 = new Sphere();
  16765. function Line(geometry, material, mode) {
  16766. if (mode === 1) {
  16767. console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead.");
  16768. }
  16769. Object3D.call(this);
  16770. this.type = "Line";
  16771. this.geometry = geometry !== void 0 ? geometry : new BufferGeometry();
  16772. this.material = material !== void 0 ? material : new LineBasicMaterial();
  16773. }
  16774. Line.prototype = Object.assign(Object.create(Object3D.prototype), {
  16775. constructor: Line,
  16776. isLine: true,
  16777. computeLineDistances: function() {
  16778. var geometry = this.geometry;
  16779. if (geometry.isBufferGeometry) {
  16780. if (geometry.index === null) {
  16781. var positionAttribute = geometry.attributes.position;
  16782. var lineDistances = [0];
  16783. for (var i2 = 1, l = positionAttribute.count; i2 < l; i2++) {
  16784. _start.fromBufferAttribute(positionAttribute, i2 - 1);
  16785. _end.fromBufferAttribute(positionAttribute, i2);
  16786. lineDistances[i2] = lineDistances[i2 - 1];
  16787. lineDistances[i2] += _start.distanceTo(_end);
  16788. }
  16789. geometry.setAttribute("lineDistance", new Float32BufferAttribute(lineDistances, 1));
  16790. } else {
  16791. console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");
  16792. }
  16793. } else if (geometry.isGeometry) {
  16794. var vertices = geometry.vertices;
  16795. var lineDistances = geometry.lineDistances;
  16796. lineDistances[0] = 0;
  16797. for (var i2 = 1, l = vertices.length; i2 < l; i2++) {
  16798. lineDistances[i2] = lineDistances[i2 - 1];
  16799. lineDistances[i2] += vertices[i2 - 1].distanceTo(vertices[i2]);
  16800. }
  16801. }
  16802. return this;
  16803. },
  16804. raycast: function(raycaster, intersects2) {
  16805. var precision = raycaster.linePrecision;
  16806. var geometry = this.geometry;
  16807. var matrixWorld = this.matrixWorld;
  16808. if (geometry.boundingSphere === null)
  16809. geometry.computeBoundingSphere();
  16810. _sphere$2.copy(geometry.boundingSphere);
  16811. _sphere$2.applyMatrix4(matrixWorld);
  16812. _sphere$2.radius += precision;
  16813. if (raycaster.ray.intersectsSphere(_sphere$2) === false)
  16814. return;
  16815. _inverseMatrix$1.getInverse(matrixWorld);
  16816. _ray$1.copy(raycaster.ray).applyMatrix4(_inverseMatrix$1);
  16817. var localPrecision = precision / ((this.scale.x + this.scale.y + this.scale.z) / 3);
  16818. var localPrecisionSq = localPrecision * localPrecision;
  16819. var vStart = new Vector3();
  16820. var vEnd = new Vector3();
  16821. var interSegment = new Vector3();
  16822. var interRay = new Vector3();
  16823. var step = this && this.isLineSegments ? 2 : 1;
  16824. if (geometry.isBufferGeometry) {
  16825. var index = geometry.index;
  16826. var attributes = geometry.attributes;
  16827. var positions = attributes.position.array;
  16828. if (index !== null) {
  16829. var indices = index.array;
  16830. for (var i2 = 0, l = indices.length - 1; i2 < l; i2 += step) {
  16831. var a = indices[i2];
  16832. var b = indices[i2 + 1];
  16833. vStart.fromArray(positions, a * 3);
  16834. vEnd.fromArray(positions, b * 3);
  16835. var distSq = _ray$1.distanceSqToSegment(vStart, vEnd, interRay, interSegment);
  16836. if (distSq > localPrecisionSq)
  16837. continue;
  16838. interRay.applyMatrix4(this.matrixWorld);
  16839. var distance = raycaster.ray.origin.distanceTo(interRay);
  16840. if (distance < raycaster.near || distance > raycaster.far)
  16841. continue;
  16842. intersects2.push({
  16843. distance,
  16844. // What do we want? intersection point on the ray or on the segment??
  16845. // point: raycaster.ray.at( distance ),
  16846. point: interSegment.clone().applyMatrix4(this.matrixWorld),
  16847. index: i2,
  16848. face: null,
  16849. faceIndex: null,
  16850. object: this
  16851. });
  16852. }
  16853. } else {
  16854. for (var i2 = 0, l = positions.length / 3 - 1; i2 < l; i2 += step) {
  16855. vStart.fromArray(positions, 3 * i2);
  16856. vEnd.fromArray(positions, 3 * i2 + 3);
  16857. var distSq = _ray$1.distanceSqToSegment(vStart, vEnd, interRay, interSegment);
  16858. if (distSq > localPrecisionSq)
  16859. continue;
  16860. interRay.applyMatrix4(this.matrixWorld);
  16861. var distance = raycaster.ray.origin.distanceTo(interRay);
  16862. if (distance < raycaster.near || distance > raycaster.far)
  16863. continue;
  16864. intersects2.push({
  16865. distance,
  16866. // What do we want? intersection point on the ray or on the segment??
  16867. // point: raycaster.ray.at( distance ),
  16868. point: interSegment.clone().applyMatrix4(this.matrixWorld),
  16869. index: i2,
  16870. face: null,
  16871. faceIndex: null,
  16872. object: this
  16873. });
  16874. }
  16875. }
  16876. } else if (geometry.isGeometry) {
  16877. var vertices = geometry.vertices;
  16878. var nbVertices = vertices.length;
  16879. for (var i2 = 0; i2 < nbVertices - 1; i2 += step) {
  16880. var distSq = _ray$1.distanceSqToSegment(vertices[i2], vertices[i2 + 1], interRay, interSegment);
  16881. if (distSq > localPrecisionSq)
  16882. continue;
  16883. interRay.applyMatrix4(this.matrixWorld);
  16884. var distance = raycaster.ray.origin.distanceTo(interRay);
  16885. if (distance < raycaster.near || distance > raycaster.far)
  16886. continue;
  16887. intersects2.push({
  16888. distance,
  16889. // What do we want? intersection point on the ray or on the segment??
  16890. // point: raycaster.ray.at( distance ),
  16891. point: interSegment.clone().applyMatrix4(this.matrixWorld),
  16892. index: i2,
  16893. face: null,
  16894. faceIndex: null,
  16895. object: this
  16896. });
  16897. }
  16898. }
  16899. },
  16900. clone: function() {
  16901. return new this.constructor(this.geometry, this.material).copy(this);
  16902. }
  16903. });
  16904. var _start$1 = new Vector3();
  16905. var _end$1 = new Vector3();
  16906. function LineSegments(geometry, material) {
  16907. Line.call(this, geometry, material);
  16908. this.type = "LineSegments";
  16909. }
  16910. LineSegments.prototype = Object.assign(Object.create(Line.prototype), {
  16911. constructor: LineSegments,
  16912. isLineSegments: true,
  16913. computeLineDistances: function() {
  16914. var geometry = this.geometry;
  16915. if (geometry.isBufferGeometry) {
  16916. if (geometry.index === null) {
  16917. var positionAttribute = geometry.attributes.position;
  16918. var lineDistances = [];
  16919. for (var i2 = 0, l = positionAttribute.count; i2 < l; i2 += 2) {
  16920. _start$1.fromBufferAttribute(positionAttribute, i2);
  16921. _end$1.fromBufferAttribute(positionAttribute, i2 + 1);
  16922. lineDistances[i2] = i2 === 0 ? 0 : lineDistances[i2 - 1];
  16923. lineDistances[i2 + 1] = lineDistances[i2] + _start$1.distanceTo(_end$1);
  16924. }
  16925. geometry.setAttribute("lineDistance", new Float32BufferAttribute(lineDistances, 1));
  16926. } else {
  16927. console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");
  16928. }
  16929. } else if (geometry.isGeometry) {
  16930. var vertices = geometry.vertices;
  16931. var lineDistances = geometry.lineDistances;
  16932. for (var i2 = 0, l = vertices.length; i2 < l; i2 += 2) {
  16933. _start$1.copy(vertices[i2]);
  16934. _end$1.copy(vertices[i2 + 1]);
  16935. lineDistances[i2] = i2 === 0 ? 0 : lineDistances[i2 - 1];
  16936. lineDistances[i2 + 1] = lineDistances[i2] + _start$1.distanceTo(_end$1);
  16937. }
  16938. }
  16939. return this;
  16940. }
  16941. });
  16942. function LineLoop(geometry, material) {
  16943. Line.call(this, geometry, material);
  16944. this.type = "LineLoop";
  16945. }
  16946. LineLoop.prototype = Object.assign(Object.create(Line.prototype), {
  16947. constructor: LineLoop,
  16948. isLineLoop: true
  16949. });
  16950. function PointsMaterial(parameters) {
  16951. Material.call(this);
  16952. this.type = "PointsMaterial";
  16953. this.color = new Color(16777215);
  16954. this.map = null;
  16955. this.alphaMap = null;
  16956. this.size = 1;
  16957. this.sizeAttenuation = true;
  16958. this.morphTargets = false;
  16959. this.setValues(parameters);
  16960. }
  16961. PointsMaterial.prototype = Object.create(Material.prototype);
  16962. PointsMaterial.prototype.constructor = PointsMaterial;
  16963. PointsMaterial.prototype.isPointsMaterial = true;
  16964. PointsMaterial.prototype.copy = function(source) {
  16965. Material.prototype.copy.call(this, source);
  16966. this.color.copy(source.color);
  16967. this.map = source.map;
  16968. this.alphaMap = source.alphaMap;
  16969. this.size = source.size;
  16970. this.sizeAttenuation = source.sizeAttenuation;
  16971. this.morphTargets = source.morphTargets;
  16972. return this;
  16973. };
  16974. var _inverseMatrix$2 = new Matrix4();
  16975. var _ray$2 = new Ray();
  16976. var _sphere$3 = new Sphere();
  16977. var _position$1 = new Vector3();
  16978. function Points(geometry, material) {
  16979. Object3D.call(this);
  16980. this.type = "Points";
  16981. this.geometry = geometry !== void 0 ? geometry : new BufferGeometry();
  16982. this.material = material !== void 0 ? material : new PointsMaterial();
  16983. this.updateMorphTargets();
  16984. }
  16985. Points.prototype = Object.assign(Object.create(Object3D.prototype), {
  16986. constructor: Points,
  16987. isPoints: true,
  16988. raycast: function(raycaster, intersects2) {
  16989. var geometry = this.geometry;
  16990. var matrixWorld = this.matrixWorld;
  16991. var threshold = raycaster.params.Points.threshold;
  16992. if (geometry.boundingSphere === null)
  16993. geometry.computeBoundingSphere();
  16994. _sphere$3.copy(geometry.boundingSphere);
  16995. _sphere$3.applyMatrix4(matrixWorld);
  16996. _sphere$3.radius += threshold;
  16997. if (raycaster.ray.intersectsSphere(_sphere$3) === false)
  16998. return;
  16999. _inverseMatrix$2.getInverse(matrixWorld);
  17000. _ray$2.copy(raycaster.ray).applyMatrix4(_inverseMatrix$2);
  17001. var localThreshold = threshold / ((this.scale.x + this.scale.y + this.scale.z) / 3);
  17002. var localThresholdSq = localThreshold * localThreshold;
  17003. if (geometry.isBufferGeometry) {
  17004. var index = geometry.index;
  17005. var attributes = geometry.attributes;
  17006. var positions = attributes.position.array;
  17007. if (index !== null) {
  17008. var indices = index.array;
  17009. for (var i2 = 0, il = indices.length; i2 < il; i2++) {
  17010. var a = indices[i2];
  17011. _position$1.fromArray(positions, a * 3);
  17012. testPoint(_position$1, a, localThresholdSq, matrixWorld, raycaster, intersects2, this);
  17013. }
  17014. } else {
  17015. for (var i2 = 0, l = positions.length / 3; i2 < l; i2++) {
  17016. _position$1.fromArray(positions, i2 * 3);
  17017. testPoint(_position$1, i2, localThresholdSq, matrixWorld, raycaster, intersects2, this);
  17018. }
  17019. }
  17020. } else {
  17021. var vertices = geometry.vertices;
  17022. for (var i2 = 0, l = vertices.length; i2 < l; i2++) {
  17023. testPoint(vertices[i2], i2, localThresholdSq, matrixWorld, raycaster, intersects2, this);
  17024. }
  17025. }
  17026. },
  17027. updateMorphTargets: function() {
  17028. var geometry = this.geometry;
  17029. var m, ml, name;
  17030. if (geometry.isBufferGeometry) {
  17031. var morphAttributes = geometry.morphAttributes;
  17032. var keys = Object.keys(morphAttributes);
  17033. if (keys.length > 0) {
  17034. var morphAttribute = morphAttributes[keys[0]];
  17035. if (morphAttribute !== void 0) {
  17036. this.morphTargetInfluences = [];
  17037. this.morphTargetDictionary = {};
  17038. for (m = 0, ml = morphAttribute.length; m < ml; m++) {
  17039. name = morphAttribute[m].name || String(m);
  17040. this.morphTargetInfluences.push(0);
  17041. this.morphTargetDictionary[name] = m;
  17042. }
  17043. }
  17044. }
  17045. } else {
  17046. var morphTargets = geometry.morphTargets;
  17047. if (morphTargets !== void 0 && morphTargets.length > 0) {
  17048. console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.");
  17049. }
  17050. }
  17051. },
  17052. clone: function() {
  17053. return new this.constructor(this.geometry, this.material).copy(this);
  17054. }
  17055. });
  17056. function testPoint(point, index, localThresholdSq, matrixWorld, raycaster, intersects2, object) {
  17057. var rayPointDistanceSq = _ray$2.distanceSqToPoint(point);
  17058. if (rayPointDistanceSq < localThresholdSq) {
  17059. var intersectPoint = new Vector3();
  17060. _ray$2.closestPointToPoint(point, intersectPoint);
  17061. intersectPoint.applyMatrix4(matrixWorld);
  17062. var distance = raycaster.ray.origin.distanceTo(intersectPoint);
  17063. if (distance < raycaster.near || distance > raycaster.far)
  17064. return;
  17065. intersects2.push({
  17066. distance,
  17067. distanceToRay: Math.sqrt(rayPointDistanceSq),
  17068. point: intersectPoint,
  17069. index,
  17070. face: null,
  17071. object
  17072. });
  17073. }
  17074. }
  17075. function VideoTexture(video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy) {
  17076. Texture.call(this, video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);
  17077. this.format = format !== void 0 ? format : RGBFormat;
  17078. this.minFilter = minFilter !== void 0 ? minFilter : LinearFilter;
  17079. this.magFilter = magFilter !== void 0 ? magFilter : LinearFilter;
  17080. this.generateMipmaps = false;
  17081. }
  17082. VideoTexture.prototype = Object.assign(Object.create(Texture.prototype), {
  17083. constructor: VideoTexture,
  17084. isVideoTexture: true,
  17085. update: function() {
  17086. var video = this.image;
  17087. if (video.readyState >= video.HAVE_CURRENT_DATA) {
  17088. this.needsUpdate = true;
  17089. }
  17090. }
  17091. });
  17092. function CompressedTexture(mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding) {
  17093. Texture.call(this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);
  17094. this.image = { width, height };
  17095. this.mipmaps = mipmaps;
  17096. this.flipY = false;
  17097. this.generateMipmaps = false;
  17098. }
  17099. CompressedTexture.prototype = Object.create(Texture.prototype);
  17100. CompressedTexture.prototype.constructor = CompressedTexture;
  17101. CompressedTexture.prototype.isCompressedTexture = true;
  17102. function CanvasTexture(canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy) {
  17103. Texture.call(this, canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);
  17104. this.needsUpdate = true;
  17105. }
  17106. CanvasTexture.prototype = Object.create(Texture.prototype);
  17107. CanvasTexture.prototype.constructor = CanvasTexture;
  17108. CanvasTexture.prototype.isCanvasTexture = true;
  17109. function DepthTexture(width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format) {
  17110. format = format !== void 0 ? format : DepthFormat;
  17111. if (format !== DepthFormat && format !== DepthStencilFormat) {
  17112. throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");
  17113. }
  17114. if (type === void 0 && format === DepthFormat)
  17115. type = UnsignedShortType;
  17116. if (type === void 0 && format === DepthStencilFormat)
  17117. type = UnsignedInt248Type;
  17118. Texture.call(this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);
  17119. this.image = { width, height };
  17120. this.magFilter = magFilter !== void 0 ? magFilter : NearestFilter;
  17121. this.minFilter = minFilter !== void 0 ? minFilter : NearestFilter;
  17122. this.flipY = false;
  17123. this.generateMipmaps = false;
  17124. }
  17125. DepthTexture.prototype = Object.create(Texture.prototype);
  17126. DepthTexture.prototype.constructor = DepthTexture;
  17127. DepthTexture.prototype.isDepthTexture = true;
  17128. function WireframeGeometry(geometry) {
  17129. BufferGeometry.call(this);
  17130. this.type = "WireframeGeometry";
  17131. var vertices = [];
  17132. var i2, j, l, o, ol;
  17133. var edge = [0, 0], edges = {}, e, edge1, edge2;
  17134. var key, keys = ["a", "b", "c"];
  17135. var vertex;
  17136. if (geometry && geometry.isGeometry) {
  17137. var faces = geometry.faces;
  17138. for (i2 = 0, l = faces.length; i2 < l; i2++) {
  17139. var face = faces[i2];
  17140. for (j = 0; j < 3; j++) {
  17141. edge1 = face[keys[j]];
  17142. edge2 = face[keys[(j + 1) % 3]];
  17143. edge[0] = Math.min(edge1, edge2);
  17144. edge[1] = Math.max(edge1, edge2);
  17145. key = edge[0] + "," + edge[1];
  17146. if (edges[key] === void 0) {
  17147. edges[key] = { index1: edge[0], index2: edge[1] };
  17148. }
  17149. }
  17150. }
  17151. for (key in edges) {
  17152. e = edges[key];
  17153. vertex = geometry.vertices[e.index1];
  17154. vertices.push(vertex.x, vertex.y, vertex.z);
  17155. vertex = geometry.vertices[e.index2];
  17156. vertices.push(vertex.x, vertex.y, vertex.z);
  17157. }
  17158. } else if (geometry && geometry.isBufferGeometry) {
  17159. var position, indices, groups;
  17160. var group, start, count;
  17161. var index1, index2;
  17162. vertex = new Vector3();
  17163. if (geometry.index !== null) {
  17164. position = geometry.attributes.position;
  17165. indices = geometry.index;
  17166. groups = geometry.groups;
  17167. if (groups.length === 0) {
  17168. groups = [{ start: 0, count: indices.count, materialIndex: 0 }];
  17169. }
  17170. for (o = 0, ol = groups.length; o < ol; ++o) {
  17171. group = groups[o];
  17172. start = group.start;
  17173. count = group.count;
  17174. for (i2 = start, l = start + count; i2 < l; i2 += 3) {
  17175. for (j = 0; j < 3; j++) {
  17176. edge1 = indices.getX(i2 + j);
  17177. edge2 = indices.getX(i2 + (j + 1) % 3);
  17178. edge[0] = Math.min(edge1, edge2);
  17179. edge[1] = Math.max(edge1, edge2);
  17180. key = edge[0] + "," + edge[1];
  17181. if (edges[key] === void 0) {
  17182. edges[key] = { index1: edge[0], index2: edge[1] };
  17183. }
  17184. }
  17185. }
  17186. }
  17187. for (key in edges) {
  17188. e = edges[key];
  17189. vertex.fromBufferAttribute(position, e.index1);
  17190. vertices.push(vertex.x, vertex.y, vertex.z);
  17191. vertex.fromBufferAttribute(position, e.index2);
  17192. vertices.push(vertex.x, vertex.y, vertex.z);
  17193. }
  17194. } else {
  17195. position = geometry.attributes.position;
  17196. for (i2 = 0, l = position.count / 3; i2 < l; i2++) {
  17197. for (j = 0; j < 3; j++) {
  17198. index1 = 3 * i2 + j;
  17199. vertex.fromBufferAttribute(position, index1);
  17200. vertices.push(vertex.x, vertex.y, vertex.z);
  17201. index2 = 3 * i2 + (j + 1) % 3;
  17202. vertex.fromBufferAttribute(position, index2);
  17203. vertices.push(vertex.x, vertex.y, vertex.z);
  17204. }
  17205. }
  17206. }
  17207. }
  17208. this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  17209. }
  17210. WireframeGeometry.prototype = Object.create(BufferGeometry.prototype);
  17211. WireframeGeometry.prototype.constructor = WireframeGeometry;
  17212. function ParametricGeometry(func, slices, stacks) {
  17213. Geometry.call(this);
  17214. this.type = "ParametricGeometry";
  17215. this.parameters = {
  17216. func,
  17217. slices,
  17218. stacks
  17219. };
  17220. this.fromBufferGeometry(new ParametricBufferGeometry(func, slices, stacks));
  17221. this.mergeVertices();
  17222. }
  17223. ParametricGeometry.prototype = Object.create(Geometry.prototype);
  17224. ParametricGeometry.prototype.constructor = ParametricGeometry;
  17225. function ParametricBufferGeometry(func, slices, stacks) {
  17226. BufferGeometry.call(this);
  17227. this.type = "ParametricBufferGeometry";
  17228. this.parameters = {
  17229. func,
  17230. slices,
  17231. stacks
  17232. };
  17233. var indices = [];
  17234. var vertices = [];
  17235. var normals = [];
  17236. var uvs = [];
  17237. var EPS = 1e-5;
  17238. var normal = new Vector3();
  17239. var p0 = new Vector3(), p1 = new Vector3();
  17240. var pu = new Vector3(), pv = new Vector3();
  17241. var i2, j;
  17242. if (func.length < 3) {
  17243. console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");
  17244. }
  17245. var sliceCount = slices + 1;
  17246. for (i2 = 0; i2 <= stacks; i2++) {
  17247. var v = i2 / stacks;
  17248. for (j = 0; j <= slices; j++) {
  17249. var u = j / slices;
  17250. func(u, v, p0);
  17251. vertices.push(p0.x, p0.y, p0.z);
  17252. if (u - EPS >= 0) {
  17253. func(u - EPS, v, p1);
  17254. pu.subVectors(p0, p1);
  17255. } else {
  17256. func(u + EPS, v, p1);
  17257. pu.subVectors(p1, p0);
  17258. }
  17259. if (v - EPS >= 0) {
  17260. func(u, v - EPS, p1);
  17261. pv.subVectors(p0, p1);
  17262. } else {
  17263. func(u, v + EPS, p1);
  17264. pv.subVectors(p1, p0);
  17265. }
  17266. normal.crossVectors(pu, pv).normalize();
  17267. normals.push(normal.x, normal.y, normal.z);
  17268. uvs.push(u, v);
  17269. }
  17270. }
  17271. for (i2 = 0; i2 < stacks; i2++) {
  17272. for (j = 0; j < slices; j++) {
  17273. var a = i2 * sliceCount + j;
  17274. var b = i2 * sliceCount + j + 1;
  17275. var c = (i2 + 1) * sliceCount + j + 1;
  17276. var d = (i2 + 1) * sliceCount + j;
  17277. indices.push(a, b, d);
  17278. indices.push(b, c, d);
  17279. }
  17280. }
  17281. this.setIndex(indices);
  17282. this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  17283. this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
  17284. this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
  17285. }
  17286. ParametricBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
  17287. ParametricBufferGeometry.prototype.constructor = ParametricBufferGeometry;
  17288. function PolyhedronGeometry(vertices, indices, radius, detail) {
  17289. Geometry.call(this);
  17290. this.type = "PolyhedronGeometry";
  17291. this.parameters = {
  17292. vertices,
  17293. indices,
  17294. radius,
  17295. detail
  17296. };
  17297. this.fromBufferGeometry(new PolyhedronBufferGeometry(vertices, indices, radius, detail));
  17298. this.mergeVertices();
  17299. }
  17300. PolyhedronGeometry.prototype = Object.create(Geometry.prototype);
  17301. PolyhedronGeometry.prototype.constructor = PolyhedronGeometry;
  17302. function PolyhedronBufferGeometry(vertices, indices, radius, detail) {
  17303. BufferGeometry.call(this);
  17304. this.type = "PolyhedronBufferGeometry";
  17305. this.parameters = {
  17306. vertices,
  17307. indices,
  17308. radius,
  17309. detail
  17310. };
  17311. radius = radius || 1;
  17312. detail = detail || 0;
  17313. var vertexBuffer = [];
  17314. var uvBuffer = [];
  17315. subdivide(detail);
  17316. applyRadius(radius);
  17317. generateUVs();
  17318. this.setAttribute("position", new Float32BufferAttribute(vertexBuffer, 3));
  17319. this.setAttribute("normal", new Float32BufferAttribute(vertexBuffer.slice(), 3));
  17320. this.setAttribute("uv", new Float32BufferAttribute(uvBuffer, 2));
  17321. if (detail === 0) {
  17322. this.computeVertexNormals();
  17323. } else {
  17324. this.normalizeNormals();
  17325. }
  17326. function subdivide(detail2) {
  17327. var a = new Vector3();
  17328. var b = new Vector3();
  17329. var c = new Vector3();
  17330. for (var i2 = 0; i2 < indices.length; i2 += 3) {
  17331. getVertexByIndex(indices[i2 + 0], a);
  17332. getVertexByIndex(indices[i2 + 1], b);
  17333. getVertexByIndex(indices[i2 + 2], c);
  17334. subdivideFace(a, b, c, detail2);
  17335. }
  17336. }
  17337. function subdivideFace(a, b, c, detail2) {
  17338. var cols = Math.pow(2, detail2);
  17339. var v = [];
  17340. var i2, j;
  17341. for (i2 = 0; i2 <= cols; i2++) {
  17342. v[i2] = [];
  17343. var aj = a.clone().lerp(c, i2 / cols);
  17344. var bj = b.clone().lerp(c, i2 / cols);
  17345. var rows = cols - i2;
  17346. for (j = 0; j <= rows; j++) {
  17347. if (j === 0 && i2 === cols) {
  17348. v[i2][j] = aj;
  17349. } else {
  17350. v[i2][j] = aj.clone().lerp(bj, j / rows);
  17351. }
  17352. }
  17353. }
  17354. for (i2 = 0; i2 < cols; i2++) {
  17355. for (j = 0; j < 2 * (cols - i2) - 1; j++) {
  17356. var k = Math.floor(j / 2);
  17357. if (j % 2 === 0) {
  17358. pushVertex(v[i2][k + 1]);
  17359. pushVertex(v[i2 + 1][k]);
  17360. pushVertex(v[i2][k]);
  17361. } else {
  17362. pushVertex(v[i2][k + 1]);
  17363. pushVertex(v[i2 + 1][k + 1]);
  17364. pushVertex(v[i2 + 1][k]);
  17365. }
  17366. }
  17367. }
  17368. }
  17369. function applyRadius(radius2) {
  17370. var vertex = new Vector3();
  17371. for (var i2 = 0; i2 < vertexBuffer.length; i2 += 3) {
  17372. vertex.x = vertexBuffer[i2 + 0];
  17373. vertex.y = vertexBuffer[i2 + 1];
  17374. vertex.z = vertexBuffer[i2 + 2];
  17375. vertex.normalize().multiplyScalar(radius2);
  17376. vertexBuffer[i2 + 0] = vertex.x;
  17377. vertexBuffer[i2 + 1] = vertex.y;
  17378. vertexBuffer[i2 + 2] = vertex.z;
  17379. }
  17380. }
  17381. function generateUVs() {
  17382. var vertex = new Vector3();
  17383. for (var i2 = 0; i2 < vertexBuffer.length; i2 += 3) {
  17384. vertex.x = vertexBuffer[i2 + 0];
  17385. vertex.y = vertexBuffer[i2 + 1];
  17386. vertex.z = vertexBuffer[i2 + 2];
  17387. var u = azimuth(vertex) / 2 / Math.PI + 0.5;
  17388. var v = inclination(vertex) / Math.PI + 0.5;
  17389. uvBuffer.push(u, 1 - v);
  17390. }
  17391. correctUVs();
  17392. correctSeam();
  17393. }
  17394. function correctSeam() {
  17395. for (var i2 = 0; i2 < uvBuffer.length; i2 += 6) {
  17396. var x0 = uvBuffer[i2 + 0];
  17397. var x1 = uvBuffer[i2 + 2];
  17398. var x2 = uvBuffer[i2 + 4];
  17399. var max = Math.max(x0, x1, x2);
  17400. var min = Math.min(x0, x1, x2);
  17401. if (max > 0.9 && min < 0.1) {
  17402. if (x0 < 0.2)
  17403. uvBuffer[i2 + 0] += 1;
  17404. if (x1 < 0.2)
  17405. uvBuffer[i2 + 2] += 1;
  17406. if (x2 < 0.2)
  17407. uvBuffer[i2 + 4] += 1;
  17408. }
  17409. }
  17410. }
  17411. function pushVertex(vertex) {
  17412. vertexBuffer.push(vertex.x, vertex.y, vertex.z);
  17413. }
  17414. function getVertexByIndex(index, vertex) {
  17415. var stride = index * 3;
  17416. vertex.x = vertices[stride + 0];
  17417. vertex.y = vertices[stride + 1];
  17418. vertex.z = vertices[stride + 2];
  17419. }
  17420. function correctUVs() {
  17421. var a = new Vector3();
  17422. var b = new Vector3();
  17423. var c = new Vector3();
  17424. var centroid = new Vector3();
  17425. var uvA = new Vector2();
  17426. var uvB = new Vector2();
  17427. var uvC = new Vector2();
  17428. for (var i2 = 0, j = 0; i2 < vertexBuffer.length; i2 += 9, j += 6) {
  17429. a.set(vertexBuffer[i2 + 0], vertexBuffer[i2 + 1], vertexBuffer[i2 + 2]);
  17430. b.set(vertexBuffer[i2 + 3], vertexBuffer[i2 + 4], vertexBuffer[i2 + 5]);
  17431. c.set(vertexBuffer[i2 + 6], vertexBuffer[i2 + 7], vertexBuffer[i2 + 8]);
  17432. uvA.set(uvBuffer[j + 0], uvBuffer[j + 1]);
  17433. uvB.set(uvBuffer[j + 2], uvBuffer[j + 3]);
  17434. uvC.set(uvBuffer[j + 4], uvBuffer[j + 5]);
  17435. centroid.copy(a).add(b).add(c).divideScalar(3);
  17436. var azi = azimuth(centroid);
  17437. correctUV(uvA, j + 0, a, azi);
  17438. correctUV(uvB, j + 2, b, azi);
  17439. correctUV(uvC, j + 4, c, azi);
  17440. }
  17441. }
  17442. function correctUV(uv, stride, vector, azimuth2) {
  17443. if (azimuth2 < 0 && uv.x === 1) {
  17444. uvBuffer[stride] = uv.x - 1;
  17445. }
  17446. if (vector.x === 0 && vector.z === 0) {
  17447. uvBuffer[stride] = azimuth2 / 2 / Math.PI + 0.5;
  17448. }
  17449. }
  17450. function azimuth(vector) {
  17451. return Math.atan2(vector.z, -vector.x);
  17452. }
  17453. function inclination(vector) {
  17454. return Math.atan2(-vector.y, Math.sqrt(vector.x * vector.x + vector.z * vector.z));
  17455. }
  17456. }
  17457. PolyhedronBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
  17458. PolyhedronBufferGeometry.prototype.constructor = PolyhedronBufferGeometry;
  17459. function TetrahedronGeometry(radius, detail) {
  17460. Geometry.call(this);
  17461. this.type = "TetrahedronGeometry";
  17462. this.parameters = {
  17463. radius,
  17464. detail
  17465. };
  17466. this.fromBufferGeometry(new TetrahedronBufferGeometry(radius, detail));
  17467. this.mergeVertices();
  17468. }
  17469. TetrahedronGeometry.prototype = Object.create(Geometry.prototype);
  17470. TetrahedronGeometry.prototype.constructor = TetrahedronGeometry;
  17471. function TetrahedronBufferGeometry(radius, detail) {
  17472. var vertices = [
  17473. 1,
  17474. 1,
  17475. 1,
  17476. -1,
  17477. -1,
  17478. 1,
  17479. -1,
  17480. 1,
  17481. -1,
  17482. 1,
  17483. -1,
  17484. -1
  17485. ];
  17486. var indices = [
  17487. 2,
  17488. 1,
  17489. 0,
  17490. 0,
  17491. 3,
  17492. 2,
  17493. 1,
  17494. 3,
  17495. 0,
  17496. 2,
  17497. 3,
  17498. 1
  17499. ];
  17500. PolyhedronBufferGeometry.call(this, vertices, indices, radius, detail);
  17501. this.type = "TetrahedronBufferGeometry";
  17502. this.parameters = {
  17503. radius,
  17504. detail
  17505. };
  17506. }
  17507. TetrahedronBufferGeometry.prototype = Object.create(PolyhedronBufferGeometry.prototype);
  17508. TetrahedronBufferGeometry.prototype.constructor = TetrahedronBufferGeometry;
  17509. function OctahedronGeometry(radius, detail) {
  17510. Geometry.call(this);
  17511. this.type = "OctahedronGeometry";
  17512. this.parameters = {
  17513. radius,
  17514. detail
  17515. };
  17516. this.fromBufferGeometry(new OctahedronBufferGeometry(radius, detail));
  17517. this.mergeVertices();
  17518. }
  17519. OctahedronGeometry.prototype = Object.create(Geometry.prototype);
  17520. OctahedronGeometry.prototype.constructor = OctahedronGeometry;
  17521. function OctahedronBufferGeometry(radius, detail) {
  17522. var vertices = [
  17523. 1,
  17524. 0,
  17525. 0,
  17526. -1,
  17527. 0,
  17528. 0,
  17529. 0,
  17530. 1,
  17531. 0,
  17532. 0,
  17533. -1,
  17534. 0,
  17535. 0,
  17536. 0,
  17537. 1,
  17538. 0,
  17539. 0,
  17540. -1
  17541. ];
  17542. var indices = [
  17543. 0,
  17544. 2,
  17545. 4,
  17546. 0,
  17547. 4,
  17548. 3,
  17549. 0,
  17550. 3,
  17551. 5,
  17552. 0,
  17553. 5,
  17554. 2,
  17555. 1,
  17556. 2,
  17557. 5,
  17558. 1,
  17559. 5,
  17560. 3,
  17561. 1,
  17562. 3,
  17563. 4,
  17564. 1,
  17565. 4,
  17566. 2
  17567. ];
  17568. PolyhedronBufferGeometry.call(this, vertices, indices, radius, detail);
  17569. this.type = "OctahedronBufferGeometry";
  17570. this.parameters = {
  17571. radius,
  17572. detail
  17573. };
  17574. }
  17575. OctahedronBufferGeometry.prototype = Object.create(PolyhedronBufferGeometry.prototype);
  17576. OctahedronBufferGeometry.prototype.constructor = OctahedronBufferGeometry;
  17577. function IcosahedronGeometry(radius, detail) {
  17578. Geometry.call(this);
  17579. this.type = "IcosahedronGeometry";
  17580. this.parameters = {
  17581. radius,
  17582. detail
  17583. };
  17584. this.fromBufferGeometry(new IcosahedronBufferGeometry(radius, detail));
  17585. this.mergeVertices();
  17586. }
  17587. IcosahedronGeometry.prototype = Object.create(Geometry.prototype);
  17588. IcosahedronGeometry.prototype.constructor = IcosahedronGeometry;
  17589. function IcosahedronBufferGeometry(radius, detail) {
  17590. var t = (1 + Math.sqrt(5)) / 2;
  17591. var vertices = [
  17592. -1,
  17593. t,
  17594. 0,
  17595. 1,
  17596. t,
  17597. 0,
  17598. -1,
  17599. -t,
  17600. 0,
  17601. 1,
  17602. -t,
  17603. 0,
  17604. 0,
  17605. -1,
  17606. t,
  17607. 0,
  17608. 1,
  17609. t,
  17610. 0,
  17611. -1,
  17612. -t,
  17613. 0,
  17614. 1,
  17615. -t,
  17616. t,
  17617. 0,
  17618. -1,
  17619. t,
  17620. 0,
  17621. 1,
  17622. -t,
  17623. 0,
  17624. -1,
  17625. -t,
  17626. 0,
  17627. 1
  17628. ];
  17629. var indices = [
  17630. 0,
  17631. 11,
  17632. 5,
  17633. 0,
  17634. 5,
  17635. 1,
  17636. 0,
  17637. 1,
  17638. 7,
  17639. 0,
  17640. 7,
  17641. 10,
  17642. 0,
  17643. 10,
  17644. 11,
  17645. 1,
  17646. 5,
  17647. 9,
  17648. 5,
  17649. 11,
  17650. 4,
  17651. 11,
  17652. 10,
  17653. 2,
  17654. 10,
  17655. 7,
  17656. 6,
  17657. 7,
  17658. 1,
  17659. 8,
  17660. 3,
  17661. 9,
  17662. 4,
  17663. 3,
  17664. 4,
  17665. 2,
  17666. 3,
  17667. 2,
  17668. 6,
  17669. 3,
  17670. 6,
  17671. 8,
  17672. 3,
  17673. 8,
  17674. 9,
  17675. 4,
  17676. 9,
  17677. 5,
  17678. 2,
  17679. 4,
  17680. 11,
  17681. 6,
  17682. 2,
  17683. 10,
  17684. 8,
  17685. 6,
  17686. 7,
  17687. 9,
  17688. 8,
  17689. 1
  17690. ];
  17691. PolyhedronBufferGeometry.call(this, vertices, indices, radius, detail);
  17692. this.type = "IcosahedronBufferGeometry";
  17693. this.parameters = {
  17694. radius,
  17695. detail
  17696. };
  17697. }
  17698. IcosahedronBufferGeometry.prototype = Object.create(PolyhedronBufferGeometry.prototype);
  17699. IcosahedronBufferGeometry.prototype.constructor = IcosahedronBufferGeometry;
  17700. function DodecahedronGeometry(radius, detail) {
  17701. Geometry.call(this);
  17702. this.type = "DodecahedronGeometry";
  17703. this.parameters = {
  17704. radius,
  17705. detail
  17706. };
  17707. this.fromBufferGeometry(new DodecahedronBufferGeometry(radius, detail));
  17708. this.mergeVertices();
  17709. }
  17710. DodecahedronGeometry.prototype = Object.create(Geometry.prototype);
  17711. DodecahedronGeometry.prototype.constructor = DodecahedronGeometry;
  17712. function DodecahedronBufferGeometry(radius, detail) {
  17713. var t = (1 + Math.sqrt(5)) / 2;
  17714. var r = 1 / t;
  17715. var vertices = [
  17716. // (±1, ±1, ±1)
  17717. -1,
  17718. -1,
  17719. -1,
  17720. -1,
  17721. -1,
  17722. 1,
  17723. -1,
  17724. 1,
  17725. -1,
  17726. -1,
  17727. 1,
  17728. 1,
  17729. 1,
  17730. -1,
  17731. -1,
  17732. 1,
  17733. -1,
  17734. 1,
  17735. 1,
  17736. 1,
  17737. -1,
  17738. 1,
  17739. 1,
  17740. 1,
  17741. // (0, ±1/φ, ±φ)
  17742. 0,
  17743. -r,
  17744. -t,
  17745. 0,
  17746. -r,
  17747. t,
  17748. 0,
  17749. r,
  17750. -t,
  17751. 0,
  17752. r,
  17753. t,
  17754. // (±1/φ, ±φ, 0)
  17755. -r,
  17756. -t,
  17757. 0,
  17758. -r,
  17759. t,
  17760. 0,
  17761. r,
  17762. -t,
  17763. 0,
  17764. r,
  17765. t,
  17766. 0,
  17767. // (±φ, 0, ±1/φ)
  17768. -t,
  17769. 0,
  17770. -r,
  17771. t,
  17772. 0,
  17773. -r,
  17774. -t,
  17775. 0,
  17776. r,
  17777. t,
  17778. 0,
  17779. r
  17780. ];
  17781. var indices = [
  17782. 3,
  17783. 11,
  17784. 7,
  17785. 3,
  17786. 7,
  17787. 15,
  17788. 3,
  17789. 15,
  17790. 13,
  17791. 7,
  17792. 19,
  17793. 17,
  17794. 7,
  17795. 17,
  17796. 6,
  17797. 7,
  17798. 6,
  17799. 15,
  17800. 17,
  17801. 4,
  17802. 8,
  17803. 17,
  17804. 8,
  17805. 10,
  17806. 17,
  17807. 10,
  17808. 6,
  17809. 8,
  17810. 0,
  17811. 16,
  17812. 8,
  17813. 16,
  17814. 2,
  17815. 8,
  17816. 2,
  17817. 10,
  17818. 0,
  17819. 12,
  17820. 1,
  17821. 0,
  17822. 1,
  17823. 18,
  17824. 0,
  17825. 18,
  17826. 16,
  17827. 6,
  17828. 10,
  17829. 2,
  17830. 6,
  17831. 2,
  17832. 13,
  17833. 6,
  17834. 13,
  17835. 15,
  17836. 2,
  17837. 16,
  17838. 18,
  17839. 2,
  17840. 18,
  17841. 3,
  17842. 2,
  17843. 3,
  17844. 13,
  17845. 18,
  17846. 1,
  17847. 9,
  17848. 18,
  17849. 9,
  17850. 11,
  17851. 18,
  17852. 11,
  17853. 3,
  17854. 4,
  17855. 14,
  17856. 12,
  17857. 4,
  17858. 12,
  17859. 0,
  17860. 4,
  17861. 0,
  17862. 8,
  17863. 11,
  17864. 9,
  17865. 5,
  17866. 11,
  17867. 5,
  17868. 19,
  17869. 11,
  17870. 19,
  17871. 7,
  17872. 19,
  17873. 5,
  17874. 14,
  17875. 19,
  17876. 14,
  17877. 4,
  17878. 19,
  17879. 4,
  17880. 17,
  17881. 1,
  17882. 12,
  17883. 14,
  17884. 1,
  17885. 14,
  17886. 5,
  17887. 1,
  17888. 5,
  17889. 9
  17890. ];
  17891. PolyhedronBufferGeometry.call(this, vertices, indices, radius, detail);
  17892. this.type = "DodecahedronBufferGeometry";
  17893. this.parameters = {
  17894. radius,
  17895. detail
  17896. };
  17897. }
  17898. DodecahedronBufferGeometry.prototype = Object.create(PolyhedronBufferGeometry.prototype);
  17899. DodecahedronBufferGeometry.prototype.constructor = DodecahedronBufferGeometry;
  17900. function TubeGeometry(path, tubularSegments, radius, radialSegments, closed, taper) {
  17901. Geometry.call(this);
  17902. this.type = "TubeGeometry";
  17903. this.parameters = {
  17904. path,
  17905. tubularSegments,
  17906. radius,
  17907. radialSegments,
  17908. closed
  17909. };
  17910. if (taper !== void 0)
  17911. console.warn("THREE.TubeGeometry: taper has been removed.");
  17912. var bufferGeometry = new TubeBufferGeometry(path, tubularSegments, radius, radialSegments, closed);
  17913. this.tangents = bufferGeometry.tangents;
  17914. this.normals = bufferGeometry.normals;
  17915. this.binormals = bufferGeometry.binormals;
  17916. this.fromBufferGeometry(bufferGeometry);
  17917. this.mergeVertices();
  17918. }
  17919. TubeGeometry.prototype = Object.create(Geometry.prototype);
  17920. TubeGeometry.prototype.constructor = TubeGeometry;
  17921. function TubeBufferGeometry(path, tubularSegments, radius, radialSegments, closed) {
  17922. BufferGeometry.call(this);
  17923. this.type = "TubeBufferGeometry";
  17924. this.parameters = {
  17925. path,
  17926. tubularSegments,
  17927. radius,
  17928. radialSegments,
  17929. closed
  17930. };
  17931. tubularSegments = tubularSegments || 64;
  17932. radius = radius || 1;
  17933. radialSegments = radialSegments || 8;
  17934. closed = closed || false;
  17935. var frames = path.computeFrenetFrames(tubularSegments, closed);
  17936. this.tangents = frames.tangents;
  17937. this.normals = frames.normals;
  17938. this.binormals = frames.binormals;
  17939. var vertex = new Vector3();
  17940. var normal = new Vector3();
  17941. var uv = new Vector2();
  17942. var P = new Vector3();
  17943. var i2, j;
  17944. var vertices = [];
  17945. var normals = [];
  17946. var uvs = [];
  17947. var indices = [];
  17948. generateBufferData();
  17949. this.setIndex(indices);
  17950. this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  17951. this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
  17952. this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
  17953. function generateBufferData() {
  17954. for (i2 = 0; i2 < tubularSegments; i2++) {
  17955. generateSegment(i2);
  17956. }
  17957. generateSegment(closed === false ? tubularSegments : 0);
  17958. generateUVs();
  17959. generateIndices();
  17960. }
  17961. function generateSegment(i3) {
  17962. P = path.getPointAt(i3 / tubularSegments, P);
  17963. var N = frames.normals[i3];
  17964. var B = frames.binormals[i3];
  17965. for (j = 0; j <= radialSegments; j++) {
  17966. var v = j / radialSegments * Math.PI * 2;
  17967. var sin = Math.sin(v);
  17968. var cos = -Math.cos(v);
  17969. normal.x = cos * N.x + sin * B.x;
  17970. normal.y = cos * N.y + sin * B.y;
  17971. normal.z = cos * N.z + sin * B.z;
  17972. normal.normalize();
  17973. normals.push(normal.x, normal.y, normal.z);
  17974. vertex.x = P.x + radius * normal.x;
  17975. vertex.y = P.y + radius * normal.y;
  17976. vertex.z = P.z + radius * normal.z;
  17977. vertices.push(vertex.x, vertex.y, vertex.z);
  17978. }
  17979. }
  17980. function generateIndices() {
  17981. for (j = 1; j <= tubularSegments; j++) {
  17982. for (i2 = 1; i2 <= radialSegments; i2++) {
  17983. var a = (radialSegments + 1) * (j - 1) + (i2 - 1);
  17984. var b = (radialSegments + 1) * j + (i2 - 1);
  17985. var c = (radialSegments + 1) * j + i2;
  17986. var d = (radialSegments + 1) * (j - 1) + i2;
  17987. indices.push(a, b, d);
  17988. indices.push(b, c, d);
  17989. }
  17990. }
  17991. }
  17992. function generateUVs() {
  17993. for (i2 = 0; i2 <= tubularSegments; i2++) {
  17994. for (j = 0; j <= radialSegments; j++) {
  17995. uv.x = i2 / tubularSegments;
  17996. uv.y = j / radialSegments;
  17997. uvs.push(uv.x, uv.y);
  17998. }
  17999. }
  18000. }
  18001. }
  18002. TubeBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
  18003. TubeBufferGeometry.prototype.constructor = TubeBufferGeometry;
  18004. TubeBufferGeometry.prototype.toJSON = function() {
  18005. var data = BufferGeometry.prototype.toJSON.call(this);
  18006. data.path = this.parameters.path.toJSON();
  18007. return data;
  18008. };
  18009. function TorusKnotGeometry(radius, tube, tubularSegments, radialSegments, p, q, heightScale) {
  18010. Geometry.call(this);
  18011. this.type = "TorusKnotGeometry";
  18012. this.parameters = {
  18013. radius,
  18014. tube,
  18015. tubularSegments,
  18016. radialSegments,
  18017. p,
  18018. q
  18019. };
  18020. if (heightScale !== void 0)
  18021. console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead.");
  18022. this.fromBufferGeometry(new TorusKnotBufferGeometry(radius, tube, tubularSegments, radialSegments, p, q));
  18023. this.mergeVertices();
  18024. }
  18025. TorusKnotGeometry.prototype = Object.create(Geometry.prototype);
  18026. TorusKnotGeometry.prototype.constructor = TorusKnotGeometry;
  18027. function TorusKnotBufferGeometry(radius, tube, tubularSegments, radialSegments, p, q) {
  18028. BufferGeometry.call(this);
  18029. this.type = "TorusKnotBufferGeometry";
  18030. this.parameters = {
  18031. radius,
  18032. tube,
  18033. tubularSegments,
  18034. radialSegments,
  18035. p,
  18036. q
  18037. };
  18038. radius = radius || 1;
  18039. tube = tube || 0.4;
  18040. tubularSegments = Math.floor(tubularSegments) || 64;
  18041. radialSegments = Math.floor(radialSegments) || 8;
  18042. p = p || 2;
  18043. q = q || 3;
  18044. var indices = [];
  18045. var vertices = [];
  18046. var normals = [];
  18047. var uvs = [];
  18048. var i2, j;
  18049. var vertex = new Vector3();
  18050. var normal = new Vector3();
  18051. var P1 = new Vector3();
  18052. var P2 = new Vector3();
  18053. var B = new Vector3();
  18054. var T = new Vector3();
  18055. var N = new Vector3();
  18056. for (i2 = 0; i2 <= tubularSegments; ++i2) {
  18057. var u = i2 / tubularSegments * p * Math.PI * 2;
  18058. calculatePositionOnCurve(u, p, q, radius, P1);
  18059. calculatePositionOnCurve(u + 0.01, p, q, radius, P2);
  18060. T.subVectors(P2, P1);
  18061. N.addVectors(P2, P1);
  18062. B.crossVectors(T, N);
  18063. N.crossVectors(B, T);
  18064. B.normalize();
  18065. N.normalize();
  18066. for (j = 0; j <= radialSegments; ++j) {
  18067. var v = j / radialSegments * Math.PI * 2;
  18068. var cx = -tube * Math.cos(v);
  18069. var cy = tube * Math.sin(v);
  18070. vertex.x = P1.x + (cx * N.x + cy * B.x);
  18071. vertex.y = P1.y + (cx * N.y + cy * B.y);
  18072. vertex.z = P1.z + (cx * N.z + cy * B.z);
  18073. vertices.push(vertex.x, vertex.y, vertex.z);
  18074. normal.subVectors(vertex, P1).normalize();
  18075. normals.push(normal.x, normal.y, normal.z);
  18076. uvs.push(i2 / tubularSegments);
  18077. uvs.push(j / radialSegments);
  18078. }
  18079. }
  18080. for (j = 1; j <= tubularSegments; j++) {
  18081. for (i2 = 1; i2 <= radialSegments; i2++) {
  18082. var a = (radialSegments + 1) * (j - 1) + (i2 - 1);
  18083. var b = (radialSegments + 1) * j + (i2 - 1);
  18084. var c = (radialSegments + 1) * j + i2;
  18085. var d = (radialSegments + 1) * (j - 1) + i2;
  18086. indices.push(a, b, d);
  18087. indices.push(b, c, d);
  18088. }
  18089. }
  18090. this.setIndex(indices);
  18091. this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  18092. this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
  18093. this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
  18094. function calculatePositionOnCurve(u2, p2, q2, radius2, position) {
  18095. var cu = Math.cos(u2);
  18096. var su = Math.sin(u2);
  18097. var quOverP = q2 / p2 * u2;
  18098. var cs = Math.cos(quOverP);
  18099. position.x = radius2 * (2 + cs) * 0.5 * cu;
  18100. position.y = radius2 * (2 + cs) * su * 0.5;
  18101. position.z = radius2 * Math.sin(quOverP) * 0.5;
  18102. }
  18103. }
  18104. TorusKnotBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
  18105. TorusKnotBufferGeometry.prototype.constructor = TorusKnotBufferGeometry;
  18106. function TorusGeometry(radius, tube, radialSegments, tubularSegments, arc) {
  18107. Geometry.call(this);
  18108. this.type = "TorusGeometry";
  18109. this.parameters = {
  18110. radius,
  18111. tube,
  18112. radialSegments,
  18113. tubularSegments,
  18114. arc
  18115. };
  18116. this.fromBufferGeometry(new TorusBufferGeometry(radius, tube, radialSegments, tubularSegments, arc));
  18117. this.mergeVertices();
  18118. }
  18119. TorusGeometry.prototype = Object.create(Geometry.prototype);
  18120. TorusGeometry.prototype.constructor = TorusGeometry;
  18121. function TorusBufferGeometry(radius, tube, radialSegments, tubularSegments, arc) {
  18122. BufferGeometry.call(this);
  18123. this.type = "TorusBufferGeometry";
  18124. this.parameters = {
  18125. radius,
  18126. tube,
  18127. radialSegments,
  18128. tubularSegments,
  18129. arc
  18130. };
  18131. radius = radius || 1;
  18132. tube = tube || 0.4;
  18133. radialSegments = Math.floor(radialSegments) || 8;
  18134. tubularSegments = Math.floor(tubularSegments) || 6;
  18135. arc = arc || Math.PI * 2;
  18136. var indices = [];
  18137. var vertices = [];
  18138. var normals = [];
  18139. var uvs = [];
  18140. var center = new Vector3();
  18141. var vertex = new Vector3();
  18142. var normal = new Vector3();
  18143. var j, i2;
  18144. for (j = 0; j <= radialSegments; j++) {
  18145. for (i2 = 0; i2 <= tubularSegments; i2++) {
  18146. var u = i2 / tubularSegments * arc;
  18147. var v = j / radialSegments * Math.PI * 2;
  18148. vertex.x = (radius + tube * Math.cos(v)) * Math.cos(u);
  18149. vertex.y = (radius + tube * Math.cos(v)) * Math.sin(u);
  18150. vertex.z = tube * Math.sin(v);
  18151. vertices.push(vertex.x, vertex.y, vertex.z);
  18152. center.x = radius * Math.cos(u);
  18153. center.y = radius * Math.sin(u);
  18154. normal.subVectors(vertex, center).normalize();
  18155. normals.push(normal.x, normal.y, normal.z);
  18156. uvs.push(i2 / tubularSegments);
  18157. uvs.push(j / radialSegments);
  18158. }
  18159. }
  18160. for (j = 1; j <= radialSegments; j++) {
  18161. for (i2 = 1; i2 <= tubularSegments; i2++) {
  18162. var a = (tubularSegments + 1) * j + i2 - 1;
  18163. var b = (tubularSegments + 1) * (j - 1) + i2 - 1;
  18164. var c = (tubularSegments + 1) * (j - 1) + i2;
  18165. var d = (tubularSegments + 1) * j + i2;
  18166. indices.push(a, b, d);
  18167. indices.push(b, c, d);
  18168. }
  18169. }
  18170. this.setIndex(indices);
  18171. this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  18172. this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
  18173. this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
  18174. }
  18175. TorusBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
  18176. TorusBufferGeometry.prototype.constructor = TorusBufferGeometry;
  18177. var Earcut = {
  18178. triangulate: function(data, holeIndices, dim) {
  18179. dim = dim || 2;
  18180. var hasHoles = holeIndices && holeIndices.length, outerLen = hasHoles ? holeIndices[0] * dim : data.length, outerNode = linkedList(data, 0, outerLen, dim, true), triangles = [];
  18181. if (!outerNode || outerNode.next === outerNode.prev)
  18182. return triangles;
  18183. var minX, minY, maxX, maxY, x, y, invSize;
  18184. if (hasHoles)
  18185. outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
  18186. if (data.length > 80 * dim) {
  18187. minX = maxX = data[0];
  18188. minY = maxY = data[1];
  18189. for (var i2 = dim; i2 < outerLen; i2 += dim) {
  18190. x = data[i2];
  18191. y = data[i2 + 1];
  18192. if (x < minX)
  18193. minX = x;
  18194. if (y < minY)
  18195. minY = y;
  18196. if (x > maxX)
  18197. maxX = x;
  18198. if (y > maxY)
  18199. maxY = y;
  18200. }
  18201. invSize = Math.max(maxX - minX, maxY - minY);
  18202. invSize = invSize !== 0 ? 1 / invSize : 0;
  18203. }
  18204. earcutLinked(outerNode, triangles, dim, minX, minY, invSize);
  18205. return triangles;
  18206. }
  18207. };
  18208. function linkedList(data, start, end, dim, clockwise) {
  18209. var i2, last;
  18210. if (clockwise === signedArea(data, start, end, dim) > 0) {
  18211. for (i2 = start; i2 < end; i2 += dim)
  18212. last = insertNode(i2, data[i2], data[i2 + 1], last);
  18213. } else {
  18214. for (i2 = end - dim; i2 >= start; i2 -= dim)
  18215. last = insertNode(i2, data[i2], data[i2 + 1], last);
  18216. }
  18217. if (last && equals(last, last.next)) {
  18218. removeNode(last);
  18219. last = last.next;
  18220. }
  18221. return last;
  18222. }
  18223. function filterPoints(start, end) {
  18224. if (!start)
  18225. return start;
  18226. if (!end)
  18227. end = start;
  18228. var p = start, again;
  18229. do {
  18230. again = false;
  18231. if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
  18232. removeNode(p);
  18233. p = end = p.prev;
  18234. if (p === p.next)
  18235. break;
  18236. again = true;
  18237. } else {
  18238. p = p.next;
  18239. }
  18240. } while (again || p !== end);
  18241. return end;
  18242. }
  18243. function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
  18244. if (!ear)
  18245. return;
  18246. if (!pass && invSize)
  18247. indexCurve(ear, minX, minY, invSize);
  18248. var stop = ear, prev, next;
  18249. while (ear.prev !== ear.next) {
  18250. prev = ear.prev;
  18251. next = ear.next;
  18252. if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
  18253. triangles.push(prev.i / dim);
  18254. triangles.push(ear.i / dim);
  18255. triangles.push(next.i / dim);
  18256. removeNode(ear);
  18257. ear = next.next;
  18258. stop = next.next;
  18259. continue;
  18260. }
  18261. ear = next;
  18262. if (ear === stop) {
  18263. if (!pass) {
  18264. earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
  18265. } else if (pass === 1) {
  18266. ear = cureLocalIntersections(ear, triangles, dim);
  18267. earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
  18268. } else if (pass === 2) {
  18269. splitEarcut(ear, triangles, dim, minX, minY, invSize);
  18270. }
  18271. break;
  18272. }
  18273. }
  18274. }
  18275. function isEar(ear) {
  18276. var a = ear.prev, b = ear, c = ear.next;
  18277. if (area(a, b, c) >= 0)
  18278. return false;
  18279. var p = ear.next.next;
  18280. while (p !== ear.prev) {
  18281. if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0)
  18282. return false;
  18283. p = p.next;
  18284. }
  18285. return true;
  18286. }
  18287. function isEarHashed(ear, minX, minY, invSize) {
  18288. var a = ear.prev, b = ear, c = ear.next;
  18289. if (area(a, b, c) >= 0)
  18290. return false;
  18291. var minTX = a.x < b.x ? a.x < c.x ? a.x : c.x : b.x < c.x ? b.x : c.x, minTY = a.y < b.y ? a.y < c.y ? a.y : c.y : b.y < c.y ? b.y : c.y, maxTX = a.x > b.x ? a.x > c.x ? a.x : c.x : b.x > c.x ? b.x : c.x, maxTY = a.y > b.y ? a.y > c.y ? a.y : c.y : b.y > c.y ? b.y : c.y;
  18292. var minZ = zOrder(minTX, minTY, minX, minY, invSize), maxZ = zOrder(maxTX, maxTY, minX, minY, invSize);
  18293. var p = ear.prevZ, n = ear.nextZ;
  18294. while (p && p.z >= minZ && n && n.z <= maxZ) {
  18295. if (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0)
  18296. return false;
  18297. p = p.prevZ;
  18298. if (n !== ear.prev && n !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && area(n.prev, n, n.next) >= 0)
  18299. return false;
  18300. n = n.nextZ;
  18301. }
  18302. while (p && p.z >= minZ) {
  18303. if (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0)
  18304. return false;
  18305. p = p.prevZ;
  18306. }
  18307. while (n && n.z <= maxZ) {
  18308. if (n !== ear.prev && n !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && area(n.prev, n, n.next) >= 0)
  18309. return false;
  18310. n = n.nextZ;
  18311. }
  18312. return true;
  18313. }
  18314. function cureLocalIntersections(start, triangles, dim) {
  18315. var p = start;
  18316. do {
  18317. var a = p.prev, b = p.next.next;
  18318. if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
  18319. triangles.push(a.i / dim);
  18320. triangles.push(p.i / dim);
  18321. triangles.push(b.i / dim);
  18322. removeNode(p);
  18323. removeNode(p.next);
  18324. p = start = b;
  18325. }
  18326. p = p.next;
  18327. } while (p !== start);
  18328. return p;
  18329. }
  18330. function splitEarcut(start, triangles, dim, minX, minY, invSize) {
  18331. var a = start;
  18332. do {
  18333. var b = a.next.next;
  18334. while (b !== a.prev) {
  18335. if (a.i !== b.i && isValidDiagonal(a, b)) {
  18336. var c = splitPolygon(a, b);
  18337. a = filterPoints(a, a.next);
  18338. c = filterPoints(c, c.next);
  18339. earcutLinked(a, triangles, dim, minX, minY, invSize);
  18340. earcutLinked(c, triangles, dim, minX, minY, invSize);
  18341. return;
  18342. }
  18343. b = b.next;
  18344. }
  18345. a = a.next;
  18346. } while (a !== start);
  18347. }
  18348. function eliminateHoles(data, holeIndices, outerNode, dim) {
  18349. var queue = [], i2, len, start, end, list;
  18350. for (i2 = 0, len = holeIndices.length; i2 < len; i2++) {
  18351. start = holeIndices[i2] * dim;
  18352. end = i2 < len - 1 ? holeIndices[i2 + 1] * dim : data.length;
  18353. list = linkedList(data, start, end, dim, false);
  18354. if (list === list.next)
  18355. list.steiner = true;
  18356. queue.push(getLeftmost(list));
  18357. }
  18358. queue.sort(compareX);
  18359. for (i2 = 0; i2 < queue.length; i2++) {
  18360. eliminateHole(queue[i2], outerNode);
  18361. outerNode = filterPoints(outerNode, outerNode.next);
  18362. }
  18363. return outerNode;
  18364. }
  18365. function compareX(a, b) {
  18366. return a.x - b.x;
  18367. }
  18368. function eliminateHole(hole, outerNode) {
  18369. outerNode = findHoleBridge(hole, outerNode);
  18370. if (outerNode) {
  18371. var b = splitPolygon(outerNode, hole);
  18372. filterPoints(b, b.next);
  18373. }
  18374. }
  18375. function findHoleBridge(hole, outerNode) {
  18376. var p = outerNode, hx = hole.x, hy = hole.y, qx = -Infinity, m;
  18377. do {
  18378. if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
  18379. var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
  18380. if (x <= hx && x > qx) {
  18381. qx = x;
  18382. if (x === hx) {
  18383. if (hy === p.y)
  18384. return p;
  18385. if (hy === p.next.y)
  18386. return p.next;
  18387. }
  18388. m = p.x < p.next.x ? p : p.next;
  18389. }
  18390. }
  18391. p = p.next;
  18392. } while (p !== outerNode);
  18393. if (!m)
  18394. return null;
  18395. if (hx === qx)
  18396. return m.prev;
  18397. var stop = m, mx = m.x, my = m.y, tanMin = Infinity, tan;
  18398. p = m.next;
  18399. while (p !== stop) {
  18400. if (hx >= p.x && p.x >= mx && hx !== p.x && pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
  18401. tan = Math.abs(hy - p.y) / (hx - p.x);
  18402. if ((tan < tanMin || tan === tanMin && p.x > m.x) && locallyInside(p, hole)) {
  18403. m = p;
  18404. tanMin = tan;
  18405. }
  18406. }
  18407. p = p.next;
  18408. }
  18409. return m;
  18410. }
  18411. function indexCurve(start, minX, minY, invSize) {
  18412. var p = start;
  18413. do {
  18414. if (p.z === null)
  18415. p.z = zOrder(p.x, p.y, minX, minY, invSize);
  18416. p.prevZ = p.prev;
  18417. p.nextZ = p.next;
  18418. p = p.next;
  18419. } while (p !== start);
  18420. p.prevZ.nextZ = null;
  18421. p.prevZ = null;
  18422. sortLinked(p);
  18423. }
  18424. function sortLinked(list) {
  18425. var i2, p, q, e, tail, numMerges, pSize, qSize, inSize = 1;
  18426. do {
  18427. p = list;
  18428. list = null;
  18429. tail = null;
  18430. numMerges = 0;
  18431. while (p) {
  18432. numMerges++;
  18433. q = p;
  18434. pSize = 0;
  18435. for (i2 = 0; i2 < inSize; i2++) {
  18436. pSize++;
  18437. q = q.nextZ;
  18438. if (!q)
  18439. break;
  18440. }
  18441. qSize = inSize;
  18442. while (pSize > 0 || qSize > 0 && q) {
  18443. if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
  18444. e = p;
  18445. p = p.nextZ;
  18446. pSize--;
  18447. } else {
  18448. e = q;
  18449. q = q.nextZ;
  18450. qSize--;
  18451. }
  18452. if (tail)
  18453. tail.nextZ = e;
  18454. else
  18455. list = e;
  18456. e.prevZ = tail;
  18457. tail = e;
  18458. }
  18459. p = q;
  18460. }
  18461. tail.nextZ = null;
  18462. inSize *= 2;
  18463. } while (numMerges > 1);
  18464. return list;
  18465. }
  18466. function zOrder(x, y, minX, minY, invSize) {
  18467. x = 32767 * (x - minX) * invSize;
  18468. y = 32767 * (y - minY) * invSize;
  18469. x = (x | x << 8) & 16711935;
  18470. x = (x | x << 4) & 252645135;
  18471. x = (x | x << 2) & 858993459;
  18472. x = (x | x << 1) & 1431655765;
  18473. y = (y | y << 8) & 16711935;
  18474. y = (y | y << 4) & 252645135;
  18475. y = (y | y << 2) & 858993459;
  18476. y = (y | y << 1) & 1431655765;
  18477. return x | y << 1;
  18478. }
  18479. function getLeftmost(start) {
  18480. var p = start, leftmost = start;
  18481. do {
  18482. if (p.x < leftmost.x || p.x === leftmost.x && p.y < leftmost.y)
  18483. leftmost = p;
  18484. p = p.next;
  18485. } while (p !== start);
  18486. return leftmost;
  18487. }
  18488. function pointInTriangle(ax, ay, bx, by, cx, cy, px2, py2) {
  18489. return (cx - px2) * (ay - py2) - (ax - px2) * (cy - py2) >= 0 && (ax - px2) * (by - py2) - (bx - px2) * (ay - py2) >= 0 && (bx - px2) * (cy - py2) - (cx - px2) * (by - py2) >= 0;
  18490. }
  18491. function isValidDiagonal(a, b) {
  18492. return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b);
  18493. }
  18494. function area(p, q, r) {
  18495. return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
  18496. }
  18497. function equals(p1, p2) {
  18498. return p1.x === p2.x && p1.y === p2.y;
  18499. }
  18500. function intersects(p1, q1, p2, q2) {
  18501. if (equals(p1, p2) && equals(q1, q2) || equals(p1, q2) && equals(p2, q1))
  18502. return true;
  18503. return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0;
  18504. }
  18505. function intersectsPolygon(a, b) {
  18506. var p = a;
  18507. do {
  18508. if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && intersects(p, p.next, a, b))
  18509. return true;
  18510. p = p.next;
  18511. } while (p !== a);
  18512. return false;
  18513. }
  18514. function locallyInside(a, b) {
  18515. return area(a.prev, a, a.next) < 0 ? area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
  18516. }
  18517. function middleInside(a, b) {
  18518. var p = a, inside = false, px2 = (a.x + b.x) / 2, py2 = (a.y + b.y) / 2;
  18519. do {
  18520. if (p.y > py2 !== p.next.y > py2 && p.next.y !== p.y && px2 < (p.next.x - p.x) * (py2 - p.y) / (p.next.y - p.y) + p.x)
  18521. inside = !inside;
  18522. p = p.next;
  18523. } while (p !== a);
  18524. return inside;
  18525. }
  18526. function splitPolygon(a, b) {
  18527. var a2 = new Node(a.i, a.x, a.y), b2 = new Node(b.i, b.x, b.y), an = a.next, bp = b.prev;
  18528. a.next = b;
  18529. b.prev = a;
  18530. a2.next = an;
  18531. an.prev = a2;
  18532. b2.next = a2;
  18533. a2.prev = b2;
  18534. bp.next = b2;
  18535. b2.prev = bp;
  18536. return b2;
  18537. }
  18538. function insertNode(i2, x, y, last) {
  18539. var p = new Node(i2, x, y);
  18540. if (!last) {
  18541. p.prev = p;
  18542. p.next = p;
  18543. } else {
  18544. p.next = last.next;
  18545. p.prev = last;
  18546. last.next.prev = p;
  18547. last.next = p;
  18548. }
  18549. return p;
  18550. }
  18551. function removeNode(p) {
  18552. p.next.prev = p.prev;
  18553. p.prev.next = p.next;
  18554. if (p.prevZ)
  18555. p.prevZ.nextZ = p.nextZ;
  18556. if (p.nextZ)
  18557. p.nextZ.prevZ = p.prevZ;
  18558. }
  18559. function Node(i2, x, y) {
  18560. this.i = i2;
  18561. this.x = x;
  18562. this.y = y;
  18563. this.prev = null;
  18564. this.next = null;
  18565. this.z = null;
  18566. this.prevZ = null;
  18567. this.nextZ = null;
  18568. this.steiner = false;
  18569. }
  18570. function signedArea(data, start, end, dim) {
  18571. var sum = 0;
  18572. for (var i2 = start, j = end - dim; i2 < end; i2 += dim) {
  18573. sum += (data[j] - data[i2]) * (data[i2 + 1] + data[j + 1]);
  18574. j = i2;
  18575. }
  18576. return sum;
  18577. }
  18578. var ShapeUtils = {
  18579. // calculate area of the contour polygon
  18580. area: function(contour) {
  18581. var n = contour.length;
  18582. var a = 0;
  18583. for (var p = n - 1, q = 0; q < n; p = q++) {
  18584. a += contour[p].x * contour[q].y - contour[q].x * contour[p].y;
  18585. }
  18586. return a * 0.5;
  18587. },
  18588. isClockWise: function(pts) {
  18589. return ShapeUtils.area(pts) < 0;
  18590. },
  18591. triangulateShape: function(contour, holes) {
  18592. var vertices = [];
  18593. var holeIndices = [];
  18594. var faces = [];
  18595. removeDupEndPts(contour);
  18596. addContour(vertices, contour);
  18597. var holeIndex = contour.length;
  18598. holes.forEach(removeDupEndPts);
  18599. for (var i2 = 0; i2 < holes.length; i2++) {
  18600. holeIndices.push(holeIndex);
  18601. holeIndex += holes[i2].length;
  18602. addContour(vertices, holes[i2]);
  18603. }
  18604. var triangles = Earcut.triangulate(vertices, holeIndices);
  18605. for (var i2 = 0; i2 < triangles.length; i2 += 3) {
  18606. faces.push(triangles.slice(i2, i2 + 3));
  18607. }
  18608. return faces;
  18609. }
  18610. };
  18611. function removeDupEndPts(points) {
  18612. var l = points.length;
  18613. if (l > 2 && points[l - 1].equals(points[0])) {
  18614. points.pop();
  18615. }
  18616. }
  18617. function addContour(vertices, contour) {
  18618. for (var i2 = 0; i2 < contour.length; i2++) {
  18619. vertices.push(contour[i2].x);
  18620. vertices.push(contour[i2].y);
  18621. }
  18622. }
  18623. function ExtrudeGeometry(shapes, options) {
  18624. Geometry.call(this);
  18625. this.type = "ExtrudeGeometry";
  18626. this.parameters = {
  18627. shapes,
  18628. options
  18629. };
  18630. this.fromBufferGeometry(new ExtrudeBufferGeometry(shapes, options));
  18631. this.mergeVertices();
  18632. }
  18633. ExtrudeGeometry.prototype = Object.create(Geometry.prototype);
  18634. ExtrudeGeometry.prototype.constructor = ExtrudeGeometry;
  18635. ExtrudeGeometry.prototype.toJSON = function() {
  18636. var data = Geometry.prototype.toJSON.call(this);
  18637. var shapes = this.parameters.shapes;
  18638. var options = this.parameters.options;
  18639. return toJSON(shapes, options, data);
  18640. };
  18641. function ExtrudeBufferGeometry(shapes, options) {
  18642. BufferGeometry.call(this);
  18643. this.type = "ExtrudeBufferGeometry";
  18644. this.parameters = {
  18645. shapes,
  18646. options
  18647. };
  18648. shapes = Array.isArray(shapes) ? shapes : [shapes];
  18649. var scope = this;
  18650. var verticesArray = [];
  18651. var uvArray = [];
  18652. for (var i2 = 0, l = shapes.length; i2 < l; i2++) {
  18653. var shape = shapes[i2];
  18654. addShape(shape);
  18655. }
  18656. this.setAttribute("position", new Float32BufferAttribute(verticesArray, 3));
  18657. this.setAttribute("uv", new Float32BufferAttribute(uvArray, 2));
  18658. this.computeVertexNormals();
  18659. function addShape(shape2) {
  18660. var placeholder = [];
  18661. var curveSegments = options.curveSegments !== void 0 ? options.curveSegments : 12;
  18662. var steps = options.steps !== void 0 ? options.steps : 1;
  18663. var depth = options.depth !== void 0 ? options.depth : 100;
  18664. var bevelEnabled = options.bevelEnabled !== void 0 ? options.bevelEnabled : true;
  18665. var bevelThickness = options.bevelThickness !== void 0 ? options.bevelThickness : 6;
  18666. var bevelSize = options.bevelSize !== void 0 ? options.bevelSize : bevelThickness - 2;
  18667. var bevelOffset = options.bevelOffset !== void 0 ? options.bevelOffset : 0;
  18668. var bevelSegments = options.bevelSegments !== void 0 ? options.bevelSegments : 3;
  18669. var extrudePath = options.extrudePath;
  18670. var uvgen = options.UVGenerator !== void 0 ? options.UVGenerator : WorldUVGenerator;
  18671. if (options.amount !== void 0) {
  18672. console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth.");
  18673. depth = options.amount;
  18674. }
  18675. var extrudePts, extrudeByPath = false;
  18676. var splineTube, binormal, normal, position2;
  18677. if (extrudePath) {
  18678. extrudePts = extrudePath.getSpacedPoints(steps);
  18679. extrudeByPath = true;
  18680. bevelEnabled = false;
  18681. splineTube = extrudePath.computeFrenetFrames(steps, false);
  18682. binormal = new Vector3();
  18683. normal = new Vector3();
  18684. position2 = new Vector3();
  18685. }
  18686. if (!bevelEnabled) {
  18687. bevelSegments = 0;
  18688. bevelThickness = 0;
  18689. bevelSize = 0;
  18690. bevelOffset = 0;
  18691. }
  18692. var ahole, h, hl;
  18693. var shapePoints = shape2.extractPoints(curveSegments);
  18694. var vertices = shapePoints.shape;
  18695. var holes = shapePoints.holes;
  18696. var reverse = !ShapeUtils.isClockWise(vertices);
  18697. if (reverse) {
  18698. vertices = vertices.reverse();
  18699. for (h = 0, hl = holes.length; h < hl; h++) {
  18700. ahole = holes[h];
  18701. if (ShapeUtils.isClockWise(ahole)) {
  18702. holes[h] = ahole.reverse();
  18703. }
  18704. }
  18705. }
  18706. var faces = ShapeUtils.triangulateShape(vertices, holes);
  18707. var contour = vertices;
  18708. for (h = 0, hl = holes.length; h < hl; h++) {
  18709. ahole = holes[h];
  18710. vertices = vertices.concat(ahole);
  18711. }
  18712. function scalePt2(pt, vec, size) {
  18713. if (!vec)
  18714. console.error("THREE.ExtrudeGeometry: vec does not exist");
  18715. return vec.clone().multiplyScalar(size).add(pt);
  18716. }
  18717. var b, bs, t, z, vert, vlen = vertices.length, face, flen = faces.length;
  18718. function getBevelVec(inPt, inPrev, inNext) {
  18719. var v_trans_x, v_trans_y, shrink_by;
  18720. var v_prev_x = inPt.x - inPrev.x, v_prev_y = inPt.y - inPrev.y;
  18721. var v_next_x = inNext.x - inPt.x, v_next_y = inNext.y - inPt.y;
  18722. var v_prev_lensq = v_prev_x * v_prev_x + v_prev_y * v_prev_y;
  18723. var collinear0 = v_prev_x * v_next_y - v_prev_y * v_next_x;
  18724. if (Math.abs(collinear0) > Number.EPSILON) {
  18725. var v_prev_len = Math.sqrt(v_prev_lensq);
  18726. var v_next_len = Math.sqrt(v_next_x * v_next_x + v_next_y * v_next_y);
  18727. var ptPrevShift_x = inPrev.x - v_prev_y / v_prev_len;
  18728. var ptPrevShift_y = inPrev.y + v_prev_x / v_prev_len;
  18729. var ptNextShift_x = inNext.x - v_next_y / v_next_len;
  18730. var ptNextShift_y = inNext.y + v_next_x / v_next_len;
  18731. var sf = ((ptNextShift_x - ptPrevShift_x) * v_next_y - (ptNextShift_y - ptPrevShift_y) * v_next_x) / (v_prev_x * v_next_y - v_prev_y * v_next_x);
  18732. v_trans_x = ptPrevShift_x + v_prev_x * sf - inPt.x;
  18733. v_trans_y = ptPrevShift_y + v_prev_y * sf - inPt.y;
  18734. var v_trans_lensq = v_trans_x * v_trans_x + v_trans_y * v_trans_y;
  18735. if (v_trans_lensq <= 2) {
  18736. return new Vector2(v_trans_x, v_trans_y);
  18737. } else {
  18738. shrink_by = Math.sqrt(v_trans_lensq / 2);
  18739. }
  18740. } else {
  18741. var direction_eq = false;
  18742. if (v_prev_x > Number.EPSILON) {
  18743. if (v_next_x > Number.EPSILON) {
  18744. direction_eq = true;
  18745. }
  18746. } else {
  18747. if (v_prev_x < -Number.EPSILON) {
  18748. if (v_next_x < -Number.EPSILON) {
  18749. direction_eq = true;
  18750. }
  18751. } else {
  18752. if (Math.sign(v_prev_y) === Math.sign(v_next_y)) {
  18753. direction_eq = true;
  18754. }
  18755. }
  18756. }
  18757. if (direction_eq) {
  18758. v_trans_x = -v_prev_y;
  18759. v_trans_y = v_prev_x;
  18760. shrink_by = Math.sqrt(v_prev_lensq);
  18761. } else {
  18762. v_trans_x = v_prev_x;
  18763. v_trans_y = v_prev_y;
  18764. shrink_by = Math.sqrt(v_prev_lensq / 2);
  18765. }
  18766. }
  18767. return new Vector2(v_trans_x / shrink_by, v_trans_y / shrink_by);
  18768. }
  18769. var contourMovements = [];
  18770. for (var i3 = 0, il = contour.length, j = il - 1, k = i3 + 1; i3 < il; i3++, j++, k++) {
  18771. if (j === il)
  18772. j = 0;
  18773. if (k === il)
  18774. k = 0;
  18775. contourMovements[i3] = getBevelVec(contour[i3], contour[j], contour[k]);
  18776. }
  18777. var holesMovements = [], oneHoleMovements, verticesMovements = contourMovements.concat();
  18778. for (h = 0, hl = holes.length; h < hl; h++) {
  18779. ahole = holes[h];
  18780. oneHoleMovements = [];
  18781. for (i3 = 0, il = ahole.length, j = il - 1, k = i3 + 1; i3 < il; i3++, j++, k++) {
  18782. if (j === il)
  18783. j = 0;
  18784. if (k === il)
  18785. k = 0;
  18786. oneHoleMovements[i3] = getBevelVec(ahole[i3], ahole[j], ahole[k]);
  18787. }
  18788. holesMovements.push(oneHoleMovements);
  18789. verticesMovements = verticesMovements.concat(oneHoleMovements);
  18790. }
  18791. for (b = 0; b < bevelSegments; b++) {
  18792. t = b / bevelSegments;
  18793. z = bevelThickness * Math.cos(t * Math.PI / 2);
  18794. bs = bevelSize * Math.sin(t * Math.PI / 2) + bevelOffset;
  18795. for (i3 = 0, il = contour.length; i3 < il; i3++) {
  18796. vert = scalePt2(contour[i3], contourMovements[i3], bs);
  18797. v(vert.x, vert.y, -z);
  18798. }
  18799. for (h = 0, hl = holes.length; h < hl; h++) {
  18800. ahole = holes[h];
  18801. oneHoleMovements = holesMovements[h];
  18802. for (i3 = 0, il = ahole.length; i3 < il; i3++) {
  18803. vert = scalePt2(ahole[i3], oneHoleMovements[i3], bs);
  18804. v(vert.x, vert.y, -z);
  18805. }
  18806. }
  18807. }
  18808. bs = bevelSize + bevelOffset;
  18809. for (i3 = 0; i3 < vlen; i3++) {
  18810. vert = bevelEnabled ? scalePt2(vertices[i3], verticesMovements[i3], bs) : vertices[i3];
  18811. if (!extrudeByPath) {
  18812. v(vert.x, vert.y, 0);
  18813. } else {
  18814. normal.copy(splineTube.normals[0]).multiplyScalar(vert.x);
  18815. binormal.copy(splineTube.binormals[0]).multiplyScalar(vert.y);
  18816. position2.copy(extrudePts[0]).add(normal).add(binormal);
  18817. v(position2.x, position2.y, position2.z);
  18818. }
  18819. }
  18820. var s;
  18821. for (s = 1; s <= steps; s++) {
  18822. for (i3 = 0; i3 < vlen; i3++) {
  18823. vert = bevelEnabled ? scalePt2(vertices[i3], verticesMovements[i3], bs) : vertices[i3];
  18824. if (!extrudeByPath) {
  18825. v(vert.x, vert.y, depth / steps * s);
  18826. } else {
  18827. normal.copy(splineTube.normals[s]).multiplyScalar(vert.x);
  18828. binormal.copy(splineTube.binormals[s]).multiplyScalar(vert.y);
  18829. position2.copy(extrudePts[s]).add(normal).add(binormal);
  18830. v(position2.x, position2.y, position2.z);
  18831. }
  18832. }
  18833. }
  18834. for (b = bevelSegments - 1; b >= 0; b--) {
  18835. t = b / bevelSegments;
  18836. z = bevelThickness * Math.cos(t * Math.PI / 2);
  18837. bs = bevelSize * Math.sin(t * Math.PI / 2) + bevelOffset;
  18838. for (i3 = 0, il = contour.length; i3 < il; i3++) {
  18839. vert = scalePt2(contour[i3], contourMovements[i3], bs);
  18840. v(vert.x, vert.y, depth + z);
  18841. }
  18842. for (h = 0, hl = holes.length; h < hl; h++) {
  18843. ahole = holes[h];
  18844. oneHoleMovements = holesMovements[h];
  18845. for (i3 = 0, il = ahole.length; i3 < il; i3++) {
  18846. vert = scalePt2(ahole[i3], oneHoleMovements[i3], bs);
  18847. if (!extrudeByPath) {
  18848. v(vert.x, vert.y, depth + z);
  18849. } else {
  18850. v(vert.x, vert.y + extrudePts[steps - 1].y, extrudePts[steps - 1].x + z);
  18851. }
  18852. }
  18853. }
  18854. }
  18855. buildLidFaces();
  18856. buildSideFaces();
  18857. function buildLidFaces() {
  18858. var start = verticesArray.length / 3;
  18859. if (bevelEnabled) {
  18860. var layer = 0;
  18861. var offset = vlen * layer;
  18862. for (i3 = 0; i3 < flen; i3++) {
  18863. face = faces[i3];
  18864. f3(face[2] + offset, face[1] + offset, face[0] + offset);
  18865. }
  18866. layer = steps + bevelSegments * 2;
  18867. offset = vlen * layer;
  18868. for (i3 = 0; i3 < flen; i3++) {
  18869. face = faces[i3];
  18870. f3(face[0] + offset, face[1] + offset, face[2] + offset);
  18871. }
  18872. } else {
  18873. for (i3 = 0; i3 < flen; i3++) {
  18874. face = faces[i3];
  18875. f3(face[2], face[1], face[0]);
  18876. }
  18877. for (i3 = 0; i3 < flen; i3++) {
  18878. face = faces[i3];
  18879. f3(face[0] + vlen * steps, face[1] + vlen * steps, face[2] + vlen * steps);
  18880. }
  18881. }
  18882. scope.addGroup(start, verticesArray.length / 3 - start, 0);
  18883. }
  18884. function buildSideFaces() {
  18885. var start = verticesArray.length / 3;
  18886. var layeroffset = 0;
  18887. sidewalls(contour, layeroffset);
  18888. layeroffset += contour.length;
  18889. for (h = 0, hl = holes.length; h < hl; h++) {
  18890. ahole = holes[h];
  18891. sidewalls(ahole, layeroffset);
  18892. layeroffset += ahole.length;
  18893. }
  18894. scope.addGroup(start, verticesArray.length / 3 - start, 1);
  18895. }
  18896. function sidewalls(contour2, layeroffset) {
  18897. var j2, k2;
  18898. i3 = contour2.length;
  18899. while (--i3 >= 0) {
  18900. j2 = i3;
  18901. k2 = i3 - 1;
  18902. if (k2 < 0)
  18903. k2 = contour2.length - 1;
  18904. var s2 = 0, sl = steps + bevelSegments * 2;
  18905. for (s2 = 0; s2 < sl; s2++) {
  18906. var slen1 = vlen * s2;
  18907. var slen2 = vlen * (s2 + 1);
  18908. var a = layeroffset + j2 + slen1, b2 = layeroffset + k2 + slen1, c = layeroffset + k2 + slen2, d = layeroffset + j2 + slen2;
  18909. f4(a, b2, c, d);
  18910. }
  18911. }
  18912. }
  18913. function v(x, y, z2) {
  18914. placeholder.push(x);
  18915. placeholder.push(y);
  18916. placeholder.push(z2);
  18917. }
  18918. function f3(a, b2, c) {
  18919. addVertex(a);
  18920. addVertex(b2);
  18921. addVertex(c);
  18922. var nextIndex = verticesArray.length / 3;
  18923. var uvs = uvgen.generateTopUV(scope, verticesArray, nextIndex - 3, nextIndex - 2, nextIndex - 1);
  18924. addUV(uvs[0]);
  18925. addUV(uvs[1]);
  18926. addUV(uvs[2]);
  18927. }
  18928. function f4(a, b2, c, d) {
  18929. addVertex(a);
  18930. addVertex(b2);
  18931. addVertex(d);
  18932. addVertex(b2);
  18933. addVertex(c);
  18934. addVertex(d);
  18935. var nextIndex = verticesArray.length / 3;
  18936. var uvs = uvgen.generateSideWallUV(scope, verticesArray, nextIndex - 6, nextIndex - 3, nextIndex - 2, nextIndex - 1);
  18937. addUV(uvs[0]);
  18938. addUV(uvs[1]);
  18939. addUV(uvs[3]);
  18940. addUV(uvs[1]);
  18941. addUV(uvs[2]);
  18942. addUV(uvs[3]);
  18943. }
  18944. function addVertex(index) {
  18945. verticesArray.push(placeholder[index * 3 + 0]);
  18946. verticesArray.push(placeholder[index * 3 + 1]);
  18947. verticesArray.push(placeholder[index * 3 + 2]);
  18948. }
  18949. function addUV(vector2) {
  18950. uvArray.push(vector2.x);
  18951. uvArray.push(vector2.y);
  18952. }
  18953. }
  18954. }
  18955. ExtrudeBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
  18956. ExtrudeBufferGeometry.prototype.constructor = ExtrudeBufferGeometry;
  18957. ExtrudeBufferGeometry.prototype.toJSON = function() {
  18958. var data = BufferGeometry.prototype.toJSON.call(this);
  18959. var shapes = this.parameters.shapes;
  18960. var options = this.parameters.options;
  18961. return toJSON(shapes, options, data);
  18962. };
  18963. var WorldUVGenerator = {
  18964. generateTopUV: function(geometry, vertices, indexA, indexB, indexC) {
  18965. var a_x = vertices[indexA * 3];
  18966. var a_y = vertices[indexA * 3 + 1];
  18967. var b_x = vertices[indexB * 3];
  18968. var b_y = vertices[indexB * 3 + 1];
  18969. var c_x = vertices[indexC * 3];
  18970. var c_y = vertices[indexC * 3 + 1];
  18971. return [
  18972. new Vector2(a_x, a_y),
  18973. new Vector2(b_x, b_y),
  18974. new Vector2(c_x, c_y)
  18975. ];
  18976. },
  18977. generateSideWallUV: function(geometry, vertices, indexA, indexB, indexC, indexD) {
  18978. var a_x = vertices[indexA * 3];
  18979. var a_y = vertices[indexA * 3 + 1];
  18980. var a_z = vertices[indexA * 3 + 2];
  18981. var b_x = vertices[indexB * 3];
  18982. var b_y = vertices[indexB * 3 + 1];
  18983. var b_z = vertices[indexB * 3 + 2];
  18984. var c_x = vertices[indexC * 3];
  18985. var c_y = vertices[indexC * 3 + 1];
  18986. var c_z = vertices[indexC * 3 + 2];
  18987. var d_x = vertices[indexD * 3];
  18988. var d_y = vertices[indexD * 3 + 1];
  18989. var d_z = vertices[indexD * 3 + 2];
  18990. if (Math.abs(a_y - b_y) < 0.01) {
  18991. return [
  18992. new Vector2(a_x, 1 - a_z),
  18993. new Vector2(b_x, 1 - b_z),
  18994. new Vector2(c_x, 1 - c_z),
  18995. new Vector2(d_x, 1 - d_z)
  18996. ];
  18997. } else {
  18998. return [
  18999. new Vector2(a_y, 1 - a_z),
  19000. new Vector2(b_y, 1 - b_z),
  19001. new Vector2(c_y, 1 - c_z),
  19002. new Vector2(d_y, 1 - d_z)
  19003. ];
  19004. }
  19005. }
  19006. };
  19007. function toJSON(shapes, options, data) {
  19008. data.shapes = [];
  19009. if (Array.isArray(shapes)) {
  19010. for (var i2 = 0, l = shapes.length; i2 < l; i2++) {
  19011. var shape = shapes[i2];
  19012. data.shapes.push(shape.uuid);
  19013. }
  19014. } else {
  19015. data.shapes.push(shapes.uuid);
  19016. }
  19017. if (options.extrudePath !== void 0)
  19018. data.options.extrudePath = options.extrudePath.toJSON();
  19019. return data;
  19020. }
  19021. function TextGeometry(text, parameters) {
  19022. Geometry.call(this);
  19023. this.type = "TextGeometry";
  19024. this.parameters = {
  19025. text,
  19026. parameters
  19027. };
  19028. this.fromBufferGeometry(new TextBufferGeometry(text, parameters));
  19029. this.mergeVertices();
  19030. }
  19031. TextGeometry.prototype = Object.create(Geometry.prototype);
  19032. TextGeometry.prototype.constructor = TextGeometry;
  19033. function TextBufferGeometry(text, parameters) {
  19034. parameters = parameters || {};
  19035. var font = parameters.font;
  19036. if (!(font && font.isFont)) {
  19037. console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font.");
  19038. return new Geometry();
  19039. }
  19040. var shapes = font.generateShapes(text, parameters.size);
  19041. parameters.depth = parameters.height !== void 0 ? parameters.height : 50;
  19042. if (parameters.bevelThickness === void 0)
  19043. parameters.bevelThickness = 10;
  19044. if (parameters.bevelSize === void 0)
  19045. parameters.bevelSize = 8;
  19046. if (parameters.bevelEnabled === void 0)
  19047. parameters.bevelEnabled = false;
  19048. ExtrudeBufferGeometry.call(this, shapes, parameters);
  19049. this.type = "TextBufferGeometry";
  19050. }
  19051. TextBufferGeometry.prototype = Object.create(ExtrudeBufferGeometry.prototype);
  19052. TextBufferGeometry.prototype.constructor = TextBufferGeometry;
  19053. function SphereGeometry(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength) {
  19054. Geometry.call(this);
  19055. this.type = "SphereGeometry";
  19056. this.parameters = {
  19057. radius,
  19058. widthSegments,
  19059. heightSegments,
  19060. phiStart,
  19061. phiLength,
  19062. thetaStart,
  19063. thetaLength
  19064. };
  19065. this.fromBufferGeometry(new SphereBufferGeometry(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength));
  19066. this.mergeVertices();
  19067. }
  19068. SphereGeometry.prototype = Object.create(Geometry.prototype);
  19069. SphereGeometry.prototype.constructor = SphereGeometry;
  19070. function SphereBufferGeometry(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength) {
  19071. BufferGeometry.call(this);
  19072. this.type = "SphereBufferGeometry";
  19073. this.parameters = {
  19074. radius,
  19075. widthSegments,
  19076. heightSegments,
  19077. phiStart,
  19078. phiLength,
  19079. thetaStart,
  19080. thetaLength
  19081. };
  19082. radius = radius || 1;
  19083. widthSegments = Math.max(3, Math.floor(widthSegments) || 8);
  19084. heightSegments = Math.max(2, Math.floor(heightSegments) || 6);
  19085. phiStart = phiStart !== void 0 ? phiStart : 0;
  19086. phiLength = phiLength !== void 0 ? phiLength : Math.PI * 2;
  19087. thetaStart = thetaStart !== void 0 ? thetaStart : 0;
  19088. thetaLength = thetaLength !== void 0 ? thetaLength : Math.PI;
  19089. var thetaEnd = Math.min(thetaStart + thetaLength, Math.PI);
  19090. var ix, iy;
  19091. var index = 0;
  19092. var grid = [];
  19093. var vertex = new Vector3();
  19094. var normal = new Vector3();
  19095. var indices = [];
  19096. var vertices = [];
  19097. var normals = [];
  19098. var uvs = [];
  19099. for (iy = 0; iy <= heightSegments; iy++) {
  19100. var verticesRow = [];
  19101. var v = iy / heightSegments;
  19102. var uOffset = 0;
  19103. if (iy == 0 && thetaStart == 0) {
  19104. uOffset = 0.5 / widthSegments;
  19105. } else if (iy == heightSegments && thetaEnd == Math.PI) {
  19106. uOffset = -0.5 / widthSegments;
  19107. }
  19108. for (ix = 0; ix <= widthSegments; ix++) {
  19109. var u = ix / widthSegments;
  19110. vertex.x = -radius * Math.cos(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength);
  19111. vertex.y = radius * Math.cos(thetaStart + v * thetaLength);
  19112. vertex.z = radius * Math.sin(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength);
  19113. vertices.push(vertex.x, vertex.y, vertex.z);
  19114. normal.copy(vertex).normalize();
  19115. normals.push(normal.x, normal.y, normal.z);
  19116. uvs.push(u + uOffset, 1 - v);
  19117. verticesRow.push(index++);
  19118. }
  19119. grid.push(verticesRow);
  19120. }
  19121. for (iy = 0; iy < heightSegments; iy++) {
  19122. for (ix = 0; ix < widthSegments; ix++) {
  19123. var a = grid[iy][ix + 1];
  19124. var b = grid[iy][ix];
  19125. var c = grid[iy + 1][ix];
  19126. var d = grid[iy + 1][ix + 1];
  19127. if (iy !== 0 || thetaStart > 0)
  19128. indices.push(a, b, d);
  19129. if (iy !== heightSegments - 1 || thetaEnd < Math.PI)
  19130. indices.push(b, c, d);
  19131. }
  19132. }
  19133. this.setIndex(indices);
  19134. this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  19135. this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
  19136. this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
  19137. }
  19138. SphereBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
  19139. SphereBufferGeometry.prototype.constructor = SphereBufferGeometry;
  19140. function RingGeometry(innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength) {
  19141. Geometry.call(this);
  19142. this.type = "RingGeometry";
  19143. this.parameters = {
  19144. innerRadius,
  19145. outerRadius,
  19146. thetaSegments,
  19147. phiSegments,
  19148. thetaStart,
  19149. thetaLength
  19150. };
  19151. this.fromBufferGeometry(new RingBufferGeometry(innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength));
  19152. this.mergeVertices();
  19153. }
  19154. RingGeometry.prototype = Object.create(Geometry.prototype);
  19155. RingGeometry.prototype.constructor = RingGeometry;
  19156. function RingBufferGeometry(innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength) {
  19157. BufferGeometry.call(this);
  19158. this.type = "RingBufferGeometry";
  19159. this.parameters = {
  19160. innerRadius,
  19161. outerRadius,
  19162. thetaSegments,
  19163. phiSegments,
  19164. thetaStart,
  19165. thetaLength
  19166. };
  19167. innerRadius = innerRadius || 0.5;
  19168. outerRadius = outerRadius || 1;
  19169. thetaStart = thetaStart !== void 0 ? thetaStart : 0;
  19170. thetaLength = thetaLength !== void 0 ? thetaLength : Math.PI * 2;
  19171. thetaSegments = thetaSegments !== void 0 ? Math.max(3, thetaSegments) : 8;
  19172. phiSegments = phiSegments !== void 0 ? Math.max(1, phiSegments) : 1;
  19173. var indices = [];
  19174. var vertices = [];
  19175. var normals = [];
  19176. var uvs = [];
  19177. var segment;
  19178. var radius = innerRadius;
  19179. var radiusStep = (outerRadius - innerRadius) / phiSegments;
  19180. var vertex = new Vector3();
  19181. var uv = new Vector2();
  19182. var j, i2;
  19183. for (j = 0; j <= phiSegments; j++) {
  19184. for (i2 = 0; i2 <= thetaSegments; i2++) {
  19185. segment = thetaStart + i2 / thetaSegments * thetaLength;
  19186. vertex.x = radius * Math.cos(segment);
  19187. vertex.y = radius * Math.sin(segment);
  19188. vertices.push(vertex.x, vertex.y, vertex.z);
  19189. normals.push(0, 0, 1);
  19190. uv.x = (vertex.x / outerRadius + 1) / 2;
  19191. uv.y = (vertex.y / outerRadius + 1) / 2;
  19192. uvs.push(uv.x, uv.y);
  19193. }
  19194. radius += radiusStep;
  19195. }
  19196. for (j = 0; j < phiSegments; j++) {
  19197. var thetaSegmentLevel = j * (thetaSegments + 1);
  19198. for (i2 = 0; i2 < thetaSegments; i2++) {
  19199. segment = i2 + thetaSegmentLevel;
  19200. var a = segment;
  19201. var b = segment + thetaSegments + 1;
  19202. var c = segment + thetaSegments + 2;
  19203. var d = segment + 1;
  19204. indices.push(a, b, d);
  19205. indices.push(b, c, d);
  19206. }
  19207. }
  19208. this.setIndex(indices);
  19209. this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  19210. this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
  19211. this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
  19212. }
  19213. RingBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
  19214. RingBufferGeometry.prototype.constructor = RingBufferGeometry;
  19215. function LatheGeometry(points, segments, phiStart, phiLength) {
  19216. Geometry.call(this);
  19217. this.type = "LatheGeometry";
  19218. this.parameters = {
  19219. points,
  19220. segments,
  19221. phiStart,
  19222. phiLength
  19223. };
  19224. this.fromBufferGeometry(new LatheBufferGeometry(points, segments, phiStart, phiLength));
  19225. this.mergeVertices();
  19226. }
  19227. LatheGeometry.prototype = Object.create(Geometry.prototype);
  19228. LatheGeometry.prototype.constructor = LatheGeometry;
  19229. function LatheBufferGeometry(points, segments, phiStart, phiLength) {
  19230. BufferGeometry.call(this);
  19231. this.type = "LatheBufferGeometry";
  19232. this.parameters = {
  19233. points,
  19234. segments,
  19235. phiStart,
  19236. phiLength
  19237. };
  19238. segments = Math.floor(segments) || 12;
  19239. phiStart = phiStart || 0;
  19240. phiLength = phiLength || Math.PI * 2;
  19241. phiLength = MathUtils.clamp(phiLength, 0, Math.PI * 2);
  19242. var indices = [];
  19243. var vertices = [];
  19244. var uvs = [];
  19245. var base;
  19246. var inverseSegments = 1 / segments;
  19247. var vertex = new Vector3();
  19248. var uv = new Vector2();
  19249. var i2, j;
  19250. for (i2 = 0; i2 <= segments; i2++) {
  19251. var phi = phiStart + i2 * inverseSegments * phiLength;
  19252. var sin = Math.sin(phi);
  19253. var cos = Math.cos(phi);
  19254. for (j = 0; j <= points.length - 1; j++) {
  19255. vertex.x = points[j].x * sin;
  19256. vertex.y = points[j].y;
  19257. vertex.z = points[j].x * cos;
  19258. vertices.push(vertex.x, vertex.y, vertex.z);
  19259. uv.x = i2 / segments;
  19260. uv.y = j / (points.length - 1);
  19261. uvs.push(uv.x, uv.y);
  19262. }
  19263. }
  19264. for (i2 = 0; i2 < segments; i2++) {
  19265. for (j = 0; j < points.length - 1; j++) {
  19266. base = j + i2 * points.length;
  19267. var a = base;
  19268. var b = base + points.length;
  19269. var c = base + points.length + 1;
  19270. var d = base + 1;
  19271. indices.push(a, b, d);
  19272. indices.push(b, c, d);
  19273. }
  19274. }
  19275. this.setIndex(indices);
  19276. this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  19277. this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
  19278. this.computeVertexNormals();
  19279. if (phiLength === Math.PI * 2) {
  19280. var normals = this.attributes.normal.array;
  19281. var n1 = new Vector3();
  19282. var n2 = new Vector3();
  19283. var n = new Vector3();
  19284. base = segments * points.length * 3;
  19285. for (i2 = 0, j = 0; i2 < points.length; i2++, j += 3) {
  19286. n1.x = normals[j + 0];
  19287. n1.y = normals[j + 1];
  19288. n1.z = normals[j + 2];
  19289. n2.x = normals[base + j + 0];
  19290. n2.y = normals[base + j + 1];
  19291. n2.z = normals[base + j + 2];
  19292. n.addVectors(n1, n2).normalize();
  19293. normals[j + 0] = normals[base + j + 0] = n.x;
  19294. normals[j + 1] = normals[base + j + 1] = n.y;
  19295. normals[j + 2] = normals[base + j + 2] = n.z;
  19296. }
  19297. }
  19298. }
  19299. LatheBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
  19300. LatheBufferGeometry.prototype.constructor = LatheBufferGeometry;
  19301. function ShapeGeometry(shapes, curveSegments) {
  19302. Geometry.call(this);
  19303. this.type = "ShapeGeometry";
  19304. if (typeof curveSegments === "object") {
  19305. console.warn("THREE.ShapeGeometry: Options parameter has been removed.");
  19306. curveSegments = curveSegments.curveSegments;
  19307. }
  19308. this.parameters = {
  19309. shapes,
  19310. curveSegments
  19311. };
  19312. this.fromBufferGeometry(new ShapeBufferGeometry(shapes, curveSegments));
  19313. this.mergeVertices();
  19314. }
  19315. ShapeGeometry.prototype = Object.create(Geometry.prototype);
  19316. ShapeGeometry.prototype.constructor = ShapeGeometry;
  19317. ShapeGeometry.prototype.toJSON = function() {
  19318. var data = Geometry.prototype.toJSON.call(this);
  19319. var shapes = this.parameters.shapes;
  19320. return toJSON$1(shapes, data);
  19321. };
  19322. function ShapeBufferGeometry(shapes, curveSegments) {
  19323. BufferGeometry.call(this);
  19324. this.type = "ShapeBufferGeometry";
  19325. this.parameters = {
  19326. shapes,
  19327. curveSegments
  19328. };
  19329. curveSegments = curveSegments || 12;
  19330. var indices = [];
  19331. var vertices = [];
  19332. var normals = [];
  19333. var uvs = [];
  19334. var groupStart = 0;
  19335. var groupCount = 0;
  19336. if (Array.isArray(shapes) === false) {
  19337. addShape(shapes);
  19338. } else {
  19339. for (var i2 = 0; i2 < shapes.length; i2++) {
  19340. addShape(shapes[i2]);
  19341. this.addGroup(groupStart, groupCount, i2);
  19342. groupStart += groupCount;
  19343. groupCount = 0;
  19344. }
  19345. }
  19346. this.setIndex(indices);
  19347. this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  19348. this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
  19349. this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
  19350. function addShape(shape) {
  19351. var i3, l, shapeHole;
  19352. var indexOffset = vertices.length / 3;
  19353. var points = shape.extractPoints(curveSegments);
  19354. var shapeVertices = points.shape;
  19355. var shapeHoles = points.holes;
  19356. if (ShapeUtils.isClockWise(shapeVertices) === false) {
  19357. shapeVertices = shapeVertices.reverse();
  19358. }
  19359. for (i3 = 0, l = shapeHoles.length; i3 < l; i3++) {
  19360. shapeHole = shapeHoles[i3];
  19361. if (ShapeUtils.isClockWise(shapeHole) === true) {
  19362. shapeHoles[i3] = shapeHole.reverse();
  19363. }
  19364. }
  19365. var faces = ShapeUtils.triangulateShape(shapeVertices, shapeHoles);
  19366. for (i3 = 0, l = shapeHoles.length; i3 < l; i3++) {
  19367. shapeHole = shapeHoles[i3];
  19368. shapeVertices = shapeVertices.concat(shapeHole);
  19369. }
  19370. for (i3 = 0, l = shapeVertices.length; i3 < l; i3++) {
  19371. var vertex = shapeVertices[i3];
  19372. vertices.push(vertex.x, vertex.y, 0);
  19373. normals.push(0, 0, 1);
  19374. uvs.push(vertex.x, vertex.y);
  19375. }
  19376. for (i3 = 0, l = faces.length; i3 < l; i3++) {
  19377. var face = faces[i3];
  19378. var a = face[0] + indexOffset;
  19379. var b = face[1] + indexOffset;
  19380. var c = face[2] + indexOffset;
  19381. indices.push(a, b, c);
  19382. groupCount += 3;
  19383. }
  19384. }
  19385. }
  19386. ShapeBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
  19387. ShapeBufferGeometry.prototype.constructor = ShapeBufferGeometry;
  19388. ShapeBufferGeometry.prototype.toJSON = function() {
  19389. var data = BufferGeometry.prototype.toJSON.call(this);
  19390. var shapes = this.parameters.shapes;
  19391. return toJSON$1(shapes, data);
  19392. };
  19393. function toJSON$1(shapes, data) {
  19394. data.shapes = [];
  19395. if (Array.isArray(shapes)) {
  19396. for (var i2 = 0, l = shapes.length; i2 < l; i2++) {
  19397. var shape = shapes[i2];
  19398. data.shapes.push(shape.uuid);
  19399. }
  19400. } else {
  19401. data.shapes.push(shapes.uuid);
  19402. }
  19403. return data;
  19404. }
  19405. function EdgesGeometry(geometry, thresholdAngle) {
  19406. BufferGeometry.call(this);
  19407. this.type = "EdgesGeometry";
  19408. this.parameters = {
  19409. thresholdAngle
  19410. };
  19411. thresholdAngle = thresholdAngle !== void 0 ? thresholdAngle : 1;
  19412. var vertices = [];
  19413. var thresholdDot = Math.cos(MathUtils.DEG2RAD * thresholdAngle);
  19414. var edge = [0, 0], edges = {}, edge1, edge2;
  19415. var key, keys = ["a", "b", "c"];
  19416. var geometry2;
  19417. if (geometry.isBufferGeometry) {
  19418. geometry2 = new Geometry();
  19419. geometry2.fromBufferGeometry(geometry);
  19420. } else {
  19421. geometry2 = geometry.clone();
  19422. }
  19423. geometry2.mergeVertices();
  19424. geometry2.computeFaceNormals();
  19425. var sourceVertices = geometry2.vertices;
  19426. var faces = geometry2.faces;
  19427. for (var i2 = 0, l = faces.length; i2 < l; i2++) {
  19428. var face = faces[i2];
  19429. for (var j = 0; j < 3; j++) {
  19430. edge1 = face[keys[j]];
  19431. edge2 = face[keys[(j + 1) % 3]];
  19432. edge[0] = Math.min(edge1, edge2);
  19433. edge[1] = Math.max(edge1, edge2);
  19434. key = edge[0] + "," + edge[1];
  19435. if (edges[key] === void 0) {
  19436. edges[key] = { index1: edge[0], index2: edge[1], face1: i2, face2: void 0 };
  19437. } else {
  19438. edges[key].face2 = i2;
  19439. }
  19440. }
  19441. }
  19442. for (key in edges) {
  19443. var e = edges[key];
  19444. if (e.face2 === void 0 || faces[e.face1].normal.dot(faces[e.face2].normal) <= thresholdDot) {
  19445. var vertex = sourceVertices[e.index1];
  19446. vertices.push(vertex.x, vertex.y, vertex.z);
  19447. vertex = sourceVertices[e.index2];
  19448. vertices.push(vertex.x, vertex.y, vertex.z);
  19449. }
  19450. }
  19451. this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  19452. }
  19453. EdgesGeometry.prototype = Object.create(BufferGeometry.prototype);
  19454. EdgesGeometry.prototype.constructor = EdgesGeometry;
  19455. function CylinderGeometry(radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength) {
  19456. Geometry.call(this);
  19457. this.type = "CylinderGeometry";
  19458. this.parameters = {
  19459. radiusTop,
  19460. radiusBottom,
  19461. height,
  19462. radialSegments,
  19463. heightSegments,
  19464. openEnded,
  19465. thetaStart,
  19466. thetaLength
  19467. };
  19468. this.fromBufferGeometry(new CylinderBufferGeometry(radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength));
  19469. this.mergeVertices();
  19470. }
  19471. CylinderGeometry.prototype = Object.create(Geometry.prototype);
  19472. CylinderGeometry.prototype.constructor = CylinderGeometry;
  19473. function CylinderBufferGeometry(radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength) {
  19474. BufferGeometry.call(this);
  19475. this.type = "CylinderBufferGeometry";
  19476. this.parameters = {
  19477. radiusTop,
  19478. radiusBottom,
  19479. height,
  19480. radialSegments,
  19481. heightSegments,
  19482. openEnded,
  19483. thetaStart,
  19484. thetaLength
  19485. };
  19486. var scope = this;
  19487. radiusTop = radiusTop !== void 0 ? radiusTop : 1;
  19488. radiusBottom = radiusBottom !== void 0 ? radiusBottom : 1;
  19489. height = height || 1;
  19490. radialSegments = Math.floor(radialSegments) || 8;
  19491. heightSegments = Math.floor(heightSegments) || 1;
  19492. openEnded = openEnded !== void 0 ? openEnded : false;
  19493. thetaStart = thetaStart !== void 0 ? thetaStart : 0;
  19494. thetaLength = thetaLength !== void 0 ? thetaLength : Math.PI * 2;
  19495. var indices = [];
  19496. var vertices = [];
  19497. var normals = [];
  19498. var uvs = [];
  19499. var index = 0;
  19500. var indexArray = [];
  19501. var halfHeight = height / 2;
  19502. var groupStart = 0;
  19503. generateTorso();
  19504. if (openEnded === false) {
  19505. if (radiusTop > 0)
  19506. generateCap(true);
  19507. if (radiusBottom > 0)
  19508. generateCap(false);
  19509. }
  19510. this.setIndex(indices);
  19511. this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  19512. this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
  19513. this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
  19514. function generateTorso() {
  19515. var x, y;
  19516. var normal = new Vector3();
  19517. var vertex = new Vector3();
  19518. var groupCount = 0;
  19519. var slope = (radiusBottom - radiusTop) / height;
  19520. for (y = 0; y <= heightSegments; y++) {
  19521. var indexRow = [];
  19522. var v = y / heightSegments;
  19523. var radius = v * (radiusBottom - radiusTop) + radiusTop;
  19524. for (x = 0; x <= radialSegments; x++) {
  19525. var u = x / radialSegments;
  19526. var theta = u * thetaLength + thetaStart;
  19527. var sinTheta = Math.sin(theta);
  19528. var cosTheta = Math.cos(theta);
  19529. vertex.x = radius * sinTheta;
  19530. vertex.y = -v * height + halfHeight;
  19531. vertex.z = radius * cosTheta;
  19532. vertices.push(vertex.x, vertex.y, vertex.z);
  19533. normal.set(sinTheta, slope, cosTheta).normalize();
  19534. normals.push(normal.x, normal.y, normal.z);
  19535. uvs.push(u, 1 - v);
  19536. indexRow.push(index++);
  19537. }
  19538. indexArray.push(indexRow);
  19539. }
  19540. for (x = 0; x < radialSegments; x++) {
  19541. for (y = 0; y < heightSegments; y++) {
  19542. var a = indexArray[y][x];
  19543. var b = indexArray[y + 1][x];
  19544. var c = indexArray[y + 1][x + 1];
  19545. var d = indexArray[y][x + 1];
  19546. indices.push(a, b, d);
  19547. indices.push(b, c, d);
  19548. groupCount += 6;
  19549. }
  19550. }
  19551. scope.addGroup(groupStart, groupCount, 0);
  19552. groupStart += groupCount;
  19553. }
  19554. function generateCap(top2) {
  19555. var x, centerIndexStart, centerIndexEnd;
  19556. var uv = new Vector2();
  19557. var vertex = new Vector3();
  19558. var groupCount = 0;
  19559. var radius = top2 === true ? radiusTop : radiusBottom;
  19560. var sign = top2 === true ? 1 : -1;
  19561. centerIndexStart = index;
  19562. for (x = 1; x <= radialSegments; x++) {
  19563. vertices.push(0, halfHeight * sign, 0);
  19564. normals.push(0, sign, 0);
  19565. uvs.push(0.5, 0.5);
  19566. index++;
  19567. }
  19568. centerIndexEnd = index;
  19569. for (x = 0; x <= radialSegments; x++) {
  19570. var u = x / radialSegments;
  19571. var theta = u * thetaLength + thetaStart;
  19572. var cosTheta = Math.cos(theta);
  19573. var sinTheta = Math.sin(theta);
  19574. vertex.x = radius * sinTheta;
  19575. vertex.y = halfHeight * sign;
  19576. vertex.z = radius * cosTheta;
  19577. vertices.push(vertex.x, vertex.y, vertex.z);
  19578. normals.push(0, sign, 0);
  19579. uv.x = cosTheta * 0.5 + 0.5;
  19580. uv.y = sinTheta * 0.5 * sign + 0.5;
  19581. uvs.push(uv.x, uv.y);
  19582. index++;
  19583. }
  19584. for (x = 0; x < radialSegments; x++) {
  19585. var c = centerIndexStart + x;
  19586. var i2 = centerIndexEnd + x;
  19587. if (top2 === true) {
  19588. indices.push(i2, i2 + 1, c);
  19589. } else {
  19590. indices.push(i2 + 1, i2, c);
  19591. }
  19592. groupCount += 3;
  19593. }
  19594. scope.addGroup(groupStart, groupCount, top2 === true ? 1 : 2);
  19595. groupStart += groupCount;
  19596. }
  19597. }
  19598. CylinderBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
  19599. CylinderBufferGeometry.prototype.constructor = CylinderBufferGeometry;
  19600. function ConeGeometry(radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength) {
  19601. CylinderGeometry.call(this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength);
  19602. this.type = "ConeGeometry";
  19603. this.parameters = {
  19604. radius,
  19605. height,
  19606. radialSegments,
  19607. heightSegments,
  19608. openEnded,
  19609. thetaStart,
  19610. thetaLength
  19611. };
  19612. }
  19613. ConeGeometry.prototype = Object.create(CylinderGeometry.prototype);
  19614. ConeGeometry.prototype.constructor = ConeGeometry;
  19615. function ConeBufferGeometry(radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength) {
  19616. CylinderBufferGeometry.call(this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength);
  19617. this.type = "ConeBufferGeometry";
  19618. this.parameters = {
  19619. radius,
  19620. height,
  19621. radialSegments,
  19622. heightSegments,
  19623. openEnded,
  19624. thetaStart,
  19625. thetaLength
  19626. };
  19627. }
  19628. ConeBufferGeometry.prototype = Object.create(CylinderBufferGeometry.prototype);
  19629. ConeBufferGeometry.prototype.constructor = ConeBufferGeometry;
  19630. function CircleGeometry(radius, segments, thetaStart, thetaLength) {
  19631. Geometry.call(this);
  19632. this.type = "CircleGeometry";
  19633. this.parameters = {
  19634. radius,
  19635. segments,
  19636. thetaStart,
  19637. thetaLength
  19638. };
  19639. this.fromBufferGeometry(new CircleBufferGeometry(radius, segments, thetaStart, thetaLength));
  19640. this.mergeVertices();
  19641. }
  19642. CircleGeometry.prototype = Object.create(Geometry.prototype);
  19643. CircleGeometry.prototype.constructor = CircleGeometry;
  19644. function CircleBufferGeometry(radius, segments, thetaStart, thetaLength) {
  19645. BufferGeometry.call(this);
  19646. this.type = "CircleBufferGeometry";
  19647. this.parameters = {
  19648. radius,
  19649. segments,
  19650. thetaStart,
  19651. thetaLength
  19652. };
  19653. radius = radius || 1;
  19654. segments = segments !== void 0 ? Math.max(3, segments) : 8;
  19655. thetaStart = thetaStart !== void 0 ? thetaStart : 0;
  19656. thetaLength = thetaLength !== void 0 ? thetaLength : Math.PI * 2;
  19657. var indices = [];
  19658. var vertices = [];
  19659. var normals = [];
  19660. var uvs = [];
  19661. var i2, s;
  19662. var vertex = new Vector3();
  19663. var uv = new Vector2();
  19664. vertices.push(0, 0, 0);
  19665. normals.push(0, 0, 1);
  19666. uvs.push(0.5, 0.5);
  19667. for (s = 0, i2 = 3; s <= segments; s++, i2 += 3) {
  19668. var segment = thetaStart + s / segments * thetaLength;
  19669. vertex.x = radius * Math.cos(segment);
  19670. vertex.y = radius * Math.sin(segment);
  19671. vertices.push(vertex.x, vertex.y, vertex.z);
  19672. normals.push(0, 0, 1);
  19673. uv.x = (vertices[i2] / radius + 1) / 2;
  19674. uv.y = (vertices[i2 + 1] / radius + 1) / 2;
  19675. uvs.push(uv.x, uv.y);
  19676. }
  19677. for (i2 = 1; i2 <= segments; i2++) {
  19678. indices.push(i2, i2 + 1, 0);
  19679. }
  19680. this.setIndex(indices);
  19681. this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  19682. this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
  19683. this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
  19684. }
  19685. CircleBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
  19686. CircleBufferGeometry.prototype.constructor = CircleBufferGeometry;
  19687. var Geometries = /* @__PURE__ */ Object.freeze({
  19688. __proto__: null,
  19689. WireframeGeometry,
  19690. ParametricGeometry,
  19691. ParametricBufferGeometry,
  19692. TetrahedronGeometry,
  19693. TetrahedronBufferGeometry,
  19694. OctahedronGeometry,
  19695. OctahedronBufferGeometry,
  19696. IcosahedronGeometry,
  19697. IcosahedronBufferGeometry,
  19698. DodecahedronGeometry,
  19699. DodecahedronBufferGeometry,
  19700. PolyhedronGeometry,
  19701. PolyhedronBufferGeometry,
  19702. TubeGeometry,
  19703. TubeBufferGeometry,
  19704. TorusKnotGeometry,
  19705. TorusKnotBufferGeometry,
  19706. TorusGeometry,
  19707. TorusBufferGeometry,
  19708. TextGeometry,
  19709. TextBufferGeometry,
  19710. SphereGeometry,
  19711. SphereBufferGeometry,
  19712. RingGeometry,
  19713. RingBufferGeometry,
  19714. PlaneGeometry,
  19715. PlaneBufferGeometry,
  19716. LatheGeometry,
  19717. LatheBufferGeometry,
  19718. ShapeGeometry,
  19719. ShapeBufferGeometry,
  19720. ExtrudeGeometry,
  19721. ExtrudeBufferGeometry,
  19722. EdgesGeometry,
  19723. ConeGeometry,
  19724. ConeBufferGeometry,
  19725. CylinderGeometry,
  19726. CylinderBufferGeometry,
  19727. CircleGeometry,
  19728. CircleBufferGeometry,
  19729. BoxGeometry,
  19730. BoxBufferGeometry
  19731. });
  19732. function ShadowMaterial(parameters) {
  19733. Material.call(this);
  19734. this.type = "ShadowMaterial";
  19735. this.color = new Color(0);
  19736. this.transparent = true;
  19737. this.setValues(parameters);
  19738. }
  19739. ShadowMaterial.prototype = Object.create(Material.prototype);
  19740. ShadowMaterial.prototype.constructor = ShadowMaterial;
  19741. ShadowMaterial.prototype.isShadowMaterial = true;
  19742. ShadowMaterial.prototype.copy = function(source) {
  19743. Material.prototype.copy.call(this, source);
  19744. this.color.copy(source.color);
  19745. return this;
  19746. };
  19747. function RawShaderMaterial(parameters) {
  19748. ShaderMaterial.call(this, parameters);
  19749. this.type = "RawShaderMaterial";
  19750. }
  19751. RawShaderMaterial.prototype = Object.create(ShaderMaterial.prototype);
  19752. RawShaderMaterial.prototype.constructor = RawShaderMaterial;
  19753. RawShaderMaterial.prototype.isRawShaderMaterial = true;
  19754. function MeshStandardMaterial(parameters) {
  19755. Material.call(this);
  19756. this.defines = { "STANDARD": "" };
  19757. this.type = "MeshStandardMaterial";
  19758. this.color = new Color(16777215);
  19759. this.roughness = 1;
  19760. this.metalness = 0;
  19761. this.map = null;
  19762. this.lightMap = null;
  19763. this.lightMapIntensity = 1;
  19764. this.aoMap = null;
  19765. this.aoMapIntensity = 1;
  19766. this.emissive = new Color(0);
  19767. this.emissiveIntensity = 1;
  19768. this.emissiveMap = null;
  19769. this.bumpMap = null;
  19770. this.bumpScale = 1;
  19771. this.normalMap = null;
  19772. this.normalMapType = TangentSpaceNormalMap;
  19773. this.normalScale = new Vector2(1, 1);
  19774. this.displacementMap = null;
  19775. this.displacementScale = 1;
  19776. this.displacementBias = 0;
  19777. this.roughnessMap = null;
  19778. this.metalnessMap = null;
  19779. this.alphaMap = null;
  19780. this.envMap = null;
  19781. this.envMapIntensity = 1;
  19782. this.refractionRatio = 0.98;
  19783. this.wireframe = false;
  19784. this.wireframeLinewidth = 1;
  19785. this.wireframeLinecap = "round";
  19786. this.wireframeLinejoin = "round";
  19787. this.skinning = false;
  19788. this.morphTargets = false;
  19789. this.morphNormals = false;
  19790. this.setValues(parameters);
  19791. }
  19792. MeshStandardMaterial.prototype = Object.create(Material.prototype);
  19793. MeshStandardMaterial.prototype.constructor = MeshStandardMaterial;
  19794. MeshStandardMaterial.prototype.isMeshStandardMaterial = true;
  19795. MeshStandardMaterial.prototype.copy = function(source) {
  19796. Material.prototype.copy.call(this, source);
  19797. this.defines = { "STANDARD": "" };
  19798. this.color.copy(source.color);
  19799. this.roughness = source.roughness;
  19800. this.metalness = source.metalness;
  19801. this.map = source.map;
  19802. this.lightMap = source.lightMap;
  19803. this.lightMapIntensity = source.lightMapIntensity;
  19804. this.aoMap = source.aoMap;
  19805. this.aoMapIntensity = source.aoMapIntensity;
  19806. this.emissive.copy(source.emissive);
  19807. this.emissiveMap = source.emissiveMap;
  19808. this.emissiveIntensity = source.emissiveIntensity;
  19809. this.bumpMap = source.bumpMap;
  19810. this.bumpScale = source.bumpScale;
  19811. this.normalMap = source.normalMap;
  19812. this.normalMapType = source.normalMapType;
  19813. this.normalScale.copy(source.normalScale);
  19814. this.displacementMap = source.displacementMap;
  19815. this.displacementScale = source.displacementScale;
  19816. this.displacementBias = source.displacementBias;
  19817. this.roughnessMap = source.roughnessMap;
  19818. this.metalnessMap = source.metalnessMap;
  19819. this.alphaMap = source.alphaMap;
  19820. this.envMap = source.envMap;
  19821. this.envMapIntensity = source.envMapIntensity;
  19822. this.refractionRatio = source.refractionRatio;
  19823. this.wireframe = source.wireframe;
  19824. this.wireframeLinewidth = source.wireframeLinewidth;
  19825. this.wireframeLinecap = source.wireframeLinecap;
  19826. this.wireframeLinejoin = source.wireframeLinejoin;
  19827. this.skinning = source.skinning;
  19828. this.morphTargets = source.morphTargets;
  19829. this.morphNormals = source.morphNormals;
  19830. return this;
  19831. };
  19832. function MeshPhysicalMaterial(parameters) {
  19833. MeshStandardMaterial.call(this);
  19834. this.defines = {
  19835. "STANDARD": "",
  19836. "PHYSICAL": ""
  19837. };
  19838. this.type = "MeshPhysicalMaterial";
  19839. this.reflectivity = 0.5;
  19840. this.clearcoat = 0;
  19841. this.clearcoatRoughness = 0;
  19842. this.sheen = null;
  19843. this.clearcoatNormalScale = new Vector2(1, 1);
  19844. this.clearcoatNormalMap = null;
  19845. this.transparency = 0;
  19846. this.setValues(parameters);
  19847. }
  19848. MeshPhysicalMaterial.prototype = Object.create(MeshStandardMaterial.prototype);
  19849. MeshPhysicalMaterial.prototype.constructor = MeshPhysicalMaterial;
  19850. MeshPhysicalMaterial.prototype.isMeshPhysicalMaterial = true;
  19851. MeshPhysicalMaterial.prototype.copy = function(source) {
  19852. MeshStandardMaterial.prototype.copy.call(this, source);
  19853. this.defines = {
  19854. "STANDARD": "",
  19855. "PHYSICAL": ""
  19856. };
  19857. this.reflectivity = source.reflectivity;
  19858. this.clearcoat = source.clearcoat;
  19859. this.clearcoatRoughness = source.clearcoatRoughness;
  19860. if (source.sheen)
  19861. this.sheen = (this.sheen || new Color()).copy(source.sheen);
  19862. else
  19863. this.sheen = null;
  19864. this.clearcoatNormalMap = source.clearcoatNormalMap;
  19865. this.clearcoatNormalScale.copy(source.clearcoatNormalScale);
  19866. this.transparency = source.transparency;
  19867. return this;
  19868. };
  19869. function MeshPhongMaterial(parameters) {
  19870. Material.call(this);
  19871. this.type = "MeshPhongMaterial";
  19872. this.color = new Color(16777215);
  19873. this.specular = new Color(1118481);
  19874. this.shininess = 30;
  19875. this.map = null;
  19876. this.lightMap = null;
  19877. this.lightMapIntensity = 1;
  19878. this.aoMap = null;
  19879. this.aoMapIntensity = 1;
  19880. this.emissive = new Color(0);
  19881. this.emissiveIntensity = 1;
  19882. this.emissiveMap = null;
  19883. this.bumpMap = null;
  19884. this.bumpScale = 1;
  19885. this.normalMap = null;
  19886. this.normalMapType = TangentSpaceNormalMap;
  19887. this.normalScale = new Vector2(1, 1);
  19888. this.displacementMap = null;
  19889. this.displacementScale = 1;
  19890. this.displacementBias = 0;
  19891. this.specularMap = null;
  19892. this.alphaMap = null;
  19893. this.envMap = null;
  19894. this.combine = MultiplyOperation;
  19895. this.reflectivity = 1;
  19896. this.refractionRatio = 0.98;
  19897. this.wireframe = false;
  19898. this.wireframeLinewidth = 1;
  19899. this.wireframeLinecap = "round";
  19900. this.wireframeLinejoin = "round";
  19901. this.skinning = false;
  19902. this.morphTargets = false;
  19903. this.morphNormals = false;
  19904. this.setValues(parameters);
  19905. }
  19906. MeshPhongMaterial.prototype = Object.create(Material.prototype);
  19907. MeshPhongMaterial.prototype.constructor = MeshPhongMaterial;
  19908. MeshPhongMaterial.prototype.isMeshPhongMaterial = true;
  19909. MeshPhongMaterial.prototype.copy = function(source) {
  19910. Material.prototype.copy.call(this, source);
  19911. this.color.copy(source.color);
  19912. this.specular.copy(source.specular);
  19913. this.shininess = source.shininess;
  19914. this.map = source.map;
  19915. this.lightMap = source.lightMap;
  19916. this.lightMapIntensity = source.lightMapIntensity;
  19917. this.aoMap = source.aoMap;
  19918. this.aoMapIntensity = source.aoMapIntensity;
  19919. this.emissive.copy(source.emissive);
  19920. this.emissiveMap = source.emissiveMap;
  19921. this.emissiveIntensity = source.emissiveIntensity;
  19922. this.bumpMap = source.bumpMap;
  19923. this.bumpScale = source.bumpScale;
  19924. this.normalMap = source.normalMap;
  19925. this.normalMapType = source.normalMapType;
  19926. this.normalScale.copy(source.normalScale);
  19927. this.displacementMap = source.displacementMap;
  19928. this.displacementScale = source.displacementScale;
  19929. this.displacementBias = source.displacementBias;
  19930. this.specularMap = source.specularMap;
  19931. this.alphaMap = source.alphaMap;
  19932. this.envMap = source.envMap;
  19933. this.combine = source.combine;
  19934. this.reflectivity = source.reflectivity;
  19935. this.refractionRatio = source.refractionRatio;
  19936. this.wireframe = source.wireframe;
  19937. this.wireframeLinewidth = source.wireframeLinewidth;
  19938. this.wireframeLinecap = source.wireframeLinecap;
  19939. this.wireframeLinejoin = source.wireframeLinejoin;
  19940. this.skinning = source.skinning;
  19941. this.morphTargets = source.morphTargets;
  19942. this.morphNormals = source.morphNormals;
  19943. return this;
  19944. };
  19945. function MeshToonMaterial(parameters) {
  19946. Material.call(this);
  19947. this.defines = { "TOON": "" };
  19948. this.type = "MeshToonMaterial";
  19949. this.color = new Color(16777215);
  19950. this.specular = new Color(1118481);
  19951. this.shininess = 30;
  19952. this.map = null;
  19953. this.gradientMap = null;
  19954. this.lightMap = null;
  19955. this.lightMapIntensity = 1;
  19956. this.aoMap = null;
  19957. this.aoMapIntensity = 1;
  19958. this.emissive = new Color(0);
  19959. this.emissiveIntensity = 1;
  19960. this.emissiveMap = null;
  19961. this.bumpMap = null;
  19962. this.bumpScale = 1;
  19963. this.normalMap = null;
  19964. this.normalMapType = TangentSpaceNormalMap;
  19965. this.normalScale = new Vector2(1, 1);
  19966. this.displacementMap = null;
  19967. this.displacementScale = 1;
  19968. this.displacementBias = 0;
  19969. this.specularMap = null;
  19970. this.alphaMap = null;
  19971. this.wireframe = false;
  19972. this.wireframeLinewidth = 1;
  19973. this.wireframeLinecap = "round";
  19974. this.wireframeLinejoin = "round";
  19975. this.skinning = false;
  19976. this.morphTargets = false;
  19977. this.morphNormals = false;
  19978. this.setValues(parameters);
  19979. }
  19980. MeshToonMaterial.prototype = Object.create(Material.prototype);
  19981. MeshToonMaterial.prototype.constructor = MeshToonMaterial;
  19982. MeshToonMaterial.prototype.isMeshToonMaterial = true;
  19983. MeshToonMaterial.prototype.copy = function(source) {
  19984. Material.prototype.copy.call(this, source);
  19985. this.color.copy(source.color);
  19986. this.specular.copy(source.specular);
  19987. this.shininess = source.shininess;
  19988. this.map = source.map;
  19989. this.gradientMap = source.gradientMap;
  19990. this.lightMap = source.lightMap;
  19991. this.lightMapIntensity = source.lightMapIntensity;
  19992. this.aoMap = source.aoMap;
  19993. this.aoMapIntensity = source.aoMapIntensity;
  19994. this.emissive.copy(source.emissive);
  19995. this.emissiveMap = source.emissiveMap;
  19996. this.emissiveIntensity = source.emissiveIntensity;
  19997. this.bumpMap = source.bumpMap;
  19998. this.bumpScale = source.bumpScale;
  19999. this.normalMap = source.normalMap;
  20000. this.normalMapType = source.normalMapType;
  20001. this.normalScale.copy(source.normalScale);
  20002. this.displacementMap = source.displacementMap;
  20003. this.displacementScale = source.displacementScale;
  20004. this.displacementBias = source.displacementBias;
  20005. this.specularMap = source.specularMap;
  20006. this.alphaMap = source.alphaMap;
  20007. this.wireframe = source.wireframe;
  20008. this.wireframeLinewidth = source.wireframeLinewidth;
  20009. this.wireframeLinecap = source.wireframeLinecap;
  20010. this.wireframeLinejoin = source.wireframeLinejoin;
  20011. this.skinning = source.skinning;
  20012. this.morphTargets = source.morphTargets;
  20013. this.morphNormals = source.morphNormals;
  20014. return this;
  20015. };
  20016. function MeshNormalMaterial(parameters) {
  20017. Material.call(this);
  20018. this.type = "MeshNormalMaterial";
  20019. this.bumpMap = null;
  20020. this.bumpScale = 1;
  20021. this.normalMap = null;
  20022. this.normalMapType = TangentSpaceNormalMap;
  20023. this.normalScale = new Vector2(1, 1);
  20024. this.displacementMap = null;
  20025. this.displacementScale = 1;
  20026. this.displacementBias = 0;
  20027. this.wireframe = false;
  20028. this.wireframeLinewidth = 1;
  20029. this.fog = false;
  20030. this.skinning = false;
  20031. this.morphTargets = false;
  20032. this.morphNormals = false;
  20033. this.setValues(parameters);
  20034. }
  20035. MeshNormalMaterial.prototype = Object.create(Material.prototype);
  20036. MeshNormalMaterial.prototype.constructor = MeshNormalMaterial;
  20037. MeshNormalMaterial.prototype.isMeshNormalMaterial = true;
  20038. MeshNormalMaterial.prototype.copy = function(source) {
  20039. Material.prototype.copy.call(this, source);
  20040. this.bumpMap = source.bumpMap;
  20041. this.bumpScale = source.bumpScale;
  20042. this.normalMap = source.normalMap;
  20043. this.normalMapType = source.normalMapType;
  20044. this.normalScale.copy(source.normalScale);
  20045. this.displacementMap = source.displacementMap;
  20046. this.displacementScale = source.displacementScale;
  20047. this.displacementBias = source.displacementBias;
  20048. this.wireframe = source.wireframe;
  20049. this.wireframeLinewidth = source.wireframeLinewidth;
  20050. this.skinning = source.skinning;
  20051. this.morphTargets = source.morphTargets;
  20052. this.morphNormals = source.morphNormals;
  20053. return this;
  20054. };
  20055. function MeshLambertMaterial(parameters) {
  20056. Material.call(this);
  20057. this.type = "MeshLambertMaterial";
  20058. this.color = new Color(16777215);
  20059. this.map = null;
  20060. this.lightMap = null;
  20061. this.lightMapIntensity = 1;
  20062. this.aoMap = null;
  20063. this.aoMapIntensity = 1;
  20064. this.emissive = new Color(0);
  20065. this.emissiveIntensity = 1;
  20066. this.emissiveMap = null;
  20067. this.specularMap = null;
  20068. this.alphaMap = null;
  20069. this.envMap = null;
  20070. this.combine = MultiplyOperation;
  20071. this.reflectivity = 1;
  20072. this.refractionRatio = 0.98;
  20073. this.wireframe = false;
  20074. this.wireframeLinewidth = 1;
  20075. this.wireframeLinecap = "round";
  20076. this.wireframeLinejoin = "round";
  20077. this.skinning = false;
  20078. this.morphTargets = false;
  20079. this.morphNormals = false;
  20080. this.setValues(parameters);
  20081. }
  20082. MeshLambertMaterial.prototype = Object.create(Material.prototype);
  20083. MeshLambertMaterial.prototype.constructor = MeshLambertMaterial;
  20084. MeshLambertMaterial.prototype.isMeshLambertMaterial = true;
  20085. MeshLambertMaterial.prototype.copy = function(source) {
  20086. Material.prototype.copy.call(this, source);
  20087. this.color.copy(source.color);
  20088. this.map = source.map;
  20089. this.lightMap = source.lightMap;
  20090. this.lightMapIntensity = source.lightMapIntensity;
  20091. this.aoMap = source.aoMap;
  20092. this.aoMapIntensity = source.aoMapIntensity;
  20093. this.emissive.copy(source.emissive);
  20094. this.emissiveMap = source.emissiveMap;
  20095. this.emissiveIntensity = source.emissiveIntensity;
  20096. this.specularMap = source.specularMap;
  20097. this.alphaMap = source.alphaMap;
  20098. this.envMap = source.envMap;
  20099. this.combine = source.combine;
  20100. this.reflectivity = source.reflectivity;
  20101. this.refractionRatio = source.refractionRatio;
  20102. this.wireframe = source.wireframe;
  20103. this.wireframeLinewidth = source.wireframeLinewidth;
  20104. this.wireframeLinecap = source.wireframeLinecap;
  20105. this.wireframeLinejoin = source.wireframeLinejoin;
  20106. this.skinning = source.skinning;
  20107. this.morphTargets = source.morphTargets;
  20108. this.morphNormals = source.morphNormals;
  20109. return this;
  20110. };
  20111. function MeshMatcapMaterial(parameters) {
  20112. Material.call(this);
  20113. this.defines = { "MATCAP": "" };
  20114. this.type = "MeshMatcapMaterial";
  20115. this.color = new Color(16777215);
  20116. this.matcap = null;
  20117. this.map = null;
  20118. this.bumpMap = null;
  20119. this.bumpScale = 1;
  20120. this.normalMap = null;
  20121. this.normalMapType = TangentSpaceNormalMap;
  20122. this.normalScale = new Vector2(1, 1);
  20123. this.displacementMap = null;
  20124. this.displacementScale = 1;
  20125. this.displacementBias = 0;
  20126. this.alphaMap = null;
  20127. this.skinning = false;
  20128. this.morphTargets = false;
  20129. this.morphNormals = false;
  20130. this.setValues(parameters);
  20131. }
  20132. MeshMatcapMaterial.prototype = Object.create(Material.prototype);
  20133. MeshMatcapMaterial.prototype.constructor = MeshMatcapMaterial;
  20134. MeshMatcapMaterial.prototype.isMeshMatcapMaterial = true;
  20135. MeshMatcapMaterial.prototype.copy = function(source) {
  20136. Material.prototype.copy.call(this, source);
  20137. this.defines = { "MATCAP": "" };
  20138. this.color.copy(source.color);
  20139. this.matcap = source.matcap;
  20140. this.map = source.map;
  20141. this.bumpMap = source.bumpMap;
  20142. this.bumpScale = source.bumpScale;
  20143. this.normalMap = source.normalMap;
  20144. this.normalMapType = source.normalMapType;
  20145. this.normalScale.copy(source.normalScale);
  20146. this.displacementMap = source.displacementMap;
  20147. this.displacementScale = source.displacementScale;
  20148. this.displacementBias = source.displacementBias;
  20149. this.alphaMap = source.alphaMap;
  20150. this.skinning = source.skinning;
  20151. this.morphTargets = source.morphTargets;
  20152. this.morphNormals = source.morphNormals;
  20153. return this;
  20154. };
  20155. function LineDashedMaterial(parameters) {
  20156. LineBasicMaterial.call(this);
  20157. this.type = "LineDashedMaterial";
  20158. this.scale = 1;
  20159. this.dashSize = 3;
  20160. this.gapSize = 1;
  20161. this.setValues(parameters);
  20162. }
  20163. LineDashedMaterial.prototype = Object.create(LineBasicMaterial.prototype);
  20164. LineDashedMaterial.prototype.constructor = LineDashedMaterial;
  20165. LineDashedMaterial.prototype.isLineDashedMaterial = true;
  20166. LineDashedMaterial.prototype.copy = function(source) {
  20167. LineBasicMaterial.prototype.copy.call(this, source);
  20168. this.scale = source.scale;
  20169. this.dashSize = source.dashSize;
  20170. this.gapSize = source.gapSize;
  20171. return this;
  20172. };
  20173. var Materials = /* @__PURE__ */ Object.freeze({
  20174. __proto__: null,
  20175. ShadowMaterial,
  20176. SpriteMaterial,
  20177. RawShaderMaterial,
  20178. ShaderMaterial,
  20179. PointsMaterial,
  20180. MeshPhysicalMaterial,
  20181. MeshStandardMaterial,
  20182. MeshPhongMaterial,
  20183. MeshToonMaterial,
  20184. MeshNormalMaterial,
  20185. MeshLambertMaterial,
  20186. MeshDepthMaterial,
  20187. MeshDistanceMaterial,
  20188. MeshBasicMaterial,
  20189. MeshMatcapMaterial,
  20190. LineDashedMaterial,
  20191. LineBasicMaterial,
  20192. Material
  20193. });
  20194. var AnimationUtils = {
  20195. // same as Array.prototype.slice, but also works on typed arrays
  20196. arraySlice: function(array, from, to) {
  20197. if (AnimationUtils.isTypedArray(array)) {
  20198. return new array.constructor(array.subarray(from, to !== void 0 ? to : array.length));
  20199. }
  20200. return array.slice(from, to);
  20201. },
  20202. // converts an array to a specific type
  20203. convertArray: function(array, type, forceClone) {
  20204. if (!array || // let 'undefined' and 'null' pass
  20205. !forceClone && array.constructor === type)
  20206. return array;
  20207. if (typeof type.BYTES_PER_ELEMENT === "number") {
  20208. return new type(array);
  20209. }
  20210. return Array.prototype.slice.call(array);
  20211. },
  20212. isTypedArray: function(object) {
  20213. return ArrayBuffer.isView(object) && !(object instanceof DataView);
  20214. },
  20215. // returns an array by which times and values can be sorted
  20216. getKeyframeOrder: function(times) {
  20217. function compareTime(i3, j) {
  20218. return times[i3] - times[j];
  20219. }
  20220. var n = times.length;
  20221. var result = new Array(n);
  20222. for (var i2 = 0; i2 !== n; ++i2)
  20223. result[i2] = i2;
  20224. result.sort(compareTime);
  20225. return result;
  20226. },
  20227. // uses the array previously returned by 'getKeyframeOrder' to sort data
  20228. sortedArray: function(values, stride, order) {
  20229. var nValues = values.length;
  20230. var result = new values.constructor(nValues);
  20231. for (var i2 = 0, dstOffset = 0; dstOffset !== nValues; ++i2) {
  20232. var srcOffset = order[i2] * stride;
  20233. for (var j = 0; j !== stride; ++j) {
  20234. result[dstOffset++] = values[srcOffset + j];
  20235. }
  20236. }
  20237. return result;
  20238. },
  20239. // function for parsing AOS keyframe formats
  20240. flattenJSON: function(jsonKeys, times, values, valuePropertyName) {
  20241. var i2 = 1, key = jsonKeys[0];
  20242. while (key !== void 0 && key[valuePropertyName] === void 0) {
  20243. key = jsonKeys[i2++];
  20244. }
  20245. if (key === void 0)
  20246. return;
  20247. var value = key[valuePropertyName];
  20248. if (value === void 0)
  20249. return;
  20250. if (Array.isArray(value)) {
  20251. do {
  20252. value = key[valuePropertyName];
  20253. if (value !== void 0) {
  20254. times.push(key.time);
  20255. values.push.apply(values, value);
  20256. }
  20257. key = jsonKeys[i2++];
  20258. } while (key !== void 0);
  20259. } else if (value.toArray !== void 0) {
  20260. do {
  20261. value = key[valuePropertyName];
  20262. if (value !== void 0) {
  20263. times.push(key.time);
  20264. value.toArray(values, values.length);
  20265. }
  20266. key = jsonKeys[i2++];
  20267. } while (key !== void 0);
  20268. } else {
  20269. do {
  20270. value = key[valuePropertyName];
  20271. if (value !== void 0) {
  20272. times.push(key.time);
  20273. values.push(value);
  20274. }
  20275. key = jsonKeys[i2++];
  20276. } while (key !== void 0);
  20277. }
  20278. },
  20279. subclip: function(sourceClip, name, startFrame, endFrame, fps) {
  20280. fps = fps || 30;
  20281. var clip = sourceClip.clone();
  20282. clip.name = name;
  20283. var tracks = [];
  20284. for (var i2 = 0; i2 < clip.tracks.length; ++i2) {
  20285. var track = clip.tracks[i2];
  20286. var valueSize = track.getValueSize();
  20287. var times = [];
  20288. var values = [];
  20289. for (var j = 0; j < track.times.length; ++j) {
  20290. var frame = track.times[j] * fps;
  20291. if (frame < startFrame || frame >= endFrame)
  20292. continue;
  20293. times.push(track.times[j]);
  20294. for (var k = 0; k < valueSize; ++k) {
  20295. values.push(track.values[j * valueSize + k]);
  20296. }
  20297. }
  20298. if (times.length === 0)
  20299. continue;
  20300. track.times = AnimationUtils.convertArray(times, track.times.constructor);
  20301. track.values = AnimationUtils.convertArray(values, track.values.constructor);
  20302. tracks.push(track);
  20303. }
  20304. clip.tracks = tracks;
  20305. var minStartTime = Infinity;
  20306. for (var i2 = 0; i2 < clip.tracks.length; ++i2) {
  20307. if (minStartTime > clip.tracks[i2].times[0]) {
  20308. minStartTime = clip.tracks[i2].times[0];
  20309. }
  20310. }
  20311. for (var i2 = 0; i2 < clip.tracks.length; ++i2) {
  20312. clip.tracks[i2].shift(-1 * minStartTime);
  20313. }
  20314. clip.resetDuration();
  20315. return clip;
  20316. }
  20317. };
  20318. function Interpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {
  20319. this.parameterPositions = parameterPositions;
  20320. this._cachedIndex = 0;
  20321. this.resultBuffer = resultBuffer !== void 0 ? resultBuffer : new sampleValues.constructor(sampleSize);
  20322. this.sampleValues = sampleValues;
  20323. this.valueSize = sampleSize;
  20324. }
  20325. Object.assign(Interpolant.prototype, {
  20326. evaluate: function(t) {
  20327. var pp = this.parameterPositions, i1 = this._cachedIndex, t1 = pp[i1], t0 = pp[i1 - 1];
  20328. validate_interval: {
  20329. seek: {
  20330. var right;
  20331. linear_scan: {
  20332. forward_scan:
  20333. if (!(t < t1)) {
  20334. for (var giveUpAt = i1 + 2; ; ) {
  20335. if (t1 === void 0) {
  20336. if (t < t0)
  20337. break forward_scan;
  20338. i1 = pp.length;
  20339. this._cachedIndex = i1;
  20340. return this.afterEnd_(i1 - 1, t, t0);
  20341. }
  20342. if (i1 === giveUpAt)
  20343. break;
  20344. t0 = t1;
  20345. t1 = pp[++i1];
  20346. if (t < t1) {
  20347. break seek;
  20348. }
  20349. }
  20350. right = pp.length;
  20351. break linear_scan;
  20352. }
  20353. if (!(t >= t0)) {
  20354. var t1global = pp[1];
  20355. if (t < t1global) {
  20356. i1 = 2;
  20357. t0 = t1global;
  20358. }
  20359. for (var giveUpAt = i1 - 2; ; ) {
  20360. if (t0 === void 0) {
  20361. this._cachedIndex = 0;
  20362. return this.beforeStart_(0, t, t1);
  20363. }
  20364. if (i1 === giveUpAt)
  20365. break;
  20366. t1 = t0;
  20367. t0 = pp[--i1 - 1];
  20368. if (t >= t0) {
  20369. break seek;
  20370. }
  20371. }
  20372. right = i1;
  20373. i1 = 0;
  20374. break linear_scan;
  20375. }
  20376. break validate_interval;
  20377. }
  20378. while (i1 < right) {
  20379. var mid = i1 + right >>> 1;
  20380. if (t < pp[mid]) {
  20381. right = mid;
  20382. } else {
  20383. i1 = mid + 1;
  20384. }
  20385. }
  20386. t1 = pp[i1];
  20387. t0 = pp[i1 - 1];
  20388. if (t0 === void 0) {
  20389. this._cachedIndex = 0;
  20390. return this.beforeStart_(0, t, t1);
  20391. }
  20392. if (t1 === void 0) {
  20393. i1 = pp.length;
  20394. this._cachedIndex = i1;
  20395. return this.afterEnd_(i1 - 1, t0, t);
  20396. }
  20397. }
  20398. this._cachedIndex = i1;
  20399. this.intervalChanged_(i1, t0, t1);
  20400. }
  20401. return this.interpolate_(i1, t0, t, t1);
  20402. },
  20403. settings: null,
  20404. // optional, subclass-specific settings structure
  20405. // Note: The indirection allows central control of many interpolants.
  20406. // --- Protected interface
  20407. DefaultSettings_: {},
  20408. getSettings_: function() {
  20409. return this.settings || this.DefaultSettings_;
  20410. },
  20411. copySampleValue_: function(index) {
  20412. var result = this.resultBuffer, values = this.sampleValues, stride = this.valueSize, offset = index * stride;
  20413. for (var i2 = 0; i2 !== stride; ++i2) {
  20414. result[i2] = values[offset + i2];
  20415. }
  20416. return result;
  20417. },
  20418. // Template methods for derived classes:
  20419. interpolate_: function() {
  20420. throw new Error("call to abstract method");
  20421. },
  20422. intervalChanged_: function() {
  20423. }
  20424. });
  20425. //!\ DECLARE ALIAS AFTER assign prototype !
  20426. Object.assign(Interpolant.prototype, {
  20427. //( 0, t, t0 ), returns this.resultBuffer
  20428. beforeStart_: Interpolant.prototype.copySampleValue_,
  20429. //( N-1, tN-1, t ), returns this.resultBuffer
  20430. afterEnd_: Interpolant.prototype.copySampleValue_
  20431. });
  20432. function CubicInterpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {
  20433. Interpolant.call(this, parameterPositions, sampleValues, sampleSize, resultBuffer);
  20434. this._weightPrev = -0;
  20435. this._offsetPrev = -0;
  20436. this._weightNext = -0;
  20437. this._offsetNext = -0;
  20438. }
  20439. CubicInterpolant.prototype = Object.assign(Object.create(Interpolant.prototype), {
  20440. constructor: CubicInterpolant,
  20441. DefaultSettings_: {
  20442. endingStart: ZeroCurvatureEnding,
  20443. endingEnd: ZeroCurvatureEnding
  20444. },
  20445. intervalChanged_: function(i1, t0, t1) {
  20446. var pp = this.parameterPositions, iPrev = i1 - 2, iNext = i1 + 1, tPrev = pp[iPrev], tNext = pp[iNext];
  20447. if (tPrev === void 0) {
  20448. switch (this.getSettings_().endingStart) {
  20449. case ZeroSlopeEnding:
  20450. iPrev = i1;
  20451. tPrev = 2 * t0 - t1;
  20452. break;
  20453. case WrapAroundEnding:
  20454. iPrev = pp.length - 2;
  20455. tPrev = t0 + pp[iPrev] - pp[iPrev + 1];
  20456. break;
  20457. default:
  20458. iPrev = i1;
  20459. tPrev = t1;
  20460. }
  20461. }
  20462. if (tNext === void 0) {
  20463. switch (this.getSettings_().endingEnd) {
  20464. case ZeroSlopeEnding:
  20465. iNext = i1;
  20466. tNext = 2 * t1 - t0;
  20467. break;
  20468. case WrapAroundEnding:
  20469. iNext = 1;
  20470. tNext = t1 + pp[1] - pp[0];
  20471. break;
  20472. default:
  20473. iNext = i1 - 1;
  20474. tNext = t0;
  20475. }
  20476. }
  20477. var halfDt = (t1 - t0) * 0.5, stride = this.valueSize;
  20478. this._weightPrev = halfDt / (t0 - tPrev);
  20479. this._weightNext = halfDt / (tNext - t1);
  20480. this._offsetPrev = iPrev * stride;
  20481. this._offsetNext = iNext * stride;
  20482. },
  20483. interpolate_: function(i1, t0, t, t1) {
  20484. var result = this.resultBuffer, values = this.sampleValues, stride = this.valueSize, o1 = i1 * stride, o0 = o1 - stride, oP = this._offsetPrev, oN = this._offsetNext, wP = this._weightPrev, wN = this._weightNext, p = (t - t0) / (t1 - t0), pp = p * p, ppp = pp * p;
  20485. var sP = -wP * ppp + 2 * wP * pp - wP * p;
  20486. var s0 = (1 + wP) * ppp + (-1.5 - 2 * wP) * pp + (-0.5 + wP) * p + 1;
  20487. var s1 = (-1 - wN) * ppp + (1.5 + wN) * pp + 0.5 * p;
  20488. var sN = wN * ppp - wN * pp;
  20489. for (var i2 = 0; i2 !== stride; ++i2) {
  20490. result[i2] = sP * values[oP + i2] + s0 * values[o0 + i2] + s1 * values[o1 + i2] + sN * values[oN + i2];
  20491. }
  20492. return result;
  20493. }
  20494. });
  20495. function LinearInterpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {
  20496. Interpolant.call(this, parameterPositions, sampleValues, sampleSize, resultBuffer);
  20497. }
  20498. LinearInterpolant.prototype = Object.assign(Object.create(Interpolant.prototype), {
  20499. constructor: LinearInterpolant,
  20500. interpolate_: function(i1, t0, t, t1) {
  20501. var result = this.resultBuffer, values = this.sampleValues, stride = this.valueSize, offset1 = i1 * stride, offset0 = offset1 - stride, weight1 = (t - t0) / (t1 - t0), weight0 = 1 - weight1;
  20502. for (var i2 = 0; i2 !== stride; ++i2) {
  20503. result[i2] = values[offset0 + i2] * weight0 + values[offset1 + i2] * weight1;
  20504. }
  20505. return result;
  20506. }
  20507. });
  20508. function DiscreteInterpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {
  20509. Interpolant.call(this, parameterPositions, sampleValues, sampleSize, resultBuffer);
  20510. }
  20511. DiscreteInterpolant.prototype = Object.assign(Object.create(Interpolant.prototype), {
  20512. constructor: DiscreteInterpolant,
  20513. interpolate_: function(i1) {
  20514. return this.copySampleValue_(i1 - 1);
  20515. }
  20516. });
  20517. function KeyframeTrack(name, times, values, interpolation) {
  20518. if (name === void 0)
  20519. throw new Error("THREE.KeyframeTrack: track name is undefined");
  20520. if (times === void 0 || times.length === 0)
  20521. throw new Error("THREE.KeyframeTrack: no keyframes in track named " + name);
  20522. this.name = name;
  20523. this.times = AnimationUtils.convertArray(times, this.TimeBufferType);
  20524. this.values = AnimationUtils.convertArray(values, this.ValueBufferType);
  20525. this.setInterpolation(interpolation || this.DefaultInterpolation);
  20526. }
  20527. Object.assign(KeyframeTrack, {
  20528. // Serialization (in static context, because of constructor invocation
  20529. // and automatic invocation of .toJSON):
  20530. toJSON: function(track) {
  20531. var trackType = track.constructor;
  20532. var json;
  20533. if (trackType.toJSON !== void 0) {
  20534. json = trackType.toJSON(track);
  20535. } else {
  20536. json = {
  20537. "name": track.name,
  20538. "times": AnimationUtils.convertArray(track.times, Array),
  20539. "values": AnimationUtils.convertArray(track.values, Array)
  20540. };
  20541. var interpolation = track.getInterpolation();
  20542. if (interpolation !== track.DefaultInterpolation) {
  20543. json.interpolation = interpolation;
  20544. }
  20545. }
  20546. json.type = track.ValueTypeName;
  20547. return json;
  20548. }
  20549. });
  20550. Object.assign(KeyframeTrack.prototype, {
  20551. constructor: KeyframeTrack,
  20552. TimeBufferType: Float32Array,
  20553. ValueBufferType: Float32Array,
  20554. DefaultInterpolation: InterpolateLinear,
  20555. InterpolantFactoryMethodDiscrete: function(result) {
  20556. return new DiscreteInterpolant(this.times, this.values, this.getValueSize(), result);
  20557. },
  20558. InterpolantFactoryMethodLinear: function(result) {
  20559. return new LinearInterpolant(this.times, this.values, this.getValueSize(), result);
  20560. },
  20561. InterpolantFactoryMethodSmooth: function(result) {
  20562. return new CubicInterpolant(this.times, this.values, this.getValueSize(), result);
  20563. },
  20564. setInterpolation: function(interpolation) {
  20565. var factoryMethod;
  20566. switch (interpolation) {
  20567. case InterpolateDiscrete:
  20568. factoryMethod = this.InterpolantFactoryMethodDiscrete;
  20569. break;
  20570. case InterpolateLinear:
  20571. factoryMethod = this.InterpolantFactoryMethodLinear;
  20572. break;
  20573. case InterpolateSmooth:
  20574. factoryMethod = this.InterpolantFactoryMethodSmooth;
  20575. break;
  20576. }
  20577. if (factoryMethod === void 0) {
  20578. var message = "unsupported interpolation for " + this.ValueTypeName + " keyframe track named " + this.name;
  20579. if (this.createInterpolant === void 0) {
  20580. if (interpolation !== this.DefaultInterpolation) {
  20581. this.setInterpolation(this.DefaultInterpolation);
  20582. } else {
  20583. throw new Error(message);
  20584. }
  20585. }
  20586. console.warn("THREE.KeyframeTrack:", message);
  20587. return this;
  20588. }
  20589. this.createInterpolant = factoryMethod;
  20590. return this;
  20591. },
  20592. getInterpolation: function() {
  20593. switch (this.createInterpolant) {
  20594. case this.InterpolantFactoryMethodDiscrete:
  20595. return InterpolateDiscrete;
  20596. case this.InterpolantFactoryMethodLinear:
  20597. return InterpolateLinear;
  20598. case this.InterpolantFactoryMethodSmooth:
  20599. return InterpolateSmooth;
  20600. }
  20601. },
  20602. getValueSize: function() {
  20603. return this.values.length / this.times.length;
  20604. },
  20605. // move all keyframes either forwards or backwards in time
  20606. shift: function(timeOffset) {
  20607. if (timeOffset !== 0) {
  20608. var times = this.times;
  20609. for (var i2 = 0, n = times.length; i2 !== n; ++i2) {
  20610. times[i2] += timeOffset;
  20611. }
  20612. }
  20613. return this;
  20614. },
  20615. // scale all keyframe times by a factor (useful for frame <-> seconds conversions)
  20616. scale: function(timeScale) {
  20617. if (timeScale !== 1) {
  20618. var times = this.times;
  20619. for (var i2 = 0, n = times.length; i2 !== n; ++i2) {
  20620. times[i2] *= timeScale;
  20621. }
  20622. }
  20623. return this;
  20624. },
  20625. // removes keyframes before and after animation without changing any values within the range [startTime, endTime].
  20626. // IMPORTANT: We do not shift around keys to the start of the track time, because for interpolated keys this will change their values
  20627. trim: function(startTime, endTime) {
  20628. var times = this.times, nKeys = times.length, from = 0, to = nKeys - 1;
  20629. while (from !== nKeys && times[from] < startTime) {
  20630. ++from;
  20631. }
  20632. while (to !== -1 && times[to] > endTime) {
  20633. --to;
  20634. }
  20635. ++to;
  20636. if (from !== 0 || to !== nKeys) {
  20637. if (from >= to)
  20638. to = Math.max(to, 1), from = to - 1;
  20639. var stride = this.getValueSize();
  20640. this.times = AnimationUtils.arraySlice(times, from, to);
  20641. this.values = AnimationUtils.arraySlice(this.values, from * stride, to * stride);
  20642. }
  20643. return this;
  20644. },
  20645. // ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable
  20646. validate: function() {
  20647. var valid = true;
  20648. var valueSize = this.getValueSize();
  20649. if (valueSize - Math.floor(valueSize) !== 0) {
  20650. console.error("THREE.KeyframeTrack: Invalid value size in track.", this);
  20651. valid = false;
  20652. }
  20653. var times = this.times, values = this.values, nKeys = times.length;
  20654. if (nKeys === 0) {
  20655. console.error("THREE.KeyframeTrack: Track is empty.", this);
  20656. valid = false;
  20657. }
  20658. var prevTime = null;
  20659. for (var i2 = 0; i2 !== nKeys; i2++) {
  20660. var currTime = times[i2];
  20661. if (typeof currTime === "number" && isNaN(currTime)) {
  20662. console.error("THREE.KeyframeTrack: Time is not a valid number.", this, i2, currTime);
  20663. valid = false;
  20664. break;
  20665. }
  20666. if (prevTime !== null && prevTime > currTime) {
  20667. console.error("THREE.KeyframeTrack: Out of order keys.", this, i2, currTime, prevTime);
  20668. valid = false;
  20669. break;
  20670. }
  20671. prevTime = currTime;
  20672. }
  20673. if (values !== void 0) {
  20674. if (AnimationUtils.isTypedArray(values)) {
  20675. for (var i2 = 0, n = values.length; i2 !== n; ++i2) {
  20676. var value = values[i2];
  20677. if (isNaN(value)) {
  20678. console.error("THREE.KeyframeTrack: Value is not a valid number.", this, i2, value);
  20679. valid = false;
  20680. break;
  20681. }
  20682. }
  20683. }
  20684. }
  20685. return valid;
  20686. },
  20687. // removes equivalent sequential keys as common in morph target sequences
  20688. // (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --> (0,0,1,1,0,0)
  20689. optimize: function() {
  20690. var times = AnimationUtils.arraySlice(this.times), values = AnimationUtils.arraySlice(this.values), stride = this.getValueSize(), smoothInterpolation = this.getInterpolation() === InterpolateSmooth, writeIndex = 1, lastIndex = times.length - 1;
  20691. for (var i2 = 1; i2 < lastIndex; ++i2) {
  20692. var keep = false;
  20693. var time = times[i2];
  20694. var timeNext = times[i2 + 1];
  20695. if (time !== timeNext && (i2 !== 1 || time !== time[0])) {
  20696. if (!smoothInterpolation) {
  20697. var offset = i2 * stride, offsetP = offset - stride, offsetN = offset + stride;
  20698. for (var j = 0; j !== stride; ++j) {
  20699. var value = values[offset + j];
  20700. if (value !== values[offsetP + j] || value !== values[offsetN + j]) {
  20701. keep = true;
  20702. break;
  20703. }
  20704. }
  20705. } else {
  20706. keep = true;
  20707. }
  20708. }
  20709. if (keep) {
  20710. if (i2 !== writeIndex) {
  20711. times[writeIndex] = times[i2];
  20712. var readOffset = i2 * stride, writeOffset = writeIndex * stride;
  20713. for (var j = 0; j !== stride; ++j) {
  20714. values[writeOffset + j] = values[readOffset + j];
  20715. }
  20716. }
  20717. ++writeIndex;
  20718. }
  20719. }
  20720. if (lastIndex > 0) {
  20721. times[writeIndex] = times[lastIndex];
  20722. for (var readOffset = lastIndex * stride, writeOffset = writeIndex * stride, j = 0; j !== stride; ++j) {
  20723. values[writeOffset + j] = values[readOffset + j];
  20724. }
  20725. ++writeIndex;
  20726. }
  20727. if (writeIndex !== times.length) {
  20728. this.times = AnimationUtils.arraySlice(times, 0, writeIndex);
  20729. this.values = AnimationUtils.arraySlice(values, 0, writeIndex * stride);
  20730. } else {
  20731. this.times = times;
  20732. this.values = values;
  20733. }
  20734. return this;
  20735. },
  20736. clone: function() {
  20737. var times = AnimationUtils.arraySlice(this.times, 0);
  20738. var values = AnimationUtils.arraySlice(this.values, 0);
  20739. var TypedKeyframeTrack = this.constructor;
  20740. var track = new TypedKeyframeTrack(this.name, times, values);
  20741. track.createInterpolant = this.createInterpolant;
  20742. return track;
  20743. }
  20744. });
  20745. function BooleanKeyframeTrack(name, times, values) {
  20746. KeyframeTrack.call(this, name, times, values);
  20747. }
  20748. BooleanKeyframeTrack.prototype = Object.assign(Object.create(KeyframeTrack.prototype), {
  20749. constructor: BooleanKeyframeTrack,
  20750. ValueTypeName: "bool",
  20751. ValueBufferType: Array,
  20752. DefaultInterpolation: InterpolateDiscrete,
  20753. InterpolantFactoryMethodLinear: void 0,
  20754. InterpolantFactoryMethodSmooth: void 0
  20755. // Note: Actually this track could have a optimized / compressed
  20756. // representation of a single value and a custom interpolant that
  20757. // computes "firstValue ^ isOdd( index )".
  20758. });
  20759. function ColorKeyframeTrack(name, times, values, interpolation) {
  20760. KeyframeTrack.call(this, name, times, values, interpolation);
  20761. }
  20762. ColorKeyframeTrack.prototype = Object.assign(Object.create(KeyframeTrack.prototype), {
  20763. constructor: ColorKeyframeTrack,
  20764. ValueTypeName: "color"
  20765. // ValueBufferType is inherited
  20766. // DefaultInterpolation is inherited
  20767. // Note: Very basic implementation and nothing special yet.
  20768. // However, this is the place for color space parameterization.
  20769. });
  20770. function NumberKeyframeTrack(name, times, values, interpolation) {
  20771. KeyframeTrack.call(this, name, times, values, interpolation);
  20772. }
  20773. NumberKeyframeTrack.prototype = Object.assign(Object.create(KeyframeTrack.prototype), {
  20774. constructor: NumberKeyframeTrack,
  20775. ValueTypeName: "number"
  20776. // ValueBufferType is inherited
  20777. // DefaultInterpolation is inherited
  20778. });
  20779. function QuaternionLinearInterpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {
  20780. Interpolant.call(this, parameterPositions, sampleValues, sampleSize, resultBuffer);
  20781. }
  20782. QuaternionLinearInterpolant.prototype = Object.assign(Object.create(Interpolant.prototype), {
  20783. constructor: QuaternionLinearInterpolant,
  20784. interpolate_: function(i1, t0, t, t1) {
  20785. var result = this.resultBuffer, values = this.sampleValues, stride = this.valueSize, offset = i1 * stride, alpha = (t - t0) / (t1 - t0);
  20786. for (var end = offset + stride; offset !== end; offset += 4) {
  20787. Quaternion.slerpFlat(result, 0, values, offset - stride, values, offset, alpha);
  20788. }
  20789. return result;
  20790. }
  20791. });
  20792. function QuaternionKeyframeTrack(name, times, values, interpolation) {
  20793. KeyframeTrack.call(this, name, times, values, interpolation);
  20794. }
  20795. QuaternionKeyframeTrack.prototype = Object.assign(Object.create(KeyframeTrack.prototype), {
  20796. constructor: QuaternionKeyframeTrack,
  20797. ValueTypeName: "quaternion",
  20798. // ValueBufferType is inherited
  20799. DefaultInterpolation: InterpolateLinear,
  20800. InterpolantFactoryMethodLinear: function(result) {
  20801. return new QuaternionLinearInterpolant(this.times, this.values, this.getValueSize(), result);
  20802. },
  20803. InterpolantFactoryMethodSmooth: void 0
  20804. // not yet implemented
  20805. });
  20806. function StringKeyframeTrack(name, times, values, interpolation) {
  20807. KeyframeTrack.call(this, name, times, values, interpolation);
  20808. }
  20809. StringKeyframeTrack.prototype = Object.assign(Object.create(KeyframeTrack.prototype), {
  20810. constructor: StringKeyframeTrack,
  20811. ValueTypeName: "string",
  20812. ValueBufferType: Array,
  20813. DefaultInterpolation: InterpolateDiscrete,
  20814. InterpolantFactoryMethodLinear: void 0,
  20815. InterpolantFactoryMethodSmooth: void 0
  20816. });
  20817. function VectorKeyframeTrack(name, times, values, interpolation) {
  20818. KeyframeTrack.call(this, name, times, values, interpolation);
  20819. }
  20820. VectorKeyframeTrack.prototype = Object.assign(Object.create(KeyframeTrack.prototype), {
  20821. constructor: VectorKeyframeTrack,
  20822. ValueTypeName: "vector"
  20823. // ValueBufferType is inherited
  20824. // DefaultInterpolation is inherited
  20825. });
  20826. function AnimationClip(name, duration, tracks) {
  20827. this.name = name;
  20828. this.tracks = tracks;
  20829. this.duration = duration !== void 0 ? duration : -1;
  20830. this.uuid = MathUtils.generateUUID();
  20831. if (this.duration < 0) {
  20832. this.resetDuration();
  20833. }
  20834. }
  20835. function getTrackTypeForValueTypeName(typeName) {
  20836. switch (typeName.toLowerCase()) {
  20837. case "scalar":
  20838. case "double":
  20839. case "float":
  20840. case "number":
  20841. case "integer":
  20842. return NumberKeyframeTrack;
  20843. case "vector":
  20844. case "vector2":
  20845. case "vector3":
  20846. case "vector4":
  20847. return VectorKeyframeTrack;
  20848. case "color":
  20849. return ColorKeyframeTrack;
  20850. case "quaternion":
  20851. return QuaternionKeyframeTrack;
  20852. case "bool":
  20853. case "boolean":
  20854. return BooleanKeyframeTrack;
  20855. case "string":
  20856. return StringKeyframeTrack;
  20857. }
  20858. throw new Error("THREE.KeyframeTrack: Unsupported typeName: " + typeName);
  20859. }
  20860. function parseKeyframeTrack(json) {
  20861. if (json.type === void 0) {
  20862. throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");
  20863. }
  20864. var trackType = getTrackTypeForValueTypeName(json.type);
  20865. if (json.times === void 0) {
  20866. var times = [], values = [];
  20867. AnimationUtils.flattenJSON(json.keys, times, values, "value");
  20868. json.times = times;
  20869. json.values = values;
  20870. }
  20871. if (trackType.parse !== void 0) {
  20872. return trackType.parse(json);
  20873. } else {
  20874. return new trackType(json.name, json.times, json.values, json.interpolation);
  20875. }
  20876. }
  20877. Object.assign(AnimationClip, {
  20878. parse: function(json) {
  20879. var tracks = [], jsonTracks = json.tracks, frameTime = 1 / (json.fps || 1);
  20880. for (var i2 = 0, n = jsonTracks.length; i2 !== n; ++i2) {
  20881. tracks.push(parseKeyframeTrack(jsonTracks[i2]).scale(frameTime));
  20882. }
  20883. return new AnimationClip(json.name, json.duration, tracks);
  20884. },
  20885. toJSON: function(clip) {
  20886. var tracks = [], clipTracks = clip.tracks;
  20887. var json = {
  20888. "name": clip.name,
  20889. "duration": clip.duration,
  20890. "tracks": tracks,
  20891. "uuid": clip.uuid
  20892. };
  20893. for (var i2 = 0, n = clipTracks.length; i2 !== n; ++i2) {
  20894. tracks.push(KeyframeTrack.toJSON(clipTracks[i2]));
  20895. }
  20896. return json;
  20897. },
  20898. CreateFromMorphTargetSequence: function(name, morphTargetSequence, fps, noLoop) {
  20899. var numMorphTargets = morphTargetSequence.length;
  20900. var tracks = [];
  20901. for (var i2 = 0; i2 < numMorphTargets; i2++) {
  20902. var times = [];
  20903. var values = [];
  20904. times.push(
  20905. (i2 + numMorphTargets - 1) % numMorphTargets,
  20906. i2,
  20907. (i2 + 1) % numMorphTargets
  20908. );
  20909. values.push(0, 1, 0);
  20910. var order = AnimationUtils.getKeyframeOrder(times);
  20911. times = AnimationUtils.sortedArray(times, 1, order);
  20912. values = AnimationUtils.sortedArray(values, 1, order);
  20913. if (!noLoop && times[0] === 0) {
  20914. times.push(numMorphTargets);
  20915. values.push(values[0]);
  20916. }
  20917. tracks.push(
  20918. new NumberKeyframeTrack(
  20919. ".morphTargetInfluences[" + morphTargetSequence[i2].name + "]",
  20920. times,
  20921. values
  20922. ).scale(1 / fps)
  20923. );
  20924. }
  20925. return new AnimationClip(name, -1, tracks);
  20926. },
  20927. findByName: function(objectOrClipArray, name) {
  20928. var clipArray = objectOrClipArray;
  20929. if (!Array.isArray(objectOrClipArray)) {
  20930. var o = objectOrClipArray;
  20931. clipArray = o.geometry && o.geometry.animations || o.animations;
  20932. }
  20933. for (var i2 = 0; i2 < clipArray.length; i2++) {
  20934. if (clipArray[i2].name === name) {
  20935. return clipArray[i2];
  20936. }
  20937. }
  20938. return null;
  20939. },
  20940. CreateClipsFromMorphTargetSequences: function(morphTargets, fps, noLoop) {
  20941. var animationToMorphTargets = {};
  20942. var pattern = /^([\w-]*?)([\d]+)$/;
  20943. for (var i2 = 0, il = morphTargets.length; i2 < il; i2++) {
  20944. var morphTarget = morphTargets[i2];
  20945. var parts = morphTarget.name.match(pattern);
  20946. if (parts && parts.length > 1) {
  20947. var name = parts[1];
  20948. var animationMorphTargets = animationToMorphTargets[name];
  20949. if (!animationMorphTargets) {
  20950. animationToMorphTargets[name] = animationMorphTargets = [];
  20951. }
  20952. animationMorphTargets.push(morphTarget);
  20953. }
  20954. }
  20955. var clips = [];
  20956. for (var name in animationToMorphTargets) {
  20957. clips.push(AnimationClip.CreateFromMorphTargetSequence(name, animationToMorphTargets[name], fps, noLoop));
  20958. }
  20959. return clips;
  20960. },
  20961. // parse the animation.hierarchy format
  20962. parseAnimation: function(animation, bones) {
  20963. if (!animation) {
  20964. console.error("THREE.AnimationClip: No animation in JSONLoader data.");
  20965. return null;
  20966. }
  20967. var addNonemptyTrack = function(trackType, trackName, animationKeys2, propertyName, destTracks) {
  20968. if (animationKeys2.length !== 0) {
  20969. var times2 = [];
  20970. var values2 = [];
  20971. AnimationUtils.flattenJSON(animationKeys2, times2, values2, propertyName);
  20972. if (times2.length !== 0) {
  20973. destTracks.push(new trackType(trackName, times2, values2));
  20974. }
  20975. }
  20976. };
  20977. var tracks = [];
  20978. var clipName = animation.name || "default";
  20979. var duration = animation.length || -1;
  20980. var fps = animation.fps || 30;
  20981. var hierarchyTracks = animation.hierarchy || [];
  20982. for (var h = 0; h < hierarchyTracks.length; h++) {
  20983. var animationKeys = hierarchyTracks[h].keys;
  20984. if (!animationKeys || animationKeys.length === 0)
  20985. continue;
  20986. if (animationKeys[0].morphTargets) {
  20987. var morphTargetNames = {};
  20988. for (var k = 0; k < animationKeys.length; k++) {
  20989. if (animationKeys[k].morphTargets) {
  20990. for (var m = 0; m < animationKeys[k].morphTargets.length; m++) {
  20991. morphTargetNames[animationKeys[k].morphTargets[m]] = -1;
  20992. }
  20993. }
  20994. }
  20995. for (var morphTargetName in morphTargetNames) {
  20996. var times = [];
  20997. var values = [];
  20998. for (var m = 0; m !== animationKeys[k].morphTargets.length; ++m) {
  20999. var animationKey = animationKeys[k];
  21000. times.push(animationKey.time);
  21001. values.push(animationKey.morphTarget === morphTargetName ? 1 : 0);
  21002. }
  21003. tracks.push(new NumberKeyframeTrack(".morphTargetInfluence[" + morphTargetName + "]", times, values));
  21004. }
  21005. duration = morphTargetNames.length * (fps || 1);
  21006. } else {
  21007. var boneName = ".bones[" + bones[h].name + "]";
  21008. addNonemptyTrack(
  21009. VectorKeyframeTrack,
  21010. boneName + ".position",
  21011. animationKeys,
  21012. "pos",
  21013. tracks
  21014. );
  21015. addNonemptyTrack(
  21016. QuaternionKeyframeTrack,
  21017. boneName + ".quaternion",
  21018. animationKeys,
  21019. "rot",
  21020. tracks
  21021. );
  21022. addNonemptyTrack(
  21023. VectorKeyframeTrack,
  21024. boneName + ".scale",
  21025. animationKeys,
  21026. "scl",
  21027. tracks
  21028. );
  21029. }
  21030. }
  21031. if (tracks.length === 0) {
  21032. return null;
  21033. }
  21034. var clip = new AnimationClip(clipName, duration, tracks);
  21035. return clip;
  21036. }
  21037. });
  21038. Object.assign(AnimationClip.prototype, {
  21039. resetDuration: function() {
  21040. var tracks = this.tracks, duration = 0;
  21041. for (var i2 = 0, n = tracks.length; i2 !== n; ++i2) {
  21042. var track = this.tracks[i2];
  21043. duration = Math.max(duration, track.times[track.times.length - 1]);
  21044. }
  21045. this.duration = duration;
  21046. return this;
  21047. },
  21048. trim: function() {
  21049. for (var i2 = 0; i2 < this.tracks.length; i2++) {
  21050. this.tracks[i2].trim(0, this.duration);
  21051. }
  21052. return this;
  21053. },
  21054. validate: function() {
  21055. var valid = true;
  21056. for (var i2 = 0; i2 < this.tracks.length; i2++) {
  21057. valid = valid && this.tracks[i2].validate();
  21058. }
  21059. return valid;
  21060. },
  21061. optimize: function() {
  21062. for (var i2 = 0; i2 < this.tracks.length; i2++) {
  21063. this.tracks[i2].optimize();
  21064. }
  21065. return this;
  21066. },
  21067. clone: function() {
  21068. var tracks = [];
  21069. for (var i2 = 0; i2 < this.tracks.length; i2++) {
  21070. tracks.push(this.tracks[i2].clone());
  21071. }
  21072. return new AnimationClip(this.name, this.duration, tracks);
  21073. }
  21074. });
  21075. var Cache = {
  21076. enabled: false,
  21077. files: {},
  21078. add: function(key, file) {
  21079. if (this.enabled === false)
  21080. return;
  21081. this.files[key] = file;
  21082. },
  21083. get: function(key) {
  21084. if (this.enabled === false)
  21085. return;
  21086. return this.files[key];
  21087. },
  21088. remove: function(key) {
  21089. delete this.files[key];
  21090. },
  21091. clear: function() {
  21092. this.files = {};
  21093. }
  21094. };
  21095. function LoadingManager(onLoad, onProgress, onError) {
  21096. var scope = this;
  21097. var isLoading = false;
  21098. var itemsLoaded = 0;
  21099. var itemsTotal = 0;
  21100. var urlModifier = void 0;
  21101. var handlers = [];
  21102. this.onStart = void 0;
  21103. this.onLoad = onLoad;
  21104. this.onProgress = onProgress;
  21105. this.onError = onError;
  21106. this.itemStart = function(url) {
  21107. itemsTotal++;
  21108. if (isLoading === false) {
  21109. if (scope.onStart !== void 0) {
  21110. scope.onStart(url, itemsLoaded, itemsTotal);
  21111. }
  21112. }
  21113. isLoading = true;
  21114. };
  21115. this.itemEnd = function(url) {
  21116. itemsLoaded++;
  21117. if (scope.onProgress !== void 0) {
  21118. scope.onProgress(url, itemsLoaded, itemsTotal);
  21119. }
  21120. if (itemsLoaded === itemsTotal) {
  21121. isLoading = false;
  21122. if (scope.onLoad !== void 0) {
  21123. scope.onLoad();
  21124. }
  21125. }
  21126. };
  21127. this.itemError = function(url) {
  21128. if (scope.onError !== void 0) {
  21129. scope.onError(url);
  21130. }
  21131. };
  21132. this.resolveURL = function(url) {
  21133. if (urlModifier) {
  21134. return urlModifier(url);
  21135. }
  21136. return url;
  21137. };
  21138. this.setURLModifier = function(transform) {
  21139. urlModifier = transform;
  21140. return this;
  21141. };
  21142. this.addHandler = function(regex, loader) {
  21143. handlers.push(regex, loader);
  21144. return this;
  21145. };
  21146. this.removeHandler = function(regex) {
  21147. var index = handlers.indexOf(regex);
  21148. if (index !== -1) {
  21149. handlers.splice(index, 2);
  21150. }
  21151. return this;
  21152. };
  21153. this.getHandler = function(file) {
  21154. for (var i2 = 0, l = handlers.length; i2 < l; i2 += 2) {
  21155. var regex = handlers[i2];
  21156. var loader = handlers[i2 + 1];
  21157. if (regex.global)
  21158. regex.lastIndex = 0;
  21159. if (regex.test(file)) {
  21160. return loader;
  21161. }
  21162. }
  21163. return null;
  21164. };
  21165. }
  21166. var DefaultLoadingManager = new LoadingManager();
  21167. function Loader(manager) {
  21168. this.manager = manager !== void 0 ? manager : DefaultLoadingManager;
  21169. this.crossOrigin = "anonymous";
  21170. this.path = "";
  21171. this.resourcePath = "";
  21172. }
  21173. Object.assign(Loader.prototype, {
  21174. load: function() {
  21175. },
  21176. parse: function() {
  21177. },
  21178. setCrossOrigin: function(crossOrigin) {
  21179. this.crossOrigin = crossOrigin;
  21180. return this;
  21181. },
  21182. setPath: function(path) {
  21183. this.path = path;
  21184. return this;
  21185. },
  21186. setResourcePath: function(resourcePath) {
  21187. this.resourcePath = resourcePath;
  21188. return this;
  21189. }
  21190. });
  21191. var loading = {};
  21192. function FileLoader(manager) {
  21193. Loader.call(this, manager);
  21194. }
  21195. FileLoader.prototype = Object.assign(Object.create(Loader.prototype), {
  21196. constructor: FileLoader,
  21197. load: function(url, onLoad, onProgress, onError) {
  21198. if (url === void 0)
  21199. url = "";
  21200. if (this.path !== void 0)
  21201. url = this.path + url;
  21202. url = this.manager.resolveURL(url);
  21203. var scope = this;
  21204. var cached = Cache.get(url);
  21205. if (cached !== void 0) {
  21206. scope.manager.itemStart(url);
  21207. setTimeout(function() {
  21208. if (onLoad)
  21209. onLoad(cached);
  21210. scope.manager.itemEnd(url);
  21211. }, 0);
  21212. return cached;
  21213. }
  21214. if (loading[url] !== void 0) {
  21215. loading[url].push({
  21216. onLoad,
  21217. onProgress,
  21218. onError
  21219. });
  21220. return;
  21221. }
  21222. var dataUriRegex = /^data:(.*?)(;base64)?,(.*)$/;
  21223. var dataUriRegexResult = url.match(dataUriRegex);
  21224. if (dataUriRegexResult) {
  21225. var mimeType = dataUriRegexResult[1];
  21226. var isBase64 = !!dataUriRegexResult[2];
  21227. var data = dataUriRegexResult[3];
  21228. data = decodeURIComponent(data);
  21229. if (isBase64)
  21230. data = atob(data);
  21231. try {
  21232. var response;
  21233. var responseType = (this.responseType || "").toLowerCase();
  21234. switch (responseType) {
  21235. case "arraybuffer":
  21236. case "blob":
  21237. var view = new Uint8Array(data.length);
  21238. for (var i2 = 0; i2 < data.length; i2++) {
  21239. view[i2] = data.charCodeAt(i2);
  21240. }
  21241. if (responseType === "blob") {
  21242. response = new Blob([view.buffer], { type: mimeType });
  21243. } else {
  21244. response = view.buffer;
  21245. }
  21246. break;
  21247. case "document":
  21248. var parser = new DOMParser();
  21249. response = parser.parseFromString(data, mimeType);
  21250. break;
  21251. case "json":
  21252. response = JSON.parse(data);
  21253. break;
  21254. default:
  21255. response = data;
  21256. break;
  21257. }
  21258. setTimeout(function() {
  21259. if (onLoad)
  21260. onLoad(response);
  21261. scope.manager.itemEnd(url);
  21262. }, 0);
  21263. } catch (error) {
  21264. setTimeout(function() {
  21265. if (onError)
  21266. onError(error);
  21267. scope.manager.itemError(url);
  21268. scope.manager.itemEnd(url);
  21269. }, 0);
  21270. }
  21271. } else {
  21272. loading[url] = [];
  21273. loading[url].push({
  21274. onLoad,
  21275. onProgress,
  21276. onError
  21277. });
  21278. var request = new XMLHttpRequest();
  21279. request.open("GET", url, true);
  21280. request.addEventListener("load", function(event) {
  21281. var response2 = this.response;
  21282. var callbacks = loading[url];
  21283. delete loading[url];
  21284. if (this.status === 200 || this.status === 0) {
  21285. if (this.status === 0)
  21286. console.warn("THREE.FileLoader: HTTP Status 0 received.");
  21287. Cache.add(url, response2);
  21288. for (var i3 = 0, il = callbacks.length; i3 < il; i3++) {
  21289. var callback = callbacks[i3];
  21290. if (callback.onLoad)
  21291. callback.onLoad(response2);
  21292. }
  21293. scope.manager.itemEnd(url);
  21294. } else {
  21295. for (var i3 = 0, il = callbacks.length; i3 < il; i3++) {
  21296. var callback = callbacks[i3];
  21297. if (callback.onError)
  21298. callback.onError(event);
  21299. }
  21300. scope.manager.itemError(url);
  21301. scope.manager.itemEnd(url);
  21302. }
  21303. }, false);
  21304. request.addEventListener("progress", function(event) {
  21305. var callbacks = loading[url];
  21306. for (var i3 = 0, il = callbacks.length; i3 < il; i3++) {
  21307. var callback = callbacks[i3];
  21308. if (callback.onProgress)
  21309. callback.onProgress(event);
  21310. }
  21311. }, false);
  21312. request.addEventListener("error", function(event) {
  21313. var callbacks = loading[url];
  21314. delete loading[url];
  21315. for (var i3 = 0, il = callbacks.length; i3 < il; i3++) {
  21316. var callback = callbacks[i3];
  21317. if (callback.onError)
  21318. callback.onError(event);
  21319. }
  21320. scope.manager.itemError(url);
  21321. scope.manager.itemEnd(url);
  21322. }, false);
  21323. request.addEventListener("abort", function(event) {
  21324. var callbacks = loading[url];
  21325. delete loading[url];
  21326. for (var i3 = 0, il = callbacks.length; i3 < il; i3++) {
  21327. var callback = callbacks[i3];
  21328. if (callback.onError)
  21329. callback.onError(event);
  21330. }
  21331. scope.manager.itemError(url);
  21332. scope.manager.itemEnd(url);
  21333. }, false);
  21334. if (this.responseType !== void 0)
  21335. request.responseType = this.responseType;
  21336. if (this.withCredentials !== void 0)
  21337. request.withCredentials = this.withCredentials;
  21338. if (request.overrideMimeType)
  21339. request.overrideMimeType(this.mimeType !== void 0 ? this.mimeType : "text/plain");
  21340. for (var header in this.requestHeader) {
  21341. request.setRequestHeader(header, this.requestHeader[header]);
  21342. }
  21343. request.send(null);
  21344. }
  21345. scope.manager.itemStart(url);
  21346. return request;
  21347. },
  21348. setResponseType: function(value) {
  21349. this.responseType = value;
  21350. return this;
  21351. },
  21352. setWithCredentials: function(value) {
  21353. this.withCredentials = value;
  21354. return this;
  21355. },
  21356. setMimeType: function(value) {
  21357. this.mimeType = value;
  21358. return this;
  21359. },
  21360. setRequestHeader: function(value) {
  21361. this.requestHeader = value;
  21362. return this;
  21363. }
  21364. });
  21365. function AnimationLoader(manager) {
  21366. Loader.call(this, manager);
  21367. }
  21368. AnimationLoader.prototype = Object.assign(Object.create(Loader.prototype), {
  21369. constructor: AnimationLoader,
  21370. load: function(url, onLoad, onProgress, onError) {
  21371. var scope = this;
  21372. var loader = new FileLoader(scope.manager);
  21373. loader.setPath(scope.path);
  21374. loader.load(url, function(text) {
  21375. onLoad(scope.parse(JSON.parse(text)));
  21376. }, onProgress, onError);
  21377. },
  21378. parse: function(json) {
  21379. var animations = [];
  21380. for (var i2 = 0; i2 < json.length; i2++) {
  21381. var clip = AnimationClip.parse(json[i2]);
  21382. animations.push(clip);
  21383. }
  21384. return animations;
  21385. }
  21386. });
  21387. function CompressedTextureLoader(manager) {
  21388. Loader.call(this, manager);
  21389. }
  21390. CompressedTextureLoader.prototype = Object.assign(Object.create(Loader.prototype), {
  21391. constructor: CompressedTextureLoader,
  21392. load: function(url, onLoad, onProgress, onError) {
  21393. var scope = this;
  21394. var images = [];
  21395. var texture = new CompressedTexture();
  21396. texture.image = images;
  21397. var loader = new FileLoader(this.manager);
  21398. loader.setPath(this.path);
  21399. loader.setResponseType("arraybuffer");
  21400. function loadTexture(i3) {
  21401. loader.load(url[i3], function(buffer) {
  21402. var texDatas = scope.parse(buffer, true);
  21403. images[i3] = {
  21404. width: texDatas.width,
  21405. height: texDatas.height,
  21406. format: texDatas.format,
  21407. mipmaps: texDatas.mipmaps
  21408. };
  21409. loaded += 1;
  21410. if (loaded === 6) {
  21411. if (texDatas.mipmapCount === 1)
  21412. texture.minFilter = LinearFilter;
  21413. texture.format = texDatas.format;
  21414. texture.needsUpdate = true;
  21415. if (onLoad)
  21416. onLoad(texture);
  21417. }
  21418. }, onProgress, onError);
  21419. }
  21420. if (Array.isArray(url)) {
  21421. var loaded = 0;
  21422. for (var i2 = 0, il = url.length; i2 < il; ++i2) {
  21423. loadTexture(i2);
  21424. }
  21425. } else {
  21426. loader.load(url, function(buffer) {
  21427. var texDatas = scope.parse(buffer, true);
  21428. if (texDatas.isCubemap) {
  21429. var faces = texDatas.mipmaps.length / texDatas.mipmapCount;
  21430. for (var f = 0; f < faces; f++) {
  21431. images[f] = { mipmaps: [] };
  21432. for (var i3 = 0; i3 < texDatas.mipmapCount; i3++) {
  21433. images[f].mipmaps.push(texDatas.mipmaps[f * texDatas.mipmapCount + i3]);
  21434. images[f].format = texDatas.format;
  21435. images[f].width = texDatas.width;
  21436. images[f].height = texDatas.height;
  21437. }
  21438. }
  21439. } else {
  21440. texture.image.width = texDatas.width;
  21441. texture.image.height = texDatas.height;
  21442. texture.mipmaps = texDatas.mipmaps;
  21443. }
  21444. if (texDatas.mipmapCount === 1) {
  21445. texture.minFilter = LinearFilter;
  21446. }
  21447. texture.format = texDatas.format;
  21448. texture.needsUpdate = true;
  21449. if (onLoad)
  21450. onLoad(texture);
  21451. }, onProgress, onError);
  21452. }
  21453. return texture;
  21454. }
  21455. });
  21456. function DataTextureLoader(manager) {
  21457. Loader.call(this, manager);
  21458. }
  21459. DataTextureLoader.prototype = Object.assign(Object.create(Loader.prototype), {
  21460. constructor: DataTextureLoader,
  21461. load: function(url, onLoad, onProgress, onError) {
  21462. var scope = this;
  21463. var texture = new DataTexture();
  21464. var loader = new FileLoader(this.manager);
  21465. loader.setResponseType("arraybuffer");
  21466. loader.setPath(this.path);
  21467. loader.load(url, function(buffer) {
  21468. var texData = scope.parse(buffer);
  21469. if (!texData)
  21470. return;
  21471. if (texData.image !== void 0) {
  21472. texture.image = texData.image;
  21473. } else if (texData.data !== void 0) {
  21474. texture.image.width = texData.width;
  21475. texture.image.height = texData.height;
  21476. texture.image.data = texData.data;
  21477. }
  21478. texture.wrapS = texData.wrapS !== void 0 ? texData.wrapS : ClampToEdgeWrapping;
  21479. texture.wrapT = texData.wrapT !== void 0 ? texData.wrapT : ClampToEdgeWrapping;
  21480. texture.magFilter = texData.magFilter !== void 0 ? texData.magFilter : LinearFilter;
  21481. texture.minFilter = texData.minFilter !== void 0 ? texData.minFilter : LinearFilter;
  21482. texture.anisotropy = texData.anisotropy !== void 0 ? texData.anisotropy : 1;
  21483. if (texData.format !== void 0) {
  21484. texture.format = texData.format;
  21485. }
  21486. if (texData.type !== void 0) {
  21487. texture.type = texData.type;
  21488. }
  21489. if (texData.mipmaps !== void 0) {
  21490. texture.mipmaps = texData.mipmaps;
  21491. texture.minFilter = LinearMipmapLinearFilter;
  21492. }
  21493. if (texData.mipmapCount === 1) {
  21494. texture.minFilter = LinearFilter;
  21495. }
  21496. texture.needsUpdate = true;
  21497. if (onLoad)
  21498. onLoad(texture, texData);
  21499. }, onProgress, onError);
  21500. return texture;
  21501. }
  21502. });
  21503. function ImageLoader(manager) {
  21504. Loader.call(this, manager);
  21505. }
  21506. ImageLoader.prototype = Object.assign(Object.create(Loader.prototype), {
  21507. constructor: ImageLoader,
  21508. load: function(url, onLoad, onProgress, onError) {
  21509. if (this.path !== void 0)
  21510. url = this.path + url;
  21511. url = this.manager.resolveURL(url);
  21512. var scope = this;
  21513. var cached = Cache.get(url);
  21514. if (cached !== void 0) {
  21515. scope.manager.itemStart(url);
  21516. setTimeout(function() {
  21517. if (onLoad)
  21518. onLoad(cached);
  21519. scope.manager.itemEnd(url);
  21520. }, 0);
  21521. return cached;
  21522. }
  21523. var image = document.createElementNS("http://www.w3.org/1999/xhtml", "img");
  21524. function onImageLoad() {
  21525. image.removeEventListener("load", onImageLoad, false);
  21526. image.removeEventListener("error", onImageError, false);
  21527. Cache.add(url, this);
  21528. if (onLoad)
  21529. onLoad(this);
  21530. scope.manager.itemEnd(url);
  21531. }
  21532. function onImageError(event) {
  21533. image.removeEventListener("load", onImageLoad, false);
  21534. image.removeEventListener("error", onImageError, false);
  21535. if (onError)
  21536. onError(event);
  21537. scope.manager.itemError(url);
  21538. scope.manager.itemEnd(url);
  21539. }
  21540. image.addEventListener("load", onImageLoad, false);
  21541. image.addEventListener("error", onImageError, false);
  21542. if (url.substr(0, 5) !== "data:") {
  21543. if (this.crossOrigin !== void 0)
  21544. image.crossOrigin = this.crossOrigin;
  21545. }
  21546. scope.manager.itemStart(url);
  21547. image.src = url;
  21548. return image;
  21549. }
  21550. });
  21551. function CubeTextureLoader(manager) {
  21552. Loader.call(this, manager);
  21553. }
  21554. CubeTextureLoader.prototype = Object.assign(Object.create(Loader.prototype), {
  21555. constructor: CubeTextureLoader,
  21556. load: function(urls, onLoad, onProgress, onError) {
  21557. var texture = new CubeTexture();
  21558. var loader = new ImageLoader(this.manager);
  21559. loader.setCrossOrigin(this.crossOrigin);
  21560. loader.setPath(this.path);
  21561. var loaded = 0;
  21562. function loadTexture(i3) {
  21563. loader.load(urls[i3], function(image) {
  21564. texture.images[i3] = image;
  21565. loaded++;
  21566. if (loaded === 6) {
  21567. texture.needsUpdate = true;
  21568. if (onLoad)
  21569. onLoad(texture);
  21570. }
  21571. }, void 0, onError);
  21572. }
  21573. for (var i2 = 0; i2 < urls.length; ++i2) {
  21574. loadTexture(i2);
  21575. }
  21576. return texture;
  21577. }
  21578. });
  21579. function TextureLoader(manager) {
  21580. Loader.call(this, manager);
  21581. }
  21582. TextureLoader.prototype = Object.assign(Object.create(Loader.prototype), {
  21583. constructor: TextureLoader,
  21584. load: function(url, onLoad, onProgress, onError) {
  21585. var texture = new Texture();
  21586. var loader = new ImageLoader(this.manager);
  21587. loader.setCrossOrigin(this.crossOrigin);
  21588. loader.setPath(this.path);
  21589. loader.load(url, function(image) {
  21590. texture.image = image;
  21591. var isJPEG = url.search(/\.jpe?g($|\?)/i) > 0 || url.search(/^data\:image\/jpeg/) === 0;
  21592. texture.format = isJPEG ? RGBFormat : RGBAFormat;
  21593. texture.needsUpdate = true;
  21594. if (onLoad !== void 0) {
  21595. onLoad(texture);
  21596. }
  21597. }, onProgress, onError);
  21598. return texture;
  21599. }
  21600. });
  21601. function Curve() {
  21602. this.type = "Curve";
  21603. this.arcLengthDivisions = 200;
  21604. }
  21605. Object.assign(Curve.prototype, {
  21606. // Virtual base class method to overwrite and implement in subclasses
  21607. // - t [0 .. 1]
  21608. getPoint: function() {
  21609. console.warn("THREE.Curve: .getPoint() not implemented.");
  21610. return null;
  21611. },
  21612. // Get point at relative position in curve according to arc length
  21613. // - u [0 .. 1]
  21614. getPointAt: function(u, optionalTarget) {
  21615. var t = this.getUtoTmapping(u);
  21616. return this.getPoint(t, optionalTarget);
  21617. },
  21618. // Get sequence of points using getPoint( t )
  21619. getPoints: function(divisions) {
  21620. if (divisions === void 0)
  21621. divisions = 5;
  21622. var points = [];
  21623. for (var d = 0; d <= divisions; d++) {
  21624. points.push(this.getPoint(d / divisions));
  21625. }
  21626. return points;
  21627. },
  21628. // Get sequence of points using getPointAt( u )
  21629. getSpacedPoints: function(divisions) {
  21630. if (divisions === void 0)
  21631. divisions = 5;
  21632. var points = [];
  21633. for (var d = 0; d <= divisions; d++) {
  21634. points.push(this.getPointAt(d / divisions));
  21635. }
  21636. return points;
  21637. },
  21638. // Get total curve arc length
  21639. getLength: function() {
  21640. var lengths = this.getLengths();
  21641. return lengths[lengths.length - 1];
  21642. },
  21643. // Get list of cumulative segment lengths
  21644. getLengths: function(divisions) {
  21645. if (divisions === void 0)
  21646. divisions = this.arcLengthDivisions;
  21647. if (this.cacheArcLengths && this.cacheArcLengths.length === divisions + 1 && !this.needsUpdate) {
  21648. return this.cacheArcLengths;
  21649. }
  21650. this.needsUpdate = false;
  21651. var cache = [];
  21652. var current, last = this.getPoint(0);
  21653. var p, sum = 0;
  21654. cache.push(0);
  21655. for (p = 1; p <= divisions; p++) {
  21656. current = this.getPoint(p / divisions);
  21657. sum += current.distanceTo(last);
  21658. cache.push(sum);
  21659. last = current;
  21660. }
  21661. this.cacheArcLengths = cache;
  21662. return cache;
  21663. },
  21664. updateArcLengths: function() {
  21665. this.needsUpdate = true;
  21666. this.getLengths();
  21667. },
  21668. // Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant
  21669. getUtoTmapping: function(u, distance) {
  21670. var arcLengths = this.getLengths();
  21671. var i2 = 0, il = arcLengths.length;
  21672. var targetArcLength;
  21673. if (distance) {
  21674. targetArcLength = distance;
  21675. } else {
  21676. targetArcLength = u * arcLengths[il - 1];
  21677. }
  21678. var low = 0, high = il - 1, comparison;
  21679. while (low <= high) {
  21680. i2 = Math.floor(low + (high - low) / 2);
  21681. comparison = arcLengths[i2] - targetArcLength;
  21682. if (comparison < 0) {
  21683. low = i2 + 1;
  21684. } else if (comparison > 0) {
  21685. high = i2 - 1;
  21686. } else {
  21687. high = i2;
  21688. break;
  21689. }
  21690. }
  21691. i2 = high;
  21692. if (arcLengths[i2] === targetArcLength) {
  21693. return i2 / (il - 1);
  21694. }
  21695. var lengthBefore = arcLengths[i2];
  21696. var lengthAfter = arcLengths[i2 + 1];
  21697. var segmentLength = lengthAfter - lengthBefore;
  21698. var segmentFraction = (targetArcLength - lengthBefore) / segmentLength;
  21699. var t = (i2 + segmentFraction) / (il - 1);
  21700. return t;
  21701. },
  21702. // Returns a unit vector tangent at t
  21703. // In case any sub curve does not implement its tangent derivation,
  21704. // 2 points a small delta apart will be used to find its gradient
  21705. // which seems to give a reasonable approximation
  21706. getTangent: function(t) {
  21707. var delta = 1e-4;
  21708. var t1 = t - delta;
  21709. var t2 = t + delta;
  21710. if (t1 < 0)
  21711. t1 = 0;
  21712. if (t2 > 1)
  21713. t2 = 1;
  21714. var pt1 = this.getPoint(t1);
  21715. var pt2 = this.getPoint(t2);
  21716. var vec = pt2.clone().sub(pt1);
  21717. return vec.normalize();
  21718. },
  21719. getTangentAt: function(u) {
  21720. var t = this.getUtoTmapping(u);
  21721. return this.getTangent(t);
  21722. },
  21723. computeFrenetFrames: function(segments, closed) {
  21724. var normal = new Vector3();
  21725. var tangents = [];
  21726. var normals = [];
  21727. var binormals = [];
  21728. var vec = new Vector3();
  21729. var mat = new Matrix4();
  21730. var i2, u, theta;
  21731. for (i2 = 0; i2 <= segments; i2++) {
  21732. u = i2 / segments;
  21733. tangents[i2] = this.getTangentAt(u);
  21734. tangents[i2].normalize();
  21735. }
  21736. normals[0] = new Vector3();
  21737. binormals[0] = new Vector3();
  21738. var min = Number.MAX_VALUE;
  21739. var tx = Math.abs(tangents[0].x);
  21740. var ty = Math.abs(tangents[0].y);
  21741. var tz = Math.abs(tangents[0].z);
  21742. if (tx <= min) {
  21743. min = tx;
  21744. normal.set(1, 0, 0);
  21745. }
  21746. if (ty <= min) {
  21747. min = ty;
  21748. normal.set(0, 1, 0);
  21749. }
  21750. if (tz <= min) {
  21751. normal.set(0, 0, 1);
  21752. }
  21753. vec.crossVectors(tangents[0], normal).normalize();
  21754. normals[0].crossVectors(tangents[0], vec);
  21755. binormals[0].crossVectors(tangents[0], normals[0]);
  21756. for (i2 = 1; i2 <= segments; i2++) {
  21757. normals[i2] = normals[i2 - 1].clone();
  21758. binormals[i2] = binormals[i2 - 1].clone();
  21759. vec.crossVectors(tangents[i2 - 1], tangents[i2]);
  21760. if (vec.length() > Number.EPSILON) {
  21761. vec.normalize();
  21762. theta = Math.acos(MathUtils.clamp(tangents[i2 - 1].dot(tangents[i2]), -1, 1));
  21763. normals[i2].applyMatrix4(mat.makeRotationAxis(vec, theta));
  21764. }
  21765. binormals[i2].crossVectors(tangents[i2], normals[i2]);
  21766. }
  21767. if (closed === true) {
  21768. theta = Math.acos(MathUtils.clamp(normals[0].dot(normals[segments]), -1, 1));
  21769. theta /= segments;
  21770. if (tangents[0].dot(vec.crossVectors(normals[0], normals[segments])) > 0) {
  21771. theta = -theta;
  21772. }
  21773. for (i2 = 1; i2 <= segments; i2++) {
  21774. normals[i2].applyMatrix4(mat.makeRotationAxis(tangents[i2], theta * i2));
  21775. binormals[i2].crossVectors(tangents[i2], normals[i2]);
  21776. }
  21777. }
  21778. return {
  21779. tangents,
  21780. normals,
  21781. binormals
  21782. };
  21783. },
  21784. clone: function() {
  21785. return new this.constructor().copy(this);
  21786. },
  21787. copy: function(source) {
  21788. this.arcLengthDivisions = source.arcLengthDivisions;
  21789. return this;
  21790. },
  21791. toJSON: function() {
  21792. var data = {
  21793. metadata: {
  21794. version: 4.5,
  21795. type: "Curve",
  21796. generator: "Curve.toJSON"
  21797. }
  21798. };
  21799. data.arcLengthDivisions = this.arcLengthDivisions;
  21800. data.type = this.type;
  21801. return data;
  21802. },
  21803. fromJSON: function(json) {
  21804. this.arcLengthDivisions = json.arcLengthDivisions;
  21805. return this;
  21806. }
  21807. });
  21808. function EllipseCurve(aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation) {
  21809. Curve.call(this);
  21810. this.type = "EllipseCurve";
  21811. this.aX = aX || 0;
  21812. this.aY = aY || 0;
  21813. this.xRadius = xRadius || 1;
  21814. this.yRadius = yRadius || 1;
  21815. this.aStartAngle = aStartAngle || 0;
  21816. this.aEndAngle = aEndAngle || 2 * Math.PI;
  21817. this.aClockwise = aClockwise || false;
  21818. this.aRotation = aRotation || 0;
  21819. }
  21820. EllipseCurve.prototype = Object.create(Curve.prototype);
  21821. EllipseCurve.prototype.constructor = EllipseCurve;
  21822. EllipseCurve.prototype.isEllipseCurve = true;
  21823. EllipseCurve.prototype.getPoint = function(t, optionalTarget) {
  21824. var point = optionalTarget || new Vector2();
  21825. var twoPi = Math.PI * 2;
  21826. var deltaAngle = this.aEndAngle - this.aStartAngle;
  21827. var samePoints = Math.abs(deltaAngle) < Number.EPSILON;
  21828. while (deltaAngle < 0)
  21829. deltaAngle += twoPi;
  21830. while (deltaAngle > twoPi)
  21831. deltaAngle -= twoPi;
  21832. if (deltaAngle < Number.EPSILON) {
  21833. if (samePoints) {
  21834. deltaAngle = 0;
  21835. } else {
  21836. deltaAngle = twoPi;
  21837. }
  21838. }
  21839. if (this.aClockwise === true && !samePoints) {
  21840. if (deltaAngle === twoPi) {
  21841. deltaAngle = -twoPi;
  21842. } else {
  21843. deltaAngle = deltaAngle - twoPi;
  21844. }
  21845. }
  21846. var angle = this.aStartAngle + t * deltaAngle;
  21847. var x = this.aX + this.xRadius * Math.cos(angle);
  21848. var y = this.aY + this.yRadius * Math.sin(angle);
  21849. if (this.aRotation !== 0) {
  21850. var cos = Math.cos(this.aRotation);
  21851. var sin = Math.sin(this.aRotation);
  21852. var tx = x - this.aX;
  21853. var ty = y - this.aY;
  21854. x = tx * cos - ty * sin + this.aX;
  21855. y = tx * sin + ty * cos + this.aY;
  21856. }
  21857. return point.set(x, y);
  21858. };
  21859. EllipseCurve.prototype.copy = function(source) {
  21860. Curve.prototype.copy.call(this, source);
  21861. this.aX = source.aX;
  21862. this.aY = source.aY;
  21863. this.xRadius = source.xRadius;
  21864. this.yRadius = source.yRadius;
  21865. this.aStartAngle = source.aStartAngle;
  21866. this.aEndAngle = source.aEndAngle;
  21867. this.aClockwise = source.aClockwise;
  21868. this.aRotation = source.aRotation;
  21869. return this;
  21870. };
  21871. EllipseCurve.prototype.toJSON = function() {
  21872. var data = Curve.prototype.toJSON.call(this);
  21873. data.aX = this.aX;
  21874. data.aY = this.aY;
  21875. data.xRadius = this.xRadius;
  21876. data.yRadius = this.yRadius;
  21877. data.aStartAngle = this.aStartAngle;
  21878. data.aEndAngle = this.aEndAngle;
  21879. data.aClockwise = this.aClockwise;
  21880. data.aRotation = this.aRotation;
  21881. return data;
  21882. };
  21883. EllipseCurve.prototype.fromJSON = function(json) {
  21884. Curve.prototype.fromJSON.call(this, json);
  21885. this.aX = json.aX;
  21886. this.aY = json.aY;
  21887. this.xRadius = json.xRadius;
  21888. this.yRadius = json.yRadius;
  21889. this.aStartAngle = json.aStartAngle;
  21890. this.aEndAngle = json.aEndAngle;
  21891. this.aClockwise = json.aClockwise;
  21892. this.aRotation = json.aRotation;
  21893. return this;
  21894. };
  21895. function ArcCurve(aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise) {
  21896. EllipseCurve.call(this, aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise);
  21897. this.type = "ArcCurve";
  21898. }
  21899. ArcCurve.prototype = Object.create(EllipseCurve.prototype);
  21900. ArcCurve.prototype.constructor = ArcCurve;
  21901. ArcCurve.prototype.isArcCurve = true;
  21902. function CubicPoly() {
  21903. var c0 = 0, c1 = 0, c2 = 0, c3 = 0;
  21904. function init2(x0, x1, t0, t1) {
  21905. c0 = x0;
  21906. c1 = t0;
  21907. c2 = -3 * x0 + 3 * x1 - 2 * t0 - t1;
  21908. c3 = 2 * x0 - 2 * x1 + t0 + t1;
  21909. }
  21910. return {
  21911. initCatmullRom: function(x0, x1, x2, x3, tension) {
  21912. init2(x1, x2, tension * (x2 - x0), tension * (x3 - x1));
  21913. },
  21914. initNonuniformCatmullRom: function(x0, x1, x2, x3, dt0, dt1, dt2) {
  21915. var t1 = (x1 - x0) / dt0 - (x2 - x0) / (dt0 + dt1) + (x2 - x1) / dt1;
  21916. var t2 = (x2 - x1) / dt1 - (x3 - x1) / (dt1 + dt2) + (x3 - x2) / dt2;
  21917. t1 *= dt1;
  21918. t2 *= dt1;
  21919. init2(x1, x2, t1, t2);
  21920. },
  21921. calc: function(t) {
  21922. var t2 = t * t;
  21923. var t3 = t2 * t;
  21924. return c0 + c1 * t + c2 * t2 + c3 * t3;
  21925. }
  21926. };
  21927. }
  21928. var tmp = new Vector3();
  21929. var px = new CubicPoly(), py = new CubicPoly(), pz = new CubicPoly();
  21930. function CatmullRomCurve3(points, closed, curveType, tension) {
  21931. Curve.call(this);
  21932. this.type = "CatmullRomCurve3";
  21933. this.points = points || [];
  21934. this.closed = closed || false;
  21935. this.curveType = curveType || "centripetal";
  21936. this.tension = tension || 0.5;
  21937. }
  21938. CatmullRomCurve3.prototype = Object.create(Curve.prototype);
  21939. CatmullRomCurve3.prototype.constructor = CatmullRomCurve3;
  21940. CatmullRomCurve3.prototype.isCatmullRomCurve3 = true;
  21941. CatmullRomCurve3.prototype.getPoint = function(t, optionalTarget) {
  21942. var point = optionalTarget || new Vector3();
  21943. var points = this.points;
  21944. var l = points.length;
  21945. var p = (l - (this.closed ? 0 : 1)) * t;
  21946. var intPoint = Math.floor(p);
  21947. var weight = p - intPoint;
  21948. if (this.closed) {
  21949. intPoint += intPoint > 0 ? 0 : (Math.floor(Math.abs(intPoint) / l) + 1) * l;
  21950. } else if (weight === 0 && intPoint === l - 1) {
  21951. intPoint = l - 2;
  21952. weight = 1;
  21953. }
  21954. var p0, p1, p2, p3;
  21955. if (this.closed || intPoint > 0) {
  21956. p0 = points[(intPoint - 1) % l];
  21957. } else {
  21958. tmp.subVectors(points[0], points[1]).add(points[0]);
  21959. p0 = tmp;
  21960. }
  21961. p1 = points[intPoint % l];
  21962. p2 = points[(intPoint + 1) % l];
  21963. if (this.closed || intPoint + 2 < l) {
  21964. p3 = points[(intPoint + 2) % l];
  21965. } else {
  21966. tmp.subVectors(points[l - 1], points[l - 2]).add(points[l - 1]);
  21967. p3 = tmp;
  21968. }
  21969. if (this.curveType === "centripetal" || this.curveType === "chordal") {
  21970. var pow = this.curveType === "chordal" ? 0.5 : 0.25;
  21971. var dt0 = Math.pow(p0.distanceToSquared(p1), pow);
  21972. var dt1 = Math.pow(p1.distanceToSquared(p2), pow);
  21973. var dt2 = Math.pow(p2.distanceToSquared(p3), pow);
  21974. if (dt1 < 1e-4)
  21975. dt1 = 1;
  21976. if (dt0 < 1e-4)
  21977. dt0 = dt1;
  21978. if (dt2 < 1e-4)
  21979. dt2 = dt1;
  21980. px.initNonuniformCatmullRom(p0.x, p1.x, p2.x, p3.x, dt0, dt1, dt2);
  21981. py.initNonuniformCatmullRom(p0.y, p1.y, p2.y, p3.y, dt0, dt1, dt2);
  21982. pz.initNonuniformCatmullRom(p0.z, p1.z, p2.z, p3.z, dt0, dt1, dt2);
  21983. } else if (this.curveType === "catmullrom") {
  21984. px.initCatmullRom(p0.x, p1.x, p2.x, p3.x, this.tension);
  21985. py.initCatmullRom(p0.y, p1.y, p2.y, p3.y, this.tension);
  21986. pz.initCatmullRom(p0.z, p1.z, p2.z, p3.z, this.tension);
  21987. }
  21988. point.set(
  21989. px.calc(weight),
  21990. py.calc(weight),
  21991. pz.calc(weight)
  21992. );
  21993. return point;
  21994. };
  21995. CatmullRomCurve3.prototype.copy = function(source) {
  21996. Curve.prototype.copy.call(this, source);
  21997. this.points = [];
  21998. for (var i2 = 0, l = source.points.length; i2 < l; i2++) {
  21999. var point = source.points[i2];
  22000. this.points.push(point.clone());
  22001. }
  22002. this.closed = source.closed;
  22003. this.curveType = source.curveType;
  22004. this.tension = source.tension;
  22005. return this;
  22006. };
  22007. CatmullRomCurve3.prototype.toJSON = function() {
  22008. var data = Curve.prototype.toJSON.call(this);
  22009. data.points = [];
  22010. for (var i2 = 0, l = this.points.length; i2 < l; i2++) {
  22011. var point = this.points[i2];
  22012. data.points.push(point.toArray());
  22013. }
  22014. data.closed = this.closed;
  22015. data.curveType = this.curveType;
  22016. data.tension = this.tension;
  22017. return data;
  22018. };
  22019. CatmullRomCurve3.prototype.fromJSON = function(json) {
  22020. Curve.prototype.fromJSON.call(this, json);
  22021. this.points = [];
  22022. for (var i2 = 0, l = json.points.length; i2 < l; i2++) {
  22023. var point = json.points[i2];
  22024. this.points.push(new Vector3().fromArray(point));
  22025. }
  22026. this.closed = json.closed;
  22027. this.curveType = json.curveType;
  22028. this.tension = json.tension;
  22029. return this;
  22030. };
  22031. function CatmullRom(t, p0, p1, p2, p3) {
  22032. var v0 = (p2 - p0) * 0.5;
  22033. var v1 = (p3 - p1) * 0.5;
  22034. var t2 = t * t;
  22035. var t3 = t * t2;
  22036. return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
  22037. }
  22038. function QuadraticBezierP0(t, p) {
  22039. var k = 1 - t;
  22040. return k * k * p;
  22041. }
  22042. function QuadraticBezierP1(t, p) {
  22043. return 2 * (1 - t) * t * p;
  22044. }
  22045. function QuadraticBezierP2(t, p) {
  22046. return t * t * p;
  22047. }
  22048. function QuadraticBezier(t, p0, p1, p2) {
  22049. return QuadraticBezierP0(t, p0) + QuadraticBezierP1(t, p1) + QuadraticBezierP2(t, p2);
  22050. }
  22051. function CubicBezierP0(t, p) {
  22052. var k = 1 - t;
  22053. return k * k * k * p;
  22054. }
  22055. function CubicBezierP1(t, p) {
  22056. var k = 1 - t;
  22057. return 3 * k * k * t * p;
  22058. }
  22059. function CubicBezierP2(t, p) {
  22060. return 3 * (1 - t) * t * t * p;
  22061. }
  22062. function CubicBezierP3(t, p) {
  22063. return t * t * t * p;
  22064. }
  22065. function CubicBezier(t, p0, p1, p2, p3) {
  22066. return CubicBezierP0(t, p0) + CubicBezierP1(t, p1) + CubicBezierP2(t, p2) + CubicBezierP3(t, p3);
  22067. }
  22068. function CubicBezierCurve(v0, v1, v2, v3) {
  22069. Curve.call(this);
  22070. this.type = "CubicBezierCurve";
  22071. this.v0 = v0 || new Vector2();
  22072. this.v1 = v1 || new Vector2();
  22073. this.v2 = v2 || new Vector2();
  22074. this.v3 = v3 || new Vector2();
  22075. }
  22076. CubicBezierCurve.prototype = Object.create(Curve.prototype);
  22077. CubicBezierCurve.prototype.constructor = CubicBezierCurve;
  22078. CubicBezierCurve.prototype.isCubicBezierCurve = true;
  22079. CubicBezierCurve.prototype.getPoint = function(t, optionalTarget) {
  22080. var point = optionalTarget || new Vector2();
  22081. var v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3;
  22082. point.set(
  22083. CubicBezier(t, v0.x, v1.x, v2.x, v3.x),
  22084. CubicBezier(t, v0.y, v1.y, v2.y, v3.y)
  22085. );
  22086. return point;
  22087. };
  22088. CubicBezierCurve.prototype.copy = function(source) {
  22089. Curve.prototype.copy.call(this, source);
  22090. this.v0.copy(source.v0);
  22091. this.v1.copy(source.v1);
  22092. this.v2.copy(source.v2);
  22093. this.v3.copy(source.v3);
  22094. return this;
  22095. };
  22096. CubicBezierCurve.prototype.toJSON = function() {
  22097. var data = Curve.prototype.toJSON.call(this);
  22098. data.v0 = this.v0.toArray();
  22099. data.v1 = this.v1.toArray();
  22100. data.v2 = this.v2.toArray();
  22101. data.v3 = this.v3.toArray();
  22102. return data;
  22103. };
  22104. CubicBezierCurve.prototype.fromJSON = function(json) {
  22105. Curve.prototype.fromJSON.call(this, json);
  22106. this.v0.fromArray(json.v0);
  22107. this.v1.fromArray(json.v1);
  22108. this.v2.fromArray(json.v2);
  22109. this.v3.fromArray(json.v3);
  22110. return this;
  22111. };
  22112. function CubicBezierCurve3(v0, v1, v2, v3) {
  22113. Curve.call(this);
  22114. this.type = "CubicBezierCurve3";
  22115. this.v0 = v0 || new Vector3();
  22116. this.v1 = v1 || new Vector3();
  22117. this.v2 = v2 || new Vector3();
  22118. this.v3 = v3 || new Vector3();
  22119. }
  22120. CubicBezierCurve3.prototype = Object.create(Curve.prototype);
  22121. CubicBezierCurve3.prototype.constructor = CubicBezierCurve3;
  22122. CubicBezierCurve3.prototype.isCubicBezierCurve3 = true;
  22123. CubicBezierCurve3.prototype.getPoint = function(t, optionalTarget) {
  22124. var point = optionalTarget || new Vector3();
  22125. var v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3;
  22126. point.set(
  22127. CubicBezier(t, v0.x, v1.x, v2.x, v3.x),
  22128. CubicBezier(t, v0.y, v1.y, v2.y, v3.y),
  22129. CubicBezier(t, v0.z, v1.z, v2.z, v3.z)
  22130. );
  22131. return point;
  22132. };
  22133. CubicBezierCurve3.prototype.copy = function(source) {
  22134. Curve.prototype.copy.call(this, source);
  22135. this.v0.copy(source.v0);
  22136. this.v1.copy(source.v1);
  22137. this.v2.copy(source.v2);
  22138. this.v3.copy(source.v3);
  22139. return this;
  22140. };
  22141. CubicBezierCurve3.prototype.toJSON = function() {
  22142. var data = Curve.prototype.toJSON.call(this);
  22143. data.v0 = this.v0.toArray();
  22144. data.v1 = this.v1.toArray();
  22145. data.v2 = this.v2.toArray();
  22146. data.v3 = this.v3.toArray();
  22147. return data;
  22148. };
  22149. CubicBezierCurve3.prototype.fromJSON = function(json) {
  22150. Curve.prototype.fromJSON.call(this, json);
  22151. this.v0.fromArray(json.v0);
  22152. this.v1.fromArray(json.v1);
  22153. this.v2.fromArray(json.v2);
  22154. this.v3.fromArray(json.v3);
  22155. return this;
  22156. };
  22157. function LineCurve(v1, v2) {
  22158. Curve.call(this);
  22159. this.type = "LineCurve";
  22160. this.v1 = v1 || new Vector2();
  22161. this.v2 = v2 || new Vector2();
  22162. }
  22163. LineCurve.prototype = Object.create(Curve.prototype);
  22164. LineCurve.prototype.constructor = LineCurve;
  22165. LineCurve.prototype.isLineCurve = true;
  22166. LineCurve.prototype.getPoint = function(t, optionalTarget) {
  22167. var point = optionalTarget || new Vector2();
  22168. if (t === 1) {
  22169. point.copy(this.v2);
  22170. } else {
  22171. point.copy(this.v2).sub(this.v1);
  22172. point.multiplyScalar(t).add(this.v1);
  22173. }
  22174. return point;
  22175. };
  22176. LineCurve.prototype.getPointAt = function(u, optionalTarget) {
  22177. return this.getPoint(u, optionalTarget);
  22178. };
  22179. LineCurve.prototype.getTangent = function() {
  22180. var tangent = this.v2.clone().sub(this.v1);
  22181. return tangent.normalize();
  22182. };
  22183. LineCurve.prototype.copy = function(source) {
  22184. Curve.prototype.copy.call(this, source);
  22185. this.v1.copy(source.v1);
  22186. this.v2.copy(source.v2);
  22187. return this;
  22188. };
  22189. LineCurve.prototype.toJSON = function() {
  22190. var data = Curve.prototype.toJSON.call(this);
  22191. data.v1 = this.v1.toArray();
  22192. data.v2 = this.v2.toArray();
  22193. return data;
  22194. };
  22195. LineCurve.prototype.fromJSON = function(json) {
  22196. Curve.prototype.fromJSON.call(this, json);
  22197. this.v1.fromArray(json.v1);
  22198. this.v2.fromArray(json.v2);
  22199. return this;
  22200. };
  22201. function LineCurve3(v1, v2) {
  22202. Curve.call(this);
  22203. this.type = "LineCurve3";
  22204. this.v1 = v1 || new Vector3();
  22205. this.v2 = v2 || new Vector3();
  22206. }
  22207. LineCurve3.prototype = Object.create(Curve.prototype);
  22208. LineCurve3.prototype.constructor = LineCurve3;
  22209. LineCurve3.prototype.isLineCurve3 = true;
  22210. LineCurve3.prototype.getPoint = function(t, optionalTarget) {
  22211. var point = optionalTarget || new Vector3();
  22212. if (t === 1) {
  22213. point.copy(this.v2);
  22214. } else {
  22215. point.copy(this.v2).sub(this.v1);
  22216. point.multiplyScalar(t).add(this.v1);
  22217. }
  22218. return point;
  22219. };
  22220. LineCurve3.prototype.getPointAt = function(u, optionalTarget) {
  22221. return this.getPoint(u, optionalTarget);
  22222. };
  22223. LineCurve3.prototype.copy = function(source) {
  22224. Curve.prototype.copy.call(this, source);
  22225. this.v1.copy(source.v1);
  22226. this.v2.copy(source.v2);
  22227. return this;
  22228. };
  22229. LineCurve3.prototype.toJSON = function() {
  22230. var data = Curve.prototype.toJSON.call(this);
  22231. data.v1 = this.v1.toArray();
  22232. data.v2 = this.v2.toArray();
  22233. return data;
  22234. };
  22235. LineCurve3.prototype.fromJSON = function(json) {
  22236. Curve.prototype.fromJSON.call(this, json);
  22237. this.v1.fromArray(json.v1);
  22238. this.v2.fromArray(json.v2);
  22239. return this;
  22240. };
  22241. function QuadraticBezierCurve(v0, v1, v2) {
  22242. Curve.call(this);
  22243. this.type = "QuadraticBezierCurve";
  22244. this.v0 = v0 || new Vector2();
  22245. this.v1 = v1 || new Vector2();
  22246. this.v2 = v2 || new Vector2();
  22247. }
  22248. QuadraticBezierCurve.prototype = Object.create(Curve.prototype);
  22249. QuadraticBezierCurve.prototype.constructor = QuadraticBezierCurve;
  22250. QuadraticBezierCurve.prototype.isQuadraticBezierCurve = true;
  22251. QuadraticBezierCurve.prototype.getPoint = function(t, optionalTarget) {
  22252. var point = optionalTarget || new Vector2();
  22253. var v0 = this.v0, v1 = this.v1, v2 = this.v2;
  22254. point.set(
  22255. QuadraticBezier(t, v0.x, v1.x, v2.x),
  22256. QuadraticBezier(t, v0.y, v1.y, v2.y)
  22257. );
  22258. return point;
  22259. };
  22260. QuadraticBezierCurve.prototype.copy = function(source) {
  22261. Curve.prototype.copy.call(this, source);
  22262. this.v0.copy(source.v0);
  22263. this.v1.copy(source.v1);
  22264. this.v2.copy(source.v2);
  22265. return this;
  22266. };
  22267. QuadraticBezierCurve.prototype.toJSON = function() {
  22268. var data = Curve.prototype.toJSON.call(this);
  22269. data.v0 = this.v0.toArray();
  22270. data.v1 = this.v1.toArray();
  22271. data.v2 = this.v2.toArray();
  22272. return data;
  22273. };
  22274. QuadraticBezierCurve.prototype.fromJSON = function(json) {
  22275. Curve.prototype.fromJSON.call(this, json);
  22276. this.v0.fromArray(json.v0);
  22277. this.v1.fromArray(json.v1);
  22278. this.v2.fromArray(json.v2);
  22279. return this;
  22280. };
  22281. function QuadraticBezierCurve3(v0, v1, v2) {
  22282. Curve.call(this);
  22283. this.type = "QuadraticBezierCurve3";
  22284. this.v0 = v0 || new Vector3();
  22285. this.v1 = v1 || new Vector3();
  22286. this.v2 = v2 || new Vector3();
  22287. }
  22288. QuadraticBezierCurve3.prototype = Object.create(Curve.prototype);
  22289. QuadraticBezierCurve3.prototype.constructor = QuadraticBezierCurve3;
  22290. QuadraticBezierCurve3.prototype.isQuadraticBezierCurve3 = true;
  22291. QuadraticBezierCurve3.prototype.getPoint = function(t, optionalTarget) {
  22292. var point = optionalTarget || new Vector3();
  22293. var v0 = this.v0, v1 = this.v1, v2 = this.v2;
  22294. point.set(
  22295. QuadraticBezier(t, v0.x, v1.x, v2.x),
  22296. QuadraticBezier(t, v0.y, v1.y, v2.y),
  22297. QuadraticBezier(t, v0.z, v1.z, v2.z)
  22298. );
  22299. return point;
  22300. };
  22301. QuadraticBezierCurve3.prototype.copy = function(source) {
  22302. Curve.prototype.copy.call(this, source);
  22303. this.v0.copy(source.v0);
  22304. this.v1.copy(source.v1);
  22305. this.v2.copy(source.v2);
  22306. return this;
  22307. };
  22308. QuadraticBezierCurve3.prototype.toJSON = function() {
  22309. var data = Curve.prototype.toJSON.call(this);
  22310. data.v0 = this.v0.toArray();
  22311. data.v1 = this.v1.toArray();
  22312. data.v2 = this.v2.toArray();
  22313. return data;
  22314. };
  22315. QuadraticBezierCurve3.prototype.fromJSON = function(json) {
  22316. Curve.prototype.fromJSON.call(this, json);
  22317. this.v0.fromArray(json.v0);
  22318. this.v1.fromArray(json.v1);
  22319. this.v2.fromArray(json.v2);
  22320. return this;
  22321. };
  22322. function SplineCurve(points) {
  22323. Curve.call(this);
  22324. this.type = "SplineCurve";
  22325. this.points = points || [];
  22326. }
  22327. SplineCurve.prototype = Object.create(Curve.prototype);
  22328. SplineCurve.prototype.constructor = SplineCurve;
  22329. SplineCurve.prototype.isSplineCurve = true;
  22330. SplineCurve.prototype.getPoint = function(t, optionalTarget) {
  22331. var point = optionalTarget || new Vector2();
  22332. var points = this.points;
  22333. var p = (points.length - 1) * t;
  22334. var intPoint = Math.floor(p);
  22335. var weight = p - intPoint;
  22336. var p0 = points[intPoint === 0 ? intPoint : intPoint - 1];
  22337. var p1 = points[intPoint];
  22338. var p2 = points[intPoint > points.length - 2 ? points.length - 1 : intPoint + 1];
  22339. var p3 = points[intPoint > points.length - 3 ? points.length - 1 : intPoint + 2];
  22340. point.set(
  22341. CatmullRom(weight, p0.x, p1.x, p2.x, p3.x),
  22342. CatmullRom(weight, p0.y, p1.y, p2.y, p3.y)
  22343. );
  22344. return point;
  22345. };
  22346. SplineCurve.prototype.copy = function(source) {
  22347. Curve.prototype.copy.call(this, source);
  22348. this.points = [];
  22349. for (var i2 = 0, l = source.points.length; i2 < l; i2++) {
  22350. var point = source.points[i2];
  22351. this.points.push(point.clone());
  22352. }
  22353. return this;
  22354. };
  22355. SplineCurve.prototype.toJSON = function() {
  22356. var data = Curve.prototype.toJSON.call(this);
  22357. data.points = [];
  22358. for (var i2 = 0, l = this.points.length; i2 < l; i2++) {
  22359. var point = this.points[i2];
  22360. data.points.push(point.toArray());
  22361. }
  22362. return data;
  22363. };
  22364. SplineCurve.prototype.fromJSON = function(json) {
  22365. Curve.prototype.fromJSON.call(this, json);
  22366. this.points = [];
  22367. for (var i2 = 0, l = json.points.length; i2 < l; i2++) {
  22368. var point = json.points[i2];
  22369. this.points.push(new Vector2().fromArray(point));
  22370. }
  22371. return this;
  22372. };
  22373. var Curves = /* @__PURE__ */ Object.freeze({
  22374. __proto__: null,
  22375. ArcCurve,
  22376. CatmullRomCurve3,
  22377. CubicBezierCurve,
  22378. CubicBezierCurve3,
  22379. EllipseCurve,
  22380. LineCurve,
  22381. LineCurve3,
  22382. QuadraticBezierCurve,
  22383. QuadraticBezierCurve3,
  22384. SplineCurve
  22385. });
  22386. function CurvePath() {
  22387. Curve.call(this);
  22388. this.type = "CurvePath";
  22389. this.curves = [];
  22390. this.autoClose = false;
  22391. }
  22392. CurvePath.prototype = Object.assign(Object.create(Curve.prototype), {
  22393. constructor: CurvePath,
  22394. add: function(curve) {
  22395. this.curves.push(curve);
  22396. },
  22397. closePath: function() {
  22398. var startPoint = this.curves[0].getPoint(0);
  22399. var endPoint = this.curves[this.curves.length - 1].getPoint(1);
  22400. if (!startPoint.equals(endPoint)) {
  22401. this.curves.push(new LineCurve(endPoint, startPoint));
  22402. }
  22403. },
  22404. // To get accurate point with reference to
  22405. // entire path distance at time t,
  22406. // following has to be done:
  22407. // 1. Length of each sub path have to be known
  22408. // 2. Locate and identify type of curve
  22409. // 3. Get t for the curve
  22410. // 4. Return curve.getPointAt(t')
  22411. getPoint: function(t) {
  22412. var d = t * this.getLength();
  22413. var curveLengths = this.getCurveLengths();
  22414. var i2 = 0;
  22415. while (i2 < curveLengths.length) {
  22416. if (curveLengths[i2] >= d) {
  22417. var diff = curveLengths[i2] - d;
  22418. var curve = this.curves[i2];
  22419. var segmentLength = curve.getLength();
  22420. var u = segmentLength === 0 ? 0 : 1 - diff / segmentLength;
  22421. return curve.getPointAt(u);
  22422. }
  22423. i2++;
  22424. }
  22425. return null;
  22426. },
  22427. // We cannot use the default THREE.Curve getPoint() with getLength() because in
  22428. // THREE.Curve, getLength() depends on getPoint() but in THREE.CurvePath
  22429. // getPoint() depends on getLength
  22430. getLength: function() {
  22431. var lens = this.getCurveLengths();
  22432. return lens[lens.length - 1];
  22433. },
  22434. // cacheLengths must be recalculated.
  22435. updateArcLengths: function() {
  22436. this.needsUpdate = true;
  22437. this.cacheLengths = null;
  22438. this.getCurveLengths();
  22439. },
  22440. // Compute lengths and cache them
  22441. // We cannot overwrite getLengths() because UtoT mapping uses it.
  22442. getCurveLengths: function() {
  22443. if (this.cacheLengths && this.cacheLengths.length === this.curves.length) {
  22444. return this.cacheLengths;
  22445. }
  22446. var lengths = [], sums = 0;
  22447. for (var i2 = 0, l = this.curves.length; i2 < l; i2++) {
  22448. sums += this.curves[i2].getLength();
  22449. lengths.push(sums);
  22450. }
  22451. this.cacheLengths = lengths;
  22452. return lengths;
  22453. },
  22454. getSpacedPoints: function(divisions) {
  22455. if (divisions === void 0)
  22456. divisions = 40;
  22457. var points = [];
  22458. for (var i2 = 0; i2 <= divisions; i2++) {
  22459. points.push(this.getPoint(i2 / divisions));
  22460. }
  22461. if (this.autoClose) {
  22462. points.push(points[0]);
  22463. }
  22464. return points;
  22465. },
  22466. getPoints: function(divisions) {
  22467. divisions = divisions || 12;
  22468. var points = [], last;
  22469. for (var i2 = 0, curves = this.curves; i2 < curves.length; i2++) {
  22470. var curve = curves[i2];
  22471. var resolution = curve && curve.isEllipseCurve ? divisions * 2 : curve && (curve.isLineCurve || curve.isLineCurve3) ? 1 : curve && curve.isSplineCurve ? divisions * curve.points.length : divisions;
  22472. var pts = curve.getPoints(resolution);
  22473. for (var j = 0; j < pts.length; j++) {
  22474. var point = pts[j];
  22475. if (last && last.equals(point))
  22476. continue;
  22477. points.push(point);
  22478. last = point;
  22479. }
  22480. }
  22481. if (this.autoClose && points.length > 1 && !points[points.length - 1].equals(points[0])) {
  22482. points.push(points[0]);
  22483. }
  22484. return points;
  22485. },
  22486. copy: function(source) {
  22487. Curve.prototype.copy.call(this, source);
  22488. this.curves = [];
  22489. for (var i2 = 0, l = source.curves.length; i2 < l; i2++) {
  22490. var curve = source.curves[i2];
  22491. this.curves.push(curve.clone());
  22492. }
  22493. this.autoClose = source.autoClose;
  22494. return this;
  22495. },
  22496. toJSON: function() {
  22497. var data = Curve.prototype.toJSON.call(this);
  22498. data.autoClose = this.autoClose;
  22499. data.curves = [];
  22500. for (var i2 = 0, l = this.curves.length; i2 < l; i2++) {
  22501. var curve = this.curves[i2];
  22502. data.curves.push(curve.toJSON());
  22503. }
  22504. return data;
  22505. },
  22506. fromJSON: function(json) {
  22507. Curve.prototype.fromJSON.call(this, json);
  22508. this.autoClose = json.autoClose;
  22509. this.curves = [];
  22510. for (var i2 = 0, l = json.curves.length; i2 < l; i2++) {
  22511. var curve = json.curves[i2];
  22512. this.curves.push(new Curves[curve.type]().fromJSON(curve));
  22513. }
  22514. return this;
  22515. }
  22516. });
  22517. function Path(points) {
  22518. CurvePath.call(this);
  22519. this.type = "Path";
  22520. this.currentPoint = new Vector2();
  22521. if (points) {
  22522. this.setFromPoints(points);
  22523. }
  22524. }
  22525. Path.prototype = Object.assign(Object.create(CurvePath.prototype), {
  22526. constructor: Path,
  22527. setFromPoints: function(points) {
  22528. this.moveTo(points[0].x, points[0].y);
  22529. for (var i2 = 1, l = points.length; i2 < l; i2++) {
  22530. this.lineTo(points[i2].x, points[i2].y);
  22531. }
  22532. return this;
  22533. },
  22534. moveTo: function(x, y) {
  22535. this.currentPoint.set(x, y);
  22536. return this;
  22537. },
  22538. lineTo: function(x, y) {
  22539. var curve = new LineCurve(this.currentPoint.clone(), new Vector2(x, y));
  22540. this.curves.push(curve);
  22541. this.currentPoint.set(x, y);
  22542. return this;
  22543. },
  22544. quadraticCurveTo: function(aCPx, aCPy, aX, aY) {
  22545. var curve = new QuadraticBezierCurve(
  22546. this.currentPoint.clone(),
  22547. new Vector2(aCPx, aCPy),
  22548. new Vector2(aX, aY)
  22549. );
  22550. this.curves.push(curve);
  22551. this.currentPoint.set(aX, aY);
  22552. return this;
  22553. },
  22554. bezierCurveTo: function(aCP1x, aCP1y, aCP2x, aCP2y, aX, aY) {
  22555. var curve = new CubicBezierCurve(
  22556. this.currentPoint.clone(),
  22557. new Vector2(aCP1x, aCP1y),
  22558. new Vector2(aCP2x, aCP2y),
  22559. new Vector2(aX, aY)
  22560. );
  22561. this.curves.push(curve);
  22562. this.currentPoint.set(aX, aY);
  22563. return this;
  22564. },
  22565. splineThru: function(pts) {
  22566. var npts = [this.currentPoint.clone()].concat(pts);
  22567. var curve = new SplineCurve(npts);
  22568. this.curves.push(curve);
  22569. this.currentPoint.copy(pts[pts.length - 1]);
  22570. return this;
  22571. },
  22572. arc: function(aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise) {
  22573. var x0 = this.currentPoint.x;
  22574. var y0 = this.currentPoint.y;
  22575. this.absarc(
  22576. aX + x0,
  22577. aY + y0,
  22578. aRadius,
  22579. aStartAngle,
  22580. aEndAngle,
  22581. aClockwise
  22582. );
  22583. return this;
  22584. },
  22585. absarc: function(aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise) {
  22586. this.absellipse(aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise);
  22587. return this;
  22588. },
  22589. ellipse: function(aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation) {
  22590. var x0 = this.currentPoint.x;
  22591. var y0 = this.currentPoint.y;
  22592. this.absellipse(aX + x0, aY + y0, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation);
  22593. return this;
  22594. },
  22595. absellipse: function(aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation) {
  22596. var curve = new EllipseCurve(aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation);
  22597. if (this.curves.length > 0) {
  22598. var firstPoint = curve.getPoint(0);
  22599. if (!firstPoint.equals(this.currentPoint)) {
  22600. this.lineTo(firstPoint.x, firstPoint.y);
  22601. }
  22602. }
  22603. this.curves.push(curve);
  22604. var lastPoint = curve.getPoint(1);
  22605. this.currentPoint.copy(lastPoint);
  22606. return this;
  22607. },
  22608. copy: function(source) {
  22609. CurvePath.prototype.copy.call(this, source);
  22610. this.currentPoint.copy(source.currentPoint);
  22611. return this;
  22612. },
  22613. toJSON: function() {
  22614. var data = CurvePath.prototype.toJSON.call(this);
  22615. data.currentPoint = this.currentPoint.toArray();
  22616. return data;
  22617. },
  22618. fromJSON: function(json) {
  22619. CurvePath.prototype.fromJSON.call(this, json);
  22620. this.currentPoint.fromArray(json.currentPoint);
  22621. return this;
  22622. }
  22623. });
  22624. function Shape(points) {
  22625. Path.call(this, points);
  22626. this.uuid = MathUtils.generateUUID();
  22627. this.type = "Shape";
  22628. this.holes = [];
  22629. }
  22630. Shape.prototype = Object.assign(Object.create(Path.prototype), {
  22631. constructor: Shape,
  22632. getPointsHoles: function(divisions) {
  22633. var holesPts = [];
  22634. for (var i2 = 0, l = this.holes.length; i2 < l; i2++) {
  22635. holesPts[i2] = this.holes[i2].getPoints(divisions);
  22636. }
  22637. return holesPts;
  22638. },
  22639. // get points of shape and holes (keypoints based on segments parameter)
  22640. extractPoints: function(divisions) {
  22641. return {
  22642. shape: this.getPoints(divisions),
  22643. holes: this.getPointsHoles(divisions)
  22644. };
  22645. },
  22646. copy: function(source) {
  22647. Path.prototype.copy.call(this, source);
  22648. this.holes = [];
  22649. for (var i2 = 0, l = source.holes.length; i2 < l; i2++) {
  22650. var hole = source.holes[i2];
  22651. this.holes.push(hole.clone());
  22652. }
  22653. return this;
  22654. },
  22655. toJSON: function() {
  22656. var data = Path.prototype.toJSON.call(this);
  22657. data.uuid = this.uuid;
  22658. data.holes = [];
  22659. for (var i2 = 0, l = this.holes.length; i2 < l; i2++) {
  22660. var hole = this.holes[i2];
  22661. data.holes.push(hole.toJSON());
  22662. }
  22663. return data;
  22664. },
  22665. fromJSON: function(json) {
  22666. Path.prototype.fromJSON.call(this, json);
  22667. this.uuid = json.uuid;
  22668. this.holes = [];
  22669. for (var i2 = 0, l = json.holes.length; i2 < l; i2++) {
  22670. var hole = json.holes[i2];
  22671. this.holes.push(new Path().fromJSON(hole));
  22672. }
  22673. return this;
  22674. }
  22675. });
  22676. function Light(color, intensity) {
  22677. Object3D.call(this);
  22678. this.type = "Light";
  22679. this.color = new Color(color);
  22680. this.intensity = intensity !== void 0 ? intensity : 1;
  22681. this.receiveShadow = void 0;
  22682. }
  22683. Light.prototype = Object.assign(Object.create(Object3D.prototype), {
  22684. constructor: Light,
  22685. isLight: true,
  22686. copy: function(source) {
  22687. Object3D.prototype.copy.call(this, source);
  22688. this.color.copy(source.color);
  22689. this.intensity = source.intensity;
  22690. return this;
  22691. },
  22692. toJSON: function(meta) {
  22693. var data = Object3D.prototype.toJSON.call(this, meta);
  22694. data.object.color = this.color.getHex();
  22695. data.object.intensity = this.intensity;
  22696. if (this.groundColor !== void 0)
  22697. data.object.groundColor = this.groundColor.getHex();
  22698. if (this.distance !== void 0)
  22699. data.object.distance = this.distance;
  22700. if (this.angle !== void 0)
  22701. data.object.angle = this.angle;
  22702. if (this.decay !== void 0)
  22703. data.object.decay = this.decay;
  22704. if (this.penumbra !== void 0)
  22705. data.object.penumbra = this.penumbra;
  22706. if (this.shadow !== void 0)
  22707. data.object.shadow = this.shadow.toJSON();
  22708. return data;
  22709. }
  22710. });
  22711. function HemisphereLight(skyColor, groundColor, intensity) {
  22712. Light.call(this, skyColor, intensity);
  22713. this.type = "HemisphereLight";
  22714. this.castShadow = void 0;
  22715. this.position.copy(Object3D.DefaultUp);
  22716. this.updateMatrix();
  22717. this.groundColor = new Color(groundColor);
  22718. }
  22719. HemisphereLight.prototype = Object.assign(Object.create(Light.prototype), {
  22720. constructor: HemisphereLight,
  22721. isHemisphereLight: true,
  22722. copy: function(source) {
  22723. Light.prototype.copy.call(this, source);
  22724. this.groundColor.copy(source.groundColor);
  22725. return this;
  22726. }
  22727. });
  22728. function LightShadow(camera) {
  22729. this.camera = camera;
  22730. this.bias = 0;
  22731. this.radius = 1;
  22732. this.mapSize = new Vector2(512, 512);
  22733. this.map = null;
  22734. this.mapPass = null;
  22735. this.matrix = new Matrix4();
  22736. this._frustum = new Frustum();
  22737. this._frameExtents = new Vector2(1, 1);
  22738. this._viewportCount = 1;
  22739. this._viewports = [
  22740. new Vector4(0, 0, 1, 1)
  22741. ];
  22742. }
  22743. Object.assign(LightShadow.prototype, {
  22744. _projScreenMatrix: new Matrix4(),
  22745. _lightPositionWorld: new Vector3(),
  22746. _lookTarget: new Vector3(),
  22747. getViewportCount: function() {
  22748. return this._viewportCount;
  22749. },
  22750. getFrustum: function() {
  22751. return this._frustum;
  22752. },
  22753. updateMatrices: function(light) {
  22754. var shadowCamera = this.camera, shadowMatrix = this.matrix, projScreenMatrix = this._projScreenMatrix, lookTarget = this._lookTarget, lightPositionWorld = this._lightPositionWorld;
  22755. lightPositionWorld.setFromMatrixPosition(light.matrixWorld);
  22756. shadowCamera.position.copy(lightPositionWorld);
  22757. lookTarget.setFromMatrixPosition(light.target.matrixWorld);
  22758. shadowCamera.lookAt(lookTarget);
  22759. shadowCamera.updateMatrixWorld();
  22760. projScreenMatrix.multiplyMatrices(shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse);
  22761. this._frustum.setFromProjectionMatrix(projScreenMatrix);
  22762. shadowMatrix.set(
  22763. 0.5,
  22764. 0,
  22765. 0,
  22766. 0.5,
  22767. 0,
  22768. 0.5,
  22769. 0,
  22770. 0.5,
  22771. 0,
  22772. 0,
  22773. 0.5,
  22774. 0.5,
  22775. 0,
  22776. 0,
  22777. 0,
  22778. 1
  22779. );
  22780. shadowMatrix.multiply(shadowCamera.projectionMatrix);
  22781. shadowMatrix.multiply(shadowCamera.matrixWorldInverse);
  22782. },
  22783. getViewport: function(viewportIndex) {
  22784. return this._viewports[viewportIndex];
  22785. },
  22786. getFrameExtents: function() {
  22787. return this._frameExtents;
  22788. },
  22789. copy: function(source) {
  22790. this.camera = source.camera.clone();
  22791. this.bias = source.bias;
  22792. this.radius = source.radius;
  22793. this.mapSize.copy(source.mapSize);
  22794. return this;
  22795. },
  22796. clone: function() {
  22797. return new this.constructor().copy(this);
  22798. },
  22799. toJSON: function() {
  22800. var object = {};
  22801. if (this.bias !== 0)
  22802. object.bias = this.bias;
  22803. if (this.radius !== 1)
  22804. object.radius = this.radius;
  22805. if (this.mapSize.x !== 512 || this.mapSize.y !== 512)
  22806. object.mapSize = this.mapSize.toArray();
  22807. object.camera = this.camera.toJSON(false).object;
  22808. delete object.camera.matrix;
  22809. return object;
  22810. }
  22811. });
  22812. function SpotLightShadow() {
  22813. LightShadow.call(this, new PerspectiveCamera(50, 1, 0.5, 500));
  22814. }
  22815. SpotLightShadow.prototype = Object.assign(Object.create(LightShadow.prototype), {
  22816. constructor: SpotLightShadow,
  22817. isSpotLightShadow: true,
  22818. updateMatrices: function(light) {
  22819. var camera = this.camera;
  22820. var fov2 = MathUtils.RAD2DEG * 2 * light.angle;
  22821. var aspect2 = this.mapSize.width / this.mapSize.height;
  22822. var far = light.distance || camera.far;
  22823. if (fov2 !== camera.fov || aspect2 !== camera.aspect || far !== camera.far) {
  22824. camera.fov = fov2;
  22825. camera.aspect = aspect2;
  22826. camera.far = far;
  22827. camera.updateProjectionMatrix();
  22828. }
  22829. LightShadow.prototype.updateMatrices.call(this, light);
  22830. }
  22831. });
  22832. function SpotLight(color, intensity, distance, angle, penumbra, decay) {
  22833. Light.call(this, color, intensity);
  22834. this.type = "SpotLight";
  22835. this.position.copy(Object3D.DefaultUp);
  22836. this.updateMatrix();
  22837. this.target = new Object3D();
  22838. Object.defineProperty(this, "power", {
  22839. get: function() {
  22840. return this.intensity * Math.PI;
  22841. },
  22842. set: function(power) {
  22843. this.intensity = power / Math.PI;
  22844. }
  22845. });
  22846. this.distance = distance !== void 0 ? distance : 0;
  22847. this.angle = angle !== void 0 ? angle : Math.PI / 3;
  22848. this.penumbra = penumbra !== void 0 ? penumbra : 0;
  22849. this.decay = decay !== void 0 ? decay : 1;
  22850. this.shadow = new SpotLightShadow();
  22851. }
  22852. SpotLight.prototype = Object.assign(Object.create(Light.prototype), {
  22853. constructor: SpotLight,
  22854. isSpotLight: true,
  22855. copy: function(source) {
  22856. Light.prototype.copy.call(this, source);
  22857. this.distance = source.distance;
  22858. this.angle = source.angle;
  22859. this.penumbra = source.penumbra;
  22860. this.decay = source.decay;
  22861. this.target = source.target.clone();
  22862. this.shadow = source.shadow.clone();
  22863. return this;
  22864. }
  22865. });
  22866. function PointLightShadow() {
  22867. LightShadow.call(this, new PerspectiveCamera(90, 1, 0.5, 500));
  22868. this._frameExtents = new Vector2(4, 2);
  22869. this._viewportCount = 6;
  22870. this._viewports = [
  22871. // These viewports map a cube-map onto a 2D texture with the
  22872. // following orientation:
  22873. //
  22874. // xzXZ
  22875. // y Y
  22876. //
  22877. // X - Positive x direction
  22878. // x - Negative x direction
  22879. // Y - Positive y direction
  22880. // y - Negative y direction
  22881. // Z - Positive z direction
  22882. // z - Negative z direction
  22883. // positive X
  22884. new Vector4(2, 1, 1, 1),
  22885. // negative X
  22886. new Vector4(0, 1, 1, 1),
  22887. // positive Z
  22888. new Vector4(3, 1, 1, 1),
  22889. // negative Z
  22890. new Vector4(1, 1, 1, 1),
  22891. // positive Y
  22892. new Vector4(3, 0, 1, 1),
  22893. // negative Y
  22894. new Vector4(1, 0, 1, 1)
  22895. ];
  22896. this._cubeDirections = [
  22897. new Vector3(1, 0, 0),
  22898. new Vector3(-1, 0, 0),
  22899. new Vector3(0, 0, 1),
  22900. new Vector3(0, 0, -1),
  22901. new Vector3(0, 1, 0),
  22902. new Vector3(0, -1, 0)
  22903. ];
  22904. this._cubeUps = [
  22905. new Vector3(0, 1, 0),
  22906. new Vector3(0, 1, 0),
  22907. new Vector3(0, 1, 0),
  22908. new Vector3(0, 1, 0),
  22909. new Vector3(0, 0, 1),
  22910. new Vector3(0, 0, -1)
  22911. ];
  22912. }
  22913. PointLightShadow.prototype = Object.assign(Object.create(LightShadow.prototype), {
  22914. constructor: PointLightShadow,
  22915. isPointLightShadow: true,
  22916. updateMatrices: function(light, viewportIndex) {
  22917. if (viewportIndex === void 0)
  22918. viewportIndex = 0;
  22919. var camera = this.camera, shadowMatrix = this.matrix, lightPositionWorld = this._lightPositionWorld, lookTarget = this._lookTarget, projScreenMatrix = this._projScreenMatrix;
  22920. lightPositionWorld.setFromMatrixPosition(light.matrixWorld);
  22921. camera.position.copy(lightPositionWorld);
  22922. lookTarget.copy(camera.position);
  22923. lookTarget.add(this._cubeDirections[viewportIndex]);
  22924. camera.up.copy(this._cubeUps[viewportIndex]);
  22925. camera.lookAt(lookTarget);
  22926. camera.updateMatrixWorld();
  22927. shadowMatrix.makeTranslation(-lightPositionWorld.x, -lightPositionWorld.y, -lightPositionWorld.z);
  22928. projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
  22929. this._frustum.setFromProjectionMatrix(projScreenMatrix);
  22930. }
  22931. });
  22932. function PointLight(color, intensity, distance, decay) {
  22933. Light.call(this, color, intensity);
  22934. this.type = "PointLight";
  22935. Object.defineProperty(this, "power", {
  22936. get: function() {
  22937. return this.intensity * 4 * Math.PI;
  22938. },
  22939. set: function(power) {
  22940. this.intensity = power / (4 * Math.PI);
  22941. }
  22942. });
  22943. this.distance = distance !== void 0 ? distance : 0;
  22944. this.decay = decay !== void 0 ? decay : 1;
  22945. this.shadow = new PointLightShadow();
  22946. }
  22947. PointLight.prototype = Object.assign(Object.create(Light.prototype), {
  22948. constructor: PointLight,
  22949. isPointLight: true,
  22950. copy: function(source) {
  22951. Light.prototype.copy.call(this, source);
  22952. this.distance = source.distance;
  22953. this.decay = source.decay;
  22954. this.shadow = source.shadow.clone();
  22955. return this;
  22956. }
  22957. });
  22958. function OrthographicCamera(left, right, top2, bottom, near, far) {
  22959. Camera.call(this);
  22960. this.type = "OrthographicCamera";
  22961. this.zoom = 1;
  22962. this.view = null;
  22963. this.left = left !== void 0 ? left : -1;
  22964. this.right = right !== void 0 ? right : 1;
  22965. this.top = top2 !== void 0 ? top2 : 1;
  22966. this.bottom = bottom !== void 0 ? bottom : -1;
  22967. this.near = near !== void 0 ? near : 0.1;
  22968. this.far = far !== void 0 ? far : 2e3;
  22969. this.updateProjectionMatrix();
  22970. }
  22971. OrthographicCamera.prototype = Object.assign(Object.create(Camera.prototype), {
  22972. constructor: OrthographicCamera,
  22973. isOrthographicCamera: true,
  22974. copy: function(source, recursive) {
  22975. Camera.prototype.copy.call(this, source, recursive);
  22976. this.left = source.left;
  22977. this.right = source.right;
  22978. this.top = source.top;
  22979. this.bottom = source.bottom;
  22980. this.near = source.near;
  22981. this.far = source.far;
  22982. this.zoom = source.zoom;
  22983. this.view = source.view === null ? null : Object.assign({}, source.view);
  22984. return this;
  22985. },
  22986. setViewOffset: function(fullWidth, fullHeight, x, y, width, height) {
  22987. if (this.view === null) {
  22988. this.view = {
  22989. enabled: true,
  22990. fullWidth: 1,
  22991. fullHeight: 1,
  22992. offsetX: 0,
  22993. offsetY: 0,
  22994. width: 1,
  22995. height: 1
  22996. };
  22997. }
  22998. this.view.enabled = true;
  22999. this.view.fullWidth = fullWidth;
  23000. this.view.fullHeight = fullHeight;
  23001. this.view.offsetX = x;
  23002. this.view.offsetY = y;
  23003. this.view.width = width;
  23004. this.view.height = height;
  23005. this.updateProjectionMatrix();
  23006. },
  23007. clearViewOffset: function() {
  23008. if (this.view !== null) {
  23009. this.view.enabled = false;
  23010. }
  23011. this.updateProjectionMatrix();
  23012. },
  23013. updateProjectionMatrix: function() {
  23014. var dx = (this.right - this.left) / (2 * this.zoom);
  23015. var dy = (this.top - this.bottom) / (2 * this.zoom);
  23016. var cx = (this.right + this.left) / 2;
  23017. var cy = (this.top + this.bottom) / 2;
  23018. var left = cx - dx;
  23019. var right = cx + dx;
  23020. var top2 = cy + dy;
  23021. var bottom = cy - dy;
  23022. if (this.view !== null && this.view.enabled) {
  23023. var scaleW = (this.right - this.left) / this.view.fullWidth / this.zoom;
  23024. var scaleH = (this.top - this.bottom) / this.view.fullHeight / this.zoom;
  23025. left += scaleW * this.view.offsetX;
  23026. right = left + scaleW * this.view.width;
  23027. top2 -= scaleH * this.view.offsetY;
  23028. bottom = top2 - scaleH * this.view.height;
  23029. }
  23030. this.projectionMatrix.makeOrthographic(left, right, top2, bottom, this.near, this.far);
  23031. this.projectionMatrixInverse.getInverse(this.projectionMatrix);
  23032. },
  23033. toJSON: function(meta) {
  23034. var data = Object3D.prototype.toJSON.call(this, meta);
  23035. data.object.zoom = this.zoom;
  23036. data.object.left = this.left;
  23037. data.object.right = this.right;
  23038. data.object.top = this.top;
  23039. data.object.bottom = this.bottom;
  23040. data.object.near = this.near;
  23041. data.object.far = this.far;
  23042. if (this.view !== null)
  23043. data.object.view = Object.assign({}, this.view);
  23044. return data;
  23045. }
  23046. });
  23047. function DirectionalLightShadow() {
  23048. LightShadow.call(this, new OrthographicCamera(-5, 5, 5, -5, 0.5, 500));
  23049. }
  23050. DirectionalLightShadow.prototype = Object.assign(Object.create(LightShadow.prototype), {
  23051. constructor: DirectionalLightShadow,
  23052. isDirectionalLightShadow: true,
  23053. updateMatrices: function(light) {
  23054. LightShadow.prototype.updateMatrices.call(this, light);
  23055. }
  23056. });
  23057. function DirectionalLight(color, intensity) {
  23058. Light.call(this, color, intensity);
  23059. this.type = "DirectionalLight";
  23060. this.position.copy(Object3D.DefaultUp);
  23061. this.updateMatrix();
  23062. this.target = new Object3D();
  23063. this.shadow = new DirectionalLightShadow();
  23064. }
  23065. DirectionalLight.prototype = Object.assign(Object.create(Light.prototype), {
  23066. constructor: DirectionalLight,
  23067. isDirectionalLight: true,
  23068. copy: function(source) {
  23069. Light.prototype.copy.call(this, source);
  23070. this.target = source.target.clone();
  23071. this.shadow = source.shadow.clone();
  23072. return this;
  23073. }
  23074. });
  23075. function AmbientLight(color, intensity) {
  23076. Light.call(this, color, intensity);
  23077. this.type = "AmbientLight";
  23078. this.castShadow = void 0;
  23079. }
  23080. AmbientLight.prototype = Object.assign(Object.create(Light.prototype), {
  23081. constructor: AmbientLight,
  23082. isAmbientLight: true
  23083. });
  23084. function RectAreaLight(color, intensity, width, height) {
  23085. Light.call(this, color, intensity);
  23086. this.type = "RectAreaLight";
  23087. this.width = width !== void 0 ? width : 10;
  23088. this.height = height !== void 0 ? height : 10;
  23089. }
  23090. RectAreaLight.prototype = Object.assign(Object.create(Light.prototype), {
  23091. constructor: RectAreaLight,
  23092. isRectAreaLight: true,
  23093. copy: function(source) {
  23094. Light.prototype.copy.call(this, source);
  23095. this.width = source.width;
  23096. this.height = source.height;
  23097. return this;
  23098. },
  23099. toJSON: function(meta) {
  23100. var data = Light.prototype.toJSON.call(this, meta);
  23101. data.object.width = this.width;
  23102. data.object.height = this.height;
  23103. return data;
  23104. }
  23105. });
  23106. function MaterialLoader(manager) {
  23107. Loader.call(this, manager);
  23108. this.textures = {};
  23109. }
  23110. MaterialLoader.prototype = Object.assign(Object.create(Loader.prototype), {
  23111. constructor: MaterialLoader,
  23112. load: function(url, onLoad, onProgress, onError) {
  23113. var scope = this;
  23114. var loader = new FileLoader(scope.manager);
  23115. loader.setPath(scope.path);
  23116. loader.load(url, function(text) {
  23117. onLoad(scope.parse(JSON.parse(text)));
  23118. }, onProgress, onError);
  23119. },
  23120. parse: function(json) {
  23121. var textures = this.textures;
  23122. function getTexture(name2) {
  23123. if (textures[name2] === void 0) {
  23124. console.warn("THREE.MaterialLoader: Undefined texture", name2);
  23125. }
  23126. return textures[name2];
  23127. }
  23128. var material = new Materials[json.type]();
  23129. if (json.uuid !== void 0)
  23130. material.uuid = json.uuid;
  23131. if (json.name !== void 0)
  23132. material.name = json.name;
  23133. if (json.color !== void 0)
  23134. material.color.setHex(json.color);
  23135. if (json.roughness !== void 0)
  23136. material.roughness = json.roughness;
  23137. if (json.metalness !== void 0)
  23138. material.metalness = json.metalness;
  23139. if (json.sheen !== void 0)
  23140. material.sheen = new Color().setHex(json.sheen);
  23141. if (json.emissive !== void 0)
  23142. material.emissive.setHex(json.emissive);
  23143. if (json.specular !== void 0)
  23144. material.specular.setHex(json.specular);
  23145. if (json.shininess !== void 0)
  23146. material.shininess = json.shininess;
  23147. if (json.clearcoat !== void 0)
  23148. material.clearcoat = json.clearcoat;
  23149. if (json.clearcoatRoughness !== void 0)
  23150. material.clearcoatRoughness = json.clearcoatRoughness;
  23151. if (json.vertexColors !== void 0)
  23152. material.vertexColors = json.vertexColors;
  23153. if (json.fog !== void 0)
  23154. material.fog = json.fog;
  23155. if (json.flatShading !== void 0)
  23156. material.flatShading = json.flatShading;
  23157. if (json.blending !== void 0)
  23158. material.blending = json.blending;
  23159. if (json.combine !== void 0)
  23160. material.combine = json.combine;
  23161. if (json.side !== void 0)
  23162. material.side = json.side;
  23163. if (json.opacity !== void 0)
  23164. material.opacity = json.opacity;
  23165. if (json.transparent !== void 0)
  23166. material.transparent = json.transparent;
  23167. if (json.alphaTest !== void 0)
  23168. material.alphaTest = json.alphaTest;
  23169. if (json.depthTest !== void 0)
  23170. material.depthTest = json.depthTest;
  23171. if (json.depthWrite !== void 0)
  23172. material.depthWrite = json.depthWrite;
  23173. if (json.colorWrite !== void 0)
  23174. material.colorWrite = json.colorWrite;
  23175. if (json.stencilWrite !== void 0)
  23176. material.stencilWrite = json.stencilWrite;
  23177. if (json.stencilWriteMask !== void 0)
  23178. material.stencilWriteMask = json.stencilWriteMask;
  23179. if (json.stencilFunc !== void 0)
  23180. material.stencilFunc = json.stencilFunc;
  23181. if (json.stencilRef !== void 0)
  23182. material.stencilRef = json.stencilRef;
  23183. if (json.stencilFuncMask !== void 0)
  23184. material.stencilFuncMask = json.stencilFuncMask;
  23185. if (json.stencilFail !== void 0)
  23186. material.stencilFail = json.stencilFail;
  23187. if (json.stencilZFail !== void 0)
  23188. material.stencilZFail = json.stencilZFail;
  23189. if (json.stencilZPass !== void 0)
  23190. material.stencilZPass = json.stencilZPass;
  23191. if (json.wireframe !== void 0)
  23192. material.wireframe = json.wireframe;
  23193. if (json.wireframeLinewidth !== void 0)
  23194. material.wireframeLinewidth = json.wireframeLinewidth;
  23195. if (json.wireframeLinecap !== void 0)
  23196. material.wireframeLinecap = json.wireframeLinecap;
  23197. if (json.wireframeLinejoin !== void 0)
  23198. material.wireframeLinejoin = json.wireframeLinejoin;
  23199. if (json.rotation !== void 0)
  23200. material.rotation = json.rotation;
  23201. if (json.linewidth !== 1)
  23202. material.linewidth = json.linewidth;
  23203. if (json.dashSize !== void 0)
  23204. material.dashSize = json.dashSize;
  23205. if (json.gapSize !== void 0)
  23206. material.gapSize = json.gapSize;
  23207. if (json.scale !== void 0)
  23208. material.scale = json.scale;
  23209. if (json.polygonOffset !== void 0)
  23210. material.polygonOffset = json.polygonOffset;
  23211. if (json.polygonOffsetFactor !== void 0)
  23212. material.polygonOffsetFactor = json.polygonOffsetFactor;
  23213. if (json.polygonOffsetUnits !== void 0)
  23214. material.polygonOffsetUnits = json.polygonOffsetUnits;
  23215. if (json.skinning !== void 0)
  23216. material.skinning = json.skinning;
  23217. if (json.morphTargets !== void 0)
  23218. material.morphTargets = json.morphTargets;
  23219. if (json.morphNormals !== void 0)
  23220. material.morphNormals = json.morphNormals;
  23221. if (json.dithering !== void 0)
  23222. material.dithering = json.dithering;
  23223. if (json.visible !== void 0)
  23224. material.visible = json.visible;
  23225. if (json.toneMapped !== void 0)
  23226. material.toneMapped = json.toneMapped;
  23227. if (json.userData !== void 0)
  23228. material.userData = json.userData;
  23229. if (json.uniforms !== void 0) {
  23230. for (var name in json.uniforms) {
  23231. var uniform = json.uniforms[name];
  23232. material.uniforms[name] = {};
  23233. switch (uniform.type) {
  23234. case "t":
  23235. material.uniforms[name].value = getTexture(uniform.value);
  23236. break;
  23237. case "c":
  23238. material.uniforms[name].value = new Color().setHex(uniform.value);
  23239. break;
  23240. case "v2":
  23241. material.uniforms[name].value = new Vector2().fromArray(uniform.value);
  23242. break;
  23243. case "v3":
  23244. material.uniforms[name].value = new Vector3().fromArray(uniform.value);
  23245. break;
  23246. case "v4":
  23247. material.uniforms[name].value = new Vector4().fromArray(uniform.value);
  23248. break;
  23249. case "m3":
  23250. material.uniforms[name].value = new Matrix3().fromArray(uniform.value);
  23251. case "m4":
  23252. material.uniforms[name].value = new Matrix4().fromArray(uniform.value);
  23253. break;
  23254. default:
  23255. material.uniforms[name].value = uniform.value;
  23256. }
  23257. }
  23258. }
  23259. if (json.defines !== void 0)
  23260. material.defines = json.defines;
  23261. if (json.vertexShader !== void 0)
  23262. material.vertexShader = json.vertexShader;
  23263. if (json.fragmentShader !== void 0)
  23264. material.fragmentShader = json.fragmentShader;
  23265. if (json.extensions !== void 0) {
  23266. for (var key in json.extensions) {
  23267. material.extensions[key] = json.extensions[key];
  23268. }
  23269. }
  23270. if (json.shading !== void 0)
  23271. material.flatShading = json.shading === 1;
  23272. if (json.size !== void 0)
  23273. material.size = json.size;
  23274. if (json.sizeAttenuation !== void 0)
  23275. material.sizeAttenuation = json.sizeAttenuation;
  23276. if (json.map !== void 0)
  23277. material.map = getTexture(json.map);
  23278. if (json.matcap !== void 0)
  23279. material.matcap = getTexture(json.matcap);
  23280. if (json.alphaMap !== void 0) {
  23281. material.alphaMap = getTexture(json.alphaMap);
  23282. material.transparent = true;
  23283. }
  23284. if (json.bumpMap !== void 0)
  23285. material.bumpMap = getTexture(json.bumpMap);
  23286. if (json.bumpScale !== void 0)
  23287. material.bumpScale = json.bumpScale;
  23288. if (json.normalMap !== void 0)
  23289. material.normalMap = getTexture(json.normalMap);
  23290. if (json.normalMapType !== void 0)
  23291. material.normalMapType = json.normalMapType;
  23292. if (json.normalScale !== void 0) {
  23293. var normalScale = json.normalScale;
  23294. if (Array.isArray(normalScale) === false) {
  23295. normalScale = [normalScale, normalScale];
  23296. }
  23297. material.normalScale = new Vector2().fromArray(normalScale);
  23298. }
  23299. if (json.displacementMap !== void 0)
  23300. material.displacementMap = getTexture(json.displacementMap);
  23301. if (json.displacementScale !== void 0)
  23302. material.displacementScale = json.displacementScale;
  23303. if (json.displacementBias !== void 0)
  23304. material.displacementBias = json.displacementBias;
  23305. if (json.roughnessMap !== void 0)
  23306. material.roughnessMap = getTexture(json.roughnessMap);
  23307. if (json.metalnessMap !== void 0)
  23308. material.metalnessMap = getTexture(json.metalnessMap);
  23309. if (json.emissiveMap !== void 0)
  23310. material.emissiveMap = getTexture(json.emissiveMap);
  23311. if (json.emissiveIntensity !== void 0)
  23312. material.emissiveIntensity = json.emissiveIntensity;
  23313. if (json.specularMap !== void 0)
  23314. material.specularMap = getTexture(json.specularMap);
  23315. if (json.envMap !== void 0)
  23316. material.envMap = getTexture(json.envMap);
  23317. if (json.envMapIntensity !== void 0)
  23318. material.envMapIntensity = json.envMapIntensity;
  23319. if (json.reflectivity !== void 0)
  23320. material.reflectivity = json.reflectivity;
  23321. if (json.refractionRatio !== void 0)
  23322. material.refractionRatio = json.refractionRatio;
  23323. if (json.lightMap !== void 0)
  23324. material.lightMap = getTexture(json.lightMap);
  23325. if (json.lightMapIntensity !== void 0)
  23326. material.lightMapIntensity = json.lightMapIntensity;
  23327. if (json.aoMap !== void 0)
  23328. material.aoMap = getTexture(json.aoMap);
  23329. if (json.aoMapIntensity !== void 0)
  23330. material.aoMapIntensity = json.aoMapIntensity;
  23331. if (json.gradientMap !== void 0)
  23332. material.gradientMap = getTexture(json.gradientMap);
  23333. if (json.clearcoatNormalMap !== void 0)
  23334. material.clearcoatNormalMap = getTexture(json.clearcoatNormalMap);
  23335. if (json.clearcoatNormalScale !== void 0)
  23336. material.clearcoatNormalScale = new Vector2().fromArray(json.clearcoatNormalScale);
  23337. return material;
  23338. },
  23339. setTextures: function(value) {
  23340. this.textures = value;
  23341. return this;
  23342. }
  23343. });
  23344. var LoaderUtils = {
  23345. decodeText: function(array) {
  23346. if (typeof TextDecoder !== "undefined") {
  23347. return new TextDecoder().decode(array);
  23348. }
  23349. var s = "";
  23350. for (var i2 = 0, il = array.length; i2 < il; i2++) {
  23351. s += String.fromCharCode(array[i2]);
  23352. }
  23353. try {
  23354. return decodeURIComponent(escape(s));
  23355. } catch (e) {
  23356. return s;
  23357. }
  23358. },
  23359. extractUrlBase: function(url) {
  23360. var index = url.lastIndexOf("/");
  23361. if (index === -1)
  23362. return "./";
  23363. return url.substr(0, index + 1);
  23364. }
  23365. };
  23366. function InstancedBufferGeometry() {
  23367. BufferGeometry.call(this);
  23368. this.type = "InstancedBufferGeometry";
  23369. this.maxInstancedCount = void 0;
  23370. }
  23371. InstancedBufferGeometry.prototype = Object.assign(Object.create(BufferGeometry.prototype), {
  23372. constructor: InstancedBufferGeometry,
  23373. isInstancedBufferGeometry: true,
  23374. copy: function(source) {
  23375. BufferGeometry.prototype.copy.call(this, source);
  23376. this.maxInstancedCount = source.maxInstancedCount;
  23377. return this;
  23378. },
  23379. clone: function() {
  23380. return new this.constructor().copy(this);
  23381. },
  23382. toJSON: function() {
  23383. var data = BufferGeometry.prototype.toJSON.call(this);
  23384. data.maxInstancedCount = this.maxInstancedCount;
  23385. data.isInstancedBufferGeometry = true;
  23386. return data;
  23387. }
  23388. });
  23389. function InstancedBufferAttribute(array, itemSize, normalized, meshPerAttribute) {
  23390. if (typeof normalized === "number") {
  23391. meshPerAttribute = normalized;
  23392. normalized = false;
  23393. console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.");
  23394. }
  23395. BufferAttribute.call(this, array, itemSize, normalized);
  23396. this.meshPerAttribute = meshPerAttribute || 1;
  23397. }
  23398. InstancedBufferAttribute.prototype = Object.assign(Object.create(BufferAttribute.prototype), {
  23399. constructor: InstancedBufferAttribute,
  23400. isInstancedBufferAttribute: true,
  23401. copy: function(source) {
  23402. BufferAttribute.prototype.copy.call(this, source);
  23403. this.meshPerAttribute = source.meshPerAttribute;
  23404. return this;
  23405. },
  23406. toJSON: function() {
  23407. var data = BufferAttribute.prototype.toJSON.call(this);
  23408. data.meshPerAttribute = this.meshPerAttribute;
  23409. data.isInstancedBufferAttribute = true;
  23410. return data;
  23411. }
  23412. });
  23413. function BufferGeometryLoader(manager) {
  23414. Loader.call(this, manager);
  23415. }
  23416. BufferGeometryLoader.prototype = Object.assign(Object.create(Loader.prototype), {
  23417. constructor: BufferGeometryLoader,
  23418. load: function(url, onLoad, onProgress, onError) {
  23419. var scope = this;
  23420. var loader = new FileLoader(scope.manager);
  23421. loader.setPath(scope.path);
  23422. loader.load(url, function(text) {
  23423. onLoad(scope.parse(JSON.parse(text)));
  23424. }, onProgress, onError);
  23425. },
  23426. parse: function(json) {
  23427. var geometry = json.isInstancedBufferGeometry ? new InstancedBufferGeometry() : new BufferGeometry();
  23428. var index = json.data.index;
  23429. if (index !== void 0) {
  23430. var typedArray = new TYPED_ARRAYS[index.type](index.array);
  23431. geometry.setIndex(new BufferAttribute(typedArray, 1));
  23432. }
  23433. var attributes = json.data.attributes;
  23434. for (var key in attributes) {
  23435. var attribute = attributes[key];
  23436. var typedArray = new TYPED_ARRAYS[attribute.type](attribute.array);
  23437. var bufferAttributeConstr = attribute.isInstancedBufferAttribute ? InstancedBufferAttribute : BufferAttribute;
  23438. var bufferAttribute = new bufferAttributeConstr(typedArray, attribute.itemSize, attribute.normalized);
  23439. if (attribute.name !== void 0)
  23440. bufferAttribute.name = attribute.name;
  23441. geometry.setAttribute(key, bufferAttribute);
  23442. }
  23443. var morphAttributes = json.data.morphAttributes;
  23444. if (morphAttributes) {
  23445. for (var key in morphAttributes) {
  23446. var attributeArray = morphAttributes[key];
  23447. var array = [];
  23448. for (var i2 = 0, il = attributeArray.length; i2 < il; i2++) {
  23449. var attribute = attributeArray[i2];
  23450. var typedArray = new TYPED_ARRAYS[attribute.type](attribute.array);
  23451. var bufferAttribute = new BufferAttribute(typedArray, attribute.itemSize, attribute.normalized);
  23452. if (attribute.name !== void 0)
  23453. bufferAttribute.name = attribute.name;
  23454. array.push(bufferAttribute);
  23455. }
  23456. geometry.morphAttributes[key] = array;
  23457. }
  23458. }
  23459. var morphTargetsRelative = json.data.morphTargetsRelative;
  23460. if (morphTargetsRelative) {
  23461. geometry.morphTargetsRelative = true;
  23462. }
  23463. var groups = json.data.groups || json.data.drawcalls || json.data.offsets;
  23464. if (groups !== void 0) {
  23465. for (var i2 = 0, n = groups.length; i2 !== n; ++i2) {
  23466. var group = groups[i2];
  23467. geometry.addGroup(group.start, group.count, group.materialIndex);
  23468. }
  23469. }
  23470. var boundingSphere = json.data.boundingSphere;
  23471. if (boundingSphere !== void 0) {
  23472. var center = new Vector3();
  23473. if (boundingSphere.center !== void 0) {
  23474. center.fromArray(boundingSphere.center);
  23475. }
  23476. geometry.boundingSphere = new Sphere(center, boundingSphere.radius);
  23477. }
  23478. if (json.name)
  23479. geometry.name = json.name;
  23480. if (json.userData)
  23481. geometry.userData = json.userData;
  23482. return geometry;
  23483. }
  23484. });
  23485. var TYPED_ARRAYS = {
  23486. Int8Array,
  23487. Uint8Array,
  23488. // Workaround for IE11 pre KB2929437. See #11440
  23489. Uint8ClampedArray: typeof Uint8ClampedArray !== "undefined" ? Uint8ClampedArray : Uint8Array,
  23490. Int16Array,
  23491. Uint16Array,
  23492. Int32Array,
  23493. Uint32Array,
  23494. Float32Array,
  23495. Float64Array
  23496. };
  23497. function ObjectLoader(manager) {
  23498. Loader.call(this, manager);
  23499. }
  23500. ObjectLoader.prototype = Object.assign(Object.create(Loader.prototype), {
  23501. constructor: ObjectLoader,
  23502. load: function(url, onLoad, onProgress, onError) {
  23503. var scope = this;
  23504. var path = this.path === "" ? LoaderUtils.extractUrlBase(url) : this.path;
  23505. this.resourcePath = this.resourcePath || path;
  23506. var loader = new FileLoader(scope.manager);
  23507. loader.setPath(this.path);
  23508. loader.load(url, function(text) {
  23509. var json = null;
  23510. try {
  23511. json = JSON.parse(text);
  23512. } catch (error) {
  23513. if (onError !== void 0)
  23514. onError(error);
  23515. console.error("THREE:ObjectLoader: Can't parse " + url + ".", error.message);
  23516. return;
  23517. }
  23518. var metadata = json.metadata;
  23519. if (metadata === void 0 || metadata.type === void 0 || metadata.type.toLowerCase() === "geometry") {
  23520. console.error("THREE.ObjectLoader: Can't load " + url);
  23521. return;
  23522. }
  23523. scope.parse(json, onLoad);
  23524. }, onProgress, onError);
  23525. },
  23526. parse: function(json, onLoad) {
  23527. var shapes = this.parseShape(json.shapes);
  23528. var geometries = this.parseGeometries(json.geometries, shapes);
  23529. var images = this.parseImages(json.images, function() {
  23530. if (onLoad !== void 0)
  23531. onLoad(object);
  23532. });
  23533. var textures = this.parseTextures(json.textures, images);
  23534. var materials = this.parseMaterials(json.materials, textures);
  23535. var object = this.parseObject(json.object, geometries, materials);
  23536. if (json.animations) {
  23537. object.animations = this.parseAnimations(json.animations);
  23538. }
  23539. if (json.images === void 0 || json.images.length === 0) {
  23540. if (onLoad !== void 0)
  23541. onLoad(object);
  23542. }
  23543. return object;
  23544. },
  23545. parseShape: function(json) {
  23546. var shapes = {};
  23547. if (json !== void 0) {
  23548. for (var i2 = 0, l = json.length; i2 < l; i2++) {
  23549. var shape = new Shape().fromJSON(json[i2]);
  23550. shapes[shape.uuid] = shape;
  23551. }
  23552. }
  23553. return shapes;
  23554. },
  23555. parseGeometries: function(json, shapes) {
  23556. var geometries = {};
  23557. if (json !== void 0) {
  23558. var bufferGeometryLoader = new BufferGeometryLoader();
  23559. for (var i2 = 0, l = json.length; i2 < l; i2++) {
  23560. var geometry;
  23561. var data = json[i2];
  23562. switch (data.type) {
  23563. case "PlaneGeometry":
  23564. case "PlaneBufferGeometry":
  23565. geometry = new Geometries[data.type](
  23566. data.width,
  23567. data.height,
  23568. data.widthSegments,
  23569. data.heightSegments
  23570. );
  23571. break;
  23572. case "BoxGeometry":
  23573. case "BoxBufferGeometry":
  23574. case "CubeGeometry":
  23575. geometry = new Geometries[data.type](
  23576. data.width,
  23577. data.height,
  23578. data.depth,
  23579. data.widthSegments,
  23580. data.heightSegments,
  23581. data.depthSegments
  23582. );
  23583. break;
  23584. case "CircleGeometry":
  23585. case "CircleBufferGeometry":
  23586. geometry = new Geometries[data.type](
  23587. data.radius,
  23588. data.segments,
  23589. data.thetaStart,
  23590. data.thetaLength
  23591. );
  23592. break;
  23593. case "CylinderGeometry":
  23594. case "CylinderBufferGeometry":
  23595. geometry = new Geometries[data.type](
  23596. data.radiusTop,
  23597. data.radiusBottom,
  23598. data.height,
  23599. data.radialSegments,
  23600. data.heightSegments,
  23601. data.openEnded,
  23602. data.thetaStart,
  23603. data.thetaLength
  23604. );
  23605. break;
  23606. case "ConeGeometry":
  23607. case "ConeBufferGeometry":
  23608. geometry = new Geometries[data.type](
  23609. data.radius,
  23610. data.height,
  23611. data.radialSegments,
  23612. data.heightSegments,
  23613. data.openEnded,
  23614. data.thetaStart,
  23615. data.thetaLength
  23616. );
  23617. break;
  23618. case "SphereGeometry":
  23619. case "SphereBufferGeometry":
  23620. geometry = new Geometries[data.type](
  23621. data.radius,
  23622. data.widthSegments,
  23623. data.heightSegments,
  23624. data.phiStart,
  23625. data.phiLength,
  23626. data.thetaStart,
  23627. data.thetaLength
  23628. );
  23629. break;
  23630. case "DodecahedronGeometry":
  23631. case "DodecahedronBufferGeometry":
  23632. case "IcosahedronGeometry":
  23633. case "IcosahedronBufferGeometry":
  23634. case "OctahedronGeometry":
  23635. case "OctahedronBufferGeometry":
  23636. case "TetrahedronGeometry":
  23637. case "TetrahedronBufferGeometry":
  23638. geometry = new Geometries[data.type](
  23639. data.radius,
  23640. data.detail
  23641. );
  23642. break;
  23643. case "RingGeometry":
  23644. case "RingBufferGeometry":
  23645. geometry = new Geometries[data.type](
  23646. data.innerRadius,
  23647. data.outerRadius,
  23648. data.thetaSegments,
  23649. data.phiSegments,
  23650. data.thetaStart,
  23651. data.thetaLength
  23652. );
  23653. break;
  23654. case "TorusGeometry":
  23655. case "TorusBufferGeometry":
  23656. geometry = new Geometries[data.type](
  23657. data.radius,
  23658. data.tube,
  23659. data.radialSegments,
  23660. data.tubularSegments,
  23661. data.arc
  23662. );
  23663. break;
  23664. case "TorusKnotGeometry":
  23665. case "TorusKnotBufferGeometry":
  23666. geometry = new Geometries[data.type](
  23667. data.radius,
  23668. data.tube,
  23669. data.tubularSegments,
  23670. data.radialSegments,
  23671. data.p,
  23672. data.q
  23673. );
  23674. break;
  23675. case "TubeGeometry":
  23676. case "TubeBufferGeometry":
  23677. geometry = new Geometries[data.type](
  23678. new Curves[data.path.type]().fromJSON(data.path),
  23679. data.tubularSegments,
  23680. data.radius,
  23681. data.radialSegments,
  23682. data.closed
  23683. );
  23684. break;
  23685. case "LatheGeometry":
  23686. case "LatheBufferGeometry":
  23687. geometry = new Geometries[data.type](
  23688. data.points,
  23689. data.segments,
  23690. data.phiStart,
  23691. data.phiLength
  23692. );
  23693. break;
  23694. case "PolyhedronGeometry":
  23695. case "PolyhedronBufferGeometry":
  23696. geometry = new Geometries[data.type](
  23697. data.vertices,
  23698. data.indices,
  23699. data.radius,
  23700. data.details
  23701. );
  23702. break;
  23703. case "ShapeGeometry":
  23704. case "ShapeBufferGeometry":
  23705. var geometryShapes = [];
  23706. for (var j = 0, jl = data.shapes.length; j < jl; j++) {
  23707. var shape = shapes[data.shapes[j]];
  23708. geometryShapes.push(shape);
  23709. }
  23710. geometry = new Geometries[data.type](
  23711. geometryShapes,
  23712. data.curveSegments
  23713. );
  23714. break;
  23715. case "ExtrudeGeometry":
  23716. case "ExtrudeBufferGeometry":
  23717. var geometryShapes = [];
  23718. for (var j = 0, jl = data.shapes.length; j < jl; j++) {
  23719. var shape = shapes[data.shapes[j]];
  23720. geometryShapes.push(shape);
  23721. }
  23722. var extrudePath = data.options.extrudePath;
  23723. if (extrudePath !== void 0) {
  23724. data.options.extrudePath = new Curves[extrudePath.type]().fromJSON(extrudePath);
  23725. }
  23726. geometry = new Geometries[data.type](
  23727. geometryShapes,
  23728. data.options
  23729. );
  23730. break;
  23731. case "BufferGeometry":
  23732. case "InstancedBufferGeometry":
  23733. geometry = bufferGeometryLoader.parse(data);
  23734. break;
  23735. case "Geometry":
  23736. if ("THREE" in window && "LegacyJSONLoader" in THREE) {
  23737. var geometryLoader = new THREE.LegacyJSONLoader();
  23738. geometry = geometryLoader.parse(data, this.resourcePath).geometry;
  23739. } else {
  23740. console.error('THREE.ObjectLoader: You have to import LegacyJSONLoader in order load geometry data of type "Geometry".');
  23741. }
  23742. break;
  23743. default:
  23744. console.warn('THREE.ObjectLoader: Unsupported geometry type "' + data.type + '"');
  23745. continue;
  23746. }
  23747. geometry.uuid = data.uuid;
  23748. if (data.name !== void 0)
  23749. geometry.name = data.name;
  23750. if (geometry.isBufferGeometry === true && data.userData !== void 0)
  23751. geometry.userData = data.userData;
  23752. geometries[data.uuid] = geometry;
  23753. }
  23754. }
  23755. return geometries;
  23756. },
  23757. parseMaterials: function(json, textures) {
  23758. var cache = {};
  23759. var materials = {};
  23760. if (json !== void 0) {
  23761. var loader = new MaterialLoader();
  23762. loader.setTextures(textures);
  23763. for (var i2 = 0, l = json.length; i2 < l; i2++) {
  23764. var data = json[i2];
  23765. if (data.type === "MultiMaterial") {
  23766. var array = [];
  23767. for (var j = 0; j < data.materials.length; j++) {
  23768. var material = data.materials[j];
  23769. if (cache[material.uuid] === void 0) {
  23770. cache[material.uuid] = loader.parse(material);
  23771. }
  23772. array.push(cache[material.uuid]);
  23773. }
  23774. materials[data.uuid] = array;
  23775. } else {
  23776. if (cache[data.uuid] === void 0) {
  23777. cache[data.uuid] = loader.parse(data);
  23778. }
  23779. materials[data.uuid] = cache[data.uuid];
  23780. }
  23781. }
  23782. }
  23783. return materials;
  23784. },
  23785. parseAnimations: function(json) {
  23786. var animations = [];
  23787. for (var i2 = 0; i2 < json.length; i2++) {
  23788. var data = json[i2];
  23789. var clip = AnimationClip.parse(data);
  23790. if (data.uuid !== void 0)
  23791. clip.uuid = data.uuid;
  23792. animations.push(clip);
  23793. }
  23794. return animations;
  23795. },
  23796. parseImages: function(json, onLoad) {
  23797. var scope = this;
  23798. var images = {};
  23799. function loadImage(url2) {
  23800. scope.manager.itemStart(url2);
  23801. return loader.load(url2, function() {
  23802. scope.manager.itemEnd(url2);
  23803. }, void 0, function() {
  23804. scope.manager.itemError(url2);
  23805. scope.manager.itemEnd(url2);
  23806. });
  23807. }
  23808. if (json !== void 0 && json.length > 0) {
  23809. var manager = new LoadingManager(onLoad);
  23810. var loader = new ImageLoader(manager);
  23811. loader.setCrossOrigin(this.crossOrigin);
  23812. for (var i2 = 0, il = json.length; i2 < il; i2++) {
  23813. var image = json[i2];
  23814. var url = image.url;
  23815. if (Array.isArray(url)) {
  23816. images[image.uuid] = [];
  23817. for (var j = 0, jl = url.length; j < jl; j++) {
  23818. var currentUrl = url[j];
  23819. var path = /^(\/\/)|([a-z]+:(\/\/)?)/i.test(currentUrl) ? currentUrl : scope.resourcePath + currentUrl;
  23820. images[image.uuid].push(loadImage(path));
  23821. }
  23822. } else {
  23823. var path = /^(\/\/)|([a-z]+:(\/\/)?)/i.test(image.url) ? image.url : scope.resourcePath + image.url;
  23824. images[image.uuid] = loadImage(path);
  23825. }
  23826. }
  23827. }
  23828. return images;
  23829. },
  23830. parseTextures: function(json, images) {
  23831. function parseConstant(value, type) {
  23832. if (typeof value === "number")
  23833. return value;
  23834. console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.", value);
  23835. return type[value];
  23836. }
  23837. var textures = {};
  23838. if (json !== void 0) {
  23839. for (var i2 = 0, l = json.length; i2 < l; i2++) {
  23840. var data = json[i2];
  23841. if (data.image === void 0) {
  23842. console.warn('THREE.ObjectLoader: No "image" specified for', data.uuid);
  23843. }
  23844. if (images[data.image] === void 0) {
  23845. console.warn("THREE.ObjectLoader: Undefined image", data.image);
  23846. }
  23847. var texture;
  23848. if (Array.isArray(images[data.image])) {
  23849. texture = new CubeTexture(images[data.image]);
  23850. } else {
  23851. texture = new Texture(images[data.image]);
  23852. }
  23853. texture.needsUpdate = true;
  23854. texture.uuid = data.uuid;
  23855. if (data.name !== void 0)
  23856. texture.name = data.name;
  23857. if (data.mapping !== void 0)
  23858. texture.mapping = parseConstant(data.mapping, TEXTURE_MAPPING);
  23859. if (data.offset !== void 0)
  23860. texture.offset.fromArray(data.offset);
  23861. if (data.repeat !== void 0)
  23862. texture.repeat.fromArray(data.repeat);
  23863. if (data.center !== void 0)
  23864. texture.center.fromArray(data.center);
  23865. if (data.rotation !== void 0)
  23866. texture.rotation = data.rotation;
  23867. if (data.wrap !== void 0) {
  23868. texture.wrapS = parseConstant(data.wrap[0], TEXTURE_WRAPPING);
  23869. texture.wrapT = parseConstant(data.wrap[1], TEXTURE_WRAPPING);
  23870. }
  23871. if (data.format !== void 0)
  23872. texture.format = data.format;
  23873. if (data.type !== void 0)
  23874. texture.type = data.type;
  23875. if (data.encoding !== void 0)
  23876. texture.encoding = data.encoding;
  23877. if (data.minFilter !== void 0)
  23878. texture.minFilter = parseConstant(data.minFilter, TEXTURE_FILTER);
  23879. if (data.magFilter !== void 0)
  23880. texture.magFilter = parseConstant(data.magFilter, TEXTURE_FILTER);
  23881. if (data.anisotropy !== void 0)
  23882. texture.anisotropy = data.anisotropy;
  23883. if (data.flipY !== void 0)
  23884. texture.flipY = data.flipY;
  23885. if (data.premultiplyAlpha !== void 0)
  23886. texture.premultiplyAlpha = data.premultiplyAlpha;
  23887. if (data.unpackAlignment !== void 0)
  23888. texture.unpackAlignment = data.unpackAlignment;
  23889. textures[data.uuid] = texture;
  23890. }
  23891. }
  23892. return textures;
  23893. },
  23894. parseObject: function(data, geometries, materials) {
  23895. var object;
  23896. function getGeometry(name) {
  23897. if (geometries[name] === void 0) {
  23898. console.warn("THREE.ObjectLoader: Undefined geometry", name);
  23899. }
  23900. return geometries[name];
  23901. }
  23902. function getMaterial(name) {
  23903. if (name === void 0)
  23904. return void 0;
  23905. if (Array.isArray(name)) {
  23906. var array = [];
  23907. for (var i3 = 0, l2 = name.length; i3 < l2; i3++) {
  23908. var uuid = name[i3];
  23909. if (materials[uuid] === void 0) {
  23910. console.warn("THREE.ObjectLoader: Undefined material", uuid);
  23911. }
  23912. array.push(materials[uuid]);
  23913. }
  23914. return array;
  23915. }
  23916. if (materials[name] === void 0) {
  23917. console.warn("THREE.ObjectLoader: Undefined material", name);
  23918. }
  23919. return materials[name];
  23920. }
  23921. switch (data.type) {
  23922. case "Scene":
  23923. object = new Scene();
  23924. if (data.background !== void 0) {
  23925. if (Number.isInteger(data.background)) {
  23926. object.background = new Color(data.background);
  23927. }
  23928. }
  23929. if (data.fog !== void 0) {
  23930. if (data.fog.type === "Fog") {
  23931. object.fog = new Fog(data.fog.color, data.fog.near, data.fog.far);
  23932. } else if (data.fog.type === "FogExp2") {
  23933. object.fog = new FogExp2(data.fog.color, data.fog.density);
  23934. }
  23935. }
  23936. break;
  23937. case "PerspectiveCamera":
  23938. object = new PerspectiveCamera(data.fov, data.aspect, data.near, data.far);
  23939. if (data.focus !== void 0)
  23940. object.focus = data.focus;
  23941. if (data.zoom !== void 0)
  23942. object.zoom = data.zoom;
  23943. if (data.filmGauge !== void 0)
  23944. object.filmGauge = data.filmGauge;
  23945. if (data.filmOffset !== void 0)
  23946. object.filmOffset = data.filmOffset;
  23947. if (data.view !== void 0)
  23948. object.view = Object.assign({}, data.view);
  23949. break;
  23950. case "OrthographicCamera":
  23951. object = new OrthographicCamera(data.left, data.right, data.top, data.bottom, data.near, data.far);
  23952. if (data.zoom !== void 0)
  23953. object.zoom = data.zoom;
  23954. if (data.view !== void 0)
  23955. object.view = Object.assign({}, data.view);
  23956. break;
  23957. case "AmbientLight":
  23958. object = new AmbientLight(data.color, data.intensity);
  23959. break;
  23960. case "DirectionalLight":
  23961. object = new DirectionalLight(data.color, data.intensity);
  23962. break;
  23963. case "PointLight":
  23964. object = new PointLight(data.color, data.intensity, data.distance, data.decay);
  23965. break;
  23966. case "RectAreaLight":
  23967. object = new RectAreaLight(data.color, data.intensity, data.width, data.height);
  23968. break;
  23969. case "SpotLight":
  23970. object = new SpotLight(data.color, data.intensity, data.distance, data.angle, data.penumbra, data.decay);
  23971. break;
  23972. case "HemisphereLight":
  23973. object = new HemisphereLight(data.color, data.groundColor, data.intensity);
  23974. break;
  23975. case "SkinnedMesh":
  23976. console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.");
  23977. case "Mesh":
  23978. var geometry = getGeometry(data.geometry);
  23979. var material = getMaterial(data.material);
  23980. if (geometry.bones && geometry.bones.length > 0) {
  23981. object = new SkinnedMesh(geometry, material);
  23982. } else {
  23983. object = new Mesh(geometry, material);
  23984. }
  23985. break;
  23986. case "InstancedMesh":
  23987. var geometry = getGeometry(data.geometry);
  23988. var material = getMaterial(data.material);
  23989. var count = data.count;
  23990. var instanceMatrix = data.instanceMatrix;
  23991. object = new InstancedMesh(geometry, material, count);
  23992. object.instanceMatrix = new BufferAttribute(new Float32Array(instanceMatrix.array), 16);
  23993. break;
  23994. case "LOD":
  23995. object = new LOD();
  23996. break;
  23997. case "Line":
  23998. object = new Line(getGeometry(data.geometry), getMaterial(data.material), data.mode);
  23999. break;
  24000. case "LineLoop":
  24001. object = new LineLoop(getGeometry(data.geometry), getMaterial(data.material));
  24002. break;
  24003. case "LineSegments":
  24004. object = new LineSegments(getGeometry(data.geometry), getMaterial(data.material));
  24005. break;
  24006. case "PointCloud":
  24007. case "Points":
  24008. object = new Points(getGeometry(data.geometry), getMaterial(data.material));
  24009. break;
  24010. case "Sprite":
  24011. object = new Sprite(getMaterial(data.material));
  24012. break;
  24013. case "Group":
  24014. object = new Group();
  24015. break;
  24016. default:
  24017. object = new Object3D();
  24018. }
  24019. object.uuid = data.uuid;
  24020. if (data.name !== void 0)
  24021. object.name = data.name;
  24022. if (data.matrix !== void 0) {
  24023. object.matrix.fromArray(data.matrix);
  24024. if (data.matrixAutoUpdate !== void 0)
  24025. object.matrixAutoUpdate = data.matrixAutoUpdate;
  24026. if (object.matrixAutoUpdate)
  24027. object.matrix.decompose(object.position, object.quaternion, object.scale);
  24028. } else {
  24029. if (data.position !== void 0)
  24030. object.position.fromArray(data.position);
  24031. if (data.rotation !== void 0)
  24032. object.rotation.fromArray(data.rotation);
  24033. if (data.quaternion !== void 0)
  24034. object.quaternion.fromArray(data.quaternion);
  24035. if (data.scale !== void 0)
  24036. object.scale.fromArray(data.scale);
  24037. }
  24038. if (data.castShadow !== void 0)
  24039. object.castShadow = data.castShadow;
  24040. if (data.receiveShadow !== void 0)
  24041. object.receiveShadow = data.receiveShadow;
  24042. if (data.shadow) {
  24043. if (data.shadow.bias !== void 0)
  24044. object.shadow.bias = data.shadow.bias;
  24045. if (data.shadow.radius !== void 0)
  24046. object.shadow.radius = data.shadow.radius;
  24047. if (data.shadow.mapSize !== void 0)
  24048. object.shadow.mapSize.fromArray(data.shadow.mapSize);
  24049. if (data.shadow.camera !== void 0)
  24050. object.shadow.camera = this.parseObject(data.shadow.camera);
  24051. }
  24052. if (data.visible !== void 0)
  24053. object.visible = data.visible;
  24054. if (data.frustumCulled !== void 0)
  24055. object.frustumCulled = data.frustumCulled;
  24056. if (data.renderOrder !== void 0)
  24057. object.renderOrder = data.renderOrder;
  24058. if (data.userData !== void 0)
  24059. object.userData = data.userData;
  24060. if (data.layers !== void 0)
  24061. object.layers.mask = data.layers;
  24062. if (data.children !== void 0) {
  24063. var children = data.children;
  24064. for (var i2 = 0; i2 < children.length; i2++) {
  24065. object.add(this.parseObject(children[i2], geometries, materials));
  24066. }
  24067. }
  24068. if (data.type === "LOD") {
  24069. if (data.autoUpdate !== void 0)
  24070. object.autoUpdate = data.autoUpdate;
  24071. var levels = data.levels;
  24072. for (var l = 0; l < levels.length; l++) {
  24073. var level = levels[l];
  24074. var child = object.getObjectByProperty("uuid", level.object);
  24075. if (child !== void 0) {
  24076. object.addLevel(child, level.distance);
  24077. }
  24078. }
  24079. }
  24080. return object;
  24081. }
  24082. });
  24083. var TEXTURE_MAPPING = {
  24084. UVMapping,
  24085. CubeReflectionMapping,
  24086. CubeRefractionMapping,
  24087. EquirectangularReflectionMapping,
  24088. EquirectangularRefractionMapping,
  24089. SphericalReflectionMapping,
  24090. CubeUVReflectionMapping,
  24091. CubeUVRefractionMapping
  24092. };
  24093. var TEXTURE_WRAPPING = {
  24094. RepeatWrapping,
  24095. ClampToEdgeWrapping,
  24096. MirroredRepeatWrapping
  24097. };
  24098. var TEXTURE_FILTER = {
  24099. NearestFilter,
  24100. NearestMipmapNearestFilter,
  24101. NearestMipmapLinearFilter,
  24102. LinearFilter,
  24103. LinearMipmapNearestFilter,
  24104. LinearMipmapLinearFilter
  24105. };
  24106. function ImageBitmapLoader(manager) {
  24107. if (typeof createImageBitmap === "undefined") {
  24108. console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported.");
  24109. }
  24110. if (typeof fetch === "undefined") {
  24111. console.warn("THREE.ImageBitmapLoader: fetch() not supported.");
  24112. }
  24113. Loader.call(this, manager);
  24114. this.options = void 0;
  24115. }
  24116. ImageBitmapLoader.prototype = Object.assign(Object.create(Loader.prototype), {
  24117. constructor: ImageBitmapLoader,
  24118. setOptions: function setOptions(options) {
  24119. this.options = options;
  24120. return this;
  24121. },
  24122. load: function(url, onLoad, onProgress, onError) {
  24123. if (url === void 0)
  24124. url = "";
  24125. if (this.path !== void 0)
  24126. url = this.path + url;
  24127. url = this.manager.resolveURL(url);
  24128. var scope = this;
  24129. var cached = Cache.get(url);
  24130. if (cached !== void 0) {
  24131. scope.manager.itemStart(url);
  24132. setTimeout(function() {
  24133. if (onLoad)
  24134. onLoad(cached);
  24135. scope.manager.itemEnd(url);
  24136. }, 0);
  24137. return cached;
  24138. }
  24139. fetch(url).then(function(res) {
  24140. return res.blob();
  24141. }).then(function(blob) {
  24142. if (scope.options === void 0) {
  24143. return createImageBitmap(blob);
  24144. } else {
  24145. return createImageBitmap(blob, scope.options);
  24146. }
  24147. }).then(function(imageBitmap) {
  24148. Cache.add(url, imageBitmap);
  24149. if (onLoad)
  24150. onLoad(imageBitmap);
  24151. scope.manager.itemEnd(url);
  24152. }).catch(function(e) {
  24153. if (onError)
  24154. onError(e);
  24155. scope.manager.itemError(url);
  24156. scope.manager.itemEnd(url);
  24157. });
  24158. scope.manager.itemStart(url);
  24159. }
  24160. });
  24161. function ShapePath() {
  24162. this.type = "ShapePath";
  24163. this.color = new Color();
  24164. this.subPaths = [];
  24165. this.currentPath = null;
  24166. }
  24167. Object.assign(ShapePath.prototype, {
  24168. moveTo: function(x, y) {
  24169. this.currentPath = new Path();
  24170. this.subPaths.push(this.currentPath);
  24171. this.currentPath.moveTo(x, y);
  24172. return this;
  24173. },
  24174. lineTo: function(x, y) {
  24175. this.currentPath.lineTo(x, y);
  24176. return this;
  24177. },
  24178. quadraticCurveTo: function(aCPx, aCPy, aX, aY) {
  24179. this.currentPath.quadraticCurveTo(aCPx, aCPy, aX, aY);
  24180. return this;
  24181. },
  24182. bezierCurveTo: function(aCP1x, aCP1y, aCP2x, aCP2y, aX, aY) {
  24183. this.currentPath.bezierCurveTo(aCP1x, aCP1y, aCP2x, aCP2y, aX, aY);
  24184. return this;
  24185. },
  24186. splineThru: function(pts) {
  24187. this.currentPath.splineThru(pts);
  24188. return this;
  24189. },
  24190. toShapes: function(isCCW, noHoles) {
  24191. function toShapesNoHoles(inSubpaths) {
  24192. var shapes2 = [];
  24193. for (var i3 = 0, l2 = inSubpaths.length; i3 < l2; i3++) {
  24194. var tmpPath2 = inSubpaths[i3];
  24195. var tmpShape2 = new Shape();
  24196. tmpShape2.curves = tmpPath2.curves;
  24197. shapes2.push(tmpShape2);
  24198. }
  24199. return shapes2;
  24200. }
  24201. function isPointInsidePolygon(inPt, inPolygon) {
  24202. var polyLen = inPolygon.length;
  24203. var inside = false;
  24204. for (var p = polyLen - 1, q = 0; q < polyLen; p = q++) {
  24205. var edgeLowPt = inPolygon[p];
  24206. var edgeHighPt = inPolygon[q];
  24207. var edgeDx = edgeHighPt.x - edgeLowPt.x;
  24208. var edgeDy = edgeHighPt.y - edgeLowPt.y;
  24209. if (Math.abs(edgeDy) > Number.EPSILON) {
  24210. if (edgeDy < 0) {
  24211. edgeLowPt = inPolygon[q];
  24212. edgeDx = -edgeDx;
  24213. edgeHighPt = inPolygon[p];
  24214. edgeDy = -edgeDy;
  24215. }
  24216. if (inPt.y < edgeLowPt.y || inPt.y > edgeHighPt.y)
  24217. continue;
  24218. if (inPt.y === edgeLowPt.y) {
  24219. if (inPt.x === edgeLowPt.x)
  24220. return true;
  24221. } else {
  24222. var perpEdge = edgeDy * (inPt.x - edgeLowPt.x) - edgeDx * (inPt.y - edgeLowPt.y);
  24223. if (perpEdge === 0)
  24224. return true;
  24225. if (perpEdge < 0)
  24226. continue;
  24227. inside = !inside;
  24228. }
  24229. } else {
  24230. if (inPt.y !== edgeLowPt.y)
  24231. continue;
  24232. if (edgeHighPt.x <= inPt.x && inPt.x <= edgeLowPt.x || edgeLowPt.x <= inPt.x && inPt.x <= edgeHighPt.x)
  24233. return true;
  24234. }
  24235. }
  24236. return inside;
  24237. }
  24238. var isClockWise = ShapeUtils.isClockWise;
  24239. var subPaths = this.subPaths;
  24240. if (subPaths.length === 0)
  24241. return [];
  24242. if (noHoles === true)
  24243. return toShapesNoHoles(subPaths);
  24244. var solid, tmpPath, tmpShape, shapes = [];
  24245. if (subPaths.length === 1) {
  24246. tmpPath = subPaths[0];
  24247. tmpShape = new Shape();
  24248. tmpShape.curves = tmpPath.curves;
  24249. shapes.push(tmpShape);
  24250. return shapes;
  24251. }
  24252. var holesFirst = !isClockWise(subPaths[0].getPoints());
  24253. holesFirst = isCCW ? !holesFirst : holesFirst;
  24254. var betterShapeHoles = [];
  24255. var newShapes = [];
  24256. var newShapeHoles = [];
  24257. var mainIdx = 0;
  24258. var tmpPoints;
  24259. newShapes[mainIdx] = void 0;
  24260. newShapeHoles[mainIdx] = [];
  24261. for (var i2 = 0, l = subPaths.length; i2 < l; i2++) {
  24262. tmpPath = subPaths[i2];
  24263. tmpPoints = tmpPath.getPoints();
  24264. solid = isClockWise(tmpPoints);
  24265. solid = isCCW ? !solid : solid;
  24266. if (solid) {
  24267. if (!holesFirst && newShapes[mainIdx])
  24268. mainIdx++;
  24269. newShapes[mainIdx] = { s: new Shape(), p: tmpPoints };
  24270. newShapes[mainIdx].s.curves = tmpPath.curves;
  24271. if (holesFirst)
  24272. mainIdx++;
  24273. newShapeHoles[mainIdx] = [];
  24274. } else {
  24275. newShapeHoles[mainIdx].push({ h: tmpPath, p: tmpPoints[0] });
  24276. }
  24277. }
  24278. if (!newShapes[0])
  24279. return toShapesNoHoles(subPaths);
  24280. if (newShapes.length > 1) {
  24281. var ambiguous = false;
  24282. var toChange = [];
  24283. for (var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx++) {
  24284. betterShapeHoles[sIdx] = [];
  24285. }
  24286. for (var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx++) {
  24287. var sho = newShapeHoles[sIdx];
  24288. for (var hIdx = 0; hIdx < sho.length; hIdx++) {
  24289. var ho = sho[hIdx];
  24290. var hole_unassigned = true;
  24291. for (var s2Idx = 0; s2Idx < newShapes.length; s2Idx++) {
  24292. if (isPointInsidePolygon(ho.p, newShapes[s2Idx].p)) {
  24293. if (sIdx !== s2Idx)
  24294. toChange.push({ froms: sIdx, tos: s2Idx, hole: hIdx });
  24295. if (hole_unassigned) {
  24296. hole_unassigned = false;
  24297. betterShapeHoles[s2Idx].push(ho);
  24298. } else {
  24299. ambiguous = true;
  24300. }
  24301. }
  24302. }
  24303. if (hole_unassigned) {
  24304. betterShapeHoles[sIdx].push(ho);
  24305. }
  24306. }
  24307. }
  24308. if (toChange.length > 0) {
  24309. if (!ambiguous)
  24310. newShapeHoles = betterShapeHoles;
  24311. }
  24312. }
  24313. var tmpHoles;
  24314. for (var i2 = 0, il = newShapes.length; i2 < il; i2++) {
  24315. tmpShape = newShapes[i2].s;
  24316. shapes.push(tmpShape);
  24317. tmpHoles = newShapeHoles[i2];
  24318. for (var j = 0, jl = tmpHoles.length; j < jl; j++) {
  24319. tmpShape.holes.push(tmpHoles[j].h);
  24320. }
  24321. }
  24322. return shapes;
  24323. }
  24324. });
  24325. function Font(data) {
  24326. this.type = "Font";
  24327. this.data = data;
  24328. }
  24329. Object.assign(Font.prototype, {
  24330. isFont: true,
  24331. generateShapes: function(text, size) {
  24332. if (size === void 0)
  24333. size = 100;
  24334. var shapes = [];
  24335. var paths = createPaths(text, size, this.data);
  24336. for (var p = 0, pl = paths.length; p < pl; p++) {
  24337. Array.prototype.push.apply(shapes, paths[p].toShapes());
  24338. }
  24339. return shapes;
  24340. }
  24341. });
  24342. function createPaths(text, size, data) {
  24343. var chars = Array.from ? Array.from(text) : String(text).split("");
  24344. var scale = size / data.resolution;
  24345. var line_height = (data.boundingBox.yMax - data.boundingBox.yMin + data.underlineThickness) * scale;
  24346. var paths = [];
  24347. var offsetX = 0, offsetY = 0;
  24348. for (var i2 = 0; i2 < chars.length; i2++) {
  24349. var char = chars[i2];
  24350. if (char === "\n") {
  24351. offsetX = 0;
  24352. offsetY -= line_height;
  24353. } else {
  24354. var ret = createPath(char, scale, offsetX, offsetY, data);
  24355. offsetX += ret.offsetX;
  24356. paths.push(ret.path);
  24357. }
  24358. }
  24359. return paths;
  24360. }
  24361. function createPath(char, scale, offsetX, offsetY, data) {
  24362. var glyph = data.glyphs[char] || data.glyphs["?"];
  24363. if (!glyph) {
  24364. console.error('THREE.Font: character "' + char + '" does not exists in font family ' + data.familyName + ".");
  24365. return;
  24366. }
  24367. var path = new ShapePath();
  24368. var x, y, cpx, cpy, cpx1, cpy1, cpx2, cpy2;
  24369. if (glyph.o) {
  24370. var outline = glyph._cachedOutline || (glyph._cachedOutline = glyph.o.split(" "));
  24371. for (var i2 = 0, l = outline.length; i2 < l; ) {
  24372. var action = outline[i2++];
  24373. switch (action) {
  24374. case "m":
  24375. x = outline[i2++] * scale + offsetX;
  24376. y = outline[i2++] * scale + offsetY;
  24377. path.moveTo(x, y);
  24378. break;
  24379. case "l":
  24380. x = outline[i2++] * scale + offsetX;
  24381. y = outline[i2++] * scale + offsetY;
  24382. path.lineTo(x, y);
  24383. break;
  24384. case "q":
  24385. cpx = outline[i2++] * scale + offsetX;
  24386. cpy = outline[i2++] * scale + offsetY;
  24387. cpx1 = outline[i2++] * scale + offsetX;
  24388. cpy1 = outline[i2++] * scale + offsetY;
  24389. path.quadraticCurveTo(cpx1, cpy1, cpx, cpy);
  24390. break;
  24391. case "b":
  24392. cpx = outline[i2++] * scale + offsetX;
  24393. cpy = outline[i2++] * scale + offsetY;
  24394. cpx1 = outline[i2++] * scale + offsetX;
  24395. cpy1 = outline[i2++] * scale + offsetY;
  24396. cpx2 = outline[i2++] * scale + offsetX;
  24397. cpy2 = outline[i2++] * scale + offsetY;
  24398. path.bezierCurveTo(cpx1, cpy1, cpx2, cpy2, cpx, cpy);
  24399. break;
  24400. }
  24401. }
  24402. }
  24403. return { offsetX: glyph.ha * scale, path };
  24404. }
  24405. function FontLoader(manager) {
  24406. Loader.call(this, manager);
  24407. }
  24408. FontLoader.prototype = Object.assign(Object.create(Loader.prototype), {
  24409. constructor: FontLoader,
  24410. load: function(url, onLoad, onProgress, onError) {
  24411. var scope = this;
  24412. var loader = new FileLoader(this.manager);
  24413. loader.setPath(this.path);
  24414. loader.load(url, function(text) {
  24415. var json;
  24416. try {
  24417. json = JSON.parse(text);
  24418. } catch (e) {
  24419. console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead.");
  24420. json = JSON.parse(text.substring(65, text.length - 2));
  24421. }
  24422. var font = scope.parse(json);
  24423. if (onLoad)
  24424. onLoad(font);
  24425. }, onProgress, onError);
  24426. },
  24427. parse: function(json) {
  24428. return new Font(json);
  24429. }
  24430. });
  24431. var _context;
  24432. var AudioContext = {
  24433. getContext: function() {
  24434. if (_context === void 0) {
  24435. _context = new (window.AudioContext || window.webkitAudioContext)();
  24436. }
  24437. return _context;
  24438. },
  24439. setContext: function(value) {
  24440. _context = value;
  24441. }
  24442. };
  24443. function AudioLoader(manager) {
  24444. Loader.call(this, manager);
  24445. }
  24446. AudioLoader.prototype = Object.assign(Object.create(Loader.prototype), {
  24447. constructor: AudioLoader,
  24448. load: function(url, onLoad, onProgress, onError) {
  24449. var loader = new FileLoader(this.manager);
  24450. loader.setResponseType("arraybuffer");
  24451. loader.setPath(this.path);
  24452. loader.load(url, function(buffer) {
  24453. var bufferCopy = buffer.slice(0);
  24454. var context = AudioContext.getContext();
  24455. context.decodeAudioData(bufferCopy, function(audioBuffer) {
  24456. onLoad(audioBuffer);
  24457. });
  24458. }, onProgress, onError);
  24459. }
  24460. });
  24461. function SphericalHarmonics3() {
  24462. this.coefficients = [];
  24463. for (var i2 = 0; i2 < 9; i2++) {
  24464. this.coefficients.push(new Vector3());
  24465. }
  24466. }
  24467. Object.assign(SphericalHarmonics3.prototype, {
  24468. isSphericalHarmonics3: true,
  24469. set: function(coefficients) {
  24470. for (var i2 = 0; i2 < 9; i2++) {
  24471. this.coefficients[i2].copy(coefficients[i2]);
  24472. }
  24473. return this;
  24474. },
  24475. zero: function() {
  24476. for (var i2 = 0; i2 < 9; i2++) {
  24477. this.coefficients[i2].set(0, 0, 0);
  24478. }
  24479. return this;
  24480. },
  24481. // get the radiance in the direction of the normal
  24482. // target is a Vector3
  24483. getAt: function(normal, target) {
  24484. var x = normal.x, y = normal.y, z = normal.z;
  24485. var coeff = this.coefficients;
  24486. target.copy(coeff[0]).multiplyScalar(0.282095);
  24487. target.addScale(coeff[1], 0.488603 * y);
  24488. target.addScale(coeff[2], 0.488603 * z);
  24489. target.addScale(coeff[3], 0.488603 * x);
  24490. target.addScale(coeff[4], 1.092548 * (x * y));
  24491. target.addScale(coeff[5], 1.092548 * (y * z));
  24492. target.addScale(coeff[6], 0.315392 * (3 * z * z - 1));
  24493. target.addScale(coeff[7], 1.092548 * (x * z));
  24494. target.addScale(coeff[8], 0.546274 * (x * x - y * y));
  24495. return target;
  24496. },
  24497. // get the irradiance (radiance convolved with cosine lobe) in the direction of the normal
  24498. // target is a Vector3
  24499. // https://graphics.stanford.edu/papers/envmap/envmap.pdf
  24500. getIrradianceAt: function(normal, target) {
  24501. var x = normal.x, y = normal.y, z = normal.z;
  24502. var coeff = this.coefficients;
  24503. target.copy(coeff[0]).multiplyScalar(0.886227);
  24504. target.addScale(coeff[1], 2 * 0.511664 * y);
  24505. target.addScale(coeff[2], 2 * 0.511664 * z);
  24506. target.addScale(coeff[3], 2 * 0.511664 * x);
  24507. target.addScale(coeff[4], 2 * 0.429043 * x * y);
  24508. target.addScale(coeff[5], 2 * 0.429043 * y * z);
  24509. target.addScale(coeff[6], 0.743125 * z * z - 0.247708);
  24510. target.addScale(coeff[7], 2 * 0.429043 * x * z);
  24511. target.addScale(coeff[8], 0.429043 * (x * x - y * y));
  24512. return target;
  24513. },
  24514. add: function(sh) {
  24515. for (var i2 = 0; i2 < 9; i2++) {
  24516. this.coefficients[i2].add(sh.coefficients[i2]);
  24517. }
  24518. return this;
  24519. },
  24520. scale: function(s) {
  24521. for (var i2 = 0; i2 < 9; i2++) {
  24522. this.coefficients[i2].multiplyScalar(s);
  24523. }
  24524. return this;
  24525. },
  24526. lerp: function(sh, alpha) {
  24527. for (var i2 = 0; i2 < 9; i2++) {
  24528. this.coefficients[i2].lerp(sh.coefficients[i2], alpha);
  24529. }
  24530. return this;
  24531. },
  24532. equals: function(sh) {
  24533. for (var i2 = 0; i2 < 9; i2++) {
  24534. if (!this.coefficients[i2].equals(sh.coefficients[i2])) {
  24535. return false;
  24536. }
  24537. }
  24538. return true;
  24539. },
  24540. copy: function(sh) {
  24541. return this.set(sh.coefficients);
  24542. },
  24543. clone: function() {
  24544. return new this.constructor().copy(this);
  24545. },
  24546. fromArray: function(array, offset) {
  24547. if (offset === void 0)
  24548. offset = 0;
  24549. var coefficients = this.coefficients;
  24550. for (var i2 = 0; i2 < 9; i2++) {
  24551. coefficients[i2].fromArray(array, offset + i2 * 3);
  24552. }
  24553. return this;
  24554. },
  24555. toArray: function(array, offset) {
  24556. if (array === void 0)
  24557. array = [];
  24558. if (offset === void 0)
  24559. offset = 0;
  24560. var coefficients = this.coefficients;
  24561. for (var i2 = 0; i2 < 9; i2++) {
  24562. coefficients[i2].toArray(array, offset + i2 * 3);
  24563. }
  24564. return array;
  24565. }
  24566. });
  24567. Object.assign(SphericalHarmonics3, {
  24568. // evaluate the basis functions
  24569. // shBasis is an Array[ 9 ]
  24570. getBasisAt: function(normal, shBasis) {
  24571. var x = normal.x, y = normal.y, z = normal.z;
  24572. shBasis[0] = 0.282095;
  24573. shBasis[1] = 0.488603 * y;
  24574. shBasis[2] = 0.488603 * z;
  24575. shBasis[3] = 0.488603 * x;
  24576. shBasis[4] = 1.092548 * x * y;
  24577. shBasis[5] = 1.092548 * y * z;
  24578. shBasis[6] = 0.315392 * (3 * z * z - 1);
  24579. shBasis[7] = 1.092548 * x * z;
  24580. shBasis[8] = 0.546274 * (x * x - y * y);
  24581. }
  24582. });
  24583. function LightProbe(sh, intensity) {
  24584. Light.call(this, void 0, intensity);
  24585. this.sh = sh !== void 0 ? sh : new SphericalHarmonics3();
  24586. }
  24587. LightProbe.prototype = Object.assign(Object.create(Light.prototype), {
  24588. constructor: LightProbe,
  24589. isLightProbe: true,
  24590. copy: function(source) {
  24591. Light.prototype.copy.call(this, source);
  24592. this.sh.copy(source.sh);
  24593. this.intensity = source.intensity;
  24594. return this;
  24595. },
  24596. toJSON: function(meta) {
  24597. var data = Light.prototype.toJSON.call(this, meta);
  24598. return data;
  24599. }
  24600. });
  24601. function HemisphereLightProbe(skyColor, groundColor, intensity) {
  24602. LightProbe.call(this, void 0, intensity);
  24603. var color1 = new Color().set(skyColor);
  24604. var color2 = new Color().set(groundColor);
  24605. var sky = new Vector3(color1.r, color1.g, color1.b);
  24606. var ground = new Vector3(color2.r, color2.g, color2.b);
  24607. var c0 = Math.sqrt(Math.PI);
  24608. var c1 = c0 * Math.sqrt(0.75);
  24609. this.sh.coefficients[0].copy(sky).add(ground).multiplyScalar(c0);
  24610. this.sh.coefficients[1].copy(sky).sub(ground).multiplyScalar(c1);
  24611. }
  24612. HemisphereLightProbe.prototype = Object.assign(Object.create(LightProbe.prototype), {
  24613. constructor: HemisphereLightProbe,
  24614. isHemisphereLightProbe: true,
  24615. copy: function(source) {
  24616. LightProbe.prototype.copy.call(this, source);
  24617. return this;
  24618. },
  24619. toJSON: function(meta) {
  24620. var data = LightProbe.prototype.toJSON.call(this, meta);
  24621. return data;
  24622. }
  24623. });
  24624. function AmbientLightProbe(color, intensity) {
  24625. LightProbe.call(this, void 0, intensity);
  24626. var color1 = new Color().set(color);
  24627. this.sh.coefficients[0].set(color1.r, color1.g, color1.b).multiplyScalar(2 * Math.sqrt(Math.PI));
  24628. }
  24629. AmbientLightProbe.prototype = Object.assign(Object.create(LightProbe.prototype), {
  24630. constructor: AmbientLightProbe,
  24631. isAmbientLightProbe: true,
  24632. copy: function(source) {
  24633. LightProbe.prototype.copy.call(this, source);
  24634. return this;
  24635. },
  24636. toJSON: function(meta) {
  24637. var data = LightProbe.prototype.toJSON.call(this, meta);
  24638. return data;
  24639. }
  24640. });
  24641. var _eyeRight = new Matrix4();
  24642. var _eyeLeft = new Matrix4();
  24643. function StereoCamera() {
  24644. this.type = "StereoCamera";
  24645. this.aspect = 1;
  24646. this.eyeSep = 0.064;
  24647. this.cameraL = new PerspectiveCamera();
  24648. this.cameraL.layers.enable(1);
  24649. this.cameraL.matrixAutoUpdate = false;
  24650. this.cameraR = new PerspectiveCamera();
  24651. this.cameraR.layers.enable(2);
  24652. this.cameraR.matrixAutoUpdate = false;
  24653. this._cache = {
  24654. focus: null,
  24655. fov: null,
  24656. aspect: null,
  24657. near: null,
  24658. far: null,
  24659. zoom: null,
  24660. eyeSep: null
  24661. };
  24662. }
  24663. Object.assign(StereoCamera.prototype, {
  24664. update: function(camera) {
  24665. var cache = this._cache;
  24666. var needsUpdate = cache.focus !== camera.focus || cache.fov !== camera.fov || cache.aspect !== camera.aspect * this.aspect || cache.near !== camera.near || cache.far !== camera.far || cache.zoom !== camera.zoom || cache.eyeSep !== this.eyeSep;
  24667. if (needsUpdate) {
  24668. cache.focus = camera.focus;
  24669. cache.fov = camera.fov;
  24670. cache.aspect = camera.aspect * this.aspect;
  24671. cache.near = camera.near;
  24672. cache.far = camera.far;
  24673. cache.zoom = camera.zoom;
  24674. cache.eyeSep = this.eyeSep;
  24675. var projectionMatrix = camera.projectionMatrix.clone();
  24676. var eyeSepHalf = cache.eyeSep / 2;
  24677. var eyeSepOnProjection = eyeSepHalf * cache.near / cache.focus;
  24678. var ymax = cache.near * Math.tan(MathUtils.DEG2RAD * cache.fov * 0.5) / cache.zoom;
  24679. var xmin, xmax;
  24680. _eyeLeft.elements[12] = -eyeSepHalf;
  24681. _eyeRight.elements[12] = eyeSepHalf;
  24682. xmin = -ymax * cache.aspect + eyeSepOnProjection;
  24683. xmax = ymax * cache.aspect + eyeSepOnProjection;
  24684. projectionMatrix.elements[0] = 2 * cache.near / (xmax - xmin);
  24685. projectionMatrix.elements[8] = (xmax + xmin) / (xmax - xmin);
  24686. this.cameraL.projectionMatrix.copy(projectionMatrix);
  24687. xmin = -ymax * cache.aspect - eyeSepOnProjection;
  24688. xmax = ymax * cache.aspect - eyeSepOnProjection;
  24689. projectionMatrix.elements[0] = 2 * cache.near / (xmax - xmin);
  24690. projectionMatrix.elements[8] = (xmax + xmin) / (xmax - xmin);
  24691. this.cameraR.projectionMatrix.copy(projectionMatrix);
  24692. }
  24693. this.cameraL.matrixWorld.copy(camera.matrixWorld).multiply(_eyeLeft);
  24694. this.cameraR.matrixWorld.copy(camera.matrixWorld).multiply(_eyeRight);
  24695. }
  24696. });
  24697. function Clock(autoStart) {
  24698. this.autoStart = autoStart !== void 0 ? autoStart : true;
  24699. this.startTime = 0;
  24700. this.oldTime = 0;
  24701. this.elapsedTime = 0;
  24702. this.running = false;
  24703. }
  24704. Object.assign(Clock.prototype, {
  24705. start: function() {
  24706. this.startTime = (typeof performance === "undefined" ? Date : performance).now();
  24707. this.oldTime = this.startTime;
  24708. this.elapsedTime = 0;
  24709. this.running = true;
  24710. },
  24711. stop: function() {
  24712. this.getElapsedTime();
  24713. this.running = false;
  24714. this.autoStart = false;
  24715. },
  24716. getElapsedTime: function() {
  24717. this.getDelta();
  24718. return this.elapsedTime;
  24719. },
  24720. getDelta: function() {
  24721. var diff = 0;
  24722. if (this.autoStart && !this.running) {
  24723. this.start();
  24724. return 0;
  24725. }
  24726. if (this.running) {
  24727. var newTime = (typeof performance === "undefined" ? Date : performance).now();
  24728. diff = (newTime - this.oldTime) / 1e3;
  24729. this.oldTime = newTime;
  24730. this.elapsedTime += diff;
  24731. }
  24732. return diff;
  24733. }
  24734. });
  24735. var _position$2 = new Vector3();
  24736. var _quaternion$3 = new Quaternion();
  24737. var _scale$1 = new Vector3();
  24738. var _orientation = new Vector3();
  24739. function AudioListener() {
  24740. Object3D.call(this);
  24741. this.type = "AudioListener";
  24742. this.context = AudioContext.getContext();
  24743. this.gain = this.context.createGain();
  24744. this.gain.connect(this.context.destination);
  24745. this.filter = null;
  24746. this.timeDelta = 0;
  24747. this._clock = new Clock();
  24748. }
  24749. AudioListener.prototype = Object.assign(Object.create(Object3D.prototype), {
  24750. constructor: AudioListener,
  24751. getInput: function() {
  24752. return this.gain;
  24753. },
  24754. removeFilter: function() {
  24755. if (this.filter !== null) {
  24756. this.gain.disconnect(this.filter);
  24757. this.filter.disconnect(this.context.destination);
  24758. this.gain.connect(this.context.destination);
  24759. this.filter = null;
  24760. }
  24761. return this;
  24762. },
  24763. getFilter: function() {
  24764. return this.filter;
  24765. },
  24766. setFilter: function(value) {
  24767. if (this.filter !== null) {
  24768. this.gain.disconnect(this.filter);
  24769. this.filter.disconnect(this.context.destination);
  24770. } else {
  24771. this.gain.disconnect(this.context.destination);
  24772. }
  24773. this.filter = value;
  24774. this.gain.connect(this.filter);
  24775. this.filter.connect(this.context.destination);
  24776. return this;
  24777. },
  24778. getMasterVolume: function() {
  24779. return this.gain.gain.value;
  24780. },
  24781. setMasterVolume: function(value) {
  24782. this.gain.gain.setTargetAtTime(value, this.context.currentTime, 0.01);
  24783. return this;
  24784. },
  24785. updateMatrixWorld: function(force) {
  24786. Object3D.prototype.updateMatrixWorld.call(this, force);
  24787. var listener = this.context.listener;
  24788. var up = this.up;
  24789. this.timeDelta = this._clock.getDelta();
  24790. this.matrixWorld.decompose(_position$2, _quaternion$3, _scale$1);
  24791. _orientation.set(0, 0, -1).applyQuaternion(_quaternion$3);
  24792. if (listener.positionX) {
  24793. var endTime = this.context.currentTime + this.timeDelta;
  24794. listener.positionX.linearRampToValueAtTime(_position$2.x, endTime);
  24795. listener.positionY.linearRampToValueAtTime(_position$2.y, endTime);
  24796. listener.positionZ.linearRampToValueAtTime(_position$2.z, endTime);
  24797. listener.forwardX.linearRampToValueAtTime(_orientation.x, endTime);
  24798. listener.forwardY.linearRampToValueAtTime(_orientation.y, endTime);
  24799. listener.forwardZ.linearRampToValueAtTime(_orientation.z, endTime);
  24800. listener.upX.linearRampToValueAtTime(up.x, endTime);
  24801. listener.upY.linearRampToValueAtTime(up.y, endTime);
  24802. listener.upZ.linearRampToValueAtTime(up.z, endTime);
  24803. } else {
  24804. listener.setPosition(_position$2.x, _position$2.y, _position$2.z);
  24805. listener.setOrientation(_orientation.x, _orientation.y, _orientation.z, up.x, up.y, up.z);
  24806. }
  24807. }
  24808. });
  24809. function Audio(listener) {
  24810. Object3D.call(this);
  24811. this.type = "Audio";
  24812. this.listener = listener;
  24813. this.context = listener.context;
  24814. this.gain = this.context.createGain();
  24815. this.gain.connect(listener.getInput());
  24816. this.autoplay = false;
  24817. this.buffer = null;
  24818. this.detune = 0;
  24819. this.loop = false;
  24820. this.loopStart = 0;
  24821. this.loopEnd = 0;
  24822. this.offset = 0;
  24823. this.duration = void 0;
  24824. this.playbackRate = 1;
  24825. this.isPlaying = false;
  24826. this.hasPlaybackControl = true;
  24827. this.sourceType = "empty";
  24828. this._startedAt = 0;
  24829. this._pausedAt = 0;
  24830. this.filters = [];
  24831. }
  24832. Audio.prototype = Object.assign(Object.create(Object3D.prototype), {
  24833. constructor: Audio,
  24834. getOutput: function() {
  24835. return this.gain;
  24836. },
  24837. setNodeSource: function(audioNode) {
  24838. this.hasPlaybackControl = false;
  24839. this.sourceType = "audioNode";
  24840. this.source = audioNode;
  24841. this.connect();
  24842. return this;
  24843. },
  24844. setMediaElementSource: function(mediaElement) {
  24845. this.hasPlaybackControl = false;
  24846. this.sourceType = "mediaNode";
  24847. this.source = this.context.createMediaElementSource(mediaElement);
  24848. this.connect();
  24849. return this;
  24850. },
  24851. setMediaStreamSource: function(mediaStream) {
  24852. this.hasPlaybackControl = false;
  24853. this.sourceType = "mediaStreamNode";
  24854. this.source = this.context.createMediaStreamSource(mediaStream);
  24855. this.connect();
  24856. return this;
  24857. },
  24858. setBuffer: function(audioBuffer) {
  24859. this.buffer = audioBuffer;
  24860. this.sourceType = "buffer";
  24861. if (this.autoplay)
  24862. this.play();
  24863. return this;
  24864. },
  24865. play: function(delay) {
  24866. if (delay === void 0)
  24867. delay = 0;
  24868. if (this.isPlaying === true) {
  24869. console.warn("THREE.Audio: Audio is already playing.");
  24870. return;
  24871. }
  24872. if (this.hasPlaybackControl === false) {
  24873. console.warn("THREE.Audio: this Audio has no playback control.");
  24874. return;
  24875. }
  24876. this._startedAt = this.context.currentTime + delay;
  24877. var source = this.context.createBufferSource();
  24878. source.buffer = this.buffer;
  24879. source.loop = this.loop;
  24880. source.loopStart = this.loopStart;
  24881. source.loopEnd = this.loopEnd;
  24882. source.onended = this.onEnded.bind(this);
  24883. source.start(this._startedAt, this._pausedAt + this.offset, this.duration);
  24884. this.isPlaying = true;
  24885. this.source = source;
  24886. this.setDetune(this.detune);
  24887. this.setPlaybackRate(this.playbackRate);
  24888. return this.connect();
  24889. },
  24890. pause: function() {
  24891. if (this.hasPlaybackControl === false) {
  24892. console.warn("THREE.Audio: this Audio has no playback control.");
  24893. return;
  24894. }
  24895. if (this.isPlaying === true) {
  24896. this._pausedAt = (this.context.currentTime - this._startedAt) * this.playbackRate;
  24897. this.source.stop();
  24898. this.source.onended = null;
  24899. this.isPlaying = false;
  24900. }
  24901. return this;
  24902. },
  24903. stop: function() {
  24904. if (this.hasPlaybackControl === false) {
  24905. console.warn("THREE.Audio: this Audio has no playback control.");
  24906. return;
  24907. }
  24908. this._pausedAt = 0;
  24909. this.source.stop();
  24910. this.source.onended = null;
  24911. this.isPlaying = false;
  24912. return this;
  24913. },
  24914. connect: function() {
  24915. if (this.filters.length > 0) {
  24916. this.source.connect(this.filters[0]);
  24917. for (var i2 = 1, l = this.filters.length; i2 < l; i2++) {
  24918. this.filters[i2 - 1].connect(this.filters[i2]);
  24919. }
  24920. this.filters[this.filters.length - 1].connect(this.getOutput());
  24921. } else {
  24922. this.source.connect(this.getOutput());
  24923. }
  24924. return this;
  24925. },
  24926. disconnect: function() {
  24927. if (this.filters.length > 0) {
  24928. this.source.disconnect(this.filters[0]);
  24929. for (var i2 = 1, l = this.filters.length; i2 < l; i2++) {
  24930. this.filters[i2 - 1].disconnect(this.filters[i2]);
  24931. }
  24932. this.filters[this.filters.length - 1].disconnect(this.getOutput());
  24933. } else {
  24934. this.source.disconnect(this.getOutput());
  24935. }
  24936. return this;
  24937. },
  24938. getFilters: function() {
  24939. return this.filters;
  24940. },
  24941. setFilters: function(value) {
  24942. if (!value)
  24943. value = [];
  24944. if (this.isPlaying === true) {
  24945. this.disconnect();
  24946. this.filters = value;
  24947. this.connect();
  24948. } else {
  24949. this.filters = value;
  24950. }
  24951. return this;
  24952. },
  24953. setDetune: function(value) {
  24954. this.detune = value;
  24955. if (this.source.detune === void 0)
  24956. return;
  24957. if (this.isPlaying === true) {
  24958. this.source.detune.setTargetAtTime(this.detune, this.context.currentTime, 0.01);
  24959. }
  24960. return this;
  24961. },
  24962. getDetune: function() {
  24963. return this.detune;
  24964. },
  24965. getFilter: function() {
  24966. return this.getFilters()[0];
  24967. },
  24968. setFilter: function(filter) {
  24969. return this.setFilters(filter ? [filter] : []);
  24970. },
  24971. setPlaybackRate: function(value) {
  24972. if (this.hasPlaybackControl === false) {
  24973. console.warn("THREE.Audio: this Audio has no playback control.");
  24974. return;
  24975. }
  24976. this.playbackRate = value;
  24977. if (this.isPlaying === true) {
  24978. this.source.playbackRate.setTargetAtTime(this.playbackRate, this.context.currentTime, 0.01);
  24979. }
  24980. return this;
  24981. },
  24982. getPlaybackRate: function() {
  24983. return this.playbackRate;
  24984. },
  24985. onEnded: function() {
  24986. this.isPlaying = false;
  24987. },
  24988. getLoop: function() {
  24989. if (this.hasPlaybackControl === false) {
  24990. console.warn("THREE.Audio: this Audio has no playback control.");
  24991. return false;
  24992. }
  24993. return this.loop;
  24994. },
  24995. setLoop: function(value) {
  24996. if (this.hasPlaybackControl === false) {
  24997. console.warn("THREE.Audio: this Audio has no playback control.");
  24998. return;
  24999. }
  25000. this.loop = value;
  25001. if (this.isPlaying === true) {
  25002. this.source.loop = this.loop;
  25003. }
  25004. return this;
  25005. },
  25006. setLoopStart: function(value) {
  25007. this.loopStart = value;
  25008. return this;
  25009. },
  25010. setLoopEnd: function(value) {
  25011. this.loopEnd = value;
  25012. return this;
  25013. },
  25014. getVolume: function() {
  25015. return this.gain.gain.value;
  25016. },
  25017. setVolume: function(value) {
  25018. this.gain.gain.setTargetAtTime(value, this.context.currentTime, 0.01);
  25019. return this;
  25020. }
  25021. });
  25022. var _position$3 = new Vector3();
  25023. var _quaternion$4 = new Quaternion();
  25024. var _scale$2 = new Vector3();
  25025. var _orientation$1 = new Vector3();
  25026. function PositionalAudio(listener) {
  25027. Audio.call(this, listener);
  25028. this.panner = this.context.createPanner();
  25029. this.panner.panningModel = "HRTF";
  25030. this.panner.connect(this.gain);
  25031. }
  25032. PositionalAudio.prototype = Object.assign(Object.create(Audio.prototype), {
  25033. constructor: PositionalAudio,
  25034. getOutput: function() {
  25035. return this.panner;
  25036. },
  25037. getRefDistance: function() {
  25038. return this.panner.refDistance;
  25039. },
  25040. setRefDistance: function(value) {
  25041. this.panner.refDistance = value;
  25042. return this;
  25043. },
  25044. getRolloffFactor: function() {
  25045. return this.panner.rolloffFactor;
  25046. },
  25047. setRolloffFactor: function(value) {
  25048. this.panner.rolloffFactor = value;
  25049. return this;
  25050. },
  25051. getDistanceModel: function() {
  25052. return this.panner.distanceModel;
  25053. },
  25054. setDistanceModel: function(value) {
  25055. this.panner.distanceModel = value;
  25056. return this;
  25057. },
  25058. getMaxDistance: function() {
  25059. return this.panner.maxDistance;
  25060. },
  25061. setMaxDistance: function(value) {
  25062. this.panner.maxDistance = value;
  25063. return this;
  25064. },
  25065. setDirectionalCone: function(coneInnerAngle, coneOuterAngle, coneOuterGain) {
  25066. this.panner.coneInnerAngle = coneInnerAngle;
  25067. this.panner.coneOuterAngle = coneOuterAngle;
  25068. this.panner.coneOuterGain = coneOuterGain;
  25069. return this;
  25070. },
  25071. updateMatrixWorld: function(force) {
  25072. Object3D.prototype.updateMatrixWorld.call(this, force);
  25073. if (this.hasPlaybackControl === true && this.isPlaying === false)
  25074. return;
  25075. this.matrixWorld.decompose(_position$3, _quaternion$4, _scale$2);
  25076. _orientation$1.set(0, 0, 1).applyQuaternion(_quaternion$4);
  25077. var panner = this.panner;
  25078. if (panner.positionX) {
  25079. var endTime = this.context.currentTime + this.listener.timeDelta;
  25080. panner.positionX.linearRampToValueAtTime(_position$3.x, endTime);
  25081. panner.positionY.linearRampToValueAtTime(_position$3.y, endTime);
  25082. panner.positionZ.linearRampToValueAtTime(_position$3.z, endTime);
  25083. panner.orientationX.linearRampToValueAtTime(_orientation$1.x, endTime);
  25084. panner.orientationY.linearRampToValueAtTime(_orientation$1.y, endTime);
  25085. panner.orientationZ.linearRampToValueAtTime(_orientation$1.z, endTime);
  25086. } else {
  25087. panner.setPosition(_position$3.x, _position$3.y, _position$3.z);
  25088. panner.setOrientation(_orientation$1.x, _orientation$1.y, _orientation$1.z);
  25089. }
  25090. }
  25091. });
  25092. function AudioAnalyser(audio, fftSize) {
  25093. this.analyser = audio.context.createAnalyser();
  25094. this.analyser.fftSize = fftSize !== void 0 ? fftSize : 2048;
  25095. this.data = new Uint8Array(this.analyser.frequencyBinCount);
  25096. audio.getOutput().connect(this.analyser);
  25097. }
  25098. Object.assign(AudioAnalyser.prototype, {
  25099. getFrequencyData: function() {
  25100. this.analyser.getByteFrequencyData(this.data);
  25101. return this.data;
  25102. },
  25103. getAverageFrequency: function() {
  25104. var value = 0, data = this.getFrequencyData();
  25105. for (var i2 = 0; i2 < data.length; i2++) {
  25106. value += data[i2];
  25107. }
  25108. return value / data.length;
  25109. }
  25110. });
  25111. function PropertyMixer(binding, typeName, valueSize) {
  25112. this.binding = binding;
  25113. this.valueSize = valueSize;
  25114. var bufferType = Float64Array, mixFunction;
  25115. switch (typeName) {
  25116. case "quaternion":
  25117. mixFunction = this._slerp;
  25118. break;
  25119. case "string":
  25120. case "bool":
  25121. bufferType = Array;
  25122. mixFunction = this._select;
  25123. break;
  25124. default:
  25125. mixFunction = this._lerp;
  25126. }
  25127. this.buffer = new bufferType(valueSize * 4);
  25128. this._mixBufferRegion = mixFunction;
  25129. this.cumulativeWeight = 0;
  25130. this.useCount = 0;
  25131. this.referenceCount = 0;
  25132. }
  25133. Object.assign(PropertyMixer.prototype, {
  25134. // accumulate data in the 'incoming' region into 'accu<i>'
  25135. accumulate: function(accuIndex, weight) {
  25136. var buffer = this.buffer, stride = this.valueSize, offset = accuIndex * stride + stride, currentWeight = this.cumulativeWeight;
  25137. if (currentWeight === 0) {
  25138. for (var i2 = 0; i2 !== stride; ++i2) {
  25139. buffer[offset + i2] = buffer[i2];
  25140. }
  25141. currentWeight = weight;
  25142. } else {
  25143. currentWeight += weight;
  25144. var mix = weight / currentWeight;
  25145. this._mixBufferRegion(buffer, offset, 0, mix, stride);
  25146. }
  25147. this.cumulativeWeight = currentWeight;
  25148. },
  25149. // apply the state of 'accu<i>' to the binding when accus differ
  25150. apply: function(accuIndex) {
  25151. var stride = this.valueSize, buffer = this.buffer, offset = accuIndex * stride + stride, weight = this.cumulativeWeight, binding = this.binding;
  25152. this.cumulativeWeight = 0;
  25153. if (weight < 1) {
  25154. var originalValueOffset = stride * 3;
  25155. this._mixBufferRegion(
  25156. buffer,
  25157. offset,
  25158. originalValueOffset,
  25159. 1 - weight,
  25160. stride
  25161. );
  25162. }
  25163. for (var i2 = stride, e = stride + stride; i2 !== e; ++i2) {
  25164. if (buffer[i2] !== buffer[i2 + stride]) {
  25165. binding.setValue(buffer, offset);
  25166. break;
  25167. }
  25168. }
  25169. },
  25170. // remember the state of the bound property and copy it to both accus
  25171. saveOriginalState: function() {
  25172. var binding = this.binding;
  25173. var buffer = this.buffer, stride = this.valueSize, originalValueOffset = stride * 3;
  25174. binding.getValue(buffer, originalValueOffset);
  25175. for (var i2 = stride, e = originalValueOffset; i2 !== e; ++i2) {
  25176. buffer[i2] = buffer[originalValueOffset + i2 % stride];
  25177. }
  25178. this.cumulativeWeight = 0;
  25179. },
  25180. // apply the state previously taken via 'saveOriginalState' to the binding
  25181. restoreOriginalState: function() {
  25182. var originalValueOffset = this.valueSize * 3;
  25183. this.binding.setValue(this.buffer, originalValueOffset);
  25184. },
  25185. // mix functions
  25186. _select: function(buffer, dstOffset, srcOffset, t, stride) {
  25187. if (t >= 0.5) {
  25188. for (var i2 = 0; i2 !== stride; ++i2) {
  25189. buffer[dstOffset + i2] = buffer[srcOffset + i2];
  25190. }
  25191. }
  25192. },
  25193. _slerp: function(buffer, dstOffset, srcOffset, t) {
  25194. Quaternion.slerpFlat(buffer, dstOffset, buffer, dstOffset, buffer, srcOffset, t);
  25195. },
  25196. _lerp: function(buffer, dstOffset, srcOffset, t, stride) {
  25197. var s = 1 - t;
  25198. for (var i2 = 0; i2 !== stride; ++i2) {
  25199. var j = dstOffset + i2;
  25200. buffer[j] = buffer[j] * s + buffer[srcOffset + i2] * t;
  25201. }
  25202. }
  25203. });
  25204. var _RESERVED_CHARS_RE = "\\[\\]\\.:\\/";
  25205. var _reservedRe = new RegExp("[" + _RESERVED_CHARS_RE + "]", "g");
  25206. var _wordChar = "[^" + _RESERVED_CHARS_RE + "]";
  25207. var _wordCharOrDot = "[^" + _RESERVED_CHARS_RE.replace("\\.", "") + "]";
  25208. var _directoryRe = /((?:WC+[\/:])*)/.source.replace("WC", _wordChar);
  25209. var _nodeRe = /(WCOD+)?/.source.replace("WCOD", _wordCharOrDot);
  25210. var _objectRe = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC", _wordChar);
  25211. var _propertyRe = /\.(WC+)(?:\[(.+)\])?/.source.replace("WC", _wordChar);
  25212. var _trackRe = new RegExp(
  25213. "^" + _directoryRe + _nodeRe + _objectRe + _propertyRe + "$"
  25214. );
  25215. var _supportedObjectNames = ["material", "materials", "bones"];
  25216. function Composite(targetGroup, path, optionalParsedPath) {
  25217. var parsedPath = optionalParsedPath || PropertyBinding.parseTrackName(path);
  25218. this._targetGroup = targetGroup;
  25219. this._bindings = targetGroup.subscribe_(path, parsedPath);
  25220. }
  25221. Object.assign(Composite.prototype, {
  25222. getValue: function(array, offset) {
  25223. this.bind();
  25224. var firstValidIndex = this._targetGroup.nCachedObjects_, binding = this._bindings[firstValidIndex];
  25225. if (binding !== void 0)
  25226. binding.getValue(array, offset);
  25227. },
  25228. setValue: function(array, offset) {
  25229. var bindings = this._bindings;
  25230. for (var i2 = this._targetGroup.nCachedObjects_, n = bindings.length; i2 !== n; ++i2) {
  25231. bindings[i2].setValue(array, offset);
  25232. }
  25233. },
  25234. bind: function() {
  25235. var bindings = this._bindings;
  25236. for (var i2 = this._targetGroup.nCachedObjects_, n = bindings.length; i2 !== n; ++i2) {
  25237. bindings[i2].bind();
  25238. }
  25239. },
  25240. unbind: function() {
  25241. var bindings = this._bindings;
  25242. for (var i2 = this._targetGroup.nCachedObjects_, n = bindings.length; i2 !== n; ++i2) {
  25243. bindings[i2].unbind();
  25244. }
  25245. }
  25246. });
  25247. function PropertyBinding(rootNode, path, parsedPath) {
  25248. this.path = path;
  25249. this.parsedPath = parsedPath || PropertyBinding.parseTrackName(path);
  25250. this.node = PropertyBinding.findNode(rootNode, this.parsedPath.nodeName) || rootNode;
  25251. this.rootNode = rootNode;
  25252. }
  25253. Object.assign(PropertyBinding, {
  25254. Composite,
  25255. create: function(root, path, parsedPath) {
  25256. if (!(root && root.isAnimationObjectGroup)) {
  25257. return new PropertyBinding(root, path, parsedPath);
  25258. } else {
  25259. return new PropertyBinding.Composite(root, path, parsedPath);
  25260. }
  25261. },
  25262. /**
  25263. * Replaces spaces with underscores and removes unsupported characters from
  25264. * node names, to ensure compatibility with parseTrackName().
  25265. *
  25266. * @param {string} name Node name to be sanitized.
  25267. * @return {string}
  25268. */
  25269. sanitizeNodeName: function(name) {
  25270. return name.replace(/\s/g, "_").replace(_reservedRe, "");
  25271. },
  25272. parseTrackName: function(trackName) {
  25273. var matches = _trackRe.exec(trackName);
  25274. if (!matches) {
  25275. throw new Error("PropertyBinding: Cannot parse trackName: " + trackName);
  25276. }
  25277. var results = {
  25278. // directoryName: matches[ 1 ], // (tschw) currently unused
  25279. nodeName: matches[2],
  25280. objectName: matches[3],
  25281. objectIndex: matches[4],
  25282. propertyName: matches[5],
  25283. // required
  25284. propertyIndex: matches[6]
  25285. };
  25286. var lastDot = results.nodeName && results.nodeName.lastIndexOf(".");
  25287. if (lastDot !== void 0 && lastDot !== -1) {
  25288. var objectName = results.nodeName.substring(lastDot + 1);
  25289. if (_supportedObjectNames.indexOf(objectName) !== -1) {
  25290. results.nodeName = results.nodeName.substring(0, lastDot);
  25291. results.objectName = objectName;
  25292. }
  25293. }
  25294. if (results.propertyName === null || results.propertyName.length === 0) {
  25295. throw new Error("PropertyBinding: can not parse propertyName from trackName: " + trackName);
  25296. }
  25297. return results;
  25298. },
  25299. findNode: function(root, nodeName) {
  25300. if (!nodeName || nodeName === "" || nodeName === "root" || nodeName === "." || nodeName === -1 || nodeName === root.name || nodeName === root.uuid) {
  25301. return root;
  25302. }
  25303. if (root.skeleton) {
  25304. var bone = root.skeleton.getBoneByName(nodeName);
  25305. if (bone !== void 0) {
  25306. return bone;
  25307. }
  25308. }
  25309. if (root.children) {
  25310. var searchNodeSubtree = function(children) {
  25311. for (var i2 = 0; i2 < children.length; i2++) {
  25312. var childNode = children[i2];
  25313. if (childNode.name === nodeName || childNode.uuid === nodeName) {
  25314. return childNode;
  25315. }
  25316. var result = searchNodeSubtree(childNode.children);
  25317. if (result)
  25318. return result;
  25319. }
  25320. return null;
  25321. };
  25322. var subTreeNode = searchNodeSubtree(root.children);
  25323. if (subTreeNode) {
  25324. return subTreeNode;
  25325. }
  25326. }
  25327. return null;
  25328. }
  25329. });
  25330. Object.assign(PropertyBinding.prototype, {
  25331. // prototype, continued
  25332. // these are used to "bind" a nonexistent property
  25333. _getValue_unavailable: function() {
  25334. },
  25335. _setValue_unavailable: function() {
  25336. },
  25337. BindingType: {
  25338. Direct: 0,
  25339. EntireArray: 1,
  25340. ArrayElement: 2,
  25341. HasFromToArray: 3
  25342. },
  25343. Versioning: {
  25344. None: 0,
  25345. NeedsUpdate: 1,
  25346. MatrixWorldNeedsUpdate: 2
  25347. },
  25348. GetterByBindingType: [
  25349. function getValue_direct(buffer, offset) {
  25350. buffer[offset] = this.node[this.propertyName];
  25351. },
  25352. function getValue_array(buffer, offset) {
  25353. var source = this.resolvedProperty;
  25354. for (var i2 = 0, n = source.length; i2 !== n; ++i2) {
  25355. buffer[offset++] = source[i2];
  25356. }
  25357. },
  25358. function getValue_arrayElement(buffer, offset) {
  25359. buffer[offset] = this.resolvedProperty[this.propertyIndex];
  25360. },
  25361. function getValue_toArray(buffer, offset) {
  25362. this.resolvedProperty.toArray(buffer, offset);
  25363. }
  25364. ],
  25365. SetterByBindingTypeAndVersioning: [
  25366. [
  25367. // Direct
  25368. function setValue_direct(buffer, offset) {
  25369. this.targetObject[this.propertyName] = buffer[offset];
  25370. },
  25371. function setValue_direct_setNeedsUpdate(buffer, offset) {
  25372. this.targetObject[this.propertyName] = buffer[offset];
  25373. this.targetObject.needsUpdate = true;
  25374. },
  25375. function setValue_direct_setMatrixWorldNeedsUpdate(buffer, offset) {
  25376. this.targetObject[this.propertyName] = buffer[offset];
  25377. this.targetObject.matrixWorldNeedsUpdate = true;
  25378. }
  25379. ],
  25380. [
  25381. // EntireArray
  25382. function setValue_array(buffer, offset) {
  25383. var dest = this.resolvedProperty;
  25384. for (var i2 = 0, n = dest.length; i2 !== n; ++i2) {
  25385. dest[i2] = buffer[offset++];
  25386. }
  25387. },
  25388. function setValue_array_setNeedsUpdate(buffer, offset) {
  25389. var dest = this.resolvedProperty;
  25390. for (var i2 = 0, n = dest.length; i2 !== n; ++i2) {
  25391. dest[i2] = buffer[offset++];
  25392. }
  25393. this.targetObject.needsUpdate = true;
  25394. },
  25395. function setValue_array_setMatrixWorldNeedsUpdate(buffer, offset) {
  25396. var dest = this.resolvedProperty;
  25397. for (var i2 = 0, n = dest.length; i2 !== n; ++i2) {
  25398. dest[i2] = buffer[offset++];
  25399. }
  25400. this.targetObject.matrixWorldNeedsUpdate = true;
  25401. }
  25402. ],
  25403. [
  25404. // ArrayElement
  25405. function setValue_arrayElement(buffer, offset) {
  25406. this.resolvedProperty[this.propertyIndex] = buffer[offset];
  25407. },
  25408. function setValue_arrayElement_setNeedsUpdate(buffer, offset) {
  25409. this.resolvedProperty[this.propertyIndex] = buffer[offset];
  25410. this.targetObject.needsUpdate = true;
  25411. },
  25412. function setValue_arrayElement_setMatrixWorldNeedsUpdate(buffer, offset) {
  25413. this.resolvedProperty[this.propertyIndex] = buffer[offset];
  25414. this.targetObject.matrixWorldNeedsUpdate = true;
  25415. }
  25416. ],
  25417. [
  25418. // HasToFromArray
  25419. function setValue_fromArray(buffer, offset) {
  25420. this.resolvedProperty.fromArray(buffer, offset);
  25421. },
  25422. function setValue_fromArray_setNeedsUpdate(buffer, offset) {
  25423. this.resolvedProperty.fromArray(buffer, offset);
  25424. this.targetObject.needsUpdate = true;
  25425. },
  25426. function setValue_fromArray_setMatrixWorldNeedsUpdate(buffer, offset) {
  25427. this.resolvedProperty.fromArray(buffer, offset);
  25428. this.targetObject.matrixWorldNeedsUpdate = true;
  25429. }
  25430. ]
  25431. ],
  25432. getValue: function getValue_unbound(targetArray, offset) {
  25433. this.bind();
  25434. this.getValue(targetArray, offset);
  25435. },
  25436. setValue: function getValue_unbound(sourceArray, offset) {
  25437. this.bind();
  25438. this.setValue(sourceArray, offset);
  25439. },
  25440. // create getter / setter pair for a property in the scene graph
  25441. bind: function() {
  25442. var targetObject = this.node, parsedPath = this.parsedPath, objectName = parsedPath.objectName, propertyName = parsedPath.propertyName, propertyIndex = parsedPath.propertyIndex;
  25443. if (!targetObject) {
  25444. targetObject = PropertyBinding.findNode(this.rootNode, parsedPath.nodeName) || this.rootNode;
  25445. this.node = targetObject;
  25446. }
  25447. this.getValue = this._getValue_unavailable;
  25448. this.setValue = this._setValue_unavailable;
  25449. if (!targetObject) {
  25450. console.error("THREE.PropertyBinding: Trying to update node for track: " + this.path + " but it wasn't found.");
  25451. return;
  25452. }
  25453. if (objectName) {
  25454. var objectIndex = parsedPath.objectIndex;
  25455. switch (objectName) {
  25456. case "materials":
  25457. if (!targetObject.material) {
  25458. console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.", this);
  25459. return;
  25460. }
  25461. if (!targetObject.material.materials) {
  25462. console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.", this);
  25463. return;
  25464. }
  25465. targetObject = targetObject.material.materials;
  25466. break;
  25467. case "bones":
  25468. if (!targetObject.skeleton) {
  25469. console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.", this);
  25470. return;
  25471. }
  25472. targetObject = targetObject.skeleton.bones;
  25473. for (var i2 = 0; i2 < targetObject.length; i2++) {
  25474. if (targetObject[i2].name === objectIndex) {
  25475. objectIndex = i2;
  25476. break;
  25477. }
  25478. }
  25479. break;
  25480. default:
  25481. if (targetObject[objectName] === void 0) {
  25482. console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.", this);
  25483. return;
  25484. }
  25485. targetObject = targetObject[objectName];
  25486. }
  25487. if (objectIndex !== void 0) {
  25488. if (targetObject[objectIndex] === void 0) {
  25489. console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.", this, targetObject);
  25490. return;
  25491. }
  25492. targetObject = targetObject[objectIndex];
  25493. }
  25494. }
  25495. var nodeProperty = targetObject[propertyName];
  25496. if (nodeProperty === void 0) {
  25497. var nodeName = parsedPath.nodeName;
  25498. console.error("THREE.PropertyBinding: Trying to update property for track: " + nodeName + "." + propertyName + " but it wasn't found.", targetObject);
  25499. return;
  25500. }
  25501. var versioning = this.Versioning.None;
  25502. this.targetObject = targetObject;
  25503. if (targetObject.needsUpdate !== void 0) {
  25504. versioning = this.Versioning.NeedsUpdate;
  25505. } else if (targetObject.matrixWorldNeedsUpdate !== void 0) {
  25506. versioning = this.Versioning.MatrixWorldNeedsUpdate;
  25507. }
  25508. var bindingType = this.BindingType.Direct;
  25509. if (propertyIndex !== void 0) {
  25510. if (propertyName === "morphTargetInfluences") {
  25511. if (!targetObject.geometry) {
  25512. console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.", this);
  25513. return;
  25514. }
  25515. if (targetObject.geometry.isBufferGeometry) {
  25516. if (!targetObject.geometry.morphAttributes) {
  25517. console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.", this);
  25518. return;
  25519. }
  25520. for (var i2 = 0; i2 < this.node.geometry.morphAttributes.position.length; i2++) {
  25521. if (targetObject.geometry.morphAttributes.position[i2].name === propertyIndex) {
  25522. propertyIndex = i2;
  25523. break;
  25524. }
  25525. }
  25526. } else {
  25527. if (!targetObject.geometry.morphTargets) {
  25528. console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphTargets.", this);
  25529. return;
  25530. }
  25531. for (var i2 = 0; i2 < this.node.geometry.morphTargets.length; i2++) {
  25532. if (targetObject.geometry.morphTargets[i2].name === propertyIndex) {
  25533. propertyIndex = i2;
  25534. break;
  25535. }
  25536. }
  25537. }
  25538. }
  25539. bindingType = this.BindingType.ArrayElement;
  25540. this.resolvedProperty = nodeProperty;
  25541. this.propertyIndex = propertyIndex;
  25542. } else if (nodeProperty.fromArray !== void 0 && nodeProperty.toArray !== void 0) {
  25543. bindingType = this.BindingType.HasFromToArray;
  25544. this.resolvedProperty = nodeProperty;
  25545. } else if (Array.isArray(nodeProperty)) {
  25546. bindingType = this.BindingType.EntireArray;
  25547. this.resolvedProperty = nodeProperty;
  25548. } else {
  25549. this.propertyName = propertyName;
  25550. }
  25551. this.getValue = this.GetterByBindingType[bindingType];
  25552. this.setValue = this.SetterByBindingTypeAndVersioning[bindingType][versioning];
  25553. },
  25554. unbind: function() {
  25555. this.node = null;
  25556. this.getValue = this._getValue_unbound;
  25557. this.setValue = this._setValue_unbound;
  25558. }
  25559. });
  25560. //!\ DECLARE ALIAS AFTER assign prototype !
  25561. Object.assign(PropertyBinding.prototype, {
  25562. // initial state of these methods that calls 'bind'
  25563. _getValue_unbound: PropertyBinding.prototype.getValue,
  25564. _setValue_unbound: PropertyBinding.prototype.setValue
  25565. });
  25566. function AnimationObjectGroup() {
  25567. this.uuid = MathUtils.generateUUID();
  25568. this._objects = Array.prototype.slice.call(arguments);
  25569. this.nCachedObjects_ = 0;
  25570. var indices = {};
  25571. this._indicesByUUID = indices;
  25572. for (var i2 = 0, n = arguments.length; i2 !== n; ++i2) {
  25573. indices[arguments[i2].uuid] = i2;
  25574. }
  25575. this._paths = [];
  25576. this._parsedPaths = [];
  25577. this._bindings = [];
  25578. this._bindingsIndicesByPath = {};
  25579. var scope = this;
  25580. this.stats = {
  25581. objects: {
  25582. get total() {
  25583. return scope._objects.length;
  25584. },
  25585. get inUse() {
  25586. return this.total - scope.nCachedObjects_;
  25587. }
  25588. },
  25589. get bindingsPerObject() {
  25590. return scope._bindings.length;
  25591. }
  25592. };
  25593. }
  25594. Object.assign(AnimationObjectGroup.prototype, {
  25595. isAnimationObjectGroup: true,
  25596. add: function() {
  25597. var objects = this._objects, nObjects = objects.length, nCachedObjects = this.nCachedObjects_, indicesByUUID = this._indicesByUUID, paths = this._paths, parsedPaths = this._parsedPaths, bindings = this._bindings, nBindings = bindings.length, knownObject = void 0;
  25598. for (var i2 = 0, n = arguments.length; i2 !== n; ++i2) {
  25599. var object = arguments[i2], uuid = object.uuid, index = indicesByUUID[uuid];
  25600. if (index === void 0) {
  25601. index = nObjects++;
  25602. indicesByUUID[uuid] = index;
  25603. objects.push(object);
  25604. for (var j = 0, m = nBindings; j !== m; ++j) {
  25605. bindings[j].push(new PropertyBinding(object, paths[j], parsedPaths[j]));
  25606. }
  25607. } else if (index < nCachedObjects) {
  25608. knownObject = objects[index];
  25609. var firstActiveIndex = --nCachedObjects, lastCachedObject = objects[firstActiveIndex];
  25610. indicesByUUID[lastCachedObject.uuid] = index;
  25611. objects[index] = lastCachedObject;
  25612. indicesByUUID[uuid] = firstActiveIndex;
  25613. objects[firstActiveIndex] = object;
  25614. for (var j = 0, m = nBindings; j !== m; ++j) {
  25615. var bindingsForPath = bindings[j], lastCached = bindingsForPath[firstActiveIndex], binding = bindingsForPath[index];
  25616. bindingsForPath[index] = lastCached;
  25617. if (binding === void 0) {
  25618. binding = new PropertyBinding(object, paths[j], parsedPaths[j]);
  25619. }
  25620. bindingsForPath[firstActiveIndex] = binding;
  25621. }
  25622. } else if (objects[index] !== knownObject) {
  25623. console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.");
  25624. }
  25625. }
  25626. this.nCachedObjects_ = nCachedObjects;
  25627. },
  25628. remove: function() {
  25629. var objects = this._objects, nCachedObjects = this.nCachedObjects_, indicesByUUID = this._indicesByUUID, bindings = this._bindings, nBindings = bindings.length;
  25630. for (var i2 = 0, n = arguments.length; i2 !== n; ++i2) {
  25631. var object = arguments[i2], uuid = object.uuid, index = indicesByUUID[uuid];
  25632. if (index !== void 0 && index >= nCachedObjects) {
  25633. var lastCachedIndex = nCachedObjects++, firstActiveObject = objects[lastCachedIndex];
  25634. indicesByUUID[firstActiveObject.uuid] = index;
  25635. objects[index] = firstActiveObject;
  25636. indicesByUUID[uuid] = lastCachedIndex;
  25637. objects[lastCachedIndex] = object;
  25638. for (var j = 0, m = nBindings; j !== m; ++j) {
  25639. var bindingsForPath = bindings[j], firstActive = bindingsForPath[lastCachedIndex], binding = bindingsForPath[index];
  25640. bindingsForPath[index] = firstActive;
  25641. bindingsForPath[lastCachedIndex] = binding;
  25642. }
  25643. }
  25644. }
  25645. this.nCachedObjects_ = nCachedObjects;
  25646. },
  25647. // remove & forget
  25648. uncache: function() {
  25649. var objects = this._objects, nObjects = objects.length, nCachedObjects = this.nCachedObjects_, indicesByUUID = this._indicesByUUID, bindings = this._bindings, nBindings = bindings.length;
  25650. for (var i2 = 0, n = arguments.length; i2 !== n; ++i2) {
  25651. var object = arguments[i2], uuid = object.uuid, index = indicesByUUID[uuid];
  25652. if (index !== void 0) {
  25653. delete indicesByUUID[uuid];
  25654. if (index < nCachedObjects) {
  25655. var firstActiveIndex = --nCachedObjects, lastCachedObject = objects[firstActiveIndex], lastIndex = --nObjects, lastObject = objects[lastIndex];
  25656. indicesByUUID[lastCachedObject.uuid] = index;
  25657. objects[index] = lastCachedObject;
  25658. indicesByUUID[lastObject.uuid] = firstActiveIndex;
  25659. objects[firstActiveIndex] = lastObject;
  25660. objects.pop();
  25661. for (var j = 0, m = nBindings; j !== m; ++j) {
  25662. var bindingsForPath = bindings[j], lastCached = bindingsForPath[firstActiveIndex], last = bindingsForPath[lastIndex];
  25663. bindingsForPath[index] = lastCached;
  25664. bindingsForPath[firstActiveIndex] = last;
  25665. bindingsForPath.pop();
  25666. }
  25667. } else {
  25668. var lastIndex = --nObjects, lastObject = objects[lastIndex];
  25669. indicesByUUID[lastObject.uuid] = index;
  25670. objects[index] = lastObject;
  25671. objects.pop();
  25672. for (var j = 0, m = nBindings; j !== m; ++j) {
  25673. var bindingsForPath = bindings[j];
  25674. bindingsForPath[index] = bindingsForPath[lastIndex];
  25675. bindingsForPath.pop();
  25676. }
  25677. }
  25678. }
  25679. }
  25680. this.nCachedObjects_ = nCachedObjects;
  25681. },
  25682. // Internal interface used by befriended PropertyBinding.Composite:
  25683. subscribe_: function(path, parsedPath) {
  25684. var indicesByPath = this._bindingsIndicesByPath, index = indicesByPath[path], bindings = this._bindings;
  25685. if (index !== void 0)
  25686. return bindings[index];
  25687. var paths = this._paths, parsedPaths = this._parsedPaths, objects = this._objects, nObjects = objects.length, nCachedObjects = this.nCachedObjects_, bindingsForPath = new Array(nObjects);
  25688. index = bindings.length;
  25689. indicesByPath[path] = index;
  25690. paths.push(path);
  25691. parsedPaths.push(parsedPath);
  25692. bindings.push(bindingsForPath);
  25693. for (var i2 = nCachedObjects, n = objects.length; i2 !== n; ++i2) {
  25694. var object = objects[i2];
  25695. bindingsForPath[i2] = new PropertyBinding(object, path, parsedPath);
  25696. }
  25697. return bindingsForPath;
  25698. },
  25699. unsubscribe_: function(path) {
  25700. var indicesByPath = this._bindingsIndicesByPath, index = indicesByPath[path];
  25701. if (index !== void 0) {
  25702. var paths = this._paths, parsedPaths = this._parsedPaths, bindings = this._bindings, lastBindingsIndex = bindings.length - 1, lastBindings = bindings[lastBindingsIndex], lastBindingsPath = path[lastBindingsIndex];
  25703. indicesByPath[lastBindingsPath] = index;
  25704. bindings[index] = lastBindings;
  25705. bindings.pop();
  25706. parsedPaths[index] = parsedPaths[lastBindingsIndex];
  25707. parsedPaths.pop();
  25708. paths[index] = paths[lastBindingsIndex];
  25709. paths.pop();
  25710. }
  25711. }
  25712. });
  25713. function AnimationAction(mixer, clip, localRoot) {
  25714. this._mixer = mixer;
  25715. this._clip = clip;
  25716. this._localRoot = localRoot || null;
  25717. var tracks = clip.tracks, nTracks = tracks.length, interpolants = new Array(nTracks);
  25718. var interpolantSettings = {
  25719. endingStart: ZeroCurvatureEnding,
  25720. endingEnd: ZeroCurvatureEnding
  25721. };
  25722. for (var i2 = 0; i2 !== nTracks; ++i2) {
  25723. var interpolant = tracks[i2].createInterpolant(null);
  25724. interpolants[i2] = interpolant;
  25725. interpolant.settings = interpolantSettings;
  25726. }
  25727. this._interpolantSettings = interpolantSettings;
  25728. this._interpolants = interpolants;
  25729. this._propertyBindings = new Array(nTracks);
  25730. this._cacheIndex = null;
  25731. this._byClipCacheIndex = null;
  25732. this._timeScaleInterpolant = null;
  25733. this._weightInterpolant = null;
  25734. this.loop = LoopRepeat;
  25735. this._loopCount = -1;
  25736. this._startTime = null;
  25737. this.time = 0;
  25738. this.timeScale = 1;
  25739. this._effectiveTimeScale = 1;
  25740. this.weight = 1;
  25741. this._effectiveWeight = 1;
  25742. this.repetitions = Infinity;
  25743. this.paused = false;
  25744. this.enabled = true;
  25745. this.clampWhenFinished = false;
  25746. this.zeroSlopeAtStart = true;
  25747. this.zeroSlopeAtEnd = true;
  25748. }
  25749. Object.assign(AnimationAction.prototype, {
  25750. // State & Scheduling
  25751. play: function() {
  25752. this._mixer._activateAction(this);
  25753. return this;
  25754. },
  25755. stop: function() {
  25756. this._mixer._deactivateAction(this);
  25757. return this.reset();
  25758. },
  25759. reset: function() {
  25760. this.paused = false;
  25761. this.enabled = true;
  25762. this.time = 0;
  25763. this._loopCount = -1;
  25764. this._startTime = null;
  25765. return this.stopFading().stopWarping();
  25766. },
  25767. isRunning: function() {
  25768. return this.enabled && !this.paused && this.timeScale !== 0 && this._startTime === null && this._mixer._isActiveAction(this);
  25769. },
  25770. // return true when play has been called
  25771. isScheduled: function() {
  25772. return this._mixer._isActiveAction(this);
  25773. },
  25774. startAt: function(time) {
  25775. this._startTime = time;
  25776. return this;
  25777. },
  25778. setLoop: function(mode, repetitions) {
  25779. this.loop = mode;
  25780. this.repetitions = repetitions;
  25781. return this;
  25782. },
  25783. // Weight
  25784. // set the weight stopping any scheduled fading
  25785. // although .enabled = false yields an effective weight of zero, this
  25786. // method does *not* change .enabled, because it would be confusing
  25787. setEffectiveWeight: function(weight) {
  25788. this.weight = weight;
  25789. this._effectiveWeight = this.enabled ? weight : 0;
  25790. return this.stopFading();
  25791. },
  25792. // return the weight considering fading and .enabled
  25793. getEffectiveWeight: function() {
  25794. return this._effectiveWeight;
  25795. },
  25796. fadeIn: function(duration) {
  25797. return this._scheduleFading(duration, 0, 1);
  25798. },
  25799. fadeOut: function(duration) {
  25800. return this._scheduleFading(duration, 1, 0);
  25801. },
  25802. crossFadeFrom: function(fadeOutAction, duration, warp) {
  25803. fadeOutAction.fadeOut(duration);
  25804. this.fadeIn(duration);
  25805. if (warp) {
  25806. var fadeInDuration = this._clip.duration, fadeOutDuration = fadeOutAction._clip.duration, startEndRatio = fadeOutDuration / fadeInDuration, endStartRatio = fadeInDuration / fadeOutDuration;
  25807. fadeOutAction.warp(1, startEndRatio, duration);
  25808. this.warp(endStartRatio, 1, duration);
  25809. }
  25810. return this;
  25811. },
  25812. crossFadeTo: function(fadeInAction, duration, warp) {
  25813. return fadeInAction.crossFadeFrom(this, duration, warp);
  25814. },
  25815. stopFading: function() {
  25816. var weightInterpolant = this._weightInterpolant;
  25817. if (weightInterpolant !== null) {
  25818. this._weightInterpolant = null;
  25819. this._mixer._takeBackControlInterpolant(weightInterpolant);
  25820. }
  25821. return this;
  25822. },
  25823. // Time Scale Control
  25824. // set the time scale stopping any scheduled warping
  25825. // although .paused = true yields an effective time scale of zero, this
  25826. // method does *not* change .paused, because it would be confusing
  25827. setEffectiveTimeScale: function(timeScale) {
  25828. this.timeScale = timeScale;
  25829. this._effectiveTimeScale = this.paused ? 0 : timeScale;
  25830. return this.stopWarping();
  25831. },
  25832. // return the time scale considering warping and .paused
  25833. getEffectiveTimeScale: function() {
  25834. return this._effectiveTimeScale;
  25835. },
  25836. setDuration: function(duration) {
  25837. this.timeScale = this._clip.duration / duration;
  25838. return this.stopWarping();
  25839. },
  25840. syncWith: function(action) {
  25841. this.time = action.time;
  25842. this.timeScale = action.timeScale;
  25843. return this.stopWarping();
  25844. },
  25845. halt: function(duration) {
  25846. return this.warp(this._effectiveTimeScale, 0, duration);
  25847. },
  25848. warp: function(startTimeScale, endTimeScale, duration) {
  25849. var mixer = this._mixer, now = mixer.time, interpolant = this._timeScaleInterpolant, timeScale = this.timeScale;
  25850. if (interpolant === null) {
  25851. interpolant = mixer._lendControlInterpolant();
  25852. this._timeScaleInterpolant = interpolant;
  25853. }
  25854. var times = interpolant.parameterPositions, values = interpolant.sampleValues;
  25855. times[0] = now;
  25856. times[1] = now + duration;
  25857. values[0] = startTimeScale / timeScale;
  25858. values[1] = endTimeScale / timeScale;
  25859. return this;
  25860. },
  25861. stopWarping: function() {
  25862. var timeScaleInterpolant = this._timeScaleInterpolant;
  25863. if (timeScaleInterpolant !== null) {
  25864. this._timeScaleInterpolant = null;
  25865. this._mixer._takeBackControlInterpolant(timeScaleInterpolant);
  25866. }
  25867. return this;
  25868. },
  25869. // Object Accessors
  25870. getMixer: function() {
  25871. return this._mixer;
  25872. },
  25873. getClip: function() {
  25874. return this._clip;
  25875. },
  25876. getRoot: function() {
  25877. return this._localRoot || this._mixer._root;
  25878. },
  25879. // Interna
  25880. _update: function(time, deltaTime, timeDirection, accuIndex) {
  25881. if (!this.enabled) {
  25882. this._updateWeight(time);
  25883. return;
  25884. }
  25885. var startTime = this._startTime;
  25886. if (startTime !== null) {
  25887. var timeRunning = (time - startTime) * timeDirection;
  25888. if (timeRunning < 0 || timeDirection === 0) {
  25889. return;
  25890. }
  25891. this._startTime = null;
  25892. deltaTime = timeDirection * timeRunning;
  25893. }
  25894. deltaTime *= this._updateTimeScale(time);
  25895. var clipTime = this._updateTime(deltaTime);
  25896. var weight = this._updateWeight(time);
  25897. if (weight > 0) {
  25898. var interpolants = this._interpolants;
  25899. var propertyMixers = this._propertyBindings;
  25900. for (var j = 0, m = interpolants.length; j !== m; ++j) {
  25901. interpolants[j].evaluate(clipTime);
  25902. propertyMixers[j].accumulate(accuIndex, weight);
  25903. }
  25904. }
  25905. },
  25906. _updateWeight: function(time) {
  25907. var weight = 0;
  25908. if (this.enabled) {
  25909. weight = this.weight;
  25910. var interpolant = this._weightInterpolant;
  25911. if (interpolant !== null) {
  25912. var interpolantValue = interpolant.evaluate(time)[0];
  25913. weight *= interpolantValue;
  25914. if (time > interpolant.parameterPositions[1]) {
  25915. this.stopFading();
  25916. if (interpolantValue === 0) {
  25917. this.enabled = false;
  25918. }
  25919. }
  25920. }
  25921. }
  25922. this._effectiveWeight = weight;
  25923. return weight;
  25924. },
  25925. _updateTimeScale: function(time) {
  25926. var timeScale = 0;
  25927. if (!this.paused) {
  25928. timeScale = this.timeScale;
  25929. var interpolant = this._timeScaleInterpolant;
  25930. if (interpolant !== null) {
  25931. var interpolantValue = interpolant.evaluate(time)[0];
  25932. timeScale *= interpolantValue;
  25933. if (time > interpolant.parameterPositions[1]) {
  25934. this.stopWarping();
  25935. if (timeScale === 0) {
  25936. this.paused = true;
  25937. } else {
  25938. this.timeScale = timeScale;
  25939. }
  25940. }
  25941. }
  25942. }
  25943. this._effectiveTimeScale = timeScale;
  25944. return timeScale;
  25945. },
  25946. _updateTime: function(deltaTime) {
  25947. var time = this.time + deltaTime;
  25948. var duration = this._clip.duration;
  25949. var loop = this.loop;
  25950. var loopCount = this._loopCount;
  25951. var pingPong = loop === LoopPingPong;
  25952. if (deltaTime === 0) {
  25953. if (loopCount === -1)
  25954. return time;
  25955. return pingPong && (loopCount & 1) === 1 ? duration - time : time;
  25956. }
  25957. if (loop === LoopOnce) {
  25958. if (loopCount === -1) {
  25959. this._loopCount = 0;
  25960. this._setEndings(true, true, false);
  25961. }
  25962. handle_stop: {
  25963. if (time >= duration) {
  25964. time = duration;
  25965. } else if (time < 0) {
  25966. time = 0;
  25967. } else {
  25968. this.time = time;
  25969. break handle_stop;
  25970. }
  25971. if (this.clampWhenFinished)
  25972. this.paused = true;
  25973. else
  25974. this.enabled = false;
  25975. this.time = time;
  25976. this._mixer.dispatchEvent({
  25977. type: "finished",
  25978. action: this,
  25979. direction: deltaTime < 0 ? -1 : 1
  25980. });
  25981. }
  25982. } else {
  25983. if (loopCount === -1) {
  25984. if (deltaTime >= 0) {
  25985. loopCount = 0;
  25986. this._setEndings(true, this.repetitions === 0, pingPong);
  25987. } else {
  25988. this._setEndings(this.repetitions === 0, true, pingPong);
  25989. }
  25990. }
  25991. if (time >= duration || time < 0) {
  25992. var loopDelta = Math.floor(time / duration);
  25993. time -= duration * loopDelta;
  25994. loopCount += Math.abs(loopDelta);
  25995. var pending = this.repetitions - loopCount;
  25996. if (pending <= 0) {
  25997. if (this.clampWhenFinished)
  25998. this.paused = true;
  25999. else
  26000. this.enabled = false;
  26001. time = deltaTime > 0 ? duration : 0;
  26002. this.time = time;
  26003. this._mixer.dispatchEvent({
  26004. type: "finished",
  26005. action: this,
  26006. direction: deltaTime > 0 ? 1 : -1
  26007. });
  26008. } else {
  26009. if (pending === 1) {
  26010. var atStart = deltaTime < 0;
  26011. this._setEndings(atStart, !atStart, pingPong);
  26012. } else {
  26013. this._setEndings(false, false, pingPong);
  26014. }
  26015. this._loopCount = loopCount;
  26016. this.time = time;
  26017. this._mixer.dispatchEvent({
  26018. type: "loop",
  26019. action: this,
  26020. loopDelta
  26021. });
  26022. }
  26023. } else {
  26024. this.time = time;
  26025. }
  26026. if (pingPong && (loopCount & 1) === 1) {
  26027. return duration - time;
  26028. }
  26029. }
  26030. return time;
  26031. },
  26032. _setEndings: function(atStart, atEnd, pingPong) {
  26033. var settings = this._interpolantSettings;
  26034. if (pingPong) {
  26035. settings.endingStart = ZeroSlopeEnding;
  26036. settings.endingEnd = ZeroSlopeEnding;
  26037. } else {
  26038. if (atStart) {
  26039. settings.endingStart = this.zeroSlopeAtStart ? ZeroSlopeEnding : ZeroCurvatureEnding;
  26040. } else {
  26041. settings.endingStart = WrapAroundEnding;
  26042. }
  26043. if (atEnd) {
  26044. settings.endingEnd = this.zeroSlopeAtEnd ? ZeroSlopeEnding : ZeroCurvatureEnding;
  26045. } else {
  26046. settings.endingEnd = WrapAroundEnding;
  26047. }
  26048. }
  26049. },
  26050. _scheduleFading: function(duration, weightNow, weightThen) {
  26051. var mixer = this._mixer, now = mixer.time, interpolant = this._weightInterpolant;
  26052. if (interpolant === null) {
  26053. interpolant = mixer._lendControlInterpolant();
  26054. this._weightInterpolant = interpolant;
  26055. }
  26056. var times = interpolant.parameterPositions, values = interpolant.sampleValues;
  26057. times[0] = now;
  26058. values[0] = weightNow;
  26059. times[1] = now + duration;
  26060. values[1] = weightThen;
  26061. return this;
  26062. }
  26063. });
  26064. function AnimationMixer(root) {
  26065. this._root = root;
  26066. this._initMemoryManager();
  26067. this._accuIndex = 0;
  26068. this.time = 0;
  26069. this.timeScale = 1;
  26070. }
  26071. AnimationMixer.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
  26072. constructor: AnimationMixer,
  26073. _bindAction: function(action, prototypeAction) {
  26074. var root = action._localRoot || this._root, tracks = action._clip.tracks, nTracks = tracks.length, bindings = action._propertyBindings, interpolants = action._interpolants, rootUuid = root.uuid, bindingsByRoot = this._bindingsByRootAndName, bindingsByName = bindingsByRoot[rootUuid];
  26075. if (bindingsByName === void 0) {
  26076. bindingsByName = {};
  26077. bindingsByRoot[rootUuid] = bindingsByName;
  26078. }
  26079. for (var i2 = 0; i2 !== nTracks; ++i2) {
  26080. var track = tracks[i2], trackName = track.name, binding = bindingsByName[trackName];
  26081. if (binding !== void 0) {
  26082. bindings[i2] = binding;
  26083. } else {
  26084. binding = bindings[i2];
  26085. if (binding !== void 0) {
  26086. if (binding._cacheIndex === null) {
  26087. ++binding.referenceCount;
  26088. this._addInactiveBinding(binding, rootUuid, trackName);
  26089. }
  26090. continue;
  26091. }
  26092. var path = prototypeAction && prototypeAction._propertyBindings[i2].binding.parsedPath;
  26093. binding = new PropertyMixer(
  26094. PropertyBinding.create(root, trackName, path),
  26095. track.ValueTypeName,
  26096. track.getValueSize()
  26097. );
  26098. ++binding.referenceCount;
  26099. this._addInactiveBinding(binding, rootUuid, trackName);
  26100. bindings[i2] = binding;
  26101. }
  26102. interpolants[i2].resultBuffer = binding.buffer;
  26103. }
  26104. },
  26105. _activateAction: function(action) {
  26106. if (!this._isActiveAction(action)) {
  26107. if (action._cacheIndex === null) {
  26108. var rootUuid = (action._localRoot || this._root).uuid, clipUuid = action._clip.uuid, actionsForClip = this._actionsByClip[clipUuid];
  26109. this._bindAction(
  26110. action,
  26111. actionsForClip && actionsForClip.knownActions[0]
  26112. );
  26113. this._addInactiveAction(action, clipUuid, rootUuid);
  26114. }
  26115. var bindings = action._propertyBindings;
  26116. for (var i2 = 0, n = bindings.length; i2 !== n; ++i2) {
  26117. var binding = bindings[i2];
  26118. if (binding.useCount++ === 0) {
  26119. this._lendBinding(binding);
  26120. binding.saveOriginalState();
  26121. }
  26122. }
  26123. this._lendAction(action);
  26124. }
  26125. },
  26126. _deactivateAction: function(action) {
  26127. if (this._isActiveAction(action)) {
  26128. var bindings = action._propertyBindings;
  26129. for (var i2 = 0, n = bindings.length; i2 !== n; ++i2) {
  26130. var binding = bindings[i2];
  26131. if (--binding.useCount === 0) {
  26132. binding.restoreOriginalState();
  26133. this._takeBackBinding(binding);
  26134. }
  26135. }
  26136. this._takeBackAction(action);
  26137. }
  26138. },
  26139. // Memory manager
  26140. _initMemoryManager: function() {
  26141. this._actions = [];
  26142. this._nActiveActions = 0;
  26143. this._actionsByClip = {};
  26144. this._bindings = [];
  26145. this._nActiveBindings = 0;
  26146. this._bindingsByRootAndName = {};
  26147. this._controlInterpolants = [];
  26148. this._nActiveControlInterpolants = 0;
  26149. var scope = this;
  26150. this.stats = {
  26151. actions: {
  26152. get total() {
  26153. return scope._actions.length;
  26154. },
  26155. get inUse() {
  26156. return scope._nActiveActions;
  26157. }
  26158. },
  26159. bindings: {
  26160. get total() {
  26161. return scope._bindings.length;
  26162. },
  26163. get inUse() {
  26164. return scope._nActiveBindings;
  26165. }
  26166. },
  26167. controlInterpolants: {
  26168. get total() {
  26169. return scope._controlInterpolants.length;
  26170. },
  26171. get inUse() {
  26172. return scope._nActiveControlInterpolants;
  26173. }
  26174. }
  26175. };
  26176. },
  26177. // Memory management for AnimationAction objects
  26178. _isActiveAction: function(action) {
  26179. var index = action._cacheIndex;
  26180. return index !== null && index < this._nActiveActions;
  26181. },
  26182. _addInactiveAction: function(action, clipUuid, rootUuid) {
  26183. var actions = this._actions, actionsByClip = this._actionsByClip, actionsForClip = actionsByClip[clipUuid];
  26184. if (actionsForClip === void 0) {
  26185. actionsForClip = {
  26186. knownActions: [action],
  26187. actionByRoot: {}
  26188. };
  26189. action._byClipCacheIndex = 0;
  26190. actionsByClip[clipUuid] = actionsForClip;
  26191. } else {
  26192. var knownActions = actionsForClip.knownActions;
  26193. action._byClipCacheIndex = knownActions.length;
  26194. knownActions.push(action);
  26195. }
  26196. action._cacheIndex = actions.length;
  26197. actions.push(action);
  26198. actionsForClip.actionByRoot[rootUuid] = action;
  26199. },
  26200. _removeInactiveAction: function(action) {
  26201. var actions = this._actions, lastInactiveAction = actions[actions.length - 1], cacheIndex = action._cacheIndex;
  26202. lastInactiveAction._cacheIndex = cacheIndex;
  26203. actions[cacheIndex] = lastInactiveAction;
  26204. actions.pop();
  26205. action._cacheIndex = null;
  26206. var clipUuid = action._clip.uuid, actionsByClip = this._actionsByClip, actionsForClip = actionsByClip[clipUuid], knownActionsForClip = actionsForClip.knownActions, lastKnownAction = knownActionsForClip[knownActionsForClip.length - 1], byClipCacheIndex = action._byClipCacheIndex;
  26207. lastKnownAction._byClipCacheIndex = byClipCacheIndex;
  26208. knownActionsForClip[byClipCacheIndex] = lastKnownAction;
  26209. knownActionsForClip.pop();
  26210. action._byClipCacheIndex = null;
  26211. var actionByRoot = actionsForClip.actionByRoot, rootUuid = (action._localRoot || this._root).uuid;
  26212. delete actionByRoot[rootUuid];
  26213. if (knownActionsForClip.length === 0) {
  26214. delete actionsByClip[clipUuid];
  26215. }
  26216. this._removeInactiveBindingsForAction(action);
  26217. },
  26218. _removeInactiveBindingsForAction: function(action) {
  26219. var bindings = action._propertyBindings;
  26220. for (var i2 = 0, n = bindings.length; i2 !== n; ++i2) {
  26221. var binding = bindings[i2];
  26222. if (--binding.referenceCount === 0) {
  26223. this._removeInactiveBinding(binding);
  26224. }
  26225. }
  26226. },
  26227. _lendAction: function(action) {
  26228. var actions = this._actions, prevIndex = action._cacheIndex, lastActiveIndex = this._nActiveActions++, firstInactiveAction = actions[lastActiveIndex];
  26229. action._cacheIndex = lastActiveIndex;
  26230. actions[lastActiveIndex] = action;
  26231. firstInactiveAction._cacheIndex = prevIndex;
  26232. actions[prevIndex] = firstInactiveAction;
  26233. },
  26234. _takeBackAction: function(action) {
  26235. var actions = this._actions, prevIndex = action._cacheIndex, firstInactiveIndex = --this._nActiveActions, lastActiveAction = actions[firstInactiveIndex];
  26236. action._cacheIndex = firstInactiveIndex;
  26237. actions[firstInactiveIndex] = action;
  26238. lastActiveAction._cacheIndex = prevIndex;
  26239. actions[prevIndex] = lastActiveAction;
  26240. },
  26241. // Memory management for PropertyMixer objects
  26242. _addInactiveBinding: function(binding, rootUuid, trackName) {
  26243. var bindingsByRoot = this._bindingsByRootAndName, bindingByName = bindingsByRoot[rootUuid], bindings = this._bindings;
  26244. if (bindingByName === void 0) {
  26245. bindingByName = {};
  26246. bindingsByRoot[rootUuid] = bindingByName;
  26247. }
  26248. bindingByName[trackName] = binding;
  26249. binding._cacheIndex = bindings.length;
  26250. bindings.push(binding);
  26251. },
  26252. _removeInactiveBinding: function(binding) {
  26253. var bindings = this._bindings, propBinding = binding.binding, rootUuid = propBinding.rootNode.uuid, trackName = propBinding.path, bindingsByRoot = this._bindingsByRootAndName, bindingByName = bindingsByRoot[rootUuid], lastInactiveBinding = bindings[bindings.length - 1], cacheIndex = binding._cacheIndex;
  26254. lastInactiveBinding._cacheIndex = cacheIndex;
  26255. bindings[cacheIndex] = lastInactiveBinding;
  26256. bindings.pop();
  26257. delete bindingByName[trackName];
  26258. if (Object.keys(bindingByName).length === 0) {
  26259. delete bindingsByRoot[rootUuid];
  26260. }
  26261. },
  26262. _lendBinding: function(binding) {
  26263. var bindings = this._bindings, prevIndex = binding._cacheIndex, lastActiveIndex = this._nActiveBindings++, firstInactiveBinding = bindings[lastActiveIndex];
  26264. binding._cacheIndex = lastActiveIndex;
  26265. bindings[lastActiveIndex] = binding;
  26266. firstInactiveBinding._cacheIndex = prevIndex;
  26267. bindings[prevIndex] = firstInactiveBinding;
  26268. },
  26269. _takeBackBinding: function(binding) {
  26270. var bindings = this._bindings, prevIndex = binding._cacheIndex, firstInactiveIndex = --this._nActiveBindings, lastActiveBinding = bindings[firstInactiveIndex];
  26271. binding._cacheIndex = firstInactiveIndex;
  26272. bindings[firstInactiveIndex] = binding;
  26273. lastActiveBinding._cacheIndex = prevIndex;
  26274. bindings[prevIndex] = lastActiveBinding;
  26275. },
  26276. // Memory management of Interpolants for weight and time scale
  26277. _lendControlInterpolant: function() {
  26278. var interpolants = this._controlInterpolants, lastActiveIndex = this._nActiveControlInterpolants++, interpolant = interpolants[lastActiveIndex];
  26279. if (interpolant === void 0) {
  26280. interpolant = new LinearInterpolant(
  26281. new Float32Array(2),
  26282. new Float32Array(2),
  26283. 1,
  26284. this._controlInterpolantsResultBuffer
  26285. );
  26286. interpolant.__cacheIndex = lastActiveIndex;
  26287. interpolants[lastActiveIndex] = interpolant;
  26288. }
  26289. return interpolant;
  26290. },
  26291. _takeBackControlInterpolant: function(interpolant) {
  26292. var interpolants = this._controlInterpolants, prevIndex = interpolant.__cacheIndex, firstInactiveIndex = --this._nActiveControlInterpolants, lastActiveInterpolant = interpolants[firstInactiveIndex];
  26293. interpolant.__cacheIndex = firstInactiveIndex;
  26294. interpolants[firstInactiveIndex] = interpolant;
  26295. lastActiveInterpolant.__cacheIndex = prevIndex;
  26296. interpolants[prevIndex] = lastActiveInterpolant;
  26297. },
  26298. _controlInterpolantsResultBuffer: new Float32Array(1),
  26299. // return an action for a clip optionally using a custom root target
  26300. // object (this method allocates a lot of dynamic memory in case a
  26301. // previously unknown clip/root combination is specified)
  26302. clipAction: function(clip, optionalRoot) {
  26303. var root = optionalRoot || this._root, rootUuid = root.uuid, clipObject = typeof clip === "string" ? AnimationClip.findByName(root, clip) : clip, clipUuid = clipObject !== null ? clipObject.uuid : clip, actionsForClip = this._actionsByClip[clipUuid], prototypeAction = null;
  26304. if (actionsForClip !== void 0) {
  26305. var existingAction = actionsForClip.actionByRoot[rootUuid];
  26306. if (existingAction !== void 0) {
  26307. return existingAction;
  26308. }
  26309. prototypeAction = actionsForClip.knownActions[0];
  26310. if (clipObject === null)
  26311. clipObject = prototypeAction._clip;
  26312. }
  26313. if (clipObject === null)
  26314. return null;
  26315. var newAction = new AnimationAction(this, clipObject, optionalRoot);
  26316. this._bindAction(newAction, prototypeAction);
  26317. this._addInactiveAction(newAction, clipUuid, rootUuid);
  26318. return newAction;
  26319. },
  26320. // get an existing action
  26321. existingAction: function(clip, optionalRoot) {
  26322. var root = optionalRoot || this._root, rootUuid = root.uuid, clipObject = typeof clip === "string" ? AnimationClip.findByName(root, clip) : clip, clipUuid = clipObject ? clipObject.uuid : clip, actionsForClip = this._actionsByClip[clipUuid];
  26323. if (actionsForClip !== void 0) {
  26324. return actionsForClip.actionByRoot[rootUuid] || null;
  26325. }
  26326. return null;
  26327. },
  26328. // deactivates all previously scheduled actions
  26329. stopAllAction: function() {
  26330. var actions = this._actions, nActions = this._nActiveActions, bindings = this._bindings, nBindings = this._nActiveBindings;
  26331. this._nActiveActions = 0;
  26332. this._nActiveBindings = 0;
  26333. for (var i2 = 0; i2 !== nActions; ++i2) {
  26334. actions[i2].reset();
  26335. }
  26336. for (var i2 = 0; i2 !== nBindings; ++i2) {
  26337. bindings[i2].useCount = 0;
  26338. }
  26339. return this;
  26340. },
  26341. // advance the time and update apply the animation
  26342. update: function(deltaTime) {
  26343. deltaTime *= this.timeScale;
  26344. var actions = this._actions, nActions = this._nActiveActions, time = this.time += deltaTime, timeDirection = Math.sign(deltaTime), accuIndex = this._accuIndex ^= 1;
  26345. for (var i2 = 0; i2 !== nActions; ++i2) {
  26346. var action = actions[i2];
  26347. action._update(time, deltaTime, timeDirection, accuIndex);
  26348. }
  26349. var bindings = this._bindings, nBindings = this._nActiveBindings;
  26350. for (var i2 = 0; i2 !== nBindings; ++i2) {
  26351. bindings[i2].apply(accuIndex);
  26352. }
  26353. return this;
  26354. },
  26355. // Allows you to seek to a specific time in an animation.
  26356. setTime: function(timeInSeconds) {
  26357. this.time = 0;
  26358. for (var i2 = 0; i2 < this._actions.length; i2++) {
  26359. this._actions[i2].time = 0;
  26360. }
  26361. return this.update(timeInSeconds);
  26362. },
  26363. // return this mixer's root target object
  26364. getRoot: function() {
  26365. return this._root;
  26366. },
  26367. // free all resources specific to a particular clip
  26368. uncacheClip: function(clip) {
  26369. var actions = this._actions, clipUuid = clip.uuid, actionsByClip = this._actionsByClip, actionsForClip = actionsByClip[clipUuid];
  26370. if (actionsForClip !== void 0) {
  26371. var actionsToRemove = actionsForClip.knownActions;
  26372. for (var i2 = 0, n = actionsToRemove.length; i2 !== n; ++i2) {
  26373. var action = actionsToRemove[i2];
  26374. this._deactivateAction(action);
  26375. var cacheIndex = action._cacheIndex, lastInactiveAction = actions[actions.length - 1];
  26376. action._cacheIndex = null;
  26377. action._byClipCacheIndex = null;
  26378. lastInactiveAction._cacheIndex = cacheIndex;
  26379. actions[cacheIndex] = lastInactiveAction;
  26380. actions.pop();
  26381. this._removeInactiveBindingsForAction(action);
  26382. }
  26383. delete actionsByClip[clipUuid];
  26384. }
  26385. },
  26386. // free all resources specific to a particular root target object
  26387. uncacheRoot: function(root) {
  26388. var rootUuid = root.uuid, actionsByClip = this._actionsByClip;
  26389. for (var clipUuid in actionsByClip) {
  26390. var actionByRoot = actionsByClip[clipUuid].actionByRoot, action = actionByRoot[rootUuid];
  26391. if (action !== void 0) {
  26392. this._deactivateAction(action);
  26393. this._removeInactiveAction(action);
  26394. }
  26395. }
  26396. var bindingsByRoot = this._bindingsByRootAndName, bindingByName = bindingsByRoot[rootUuid];
  26397. if (bindingByName !== void 0) {
  26398. for (var trackName in bindingByName) {
  26399. var binding = bindingByName[trackName];
  26400. binding.restoreOriginalState();
  26401. this._removeInactiveBinding(binding);
  26402. }
  26403. }
  26404. },
  26405. // remove a targeted clip from the cache
  26406. uncacheAction: function(clip, optionalRoot) {
  26407. var action = this.existingAction(clip, optionalRoot);
  26408. if (action !== null) {
  26409. this._deactivateAction(action);
  26410. this._removeInactiveAction(action);
  26411. }
  26412. }
  26413. });
  26414. function Uniform(value) {
  26415. if (typeof value === "string") {
  26416. console.warn("THREE.Uniform: Type parameter is no longer needed.");
  26417. value = arguments[1];
  26418. }
  26419. this.value = value;
  26420. }
  26421. Uniform.prototype.clone = function() {
  26422. return new Uniform(this.value.clone === void 0 ? this.value : this.value.clone());
  26423. };
  26424. function InstancedInterleavedBuffer(array, stride, meshPerAttribute) {
  26425. InterleavedBuffer.call(this, array, stride);
  26426. this.meshPerAttribute = meshPerAttribute || 1;
  26427. }
  26428. InstancedInterleavedBuffer.prototype = Object.assign(Object.create(InterleavedBuffer.prototype), {
  26429. constructor: InstancedInterleavedBuffer,
  26430. isInstancedInterleavedBuffer: true,
  26431. copy: function(source) {
  26432. InterleavedBuffer.prototype.copy.call(this, source);
  26433. this.meshPerAttribute = source.meshPerAttribute;
  26434. return this;
  26435. }
  26436. });
  26437. function Raycaster(origin, direction, near, far) {
  26438. this.ray = new Ray(origin, direction);
  26439. this.near = near || 0;
  26440. this.far = far || Infinity;
  26441. this.camera = null;
  26442. this.params = {
  26443. Mesh: {},
  26444. Line: {},
  26445. LOD: {},
  26446. Points: { threshold: 1 },
  26447. Sprite: {}
  26448. };
  26449. Object.defineProperties(this.params, {
  26450. PointCloud: {
  26451. get: function() {
  26452. console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points.");
  26453. return this.Points;
  26454. }
  26455. }
  26456. });
  26457. }
  26458. function ascSort(a, b) {
  26459. return a.distance - b.distance;
  26460. }
  26461. function intersectObject(object, raycaster, intersects2, recursive) {
  26462. if (object.visible === false)
  26463. return;
  26464. object.raycast(raycaster, intersects2);
  26465. if (recursive === true) {
  26466. var children = object.children;
  26467. for (var i2 = 0, l = children.length; i2 < l; i2++) {
  26468. intersectObject(children[i2], raycaster, intersects2, true);
  26469. }
  26470. }
  26471. }
  26472. Object.assign(Raycaster.prototype, {
  26473. linePrecision: 1,
  26474. set: function(origin, direction) {
  26475. this.ray.set(origin, direction);
  26476. },
  26477. setFromCamera: function(coords, camera) {
  26478. if (camera && camera.isPerspectiveCamera) {
  26479. this.ray.origin.setFromMatrixPosition(camera.matrixWorld);
  26480. this.ray.direction.set(coords.x, coords.y, 0.5).unproject(camera).sub(this.ray.origin).normalize();
  26481. this.camera = camera;
  26482. } else if (camera && camera.isOrthographicCamera) {
  26483. this.ray.origin.set(coords.x, coords.y, (camera.near + camera.far) / (camera.near - camera.far)).unproject(camera);
  26484. this.ray.direction.set(0, 0, -1).transformDirection(camera.matrixWorld);
  26485. this.camera = camera;
  26486. } else {
  26487. console.error("THREE.Raycaster: Unsupported camera type.");
  26488. }
  26489. },
  26490. intersectObject: function(object, recursive, optionalTarget) {
  26491. var intersects2 = optionalTarget || [];
  26492. intersectObject(object, this, intersects2, recursive);
  26493. intersects2.sort(ascSort);
  26494. return intersects2;
  26495. },
  26496. intersectObjects: function(objects, recursive, optionalTarget) {
  26497. var intersects2 = optionalTarget || [];
  26498. if (Array.isArray(objects) === false) {
  26499. console.warn("THREE.Raycaster.intersectObjects: objects is not an Array.");
  26500. return intersects2;
  26501. }
  26502. for (var i2 = 0, l = objects.length; i2 < l; i2++) {
  26503. intersectObject(objects[i2], this, intersects2, recursive);
  26504. }
  26505. intersects2.sort(ascSort);
  26506. return intersects2;
  26507. }
  26508. });
  26509. function Spherical(radius, phi, theta) {
  26510. this.radius = radius !== void 0 ? radius : 1;
  26511. this.phi = phi !== void 0 ? phi : 0;
  26512. this.theta = theta !== void 0 ? theta : 0;
  26513. return this;
  26514. }
  26515. Object.assign(Spherical.prototype, {
  26516. set: function(radius, phi, theta) {
  26517. this.radius = radius;
  26518. this.phi = phi;
  26519. this.theta = theta;
  26520. return this;
  26521. },
  26522. clone: function() {
  26523. return new this.constructor().copy(this);
  26524. },
  26525. copy: function(other) {
  26526. this.radius = other.radius;
  26527. this.phi = other.phi;
  26528. this.theta = other.theta;
  26529. return this;
  26530. },
  26531. // restrict phi to be betwee EPS and PI-EPS
  26532. makeSafe: function() {
  26533. var EPS = 1e-6;
  26534. this.phi = Math.max(EPS, Math.min(Math.PI - EPS, this.phi));
  26535. return this;
  26536. },
  26537. setFromVector3: function(v) {
  26538. return this.setFromCartesianCoords(v.x, v.y, v.z);
  26539. },
  26540. setFromCartesianCoords: function(x, y, z) {
  26541. this.radius = Math.sqrt(x * x + y * y + z * z);
  26542. if (this.radius === 0) {
  26543. this.theta = 0;
  26544. this.phi = 0;
  26545. } else {
  26546. this.theta = Math.atan2(x, z);
  26547. this.phi = Math.acos(MathUtils.clamp(y / this.radius, -1, 1));
  26548. }
  26549. return this;
  26550. }
  26551. });
  26552. function Cylindrical(radius, theta, y) {
  26553. this.radius = radius !== void 0 ? radius : 1;
  26554. this.theta = theta !== void 0 ? theta : 0;
  26555. this.y = y !== void 0 ? y : 0;
  26556. return this;
  26557. }
  26558. Object.assign(Cylindrical.prototype, {
  26559. set: function(radius, theta, y) {
  26560. this.radius = radius;
  26561. this.theta = theta;
  26562. this.y = y;
  26563. return this;
  26564. },
  26565. clone: function() {
  26566. return new this.constructor().copy(this);
  26567. },
  26568. copy: function(other) {
  26569. this.radius = other.radius;
  26570. this.theta = other.theta;
  26571. this.y = other.y;
  26572. return this;
  26573. },
  26574. setFromVector3: function(v) {
  26575. return this.setFromCartesianCoords(v.x, v.y, v.z);
  26576. },
  26577. setFromCartesianCoords: function(x, y, z) {
  26578. this.radius = Math.sqrt(x * x + z * z);
  26579. this.theta = Math.atan2(x, z);
  26580. this.y = y;
  26581. return this;
  26582. }
  26583. });
  26584. var _vector$7 = new Vector2();
  26585. function Box2(min, max) {
  26586. this.min = min !== void 0 ? min : new Vector2(Infinity, Infinity);
  26587. this.max = max !== void 0 ? max : new Vector2(-Infinity, -Infinity);
  26588. }
  26589. Object.assign(Box2.prototype, {
  26590. set: function(min, max) {
  26591. this.min.copy(min);
  26592. this.max.copy(max);
  26593. return this;
  26594. },
  26595. setFromPoints: function(points) {
  26596. this.makeEmpty();
  26597. for (var i2 = 0, il = points.length; i2 < il; i2++) {
  26598. this.expandByPoint(points[i2]);
  26599. }
  26600. return this;
  26601. },
  26602. setFromCenterAndSize: function(center, size) {
  26603. var halfSize = _vector$7.copy(size).multiplyScalar(0.5);
  26604. this.min.copy(center).sub(halfSize);
  26605. this.max.copy(center).add(halfSize);
  26606. return this;
  26607. },
  26608. clone: function() {
  26609. return new this.constructor().copy(this);
  26610. },
  26611. copy: function(box) {
  26612. this.min.copy(box.min);
  26613. this.max.copy(box.max);
  26614. return this;
  26615. },
  26616. makeEmpty: function() {
  26617. this.min.x = this.min.y = Infinity;
  26618. this.max.x = this.max.y = -Infinity;
  26619. return this;
  26620. },
  26621. isEmpty: function() {
  26622. return this.max.x < this.min.x || this.max.y < this.min.y;
  26623. },
  26624. getCenter: function(target) {
  26625. if (target === void 0) {
  26626. console.warn("THREE.Box2: .getCenter() target is now required");
  26627. target = new Vector2();
  26628. }
  26629. return this.isEmpty() ? target.set(0, 0) : target.addVectors(this.min, this.max).multiplyScalar(0.5);
  26630. },
  26631. getSize: function(target) {
  26632. if (target === void 0) {
  26633. console.warn("THREE.Box2: .getSize() target is now required");
  26634. target = new Vector2();
  26635. }
  26636. return this.isEmpty() ? target.set(0, 0) : target.subVectors(this.max, this.min);
  26637. },
  26638. expandByPoint: function(point) {
  26639. this.min.min(point);
  26640. this.max.max(point);
  26641. return this;
  26642. },
  26643. expandByVector: function(vector) {
  26644. this.min.sub(vector);
  26645. this.max.add(vector);
  26646. return this;
  26647. },
  26648. expandByScalar: function(scalar) {
  26649. this.min.addScalar(-scalar);
  26650. this.max.addScalar(scalar);
  26651. return this;
  26652. },
  26653. containsPoint: function(point) {
  26654. return point.x < this.min.x || point.x > this.max.x || point.y < this.min.y || point.y > this.max.y ? false : true;
  26655. },
  26656. containsBox: function(box) {
  26657. return this.min.x <= box.min.x && box.max.x <= this.max.x && this.min.y <= box.min.y && box.max.y <= this.max.y;
  26658. },
  26659. getParameter: function(point, target) {
  26660. if (target === void 0) {
  26661. console.warn("THREE.Box2: .getParameter() target is now required");
  26662. target = new Vector2();
  26663. }
  26664. return target.set(
  26665. (point.x - this.min.x) / (this.max.x - this.min.x),
  26666. (point.y - this.min.y) / (this.max.y - this.min.y)
  26667. );
  26668. },
  26669. intersectsBox: function(box) {
  26670. return box.max.x < this.min.x || box.min.x > this.max.x || box.max.y < this.min.y || box.min.y > this.max.y ? false : true;
  26671. },
  26672. clampPoint: function(point, target) {
  26673. if (target === void 0) {
  26674. console.warn("THREE.Box2: .clampPoint() target is now required");
  26675. target = new Vector2();
  26676. }
  26677. return target.copy(point).clamp(this.min, this.max);
  26678. },
  26679. distanceToPoint: function(point) {
  26680. var clampedPoint = _vector$7.copy(point).clamp(this.min, this.max);
  26681. return clampedPoint.sub(point).length();
  26682. },
  26683. intersect: function(box) {
  26684. this.min.max(box.min);
  26685. this.max.min(box.max);
  26686. return this;
  26687. },
  26688. union: function(box) {
  26689. this.min.min(box.min);
  26690. this.max.max(box.max);
  26691. return this;
  26692. },
  26693. translate: function(offset) {
  26694. this.min.add(offset);
  26695. this.max.add(offset);
  26696. return this;
  26697. },
  26698. equals: function(box) {
  26699. return box.min.equals(this.min) && box.max.equals(this.max);
  26700. }
  26701. });
  26702. var _startP = new Vector3();
  26703. var _startEnd = new Vector3();
  26704. function Line3(start, end) {
  26705. this.start = start !== void 0 ? start : new Vector3();
  26706. this.end = end !== void 0 ? end : new Vector3();
  26707. }
  26708. Object.assign(Line3.prototype, {
  26709. set: function(start, end) {
  26710. this.start.copy(start);
  26711. this.end.copy(end);
  26712. return this;
  26713. },
  26714. clone: function() {
  26715. return new this.constructor().copy(this);
  26716. },
  26717. copy: function(line) {
  26718. this.start.copy(line.start);
  26719. this.end.copy(line.end);
  26720. return this;
  26721. },
  26722. getCenter: function(target) {
  26723. if (target === void 0) {
  26724. console.warn("THREE.Line3: .getCenter() target is now required");
  26725. target = new Vector3();
  26726. }
  26727. return target.addVectors(this.start, this.end).multiplyScalar(0.5);
  26728. },
  26729. delta: function(target) {
  26730. if (target === void 0) {
  26731. console.warn("THREE.Line3: .delta() target is now required");
  26732. target = new Vector3();
  26733. }
  26734. return target.subVectors(this.end, this.start);
  26735. },
  26736. distanceSq: function() {
  26737. return this.start.distanceToSquared(this.end);
  26738. },
  26739. distance: function() {
  26740. return this.start.distanceTo(this.end);
  26741. },
  26742. at: function(t, target) {
  26743. if (target === void 0) {
  26744. console.warn("THREE.Line3: .at() target is now required");
  26745. target = new Vector3();
  26746. }
  26747. return this.delta(target).multiplyScalar(t).add(this.start);
  26748. },
  26749. closestPointToPointParameter: function(point, clampToLine) {
  26750. _startP.subVectors(point, this.start);
  26751. _startEnd.subVectors(this.end, this.start);
  26752. var startEnd2 = _startEnd.dot(_startEnd);
  26753. var startEnd_startP = _startEnd.dot(_startP);
  26754. var t = startEnd_startP / startEnd2;
  26755. if (clampToLine) {
  26756. t = MathUtils.clamp(t, 0, 1);
  26757. }
  26758. return t;
  26759. },
  26760. closestPointToPoint: function(point, clampToLine, target) {
  26761. var t = this.closestPointToPointParameter(point, clampToLine);
  26762. if (target === void 0) {
  26763. console.warn("THREE.Line3: .closestPointToPoint() target is now required");
  26764. target = new Vector3();
  26765. }
  26766. return this.delta(target).multiplyScalar(t).add(this.start);
  26767. },
  26768. applyMatrix4: function(matrix) {
  26769. this.start.applyMatrix4(matrix);
  26770. this.end.applyMatrix4(matrix);
  26771. return this;
  26772. },
  26773. equals: function(line) {
  26774. return line.start.equals(this.start) && line.end.equals(this.end);
  26775. }
  26776. });
  26777. function ImmediateRenderObject(material) {
  26778. Object3D.call(this);
  26779. this.material = material;
  26780. this.render = function() {
  26781. };
  26782. }
  26783. ImmediateRenderObject.prototype = Object.create(Object3D.prototype);
  26784. ImmediateRenderObject.prototype.constructor = ImmediateRenderObject;
  26785. ImmediateRenderObject.prototype.isImmediateRenderObject = true;
  26786. var _vector$8 = new Vector3();
  26787. function SpotLightHelper(light, color) {
  26788. Object3D.call(this);
  26789. this.light = light;
  26790. this.light.updateMatrixWorld();
  26791. this.matrix = light.matrixWorld;
  26792. this.matrixAutoUpdate = false;
  26793. this.color = color;
  26794. var geometry = new BufferGeometry();
  26795. var positions = [
  26796. 0,
  26797. 0,
  26798. 0,
  26799. 0,
  26800. 0,
  26801. 1,
  26802. 0,
  26803. 0,
  26804. 0,
  26805. 1,
  26806. 0,
  26807. 1,
  26808. 0,
  26809. 0,
  26810. 0,
  26811. -1,
  26812. 0,
  26813. 1,
  26814. 0,
  26815. 0,
  26816. 0,
  26817. 0,
  26818. 1,
  26819. 1,
  26820. 0,
  26821. 0,
  26822. 0,
  26823. 0,
  26824. -1,
  26825. 1
  26826. ];
  26827. for (var i2 = 0, j = 1, l = 32; i2 < l; i2++, j++) {
  26828. var p1 = i2 / l * Math.PI * 2;
  26829. var p2 = j / l * Math.PI * 2;
  26830. positions.push(
  26831. Math.cos(p1),
  26832. Math.sin(p1),
  26833. 1,
  26834. Math.cos(p2),
  26835. Math.sin(p2),
  26836. 1
  26837. );
  26838. }
  26839. geometry.setAttribute("position", new Float32BufferAttribute(positions, 3));
  26840. var material = new LineBasicMaterial({ fog: false });
  26841. this.cone = new LineSegments(geometry, material);
  26842. this.add(this.cone);
  26843. this.update();
  26844. }
  26845. SpotLightHelper.prototype = Object.create(Object3D.prototype);
  26846. SpotLightHelper.prototype.constructor = SpotLightHelper;
  26847. SpotLightHelper.prototype.dispose = function() {
  26848. this.cone.geometry.dispose();
  26849. this.cone.material.dispose();
  26850. };
  26851. SpotLightHelper.prototype.update = function() {
  26852. this.light.updateMatrixWorld();
  26853. var coneLength = this.light.distance ? this.light.distance : 1e3;
  26854. var coneWidth = coneLength * Math.tan(this.light.angle);
  26855. this.cone.scale.set(coneWidth, coneWidth, coneLength);
  26856. _vector$8.setFromMatrixPosition(this.light.target.matrixWorld);
  26857. this.cone.lookAt(_vector$8);
  26858. if (this.color !== void 0) {
  26859. this.cone.material.color.set(this.color);
  26860. } else {
  26861. this.cone.material.color.copy(this.light.color);
  26862. }
  26863. };
  26864. var _vector$9 = new Vector3();
  26865. var _boneMatrix = new Matrix4();
  26866. var _matrixWorldInv = new Matrix4();
  26867. function getBoneList(object) {
  26868. var boneList = [];
  26869. if (object && object.isBone) {
  26870. boneList.push(object);
  26871. }
  26872. for (var i2 = 0; i2 < object.children.length; i2++) {
  26873. boneList.push.apply(boneList, getBoneList(object.children[i2]));
  26874. }
  26875. return boneList;
  26876. }
  26877. function SkeletonHelper(object) {
  26878. var bones = getBoneList(object);
  26879. var geometry = new BufferGeometry();
  26880. var vertices = [];
  26881. var colors = [];
  26882. var color1 = new Color(0, 0, 1);
  26883. var color2 = new Color(0, 1, 0);
  26884. for (var i2 = 0; i2 < bones.length; i2++) {
  26885. var bone = bones[i2];
  26886. if (bone.parent && bone.parent.isBone) {
  26887. vertices.push(0, 0, 0);
  26888. vertices.push(0, 0, 0);
  26889. colors.push(color1.r, color1.g, color1.b);
  26890. colors.push(color2.r, color2.g, color2.b);
  26891. }
  26892. }
  26893. geometry.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  26894. geometry.setAttribute("color", new Float32BufferAttribute(colors, 3));
  26895. var material = new LineBasicMaterial({ vertexColors: VertexColors, depthTest: false, depthWrite: false, transparent: true });
  26896. LineSegments.call(this, geometry, material);
  26897. this.root = object;
  26898. this.bones = bones;
  26899. this.matrix = object.matrixWorld;
  26900. this.matrixAutoUpdate = false;
  26901. }
  26902. SkeletonHelper.prototype = Object.create(LineSegments.prototype);
  26903. SkeletonHelper.prototype.constructor = SkeletonHelper;
  26904. SkeletonHelper.prototype.updateMatrixWorld = function(force) {
  26905. var bones = this.bones;
  26906. var geometry = this.geometry;
  26907. var position = geometry.getAttribute("position");
  26908. _matrixWorldInv.getInverse(this.root.matrixWorld);
  26909. for (var i2 = 0, j = 0; i2 < bones.length; i2++) {
  26910. var bone = bones[i2];
  26911. if (bone.parent && bone.parent.isBone) {
  26912. _boneMatrix.multiplyMatrices(_matrixWorldInv, bone.matrixWorld);
  26913. _vector$9.setFromMatrixPosition(_boneMatrix);
  26914. position.setXYZ(j, _vector$9.x, _vector$9.y, _vector$9.z);
  26915. _boneMatrix.multiplyMatrices(_matrixWorldInv, bone.parent.matrixWorld);
  26916. _vector$9.setFromMatrixPosition(_boneMatrix);
  26917. position.setXYZ(j + 1, _vector$9.x, _vector$9.y, _vector$9.z);
  26918. j += 2;
  26919. }
  26920. }
  26921. geometry.getAttribute("position").needsUpdate = true;
  26922. Object3D.prototype.updateMatrixWorld.call(this, force);
  26923. };
  26924. function PointLightHelper(light, sphereSize, color) {
  26925. this.light = light;
  26926. this.light.updateMatrixWorld();
  26927. this.color = color;
  26928. var geometry = new SphereBufferGeometry(sphereSize, 4, 2);
  26929. var material = new MeshBasicMaterial({ wireframe: true, fog: false });
  26930. Mesh.call(this, geometry, material);
  26931. this.matrix = this.light.matrixWorld;
  26932. this.matrixAutoUpdate = false;
  26933. this.update();
  26934. }
  26935. PointLightHelper.prototype = Object.create(Mesh.prototype);
  26936. PointLightHelper.prototype.constructor = PointLightHelper;
  26937. PointLightHelper.prototype.dispose = function() {
  26938. this.geometry.dispose();
  26939. this.material.dispose();
  26940. };
  26941. PointLightHelper.prototype.update = function() {
  26942. if (this.color !== void 0) {
  26943. this.material.color.set(this.color);
  26944. } else {
  26945. this.material.color.copy(this.light.color);
  26946. }
  26947. };
  26948. var _vector$a = new Vector3();
  26949. var _color1 = new Color();
  26950. var _color2 = new Color();
  26951. function HemisphereLightHelper(light, size, color) {
  26952. Object3D.call(this);
  26953. this.light = light;
  26954. this.light.updateMatrixWorld();
  26955. this.matrix = light.matrixWorld;
  26956. this.matrixAutoUpdate = false;
  26957. this.color = color;
  26958. var geometry = new OctahedronBufferGeometry(size);
  26959. geometry.rotateY(Math.PI * 0.5);
  26960. this.material = new MeshBasicMaterial({ wireframe: true, fog: false });
  26961. if (this.color === void 0)
  26962. this.material.vertexColors = VertexColors;
  26963. var position = geometry.getAttribute("position");
  26964. var colors = new Float32Array(position.count * 3);
  26965. geometry.setAttribute("color", new BufferAttribute(colors, 3));
  26966. this.add(new Mesh(geometry, this.material));
  26967. this.update();
  26968. }
  26969. HemisphereLightHelper.prototype = Object.create(Object3D.prototype);
  26970. HemisphereLightHelper.prototype.constructor = HemisphereLightHelper;
  26971. HemisphereLightHelper.prototype.dispose = function() {
  26972. this.children[0].geometry.dispose();
  26973. this.children[0].material.dispose();
  26974. };
  26975. HemisphereLightHelper.prototype.update = function() {
  26976. var mesh = this.children[0];
  26977. if (this.color !== void 0) {
  26978. this.material.color.set(this.color);
  26979. } else {
  26980. var colors = mesh.geometry.getAttribute("color");
  26981. _color1.copy(this.light.color);
  26982. _color2.copy(this.light.groundColor);
  26983. for (var i2 = 0, l = colors.count; i2 < l; i2++) {
  26984. var color = i2 < l / 2 ? _color1 : _color2;
  26985. colors.setXYZ(i2, color.r, color.g, color.b);
  26986. }
  26987. colors.needsUpdate = true;
  26988. }
  26989. mesh.lookAt(_vector$a.setFromMatrixPosition(this.light.matrixWorld).negate());
  26990. };
  26991. function GridHelper(size, divisions, color1, color2) {
  26992. size = size || 10;
  26993. divisions = divisions || 10;
  26994. color1 = new Color(color1 !== void 0 ? color1 : 4473924);
  26995. color2 = new Color(color2 !== void 0 ? color2 : 8947848);
  26996. var center = divisions / 2;
  26997. var step = size / divisions;
  26998. var halfSize = size / 2;
  26999. var vertices = [], colors = [];
  27000. for (var i2 = 0, j = 0, k = -halfSize; i2 <= divisions; i2++, k += step) {
  27001. vertices.push(-halfSize, 0, k, halfSize, 0, k);
  27002. vertices.push(k, 0, -halfSize, k, 0, halfSize);
  27003. var color = i2 === center ? color1 : color2;
  27004. color.toArray(colors, j);
  27005. j += 3;
  27006. color.toArray(colors, j);
  27007. j += 3;
  27008. color.toArray(colors, j);
  27009. j += 3;
  27010. color.toArray(colors, j);
  27011. j += 3;
  27012. }
  27013. var geometry = new BufferGeometry();
  27014. geometry.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  27015. geometry.setAttribute("color", new Float32BufferAttribute(colors, 3));
  27016. var material = new LineBasicMaterial({ vertexColors: VertexColors });
  27017. LineSegments.call(this, geometry, material);
  27018. }
  27019. GridHelper.prototype = Object.assign(Object.create(LineSegments.prototype), {
  27020. constructor: GridHelper,
  27021. copy: function(source) {
  27022. LineSegments.prototype.copy.call(this, source);
  27023. this.geometry.copy(source.geometry);
  27024. this.material.copy(source.material);
  27025. return this;
  27026. },
  27027. clone: function() {
  27028. return new this.constructor().copy(this);
  27029. }
  27030. });
  27031. function PolarGridHelper(radius, radials, circles, divisions, color1, color2) {
  27032. radius = radius || 10;
  27033. radials = radials || 16;
  27034. circles = circles || 8;
  27035. divisions = divisions || 64;
  27036. color1 = new Color(color1 !== void 0 ? color1 : 4473924);
  27037. color2 = new Color(color2 !== void 0 ? color2 : 8947848);
  27038. var vertices = [];
  27039. var colors = [];
  27040. var x, z;
  27041. var v, i2, j, r, color;
  27042. for (i2 = 0; i2 <= radials; i2++) {
  27043. v = i2 / radials * (Math.PI * 2);
  27044. x = Math.sin(v) * radius;
  27045. z = Math.cos(v) * radius;
  27046. vertices.push(0, 0, 0);
  27047. vertices.push(x, 0, z);
  27048. color = i2 & 1 ? color1 : color2;
  27049. colors.push(color.r, color.g, color.b);
  27050. colors.push(color.r, color.g, color.b);
  27051. }
  27052. for (i2 = 0; i2 <= circles; i2++) {
  27053. color = i2 & 1 ? color1 : color2;
  27054. r = radius - radius / circles * i2;
  27055. for (j = 0; j < divisions; j++) {
  27056. v = j / divisions * (Math.PI * 2);
  27057. x = Math.sin(v) * r;
  27058. z = Math.cos(v) * r;
  27059. vertices.push(x, 0, z);
  27060. colors.push(color.r, color.g, color.b);
  27061. v = (j + 1) / divisions * (Math.PI * 2);
  27062. x = Math.sin(v) * r;
  27063. z = Math.cos(v) * r;
  27064. vertices.push(x, 0, z);
  27065. colors.push(color.r, color.g, color.b);
  27066. }
  27067. }
  27068. var geometry = new BufferGeometry();
  27069. geometry.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  27070. geometry.setAttribute("color", new Float32BufferAttribute(colors, 3));
  27071. var material = new LineBasicMaterial({ vertexColors: VertexColors });
  27072. LineSegments.call(this, geometry, material);
  27073. }
  27074. PolarGridHelper.prototype = Object.create(LineSegments.prototype);
  27075. PolarGridHelper.prototype.constructor = PolarGridHelper;
  27076. var _v1$5 = new Vector3();
  27077. var _v2$3 = new Vector3();
  27078. var _v3$1 = new Vector3();
  27079. function DirectionalLightHelper(light, size, color) {
  27080. Object3D.call(this);
  27081. this.light = light;
  27082. this.light.updateMatrixWorld();
  27083. this.matrix = light.matrixWorld;
  27084. this.matrixAutoUpdate = false;
  27085. this.color = color;
  27086. if (size === void 0)
  27087. size = 1;
  27088. var geometry = new BufferGeometry();
  27089. geometry.setAttribute("position", new Float32BufferAttribute([
  27090. -size,
  27091. size,
  27092. 0,
  27093. size,
  27094. size,
  27095. 0,
  27096. size,
  27097. -size,
  27098. 0,
  27099. -size,
  27100. -size,
  27101. 0,
  27102. -size,
  27103. size,
  27104. 0
  27105. ], 3));
  27106. var material = new LineBasicMaterial({ fog: false });
  27107. this.lightPlane = new Line(geometry, material);
  27108. this.add(this.lightPlane);
  27109. geometry = new BufferGeometry();
  27110. geometry.setAttribute("position", new Float32BufferAttribute([0, 0, 0, 0, 0, 1], 3));
  27111. this.targetLine = new Line(geometry, material);
  27112. this.add(this.targetLine);
  27113. this.update();
  27114. }
  27115. DirectionalLightHelper.prototype = Object.create(Object3D.prototype);
  27116. DirectionalLightHelper.prototype.constructor = DirectionalLightHelper;
  27117. DirectionalLightHelper.prototype.dispose = function() {
  27118. this.lightPlane.geometry.dispose();
  27119. this.lightPlane.material.dispose();
  27120. this.targetLine.geometry.dispose();
  27121. this.targetLine.material.dispose();
  27122. };
  27123. DirectionalLightHelper.prototype.update = function() {
  27124. _v1$5.setFromMatrixPosition(this.light.matrixWorld);
  27125. _v2$3.setFromMatrixPosition(this.light.target.matrixWorld);
  27126. _v3$1.subVectors(_v2$3, _v1$5);
  27127. this.lightPlane.lookAt(_v2$3);
  27128. if (this.color !== void 0) {
  27129. this.lightPlane.material.color.set(this.color);
  27130. this.targetLine.material.color.set(this.color);
  27131. } else {
  27132. this.lightPlane.material.color.copy(this.light.color);
  27133. this.targetLine.material.color.copy(this.light.color);
  27134. }
  27135. this.targetLine.lookAt(_v2$3);
  27136. this.targetLine.scale.z = _v3$1.length();
  27137. };
  27138. var _vector$b = new Vector3();
  27139. var _camera = new Camera();
  27140. function CameraHelper(camera) {
  27141. var geometry = new BufferGeometry();
  27142. var material = new LineBasicMaterial({ color: 16777215, vertexColors: FaceColors });
  27143. var vertices = [];
  27144. var colors = [];
  27145. var pointMap = {};
  27146. var colorFrustum = new Color(16755200);
  27147. var colorCone = new Color(16711680);
  27148. var colorUp = new Color(43775);
  27149. var colorTarget = new Color(16777215);
  27150. var colorCross = new Color(3355443);
  27151. addLine("n1", "n2", colorFrustum);
  27152. addLine("n2", "n4", colorFrustum);
  27153. addLine("n4", "n3", colorFrustum);
  27154. addLine("n3", "n1", colorFrustum);
  27155. addLine("f1", "f2", colorFrustum);
  27156. addLine("f2", "f4", colorFrustum);
  27157. addLine("f4", "f3", colorFrustum);
  27158. addLine("f3", "f1", colorFrustum);
  27159. addLine("n1", "f1", colorFrustum);
  27160. addLine("n2", "f2", colorFrustum);
  27161. addLine("n3", "f3", colorFrustum);
  27162. addLine("n4", "f4", colorFrustum);
  27163. addLine("p", "n1", colorCone);
  27164. addLine("p", "n2", colorCone);
  27165. addLine("p", "n3", colorCone);
  27166. addLine("p", "n4", colorCone);
  27167. addLine("u1", "u2", colorUp);
  27168. addLine("u2", "u3", colorUp);
  27169. addLine("u3", "u1", colorUp);
  27170. addLine("c", "t", colorTarget);
  27171. addLine("p", "c", colorCross);
  27172. addLine("cn1", "cn2", colorCross);
  27173. addLine("cn3", "cn4", colorCross);
  27174. addLine("cf1", "cf2", colorCross);
  27175. addLine("cf3", "cf4", colorCross);
  27176. function addLine(a, b, color) {
  27177. addPoint(a, color);
  27178. addPoint(b, color);
  27179. }
  27180. function addPoint(id, color) {
  27181. vertices.push(0, 0, 0);
  27182. colors.push(color.r, color.g, color.b);
  27183. if (pointMap[id] === void 0) {
  27184. pointMap[id] = [];
  27185. }
  27186. pointMap[id].push(vertices.length / 3 - 1);
  27187. }
  27188. geometry.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  27189. geometry.setAttribute("color", new Float32BufferAttribute(colors, 3));
  27190. LineSegments.call(this, geometry, material);
  27191. this.camera = camera;
  27192. if (this.camera.updateProjectionMatrix)
  27193. this.camera.updateProjectionMatrix();
  27194. this.matrix = camera.matrixWorld;
  27195. this.matrixAutoUpdate = false;
  27196. this.pointMap = pointMap;
  27197. this.update();
  27198. }
  27199. CameraHelper.prototype = Object.create(LineSegments.prototype);
  27200. CameraHelper.prototype.constructor = CameraHelper;
  27201. CameraHelper.prototype.update = function() {
  27202. var geometry = this.geometry;
  27203. var pointMap = this.pointMap;
  27204. var w = 1, h = 1;
  27205. _camera.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse);
  27206. setPoint("c", pointMap, geometry, _camera, 0, 0, -1);
  27207. setPoint("t", pointMap, geometry, _camera, 0, 0, 1);
  27208. setPoint("n1", pointMap, geometry, _camera, -w, -h, -1);
  27209. setPoint("n2", pointMap, geometry, _camera, w, -h, -1);
  27210. setPoint("n3", pointMap, geometry, _camera, -w, h, -1);
  27211. setPoint("n4", pointMap, geometry, _camera, w, h, -1);
  27212. setPoint("f1", pointMap, geometry, _camera, -w, -h, 1);
  27213. setPoint("f2", pointMap, geometry, _camera, w, -h, 1);
  27214. setPoint("f3", pointMap, geometry, _camera, -w, h, 1);
  27215. setPoint("f4", pointMap, geometry, _camera, w, h, 1);
  27216. setPoint("u1", pointMap, geometry, _camera, w * 0.7, h * 1.1, -1);
  27217. setPoint("u2", pointMap, geometry, _camera, -w * 0.7, h * 1.1, -1);
  27218. setPoint("u3", pointMap, geometry, _camera, 0, h * 2, -1);
  27219. setPoint("cf1", pointMap, geometry, _camera, -w, 0, 1);
  27220. setPoint("cf2", pointMap, geometry, _camera, w, 0, 1);
  27221. setPoint("cf3", pointMap, geometry, _camera, 0, -h, 1);
  27222. setPoint("cf4", pointMap, geometry, _camera, 0, h, 1);
  27223. setPoint("cn1", pointMap, geometry, _camera, -w, 0, -1);
  27224. setPoint("cn2", pointMap, geometry, _camera, w, 0, -1);
  27225. setPoint("cn3", pointMap, geometry, _camera, 0, -h, -1);
  27226. setPoint("cn4", pointMap, geometry, _camera, 0, h, -1);
  27227. geometry.getAttribute("position").needsUpdate = true;
  27228. };
  27229. function setPoint(point, pointMap, geometry, camera, x, y, z) {
  27230. _vector$b.set(x, y, z).unproject(camera);
  27231. var points = pointMap[point];
  27232. if (points !== void 0) {
  27233. var position = geometry.getAttribute("position");
  27234. for (var i2 = 0, l = points.length; i2 < l; i2++) {
  27235. position.setXYZ(points[i2], _vector$b.x, _vector$b.y, _vector$b.z);
  27236. }
  27237. }
  27238. }
  27239. var _box$3 = new Box3();
  27240. function BoxHelper(object, color) {
  27241. this.object = object;
  27242. if (color === void 0)
  27243. color = 16776960;
  27244. var indices = 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]);
  27245. var positions = new Float32Array(8 * 3);
  27246. var geometry = new BufferGeometry();
  27247. geometry.setIndex(new BufferAttribute(indices, 1));
  27248. geometry.setAttribute("position", new BufferAttribute(positions, 3));
  27249. LineSegments.call(this, geometry, new LineBasicMaterial({ color }));
  27250. this.matrixAutoUpdate = false;
  27251. this.update();
  27252. }
  27253. BoxHelper.prototype = Object.create(LineSegments.prototype);
  27254. BoxHelper.prototype.constructor = BoxHelper;
  27255. BoxHelper.prototype.update = function(object) {
  27256. if (object !== void 0) {
  27257. console.warn("THREE.BoxHelper: .update() has no longer arguments.");
  27258. }
  27259. if (this.object !== void 0) {
  27260. _box$3.setFromObject(this.object);
  27261. }
  27262. if (_box$3.isEmpty())
  27263. return;
  27264. var min = _box$3.min;
  27265. var max = _box$3.max;
  27266. var position = this.geometry.attributes.position;
  27267. var array = position.array;
  27268. array[0] = max.x;
  27269. array[1] = max.y;
  27270. array[2] = max.z;
  27271. array[3] = min.x;
  27272. array[4] = max.y;
  27273. array[5] = max.z;
  27274. array[6] = min.x;
  27275. array[7] = min.y;
  27276. array[8] = max.z;
  27277. array[9] = max.x;
  27278. array[10] = min.y;
  27279. array[11] = max.z;
  27280. array[12] = max.x;
  27281. array[13] = max.y;
  27282. array[14] = min.z;
  27283. array[15] = min.x;
  27284. array[16] = max.y;
  27285. array[17] = min.z;
  27286. array[18] = min.x;
  27287. array[19] = min.y;
  27288. array[20] = min.z;
  27289. array[21] = max.x;
  27290. array[22] = min.y;
  27291. array[23] = min.z;
  27292. position.needsUpdate = true;
  27293. this.geometry.computeBoundingSphere();
  27294. };
  27295. BoxHelper.prototype.setFromObject = function(object) {
  27296. this.object = object;
  27297. this.update();
  27298. return this;
  27299. };
  27300. BoxHelper.prototype.copy = function(source) {
  27301. LineSegments.prototype.copy.call(this, source);
  27302. this.object = source.object;
  27303. return this;
  27304. };
  27305. BoxHelper.prototype.clone = function() {
  27306. return new this.constructor().copy(this);
  27307. };
  27308. function Box3Helper(box, color) {
  27309. this.type = "Box3Helper";
  27310. this.box = box;
  27311. color = color || 16776960;
  27312. var indices = 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]);
  27313. var positions = [1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1];
  27314. var geometry = new BufferGeometry();
  27315. geometry.setIndex(new BufferAttribute(indices, 1));
  27316. geometry.setAttribute("position", new Float32BufferAttribute(positions, 3));
  27317. LineSegments.call(this, geometry, new LineBasicMaterial({ color }));
  27318. this.geometry.computeBoundingSphere();
  27319. }
  27320. Box3Helper.prototype = Object.create(LineSegments.prototype);
  27321. Box3Helper.prototype.constructor = Box3Helper;
  27322. Box3Helper.prototype.updateMatrixWorld = function(force) {
  27323. var box = this.box;
  27324. if (box.isEmpty())
  27325. return;
  27326. box.getCenter(this.position);
  27327. box.getSize(this.scale);
  27328. this.scale.multiplyScalar(0.5);
  27329. Object3D.prototype.updateMatrixWorld.call(this, force);
  27330. };
  27331. function PlaneHelper(plane, size, hex) {
  27332. this.type = "PlaneHelper";
  27333. this.plane = plane;
  27334. this.size = size === void 0 ? 1 : size;
  27335. var color = hex !== void 0 ? hex : 16776960;
  27336. var positions = [1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0];
  27337. var geometry = new BufferGeometry();
  27338. geometry.setAttribute("position", new Float32BufferAttribute(positions, 3));
  27339. geometry.computeBoundingSphere();
  27340. Line.call(this, geometry, new LineBasicMaterial({ color }));
  27341. var positions2 = [1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1];
  27342. var geometry2 = new BufferGeometry();
  27343. geometry2.setAttribute("position", new Float32BufferAttribute(positions2, 3));
  27344. geometry2.computeBoundingSphere();
  27345. this.add(new Mesh(geometry2, new MeshBasicMaterial({ color, opacity: 0.2, transparent: true, depthWrite: false })));
  27346. }
  27347. PlaneHelper.prototype = Object.create(Line.prototype);
  27348. PlaneHelper.prototype.constructor = PlaneHelper;
  27349. PlaneHelper.prototype.updateMatrixWorld = function(force) {
  27350. var scale = -this.plane.constant;
  27351. if (Math.abs(scale) < 1e-8)
  27352. scale = 1e-8;
  27353. this.scale.set(0.5 * this.size, 0.5 * this.size, scale);
  27354. this.children[0].material.side = scale < 0 ? BackSide : FrontSide;
  27355. this.lookAt(this.plane.normal);
  27356. Object3D.prototype.updateMatrixWorld.call(this, force);
  27357. };
  27358. var _axis = new Vector3();
  27359. var _lineGeometry, _coneGeometry;
  27360. function ArrowHelper(dir, origin, length, color, headLength, headWidth) {
  27361. Object3D.call(this);
  27362. if (dir === void 0)
  27363. dir = new Vector3(0, 0, 1);
  27364. if (origin === void 0)
  27365. origin = new Vector3(0, 0, 0);
  27366. if (length === void 0)
  27367. length = 1;
  27368. if (color === void 0)
  27369. color = 16776960;
  27370. if (headLength === void 0)
  27371. headLength = 0.2 * length;
  27372. if (headWidth === void 0)
  27373. headWidth = 0.2 * headLength;
  27374. if (_lineGeometry === void 0) {
  27375. _lineGeometry = new BufferGeometry();
  27376. _lineGeometry.setAttribute("position", new Float32BufferAttribute([0, 0, 0, 0, 1, 0], 3));
  27377. _coneGeometry = new CylinderBufferGeometry(0, 0.5, 1, 5, 1);
  27378. _coneGeometry.translate(0, -0.5, 0);
  27379. }
  27380. this.position.copy(origin);
  27381. this.line = new Line(_lineGeometry, new LineBasicMaterial({ color }));
  27382. this.line.matrixAutoUpdate = false;
  27383. this.add(this.line);
  27384. this.cone = new Mesh(_coneGeometry, new MeshBasicMaterial({ color }));
  27385. this.cone.matrixAutoUpdate = false;
  27386. this.add(this.cone);
  27387. this.setDirection(dir);
  27388. this.setLength(length, headLength, headWidth);
  27389. }
  27390. ArrowHelper.prototype = Object.create(Object3D.prototype);
  27391. ArrowHelper.prototype.constructor = ArrowHelper;
  27392. ArrowHelper.prototype.setDirection = function(dir) {
  27393. if (dir.y > 0.99999) {
  27394. this.quaternion.set(0, 0, 0, 1);
  27395. } else if (dir.y < -0.99999) {
  27396. this.quaternion.set(1, 0, 0, 0);
  27397. } else {
  27398. _axis.set(dir.z, 0, -dir.x).normalize();
  27399. var radians = Math.acos(dir.y);
  27400. this.quaternion.setFromAxisAngle(_axis, radians);
  27401. }
  27402. };
  27403. ArrowHelper.prototype.setLength = function(length, headLength, headWidth) {
  27404. if (headLength === void 0)
  27405. headLength = 0.2 * length;
  27406. if (headWidth === void 0)
  27407. headWidth = 0.2 * headLength;
  27408. this.line.scale.set(1, Math.max(1e-4, length - headLength), 1);
  27409. this.line.updateMatrix();
  27410. this.cone.scale.set(headWidth, headLength, headWidth);
  27411. this.cone.position.y = length;
  27412. this.cone.updateMatrix();
  27413. };
  27414. ArrowHelper.prototype.setColor = function(color) {
  27415. this.line.material.color.set(color);
  27416. this.cone.material.color.set(color);
  27417. };
  27418. ArrowHelper.prototype.copy = function(source) {
  27419. Object3D.prototype.copy.call(this, source, false);
  27420. this.line.copy(source.line);
  27421. this.cone.copy(source.cone);
  27422. return this;
  27423. };
  27424. ArrowHelper.prototype.clone = function() {
  27425. return new this.constructor().copy(this);
  27426. };
  27427. function AxesHelper(size) {
  27428. size = size || 1;
  27429. var vertices = [
  27430. 0,
  27431. 0,
  27432. 0,
  27433. size,
  27434. 0,
  27435. 0,
  27436. 0,
  27437. 0,
  27438. 0,
  27439. 0,
  27440. size,
  27441. 0,
  27442. 0,
  27443. 0,
  27444. 0,
  27445. 0,
  27446. 0,
  27447. size
  27448. ];
  27449. var colors = [
  27450. 1,
  27451. 0,
  27452. 0,
  27453. 1,
  27454. 0.6,
  27455. 0,
  27456. 0,
  27457. 1,
  27458. 0,
  27459. 0.6,
  27460. 1,
  27461. 0,
  27462. 0,
  27463. 0,
  27464. 1,
  27465. 0,
  27466. 0.6,
  27467. 1
  27468. ];
  27469. var geometry = new BufferGeometry();
  27470. geometry.setAttribute("position", new Float32BufferAttribute(vertices, 3));
  27471. geometry.setAttribute("color", new Float32BufferAttribute(colors, 3));
  27472. var material = new LineBasicMaterial({ vertexColors: VertexColors });
  27473. LineSegments.call(this, geometry, material);
  27474. }
  27475. AxesHelper.prototype = Object.create(LineSegments.prototype);
  27476. AxesHelper.prototype.constructor = AxesHelper;
  27477. var LOD_MIN = 4;
  27478. var LOD_MAX = 8;
  27479. var SIZE_MAX = Math.pow(2, LOD_MAX);
  27480. var EXTRA_LOD_SIGMA = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582];
  27481. var TOTAL_LODS = LOD_MAX - LOD_MIN + 1 + EXTRA_LOD_SIGMA.length;
  27482. var MAX_SAMPLES = 20;
  27483. var ENCODINGS = {
  27484. [LinearEncoding]: 0,
  27485. [sRGBEncoding]: 1,
  27486. [RGBEEncoding]: 2,
  27487. [RGBM7Encoding]: 3,
  27488. [RGBM16Encoding]: 4,
  27489. [RGBDEncoding]: 5,
  27490. [GammaEncoding]: 6
  27491. };
  27492. var _flatCamera = new OrthographicCamera();
  27493. var _blurMaterial = _getBlurShader(MAX_SAMPLES);
  27494. var _equirectShader = null;
  27495. var _cubemapShader = null;
  27496. var { _lodPlanes, _sizeLods, _sigmas } = _createPlanes();
  27497. var _pingPongRenderTarget = null;
  27498. var _renderer = null;
  27499. var _oldTarget = null;
  27500. var PHI = (1 + Math.sqrt(5)) / 2;
  27501. var INV_PHI = 1 / PHI;
  27502. var _axisDirections = [
  27503. new Vector3(1, 1, 1),
  27504. new Vector3(-1, 1, 1),
  27505. new Vector3(1, 1, -1),
  27506. new Vector3(-1, 1, -1),
  27507. new Vector3(0, PHI, INV_PHI),
  27508. new Vector3(0, PHI, -INV_PHI),
  27509. new Vector3(INV_PHI, 0, PHI),
  27510. new Vector3(-INV_PHI, 0, PHI),
  27511. new Vector3(PHI, INV_PHI, 0),
  27512. new Vector3(-PHI, INV_PHI, 0)
  27513. ];
  27514. function PMREMGenerator(renderer) {
  27515. _renderer = renderer;
  27516. _compileMaterial(_blurMaterial);
  27517. }
  27518. PMREMGenerator.prototype = {
  27519. constructor: PMREMGenerator,
  27520. /**
  27521. * Generates a PMREM from a supplied Scene, which can be faster than using an
  27522. * image if networking bandwidth is low. Optional sigma specifies a blur radius
  27523. * in radians to be applied to the scene before PMREM generation. Optional near
  27524. * and far planes ensure the scene is rendered in its entirety (the cubeCamera
  27525. * is placed at the origin).
  27526. */
  27527. fromScene: function(scene, sigma = 0, near = 0.1, far = 100) {
  27528. _oldTarget = _renderer.getRenderTarget();
  27529. var cubeUVRenderTarget = _allocateTargets();
  27530. _sceneToCubeUV(scene, near, far, cubeUVRenderTarget);
  27531. if (sigma > 0) {
  27532. _blur(cubeUVRenderTarget, 0, 0, sigma);
  27533. }
  27534. _applyPMREM(cubeUVRenderTarget);
  27535. _cleanup(cubeUVRenderTarget);
  27536. return cubeUVRenderTarget;
  27537. },
  27538. /**
  27539. * Generates a PMREM from an equirectangular texture, which can be either LDR
  27540. * (RGBFormat) or HDR (RGBEFormat). The ideal input image size is 1k (1024 x 512),
  27541. * as this matches best with the 256 x 256 cubemap output.
  27542. */
  27543. fromEquirectangular: function(equirectangular) {
  27544. equirectangular.magFilter = NearestFilter;
  27545. equirectangular.minFilter = NearestFilter;
  27546. equirectangular.generateMipmaps = false;
  27547. return this.fromCubemap(equirectangular);
  27548. },
  27549. /**
  27550. * Generates a PMREM from an cubemap texture, which can be either LDR
  27551. * (RGBFormat) or HDR (RGBEFormat). The ideal input cube size is 256 x 256,
  27552. * as this matches best with the 256 x 256 cubemap output.
  27553. */
  27554. fromCubemap: function(cubemap) {
  27555. _oldTarget = _renderer.getRenderTarget();
  27556. var cubeUVRenderTarget = _allocateTargets(cubemap);
  27557. _textureToCubeUV(cubemap, cubeUVRenderTarget);
  27558. _applyPMREM(cubeUVRenderTarget);
  27559. _cleanup(cubeUVRenderTarget);
  27560. return cubeUVRenderTarget;
  27561. },
  27562. /**
  27563. * Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during
  27564. * your texture's network fetch for increased concurrency.
  27565. */
  27566. compileCubemapShader: function() {
  27567. if (_cubemapShader == null) {
  27568. _cubemapShader = _getCubemapShader();
  27569. _compileMaterial(_cubemapShader);
  27570. }
  27571. },
  27572. /**
  27573. * Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during
  27574. * your texture's network fetch for increased concurrency.
  27575. */
  27576. compileEquirectangularShader: function() {
  27577. if (_equirectShader == null) {
  27578. _equirectShader = _getEquirectShader();
  27579. _compileMaterial(_equirectShader);
  27580. }
  27581. },
  27582. /**
  27583. * Disposes of the PMREMGenerator's internal memory. Note that PMREMGenerator is a static class,
  27584. * so you should not need more than one PMREMGenerator object. If you do, calling dispose() on
  27585. * one of them will cause any others to also become unusable.
  27586. */
  27587. dispose: function() {
  27588. _blurMaterial.dispose();
  27589. if (_cubemapShader != null)
  27590. _cubemapShader.dispose();
  27591. if (_equirectShader != null)
  27592. _equirectShader.dispose();
  27593. for (var i2 = 0; i2 < _lodPlanes.length; i2++) {
  27594. _lodPlanes[i2].dispose();
  27595. }
  27596. }
  27597. };
  27598. function _createPlanes() {
  27599. var _lodPlanes2 = [];
  27600. var _sizeLods2 = [];
  27601. var _sigmas2 = [];
  27602. var lod = LOD_MAX;
  27603. for (var i2 = 0; i2 < TOTAL_LODS; i2++) {
  27604. var sizeLod = Math.pow(2, lod);
  27605. _sizeLods2.push(sizeLod);
  27606. var sigma = 1 / sizeLod;
  27607. if (i2 > LOD_MAX - LOD_MIN) {
  27608. sigma = EXTRA_LOD_SIGMA[i2 - LOD_MAX + LOD_MIN - 1];
  27609. } else if (i2 == 0) {
  27610. sigma = 0;
  27611. }
  27612. _sigmas2.push(sigma);
  27613. var texelSize = 1 / (sizeLod - 1);
  27614. var min = -texelSize / 2;
  27615. var max = 1 + texelSize / 2;
  27616. var uv1 = [min, min, max, min, max, max, min, min, max, max, min, max];
  27617. var cubeFaces = 6;
  27618. var vertices = 6;
  27619. var positionSize = 3;
  27620. var uvSize = 2;
  27621. var faceIndexSize = 1;
  27622. var position = new Float32Array(positionSize * vertices * cubeFaces);
  27623. var uv = new Float32Array(uvSize * vertices * cubeFaces);
  27624. var faceIndex = new Float32Array(faceIndexSize * vertices * cubeFaces);
  27625. for (var face = 0; face < cubeFaces; face++) {
  27626. var x = face % 3 * 2 / 3 - 1;
  27627. var y = face > 2 ? 0 : -1;
  27628. var coordinates = [
  27629. x,
  27630. y,
  27631. 0,
  27632. x + 2 / 3,
  27633. y,
  27634. 0,
  27635. x + 2 / 3,
  27636. y + 1,
  27637. 0,
  27638. x,
  27639. y,
  27640. 0,
  27641. x + 2 / 3,
  27642. y + 1,
  27643. 0,
  27644. x,
  27645. y + 1,
  27646. 0
  27647. ];
  27648. position.set(coordinates, positionSize * vertices * face);
  27649. uv.set(uv1, uvSize * vertices * face);
  27650. var fill = [face, face, face, face, face, face];
  27651. faceIndex.set(fill, faceIndexSize * vertices * face);
  27652. }
  27653. var planes = new BufferGeometry();
  27654. planes.setAttribute("position", new BufferAttribute(position, positionSize));
  27655. planes.setAttribute("uv", new BufferAttribute(uv, uvSize));
  27656. planes.setAttribute("faceIndex", new BufferAttribute(faceIndex, faceIndexSize));
  27657. _lodPlanes2.push(planes);
  27658. if (lod > LOD_MIN) {
  27659. lod--;
  27660. }
  27661. }
  27662. return { _lodPlanes: _lodPlanes2, _sizeLods: _sizeLods2, _sigmas: _sigmas2 };
  27663. }
  27664. function _allocateTargets(equirectangular) {
  27665. var params = {
  27666. magFilter: NearestFilter,
  27667. minFilter: NearestFilter,
  27668. generateMipmaps: false,
  27669. type: equirectangular ? equirectangular.type : UnsignedByteType,
  27670. format: equirectangular ? equirectangular.format : RGBEFormat,
  27671. encoding: equirectangular ? equirectangular.encoding : RGBEEncoding,
  27672. depthBuffer: false,
  27673. stencilBuffer: false
  27674. };
  27675. var cubeUVRenderTarget = _createRenderTarget(params);
  27676. cubeUVRenderTarget.depthBuffer = equirectangular ? false : true;
  27677. _pingPongRenderTarget = _createRenderTarget(params);
  27678. return cubeUVRenderTarget;
  27679. }
  27680. function _cleanup(outputTarget) {
  27681. _pingPongRenderTarget.dispose();
  27682. _renderer.setRenderTarget(_oldTarget);
  27683. outputTarget.scissorTest = false;
  27684. outputTarget.setSize(outputTarget.width, outputTarget.height);
  27685. }
  27686. function _sceneToCubeUV(scene, near, far, cubeUVRenderTarget) {
  27687. var fov2 = 90;
  27688. var aspect2 = 1;
  27689. var cubeCamera = new PerspectiveCamera(fov2, aspect2, near, far);
  27690. var upSign = [1, 1, 1, 1, -1, 1];
  27691. var forwardSign = [1, 1, -1, -1, -1, 1];
  27692. var outputEncoding = _renderer.outputEncoding;
  27693. var toneMapping = _renderer.toneMapping;
  27694. var toneMappingExposure = _renderer.toneMappingExposure;
  27695. var clearColor = _renderer.getClearColor();
  27696. var clearAlpha = _renderer.getClearAlpha();
  27697. _renderer.toneMapping = LinearToneMapping;
  27698. _renderer.toneMappingExposure = 1;
  27699. _renderer.outputEncoding = LinearEncoding;
  27700. scene.scale.z *= -1;
  27701. var background = scene.background;
  27702. if (background && background.isColor) {
  27703. background.convertSRGBToLinear();
  27704. var maxComponent = Math.max(background.r, background.g, background.b);
  27705. var fExp = Math.min(Math.max(Math.ceil(Math.log2(maxComponent)), -128), 127);
  27706. background = background.multiplyScalar(Math.pow(2, -fExp));
  27707. var alpha = (fExp + 128) / 255;
  27708. _renderer.setClearColor(background, alpha);
  27709. scene.background = null;
  27710. }
  27711. for (var i2 = 0; i2 < 6; i2++) {
  27712. var col = i2 % 3;
  27713. if (col == 0) {
  27714. cubeCamera.up.set(0, upSign[i2], 0);
  27715. cubeCamera.lookAt(forwardSign[i2], 0, 0);
  27716. } else if (col == 1) {
  27717. cubeCamera.up.set(0, 0, upSign[i2]);
  27718. cubeCamera.lookAt(0, forwardSign[i2], 0);
  27719. } else {
  27720. cubeCamera.up.set(0, upSign[i2], 0);
  27721. cubeCamera.lookAt(0, 0, forwardSign[i2]);
  27722. }
  27723. _setViewport(
  27724. cubeUVRenderTarget,
  27725. col * SIZE_MAX,
  27726. i2 > 2 ? SIZE_MAX : 0,
  27727. SIZE_MAX,
  27728. SIZE_MAX
  27729. );
  27730. _renderer.setRenderTarget(cubeUVRenderTarget);
  27731. _renderer.render(scene, cubeCamera);
  27732. }
  27733. _renderer.toneMapping = toneMapping;
  27734. _renderer.toneMappingExposure = toneMappingExposure;
  27735. _renderer.outputEncoding = outputEncoding;
  27736. _renderer.setClearColor(clearColor, clearAlpha);
  27737. scene.scale.z *= -1;
  27738. }
  27739. function _textureToCubeUV(texture, cubeUVRenderTarget) {
  27740. var scene = new Scene();
  27741. if (texture.isCubeTexture) {
  27742. if (_cubemapShader == null) {
  27743. _cubemapShader = _getCubemapShader();
  27744. }
  27745. } else {
  27746. if (_equirectShader == null) {
  27747. _equirectShader = _getEquirectShader();
  27748. }
  27749. }
  27750. var material = texture.isCubeTexture ? _cubemapShader : _equirectShader;
  27751. scene.add(new Mesh(_lodPlanes[0], material));
  27752. var uniforms = material.uniforms;
  27753. uniforms["envMap"].value = texture;
  27754. if (!texture.isCubeTexture) {
  27755. uniforms["texelSize"].value.set(1 / texture.image.width, 1 / texture.image.height);
  27756. }
  27757. uniforms["inputEncoding"].value = ENCODINGS[texture.encoding];
  27758. uniforms["outputEncoding"].value = ENCODINGS[texture.encoding];
  27759. _setViewport(cubeUVRenderTarget, 0, 0, 3 * SIZE_MAX, 2 * SIZE_MAX);
  27760. _renderer.setRenderTarget(cubeUVRenderTarget);
  27761. _renderer.render(scene, _flatCamera);
  27762. }
  27763. function _compileMaterial(material) {
  27764. var tmpScene = new Scene();
  27765. tmpScene.add(new Mesh(_lodPlanes[0], material));
  27766. _renderer.compile(tmpScene, _flatCamera);
  27767. }
  27768. function _createRenderTarget(params) {
  27769. var cubeUVRenderTarget = new WebGLRenderTarget(3 * SIZE_MAX, 3 * SIZE_MAX, params);
  27770. cubeUVRenderTarget.texture.mapping = CubeUVReflectionMapping;
  27771. cubeUVRenderTarget.texture.name = "PMREM.cubeUv";
  27772. cubeUVRenderTarget.scissorTest = true;
  27773. return cubeUVRenderTarget;
  27774. }
  27775. function _setViewport(target, x, y, width, height) {
  27776. target.viewport.set(x, y, width, height);
  27777. target.scissor.set(x, y, width, height);
  27778. }
  27779. function _applyPMREM(cubeUVRenderTarget) {
  27780. var autoClear = _renderer.autoClear;
  27781. _renderer.autoClear = false;
  27782. for (var i2 = 1; i2 < TOTAL_LODS; i2++) {
  27783. var sigma = Math.sqrt(
  27784. _sigmas[i2] * _sigmas[i2] - _sigmas[i2 - 1] * _sigmas[i2 - 1]
  27785. );
  27786. var poleAxis = _axisDirections[(i2 - 1) % _axisDirections.length];
  27787. _blur(cubeUVRenderTarget, i2 - 1, i2, sigma, poleAxis);
  27788. }
  27789. _renderer.autoClear = autoClear;
  27790. }
  27791. function _blur(cubeUVRenderTarget, lodIn, lodOut, sigma, poleAxis) {
  27792. _halfBlur(
  27793. cubeUVRenderTarget,
  27794. _pingPongRenderTarget,
  27795. lodIn,
  27796. lodOut,
  27797. sigma,
  27798. "latitudinal",
  27799. poleAxis
  27800. );
  27801. _halfBlur(
  27802. _pingPongRenderTarget,
  27803. cubeUVRenderTarget,
  27804. lodOut,
  27805. lodOut,
  27806. sigma,
  27807. "longitudinal",
  27808. poleAxis
  27809. );
  27810. }
  27811. function _halfBlur(targetIn, targetOut, lodIn, lodOut, sigmaRadians, direction, poleAxis) {
  27812. if (direction !== "latitudinal" && direction !== "longitudinal") {
  27813. console.error(
  27814. "blur direction must be either latitudinal or longitudinal!"
  27815. );
  27816. }
  27817. var STANDARD_DEVIATIONS = 3;
  27818. var blurScene = new Scene();
  27819. blurScene.add(new Mesh(_lodPlanes[lodOut], _blurMaterial));
  27820. var blurUniforms = _blurMaterial.uniforms;
  27821. var pixels = _sizeLods[lodIn] - 1;
  27822. var radiansPerPixel = isFinite(sigmaRadians) ? Math.PI / (2 * pixels) : 2 * Math.PI / (2 * MAX_SAMPLES - 1);
  27823. var sigmaPixels = sigmaRadians / radiansPerPixel;
  27824. var samples = isFinite(sigmaRadians) ? 1 + Math.floor(STANDARD_DEVIATIONS * sigmaPixels) : MAX_SAMPLES;
  27825. if (samples > MAX_SAMPLES) {
  27826. console.warn(`sigmaRadians, ${sigmaRadians}, is too large and will clip, as it requested ${samples} samples when the maximum is set to ${MAX_SAMPLES}`);
  27827. }
  27828. var weights = [];
  27829. var sum = 0;
  27830. for (var i2 = 0; i2 < MAX_SAMPLES; ++i2) {
  27831. var x = i2 / sigmaPixels;
  27832. var weight = Math.exp(-x * x / 2);
  27833. weights.push(weight);
  27834. if (i2 == 0) {
  27835. sum += weight;
  27836. } else if (i2 < samples) {
  27837. sum += 2 * weight;
  27838. }
  27839. }
  27840. for (var i2 = 0; i2 < weights.length; i2++) {
  27841. weights[i2] = weights[i2] / sum;
  27842. }
  27843. blurUniforms["envMap"].value = targetIn.texture;
  27844. blurUniforms["samples"].value = samples;
  27845. blurUniforms["weights"].value = weights;
  27846. blurUniforms["latitudinal"].value = direction === "latitudinal";
  27847. if (poleAxis) {
  27848. blurUniforms["poleAxis"].value = poleAxis;
  27849. }
  27850. blurUniforms["dTheta"].value = radiansPerPixel;
  27851. blurUniforms["mipInt"].value = LOD_MAX - lodIn;
  27852. blurUniforms["inputEncoding"].value = ENCODINGS[targetIn.texture.encoding];
  27853. blurUniforms["outputEncoding"].value = ENCODINGS[targetIn.texture.encoding];
  27854. var outputSize = _sizeLods[lodOut];
  27855. var x = 3 * Math.max(0, SIZE_MAX - 2 * outputSize);
  27856. var y = (lodOut === 0 ? 0 : 2 * SIZE_MAX) + 2 * outputSize * (lodOut > LOD_MAX - LOD_MIN ? lodOut - LOD_MAX + LOD_MIN : 0);
  27857. _setViewport(targetOut, x, y, 3 * outputSize, 2 * outputSize);
  27858. _renderer.setRenderTarget(targetOut);
  27859. _renderer.render(blurScene, _flatCamera);
  27860. }
  27861. function _getBlurShader(maxSamples) {
  27862. var weights = new Float32Array(maxSamples);
  27863. var poleAxis = new Vector3(0, 1, 0);
  27864. var shaderMaterial = new RawShaderMaterial({
  27865. defines: { "n": maxSamples },
  27866. uniforms: {
  27867. "envMap": { value: null },
  27868. "samples": { value: 1 },
  27869. "weights": { value: weights },
  27870. "latitudinal": { value: false },
  27871. "dTheta": { value: 0 },
  27872. "mipInt": { value: 0 },
  27873. "poleAxis": { value: poleAxis },
  27874. "inputEncoding": { value: ENCODINGS[LinearEncoding] },
  27875. "outputEncoding": { value: ENCODINGS[LinearEncoding] }
  27876. },
  27877. vertexShader: _getCommonVertexShader(),
  27878. fragmentShader: `
  27879. precision mediump float;
  27880. precision mediump int;
  27881. varying vec3 vOutputDirection;
  27882. uniform sampler2D envMap;
  27883. uniform int samples;
  27884. uniform float weights[n];
  27885. uniform bool latitudinal;
  27886. uniform float dTheta;
  27887. uniform float mipInt;
  27888. uniform vec3 poleAxis;
  27889. ${_getEncodings()}
  27890. #define ENVMAP_TYPE_CUBE_UV
  27891. #include <cube_uv_reflection_fragment>
  27892. void main() {
  27893. gl_FragColor = vec4(0.0);
  27894. for (int i = 0; i < n; i++) {
  27895. if (i >= samples)
  27896. break;
  27897. for (int dir = -1; dir < 2; dir += 2) {
  27898. if (i == 0 && dir == 1)
  27899. continue;
  27900. vec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);
  27901. if (all(equal(axis, vec3(0.0))))
  27902. axis = cross(vec3(0.0, 1.0, 0.0), vOutputDirection);
  27903. axis = normalize(axis);
  27904. float theta = dTheta * float(dir * i);
  27905. float cosTheta = cos(theta);
  27906. // Rodrigues' axis-angle rotation
  27907. vec3 sampleDirection = vOutputDirection * cosTheta
  27908. + cross(axis, vOutputDirection) * sin(theta)
  27909. + axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);
  27910. gl_FragColor.rgb +=
  27911. weights[i] * bilinearCubeUV(envMap, sampleDirection, mipInt);
  27912. }
  27913. }
  27914. gl_FragColor = linearToOutputTexel(gl_FragColor);
  27915. }
  27916. `,
  27917. blending: NoBlending,
  27918. depthTest: false,
  27919. depthWrite: false
  27920. });
  27921. shaderMaterial.type = "SphericalGaussianBlur";
  27922. return shaderMaterial;
  27923. }
  27924. function _getEquirectShader() {
  27925. var texelSize = new Vector2(1, 1);
  27926. var shaderMaterial = new RawShaderMaterial({
  27927. uniforms: {
  27928. "envMap": { value: null },
  27929. "texelSize": { value: texelSize },
  27930. "inputEncoding": { value: ENCODINGS[LinearEncoding] },
  27931. "outputEncoding": { value: ENCODINGS[LinearEncoding] }
  27932. },
  27933. vertexShader: _getCommonVertexShader(),
  27934. fragmentShader: `
  27935. precision mediump float;
  27936. precision mediump int;
  27937. varying vec3 vOutputDirection;
  27938. uniform sampler2D envMap;
  27939. uniform vec2 texelSize;
  27940. ${_getEncodings()}
  27941. #define RECIPROCAL_PI 0.31830988618
  27942. #define RECIPROCAL_PI2 0.15915494
  27943. void main() {
  27944. gl_FragColor = vec4(0.0);
  27945. vec3 outputDirection = normalize(vOutputDirection);
  27946. vec2 uv;
  27947. uv.y = asin(clamp(outputDirection.y, -1.0, 1.0)) * RECIPROCAL_PI + 0.5;
  27948. uv.x = atan(outputDirection.z, outputDirection.x) * RECIPROCAL_PI2 + 0.5;
  27949. vec2 f = fract(uv / texelSize - 0.5);
  27950. uv -= f * texelSize;
  27951. vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
  27952. uv.x += texelSize.x;
  27953. vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
  27954. uv.y += texelSize.y;
  27955. vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
  27956. uv.x -= texelSize.x;
  27957. vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
  27958. vec3 tm = mix(tl, tr, f.x);
  27959. vec3 bm = mix(bl, br, f.x);
  27960. gl_FragColor.rgb = mix(tm, bm, f.y);
  27961. gl_FragColor = linearToOutputTexel(gl_FragColor);
  27962. }
  27963. `,
  27964. blending: NoBlending,
  27965. depthTest: false,
  27966. depthWrite: false
  27967. });
  27968. shaderMaterial.type = "EquirectangularToCubeUV";
  27969. return shaderMaterial;
  27970. }
  27971. function _getCubemapShader() {
  27972. var shaderMaterial = new RawShaderMaterial({
  27973. uniforms: {
  27974. "envMap": { value: null },
  27975. "inputEncoding": { value: ENCODINGS[LinearEncoding] },
  27976. "outputEncoding": { value: ENCODINGS[LinearEncoding] }
  27977. },
  27978. vertexShader: _getCommonVertexShader(),
  27979. fragmentShader: `
  27980. precision mediump float;
  27981. precision mediump int;
  27982. varying vec3 vOutputDirection;
  27983. uniform samplerCube envMap;
  27984. ${_getEncodings()}
  27985. void main() {
  27986. gl_FragColor = vec4(0.0);
  27987. gl_FragColor.rgb = envMapTexelToLinear(textureCube(envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ))).rgb;
  27988. gl_FragColor = linearToOutputTexel(gl_FragColor);
  27989. }
  27990. `,
  27991. blending: NoBlending,
  27992. depthTest: false,
  27993. depthWrite: false
  27994. });
  27995. shaderMaterial.type = "CubemapToCubeUV";
  27996. return shaderMaterial;
  27997. }
  27998. function _getCommonVertexShader() {
  27999. return `
  28000. precision mediump float;
  28001. precision mediump int;
  28002. attribute vec3 position;
  28003. attribute vec2 uv;
  28004. attribute float faceIndex;
  28005. varying vec3 vOutputDirection;
  28006. vec3 getDirection(vec2 uv, float face) {
  28007. uv = 2.0 * uv - 1.0;
  28008. vec3 direction = vec3(uv, 1.0);
  28009. if (face == 0.0) {
  28010. direction = direction.zyx;
  28011. direction.z *= -1.0;
  28012. } else if (face == 1.0) {
  28013. direction = direction.xzy;
  28014. direction.z *= -1.0;
  28015. } else if (face == 3.0) {
  28016. direction = direction.zyx;
  28017. direction.x *= -1.0;
  28018. } else if (face == 4.0) {
  28019. direction = direction.xzy;
  28020. direction.y *= -1.0;
  28021. } else if (face == 5.0) {
  28022. direction.xz *= -1.0;
  28023. }
  28024. return direction;
  28025. }
  28026. void main() {
  28027. vOutputDirection = getDirection(uv, faceIndex);
  28028. gl_Position = vec4( position, 1.0 );
  28029. }
  28030. `;
  28031. }
  28032. function _getEncodings() {
  28033. return `
  28034. uniform int inputEncoding;
  28035. uniform int outputEncoding;
  28036. #include <encodings_pars_fragment>
  28037. vec4 inputTexelToLinear(vec4 value){
  28038. if(inputEncoding == 0){
  28039. return value;
  28040. }else if(inputEncoding == 1){
  28041. return sRGBToLinear(value);
  28042. }else if(inputEncoding == 2){
  28043. return RGBEToLinear(value);
  28044. }else if(inputEncoding == 3){
  28045. return RGBMToLinear(value, 7.0);
  28046. }else if(inputEncoding == 4){
  28047. return RGBMToLinear(value, 16.0);
  28048. }else if(inputEncoding == 5){
  28049. return RGBDToLinear(value, 256.0);
  28050. }else{
  28051. return GammaToLinear(value, 2.2);
  28052. }
  28053. }
  28054. vec4 linearToOutputTexel(vec4 value){
  28055. if(outputEncoding == 0){
  28056. return value;
  28057. }else if(outputEncoding == 1){
  28058. return LinearTosRGB(value);
  28059. }else if(outputEncoding == 2){
  28060. return LinearToRGBE(value);
  28061. }else if(outputEncoding == 3){
  28062. return LinearToRGBM(value, 7.0);
  28063. }else if(outputEncoding == 4){
  28064. return LinearToRGBM(value, 16.0);
  28065. }else if(outputEncoding == 5){
  28066. return LinearToRGBD(value, 256.0);
  28067. }else{
  28068. return LinearToGamma(value, 2.2);
  28069. }
  28070. }
  28071. vec4 envMapTexelToLinear(vec4 color) {
  28072. return inputTexelToLinear(color);
  28073. }
  28074. `;
  28075. }
  28076. Curve.create = function(construct, getPoint) {
  28077. console.log("THREE.Curve.create() has been deprecated");
  28078. construct.prototype = Object.create(Curve.prototype);
  28079. construct.prototype.constructor = construct;
  28080. construct.prototype.getPoint = getPoint;
  28081. return construct;
  28082. };
  28083. Object.assign(CurvePath.prototype, {
  28084. createPointsGeometry: function(divisions) {
  28085. console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");
  28086. var pts = this.getPoints(divisions);
  28087. return this.createGeometry(pts);
  28088. },
  28089. createSpacedPointsGeometry: function(divisions) {
  28090. console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");
  28091. var pts = this.getSpacedPoints(divisions);
  28092. return this.createGeometry(pts);
  28093. },
  28094. createGeometry: function(points) {
  28095. console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");
  28096. var geometry = new Geometry();
  28097. for (var i2 = 0, l = points.length; i2 < l; i2++) {
  28098. var point = points[i2];
  28099. geometry.vertices.push(new Vector3(point.x, point.y, point.z || 0));
  28100. }
  28101. return geometry;
  28102. }
  28103. });
  28104. Object.assign(Path.prototype, {
  28105. fromPoints: function(points) {
  28106. console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints().");
  28107. return this.setFromPoints(points);
  28108. }
  28109. });
  28110. Object.create(CatmullRomCurve3.prototype);
  28111. Object.create(CatmullRomCurve3.prototype);
  28112. function Spline(points) {
  28113. console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead.");
  28114. CatmullRomCurve3.call(this, points);
  28115. this.type = "catmullrom";
  28116. }
  28117. Spline.prototype = Object.create(CatmullRomCurve3.prototype);
  28118. Object.assign(Spline.prototype, {
  28119. initFromArray: function() {
  28120. console.error("THREE.Spline: .initFromArray() has been removed.");
  28121. },
  28122. getControlPointsArray: function() {
  28123. console.error("THREE.Spline: .getControlPointsArray() has been removed.");
  28124. },
  28125. reparametrizeByArcLength: function() {
  28126. console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.");
  28127. }
  28128. });
  28129. GridHelper.prototype.setColors = function() {
  28130. console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.");
  28131. };
  28132. SkeletonHelper.prototype.update = function() {
  28133. console.error("THREE.SkeletonHelper: update() no longer needs to be called.");
  28134. };
  28135. Object.assign(Loader.prototype, {
  28136. extractUrlBase: function(url) {
  28137. console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead.");
  28138. return LoaderUtils.extractUrlBase(url);
  28139. }
  28140. });
  28141. Loader.Handlers = {
  28142. add: function() {
  28143. console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.");
  28144. },
  28145. get: function() {
  28146. console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.");
  28147. }
  28148. };
  28149. Object.assign(ObjectLoader.prototype, {
  28150. setTexturePath: function(value) {
  28151. console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath().");
  28152. return this.setResourcePath(value);
  28153. }
  28154. });
  28155. Object.assign(Box2.prototype, {
  28156. center: function(optionalTarget) {
  28157. console.warn("THREE.Box2: .center() has been renamed to .getCenter().");
  28158. return this.getCenter(optionalTarget);
  28159. },
  28160. empty: function() {
  28161. console.warn("THREE.Box2: .empty() has been renamed to .isEmpty().");
  28162. return this.isEmpty();
  28163. },
  28164. isIntersectionBox: function(box) {
  28165. console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().");
  28166. return this.intersectsBox(box);
  28167. },
  28168. size: function(optionalTarget) {
  28169. console.warn("THREE.Box2: .size() has been renamed to .getSize().");
  28170. return this.getSize(optionalTarget);
  28171. }
  28172. });
  28173. Object.assign(Box3.prototype, {
  28174. center: function(optionalTarget) {
  28175. console.warn("THREE.Box3: .center() has been renamed to .getCenter().");
  28176. return this.getCenter(optionalTarget);
  28177. },
  28178. empty: function() {
  28179. console.warn("THREE.Box3: .empty() has been renamed to .isEmpty().");
  28180. return this.isEmpty();
  28181. },
  28182. isIntersectionBox: function(box) {
  28183. console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().");
  28184. return this.intersectsBox(box);
  28185. },
  28186. isIntersectionSphere: function(sphere) {
  28187. console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().");
  28188. return this.intersectsSphere(sphere);
  28189. },
  28190. size: function(optionalTarget) {
  28191. console.warn("THREE.Box3: .size() has been renamed to .getSize().");
  28192. return this.getSize(optionalTarget);
  28193. }
  28194. });
  28195. Frustum.prototype.setFromMatrix = function(m) {
  28196. console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix().");
  28197. return this.setFromProjectionMatrix(m);
  28198. };
  28199. Line3.prototype.center = function(optionalTarget) {
  28200. console.warn("THREE.Line3: .center() has been renamed to .getCenter().");
  28201. return this.getCenter(optionalTarget);
  28202. };
  28203. Object.assign(MathUtils, {
  28204. random16: function() {
  28205. console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead.");
  28206. return Math.random();
  28207. },
  28208. nearestPowerOfTwo: function(value) {
  28209. console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo().");
  28210. return MathUtils.floorPowerOfTwo(value);
  28211. },
  28212. nextPowerOfTwo: function(value) {
  28213. console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo().");
  28214. return MathUtils.ceilPowerOfTwo(value);
  28215. }
  28216. });
  28217. Object.assign(Matrix3.prototype, {
  28218. flattenToArrayOffset: function(array, offset) {
  28219. console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.");
  28220. return this.toArray(array, offset);
  28221. },
  28222. multiplyVector3: function(vector) {
  28223. console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.");
  28224. return vector.applyMatrix3(this);
  28225. },
  28226. multiplyVector3Array: function() {
  28227. console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.");
  28228. },
  28229. applyToBufferAttribute: function(attribute) {
  28230. console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead.");
  28231. return attribute.applyMatrix3(this);
  28232. },
  28233. applyToVector3Array: function() {
  28234. console.error("THREE.Matrix3: .applyToVector3Array() has been removed.");
  28235. }
  28236. });
  28237. Object.assign(Matrix4.prototype, {
  28238. extractPosition: function(m) {
  28239. console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().");
  28240. return this.copyPosition(m);
  28241. },
  28242. flattenToArrayOffset: function(array, offset) {
  28243. console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.");
  28244. return this.toArray(array, offset);
  28245. },
  28246. getPosition: function() {
  28247. console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.");
  28248. return new Vector3().setFromMatrixColumn(this, 3);
  28249. },
  28250. setRotationFromQuaternion: function(q) {
  28251. console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().");
  28252. return this.makeRotationFromQuaternion(q);
  28253. },
  28254. multiplyToArray: function() {
  28255. console.warn("THREE.Matrix4: .multiplyToArray() has been removed.");
  28256. },
  28257. multiplyVector3: function(vector) {
  28258. console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead.");
  28259. return vector.applyMatrix4(this);
  28260. },
  28261. multiplyVector4: function(vector) {
  28262. console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.");
  28263. return vector.applyMatrix4(this);
  28264. },
  28265. multiplyVector3Array: function() {
  28266. console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.");
  28267. },
  28268. rotateAxis: function(v) {
  28269. console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.");
  28270. v.transformDirection(this);
  28271. },
  28272. crossVector: function(vector) {
  28273. console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.");
  28274. return vector.applyMatrix4(this);
  28275. },
  28276. translate: function() {
  28277. console.error("THREE.Matrix4: .translate() has been removed.");
  28278. },
  28279. rotateX: function() {
  28280. console.error("THREE.Matrix4: .rotateX() has been removed.");
  28281. },
  28282. rotateY: function() {
  28283. console.error("THREE.Matrix4: .rotateY() has been removed.");
  28284. },
  28285. rotateZ: function() {
  28286. console.error("THREE.Matrix4: .rotateZ() has been removed.");
  28287. },
  28288. rotateByAxis: function() {
  28289. console.error("THREE.Matrix4: .rotateByAxis() has been removed.");
  28290. },
  28291. applyToBufferAttribute: function(attribute) {
  28292. console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead.");
  28293. return attribute.applyMatrix4(this);
  28294. },
  28295. applyToVector3Array: function() {
  28296. console.error("THREE.Matrix4: .applyToVector3Array() has been removed.");
  28297. },
  28298. makeFrustum: function(left, right, bottom, top2, near, far) {
  28299. console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead.");
  28300. return this.makePerspective(left, right, top2, bottom, near, far);
  28301. }
  28302. });
  28303. Plane.prototype.isIntersectionLine = function(line) {
  28304. console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().");
  28305. return this.intersectsLine(line);
  28306. };
  28307. Quaternion.prototype.multiplyVector3 = function(vector) {
  28308. console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.");
  28309. return vector.applyQuaternion(this);
  28310. };
  28311. Object.assign(Ray.prototype, {
  28312. isIntersectionBox: function(box) {
  28313. console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().");
  28314. return this.intersectsBox(box);
  28315. },
  28316. isIntersectionPlane: function(plane) {
  28317. console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().");
  28318. return this.intersectsPlane(plane);
  28319. },
  28320. isIntersectionSphere: function(sphere) {
  28321. console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().");
  28322. return this.intersectsSphere(sphere);
  28323. }
  28324. });
  28325. Object.assign(Triangle.prototype, {
  28326. area: function() {
  28327. console.warn("THREE.Triangle: .area() has been renamed to .getArea().");
  28328. return this.getArea();
  28329. },
  28330. barycoordFromPoint: function(point, target) {
  28331. console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().");
  28332. return this.getBarycoord(point, target);
  28333. },
  28334. midpoint: function(target) {
  28335. console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint().");
  28336. return this.getMidpoint(target);
  28337. },
  28338. normal: function(target) {
  28339. console.warn("THREE.Triangle: .normal() has been renamed to .getNormal().");
  28340. return this.getNormal(target);
  28341. },
  28342. plane: function(target) {
  28343. console.warn("THREE.Triangle: .plane() has been renamed to .getPlane().");
  28344. return this.getPlane(target);
  28345. }
  28346. });
  28347. Object.assign(Triangle, {
  28348. barycoordFromPoint: function(point, a, b, c, target) {
  28349. console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().");
  28350. return Triangle.getBarycoord(point, a, b, c, target);
  28351. },
  28352. normal: function(a, b, c, target) {
  28353. console.warn("THREE.Triangle: .normal() has been renamed to .getNormal().");
  28354. return Triangle.getNormal(a, b, c, target);
  28355. }
  28356. });
  28357. Object.assign(Shape.prototype, {
  28358. extractAllPoints: function(divisions) {
  28359. console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead.");
  28360. return this.extractPoints(divisions);
  28361. },
  28362. extrude: function(options) {
  28363. console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.");
  28364. return new ExtrudeGeometry(this, options);
  28365. },
  28366. makeGeometry: function(options) {
  28367. console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.");
  28368. return new ShapeGeometry(this, options);
  28369. }
  28370. });
  28371. Object.assign(Vector2.prototype, {
  28372. fromAttribute: function(attribute, index, offset) {
  28373. console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute().");
  28374. return this.fromBufferAttribute(attribute, index, offset);
  28375. },
  28376. distanceToManhattan: function(v) {
  28377. console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo().");
  28378. return this.manhattanDistanceTo(v);
  28379. },
  28380. lengthManhattan: function() {
  28381. console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength().");
  28382. return this.manhattanLength();
  28383. }
  28384. });
  28385. Object.assign(Vector3.prototype, {
  28386. setEulerFromRotationMatrix: function() {
  28387. console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.");
  28388. },
  28389. setEulerFromQuaternion: function() {
  28390. console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.");
  28391. },
  28392. getPositionFromMatrix: function(m) {
  28393. console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().");
  28394. return this.setFromMatrixPosition(m);
  28395. },
  28396. getScaleFromMatrix: function(m) {
  28397. console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().");
  28398. return this.setFromMatrixScale(m);
  28399. },
  28400. getColumnFromMatrix: function(index, matrix) {
  28401. console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().");
  28402. return this.setFromMatrixColumn(matrix, index);
  28403. },
  28404. applyProjection: function(m) {
  28405. console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead.");
  28406. return this.applyMatrix4(m);
  28407. },
  28408. fromAttribute: function(attribute, index, offset) {
  28409. console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute().");
  28410. return this.fromBufferAttribute(attribute, index, offset);
  28411. },
  28412. distanceToManhattan: function(v) {
  28413. console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo().");
  28414. return this.manhattanDistanceTo(v);
  28415. },
  28416. lengthManhattan: function() {
  28417. console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength().");
  28418. return this.manhattanLength();
  28419. }
  28420. });
  28421. Object.assign(Vector4.prototype, {
  28422. fromAttribute: function(attribute, index, offset) {
  28423. console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute().");
  28424. return this.fromBufferAttribute(attribute, index, offset);
  28425. },
  28426. lengthManhattan: function() {
  28427. console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength().");
  28428. return this.manhattanLength();
  28429. }
  28430. });
  28431. Object.assign(Geometry.prototype, {
  28432. computeTangents: function() {
  28433. console.error("THREE.Geometry: .computeTangents() has been removed.");
  28434. },
  28435. computeLineDistances: function() {
  28436. console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.");
  28437. },
  28438. applyMatrix: function(matrix) {
  28439. console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4().");
  28440. return this.applyMatrix4(matrix);
  28441. }
  28442. });
  28443. Object.assign(Object3D.prototype, {
  28444. getChildByName: function(name) {
  28445. console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().");
  28446. return this.getObjectByName(name);
  28447. },
  28448. renderDepth: function() {
  28449. console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.");
  28450. },
  28451. translate: function(distance, axis) {
  28452. console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.");
  28453. return this.translateOnAxis(axis, distance);
  28454. },
  28455. getWorldRotation: function() {
  28456. console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.");
  28457. },
  28458. applyMatrix: function(matrix) {
  28459. console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4().");
  28460. return this.applyMatrix4(matrix);
  28461. }
  28462. });
  28463. Object.defineProperties(Object3D.prototype, {
  28464. eulerOrder: {
  28465. get: function() {
  28466. console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");
  28467. return this.rotation.order;
  28468. },
  28469. set: function(value) {
  28470. console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");
  28471. this.rotation.order = value;
  28472. }
  28473. },
  28474. useQuaternion: {
  28475. get: function() {
  28476. console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.");
  28477. },
  28478. set: function() {
  28479. console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.");
  28480. }
  28481. }
  28482. });
  28483. Object.assign(Mesh.prototype, {
  28484. setDrawMode: function() {
  28485. console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.");
  28486. }
  28487. });
  28488. Object.defineProperties(Mesh.prototype, {
  28489. drawMode: {
  28490. get: function() {
  28491. console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode.");
  28492. return TrianglesDrawMode;
  28493. },
  28494. set: function() {
  28495. console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.");
  28496. }
  28497. }
  28498. });
  28499. Object.defineProperties(LOD.prototype, {
  28500. objects: {
  28501. get: function() {
  28502. console.warn("THREE.LOD: .objects has been renamed to .levels.");
  28503. return this.levels;
  28504. }
  28505. }
  28506. });
  28507. Object.defineProperty(Skeleton.prototype, "useVertexTexture", {
  28508. get: function() {
  28509. console.warn("THREE.Skeleton: useVertexTexture has been removed.");
  28510. },
  28511. set: function() {
  28512. console.warn("THREE.Skeleton: useVertexTexture has been removed.");
  28513. }
  28514. });
  28515. SkinnedMesh.prototype.initBones = function() {
  28516. console.error("THREE.SkinnedMesh: initBones() has been removed.");
  28517. };
  28518. Object.defineProperty(Curve.prototype, "__arcLengthDivisions", {
  28519. get: function() {
  28520. console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions.");
  28521. return this.arcLengthDivisions;
  28522. },
  28523. set: function(value) {
  28524. console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions.");
  28525. this.arcLengthDivisions = value;
  28526. }
  28527. });
  28528. PerspectiveCamera.prototype.setLens = function(focalLength, filmGauge) {
  28529. console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup.");
  28530. if (filmGauge !== void 0)
  28531. this.filmGauge = filmGauge;
  28532. this.setFocalLength(focalLength);
  28533. };
  28534. Object.defineProperties(Light.prototype, {
  28535. onlyShadow: {
  28536. set: function() {
  28537. console.warn("THREE.Light: .onlyShadow has been removed.");
  28538. }
  28539. },
  28540. shadowCameraFov: {
  28541. set: function(value) {
  28542. console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov.");
  28543. this.shadow.camera.fov = value;
  28544. }
  28545. },
  28546. shadowCameraLeft: {
  28547. set: function(value) {
  28548. console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left.");
  28549. this.shadow.camera.left = value;
  28550. }
  28551. },
  28552. shadowCameraRight: {
  28553. set: function(value) {
  28554. console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right.");
  28555. this.shadow.camera.right = value;
  28556. }
  28557. },
  28558. shadowCameraTop: {
  28559. set: function(value) {
  28560. console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top.");
  28561. this.shadow.camera.top = value;
  28562. }
  28563. },
  28564. shadowCameraBottom: {
  28565. set: function(value) {
  28566. console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.");
  28567. this.shadow.camera.bottom = value;
  28568. }
  28569. },
  28570. shadowCameraNear: {
  28571. set: function(value) {
  28572. console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near.");
  28573. this.shadow.camera.near = value;
  28574. }
  28575. },
  28576. shadowCameraFar: {
  28577. set: function(value) {
  28578. console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far.");
  28579. this.shadow.camera.far = value;
  28580. }
  28581. },
  28582. shadowCameraVisible: {
  28583. set: function() {
  28584. console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.");
  28585. }
  28586. },
  28587. shadowBias: {
  28588. set: function(value) {
  28589. console.warn("THREE.Light: .shadowBias is now .shadow.bias.");
  28590. this.shadow.bias = value;
  28591. }
  28592. },
  28593. shadowDarkness: {
  28594. set: function() {
  28595. console.warn("THREE.Light: .shadowDarkness has been removed.");
  28596. }
  28597. },
  28598. shadowMapWidth: {
  28599. set: function(value) {
  28600. console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.");
  28601. this.shadow.mapSize.width = value;
  28602. }
  28603. },
  28604. shadowMapHeight: {
  28605. set: function(value) {
  28606. console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.");
  28607. this.shadow.mapSize.height = value;
  28608. }
  28609. }
  28610. });
  28611. Object.defineProperties(BufferAttribute.prototype, {
  28612. length: {
  28613. get: function() {
  28614. console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead.");
  28615. return this.array.length;
  28616. }
  28617. },
  28618. dynamic: {
  28619. get: function() {
  28620. console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead.");
  28621. return this.usage === DynamicDrawUsage;
  28622. },
  28623. set: function() {
  28624. console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead.");
  28625. this.setUsage(DynamicDrawUsage);
  28626. }
  28627. }
  28628. });
  28629. Object.assign(BufferAttribute.prototype, {
  28630. setDynamic: function(value) {
  28631. console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead.");
  28632. this.setUsage(value === true ? DynamicDrawUsage : StaticDrawUsage);
  28633. return this;
  28634. },
  28635. copyIndicesArray: function() {
  28636. console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.");
  28637. },
  28638. setArray: function() {
  28639. console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers");
  28640. }
  28641. });
  28642. Object.assign(BufferGeometry.prototype, {
  28643. addIndex: function(index) {
  28644. console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().");
  28645. this.setIndex(index);
  28646. },
  28647. addAttribute: function(name, attribute) {
  28648. console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute().");
  28649. if (!(attribute && attribute.isBufferAttribute) && !(attribute && attribute.isInterleavedBufferAttribute)) {
  28650. console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute ).");
  28651. return this.setAttribute(name, new BufferAttribute(arguments[1], arguments[2]));
  28652. }
  28653. if (name === "index") {
  28654. console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute.");
  28655. this.setIndex(attribute);
  28656. return this;
  28657. }
  28658. return this.setAttribute(name, attribute);
  28659. },
  28660. addDrawCall: function(start, count, indexOffset) {
  28661. if (indexOffset !== void 0) {
  28662. console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.");
  28663. }
  28664. console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup().");
  28665. this.addGroup(start, count);
  28666. },
  28667. clearDrawCalls: function() {
  28668. console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().");
  28669. this.clearGroups();
  28670. },
  28671. computeTangents: function() {
  28672. console.warn("THREE.BufferGeometry: .computeTangents() has been removed.");
  28673. },
  28674. computeOffsets: function() {
  28675. console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.");
  28676. },
  28677. removeAttribute: function(name) {
  28678. console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute().");
  28679. return this.deleteAttribute(name);
  28680. },
  28681. applyMatrix: function(matrix) {
  28682. console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4().");
  28683. return this.applyMatrix4(matrix);
  28684. }
  28685. });
  28686. Object.defineProperties(BufferGeometry.prototype, {
  28687. drawcalls: {
  28688. get: function() {
  28689. console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups.");
  28690. return this.groups;
  28691. }
  28692. },
  28693. offsets: {
  28694. get: function() {
  28695. console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups.");
  28696. return this.groups;
  28697. }
  28698. }
  28699. });
  28700. Object.defineProperties(InterleavedBuffer.prototype, {
  28701. dynamic: {
  28702. get: function() {
  28703. console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead.");
  28704. return this.usage === DynamicDrawUsage;
  28705. },
  28706. set: function(value) {
  28707. console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead.");
  28708. this.setUsage(value);
  28709. }
  28710. }
  28711. });
  28712. Object.assign(InterleavedBuffer.prototype, {
  28713. setDynamic: function(value) {
  28714. console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead.");
  28715. this.setUsage(value === true ? DynamicDrawUsage : StaticDrawUsage);
  28716. return this;
  28717. },
  28718. setArray: function() {
  28719. console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers");
  28720. }
  28721. });
  28722. Object.assign(ExtrudeBufferGeometry.prototype, {
  28723. getArrays: function() {
  28724. console.error("THREE.ExtrudeBufferGeometry: .getArrays() has been removed.");
  28725. },
  28726. addShapeList: function() {
  28727. console.error("THREE.ExtrudeBufferGeometry: .addShapeList() has been removed.");
  28728. },
  28729. addShape: function() {
  28730. console.error("THREE.ExtrudeBufferGeometry: .addShape() has been removed.");
  28731. }
  28732. });
  28733. Object.defineProperties(Uniform.prototype, {
  28734. dynamic: {
  28735. set: function() {
  28736. console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.");
  28737. }
  28738. },
  28739. onUpdate: {
  28740. value: function() {
  28741. console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead.");
  28742. return this;
  28743. }
  28744. }
  28745. });
  28746. Object.defineProperties(Material.prototype, {
  28747. wrapAround: {
  28748. get: function() {
  28749. console.warn("THREE.Material: .wrapAround has been removed.");
  28750. },
  28751. set: function() {
  28752. console.warn("THREE.Material: .wrapAround has been removed.");
  28753. }
  28754. },
  28755. overdraw: {
  28756. get: function() {
  28757. console.warn("THREE.Material: .overdraw has been removed.");
  28758. },
  28759. set: function() {
  28760. console.warn("THREE.Material: .overdraw has been removed.");
  28761. }
  28762. },
  28763. wrapRGB: {
  28764. get: function() {
  28765. console.warn("THREE.Material: .wrapRGB has been removed.");
  28766. return new Color();
  28767. }
  28768. },
  28769. shading: {
  28770. get: function() {
  28771. console.error("THREE." + this.type + ": .shading has been removed. Use the boolean .flatShading instead.");
  28772. },
  28773. set: function(value) {
  28774. console.warn("THREE." + this.type + ": .shading has been removed. Use the boolean .flatShading instead.");
  28775. this.flatShading = value === FlatShading;
  28776. }
  28777. },
  28778. stencilMask: {
  28779. get: function() {
  28780. console.warn("THREE." + this.type + ": .stencilMask has been removed. Use .stencilFuncMask instead.");
  28781. return this.stencilFuncMask;
  28782. },
  28783. set: function(value) {
  28784. console.warn("THREE." + this.type + ": .stencilMask has been removed. Use .stencilFuncMask instead.");
  28785. this.stencilFuncMask = value;
  28786. }
  28787. }
  28788. });
  28789. Object.defineProperties(MeshPhongMaterial.prototype, {
  28790. metal: {
  28791. get: function() {
  28792. console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead.");
  28793. return false;
  28794. },
  28795. set: function() {
  28796. console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead");
  28797. }
  28798. }
  28799. });
  28800. Object.defineProperties(ShaderMaterial.prototype, {
  28801. derivatives: {
  28802. get: function() {
  28803. console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");
  28804. return this.extensions.derivatives;
  28805. },
  28806. set: function(value) {
  28807. console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");
  28808. this.extensions.derivatives = value;
  28809. }
  28810. }
  28811. });
  28812. Object.assign(WebGLRenderer.prototype, {
  28813. clearTarget: function(renderTarget, color, depth, stencil) {
  28814. console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead.");
  28815. this.setRenderTarget(renderTarget);
  28816. this.clear(color, depth, stencil);
  28817. },
  28818. animate: function(callback) {
  28819. console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop().");
  28820. this.setAnimationLoop(callback);
  28821. },
  28822. getCurrentRenderTarget: function() {
  28823. console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget().");
  28824. return this.getRenderTarget();
  28825. },
  28826. getMaxAnisotropy: function() {
  28827. console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy().");
  28828. return this.capabilities.getMaxAnisotropy();
  28829. },
  28830. getPrecision: function() {
  28831. console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision.");
  28832. return this.capabilities.precision;
  28833. },
  28834. resetGLState: function() {
  28835. console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset().");
  28836. return this.state.reset();
  28837. },
  28838. supportsFloatTextures: function() {
  28839. console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' ).");
  28840. return this.extensions.get("OES_texture_float");
  28841. },
  28842. supportsHalfFloatTextures: function() {
  28843. console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' ).");
  28844. return this.extensions.get("OES_texture_half_float");
  28845. },
  28846. supportsStandardDerivatives: function() {
  28847. console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' ).");
  28848. return this.extensions.get("OES_standard_derivatives");
  28849. },
  28850. supportsCompressedTextureS3TC: function() {
  28851. console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' ).");
  28852. return this.extensions.get("WEBGL_compressed_texture_s3tc");
  28853. },
  28854. supportsCompressedTexturePVRTC: function() {
  28855. console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' ).");
  28856. return this.extensions.get("WEBGL_compressed_texture_pvrtc");
  28857. },
  28858. supportsBlendMinMax: function() {
  28859. console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' ).");
  28860. return this.extensions.get("EXT_blend_minmax");
  28861. },
  28862. supportsVertexTextures: function() {
  28863. console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures.");
  28864. return this.capabilities.vertexTextures;
  28865. },
  28866. supportsInstancedArrays: function() {
  28867. console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' ).");
  28868. return this.extensions.get("ANGLE_instanced_arrays");
  28869. },
  28870. enableScissorTest: function(boolean) {
  28871. console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().");
  28872. this.setScissorTest(boolean);
  28873. },
  28874. initMaterial: function() {
  28875. console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.");
  28876. },
  28877. addPrePlugin: function() {
  28878. console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.");
  28879. },
  28880. addPostPlugin: function() {
  28881. console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.");
  28882. },
  28883. updateShadowMap: function() {
  28884. console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.");
  28885. },
  28886. setFaceCulling: function() {
  28887. console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.");
  28888. },
  28889. allocTextureUnit: function() {
  28890. console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.");
  28891. },
  28892. setTexture: function() {
  28893. console.warn("THREE.WebGLRenderer: .setTexture() has been removed.");
  28894. },
  28895. setTexture2D: function() {
  28896. console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.");
  28897. },
  28898. setTextureCube: function() {
  28899. console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.");
  28900. },
  28901. getActiveMipMapLevel: function() {
  28902. console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel().");
  28903. return this.getActiveMipmapLevel();
  28904. }
  28905. });
  28906. Object.defineProperties(WebGLRenderer.prototype, {
  28907. shadowMapEnabled: {
  28908. get: function() {
  28909. return this.shadowMap.enabled;
  28910. },
  28911. set: function(value) {
  28912. console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.");
  28913. this.shadowMap.enabled = value;
  28914. }
  28915. },
  28916. shadowMapType: {
  28917. get: function() {
  28918. return this.shadowMap.type;
  28919. },
  28920. set: function(value) {
  28921. console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.");
  28922. this.shadowMap.type = value;
  28923. }
  28924. },
  28925. shadowMapCullFace: {
  28926. get: function() {
  28927. console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.");
  28928. return void 0;
  28929. },
  28930. set: function() {
  28931. console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.");
  28932. }
  28933. },
  28934. context: {
  28935. get: function() {
  28936. console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead.");
  28937. return this.getContext();
  28938. }
  28939. },
  28940. vr: {
  28941. get: function() {
  28942. console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr");
  28943. return this.xr;
  28944. }
  28945. },
  28946. gammaInput: {
  28947. get: function() {
  28948. console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.");
  28949. return false;
  28950. },
  28951. set: function() {
  28952. console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.");
  28953. }
  28954. },
  28955. gammaOutput: {
  28956. get: function() {
  28957. console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead.");
  28958. return false;
  28959. },
  28960. set: function(value) {
  28961. console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead.");
  28962. this.outputEncoding = value === true ? sRGBEncoding : LinearEncoding;
  28963. }
  28964. }
  28965. });
  28966. Object.defineProperties(WebGLShadowMap.prototype, {
  28967. cullFace: {
  28968. get: function() {
  28969. console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.");
  28970. return void 0;
  28971. },
  28972. set: function() {
  28973. console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.");
  28974. }
  28975. },
  28976. renderReverseSided: {
  28977. get: function() {
  28978. console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.");
  28979. return void 0;
  28980. },
  28981. set: function() {
  28982. console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.");
  28983. }
  28984. },
  28985. renderSingleSided: {
  28986. get: function() {
  28987. console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.");
  28988. return void 0;
  28989. },
  28990. set: function() {
  28991. console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.");
  28992. }
  28993. }
  28994. });
  28995. Object.defineProperties(WebGLRenderTarget.prototype, {
  28996. wrapS: {
  28997. get: function() {
  28998. console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");
  28999. return this.texture.wrapS;
  29000. },
  29001. set: function(value) {
  29002. console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");
  29003. this.texture.wrapS = value;
  29004. }
  29005. },
  29006. wrapT: {
  29007. get: function() {
  29008. console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");
  29009. return this.texture.wrapT;
  29010. },
  29011. set: function(value) {
  29012. console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");
  29013. this.texture.wrapT = value;
  29014. }
  29015. },
  29016. magFilter: {
  29017. get: function() {
  29018. console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");
  29019. return this.texture.magFilter;
  29020. },
  29021. set: function(value) {
  29022. console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");
  29023. this.texture.magFilter = value;
  29024. }
  29025. },
  29026. minFilter: {
  29027. get: function() {
  29028. console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");
  29029. return this.texture.minFilter;
  29030. },
  29031. set: function(value) {
  29032. console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");
  29033. this.texture.minFilter = value;
  29034. }
  29035. },
  29036. anisotropy: {
  29037. get: function() {
  29038. console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");
  29039. return this.texture.anisotropy;
  29040. },
  29041. set: function(value) {
  29042. console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");
  29043. this.texture.anisotropy = value;
  29044. }
  29045. },
  29046. offset: {
  29047. get: function() {
  29048. console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");
  29049. return this.texture.offset;
  29050. },
  29051. set: function(value) {
  29052. console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");
  29053. this.texture.offset = value;
  29054. }
  29055. },
  29056. repeat: {
  29057. get: function() {
  29058. console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");
  29059. return this.texture.repeat;
  29060. },
  29061. set: function(value) {
  29062. console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");
  29063. this.texture.repeat = value;
  29064. }
  29065. },
  29066. format: {
  29067. get: function() {
  29068. console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");
  29069. return this.texture.format;
  29070. },
  29071. set: function(value) {
  29072. console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");
  29073. this.texture.format = value;
  29074. }
  29075. },
  29076. type: {
  29077. get: function() {
  29078. console.warn("THREE.WebGLRenderTarget: .type is now .texture.type.");
  29079. return this.texture.type;
  29080. },
  29081. set: function(value) {
  29082. console.warn("THREE.WebGLRenderTarget: .type is now .texture.type.");
  29083. this.texture.type = value;
  29084. }
  29085. },
  29086. generateMipmaps: {
  29087. get: function() {
  29088. console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");
  29089. return this.texture.generateMipmaps;
  29090. },
  29091. set: function(value) {
  29092. console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");
  29093. this.texture.generateMipmaps = value;
  29094. }
  29095. }
  29096. });
  29097. Object.defineProperties(Audio.prototype, {
  29098. load: {
  29099. value: function(file) {
  29100. console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");
  29101. var scope = this;
  29102. var audioLoader = new AudioLoader();
  29103. audioLoader.load(file, function(buffer) {
  29104. scope.setBuffer(buffer);
  29105. });
  29106. return this;
  29107. }
  29108. },
  29109. startTime: {
  29110. set: function() {
  29111. console.warn("THREE.Audio: .startTime is now .play( delay ).");
  29112. }
  29113. }
  29114. });
  29115. AudioAnalyser.prototype.getData = function() {
  29116. console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData().");
  29117. return this.getFrequencyData();
  29118. };
  29119. CubeCamera.prototype.updateCubeMap = function(renderer, scene) {
  29120. console.warn("THREE.CubeCamera: .updateCubeMap() is now .update().");
  29121. return this.update(renderer, scene);
  29122. };
  29123. ImageUtils.crossOrigin = void 0;
  29124. ImageUtils.loadTexture = function(url, mapping, onLoad, onError) {
  29125. console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");
  29126. var loader = new TextureLoader();
  29127. loader.setCrossOrigin(this.crossOrigin);
  29128. var texture = loader.load(url, onLoad, void 0, onError);
  29129. if (mapping)
  29130. texture.mapping = mapping;
  29131. return texture;
  29132. };
  29133. ImageUtils.loadTextureCube = function(urls, mapping, onLoad, onError) {
  29134. console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");
  29135. var loader = new CubeTextureLoader();
  29136. loader.setCrossOrigin(this.crossOrigin);
  29137. var texture = loader.load(urls, onLoad, void 0, onError);
  29138. if (mapping)
  29139. texture.mapping = mapping;
  29140. return texture;
  29141. };
  29142. ImageUtils.loadCompressedTexture = function() {
  29143. console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.");
  29144. };
  29145. ImageUtils.loadCompressedTextureCube = function() {
  29146. console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.");
  29147. };
  29148. if (typeof __THREE_DEVTOOLS__ !== "undefined") {
  29149. __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: {
  29150. revision: REVISION
  29151. } }));
  29152. }
  29153. class MyAlignedDimension extends mxdraw.MxDbAlignedDimension {
  29154. constructor() {
  29155. super();
  29156. }
  29157. getDimText() {
  29158. var v2ndPtTo1stPt = new Vector3(this.point1.x - this.point2.x, this.point1.y - this.point2.y, 0);
  29159. var fLen = v2ndPtTo1stPt.length();
  29160. return fLen.toFixed(2);
  29161. }
  29162. create() {
  29163. return new MyAlignedDimension();
  29164. }
  29165. getTypeName() {
  29166. return this.constructor.name;
  29167. }
  29168. }
  29169. function Mx_Linear() {
  29170. return __async(this, null, function* () {
  29171. const getPoint = new mxdraw.MrxDbgUiPrPoint();
  29172. getPoint.setMessage("\n指定第一点:");
  29173. getPoint.go((status) => {
  29174. if (status != 0) {
  29175. return;
  29176. }
  29177. const pt1 = getPoint.value();
  29178. let dim = new MyAlignedDimension();
  29179. dim.setPoint1(pt1);
  29180. dim.setColor(65314);
  29181. const worldDrawComment = new mxdraw.McEdGetPointWorldDrawObject();
  29182. worldDrawComment.setDraw((currentPoint) => {
  29183. dim.setPoint2(currentPoint);
  29184. worldDrawComment.drawCustomEntity(dim);
  29185. });
  29186. getPoint.setBasePt(pt1);
  29187. getPoint.setUseBasePt(true);
  29188. getPoint.setUserDraw(worldDrawComment);
  29189. getPoint.setMessage("\n指定第二点:");
  29190. getPoint.setInputToucheType(mxdraw.MxType.InputToucheType.kGetEnd);
  29191. getPoint.go((status2) => {
  29192. if (status2 != 0) {
  29193. console.log(status2);
  29194. return;
  29195. }
  29196. const pt2 = getPoint.value();
  29197. dim.setPoint2(pt2);
  29198. mxdraw.MxFun.getCurrentDraw().addMxEntity(dim);
  29199. alert("测试长度是:" + dim.getDimText());
  29200. });
  29201. });
  29202. });
  29203. }
  29204. function BR_AngleMeasure() {
  29205. const point = new mxdraw.MrxDbgUiPrPoint();
  29206. const mxDraw = mxdraw.MxFun.getCurrentDraw();
  29207. const angleDim = new mxdraw.MxDb2LineAngularDimension();
  29208. angleDim.color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
  29209. const worldDraw = new mxdraw.McEdGetPointWorldDrawObject();
  29210. worldDraw.setColor(mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor());
  29211. point.setMessage("\n指定第一点:");
  29212. point.go((status) => {
  29213. if (status !== 0) {
  29214. return;
  29215. }
  29216. point.setMessage("\n指定第二个角度点:");
  29217. angleDim.point1 = point.value();
  29218. worldDraw.setDraw((currentPoint, pWorldDraw) => {
  29219. angleDim.point2 = currentPoint;
  29220. pWorldDraw.drawLine(angleDim.point1, currentPoint);
  29221. });
  29222. point.setUserDraw(worldDraw);
  29223. point.go((status2) => {
  29224. point.setMessage("\n指定最后一个点:");
  29225. if (status2 !== 0) {
  29226. return;
  29227. }
  29228. angleDim.point2 = point.value();
  29229. worldDraw.setDraw((currentPoint, pWorldDraw) => {
  29230. angleDim.point3 = currentPoint;
  29231. worldDraw.drawCustomEntity(angleDim);
  29232. });
  29233. point.go((status3) => {
  29234. if (status3 !== 0) {
  29235. return;
  29236. }
  29237. mxDraw.addMxEntity(angleDim);
  29238. });
  29239. });
  29240. });
  29241. }
  29242. function BR_CoordMeasure() {
  29243. const getPoint = new mxdraw.MrxDbgUiPrPoint();
  29244. getPoint.setMessage("\n指定坐标点:");
  29245. getPoint.go((status) => {
  29246. if (status != 0) {
  29247. return;
  29248. }
  29249. const pt1 = getPoint.value();
  29250. let mxCoord = new mxdraw.MxDbCoord();
  29251. mxCoord.point1 = pt1;
  29252. mxCoord.point2 = pt1.clone();
  29253. mxCoord.color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
  29254. getPoint.setBasePt(pt1);
  29255. getPoint.setUseBasePt(true);
  29256. getPoint.setUserDraw((curPoint, pWorldDraw) => {
  29257. mxCoord.point2 = curPoint;
  29258. pWorldDraw.drawCustomEntity(mxCoord);
  29259. });
  29260. getPoint.setMessage("\n指定标注点:");
  29261. getPoint.go((status2) => {
  29262. if (status2 != 0) {
  29263. console.log(status2);
  29264. return;
  29265. }
  29266. mxCoord.point2 = getPoint.value();
  29267. mxdraw.MxFun.addToCurrentSpace(mxCoord);
  29268. });
  29269. });
  29270. }
  29271. function init$m() {
  29272. new MyAlignedDimension().rxInit();
  29273. mxdraw.MxFun.addCommand("Mx_Linear", Mx_Linear);
  29274. mxdraw.MxFun.addCommand("BR_AngleMeasure", BR_AngleMeasure);
  29275. mxdraw.MxFun.addCommand("BR_CoordMeasure", BR_CoordMeasure);
  29276. }
  29277. function MxTest_SelectEntity() {
  29278. return __async(this, null, function* () {
  29279. let getEnt = new mxcad2.MxCADUiPrEntity();
  29280. getEnt.setMessage("select entity:");
  29281. let id = yield getEnt.go();
  29282. let ent = id.getMcDbEntity();
  29283. if (ent === null)
  29284. return;
  29285. console.log("ent.objectName", ent.objectName);
  29286. if (ent instanceof mxcad2.McDbBlockReference) {
  29287. let blkRef = ent;
  29288. let retExplode = blkRef.explode();
  29289. if (retExplode.GetCount() == 0)
  29290. return;
  29291. let iExplodeConut = retExplode.GetCount();
  29292. for (let j = 0; j < iExplodeConut; j++) {
  29293. let tmpobj = retExplode.AtObject(j).val;
  29294. if (tmpobj instanceof mxcad2.McDbPolyline) {
  29295. let polyline = tmpobj;
  29296. let num = polyline.numVerts();
  29297. for (let i2 = 0; i2 < num; i2++) {
  29298. let pt = polyline.getPointAt(i2);
  29299. let bulge = polyline.getBulgeAt(i2);
  29300. console.log("polyline.pt" + i2 + ":" + McGePoint3dToString(pt.val));
  29301. console.log("polyline.bulge" + i2 + ":" + bulge);
  29302. }
  29303. }
  29304. }
  29305. } else if (ent instanceof mxcad2.McDbPolyline) {
  29306. let polyline = ent;
  29307. let num = polyline.numVerts();
  29308. for (let i2 = 0; i2 < num; i2++) {
  29309. let pt = polyline.getPointAt(i2);
  29310. let bulge = polyline.getBulgeAt(i2);
  29311. console.log("polyline.pt" + i2 + ":" + McGePoint3dToString(pt.val));
  29312. console.log("polyline.bulge" + i2 + ":" + bulge);
  29313. }
  29314. }
  29315. });
  29316. }
  29317. function init$l() {
  29318. mxdraw.MxFun.addCommand("MxTest_SelectEntity", MxTest_SelectEntity);
  29319. }
  29320. class MxDrawTableData {
  29321. constructor() {
  29322. this.m_aryColumn = [];
  29323. this.m_allData = [];
  29324. this.m_dColumnHeight = 14;
  29325. this.m_dRowHeight = 10;
  29326. this.m_dRowLineWdith = 0;
  29327. this.m_dColumnLineWidth = 0.5;
  29328. this.m_dRowTextHeight = 6;
  29329. this.m_dColumnTextHeight = 10;
  29330. }
  29331. addColumn(sName, dW) {
  29332. this.m_aryColumn.push({ name: sName, w: dW });
  29333. }
  29334. addRow(ary) {
  29335. this.m_allData.push(ary);
  29336. }
  29337. }
  29338. class MxDrawTable {
  29339. constructor() {
  29340. this.data = new MxDrawTableData();
  29341. this.pt = new mxcad2.McGePoint3d();
  29342. this.dScale = 1;
  29343. this.mxcad = mxcad2.MxCpp.getCurrentMxCAD();
  29344. }
  29345. draw(pt, dScale) {
  29346. this.pt = pt;
  29347. this.dScale = dScale;
  29348. if (this.data.m_aryColumn.length == 0)
  29349. return false;
  29350. if (this.data.m_allData.length == 0)
  29351. return false;
  29352. this.DrawTableHead();
  29353. this.DrawContent();
  29354. return true;
  29355. }
  29356. DrawTableHead() {
  29357. let m_data = this.data;
  29358. let m_instPt = this.pt.clone();
  29359. let curPt = this.pt.clone();
  29360. let vecTmp = new mxcad2.McGeVector3d(0, 1, 0).mult(this.Scale(this.data.m_dColumnHeight));
  29361. console.log(vecTmp);
  29362. let dLineWidth = this.Scale(this.data.m_dColumnLineWidth);
  29363. let dAllW = 0;
  29364. let kXAxis = new mxcad2.McGeVector3d(1, 0, 0);
  29365. for (let i2 = 0; i2 < m_data.m_aryColumn.length; i2++) {
  29366. let col = m_data.m_aryColumn[i2];
  29367. this.DrawLine(curPt, curPt.clone().subvec(vecTmp), dLineWidth);
  29368. this.DrawMCText(curPt.clone().addvec(kXAxis.clone().mult(this.Scale(col.w) * 0.5)).subvec(vecTmp.clone().mult(0.5)), col.name, this.Scale(m_data.m_dColumnTextHeight));
  29369. curPt.addvec(kXAxis.clone().mult(this.Scale(col.w)));
  29370. dAllW += this.Scale(col.w);
  29371. }
  29372. this.DrawLine(curPt, curPt.clone().subvec(vecTmp), dLineWidth);
  29373. this.DrawLine(m_instPt, m_instPt.clone().addvec(kXAxis.clone().mult(dAllW)), dLineWidth);
  29374. this.DrawLine(m_instPt.clone().subvec(vecTmp), m_instPt.addvec(kXAxis.clone().mult(dAllW)).subvec(vecTmp), dLineWidth);
  29375. return true;
  29376. }
  29377. DrawContent() {
  29378. let m_data = this.data;
  29379. let m_instPt = this.pt;
  29380. let dAllW = 0;
  29381. for (let i2 = 0; i2 < m_data.m_aryColumn.length; i2++) {
  29382. dAllW += this.Scale(m_data.m_aryColumn[i2].w);
  29383. }
  29384. let dLineWidth = this.Scale(this.data.m_dRowLineWdith);
  29385. let kXAxis = new mxcad2.McGeVector3d(1, 0, 0);
  29386. let kYAxis = new mxcad2.McGeVector3d(0, 1, 0);
  29387. let instPt = m_instPt.clone().subvec(kYAxis.clone().mult(this.Scale(m_data.m_dColumnHeight)));
  29388. let vecTmp = kYAxis.clone().mult(this.Scale(m_data.m_dRowHeight));
  29389. for (let i2 = 0; i2 < m_data.m_allData.length; i2++) {
  29390. let curPt = instPt.clone();
  29391. for (let j = 0; j < m_data.m_aryColumn.length; j++) {
  29392. let col = m_data.m_aryColumn[j];
  29393. this.DrawLine(curPt, curPt.clone().subvec(vecTmp), dLineWidth);
  29394. this.DrawMCText(curPt.clone().addvec(kXAxis.clone().mult(this.Scale(col.w * 0.5))).subvec(vecTmp.clone().mult(0.5)), m_data.m_allData[i2][j], this.Scale(m_data.m_dRowTextHeight));
  29395. curPt.addvec(kXAxis.clone().mult(this.Scale(col.w)));
  29396. }
  29397. this.DrawLine(curPt, curPt.clone().subvec(vecTmp), dLineWidth);
  29398. this.DrawLine(instPt, instPt.clone().addvec(kXAxis.clone().mult(dAllW)), dLineWidth);
  29399. this.DrawLine(instPt.clone().subvec(vecTmp), instPt.clone().addvec(kXAxis.clone().mult(dAllW)).subvec(vecTmp), dLineWidth);
  29400. instPt.subvec(vecTmp);
  29401. }
  29402. return true;
  29403. }
  29404. DrawLine(pt1, pt2, dLineWidth) {
  29405. this.mxcad.drawLineWidth = dLineWidth;
  29406. this.mxcad.drawColorIndex = mxcad2.ColorIndexType.kMagenta;
  29407. this.mxcad.drawLine(pt1.x, pt1.y, pt2.x, pt2.y);
  29408. }
  29409. DrawMCText(pt1, sTxt, dTextHeight) {
  29410. this.mxcad.drawColorIndex = 0;
  29411. this.mxcad.drawColor = new mxcad2.McCmColor(0, 255, 0);
  29412. this.mxcad.drawText(pt1.x, pt1.y, sTxt, dTextHeight, 0, mxcad2.McDb.TextHorzMode.kTextMid, mxcad2.McDb.TextVertMode.kTextVertMid);
  29413. }
  29414. Scale(dL) {
  29415. return dL * this.dScale;
  29416. }
  29417. }
  29418. var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
  29419. function getDefaultExportFromCjs(x) {
  29420. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
  29421. }
  29422. var qrcode = { exports: {} };
  29423. (function(module, exports2) {
  29424. var qrcode2 = function() {
  29425. var qrcode3 = function(typeNumber, errorCorrectionLevel) {
  29426. var PAD0 = 236;
  29427. var PAD1 = 17;
  29428. var _typeNumber = typeNumber;
  29429. var _errorCorrectionLevel = QRErrorCorrectionLevel[errorCorrectionLevel];
  29430. var _modules = null;
  29431. var _moduleCount = 0;
  29432. var _dataCache = null;
  29433. var _dataList = [];
  29434. var _this = {};
  29435. var makeImpl = function(test2, maskPattern) {
  29436. _moduleCount = _typeNumber * 4 + 17;
  29437. _modules = function(moduleCount) {
  29438. var modules = new Array(moduleCount);
  29439. for (var row = 0; row < moduleCount; row += 1) {
  29440. modules[row] = new Array(moduleCount);
  29441. for (var col = 0; col < moduleCount; col += 1) {
  29442. modules[row][col] = null;
  29443. }
  29444. }
  29445. return modules;
  29446. }(_moduleCount);
  29447. setupPositionProbePattern(0, 0);
  29448. setupPositionProbePattern(_moduleCount - 7, 0);
  29449. setupPositionProbePattern(0, _moduleCount - 7);
  29450. setupPositionAdjustPattern();
  29451. setupTimingPattern();
  29452. setupTypeInfo(test2, maskPattern);
  29453. if (_typeNumber >= 7) {
  29454. setupTypeNumber(test2);
  29455. }
  29456. if (_dataCache == null) {
  29457. _dataCache = createData(_typeNumber, _errorCorrectionLevel, _dataList);
  29458. }
  29459. mapData(_dataCache, maskPattern);
  29460. };
  29461. var setupPositionProbePattern = function(row, col) {
  29462. for (var r = -1; r <= 7; r += 1) {
  29463. if (row + r <= -1 || _moduleCount <= row + r)
  29464. continue;
  29465. for (var c = -1; c <= 7; c += 1) {
  29466. if (col + c <= -1 || _moduleCount <= col + c)
  29467. continue;
  29468. if (0 <= r && r <= 6 && (c == 0 || c == 6) || 0 <= c && c <= 6 && (r == 0 || r == 6) || 2 <= r && r <= 4 && 2 <= c && c <= 4) {
  29469. _modules[row + r][col + c] = true;
  29470. } else {
  29471. _modules[row + r][col + c] = false;
  29472. }
  29473. }
  29474. }
  29475. };
  29476. var getBestMaskPattern = function() {
  29477. var minLostPoint = 0;
  29478. var pattern = 0;
  29479. for (var i2 = 0; i2 < 8; i2 += 1) {
  29480. makeImpl(true, i2);
  29481. var lostPoint = QRUtil.getLostPoint(_this);
  29482. if (i2 == 0 || minLostPoint > lostPoint) {
  29483. minLostPoint = lostPoint;
  29484. pattern = i2;
  29485. }
  29486. }
  29487. return pattern;
  29488. };
  29489. var setupTimingPattern = function() {
  29490. for (var r = 8; r < _moduleCount - 8; r += 1) {
  29491. if (_modules[r][6] != null) {
  29492. continue;
  29493. }
  29494. _modules[r][6] = r % 2 == 0;
  29495. }
  29496. for (var c = 8; c < _moduleCount - 8; c += 1) {
  29497. if (_modules[6][c] != null) {
  29498. continue;
  29499. }
  29500. _modules[6][c] = c % 2 == 0;
  29501. }
  29502. };
  29503. var setupPositionAdjustPattern = function() {
  29504. var pos = QRUtil.getPatternPosition(_typeNumber);
  29505. for (var i2 = 0; i2 < pos.length; i2 += 1) {
  29506. for (var j = 0; j < pos.length; j += 1) {
  29507. var row = pos[i2];
  29508. var col = pos[j];
  29509. if (_modules[row][col] != null) {
  29510. continue;
  29511. }
  29512. for (var r = -2; r <= 2; r += 1) {
  29513. for (var c = -2; c <= 2; c += 1) {
  29514. if (r == -2 || r == 2 || c == -2 || c == 2 || r == 0 && c == 0) {
  29515. _modules[row + r][col + c] = true;
  29516. } else {
  29517. _modules[row + r][col + c] = false;
  29518. }
  29519. }
  29520. }
  29521. }
  29522. }
  29523. };
  29524. var setupTypeNumber = function(test2) {
  29525. var bits = QRUtil.getBCHTypeNumber(_typeNumber);
  29526. for (var i2 = 0; i2 < 18; i2 += 1) {
  29527. var mod = !test2 && (bits >> i2 & 1) == 1;
  29528. _modules[Math.floor(i2 / 3)][i2 % 3 + _moduleCount - 8 - 3] = mod;
  29529. }
  29530. for (var i2 = 0; i2 < 18; i2 += 1) {
  29531. var mod = !test2 && (bits >> i2 & 1) == 1;
  29532. _modules[i2 % 3 + _moduleCount - 8 - 3][Math.floor(i2 / 3)] = mod;
  29533. }
  29534. };
  29535. var setupTypeInfo = function(test2, maskPattern) {
  29536. var data = _errorCorrectionLevel << 3 | maskPattern;
  29537. var bits = QRUtil.getBCHTypeInfo(data);
  29538. for (var i2 = 0; i2 < 15; i2 += 1) {
  29539. var mod = !test2 && (bits >> i2 & 1) == 1;
  29540. if (i2 < 6) {
  29541. _modules[i2][8] = mod;
  29542. } else if (i2 < 8) {
  29543. _modules[i2 + 1][8] = mod;
  29544. } else {
  29545. _modules[_moduleCount - 15 + i2][8] = mod;
  29546. }
  29547. }
  29548. for (var i2 = 0; i2 < 15; i2 += 1) {
  29549. var mod = !test2 && (bits >> i2 & 1) == 1;
  29550. if (i2 < 8) {
  29551. _modules[8][_moduleCount - i2 - 1] = mod;
  29552. } else if (i2 < 9) {
  29553. _modules[8][15 - i2 - 1 + 1] = mod;
  29554. } else {
  29555. _modules[8][15 - i2 - 1] = mod;
  29556. }
  29557. }
  29558. _modules[_moduleCount - 8][8] = !test2;
  29559. };
  29560. var mapData = function(data, maskPattern) {
  29561. var inc = -1;
  29562. var row = _moduleCount - 1;
  29563. var bitIndex = 7;
  29564. var byteIndex = 0;
  29565. var maskFunc = QRUtil.getMaskFunction(maskPattern);
  29566. for (var col = _moduleCount - 1; col > 0; col -= 2) {
  29567. if (col == 6)
  29568. col -= 1;
  29569. while (true) {
  29570. for (var c = 0; c < 2; c += 1) {
  29571. if (_modules[row][col - c] == null) {
  29572. var dark = false;
  29573. if (byteIndex < data.length) {
  29574. dark = (data[byteIndex] >>> bitIndex & 1) == 1;
  29575. }
  29576. var mask = maskFunc(row, col - c);
  29577. if (mask) {
  29578. dark = !dark;
  29579. }
  29580. _modules[row][col - c] = dark;
  29581. bitIndex -= 1;
  29582. if (bitIndex == -1) {
  29583. byteIndex += 1;
  29584. bitIndex = 7;
  29585. }
  29586. }
  29587. }
  29588. row += inc;
  29589. if (row < 0 || _moduleCount <= row) {
  29590. row -= inc;
  29591. inc = -inc;
  29592. break;
  29593. }
  29594. }
  29595. }
  29596. };
  29597. var createBytes = function(buffer, rsBlocks) {
  29598. var offset = 0;
  29599. var maxDcCount = 0;
  29600. var maxEcCount = 0;
  29601. var dcdata = new Array(rsBlocks.length);
  29602. var ecdata = new Array(rsBlocks.length);
  29603. for (var r = 0; r < rsBlocks.length; r += 1) {
  29604. var dcCount = rsBlocks[r].dataCount;
  29605. var ecCount = rsBlocks[r].totalCount - dcCount;
  29606. maxDcCount = Math.max(maxDcCount, dcCount);
  29607. maxEcCount = Math.max(maxEcCount, ecCount);
  29608. dcdata[r] = new Array(dcCount);
  29609. for (var i2 = 0; i2 < dcdata[r].length; i2 += 1) {
  29610. dcdata[r][i2] = 255 & buffer.getBuffer()[i2 + offset];
  29611. }
  29612. offset += dcCount;
  29613. var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
  29614. var rawPoly = qrPolynomial(dcdata[r], rsPoly.getLength() - 1);
  29615. var modPoly = rawPoly.mod(rsPoly);
  29616. ecdata[r] = new Array(rsPoly.getLength() - 1);
  29617. for (var i2 = 0; i2 < ecdata[r].length; i2 += 1) {
  29618. var modIndex = i2 + modPoly.getLength() - ecdata[r].length;
  29619. ecdata[r][i2] = modIndex >= 0 ? modPoly.getAt(modIndex) : 0;
  29620. }
  29621. }
  29622. var totalCodeCount = 0;
  29623. for (var i2 = 0; i2 < rsBlocks.length; i2 += 1) {
  29624. totalCodeCount += rsBlocks[i2].totalCount;
  29625. }
  29626. var data = new Array(totalCodeCount);
  29627. var index = 0;
  29628. for (var i2 = 0; i2 < maxDcCount; i2 += 1) {
  29629. for (var r = 0; r < rsBlocks.length; r += 1) {
  29630. if (i2 < dcdata[r].length) {
  29631. data[index] = dcdata[r][i2];
  29632. index += 1;
  29633. }
  29634. }
  29635. }
  29636. for (var i2 = 0; i2 < maxEcCount; i2 += 1) {
  29637. for (var r = 0; r < rsBlocks.length; r += 1) {
  29638. if (i2 < ecdata[r].length) {
  29639. data[index] = ecdata[r][i2];
  29640. index += 1;
  29641. }
  29642. }
  29643. }
  29644. return data;
  29645. };
  29646. var createData = function(typeNumber2, errorCorrectionLevel2, dataList) {
  29647. var rsBlocks = QRRSBlock.getRSBlocks(typeNumber2, errorCorrectionLevel2);
  29648. var buffer = qrBitBuffer();
  29649. for (var i2 = 0; i2 < dataList.length; i2 += 1) {
  29650. var data = dataList[i2];
  29651. buffer.put(data.getMode(), 4);
  29652. buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber2));
  29653. data.write(buffer);
  29654. }
  29655. var totalDataCount = 0;
  29656. for (var i2 = 0; i2 < rsBlocks.length; i2 += 1) {
  29657. totalDataCount += rsBlocks[i2].dataCount;
  29658. }
  29659. if (buffer.getLengthInBits() > totalDataCount * 8) {
  29660. throw "code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")";
  29661. }
  29662. if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
  29663. buffer.put(0, 4);
  29664. }
  29665. while (buffer.getLengthInBits() % 8 != 0) {
  29666. buffer.putBit(false);
  29667. }
  29668. while (true) {
  29669. if (buffer.getLengthInBits() >= totalDataCount * 8) {
  29670. break;
  29671. }
  29672. buffer.put(PAD0, 8);
  29673. if (buffer.getLengthInBits() >= totalDataCount * 8) {
  29674. break;
  29675. }
  29676. buffer.put(PAD1, 8);
  29677. }
  29678. return createBytes(buffer, rsBlocks);
  29679. };
  29680. _this.addData = function(data, mode) {
  29681. mode = mode || "Byte";
  29682. var newData = null;
  29683. switch (mode) {
  29684. case "Numeric":
  29685. newData = qrNumber(data);
  29686. break;
  29687. case "Alphanumeric":
  29688. newData = qrAlphaNum(data);
  29689. break;
  29690. case "Byte":
  29691. newData = qr8BitByte(data);
  29692. break;
  29693. case "Kanji":
  29694. newData = qrKanji(data);
  29695. break;
  29696. default:
  29697. throw "mode:" + mode;
  29698. }
  29699. _dataList.push(newData);
  29700. _dataCache = null;
  29701. };
  29702. _this.isDark = function(row, col) {
  29703. if (row < 0 || _moduleCount <= row || col < 0 || _moduleCount <= col) {
  29704. throw row + "," + col;
  29705. }
  29706. return _modules[row][col];
  29707. };
  29708. _this.getModuleCount = function() {
  29709. return _moduleCount;
  29710. };
  29711. _this.make = function() {
  29712. if (_typeNumber < 1) {
  29713. var typeNumber2 = 1;
  29714. for (; typeNumber2 < 40; typeNumber2++) {
  29715. var rsBlocks = QRRSBlock.getRSBlocks(typeNumber2, _errorCorrectionLevel);
  29716. var buffer = qrBitBuffer();
  29717. for (var i2 = 0; i2 < _dataList.length; i2++) {
  29718. var data = _dataList[i2];
  29719. buffer.put(data.getMode(), 4);
  29720. buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber2));
  29721. data.write(buffer);
  29722. }
  29723. var totalDataCount = 0;
  29724. for (var i2 = 0; i2 < rsBlocks.length; i2++) {
  29725. totalDataCount += rsBlocks[i2].dataCount;
  29726. }
  29727. if (buffer.getLengthInBits() <= totalDataCount * 8) {
  29728. break;
  29729. }
  29730. }
  29731. _typeNumber = typeNumber2;
  29732. }
  29733. makeImpl(false, getBestMaskPattern());
  29734. };
  29735. _this.createTableTag = function(cellSize, margin) {
  29736. cellSize = cellSize || 2;
  29737. margin = typeof margin == "undefined" ? cellSize * 4 : margin;
  29738. var qrHtml = "";
  29739. qrHtml += '<table style="';
  29740. qrHtml += " border-width: 0px; border-style: none;";
  29741. qrHtml += " border-collapse: collapse;";
  29742. qrHtml += " padding: 0px; margin: " + margin + "px;";
  29743. qrHtml += '">';
  29744. qrHtml += "<tbody>";
  29745. for (var r = 0; r < _this.getModuleCount(); r += 1) {
  29746. qrHtml += "<tr>";
  29747. for (var c = 0; c < _this.getModuleCount(); c += 1) {
  29748. qrHtml += '<td style="';
  29749. qrHtml += " border-width: 0px; border-style: none;";
  29750. qrHtml += " border-collapse: collapse;";
  29751. qrHtml += " padding: 0px; margin: 0px;";
  29752. qrHtml += " width: " + cellSize + "px;";
  29753. qrHtml += " height: " + cellSize + "px;";
  29754. qrHtml += " background-color: ";
  29755. qrHtml += _this.isDark(r, c) ? "#000000" : "#ffffff";
  29756. qrHtml += ";";
  29757. qrHtml += '"/>';
  29758. }
  29759. qrHtml += "</tr>";
  29760. }
  29761. qrHtml += "</tbody>";
  29762. qrHtml += "</table>";
  29763. return qrHtml;
  29764. };
  29765. _this.createSvgTag = function(cellSize, margin, alt, title) {
  29766. var opts = {};
  29767. if (typeof arguments[0] == "object") {
  29768. opts = arguments[0];
  29769. cellSize = opts.cellSize;
  29770. margin = opts.margin;
  29771. alt = opts.alt;
  29772. title = opts.title;
  29773. }
  29774. cellSize = cellSize || 2;
  29775. margin = typeof margin == "undefined" ? cellSize * 4 : margin;
  29776. alt = typeof alt === "string" ? { text: alt } : alt || {};
  29777. alt.text = alt.text || null;
  29778. alt.id = alt.text ? alt.id || "qrcode-description" : null;
  29779. title = typeof title === "string" ? { text: title } : title || {};
  29780. title.text = title.text || null;
  29781. title.id = title.text ? title.id || "qrcode-title" : null;
  29782. var size = _this.getModuleCount() * cellSize + margin * 2;
  29783. var c, mc, r, mr, qrSvg = "", rect;
  29784. rect = "l" + cellSize + ",0 0," + cellSize + " -" + cellSize + ",0 0,-" + cellSize + "z ";
  29785. qrSvg += '<svg version="1.1" xmlns="http://www.w3.org/2000/svg"';
  29786. qrSvg += !opts.scalable ? ' width="' + size + 'px" height="' + size + 'px"' : "";
  29787. qrSvg += ' viewBox="0 0 ' + size + " " + size + '" ';
  29788. qrSvg += ' preserveAspectRatio="xMinYMin meet"';
  29789. qrSvg += title.text || alt.text ? ' role="img" aria-labelledby="' + escapeXml([title.id, alt.id].join(" ").trim()) + '"' : "";
  29790. qrSvg += ">";
  29791. qrSvg += title.text ? '<title id="' + escapeXml(title.id) + '">' + escapeXml(title.text) + "</title>" : "";
  29792. qrSvg += alt.text ? '<description id="' + escapeXml(alt.id) + '">' + escapeXml(alt.text) + "</description>" : "";
  29793. qrSvg += '<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>';
  29794. qrSvg += '<path d="';
  29795. for (r = 0; r < _this.getModuleCount(); r += 1) {
  29796. mr = r * cellSize + margin;
  29797. for (c = 0; c < _this.getModuleCount(); c += 1) {
  29798. if (_this.isDark(r, c)) {
  29799. mc = c * cellSize + margin;
  29800. qrSvg += "M" + mc + "," + mr + rect;
  29801. }
  29802. }
  29803. }
  29804. qrSvg += '" stroke="transparent" fill="black"/>';
  29805. qrSvg += "</svg>";
  29806. return qrSvg;
  29807. };
  29808. _this.createDataURL = function(cellSize, margin) {
  29809. cellSize = cellSize || 2;
  29810. margin = typeof margin == "undefined" ? cellSize * 4 : margin;
  29811. var size = _this.getModuleCount() * cellSize + margin * 2;
  29812. var min = margin;
  29813. var max = size - margin;
  29814. return createDataURL(size, size, function(x, y) {
  29815. if (min <= x && x < max && min <= y && y < max) {
  29816. var c = Math.floor((x - min) / cellSize);
  29817. var r = Math.floor((y - min) / cellSize);
  29818. return _this.isDark(r, c) ? 0 : 1;
  29819. } else {
  29820. return 1;
  29821. }
  29822. });
  29823. };
  29824. _this.createImgTag = function(cellSize, margin, alt) {
  29825. cellSize = cellSize || 2;
  29826. margin = typeof margin == "undefined" ? cellSize * 4 : margin;
  29827. var size = _this.getModuleCount() * cellSize + margin * 2;
  29828. var img = "";
  29829. img += "<img";
  29830. img += ' src="';
  29831. img += _this.createDataURL(cellSize, margin);
  29832. img += '"';
  29833. img += ' width="';
  29834. img += size;
  29835. img += '"';
  29836. img += ' height="';
  29837. img += size;
  29838. img += '"';
  29839. if (alt) {
  29840. img += ' alt="';
  29841. img += escapeXml(alt);
  29842. img += '"';
  29843. }
  29844. img += "/>";
  29845. return img;
  29846. };
  29847. var escapeXml = function(s) {
  29848. var escaped = "";
  29849. for (var i2 = 0; i2 < s.length; i2 += 1) {
  29850. var c = s.charAt(i2);
  29851. switch (c) {
  29852. case "<":
  29853. escaped += "&lt;";
  29854. break;
  29855. case ">":
  29856. escaped += "&gt;";
  29857. break;
  29858. case "&":
  29859. escaped += "&amp;";
  29860. break;
  29861. case '"':
  29862. escaped += "&quot;";
  29863. break;
  29864. default:
  29865. escaped += c;
  29866. break;
  29867. }
  29868. }
  29869. return escaped;
  29870. };
  29871. var _createHalfASCII = function(margin) {
  29872. var cellSize = 1;
  29873. margin = typeof margin == "undefined" ? cellSize * 2 : margin;
  29874. var size = _this.getModuleCount() * cellSize + margin * 2;
  29875. var min = margin;
  29876. var max = size - margin;
  29877. var y, x, r1, r2, p;
  29878. var blocks = {
  29879. "██": "█",
  29880. "█ ": "▀",
  29881. " █": "▄",
  29882. " ": " "
  29883. };
  29884. var blocksLastLineNoMargin = {
  29885. "██": "▀",
  29886. "█ ": "▀",
  29887. " █": " ",
  29888. " ": " "
  29889. };
  29890. var ascii = "";
  29891. for (y = 0; y < size; y += 2) {
  29892. r1 = Math.floor((y - min) / cellSize);
  29893. r2 = Math.floor((y + 1 - min) / cellSize);
  29894. for (x = 0; x < size; x += 1) {
  29895. p = "█";
  29896. if (min <= x && x < max && min <= y && y < max && _this.isDark(r1, Math.floor((x - min) / cellSize))) {
  29897. p = " ";
  29898. }
  29899. if (min <= x && x < max && min <= y + 1 && y + 1 < max && _this.isDark(r2, Math.floor((x - min) / cellSize))) {
  29900. p += " ";
  29901. } else {
  29902. p += "█";
  29903. }
  29904. ascii += margin < 1 && y + 1 >= max ? blocksLastLineNoMargin[p] : blocks[p];
  29905. }
  29906. ascii += "\n";
  29907. }
  29908. if (size % 2 && margin > 0) {
  29909. return ascii.substring(0, ascii.length - size - 1) + Array(size + 1).join("▀");
  29910. }
  29911. return ascii.substring(0, ascii.length - 1);
  29912. };
  29913. _this.createASCII = function(cellSize, margin) {
  29914. cellSize = cellSize || 1;
  29915. if (cellSize < 2) {
  29916. return _createHalfASCII(margin);
  29917. }
  29918. cellSize -= 1;
  29919. margin = typeof margin == "undefined" ? cellSize * 2 : margin;
  29920. var size = _this.getModuleCount() * cellSize + margin * 2;
  29921. var min = margin;
  29922. var max = size - margin;
  29923. var y, x, r, p;
  29924. var white = Array(cellSize + 1).join("██");
  29925. var black = Array(cellSize + 1).join(" ");
  29926. var ascii = "";
  29927. var line = "";
  29928. for (y = 0; y < size; y += 1) {
  29929. r = Math.floor((y - min) / cellSize);
  29930. line = "";
  29931. for (x = 0; x < size; x += 1) {
  29932. p = 1;
  29933. if (min <= x && x < max && min <= y && y < max && _this.isDark(r, Math.floor((x - min) / cellSize))) {
  29934. p = 0;
  29935. }
  29936. line += p ? white : black;
  29937. }
  29938. for (r = 0; r < cellSize; r += 1) {
  29939. ascii += line + "\n";
  29940. }
  29941. }
  29942. return ascii.substring(0, ascii.length - 1);
  29943. };
  29944. _this.renderTo2dContext = function(context, cellSize) {
  29945. cellSize = cellSize || 2;
  29946. var length = _this.getModuleCount();
  29947. for (var row = 0; row < length; row++) {
  29948. for (var col = 0; col < length; col++) {
  29949. context.fillStyle = _this.isDark(row, col) ? "black" : "white";
  29950. context.fillRect(row * cellSize, col * cellSize, cellSize, cellSize);
  29951. }
  29952. }
  29953. };
  29954. return _this;
  29955. };
  29956. qrcode3.stringToBytesFuncs = {
  29957. "default": function(s) {
  29958. var bytes = [];
  29959. for (var i2 = 0; i2 < s.length; i2 += 1) {
  29960. var c = s.charCodeAt(i2);
  29961. bytes.push(c & 255);
  29962. }
  29963. return bytes;
  29964. }
  29965. };
  29966. qrcode3.stringToBytes = qrcode3.stringToBytesFuncs["default"];
  29967. qrcode3.createStringToBytes = function(unicodeData, numChars) {
  29968. var unicodeMap = function() {
  29969. var bin = base64DecodeInputStream(unicodeData);
  29970. var read = function() {
  29971. var b = bin.read();
  29972. if (b == -1)
  29973. throw "eof";
  29974. return b;
  29975. };
  29976. var count = 0;
  29977. var unicodeMap2 = {};
  29978. while (true) {
  29979. var b0 = bin.read();
  29980. if (b0 == -1)
  29981. break;
  29982. var b1 = read();
  29983. var b2 = read();
  29984. var b3 = read();
  29985. var k = String.fromCharCode(b0 << 8 | b1);
  29986. var v = b2 << 8 | b3;
  29987. unicodeMap2[k] = v;
  29988. count += 1;
  29989. }
  29990. if (count != numChars) {
  29991. throw count + " != " + numChars;
  29992. }
  29993. return unicodeMap2;
  29994. }();
  29995. var unknownChar = "?".charCodeAt(0);
  29996. return function(s) {
  29997. var bytes = [];
  29998. for (var i2 = 0; i2 < s.length; i2 += 1) {
  29999. var c = s.charCodeAt(i2);
  30000. if (c < 128) {
  30001. bytes.push(c);
  30002. } else {
  30003. var b = unicodeMap[s.charAt(i2)];
  30004. if (typeof b == "number") {
  30005. if ((b & 255) == b) {
  30006. bytes.push(b);
  30007. } else {
  30008. bytes.push(b >>> 8);
  30009. bytes.push(b & 255);
  30010. }
  30011. } else {
  30012. bytes.push(unknownChar);
  30013. }
  30014. }
  30015. }
  30016. return bytes;
  30017. };
  30018. };
  30019. var QRMode = {
  30020. MODE_NUMBER: 1 << 0,
  30021. MODE_ALPHA_NUM: 1 << 1,
  30022. MODE_8BIT_BYTE: 1 << 2,
  30023. MODE_KANJI: 1 << 3
  30024. };
  30025. var QRErrorCorrectionLevel = {
  30026. L: 1,
  30027. M: 0,
  30028. Q: 3,
  30029. H: 2
  30030. };
  30031. var QRMaskPattern = {
  30032. PATTERN000: 0,
  30033. PATTERN001: 1,
  30034. PATTERN010: 2,
  30035. PATTERN011: 3,
  30036. PATTERN100: 4,
  30037. PATTERN101: 5,
  30038. PATTERN110: 6,
  30039. PATTERN111: 7
  30040. };
  30041. var QRUtil = function() {
  30042. var PATTERN_POSITION_TABLE = [
  30043. [],
  30044. [6, 18],
  30045. [6, 22],
  30046. [6, 26],
  30047. [6, 30],
  30048. [6, 34],
  30049. [6, 22, 38],
  30050. [6, 24, 42],
  30051. [6, 26, 46],
  30052. [6, 28, 50],
  30053. [6, 30, 54],
  30054. [6, 32, 58],
  30055. [6, 34, 62],
  30056. [6, 26, 46, 66],
  30057. [6, 26, 48, 70],
  30058. [6, 26, 50, 74],
  30059. [6, 30, 54, 78],
  30060. [6, 30, 56, 82],
  30061. [6, 30, 58, 86],
  30062. [6, 34, 62, 90],
  30063. [6, 28, 50, 72, 94],
  30064. [6, 26, 50, 74, 98],
  30065. [6, 30, 54, 78, 102],
  30066. [6, 28, 54, 80, 106],
  30067. [6, 32, 58, 84, 110],
  30068. [6, 30, 58, 86, 114],
  30069. [6, 34, 62, 90, 118],
  30070. [6, 26, 50, 74, 98, 122],
  30071. [6, 30, 54, 78, 102, 126],
  30072. [6, 26, 52, 78, 104, 130],
  30073. [6, 30, 56, 82, 108, 134],
  30074. [6, 34, 60, 86, 112, 138],
  30075. [6, 30, 58, 86, 114, 142],
  30076. [6, 34, 62, 90, 118, 146],
  30077. [6, 30, 54, 78, 102, 126, 150],
  30078. [6, 24, 50, 76, 102, 128, 154],
  30079. [6, 28, 54, 80, 106, 132, 158],
  30080. [6, 32, 58, 84, 110, 136, 162],
  30081. [6, 26, 54, 82, 110, 138, 166],
  30082. [6, 30, 58, 86, 114, 142, 170]
  30083. ];
  30084. var G15 = 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0;
  30085. var G18 = 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0;
  30086. var G15_MASK = 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1;
  30087. var _this = {};
  30088. var getBCHDigit = function(data) {
  30089. var digit = 0;
  30090. while (data != 0) {
  30091. digit += 1;
  30092. data >>>= 1;
  30093. }
  30094. return digit;
  30095. };
  30096. _this.getBCHTypeInfo = function(data) {
  30097. var d = data << 10;
  30098. while (getBCHDigit(d) - getBCHDigit(G15) >= 0) {
  30099. d ^= G15 << getBCHDigit(d) - getBCHDigit(G15);
  30100. }
  30101. return (data << 10 | d) ^ G15_MASK;
  30102. };
  30103. _this.getBCHTypeNumber = function(data) {
  30104. var d = data << 12;
  30105. while (getBCHDigit(d) - getBCHDigit(G18) >= 0) {
  30106. d ^= G18 << getBCHDigit(d) - getBCHDigit(G18);
  30107. }
  30108. return data << 12 | d;
  30109. };
  30110. _this.getPatternPosition = function(typeNumber) {
  30111. return PATTERN_POSITION_TABLE[typeNumber - 1];
  30112. };
  30113. _this.getMaskFunction = function(maskPattern) {
  30114. switch (maskPattern) {
  30115. case QRMaskPattern.PATTERN000:
  30116. return function(i2, j) {
  30117. return (i2 + j) % 2 == 0;
  30118. };
  30119. case QRMaskPattern.PATTERN001:
  30120. return function(i2, j) {
  30121. return i2 % 2 == 0;
  30122. };
  30123. case QRMaskPattern.PATTERN010:
  30124. return function(i2, j) {
  30125. return j % 3 == 0;
  30126. };
  30127. case QRMaskPattern.PATTERN011:
  30128. return function(i2, j) {
  30129. return (i2 + j) % 3 == 0;
  30130. };
  30131. case QRMaskPattern.PATTERN100:
  30132. return function(i2, j) {
  30133. return (Math.floor(i2 / 2) + Math.floor(j / 3)) % 2 == 0;
  30134. };
  30135. case QRMaskPattern.PATTERN101:
  30136. return function(i2, j) {
  30137. return i2 * j % 2 + i2 * j % 3 == 0;
  30138. };
  30139. case QRMaskPattern.PATTERN110:
  30140. return function(i2, j) {
  30141. return (i2 * j % 2 + i2 * j % 3) % 2 == 0;
  30142. };
  30143. case QRMaskPattern.PATTERN111:
  30144. return function(i2, j) {
  30145. return (i2 * j % 3 + (i2 + j) % 2) % 2 == 0;
  30146. };
  30147. default:
  30148. throw "bad maskPattern:" + maskPattern;
  30149. }
  30150. };
  30151. _this.getErrorCorrectPolynomial = function(errorCorrectLength) {
  30152. var a = qrPolynomial([1], 0);
  30153. for (var i2 = 0; i2 < errorCorrectLength; i2 += 1) {
  30154. a = a.multiply(qrPolynomial([1, QRMath.gexp(i2)], 0));
  30155. }
  30156. return a;
  30157. };
  30158. _this.getLengthInBits = function(mode, type) {
  30159. if (1 <= type && type < 10) {
  30160. switch (mode) {
  30161. case QRMode.MODE_NUMBER:
  30162. return 10;
  30163. case QRMode.MODE_ALPHA_NUM:
  30164. return 9;
  30165. case QRMode.MODE_8BIT_BYTE:
  30166. return 8;
  30167. case QRMode.MODE_KANJI:
  30168. return 8;
  30169. default:
  30170. throw "mode:" + mode;
  30171. }
  30172. } else if (type < 27) {
  30173. switch (mode) {
  30174. case QRMode.MODE_NUMBER:
  30175. return 12;
  30176. case QRMode.MODE_ALPHA_NUM:
  30177. return 11;
  30178. case QRMode.MODE_8BIT_BYTE:
  30179. return 16;
  30180. case QRMode.MODE_KANJI:
  30181. return 10;
  30182. default:
  30183. throw "mode:" + mode;
  30184. }
  30185. } else if (type < 41) {
  30186. switch (mode) {
  30187. case QRMode.MODE_NUMBER:
  30188. return 14;
  30189. case QRMode.MODE_ALPHA_NUM:
  30190. return 13;
  30191. case QRMode.MODE_8BIT_BYTE:
  30192. return 16;
  30193. case QRMode.MODE_KANJI:
  30194. return 12;
  30195. default:
  30196. throw "mode:" + mode;
  30197. }
  30198. } else {
  30199. throw "type:" + type;
  30200. }
  30201. };
  30202. _this.getLostPoint = function(qrcode4) {
  30203. var moduleCount = qrcode4.getModuleCount();
  30204. var lostPoint = 0;
  30205. for (var row = 0; row < moduleCount; row += 1) {
  30206. for (var col = 0; col < moduleCount; col += 1) {
  30207. var sameCount = 0;
  30208. var dark = qrcode4.isDark(row, col);
  30209. for (var r = -1; r <= 1; r += 1) {
  30210. if (row + r < 0 || moduleCount <= row + r) {
  30211. continue;
  30212. }
  30213. for (var c = -1; c <= 1; c += 1) {
  30214. if (col + c < 0 || moduleCount <= col + c) {
  30215. continue;
  30216. }
  30217. if (r == 0 && c == 0) {
  30218. continue;
  30219. }
  30220. if (dark == qrcode4.isDark(row + r, col + c)) {
  30221. sameCount += 1;
  30222. }
  30223. }
  30224. }
  30225. if (sameCount > 5) {
  30226. lostPoint += 3 + sameCount - 5;
  30227. }
  30228. }
  30229. }
  30230. for (var row = 0; row < moduleCount - 1; row += 1) {
  30231. for (var col = 0; col < moduleCount - 1; col += 1) {
  30232. var count = 0;
  30233. if (qrcode4.isDark(row, col))
  30234. count += 1;
  30235. if (qrcode4.isDark(row + 1, col))
  30236. count += 1;
  30237. if (qrcode4.isDark(row, col + 1))
  30238. count += 1;
  30239. if (qrcode4.isDark(row + 1, col + 1))
  30240. count += 1;
  30241. if (count == 0 || count == 4) {
  30242. lostPoint += 3;
  30243. }
  30244. }
  30245. }
  30246. for (var row = 0; row < moduleCount; row += 1) {
  30247. for (var col = 0; col < moduleCount - 6; col += 1) {
  30248. if (qrcode4.isDark(row, col) && !qrcode4.isDark(row, col + 1) && qrcode4.isDark(row, col + 2) && qrcode4.isDark(row, col + 3) && qrcode4.isDark(row, col + 4) && !qrcode4.isDark(row, col + 5) && qrcode4.isDark(row, col + 6)) {
  30249. lostPoint += 40;
  30250. }
  30251. }
  30252. }
  30253. for (var col = 0; col < moduleCount; col += 1) {
  30254. for (var row = 0; row < moduleCount - 6; row += 1) {
  30255. if (qrcode4.isDark(row, col) && !qrcode4.isDark(row + 1, col) && qrcode4.isDark(row + 2, col) && qrcode4.isDark(row + 3, col) && qrcode4.isDark(row + 4, col) && !qrcode4.isDark(row + 5, col) && qrcode4.isDark(row + 6, col)) {
  30256. lostPoint += 40;
  30257. }
  30258. }
  30259. }
  30260. var darkCount = 0;
  30261. for (var col = 0; col < moduleCount; col += 1) {
  30262. for (var row = 0; row < moduleCount; row += 1) {
  30263. if (qrcode4.isDark(row, col)) {
  30264. darkCount += 1;
  30265. }
  30266. }
  30267. }
  30268. var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
  30269. lostPoint += ratio * 10;
  30270. return lostPoint;
  30271. };
  30272. return _this;
  30273. }();
  30274. var QRMath = function() {
  30275. var EXP_TABLE = new Array(256);
  30276. var LOG_TABLE = new Array(256);
  30277. for (var i2 = 0; i2 < 8; i2 += 1) {
  30278. EXP_TABLE[i2] = 1 << i2;
  30279. }
  30280. for (var i2 = 8; i2 < 256; i2 += 1) {
  30281. EXP_TABLE[i2] = EXP_TABLE[i2 - 4] ^ EXP_TABLE[i2 - 5] ^ EXP_TABLE[i2 - 6] ^ EXP_TABLE[i2 - 8];
  30282. }
  30283. for (var i2 = 0; i2 < 255; i2 += 1) {
  30284. LOG_TABLE[EXP_TABLE[i2]] = i2;
  30285. }
  30286. var _this = {};
  30287. _this.glog = function(n) {
  30288. if (n < 1) {
  30289. throw "glog(" + n + ")";
  30290. }
  30291. return LOG_TABLE[n];
  30292. };
  30293. _this.gexp = function(n) {
  30294. while (n < 0) {
  30295. n += 255;
  30296. }
  30297. while (n >= 256) {
  30298. n -= 255;
  30299. }
  30300. return EXP_TABLE[n];
  30301. };
  30302. return _this;
  30303. }();
  30304. function qrPolynomial(num, shift) {
  30305. if (typeof num.length == "undefined") {
  30306. throw num.length + "/" + shift;
  30307. }
  30308. var _num = function() {
  30309. var offset = 0;
  30310. while (offset < num.length && num[offset] == 0) {
  30311. offset += 1;
  30312. }
  30313. var _num2 = new Array(num.length - offset + shift);
  30314. for (var i2 = 0; i2 < num.length - offset; i2 += 1) {
  30315. _num2[i2] = num[i2 + offset];
  30316. }
  30317. return _num2;
  30318. }();
  30319. var _this = {};
  30320. _this.getAt = function(index) {
  30321. return _num[index];
  30322. };
  30323. _this.getLength = function() {
  30324. return _num.length;
  30325. };
  30326. _this.multiply = function(e) {
  30327. var num2 = new Array(_this.getLength() + e.getLength() - 1);
  30328. for (var i2 = 0; i2 < _this.getLength(); i2 += 1) {
  30329. for (var j = 0; j < e.getLength(); j += 1) {
  30330. num2[i2 + j] ^= QRMath.gexp(QRMath.glog(_this.getAt(i2)) + QRMath.glog(e.getAt(j)));
  30331. }
  30332. }
  30333. return qrPolynomial(num2, 0);
  30334. };
  30335. _this.mod = function(e) {
  30336. if (_this.getLength() - e.getLength() < 0) {
  30337. return _this;
  30338. }
  30339. var ratio = QRMath.glog(_this.getAt(0)) - QRMath.glog(e.getAt(0));
  30340. var num2 = new Array(_this.getLength());
  30341. for (var i2 = 0; i2 < _this.getLength(); i2 += 1) {
  30342. num2[i2] = _this.getAt(i2);
  30343. }
  30344. for (var i2 = 0; i2 < e.getLength(); i2 += 1) {
  30345. num2[i2] ^= QRMath.gexp(QRMath.glog(e.getAt(i2)) + ratio);
  30346. }
  30347. return qrPolynomial(num2, 0).mod(e);
  30348. };
  30349. return _this;
  30350. }
  30351. var QRRSBlock = function() {
  30352. var RS_BLOCK_TABLE = [
  30353. // L
  30354. // M
  30355. // Q
  30356. // H
  30357. // 1
  30358. [1, 26, 19],
  30359. [1, 26, 16],
  30360. [1, 26, 13],
  30361. [1, 26, 9],
  30362. // 2
  30363. [1, 44, 34],
  30364. [1, 44, 28],
  30365. [1, 44, 22],
  30366. [1, 44, 16],
  30367. // 3
  30368. [1, 70, 55],
  30369. [1, 70, 44],
  30370. [2, 35, 17],
  30371. [2, 35, 13],
  30372. // 4
  30373. [1, 100, 80],
  30374. [2, 50, 32],
  30375. [2, 50, 24],
  30376. [4, 25, 9],
  30377. // 5
  30378. [1, 134, 108],
  30379. [2, 67, 43],
  30380. [2, 33, 15, 2, 34, 16],
  30381. [2, 33, 11, 2, 34, 12],
  30382. // 6
  30383. [2, 86, 68],
  30384. [4, 43, 27],
  30385. [4, 43, 19],
  30386. [4, 43, 15],
  30387. // 7
  30388. [2, 98, 78],
  30389. [4, 49, 31],
  30390. [2, 32, 14, 4, 33, 15],
  30391. [4, 39, 13, 1, 40, 14],
  30392. // 8
  30393. [2, 121, 97],
  30394. [2, 60, 38, 2, 61, 39],
  30395. [4, 40, 18, 2, 41, 19],
  30396. [4, 40, 14, 2, 41, 15],
  30397. // 9
  30398. [2, 146, 116],
  30399. [3, 58, 36, 2, 59, 37],
  30400. [4, 36, 16, 4, 37, 17],
  30401. [4, 36, 12, 4, 37, 13],
  30402. // 10
  30403. [2, 86, 68, 2, 87, 69],
  30404. [4, 69, 43, 1, 70, 44],
  30405. [6, 43, 19, 2, 44, 20],
  30406. [6, 43, 15, 2, 44, 16],
  30407. // 11
  30408. [4, 101, 81],
  30409. [1, 80, 50, 4, 81, 51],
  30410. [4, 50, 22, 4, 51, 23],
  30411. [3, 36, 12, 8, 37, 13],
  30412. // 12
  30413. [2, 116, 92, 2, 117, 93],
  30414. [6, 58, 36, 2, 59, 37],
  30415. [4, 46, 20, 6, 47, 21],
  30416. [7, 42, 14, 4, 43, 15],
  30417. // 13
  30418. [4, 133, 107],
  30419. [8, 59, 37, 1, 60, 38],
  30420. [8, 44, 20, 4, 45, 21],
  30421. [12, 33, 11, 4, 34, 12],
  30422. // 14
  30423. [3, 145, 115, 1, 146, 116],
  30424. [4, 64, 40, 5, 65, 41],
  30425. [11, 36, 16, 5, 37, 17],
  30426. [11, 36, 12, 5, 37, 13],
  30427. // 15
  30428. [5, 109, 87, 1, 110, 88],
  30429. [5, 65, 41, 5, 66, 42],
  30430. [5, 54, 24, 7, 55, 25],
  30431. [11, 36, 12, 7, 37, 13],
  30432. // 16
  30433. [5, 122, 98, 1, 123, 99],
  30434. [7, 73, 45, 3, 74, 46],
  30435. [15, 43, 19, 2, 44, 20],
  30436. [3, 45, 15, 13, 46, 16],
  30437. // 17
  30438. [1, 135, 107, 5, 136, 108],
  30439. [10, 74, 46, 1, 75, 47],
  30440. [1, 50, 22, 15, 51, 23],
  30441. [2, 42, 14, 17, 43, 15],
  30442. // 18
  30443. [5, 150, 120, 1, 151, 121],
  30444. [9, 69, 43, 4, 70, 44],
  30445. [17, 50, 22, 1, 51, 23],
  30446. [2, 42, 14, 19, 43, 15],
  30447. // 19
  30448. [3, 141, 113, 4, 142, 114],
  30449. [3, 70, 44, 11, 71, 45],
  30450. [17, 47, 21, 4, 48, 22],
  30451. [9, 39, 13, 16, 40, 14],
  30452. // 20
  30453. [3, 135, 107, 5, 136, 108],
  30454. [3, 67, 41, 13, 68, 42],
  30455. [15, 54, 24, 5, 55, 25],
  30456. [15, 43, 15, 10, 44, 16],
  30457. // 21
  30458. [4, 144, 116, 4, 145, 117],
  30459. [17, 68, 42],
  30460. [17, 50, 22, 6, 51, 23],
  30461. [19, 46, 16, 6, 47, 17],
  30462. // 22
  30463. [2, 139, 111, 7, 140, 112],
  30464. [17, 74, 46],
  30465. [7, 54, 24, 16, 55, 25],
  30466. [34, 37, 13],
  30467. // 23
  30468. [4, 151, 121, 5, 152, 122],
  30469. [4, 75, 47, 14, 76, 48],
  30470. [11, 54, 24, 14, 55, 25],
  30471. [16, 45, 15, 14, 46, 16],
  30472. // 24
  30473. [6, 147, 117, 4, 148, 118],
  30474. [6, 73, 45, 14, 74, 46],
  30475. [11, 54, 24, 16, 55, 25],
  30476. [30, 46, 16, 2, 47, 17],
  30477. // 25
  30478. [8, 132, 106, 4, 133, 107],
  30479. [8, 75, 47, 13, 76, 48],
  30480. [7, 54, 24, 22, 55, 25],
  30481. [22, 45, 15, 13, 46, 16],
  30482. // 26
  30483. [10, 142, 114, 2, 143, 115],
  30484. [19, 74, 46, 4, 75, 47],
  30485. [28, 50, 22, 6, 51, 23],
  30486. [33, 46, 16, 4, 47, 17],
  30487. // 27
  30488. [8, 152, 122, 4, 153, 123],
  30489. [22, 73, 45, 3, 74, 46],
  30490. [8, 53, 23, 26, 54, 24],
  30491. [12, 45, 15, 28, 46, 16],
  30492. // 28
  30493. [3, 147, 117, 10, 148, 118],
  30494. [3, 73, 45, 23, 74, 46],
  30495. [4, 54, 24, 31, 55, 25],
  30496. [11, 45, 15, 31, 46, 16],
  30497. // 29
  30498. [7, 146, 116, 7, 147, 117],
  30499. [21, 73, 45, 7, 74, 46],
  30500. [1, 53, 23, 37, 54, 24],
  30501. [19, 45, 15, 26, 46, 16],
  30502. // 30
  30503. [5, 145, 115, 10, 146, 116],
  30504. [19, 75, 47, 10, 76, 48],
  30505. [15, 54, 24, 25, 55, 25],
  30506. [23, 45, 15, 25, 46, 16],
  30507. // 31
  30508. [13, 145, 115, 3, 146, 116],
  30509. [2, 74, 46, 29, 75, 47],
  30510. [42, 54, 24, 1, 55, 25],
  30511. [23, 45, 15, 28, 46, 16],
  30512. // 32
  30513. [17, 145, 115],
  30514. [10, 74, 46, 23, 75, 47],
  30515. [10, 54, 24, 35, 55, 25],
  30516. [19, 45, 15, 35, 46, 16],
  30517. // 33
  30518. [17, 145, 115, 1, 146, 116],
  30519. [14, 74, 46, 21, 75, 47],
  30520. [29, 54, 24, 19, 55, 25],
  30521. [11, 45, 15, 46, 46, 16],
  30522. // 34
  30523. [13, 145, 115, 6, 146, 116],
  30524. [14, 74, 46, 23, 75, 47],
  30525. [44, 54, 24, 7, 55, 25],
  30526. [59, 46, 16, 1, 47, 17],
  30527. // 35
  30528. [12, 151, 121, 7, 152, 122],
  30529. [12, 75, 47, 26, 76, 48],
  30530. [39, 54, 24, 14, 55, 25],
  30531. [22, 45, 15, 41, 46, 16],
  30532. // 36
  30533. [6, 151, 121, 14, 152, 122],
  30534. [6, 75, 47, 34, 76, 48],
  30535. [46, 54, 24, 10, 55, 25],
  30536. [2, 45, 15, 64, 46, 16],
  30537. // 37
  30538. [17, 152, 122, 4, 153, 123],
  30539. [29, 74, 46, 14, 75, 47],
  30540. [49, 54, 24, 10, 55, 25],
  30541. [24, 45, 15, 46, 46, 16],
  30542. // 38
  30543. [4, 152, 122, 18, 153, 123],
  30544. [13, 74, 46, 32, 75, 47],
  30545. [48, 54, 24, 14, 55, 25],
  30546. [42, 45, 15, 32, 46, 16],
  30547. // 39
  30548. [20, 147, 117, 4, 148, 118],
  30549. [40, 75, 47, 7, 76, 48],
  30550. [43, 54, 24, 22, 55, 25],
  30551. [10, 45, 15, 67, 46, 16],
  30552. // 40
  30553. [19, 148, 118, 6, 149, 119],
  30554. [18, 75, 47, 31, 76, 48],
  30555. [34, 54, 24, 34, 55, 25],
  30556. [20, 45, 15, 61, 46, 16]
  30557. ];
  30558. var qrRSBlock = function(totalCount, dataCount) {
  30559. var _this2 = {};
  30560. _this2.totalCount = totalCount;
  30561. _this2.dataCount = dataCount;
  30562. return _this2;
  30563. };
  30564. var _this = {};
  30565. var getRsBlockTable = function(typeNumber, errorCorrectionLevel) {
  30566. switch (errorCorrectionLevel) {
  30567. case QRErrorCorrectionLevel.L:
  30568. return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
  30569. case QRErrorCorrectionLevel.M:
  30570. return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
  30571. case QRErrorCorrectionLevel.Q:
  30572. return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
  30573. case QRErrorCorrectionLevel.H:
  30574. return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
  30575. default:
  30576. return void 0;
  30577. }
  30578. };
  30579. _this.getRSBlocks = function(typeNumber, errorCorrectionLevel) {
  30580. var rsBlock = getRsBlockTable(typeNumber, errorCorrectionLevel);
  30581. if (typeof rsBlock == "undefined") {
  30582. throw "bad rs block @ typeNumber:" + typeNumber + "/errorCorrectionLevel:" + errorCorrectionLevel;
  30583. }
  30584. var length = rsBlock.length / 3;
  30585. var list = [];
  30586. for (var i2 = 0; i2 < length; i2 += 1) {
  30587. var count = rsBlock[i2 * 3 + 0];
  30588. var totalCount = rsBlock[i2 * 3 + 1];
  30589. var dataCount = rsBlock[i2 * 3 + 2];
  30590. for (var j = 0; j < count; j += 1) {
  30591. list.push(qrRSBlock(totalCount, dataCount));
  30592. }
  30593. }
  30594. return list;
  30595. };
  30596. return _this;
  30597. }();
  30598. var qrBitBuffer = function() {
  30599. var _buffer = [];
  30600. var _length = 0;
  30601. var _this = {};
  30602. _this.getBuffer = function() {
  30603. return _buffer;
  30604. };
  30605. _this.getAt = function(index) {
  30606. var bufIndex = Math.floor(index / 8);
  30607. return (_buffer[bufIndex] >>> 7 - index % 8 & 1) == 1;
  30608. };
  30609. _this.put = function(num, length) {
  30610. for (var i2 = 0; i2 < length; i2 += 1) {
  30611. _this.putBit((num >>> length - i2 - 1 & 1) == 1);
  30612. }
  30613. };
  30614. _this.getLengthInBits = function() {
  30615. return _length;
  30616. };
  30617. _this.putBit = function(bit) {
  30618. var bufIndex = Math.floor(_length / 8);
  30619. if (_buffer.length <= bufIndex) {
  30620. _buffer.push(0);
  30621. }
  30622. if (bit) {
  30623. _buffer[bufIndex] |= 128 >>> _length % 8;
  30624. }
  30625. _length += 1;
  30626. };
  30627. return _this;
  30628. };
  30629. var qrNumber = function(data) {
  30630. var _mode = QRMode.MODE_NUMBER;
  30631. var _data = data;
  30632. var _this = {};
  30633. _this.getMode = function() {
  30634. return _mode;
  30635. };
  30636. _this.getLength = function(buffer) {
  30637. return _data.length;
  30638. };
  30639. _this.write = function(buffer) {
  30640. var data2 = _data;
  30641. var i2 = 0;
  30642. while (i2 + 2 < data2.length) {
  30643. buffer.put(strToNum(data2.substring(i2, i2 + 3)), 10);
  30644. i2 += 3;
  30645. }
  30646. if (i2 < data2.length) {
  30647. if (data2.length - i2 == 1) {
  30648. buffer.put(strToNum(data2.substring(i2, i2 + 1)), 4);
  30649. } else if (data2.length - i2 == 2) {
  30650. buffer.put(strToNum(data2.substring(i2, i2 + 2)), 7);
  30651. }
  30652. }
  30653. };
  30654. var strToNum = function(s) {
  30655. var num = 0;
  30656. for (var i2 = 0; i2 < s.length; i2 += 1) {
  30657. num = num * 10 + chatToNum(s.charAt(i2));
  30658. }
  30659. return num;
  30660. };
  30661. var chatToNum = function(c) {
  30662. if ("0" <= c && c <= "9") {
  30663. return c.charCodeAt(0) - "0".charCodeAt(0);
  30664. }
  30665. throw "illegal char :" + c;
  30666. };
  30667. return _this;
  30668. };
  30669. var qrAlphaNum = function(data) {
  30670. var _mode = QRMode.MODE_ALPHA_NUM;
  30671. var _data = data;
  30672. var _this = {};
  30673. _this.getMode = function() {
  30674. return _mode;
  30675. };
  30676. _this.getLength = function(buffer) {
  30677. return _data.length;
  30678. };
  30679. _this.write = function(buffer) {
  30680. var s = _data;
  30681. var i2 = 0;
  30682. while (i2 + 1 < s.length) {
  30683. buffer.put(
  30684. getCode(s.charAt(i2)) * 45 + getCode(s.charAt(i2 + 1)),
  30685. 11
  30686. );
  30687. i2 += 2;
  30688. }
  30689. if (i2 < s.length) {
  30690. buffer.put(getCode(s.charAt(i2)), 6);
  30691. }
  30692. };
  30693. var getCode = function(c) {
  30694. if ("0" <= c && c <= "9") {
  30695. return c.charCodeAt(0) - "0".charCodeAt(0);
  30696. } else if ("A" <= c && c <= "Z") {
  30697. return c.charCodeAt(0) - "A".charCodeAt(0) + 10;
  30698. } else {
  30699. switch (c) {
  30700. case " ":
  30701. return 36;
  30702. case "$":
  30703. return 37;
  30704. case "%":
  30705. return 38;
  30706. case "*":
  30707. return 39;
  30708. case "+":
  30709. return 40;
  30710. case "-":
  30711. return 41;
  30712. case ".":
  30713. return 42;
  30714. case "/":
  30715. return 43;
  30716. case ":":
  30717. return 44;
  30718. default:
  30719. throw "illegal char :" + c;
  30720. }
  30721. }
  30722. };
  30723. return _this;
  30724. };
  30725. var qr8BitByte = function(data) {
  30726. var _mode = QRMode.MODE_8BIT_BYTE;
  30727. var _bytes = qrcode3.stringToBytes(data);
  30728. var _this = {};
  30729. _this.getMode = function() {
  30730. return _mode;
  30731. };
  30732. _this.getLength = function(buffer) {
  30733. return _bytes.length;
  30734. };
  30735. _this.write = function(buffer) {
  30736. for (var i2 = 0; i2 < _bytes.length; i2 += 1) {
  30737. buffer.put(_bytes[i2], 8);
  30738. }
  30739. };
  30740. return _this;
  30741. };
  30742. var qrKanji = function(data) {
  30743. var _mode = QRMode.MODE_KANJI;
  30744. var stringToBytes = qrcode3.stringToBytesFuncs["SJIS"];
  30745. if (!stringToBytes) {
  30746. throw "sjis not supported.";
  30747. }
  30748. !function(c, code) {
  30749. var test2 = stringToBytes(c);
  30750. if (test2.length != 2 || (test2[0] << 8 | test2[1]) != code) {
  30751. throw "sjis not supported.";
  30752. }
  30753. }("友", 38726);
  30754. var _bytes = stringToBytes(data);
  30755. var _this = {};
  30756. _this.getMode = function() {
  30757. return _mode;
  30758. };
  30759. _this.getLength = function(buffer) {
  30760. return ~~(_bytes.length / 2);
  30761. };
  30762. _this.write = function(buffer) {
  30763. var data2 = _bytes;
  30764. var i2 = 0;
  30765. while (i2 + 1 < data2.length) {
  30766. var c = (255 & data2[i2]) << 8 | 255 & data2[i2 + 1];
  30767. if (33088 <= c && c <= 40956) {
  30768. c -= 33088;
  30769. } else if (57408 <= c && c <= 60351) {
  30770. c -= 49472;
  30771. } else {
  30772. throw "illegal char at " + (i2 + 1) + "/" + c;
  30773. }
  30774. c = (c >>> 8 & 255) * 192 + (c & 255);
  30775. buffer.put(c, 13);
  30776. i2 += 2;
  30777. }
  30778. if (i2 < data2.length) {
  30779. throw "illegal char at " + (i2 + 1);
  30780. }
  30781. };
  30782. return _this;
  30783. };
  30784. var byteArrayOutputStream = function() {
  30785. var _bytes = [];
  30786. var _this = {};
  30787. _this.writeByte = function(b) {
  30788. _bytes.push(b & 255);
  30789. };
  30790. _this.writeShort = function(i2) {
  30791. _this.writeByte(i2);
  30792. _this.writeByte(i2 >>> 8);
  30793. };
  30794. _this.writeBytes = function(b, off, len) {
  30795. off = off || 0;
  30796. len = len || b.length;
  30797. for (var i2 = 0; i2 < len; i2 += 1) {
  30798. _this.writeByte(b[i2 + off]);
  30799. }
  30800. };
  30801. _this.writeString = function(s) {
  30802. for (var i2 = 0; i2 < s.length; i2 += 1) {
  30803. _this.writeByte(s.charCodeAt(i2));
  30804. }
  30805. };
  30806. _this.toByteArray = function() {
  30807. return _bytes;
  30808. };
  30809. _this.toString = function() {
  30810. var s = "";
  30811. s += "[";
  30812. for (var i2 = 0; i2 < _bytes.length; i2 += 1) {
  30813. if (i2 > 0) {
  30814. s += ",";
  30815. }
  30816. s += _bytes[i2];
  30817. }
  30818. s += "]";
  30819. return s;
  30820. };
  30821. return _this;
  30822. };
  30823. var base64EncodeOutputStream = function() {
  30824. var _buffer = 0;
  30825. var _buflen = 0;
  30826. var _length = 0;
  30827. var _base64 = "";
  30828. var _this = {};
  30829. var writeEncoded = function(b) {
  30830. _base64 += String.fromCharCode(encode(b & 63));
  30831. };
  30832. var encode = function(n) {
  30833. if (n < 0)
  30834. ;
  30835. else if (n < 26) {
  30836. return 65 + n;
  30837. } else if (n < 52) {
  30838. return 97 + (n - 26);
  30839. } else if (n < 62) {
  30840. return 48 + (n - 52);
  30841. } else if (n == 62) {
  30842. return 43;
  30843. } else if (n == 63) {
  30844. return 47;
  30845. }
  30846. throw "n:" + n;
  30847. };
  30848. _this.writeByte = function(n) {
  30849. _buffer = _buffer << 8 | n & 255;
  30850. _buflen += 8;
  30851. _length += 1;
  30852. while (_buflen >= 6) {
  30853. writeEncoded(_buffer >>> _buflen - 6);
  30854. _buflen -= 6;
  30855. }
  30856. };
  30857. _this.flush = function() {
  30858. if (_buflen > 0) {
  30859. writeEncoded(_buffer << 6 - _buflen);
  30860. _buffer = 0;
  30861. _buflen = 0;
  30862. }
  30863. if (_length % 3 != 0) {
  30864. var padlen = 3 - _length % 3;
  30865. for (var i2 = 0; i2 < padlen; i2 += 1) {
  30866. _base64 += "=";
  30867. }
  30868. }
  30869. };
  30870. _this.toString = function() {
  30871. return _base64;
  30872. };
  30873. return _this;
  30874. };
  30875. var base64DecodeInputStream = function(str) {
  30876. var _str = str;
  30877. var _pos = 0;
  30878. var _buffer = 0;
  30879. var _buflen = 0;
  30880. var _this = {};
  30881. _this.read = function() {
  30882. while (_buflen < 8) {
  30883. if (_pos >= _str.length) {
  30884. if (_buflen == 0) {
  30885. return -1;
  30886. }
  30887. throw "unexpected end of file./" + _buflen;
  30888. }
  30889. var c = _str.charAt(_pos);
  30890. _pos += 1;
  30891. if (c == "=") {
  30892. _buflen = 0;
  30893. return -1;
  30894. } else if (c.match(/^\s$/)) {
  30895. continue;
  30896. }
  30897. _buffer = _buffer << 6 | decode(c.charCodeAt(0));
  30898. _buflen += 6;
  30899. }
  30900. var n = _buffer >>> _buflen - 8 & 255;
  30901. _buflen -= 8;
  30902. return n;
  30903. };
  30904. var decode = function(c) {
  30905. if (65 <= c && c <= 90) {
  30906. return c - 65;
  30907. } else if (97 <= c && c <= 122) {
  30908. return c - 97 + 26;
  30909. } else if (48 <= c && c <= 57) {
  30910. return c - 48 + 52;
  30911. } else if (c == 43) {
  30912. return 62;
  30913. } else if (c == 47) {
  30914. return 63;
  30915. } else {
  30916. throw "c:" + c;
  30917. }
  30918. };
  30919. return _this;
  30920. };
  30921. var gifImage = function(width, height) {
  30922. var _width = width;
  30923. var _height = height;
  30924. var _data = new Array(width * height);
  30925. var _this = {};
  30926. _this.setPixel = function(x, y, pixel) {
  30927. _data[y * _width + x] = pixel;
  30928. };
  30929. _this.write = function(out) {
  30930. out.writeString("GIF87a");
  30931. out.writeShort(_width);
  30932. out.writeShort(_height);
  30933. out.writeByte(128);
  30934. out.writeByte(0);
  30935. out.writeByte(0);
  30936. out.writeByte(0);
  30937. out.writeByte(0);
  30938. out.writeByte(0);
  30939. out.writeByte(255);
  30940. out.writeByte(255);
  30941. out.writeByte(255);
  30942. out.writeString(",");
  30943. out.writeShort(0);
  30944. out.writeShort(0);
  30945. out.writeShort(_width);
  30946. out.writeShort(_height);
  30947. out.writeByte(0);
  30948. var lzwMinCodeSize = 2;
  30949. var raster = getLZWRaster(lzwMinCodeSize);
  30950. out.writeByte(lzwMinCodeSize);
  30951. var offset = 0;
  30952. while (raster.length - offset > 255) {
  30953. out.writeByte(255);
  30954. out.writeBytes(raster, offset, 255);
  30955. offset += 255;
  30956. }
  30957. out.writeByte(raster.length - offset);
  30958. out.writeBytes(raster, offset, raster.length - offset);
  30959. out.writeByte(0);
  30960. out.writeString(";");
  30961. };
  30962. var bitOutputStream = function(out) {
  30963. var _out = out;
  30964. var _bitLength = 0;
  30965. var _bitBuffer = 0;
  30966. var _this2 = {};
  30967. _this2.write = function(data, length) {
  30968. if (data >>> length != 0) {
  30969. throw "length over";
  30970. }
  30971. while (_bitLength + length >= 8) {
  30972. _out.writeByte(255 & (data << _bitLength | _bitBuffer));
  30973. length -= 8 - _bitLength;
  30974. data >>>= 8 - _bitLength;
  30975. _bitBuffer = 0;
  30976. _bitLength = 0;
  30977. }
  30978. _bitBuffer = data << _bitLength | _bitBuffer;
  30979. _bitLength = _bitLength + length;
  30980. };
  30981. _this2.flush = function() {
  30982. if (_bitLength > 0) {
  30983. _out.writeByte(_bitBuffer);
  30984. }
  30985. };
  30986. return _this2;
  30987. };
  30988. var getLZWRaster = function(lzwMinCodeSize) {
  30989. var clearCode = 1 << lzwMinCodeSize;
  30990. var endCode = (1 << lzwMinCodeSize) + 1;
  30991. var bitLength = lzwMinCodeSize + 1;
  30992. var table = lzwTable();
  30993. for (var i2 = 0; i2 < clearCode; i2 += 1) {
  30994. table.add(String.fromCharCode(i2));
  30995. }
  30996. table.add(String.fromCharCode(clearCode));
  30997. table.add(String.fromCharCode(endCode));
  30998. var byteOut = byteArrayOutputStream();
  30999. var bitOut = bitOutputStream(byteOut);
  31000. bitOut.write(clearCode, bitLength);
  31001. var dataIndex = 0;
  31002. var s = String.fromCharCode(_data[dataIndex]);
  31003. dataIndex += 1;
  31004. while (dataIndex < _data.length) {
  31005. var c = String.fromCharCode(_data[dataIndex]);
  31006. dataIndex += 1;
  31007. if (table.contains(s + c)) {
  31008. s = s + c;
  31009. } else {
  31010. bitOut.write(table.indexOf(s), bitLength);
  31011. if (table.size() < 4095) {
  31012. if (table.size() == 1 << bitLength) {
  31013. bitLength += 1;
  31014. }
  31015. table.add(s + c);
  31016. }
  31017. s = c;
  31018. }
  31019. }
  31020. bitOut.write(table.indexOf(s), bitLength);
  31021. bitOut.write(endCode, bitLength);
  31022. bitOut.flush();
  31023. return byteOut.toByteArray();
  31024. };
  31025. var lzwTable = function() {
  31026. var _map = {};
  31027. var _size = 0;
  31028. var _this2 = {};
  31029. _this2.add = function(key) {
  31030. if (_this2.contains(key)) {
  31031. throw "dup key:" + key;
  31032. }
  31033. _map[key] = _size;
  31034. _size += 1;
  31035. };
  31036. _this2.size = function() {
  31037. return _size;
  31038. };
  31039. _this2.indexOf = function(key) {
  31040. return _map[key];
  31041. };
  31042. _this2.contains = function(key) {
  31043. return typeof _map[key] != "undefined";
  31044. };
  31045. return _this2;
  31046. };
  31047. return _this;
  31048. };
  31049. var createDataURL = function(width, height, getPixel) {
  31050. var gif = gifImage(width, height);
  31051. for (var y = 0; y < height; y += 1) {
  31052. for (var x = 0; x < width; x += 1) {
  31053. gif.setPixel(x, y, getPixel(x, y));
  31054. }
  31055. }
  31056. var b = byteArrayOutputStream();
  31057. gif.write(b);
  31058. var base64 = base64EncodeOutputStream();
  31059. var bytes = b.toByteArray();
  31060. for (var i2 = 0; i2 < bytes.length; i2 += 1) {
  31061. base64.writeByte(bytes[i2]);
  31062. }
  31063. base64.flush();
  31064. return "data:image/gif;base64," + base64;
  31065. };
  31066. return qrcode3;
  31067. }();
  31068. !function() {
  31069. qrcode2.stringToBytesFuncs["UTF-8"] = function(s) {
  31070. function toUTF8Array(str) {
  31071. var utf8 = [];
  31072. for (var i2 = 0; i2 < str.length; i2++) {
  31073. var charcode = str.charCodeAt(i2);
  31074. if (charcode < 128)
  31075. utf8.push(charcode);
  31076. else if (charcode < 2048) {
  31077. utf8.push(
  31078. 192 | charcode >> 6,
  31079. 128 | charcode & 63
  31080. );
  31081. } else if (charcode < 55296 || charcode >= 57344) {
  31082. utf8.push(
  31083. 224 | charcode >> 12,
  31084. 128 | charcode >> 6 & 63,
  31085. 128 | charcode & 63
  31086. );
  31087. } else {
  31088. i2++;
  31089. charcode = 65536 + ((charcode & 1023) << 10 | str.charCodeAt(i2) & 1023);
  31090. utf8.push(
  31091. 240 | charcode >> 18,
  31092. 128 | charcode >> 12 & 63,
  31093. 128 | charcode >> 6 & 63,
  31094. 128 | charcode & 63
  31095. );
  31096. }
  31097. }
  31098. return utf8;
  31099. }
  31100. return toUTF8Array(s);
  31101. };
  31102. }();
  31103. (function(factory) {
  31104. {
  31105. module.exports = factory();
  31106. }
  31107. })(function() {
  31108. return qrcode2;
  31109. });
  31110. })(qrcode);
  31111. var qrcodeExports = qrcode.exports;
  31112. const QRCode = /* @__PURE__ */ getDefaultExportFromCjs(qrcodeExports);
  31113. function McDbEntityToJsonObject(ent) {
  31114. let obj = {};
  31115. obj.ObjectName = ent.objectName;
  31116. obj.id = ent.getObjectID().id;
  31117. obj.handle = ent.getHandle();
  31118. obj.layer = ent.layer;
  31119. obj.color = ent.trueColor.getColorString();
  31120. obj.colorVal = ent.trueColor.getColorValue(ent.layerId);
  31121. obj.linetype = ent.linetype;
  31122. obj.textStyle = ent.textStyle;
  31123. obj.type = ent.objectName;
  31124. obj.dxf0 = ent.dxf0;
  31125. if (ent instanceof mxcad2.McDbText) {
  31126. let txt = ent;
  31127. obj.position = McGePoint3dToString(txt.position);
  31128. obj.textString = txt.textString;
  31129. } else if (ent instanceof mxcad2.McDbMText) {
  31130. let mtxt = ent;
  31131. obj.contents = mtxt.contents;
  31132. obj.location = McGePoint3dToString(mtxt.location);
  31133. } else if (ent instanceof mxcad2.McDbLine) {
  31134. let line = ent;
  31135. obj.startPoint = McGePoint3dToString(line.startPoint);
  31136. obj.endPoint = McGePoint3dToString(line.endPoint);
  31137. } else if (ent instanceof mxcad2.McDbCircle) {
  31138. let circle = ent;
  31139. obj.center = McGePoint3dToString(circle.center);
  31140. obj.radius = circle.radius;
  31141. } else if (ent instanceof mxcad2.McDbArc) {
  31142. let arc = ent;
  31143. obj.center = McGePoint3dToString(arc.center);
  31144. obj.startAngle = arc.startAngle;
  31145. obj.endAngle = arc.endAngle;
  31146. } else if (ent instanceof mxcad2.McDbPolyline) {
  31147. let polyline = ent;
  31148. let num = polyline.numVerts();
  31149. obj.num = num;
  31150. for (let i2 = 0; i2 < num; i2++) {
  31151. let pt = polyline.getPointAt(i2);
  31152. let bulge = polyline.getBulgeAt(i2);
  31153. obj["pt" + i2] = McGePoint3dToString(pt.val);
  31154. obj["bulge" + i2] = bulge;
  31155. }
  31156. } else if (ent instanceof mxcad2.McDbBlockReference) {
  31157. let blkRef = ent;
  31158. obj.position = McGePoint3dToString(blkRef.position);
  31159. obj.blockTransform = blkRef.blockTransform;
  31160. obj.blockName = blkRef.blockName;
  31161. } else if (ent instanceof mxcad2.McDbAlignedDimension) {
  31162. let alignedDim = ent;
  31163. obj.xLine1Point = McGePoint3dToString(alignedDim.xLine1Point);
  31164. obj.xLine2Point = McGePoint3dToString(alignedDim.xLine2Point);
  31165. let txts = alignedDim.GetAllText();
  31166. txts.forEach((val, index) => {
  31167. obj["txt:" + index] = val;
  31168. });
  31169. } else if (ent instanceof mxcad2.McDbRotatedDimension) {
  31170. let rotatedDim = ent;
  31171. obj.xLine1Point = McGePoint3dToString(rotatedDim.xLine1Point);
  31172. obj.xLine2Point = McGePoint3dToString(rotatedDim.xLine2Point);
  31173. let txts = rotatedDim.GetAllText();
  31174. txts.forEach((val, index) => {
  31175. obj["txt:" + index] = val;
  31176. });
  31177. } else if (ent instanceof mxcad2.McDbDimension) {
  31178. let dim = ent;
  31179. let txts = dim.GetAllText();
  31180. txts.forEach((val, index) => {
  31181. obj["txt:" + index] = val;
  31182. });
  31183. } else if (ent instanceof mxcad2.McDbHatch) {
  31184. let hatch = ent;
  31185. obj.patternType = hatch.patternType();
  31186. obj.patternName = hatch.patternName();
  31187. obj.patternAngle = hatch.patternAngle;
  31188. obj.patternScale = hatch.patternScale;
  31189. obj.patternSpace = hatch.patternSpace;
  31190. obj.patternDouble = hatch.patternDouble;
  31191. obj.hatchStyle = hatch.hatchStyle();
  31192. obj.isSolid = hatch.isSolid();
  31193. obj.numLoops = hatch.numLoops;
  31194. for (let i2 = 0; i2 < obj.numLoops; i2++) {
  31195. let loop = hatch.getLoopAt(i2);
  31196. loop.vertices.forEach((val, inidex) => {
  31197. loop["pt:" + inidex] = {};
  31198. loop["pt:" + inidex].x = val.x;
  31199. loop["pt:" + inidex].y = val.y;
  31200. loop["pt:" + inidex].z = val.z;
  31201. });
  31202. obj["loop:" + i2] = loop;
  31203. }
  31204. obj.numPatternDefinitions = hatch.numPatternDefinitions;
  31205. for (let i2 = 0; i2 < obj.numPatternDefinitions; i2++) {
  31206. obj["patternDefinitions:" + i2] = hatch.getPatternDefinitionAt(i2);
  31207. }
  31208. } else if (ent instanceof mxcad2.McDbRasterImage) {
  31209. let image = ent;
  31210. let orientation = image.getOrientation();
  31211. obj.orientation = {};
  31212. obj.orientation.origin = orientation.origin.toVector3();
  31213. obj.orientation.uCorner = orientation.uCorner.toVector3();
  31214. obj.orientation.vOnPlane = orientation.vOnPlane.toVector3();
  31215. let clipBoundary = image.clipBoundary();
  31216. obj.clipBoundary = {};
  31217. clipBoundary.forEach((pt, index) => {
  31218. obj.clipBoundary["pt" + index] = pt.toVector3();
  31219. });
  31220. obj.clipBoundaryType = image.clipBoundaryType();
  31221. let imageDef = image.imageDefId().getMcDbRasterImageDef();
  31222. if (imageDef) {
  31223. obj.filePath = imageDef.sourceFileName;
  31224. }
  31225. }
  31226. return obj;
  31227. }
  31228. function TestGetAllEntity() {
  31229. return __async(this, null, function* () {
  31230. let ss = new mxcad2.MxCADSelectionSet();
  31231. ss.allSelect();
  31232. ss.forEach((id) => {
  31233. let ent = id.getMcDbEntity();
  31234. if (!ent)
  31235. return;
  31236. ent = McDbEntityToJsonObject(ent);
  31237. console.log(JSON.stringify(ent));
  31238. });
  31239. });
  31240. }
  31241. function TestGentEntityOnLayer() {
  31242. return __async(this, null, function* () {
  31243. let ss = new mxcad2.MxCADSelectionSet();
  31244. let filter = new mxcad2.MxCADResbuf();
  31245. filter.AddString("0", 8);
  31246. ss.allSelect(filter);
  31247. ss.forEach((id) => {
  31248. let ent = id.getMcDbEntity();
  31249. if (!ent)
  31250. return;
  31251. if (ent instanceof mxcad2.McDbHatch) {
  31252. let obj = {};
  31253. let hatch = ent;
  31254. obj.patternType = hatch.patternType();
  31255. obj.patternName = hatch.patternName();
  31256. obj.patternAngle = hatch.patternAngle;
  31257. obj.patternScale = hatch.patternScale;
  31258. obj.patternSpace = hatch.patternSpace;
  31259. obj.patternDouble = hatch.patternDouble;
  31260. obj.hatchStyle = hatch.hatchStyle();
  31261. obj.isSolid = hatch.isSolid();
  31262. obj.numLoops = hatch.numLoops;
  31263. for (let i2 = 0; i2 < obj.numLoops; i2++) {
  31264. let loop = hatch.getLoopAt(i2);
  31265. loop.vertices.forEach((val, inidex) => {
  31266. loop["pt:" + inidex] = {};
  31267. loop["pt:" + inidex].x = val.x;
  31268. loop["pt:" + inidex].y = val.y;
  31269. loop["pt:" + inidex].z = val.z;
  31270. });
  31271. obj["loop:" + i2] = loop;
  31272. }
  31273. obj.numPatternDefinitions = hatch.numPatternDefinitions;
  31274. for (let i2 = 0; i2 < obj.numPatternDefinitions; i2++) {
  31275. obj["patternDefinitions:" + i2] = hatch.getPatternDefinitionAt(i2);
  31276. }
  31277. console.log(obj);
  31278. }
  31279. });
  31280. });
  31281. }
  31282. function MxTest_GetSysVars() {
  31283. return __async(this, null, function* () {
  31284. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  31285. let database = mxcad$1.getDatabase();
  31286. let grid = {};
  31287. grid["name"] = "GRIDMODE";
  31288. grid["isShow"] = mxcad$1.getSysVarLong("GRIDMODE");
  31289. let ptSnapUnit = mxcad$1.getSysVarPoint("SNAPUNIT");
  31290. grid["xdist"] = ptSnapUnit.x;
  31291. grid["ydist"] = ptSnapUnit.x;
  31292. console.log(grid);
  31293. let ortho = {};
  31294. ortho["name"] = "ORTHOMODE";
  31295. ortho["isShow"] = mxcad$1.getSysVarLong("ORTHOMODE");
  31296. console.log(ortho);
  31297. let polarAxis = {};
  31298. polarAxis["name"] = "AUTOSNAP";
  31299. polarAxis["enable"] = (mxcad$1.getSysVarLong("AUTOSNAP") & 8) != 0;
  31300. polarAxis["polarang"] = mxcad$1.getSysVarDouble("POLARANG");
  31301. console.log(polarAxis);
  31302. let osnap = {};
  31303. osnap["name"] = "OSMODE";
  31304. osnap["enable"] = (mxcad$1.getSysVarLong("OSMODE") & 16384) == 0;
  31305. osnap["value"] = mxcad$1.getSysVarLong("OSMODE");
  31306. osnap["End"] = (mxcad$1.getSysVarLong("OSMODE") & 1) != 0;
  31307. osnap["Mid"] = (mxcad$1.getSysVarLong("OSMODE") & 2) != 0;
  31308. osnap["Cen"] = (mxcad$1.getSysVarLong("OSMODE") & 4) != 0;
  31309. osnap["Node"] = (mxcad$1.getSysVarLong("OSMODE") & 8) != 0;
  31310. osnap["Quad"] = (mxcad$1.getSysVarLong("OSMODE") & 16) != 0;
  31311. osnap["Int"] = (mxcad$1.getSysVarLong("OSMODE") & 32) != 0;
  31312. osnap["Ins"] = (mxcad$1.getSysVarLong("OSMODE") & 64) != 0;
  31313. osnap["Perp"] = (mxcad$1.getSysVarLong("OSMODE") & 128) != 0;
  31314. osnap["Tan"] = (mxcad$1.getSysVarLong("OSMODE") & 256) != 0;
  31315. osnap["Near"] = (mxcad$1.getSysVarLong("OSMODE") & 512) != 0;
  31316. console.log(osnap);
  31317. let dyntrace = {};
  31318. dyntrace["name"] = "DYNTRACE";
  31319. dyntrace["enable"] = mxcad$1.getSysVarLong("DYNTRACE") != 0;
  31320. console.log(dyntrace);
  31321. let dyn = {};
  31322. dyn["name"] = "DYNINPUT";
  31323. dyn["enable"] = mxcad$1.getSysVarLong("DYNINPUT") != 0;
  31324. console.log(dyn);
  31325. let sysvar = {};
  31326. sysvar.LTSCALE = mxcad$1.getSysVarDouble("LTSCALE");
  31327. sysvar.CELTSCALE = mxcad$1.getSysVarDouble("CELTSCALE");
  31328. sysvar.CELTYPE = mxcad$1.getSysVarString("CELTYPE");
  31329. sysvar.TEXTSTYLE = mxcad$1.getSysVarString("TEXTSTYLE");
  31330. sysvar.CLAYOUTNAME = mxcad$1.getSysVarString("CLAYOUTNAME");
  31331. sysvar.CLAYER = mxcad$1.getSysVarString("CLAYER");
  31332. sysvar.CECOLOR = database.getCurrentlyTrueColor().getColorValue();
  31333. sysvar.INSBASE = mxcad$1.getSysVarPoint("INSBASE");
  31334. sysvar.CELWEIGHT = mxcad$1.getSysVarLong("CELWEIGHT");
  31335. sysvar.PDMODE = mxcad$1.getSysVarLong("PDMODE");
  31336. sysvar.PDSIZE = mxcad$1.getSysVarDouble("PDSIZE");
  31337. console.log(sysvar);
  31338. });
  31339. }
  31340. function MxTest_ReadxData() {
  31341. return __async(this, null, function* () {
  31342. let selEntity = new mxcad2.MxCADUiPrEntity();
  31343. selEntity.setMessage("选择对象");
  31344. let id = yield selEntity.go();
  31345. if (!id.isValid())
  31346. return;
  31347. let ent = id.getMcDbEntity();
  31348. if (ent === null)
  31349. return;
  31350. let data = ent.getxData();
  31351. data.forEach((val, type, dxf) => {
  31352. console.log(JSON.stringify({ val, type, dxf }));
  31353. });
  31354. });
  31355. }
  31356. function MxTest_WritexData() {
  31357. return __async(this, null, function* () {
  31358. let selEntity = new mxcad2.MxCADUiPrEntity();
  31359. selEntity.setMessage("选择对象");
  31360. let id = yield selEntity.go();
  31361. if (!id.isValid())
  31362. return;
  31363. let ent = id.getMcDbEntity();
  31364. if (ent === null)
  31365. return;
  31366. ent.setxDataString("DataName", "xxxxx");
  31367. });
  31368. }
  31369. function MxTest_DrawLine() {
  31370. return __async(this, null, function* () {
  31371. const getPoint = new mxcad2.MxCADUiPrPoint();
  31372. getPoint.setMessage("\n指定第一点:");
  31373. let prvPoint = yield getPoint.go();
  31374. if (!prvPoint)
  31375. return;
  31376. getPoint.setMessage("\n指定下一个点:");
  31377. while (true) {
  31378. getPoint.setBasePt(prvPoint);
  31379. let pt = yield getPoint.go();
  31380. if (!pt)
  31381. return;
  31382. let line = new mxcad2.McDbLine(prvPoint, pt);
  31383. mxcad2.MxCpp.getCurrentMxCAD().drawEntity(line);
  31384. prvPoint = pt;
  31385. }
  31386. });
  31387. }
  31388. function getHostUrl() {
  31389. let host = window.location.hostname;
  31390. if (host.substring(0, 4) != "http") {
  31391. host = document.location.protocol + "//" + host;
  31392. }
  31393. return host;
  31394. }
  31395. function MxTest_InsertBlock() {
  31396. return __async(this, null, function* () {
  31397. let baseUrl = "http://localhost:3000/mxcad/";
  31398. if (baseUrl.substring(0, 16) == "http://localhost") {
  31399. baseUrl = getHostUrl() + baseUrl.substring(16);
  31400. }
  31401. let blkFilePath = baseUrl + "tree.mxweb";
  31402. let mxcad$1 = mxcad2.MxCpp.App.getCurrentMxCAD();
  31403. let blkrecId = yield mxcad$1.insertBlock(blkFilePath, "tree");
  31404. if (!blkrecId.isValid()) {
  31405. return;
  31406. }
  31407. let blkRef = new mxcad2.McDbBlockReference();
  31408. blkRef.blockTableRecordId = blkrecId;
  31409. let box = blkRef.getBoundingBox();
  31410. if (box.ret) {
  31411. let dLen = box.maxPt.distanceTo(box.minPt);
  31412. if (dLen > 1e-5) {
  31413. blkRef.setScale(mxcad$1.getMxDrawObject().screenCoordLong2Doc(100) / dLen);
  31414. }
  31415. }
  31416. let getPoint = new mxcad2.MxCADUiPrPoint();
  31417. getPoint.setMessage("指定插入基点");
  31418. getPoint.setUserDraw((v, worldDraw) => {
  31419. blkRef.position = v;
  31420. worldDraw.drawMcDbEntity(blkRef);
  31421. });
  31422. let pt = yield getPoint.go();
  31423. if (!pt)
  31424. return;
  31425. blkRef.position = pt;
  31426. let newBlkRefId = mxcad$1.drawEntity(blkRef);
  31427. if (!newBlkRefId.isValid) {
  31428. console.log("insert error");
  31429. return;
  31430. }
  31431. blkRef = newBlkRefId.getMcDbEntity();
  31432. blkRef.disableDisplay(true);
  31433. let blkRecord = blkrecId.getMcDbBlockTableRecord();
  31434. let ids = blkRecord.getAllEntityId();
  31435. ids.forEach((id, index) => {
  31436. if (!id.isKindOf("McDbAttributeDefinition"))
  31437. return;
  31438. let attribDef = id.getMcDbEntity();
  31439. let tag = attribDef.tag;
  31440. let txt = attribDef.textString;
  31441. let attrib = new mxcad2.McDbAttribute();
  31442. attrib.position = attribDef.position;
  31443. attrib.alignmentPoint = attribDef.alignmentPoint;
  31444. attrib.height = attribDef.height;
  31445. attrib.trueColor = attribDef.trueColor;
  31446. attrib.widthFactor = attribDef.widthFactor;
  31447. if (txt.length > 0)
  31448. attrib.textString = txt;
  31449. else
  31450. attrib.textString = "test" + index;
  31451. attrib.tag = tag;
  31452. attrib.isInvisible = attribDef.isInvisible;
  31453. attrib.transformBy(blkRef.blockTransform);
  31454. attrib = blkRef.appendAttribute(attrib).getMcDbEntity();
  31455. attrib.textStyle = attribDef.textStyle;
  31456. attrib.layer = attribDef.layer;
  31457. });
  31458. blkRef.disableDisplay(false);
  31459. });
  31460. }
  31461. function MxTest_GetAllLayer() {
  31462. let mxcad$1 = mxcad2.MxCpp.App.getCurrentMxCAD();
  31463. let layerTable = mxcad$1.getDatabase().getLayerTable();
  31464. let aryId = layerTable.getAllRecordId();
  31465. let ret = [];
  31466. aryId.forEach((id) => {
  31467. let layerRec = id.getMcDbLayerTableRecord();
  31468. if (layerRec === null)
  31469. return;
  31470. console.log(layerRec);
  31471. console.log("layerRec.color:" + layerRec.color.getColorString());
  31472. console.log("layerRec.name:" + layerRec.name);
  31473. let layer = {};
  31474. layer.name = layerRec.name;
  31475. layer.color = layerRec.color.getColorString();
  31476. ret.push(layer);
  31477. });
  31478. mxdraw.MxFun.postMessageToParentFrame(ret);
  31479. return ret;
  31480. }
  31481. function MxTest_AddLayer() {
  31482. let mxcad$1 = mxcad2.MxCpp.App.getCurrentMxCAD();
  31483. let layerTable = mxcad$1.getDatabase().getLayerTable();
  31484. if (!layerTable.has("xxx11")) {
  31485. let newLayer = new mxcad2.McDbLayerTableRecord();
  31486. newLayer.name = "xxx11";
  31487. layerTable.add(newLayer);
  31488. }
  31489. if (layerTable.has("xxx11")) {
  31490. console.log("add layer ok");
  31491. }
  31492. }
  31493. function MxTest_GetAllLinetype() {
  31494. let mxcad$1 = mxcad2.MxCpp.App.getCurrentMxCAD();
  31495. let linetypeTable = mxcad$1.getDatabase().getLinetypeTable();
  31496. let aryId = linetypeTable.getAllRecordId();
  31497. aryId.forEach((id) => {
  31498. let linetypeRec = id.getMcDbLinetypeTableRecord();
  31499. if (linetypeRec === null)
  31500. return;
  31501. console.log(linetypeRec);
  31502. });
  31503. }
  31504. function MxTest_GetAllTextStyle() {
  31505. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  31506. let textSyleTable = mxcad$1.getDatabase().getTextStyleTable();
  31507. let aryId = textSyleTable.getAllRecordId();
  31508. aryId.forEach((id) => {
  31509. let textSyleRec = id.getMcDbTextStyleTableRecord();
  31510. if (textSyleRec === null)
  31511. return;
  31512. let out = {};
  31513. out.name = textSyleRec.name;
  31514. out.font = textSyleRec.font();
  31515. out.fileName = textSyleRec.fileName;
  31516. out.bigFontFileName = textSyleRec.bigFontFileName;
  31517. out.textSize = textSyleRec.textSize;
  31518. out.xScale = textSyleRec.xScale;
  31519. console.log(out);
  31520. });
  31521. }
  31522. function MxTest_AddTextStyleTable() {
  31523. return __async(this, null, function* () {
  31524. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  31525. let textSyleTable = mxcad$1.getDatabase().getTextStyleTable();
  31526. let sMyTextStyle = "MyTextStyle";
  31527. if (textSyleTable.has(sMyTextStyle, false)) {
  31528. let id = textSyleTable.get(sMyTextStyle, false);
  31529. id.erase(false);
  31530. }
  31531. let newTextStyleRecord = new mxcad2.McDbTextStyleTableRecord();
  31532. newTextStyleRecord.fileName = "txt.shx";
  31533. newTextStyleRecord.bigFontFileName = "hztxt.shx";
  31534. newTextStyleRecord.textSize = 10;
  31535. newTextStyleRecord.name = sMyTextStyle;
  31536. newTextStyleRecord.xScale = 0.7;
  31537. if (textSyleTable.add(newTextStyleRecord).isValid()) {
  31538. console.log("add ok");
  31539. }
  31540. });
  31541. }
  31542. function MxTest_GetAllBlock() {
  31543. let mxcad$1 = mxcad2.MxCpp.App.getCurrentMxCAD();
  31544. let blockTable = mxcad$1.getDatabase().getBlockTable();
  31545. let aryId = blockTable.getAllRecordId();
  31546. aryId.forEach((id) => {
  31547. let blkRec = id.getMcDbBlockTableRecord();
  31548. if (blkRec === null)
  31549. return;
  31550. console.log(blkRec);
  31551. console.log("blkRec.name:" + blkRec.name);
  31552. console.log("blkRec.origin:" + blkRec.origin);
  31553. });
  31554. }
  31555. function Mx_Test_DrawTable() {
  31556. return __async(this, null, function* () {
  31557. let draw = new MxDrawTable();
  31558. draw.data.addColumn("序号", 30);
  31559. draw.data.addColumn("名称", 45);
  31560. draw.data.addColumn("材料", 60);
  31561. draw.data.addColumn("长度", 50);
  31562. for (let i2 = 0; i2 < 10; i2++) {
  31563. let sT = "" + i2;
  31564. draw.data.addRow([sT, "AAAA", "BBBB", "1000"]);
  31565. }
  31566. let getPoint = new mxcad2.MxCADUiPrPoint();
  31567. getPoint.setMessage("\n指定表格插入点:");
  31568. let pt = yield getPoint.go();
  31569. if (!pt)
  31570. return;
  31571. let lScale = mxdraw.MxFun.screenCoordLong2Doc(100) / 200;
  31572. draw.draw(pt, lScale);
  31573. });
  31574. }
  31575. function Mx_Test_QRCode() {
  31576. return __async(this, null, function* () {
  31577. const getPoint = new mxdraw.MrxDbgUiPrPoint();
  31578. getPoint.setMessage("\n指定插入点:");
  31579. let pt = yield getPoint.go();
  31580. if (!pt)
  31581. return;
  31582. let mxobj = mxdraw.MxFun.getCurrentDraw();
  31583. const qr = QRCode(5, "L");
  31584. qr.addData("https://www.mxdraw3d.com");
  31585. qr.make();
  31586. const qrDataURL = qr.createDataURL();
  31587. const texture = new TextureLoader().load(qrDataURL);
  31588. const material = new MeshBasicMaterial({ map: texture });
  31589. let w = mxdraw.MxFun.screenCoordLong2Doc(80);
  31590. let h = mxdraw.MxFun.screenCoordLong2Doc(80);
  31591. let image = new mxdraw.MxDbImage();
  31592. image.setRenderOrder(mxdraw.MxType.MxDefaultRenderOrder.kCADMeshRenderOrder - 1);
  31593. image.setPoint1(pt);
  31594. let pt2 = new Vector3(pt.x + w, pt.y + h, pt.z);
  31595. image.setPoint2(pt2);
  31596. image.setMaterial(material);
  31597. mxobj.addMxEntity(image);
  31598. setInterval(() => {
  31599. mxobj.updateDisplay();
  31600. }, 100);
  31601. });
  31602. }
  31603. function MxTest_InsertStamp() {
  31604. return __async(this, null, function* () {
  31605. let baseUrl = "http://localhost:3000/mxcad/";
  31606. if (baseUrl.substring(0, 16) == "http://localhost") {
  31607. baseUrl = getHostUrl() + baseUrl.substring(16);
  31608. }
  31609. let blkFilePath = baseUrl + "stamp.mxweb";
  31610. let mxcad$1 = mxcad2.MxCpp.App.getCurrentMxCAD();
  31611. let blkrecId = yield mxcad$1.insertBlock(blkFilePath, "stamp");
  31612. if (!blkrecId.isValid()) {
  31613. return;
  31614. }
  31615. let blkRef = new mxcad2.McDbBlockReference();
  31616. blkRef.blockTableRecordId = blkrecId;
  31617. let box = blkRef.getBoundingBox();
  31618. if (box.ret) {
  31619. let dLen = box.maxPt.distanceTo(box.minPt);
  31620. if (dLen > 1e-5) {
  31621. blkRef.setScale(mxcad$1.getMxDrawObject().screenCoordLong2Doc(100) / dLen);
  31622. }
  31623. }
  31624. let getPoint = new mxcad2.MxCADUiPrPoint();
  31625. getPoint.setMessage("指定插入基点");
  31626. getPoint.setUserDraw((v, worldDraw) => {
  31627. blkRef.position = v;
  31628. worldDraw.drawMcDbEntity(blkRef);
  31629. });
  31630. let pt = yield getPoint.go();
  31631. if (!pt)
  31632. return;
  31633. blkRef.position = pt;
  31634. mxcad$1.drawEntity(blkRef);
  31635. });
  31636. }
  31637. function MxTest_LineTypeTest() {
  31638. return __async(this, null, function* () {
  31639. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  31640. let linetypeRecord = mxcad$1.database.getLinetypeTable().get("TestMyLine");
  31641. if (!linetypeRecord.isErase()) {
  31642. linetypeRecord.erase();
  31643. }
  31644. let lintype = mxcad$1.addLinetypeEx("TestMyLine", '.5,-.2,["HW",STANDARD,S=.1,R=0.0,X=-0.1,Y=-.05],-.2', "");
  31645. if (!lintype.isValid())
  31646. return;
  31647. let getEnt = new mxcad2.MxCADUiPrEntity();
  31648. let entId = yield getEnt.go();
  31649. let ent = entId.getMcDbEntity();
  31650. if (!ent)
  31651. return;
  31652. ent.linetypeId = lintype;
  31653. });
  31654. }
  31655. function MxTest_DictionaryData(dict) {
  31656. let aryName = dict.getAllObjectName();
  31657. aryName.forEach((name) => {
  31658. console.log(name);
  31659. let id = dict.getAt(name);
  31660. let obj = id.getMcDbObject();
  31661. if (obj instanceof mxcad2.McDbDictionary) {
  31662. let dict2 = obj;
  31663. console.log(dict2);
  31664. MxTest_DictionaryData(dict2);
  31665. } else if (obj instanceof mxcad2.McDbXrecord) {
  31666. let xrec = obj;
  31667. let data = xrec.getData();
  31668. data.PrintData();
  31669. }
  31670. });
  31671. }
  31672. function MxTest_GetObjectExDictionaryData() {
  31673. return __async(this, null, function* () {
  31674. let selEntity = new mxcad2.MxCADUiPrEntity();
  31675. selEntity.setMessage("选择标注对象");
  31676. let id = yield selEntity.go();
  31677. if (!id.isValid())
  31678. return;
  31679. let ent = id.getMcDbEntity();
  31680. if (ent && ent.isHaveExtensionDictionary()) {
  31681. let dict = ent.getExtensionDictionary();
  31682. MxTest_DictionaryData(dict);
  31683. }
  31684. });
  31685. }
  31686. function MxTest_GetNamedObjectsDictionary() {
  31687. return __async(this, null, function* () {
  31688. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  31689. let dict = mxcad$1.getDatabase().getNamedObjectsDictionary();
  31690. let aryName = dict.getAllObjectName();
  31691. aryName.forEach((name) => {
  31692. console.log(name);
  31693. let id = dict.getAt(name);
  31694. let obj = id.getMcDbObject();
  31695. if (obj instanceof mxcad2.McDbDictionary) {
  31696. let dict2 = obj;
  31697. console.log(dict2);
  31698. MxTest_DictionaryData(dict2);
  31699. }
  31700. });
  31701. });
  31702. }
  31703. function MxTest_WriteXRecord() {
  31704. return __async(this, null, function* () {
  31705. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  31706. let dict = mxcad$1.getDatabase().getNamedObjectsDictionary();
  31707. let sName = "MyDict";
  31708. let idDict = dict.getAt(sName);
  31709. if (idDict.isNull()) {
  31710. let newDict = new mxcad2.McDbDictionary();
  31711. idDict = dict.addObject(sName, newDict);
  31712. }
  31713. let myDict = idDict.getMcDbDictionary();
  31714. if (myDict) {
  31715. let xrec = new mxcad2.McDbXrecord();
  31716. let data = new mxcad2.MxCADResbuf();
  31717. data.AddString("TestData");
  31718. xrec.setData(data);
  31719. myDict.addObject("MyRecord", xrec);
  31720. console.log("write xrecord ok");
  31721. }
  31722. });
  31723. }
  31724. function Mx_Test_ChangeColor() {
  31725. return __async(this, null, function* () {
  31726. let getEntity = new mxcad2.MxCADUiPrEntity();
  31727. getEntity.setMessage("选择标注对象");
  31728. let id = yield getEntity.go();
  31729. if (!id.isValid())
  31730. return;
  31731. let ent = id.getMcDbEntity();
  31732. if (!ent)
  31733. return;
  31734. ent.trueColor = new mxcad2.McCmColor(255, 0, 255);
  31735. });
  31736. }
  31737. let idVisible;
  31738. function Mx_Test_ChangeVisible() {
  31739. return __async(this, null, function* () {
  31740. if (!idVisible) {
  31741. let getEntity = new mxcad2.MxCADUiPrEntity();
  31742. getEntity.setMessage("选择标注对象");
  31743. let id = yield getEntity.go();
  31744. if (!id.isValid())
  31745. return;
  31746. let ent = id.getMcDbEntity();
  31747. if (!ent)
  31748. return;
  31749. ent.visible = false;
  31750. idVisible = id;
  31751. } else {
  31752. let ent = idVisible.getMcDbEntity();
  31753. if (!ent)
  31754. return;
  31755. ent.visible = true;
  31756. }
  31757. });
  31758. }
  31759. function Mx_Test_ChangeEntityLayer() {
  31760. return __async(this, null, function* () {
  31761. let newLayerName = "WALL";
  31762. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  31763. if (!mxcad$1.database.layerTable.has(newLayerName)) {
  31764. console.log("no have layer:" + newLayerName);
  31765. }
  31766. let getEntity = new mxcad2.MxCADUiPrEntity();
  31767. getEntity.setMessage("选择对象");
  31768. let id = yield getEntity.go();
  31769. if (!id.isValid())
  31770. return;
  31771. let ent = id.getMcDbEntity();
  31772. if (!ent)
  31773. return;
  31774. ent.layer = newLayerName;
  31775. });
  31776. }
  31777. function Mx_ChaneEntityDrawOrder() {
  31778. return __async(this, null, function* () {
  31779. let ss = new mxcad2.MxCADSelectionSet();
  31780. if (!(yield ss.userSelect("\n选择对象")))
  31781. return;
  31782. let minmaxOrder = mxcad2.MxCpp.getCurrentDatabase().currentSpace.getMinMaxDrawOrder();
  31783. let lOrder = minmaxOrder.maxDrawOrder + 1;
  31784. ss.forEach((id) => {
  31785. let ent = id.getMcDbEntity();
  31786. if (ent) {
  31787. ent.drawOrder = lOrder;
  31788. }
  31789. });
  31790. });
  31791. }
  31792. function init$k() {
  31793. mxdraw.MxFun.addCommand("TestGetAllEntity", TestGetAllEntity);
  31794. mxdraw.MxFun.addCommand("MxTest_GetSysVars", MxTest_GetSysVars);
  31795. mxdraw.MxFun.addCommand("MxTest_ReadxData", MxTest_ReadxData);
  31796. mxdraw.MxFun.addCommand("MxTest_WritexData", MxTest_WritexData);
  31797. mxdraw.MxFun.addCommand("MxTest_DrawLine", MxTest_DrawLine);
  31798. mxdraw.MxFun.addCommand("MxTest_InsertBlock", MxTest_InsertBlock);
  31799. mxdraw.MxFun.addCommand("MxTest_GetAllLayer", MxTest_GetAllLayer);
  31800. mxdraw.MxFun.addCommand("MxTest_AddLayer", MxTest_AddLayer);
  31801. mxdraw.MxFun.addCommand("MxTest_GetAllTextStyle", MxTest_GetAllTextStyle);
  31802. mxdraw.MxFun.addCommand("MxTest_GetAllBlock", MxTest_GetAllBlock);
  31803. mxdraw.MxFun.addCommand("MxTest_GetAllLinetype", MxTest_GetAllLinetype);
  31804. mxdraw.MxFun.addCommand("Mx_Test_DrawTable", Mx_Test_DrawTable);
  31805. mxdraw.MxFun.addCommand("Mx_Test_QRCode", Mx_Test_QRCode);
  31806. mxdraw.MxFun.addCommand("MxTest_InsertStamp", MxTest_InsertStamp);
  31807. mxdraw.MxFun.addCommand("MxTest_LineTypeTest", MxTest_LineTypeTest);
  31808. mxdraw.MxFun.addCommand("TestGentEntityOnLayer", TestGentEntityOnLayer);
  31809. mxdraw.MxFun.addCommand("MxTest_GetNamedObjectsDictionary", MxTest_GetNamedObjectsDictionary);
  31810. mxdraw.MxFun.addCommand("MxTest_GetObjectExDictionaryData", MxTest_GetObjectExDictionaryData);
  31811. mxdraw.MxFun.addCommand("MxTest_WriteXRecord", MxTest_WriteXRecord);
  31812. mxdraw.MxFun.addCommand("MxTest_AddTextStyleTable", MxTest_AddTextStyleTable);
  31813. mxdraw.MxFun.addCommand("Mx_Test_ChangeColor", Mx_Test_ChangeColor);
  31814. mxdraw.MxFun.addCommand("Mx_Test_ChangeVisible", Mx_Test_ChangeVisible);
  31815. mxdraw.MxFun.addCommand("Mx_Test_ChangeEntityLayer", Mx_Test_ChangeEntityLayer);
  31816. mxdraw.MxFun.addCommand("Mx_ChaneEntityDrawOrder", Mx_ChaneEntityDrawOrder);
  31817. }
  31818. function Mx_Export_DWG() {
  31819. return __async(this, null, function* () {
  31820. let {
  31821. baseUrl = "",
  31822. saveDwgUrl = "",
  31823. mxfilepath = ""
  31824. } = getMxCADUi().getUploadFileConfig();
  31825. mxcad2.MxCpp.getCurrentMxCAD().saveFileToUrl(saveDwgUrl, (iResult, sserverResult) => {
  31826. try {
  31827. let ret = JSON.parse(sserverResult);
  31828. if (ret.ret == "ok") {
  31829. let filePath = baseUrl + mxfilepath + ret.file;
  31830. fetch(filePath).then((res) => __async(this, null, function* () {
  31831. const blob = yield res.blob();
  31832. mxcad2.MxTools.saveAsFileDialog({
  31833. blob,
  31834. filename: ret.file,
  31835. types: [{
  31836. description: "dwg图纸",
  31837. accept: {
  31838. "application/octet-stream": [".dwg"]
  31839. }
  31840. }]
  31841. });
  31842. }));
  31843. } else {
  31844. console.log(sserverResult);
  31845. }
  31846. } catch (e) {
  31847. console.log("Mx: sserverResult error");
  31848. }
  31849. });
  31850. });
  31851. }
  31852. function Mx_Export_MxWeb() {
  31853. return __async(this, null, function* () {
  31854. let {
  31855. baseUrl = "",
  31856. mxfilepath = "",
  31857. saveUrl = ""
  31858. } = getMxCADUi().getUploadFileConfig();
  31859. mxcad2.MxCpp.getCurrentMxCAD().saveFileToUrl(saveUrl, (iResult, sserverResult) => {
  31860. try {
  31861. let ret = JSON.parse(sserverResult);
  31862. if (ret.ret == "ok") {
  31863. let filePath = baseUrl + mxfilepath + ret.file;
  31864. mxcad2.MxTools.downloadFileFromUrl(filePath, ret.file);
  31865. } else {
  31866. console.log(sserverResult);
  31867. }
  31868. } catch (e) {
  31869. console.log("Mx: sserverResult error");
  31870. }
  31871. });
  31872. });
  31873. }
  31874. function Mx_Open_MxWeb() {
  31875. return __async(this, null, function* () {
  31876. mxcad2.MxCpp.getCurrentMxCAD().openWebFile("http://localhost:1337/mxcad/file/8c79da20e232495888dbb0da17459399.mxweb");
  31877. });
  31878. }
  31879. function MxTest_NewFile() {
  31880. return __async(this, null, function* () {
  31881. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  31882. mxcad$1.newFile();
  31883. });
  31884. }
  31885. function Mx_Export_Pdf() {
  31886. return __async(this, null, function* () {
  31887. let getPoint = new mxcad2.MxCADUiPrPoint();
  31888. getPoint.setMessage("\n指定输出范围第一点:");
  31889. let pt1 = yield getPoint.go();
  31890. if (!pt1)
  31891. return;
  31892. getPoint.setMessage("\n指定输出范围第二点:");
  31893. getPoint.setUserDraw((currentPoint, worldDraw) => {
  31894. worldDraw.setColor(16711680);
  31895. let pl = new mxcad2.McDbPolyline();
  31896. pl.addVertexAt(pt1);
  31897. pl.addVertexAt(new mxcad2.McGePoint3d(pt1.x, currentPoint.y));
  31898. pl.addVertexAt(currentPoint);
  31899. pl.addVertexAt(new mxcad2.McGePoint3d(currentPoint.x, pt1.y));
  31900. pl.constantWidth = mxdraw.MxFun.screenCoordLong2Doc(2);
  31901. pl.isClosed = true;
  31902. worldDraw.drawMcDbEntity(pl);
  31903. let points = [];
  31904. points.push(pt1.toVector3());
  31905. points.push(new THREE.Vector3(pt1.x, currentPoint.y));
  31906. points.push(currentPoint.toVector3());
  31907. points.push(new THREE.Vector3(currentPoint.x, pt1.y));
  31908. worldDraw.setColor(12868);
  31909. worldDraw.drawSolid(points, 0.5);
  31910. });
  31911. getPoint.setDisableOsnap(true);
  31912. getPoint.setDisableOrthoTrace(true);
  31913. getPoint.setDynamicInputType(mxdraw.DynamicInputType.kXYCoordInput);
  31914. let pt2 = yield getPoint.go();
  31915. if (!pt2) {
  31916. return;
  31917. }
  31918. let {
  31919. baseUrl = "",
  31920. mxfilepath = "",
  31921. printPdfUrl = ""
  31922. } = getMxCADUi().getUploadFileConfig();
  31923. console.log(getMxCADUi().getUploadFileConfig());
  31924. let param = {
  31925. width: "2100",
  31926. height: "2970",
  31927. bd_pt1_x: "" + pt1.x,
  31928. bd_pt1_y: "" + pt1.y,
  31929. bd_pt2_x: "" + pt2.x,
  31930. bd_pt2_y: "" + pt2.y
  31931. };
  31932. mxcad2.MxCpp.getCurrentMxCAD().saveFileToUrl(printPdfUrl, (iResult, sserverResult) => {
  31933. try {
  31934. let ret = JSON.parse(sserverResult);
  31935. if (ret.ret == "ok") {
  31936. let filePath = baseUrl + mxfilepath + ret.file;
  31937. mxcad2.MxTools.downloadFileFromUrl(filePath, ret.file);
  31938. } else {
  31939. console.log(sserverResult);
  31940. }
  31941. } catch (e) {
  31942. console.log("Mx: sserverResult error");
  31943. }
  31944. }, void 0, JSON.stringify(param));
  31945. });
  31946. }
  31947. function init$j() {
  31948. mxdraw.MxFun.addCommand("Mx_Export_DWG", Mx_Export_DWG);
  31949. mxdraw.MxFun.addCommand("Mx_Export_MxWeb", Mx_Export_MxWeb);
  31950. mxdraw.MxFun.addCommand("Mx_Open_MxWeb", Mx_Open_MxWeb);
  31951. mxdraw.MxFun.addCommand("MxTest_NewFile", MxTest_NewFile);
  31952. mxdraw.MxFun.addCommand("Mx_Export_Pdf", Mx_Export_Pdf);
  31953. }
  31954. function MxTest_FindText() {
  31955. return __async(this, null, function* () {
  31956. let sFindText1 = "0601";
  31957. let sFindText2 = "001A";
  31958. let ss = new mxcad2.MxCADSelectionSet();
  31959. let filter = new mxcad2.MxCADResbuf();
  31960. filter.AddMcDbEntityTypes("TEXT,MTEXT,INSERT,ACAD_PROXY_ENTITY");
  31961. ss.allSelect(filter);
  31962. let findPos;
  31963. let entBox;
  31964. let iCount = ss.count();
  31965. for (let i2 = 0; i2 < iCount; i2++) {
  31966. let id = ss.item(i2);
  31967. let ent = id.getMcDbEntity();
  31968. if (!ent)
  31969. return;
  31970. if (ent instanceof mxcad2.McDbText) {
  31971. let txt = ent;
  31972. if (txt.textString == sFindText1) {
  31973. findPos = txt.position;
  31974. entBox = txt.getBoundingBox();
  31975. break;
  31976. }
  31977. } else if (ent instanceof mxcad2.McDbMText) {
  31978. let mtxt = ent;
  31979. if (mtxt.contents == sFindText1) {
  31980. findPos = mtxt.location;
  31981. entBox = mtxt.getBoundingBox();
  31982. break;
  31983. }
  31984. } else if (ent instanceof mxcad2.McDbBlockReference) {
  31985. let blkRef = ent;
  31986. let aryId = blkRef.getAllAttribute();
  31987. let iFind = 0;
  31988. aryId.forEach((id2) => {
  31989. let attribt = id2.getMcDbEntity();
  31990. if (attribt.textString == sFindText1) {
  31991. iFind++;
  31992. } else if (attribt.textString == sFindText2) {
  31993. iFind++;
  31994. }
  31995. });
  31996. if (iFind == 2) {
  31997. findPos = blkRef.position;
  31998. entBox = blkRef.getBoundingBox();
  31999. break;
  32000. }
  32001. } else if (ent instanceof mxcad2.McDbProxyEntity) {
  32002. let proxyEntity = ent;
  32003. let aryText = proxyEntity.getAllTextContent();
  32004. let iFind = 0;
  32005. aryText.forEach((val) => {
  32006. if (val == sFindText1) {
  32007. iFind++;
  32008. }
  32009. });
  32010. if (iFind >= 1) {
  32011. entBox = proxyEntity.getBoundingBox();
  32012. if (entBox && entBox.ret) {
  32013. findPos = new mxcad2.McGePoint3d(entBox.minPt.x + (entBox.maxPt.x - entBox.minPt.x) * 0.5, entBox.minPt.y + (entBox.maxPt.y - entBox.minPt.y) * 0.5);
  32014. }
  32015. break;
  32016. }
  32017. }
  32018. }
  32019. if (entBox && entBox.ret) {
  32020. console.log(entBox);
  32021. let len = entBox.minPt.distanceTo(entBox.maxPt) * 2;
  32022. mxdraw.MxFun.getCurrentDraw().zoomW(
  32023. new THREE.Vector3(entBox.minPt.x - len, entBox.minPt.y - len, 0),
  32024. new THREE.Vector3(entBox.maxPt.x + len, entBox.maxPt.y + len, 0)
  32025. );
  32026. } else if (findPos) {
  32027. mxdraw.MxFun.getCurrentDraw().zoomCenter(findPos.x, findPos.y);
  32028. } else {
  32029. console.log("没有找到文字:" + sFindText1);
  32030. }
  32031. });
  32032. }
  32033. function init$i() {
  32034. mxdraw.MxFun.addCommand("MxTest_FindText", MxTest_FindText);
  32035. }
  32036. class McDbTestLineCustomEntity extends mxcad2.McDbCustomEntity {
  32037. constructor(imp) {
  32038. super(imp);
  32039. this.pt1 = new mxcad2.McGePoint3d();
  32040. this.pt2 = new mxcad2.McGePoint3d();
  32041. }
  32042. create(imp) {
  32043. return new McDbTestLineCustomEntity(imp);
  32044. }
  32045. getTypeName() {
  32046. return "McDbTestLineCustomEntity";
  32047. }
  32048. dwgInFields(filter) {
  32049. this.pt1 = filter.readPoint("pt1").val;
  32050. this.pt2 = filter.readPoint("pt2").val;
  32051. return true;
  32052. }
  32053. dwgOutFields(filter) {
  32054. filter.writePoint("pt1", this.pt1);
  32055. filter.writePoint("pt2", this.pt2);
  32056. return true;
  32057. }
  32058. moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset) {
  32059. this.assertWrite();
  32060. if (iIndex == 0) {
  32061. this.pt1.x += dXOffset;
  32062. this.pt1.y += dYOffset;
  32063. this.pt1.z += dZOffset;
  32064. } else if (iIndex == 1) {
  32065. this.pt2.x += dXOffset;
  32066. this.pt2.y += dYOffset;
  32067. this.pt2.z += dZOffset;
  32068. }
  32069. }
  32070. getGripPoints() {
  32071. let ret = new mxcad2.McGePoint3dArray();
  32072. ret.append(this.pt1);
  32073. ret.append(this.pt2);
  32074. return ret;
  32075. }
  32076. worldDraw(draw) {
  32077. let tmpline = new mxcad2.McDbLine(this.pt1, this.pt2);
  32078. draw.drawEntity(tmpline);
  32079. }
  32080. //
  32081. setPoint1(pt1) {
  32082. this.assertWrite();
  32083. this.pt1 = pt1.clone();
  32084. }
  32085. setPoint2(pt2) {
  32086. this.assertWrite();
  32087. this.pt2 = pt2.clone();
  32088. }
  32089. getPoint1() {
  32090. return this.pt1;
  32091. }
  32092. getPoint2() {
  32093. return this.pt2;
  32094. }
  32095. }
  32096. function MxTest_DrawCustomEntity() {
  32097. return __async(this, null, function* () {
  32098. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  32099. const getPoint = new mxcad2.MxCADUiPrPoint();
  32100. getPoint.setMessage("\n指定一点:");
  32101. let pt1 = yield getPoint.go();
  32102. if (!pt1)
  32103. return;
  32104. getPoint.setBasePt(pt1);
  32105. getPoint.setUseBasePt(true);
  32106. getPoint.setMessage("\n指定二点:");
  32107. let pt2 = yield getPoint.go();
  32108. if (!pt2)
  32109. return;
  32110. let myline = new McDbTestLineCustomEntity();
  32111. myline.setPoint1(pt1);
  32112. myline.setPoint2(pt2);
  32113. mxcad$1.drawEntity(myline);
  32114. });
  32115. }
  32116. function init$h() {
  32117. new McDbTestLineCustomEntity().rxInit();
  32118. mxdraw.MxFun.addCommand("MxTest_DrawCustomEntity", MxTest_DrawCustomEntity);
  32119. }
  32120. function MxTest_SelectEntitysToBlock() {
  32121. return __async(this, null, function* () {
  32122. let ss = new mxcad2.MxCADSelectionSet();
  32123. if (!(yield ss.userSelect("选择要做成块的对象:")))
  32124. return;
  32125. if (ss.count() == 0)
  32126. return;
  32127. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  32128. let blkTable = mxcad$1.getDatabase().getBlockTable();
  32129. let blkRecId = blkTable.add(new mxcad2.McDbBlockTableRecord());
  32130. let blkTableRecord = blkRecId.getMcDbBlockTableRecord();
  32131. if (blkTableRecord == null)
  32132. return;
  32133. let pt1x, pt1y, pt2x, pt2y;
  32134. ss.forEach((id) => {
  32135. let ent = id.getMcDbEntity();
  32136. if (!ent)
  32137. return;
  32138. let cent = ent.clone();
  32139. blkTableRecord.appendAcDbEntity(cent);
  32140. let entBox = ent.getBoundingBox();
  32141. if (entBox.ret) {
  32142. if (!pt1x) {
  32143. pt1x = entBox.minPt.x;
  32144. pt1y = entBox.minPt.y;
  32145. pt2x = entBox.maxPt.x;
  32146. pt2y = entBox.maxPt.y;
  32147. } else {
  32148. if (pt1x > entBox.minPt.x)
  32149. pt1x = entBox.minPt.x;
  32150. if (pt1y > entBox.minPt.y)
  32151. pt1y = entBox.minPt.y;
  32152. if (pt2x < entBox.maxPt.x)
  32153. pt2x = entBox.maxPt.x;
  32154. if (pt2y < entBox.maxPt.y)
  32155. pt2y = entBox.maxPt.y;
  32156. }
  32157. }
  32158. });
  32159. if (pt1x === void 0) {
  32160. return;
  32161. }
  32162. let insertPtx = pt1x + (pt2x - pt1x) * 0.5;
  32163. let insertPty = pt1y + (pt2y - pt1y) * 0.5;
  32164. blkTableRecord.origin = new mxcad2.McGePoint3d(insertPtx, insertPty, 0);
  32165. let blkRef = new mxcad2.McDbBlockReference();
  32166. blkRef.blockTableRecordId = blkRecId;
  32167. blkRef.position = new mxcad2.McGePoint3d(insertPtx, insertPty, 0);
  32168. mxcad$1.drawEntity(blkRef);
  32169. ss.forEach((id) => {
  32170. let ent = id.getMcDbEntity();
  32171. if (!ent)
  32172. return;
  32173. ent.erase();
  32174. });
  32175. });
  32176. }
  32177. function init$g() {
  32178. mxdraw.MxFun.addCommand("MxTest_SelectEntitysToBlock", MxTest_SelectEntitysToBlock);
  32179. }
  32180. function MxTest_DrawHatchFormPoint() {
  32181. return __async(this, null, function* () {
  32182. const getPoint = new mxcad2.MxCADUiPrPoint();
  32183. getPoint.setMessage("\n指定填充区域内部一点:");
  32184. getPoint.disableAllTrace(true);
  32185. getPoint.setDisableOsnap(true);
  32186. let pt = yield getPoint.go();
  32187. if (!pt)
  32188. return;
  32189. let hatch = mxcad2.MxCADUtility.builderHatchFromPoint(pt);
  32190. if (!hatch) {
  32191. mxdraw.MxFun.acutPrintf("没有找到闭合区域\n");
  32192. return;
  32193. }
  32194. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  32195. mxcad$1.drawEntity(hatch);
  32196. });
  32197. }
  32198. function init$f() {
  32199. mxdraw.MxFun.addCommand("MxTest_DrawHatchFormPoint", MxTest_DrawHatchFormPoint);
  32200. }
  32201. const namedColors = {
  32202. aliceblue: [240, 248, 255],
  32203. antiquewhite: [250, 235, 215],
  32204. aqua: [0, 255, 255],
  32205. aquamarine: [127, 255, 212],
  32206. azure: [240, 255, 255],
  32207. beige: [245, 245, 220],
  32208. bisque: [255, 228, 196],
  32209. black: [0, 0, 0],
  32210. blanchedalmond: [255, 235, 205],
  32211. blue: [0, 0, 255],
  32212. blueviolet: [138, 43, 226],
  32213. brown: [165, 42, 42],
  32214. burlywood: [222, 184, 135],
  32215. cadetblue: [95, 158, 160],
  32216. chartreuse: [127, 255, 0],
  32217. chocolate: [210, 105, 30],
  32218. coral: [255, 127, 80],
  32219. cornflowerblue: [100, 149, 237],
  32220. cornsilk: [255, 248, 220],
  32221. crimson: [220, 20, 60],
  32222. cyan: [0, 255, 255],
  32223. darkblue: [0, 0, 139],
  32224. darkcyan: [0, 139, 139],
  32225. darkgoldenrod: [184, 134, 11],
  32226. darkgray: [169, 169, 169],
  32227. darkgreen: [0, 100, 0],
  32228. darkkhaki: [189, 183, 107],
  32229. darkmagenta: [139, 0, 139],
  32230. darkolivegreen: [85, 107, 47],
  32231. darkorange: [255, 140, 0],
  32232. darkorchid: [153, 50, 204],
  32233. darkred: [139, 0, 0],
  32234. darksalmon: [233, 150, 122],
  32235. darkseagreen: [143, 188, 143],
  32236. darkslateblue: [72, 61, 139],
  32237. darkslategray: [47, 79, 79],
  32238. darkturquoise: [0, 206, 209],
  32239. darkviolet: [148, 0, 211],
  32240. deeppink: [255, 20, 147],
  32241. deepskyblue: [0, 191, 255],
  32242. dimgray: [105, 105, 105],
  32243. dodgerblue: [30, 144, 255],
  32244. firebrick: [178, 34, 34],
  32245. floralwhite: [255, 250, 240],
  32246. forestgreen: [34, 139, 34],
  32247. fuchsia: [255, 0, 255],
  32248. gainsboro: [220, 220, 220],
  32249. ghostwhite: [248, 248, 255],
  32250. gold: [255, 215, 0],
  32251. goldenrod: [218, 165, 32],
  32252. gray: [128, 128, 128],
  32253. green: [0, 128, 0],
  32254. greenyellow: [173, 255, 47],
  32255. honeydew: [240, 255, 240],
  32256. hotpink: [255, 105, 180],
  32257. indianred: [205, 92, 92],
  32258. indigo: [75, 0, 130],
  32259. ivory: [255, 255, 240],
  32260. khaki: [240, 230, 140],
  32261. lavender: [230, 230, 250],
  32262. lavenderblush: [255, 240, 245],
  32263. lawngreen: [124, 252, 0],
  32264. lemonchiffon: [255, 250, 205],
  32265. lightblue: [173, 216, 230],
  32266. lightcoral: [240, 128, 128],
  32267. lightcyan: [224, 255, 255],
  32268. lightgoldenrodyellow: [250, 250, 210],
  32269. lightgray: [211, 211, 211],
  32270. lightgreen: [144, 238, 144],
  32271. lightpink: [255, 182, 193],
  32272. lightsalmon: [255, 160, 122],
  32273. lightseagreen: [32, 178, 170],
  32274. lightskyblue: [135, 206, 250],
  32275. lightslategray: [119, 136, 153],
  32276. lightsteelblue: [176, 196, 222],
  32277. lightyellow: [255, 255, 224],
  32278. lime: [0, 255, 0],
  32279. limegreen: [50, 205, 50],
  32280. linen: [250, 240, 230],
  32281. magenta: [255, 0, 255],
  32282. maroon: [128, 0, 0],
  32283. mediumaquamarine: [102, 205, 170],
  32284. mediumblue: [0, 0, 205],
  32285. mediumorchid: [186, 85, 211],
  32286. mediumpurple: [147, 112, 219],
  32287. mediumseagreen: [60, 179, 113],
  32288. mediumslateblue: [123, 104, 238],
  32289. mediumspringgreen: [0, 250, 154],
  32290. mediumturquoise: [72, 209, 204],
  32291. mediumvioletred: [199, 21, 133],
  32292. midnightblue: [25, 25, 112],
  32293. mintcream: [245, 255, 250],
  32294. mistyrose: [255, 228, 225],
  32295. moccasin: [255, 228, 181],
  32296. navajowhite: [255, 222, 173],
  32297. navy: [0, 0, 128],
  32298. oldlace: [253, 245, 230],
  32299. olive: [128, 128, 0],
  32300. olivedrab: [107, 142, 35],
  32301. orange: [255, 165, 0],
  32302. orangered: [255, 69, 0],
  32303. orchid: [218, 112, 214],
  32304. palegoldenrod: [238, 232, 170],
  32305. palegreen: [152, 251, 152],
  32306. paleturquoise: [175, 238, 238],
  32307. palevioletred: [219, 112, 147],
  32308. papayawhip: [255, 239, 213],
  32309. peachpuff: [255, 218, 185],
  32310. peru: [205, 133, 63],
  32311. pink: [255, 192, 203],
  32312. plum: [221, 160, 221],
  32313. powderblue: [176, 224, 230],
  32314. purple: [128, 0, 128],
  32315. rebeccapurple: [102, 51, 153],
  32316. red: [255, 0, 0],
  32317. rosybrown: [188, 143, 143],
  32318. royalblue: [65, 105, 225],
  32319. saddlebrown: [139, 69, 19],
  32320. salmon: [250, 128, 114],
  32321. sandybrown: [244, 164, 96],
  32322. seagreen: [46, 139, 87],
  32323. seashell: [255, 245, 238],
  32324. sienna: [160, 82, 45],
  32325. silver: [192, 192, 192],
  32326. skyblue: [135, 206, 235],
  32327. slateblue: [106, 90, 205],
  32328. slategray: [112, 128, 144],
  32329. snow: [255, 250, 250],
  32330. springgreen: [0, 255, 127],
  32331. steelblue: [70, 130, 180],
  32332. tan: [210, 180, 140],
  32333. teal: [0, 128, 128],
  32334. thistle: [216, 191, 216],
  32335. tomato: [255, 99, 71],
  32336. turquoise: [64, 224, 208],
  32337. violet: [238, 130, 238],
  32338. wheat: [245, 222, 179],
  32339. white: [255, 255, 255],
  32340. whitesmoke: [245, 245, 245],
  32341. yellow: [255, 255, 0],
  32342. yellowgreen: [154, 205, 50]
  32343. };
  32344. function parseColor(color) {
  32345. if (/^\d+,\s*\d+,\s*\d+$/.test(color)) {
  32346. return color.split(",").map(Number);
  32347. } else if (/^0x[0-9a-fA-F]{6}$/.test(color)) {
  32348. const hexValue = parseInt(color, 16);
  32349. return [
  32350. hexValue >> 16 & 255,
  32351. hexValue >> 8 & 255,
  32352. hexValue & 255
  32353. ];
  32354. } else if (/^#[0-9a-fA-F]{6}$/.test(color)) {
  32355. const hexValue = parseInt(color.slice(1), 16);
  32356. return [
  32357. hexValue >> 16 & 255,
  32358. hexValue >> 8 & 255,
  32359. hexValue & 255
  32360. ];
  32361. } else if (namedColors[color.toLowerCase()]) {
  32362. const lowerCaseColor = color.toLowerCase();
  32363. if (namedColors[lowerCaseColor]) {
  32364. return namedColors[lowerCaseColor];
  32365. }
  32366. } else {
  32367. const color2 = new mxcad2.McCmColor();
  32368. color2.setColorIndex(256);
  32369. return [color2.red, color2.green, color2.blue];
  32370. }
  32371. }
  32372. const addLayer = (layerName) => {
  32373. const layerTable = mxcad2.MxCpp.getCurrentDatabase().layerTable;
  32374. if (layerTable.has(layerName)) {
  32375. return;
  32376. }
  32377. const layer = new mxcad2.McDbLayerTableRecord();
  32378. layer.color = new mxcad2.McCmColor(0, 0, 0);
  32379. layer.isFrozen = false;
  32380. layer.isLocked = false;
  32381. layer.isOff = false;
  32382. layer.lineWeight = mxcad2.McDb.LineWeight.kLnWtByLayer;
  32383. layer.name = layerName;
  32384. layerTable.add(layer);
  32385. };
  32386. const baseParams = [
  32387. {
  32388. name: "color",
  32389. description: "颜色",
  32390. "type": "str",
  32391. "required": true
  32392. },
  32393. {
  32394. name: "layer",
  32395. description: "图层",
  32396. "type": "str",
  32397. "required": true
  32398. },
  32399. {
  32400. name: "lineweight",
  32401. description: "线重",
  32402. "type": "float",
  32403. "required": true
  32404. }
  32405. ];
  32406. const mergeBaseMcDbEntityProps = (entity, param) => {
  32407. if (param.layer) {
  32408. addLayer(param.layer);
  32409. }
  32410. const setMcDbEntityProps = (ent) => {
  32411. if (param.color) {
  32412. ent.trueColor = new mxcad2.McCmColor(...parseColor(param.color));
  32413. } else {
  32414. ent.trueColor = new mxcad2.McCmColor(mxcad2.MxCpp.getCurrentDatabase().getCurrentlyDrawColor());
  32415. }
  32416. if (param.layer) {
  32417. ent.layer = param.layer;
  32418. } else {
  32419. ent.layer = mxcad2.MxCpp.getCurrentDatabase().getCurrentlyLayerName();
  32420. }
  32421. if (param.lineweight) {
  32422. ent.lineweight = param.lineweight;
  32423. }
  32424. };
  32425. if (Array.isArray(entity)) {
  32426. entity.forEach(setMcDbEntityProps);
  32427. } else if (entity) {
  32428. setMcDbEntityProps(entity);
  32429. }
  32430. };
  32431. const parseParamPoints = (pointsStr) => {
  32432. const pointsArr = pointsStr.split(",").map((i22) => Number(i22));
  32433. const points = [];
  32434. let i2 = 0;
  32435. while (i2 < pointsArr.length) {
  32436. const x = pointsArr[i2];
  32437. i2++;
  32438. const y = pointsArr[i2];
  32439. i2++;
  32440. if (typeof x === "undefined" || typeof y === "undefined")
  32441. return points;
  32442. const point = new mxcad2.McGePoint3d(x, y);
  32443. points.push(point);
  32444. }
  32445. return points;
  32446. };
  32447. const parsePoint = (point) => {
  32448. if (typeof point === "object" && "x" in point && "y" in point) {
  32449. return new mxcad2.McGePoint3d(point.x, point.y);
  32450. }
  32451. if (Array.isArray(point)) {
  32452. return new mxcad2.McGePoint3d(point[0], point[1]);
  32453. } else if (typeof point === "string") {
  32454. const [x, y] = point.split(",").map((i2) => Number(i2));
  32455. if (typeof x === "number" && typeof y === "number") {
  32456. return new mxcad2.McGePoint3d(x, y);
  32457. }
  32458. }
  32459. };
  32460. class MxAiDrawLine {
  32461. call(param) {
  32462. console.log(param);
  32463. if (param && param.pt1 && param.pt2) {
  32464. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  32465. if (param.pt1)
  32466. param.pt1 = parsePoint(param.pt1);
  32467. if (param.pt2)
  32468. param.pt2 = parsePoint(param.pt2);
  32469. const objId = mxcad$1.drawLine(param.pt1.x, param.pt1.y, param.pt2.x, param.pt2.y);
  32470. mergeBaseMcDbEntityProps(objId.getMcDbEntity(), param);
  32471. mxcad$1.updateDisplay();
  32472. }
  32473. }
  32474. regist_data() {
  32475. return {
  32476. filename: "drawline.json",
  32477. name: "draw_line",
  32478. description: "根据直线的开始点和结束点绘制一个直线段",
  32479. params: [
  32480. {
  32481. name: "pt1",
  32482. description: "直线开始点",
  32483. "type": "tuple[float, float]",
  32484. "required": true
  32485. },
  32486. {
  32487. name: "pt2",
  32488. description: "直线结束点",
  32489. "type": "tuple[float, float]",
  32490. "required": true
  32491. },
  32492. ...baseParams
  32493. ]
  32494. };
  32495. }
  32496. }
  32497. function init$e() {
  32498. MxAiModule.regist(MxAiDrawLine);
  32499. }
  32500. class MxAiDrawCircle {
  32501. call(param) {
  32502. console.log(param);
  32503. if (param && param.cen && param.radius) {
  32504. if (param.cen)
  32505. param.center = parsePoint(param.cen);
  32506. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  32507. const objId = mxcad$1.drawCircle(param.center.x, param.center.y, param.radius);
  32508. mergeBaseMcDbEntityProps(objId.getMcDbEntity(), param);
  32509. mxcad$1.updateDisplay();
  32510. }
  32511. }
  32512. regist_data() {
  32513. return {
  32514. filename: "drawcircle.json",
  32515. name: "draw_circle",
  32516. description: "根据圆心和半径绘制一个圆",
  32517. params: [
  32518. {
  32519. name: "center",
  32520. description: "圆的中心点",
  32521. "type": "tuple[float, float]",
  32522. "required": true
  32523. },
  32524. {
  32525. name: "radius",
  32526. description: "圆的半径",
  32527. "type": "float",
  32528. "required": true
  32529. },
  32530. ...baseParams
  32531. ]
  32532. };
  32533. }
  32534. }
  32535. const init$d = () => {
  32536. MxAiModule.regist(MxAiDrawCircle);
  32537. };
  32538. function findIntersection(p1, p2, p3, p4, isExtending) {
  32539. const x1 = p1.x, y1 = p1.y;
  32540. const x2 = p2.x, y2 = p2.y;
  32541. const x3 = p3.x, y3 = p3.y;
  32542. const x4 = p4.x, y4 = p4.y;
  32543. const denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
  32544. if (denominator === 0) {
  32545. return null;
  32546. }
  32547. const t = ((x1 - x3) * (y3 - y4) - (y1 - y3) * (x3 - x4)) / denominator;
  32548. const u = -((x1 - x2) * (y1 - y3) - (y1 - y2) * (x1 - x3)) / denominator;
  32549. const intersectionX = x1 + t * (x2 - x1);
  32550. const intersectionY = y1 + t * (y2 - y1);
  32551. const point = new mxcad2.McGePoint3d(intersectionX, intersectionY, 0);
  32552. if (isExtending)
  32553. return point;
  32554. if (t > 0 && t < 1 && u > 0 && u < 1) {
  32555. return point;
  32556. } else {
  32557. return null;
  32558. }
  32559. }
  32560. function insidePolygon(points, point) {
  32561. const x = point.x, y = point.y;
  32562. let inside = false;
  32563. for (let i2 = 0, j = points.length - 1; i2 < points.length; j = i2++) {
  32564. const xi = points[i2].x, yi = points[i2].y;
  32565. const xj = points[j].x, yj = points[j].y;
  32566. const intersect = yi > y != yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
  32567. if (intersect)
  32568. inside = !inside;
  32569. }
  32570. return inside;
  32571. }
  32572. function angleTo(x1, y1, x2, y2) {
  32573. const x = x1 - x2;
  32574. const y = y1 - y2;
  32575. let angle_temp = 0;
  32576. if (x == 0) {
  32577. angle_temp = Math.PI / 2;
  32578. } else {
  32579. angle_temp = Math.atan(Math.abs(y / x));
  32580. }
  32581. if (x < 0 && y >= 0) {
  32582. angle_temp = Math.PI - angle_temp;
  32583. } else if (x < 0 && y < 0) {
  32584. angle_temp = Math.PI + angle_temp;
  32585. } else if (x >= 0 && y < 0) {
  32586. angle_temp = Math.PI * 2 - angle_temp;
  32587. }
  32588. return angle_temp;
  32589. }
  32590. function createArc(center, radius, startAngle, endAngle) {
  32591. const arc = new mxcad2.McDbArc();
  32592. arc.center = center;
  32593. arc.radius = radius;
  32594. arc.startAngle = startAngle;
  32595. arc.endAngle = endAngle;
  32596. return arc;
  32597. }
  32598. class MxAiDrawCircleArc {
  32599. call(param) {
  32600. return __async(this, null, function* () {
  32601. console.log(param);
  32602. let { center, radius, startAngle, endAngle, is3PDraw, point1, point2, point3 } = param;
  32603. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  32604. mxcad$1.newFile();
  32605. mxcad$1.zoomAll();
  32606. const getPoint = new mxcad2.MxCADUiPrPoint();
  32607. const getDist = new mxcad2.MxCADUiPrDist();
  32608. if (is3PDraw) {
  32609. if (point1)
  32610. point1 = parsePoint(point1);
  32611. if (point2)
  32612. point2 = parsePoint(point2);
  32613. if (point3)
  32614. point3 = parsePoint(point3);
  32615. getPoint.setKeyWords("");
  32616. if (!point1) {
  32617. getPoint.setMessage("指定圆弧起点");
  32618. getPoint.setUserDraw((pt, pw) => {
  32619. if (!point2 || !point3)
  32620. return;
  32621. const arc2 = new mxcad2.McDbArc();
  32622. arc2.computeArc(pt.x, pt.y, point2.x, point2.y, point3.x, point3.y);
  32623. pw.drawMcDbEntity(arc2);
  32624. });
  32625. point1 = yield getPoint.go();
  32626. if (!point1)
  32627. return;
  32628. }
  32629. if (!point2) {
  32630. getPoint.setMessage("指定圆弧第二个点");
  32631. getPoint.setUserDraw((pt, pw) => {
  32632. if (!point1 || !point3)
  32633. return;
  32634. const arc2 = new mxcad2.McDbArc();
  32635. arc2.computeArc(point1.x, point1.y, pt.x, pt.y, point3.x, point3.y);
  32636. pw.drawMcDbEntity(arc2);
  32637. });
  32638. point2 = yield getPoint.go();
  32639. if (!point2)
  32640. return;
  32641. }
  32642. if (!point3) {
  32643. getPoint.setMessage("指定圆弧的端点");
  32644. getPoint.setUserDraw((pt, pw) => {
  32645. if (!point1 || !point2)
  32646. return;
  32647. const arc2 = new mxcad2.McDbArc();
  32648. arc2.computeArc(point1.x, point1.y, point2.x, point2.y, pt.x, pt.y);
  32649. pw.drawMcDbEntity(arc2);
  32650. });
  32651. point3 = yield getPoint.go();
  32652. if (!point3)
  32653. return;
  32654. }
  32655. const arc = new mxcad2.McDbArc();
  32656. console.log(point1.x, point1.y, point2.x, point2.y, point3.x, point3.y);
  32657. arc.computeArc(point1.x, point1.y, point2.x, point2.y, point3.x, point3.y);
  32658. mergeBaseMcDbEntityProps(arc, param);
  32659. mxcad$1.drawEntity(arc);
  32660. mxcad$1.updateDisplay();
  32661. } else {
  32662. if (center)
  32663. center = parsePoint(center);
  32664. if (startAngle)
  32665. startAngle = startAngle * (Math.PI / 180);
  32666. if (endAngle)
  32667. endAngle = endAngle * (Math.PI / 180);
  32668. if (!center) {
  32669. getPoint.setMessage("指定圆弧圆心");
  32670. getPoint.setKeyWords("");
  32671. getPoint.setUserDraw((pt, pw) => {
  32672. if (!radius)
  32673. return;
  32674. pw.drawMcDbEntity(createArc(pt, radius, startAngle || 0, endAngle || Math.PI * 2));
  32675. });
  32676. const point = yield getPoint.go();
  32677. if (!point)
  32678. return;
  32679. center = point;
  32680. }
  32681. if (!radius) {
  32682. getDist.setBasePt(center);
  32683. getDist.setMessage(mxcad2._ML_String("MxAiDrawCircleArc_Radius", "指定圆弧半径"));
  32684. getDist.setKeyWords("");
  32685. getDist.setUserDraw((pt, pw) => {
  32686. if (!center)
  32687. return;
  32688. const radius2 = pt.distanceTo(center);
  32689. pw.drawMcDbEntity(createArc(center, radius2, startAngle || 0, endAngle || Math.PI * 2));
  32690. });
  32691. radius = yield getDist.go();
  32692. if (!radius)
  32693. return;
  32694. }
  32695. if (!startAngle) {
  32696. if (!center)
  32697. return;
  32698. getDist.setBasePt(center);
  32699. getDist.setMessage(mxcad2._ML_String("MxAiDrawCircleArc_StartAngle", "指定圆弧开始角"));
  32700. getDist.setKeyWords("");
  32701. getDist.setUserDraw((pt, pw) => {
  32702. if (!center)
  32703. return;
  32704. if (!radius)
  32705. return;
  32706. startAngle = angleTo(center.x, center.y, pt.x, pt.y) - Math.PI;
  32707. pw.drawMcDbEntity(createArc(center, radius, startAngle || 0, endAngle || Math.PI * 2));
  32708. });
  32709. const val = yield getDist.go();
  32710. if (!val)
  32711. return;
  32712. if (getDist.getDetailedResult() === mxdraw.DetailedResult.kCoordIn) {
  32713. startAngle = val * (Math.PI / 180);
  32714. }
  32715. }
  32716. if (!endAngle) {
  32717. if (!center)
  32718. return;
  32719. getDist.setBasePt(center);
  32720. getDist.setMessage(mxcad2._ML_String("MxAiDrawCircleArc_EndAngle", "指定圆弧结束角"));
  32721. getDist.setKeyWords("");
  32722. getDist.setUserDraw((pt, pw) => {
  32723. if (!center)
  32724. return;
  32725. if (!radius)
  32726. return;
  32727. endAngle = angleTo(center.x, center.y, pt.x, pt.y) - Math.PI;
  32728. pw.drawMcDbEntity(createArc(center, radius, startAngle || 0, endAngle || Math.PI * 2));
  32729. });
  32730. const val = yield getDist.go();
  32731. if (!val)
  32732. return;
  32733. if (getDist.getDetailedResult() === mxdraw.DetailedResult.kCoordIn) {
  32734. endAngle = val * (Math.PI / 180);
  32735. }
  32736. }
  32737. const arc = createArc(center, radius, startAngle, endAngle);
  32738. mergeBaseMcDbEntityProps(arc, param);
  32739. mxcad$1.drawEntity(arc);
  32740. mxcad$1.updateDisplay();
  32741. }
  32742. });
  32743. }
  32744. regist_data() {
  32745. return {
  32746. filename: "drawcirclearc.json",
  32747. name: "draw_circle_arc",
  32748. description: "绘制圆弧",
  32749. params: [
  32750. {
  32751. name: "center",
  32752. description: "圆弧圆心",
  32753. "type": "tuple[float, float]",
  32754. "required": true
  32755. },
  32756. {
  32757. name: "radius",
  32758. description: "圆弧半径",
  32759. "type": "float",
  32760. "required": true
  32761. },
  32762. {
  32763. name: "startAngle",
  32764. description: "圆弧开始角",
  32765. "type": "float",
  32766. "required": true
  32767. },
  32768. {
  32769. name: "endAngle",
  32770. description: "圆弧结束角",
  32771. "type": "float",
  32772. "required": true
  32773. },
  32774. {
  32775. name: "is3PDraw",
  32776. description: "是否三点绘制",
  32777. "type": "boolean",
  32778. "required": true
  32779. },
  32780. {
  32781. name: "point1",
  32782. description: "三点绘制圆弧的第一个点(起点)",
  32783. "type": "tuple[float, float]",
  32784. "required": true
  32785. },
  32786. {
  32787. name: "point2",
  32788. description: "三点绘制圆弧的第二个点",
  32789. "type": "tuple[float, float]",
  32790. "required": true
  32791. },
  32792. {
  32793. name: "point3",
  32794. description: "三点绘制圆弧的第三个点(终点)",
  32795. "type": "tuple[float, float]",
  32796. "required": true
  32797. },
  32798. ...baseParams
  32799. ]
  32800. };
  32801. }
  32802. }
  32803. const init$c = () => {
  32804. MxAiModule.regist(MxAiDrawCircleArc);
  32805. };
  32806. function computePolygonVerticesFromMidpoint(centerPoint = new mxcad2.McGePoint3d(), edgeMidPoint = new mxcad2.McGePoint3d(), sides = 3) {
  32807. const midX = edgeMidPoint.x;
  32808. const midY = edgeMidPoint.y;
  32809. const centerX = centerPoint.x;
  32810. const centerY = centerPoint.y;
  32811. const numberOfSides = Math.max(3, sides);
  32812. const distanceToCenter = Math.sqrt(__pow(midX - centerX, 2) + __pow(midY - centerY, 2));
  32813. const radius = distanceToCenter / Math.cos(Math.PI / numberOfSides);
  32814. const startAngle = Math.atan2(midY - centerY, midX - centerX) - Math.PI / numberOfSides;
  32815. const vertices = [];
  32816. for (let i2 = 0; i2 < numberOfSides; i2++) {
  32817. const angle = startAngle + i2 * 2 * Math.PI / numberOfSides;
  32818. const x = centerX + radius * Math.cos(angle);
  32819. const y = centerY + radius * Math.sin(angle);
  32820. vertices.push(new mxcad2.McGePoint3d(x, y));
  32821. }
  32822. return vertices;
  32823. }
  32824. function computeRegularPolygonVertices(centerPoint = new mxcad2.McGePoint3d(), vertexPoint = new mxcad2.McGePoint3d(), sides = 3) {
  32825. const verticesArray = [];
  32826. sides = Math.max(3, sides);
  32827. verticesArray.push(vertexPoint);
  32828. const angleIncrement = Math.PI * 2 / sides;
  32829. for (let i2 = 1; i2 < sides; i2++) {
  32830. const cosValue = Math.cos(angleIncrement * i2), sinValue = Math.sin(angleIncrement * i2);
  32831. const startPt = centerPoint.clone();
  32832. const endPt = vertexPoint.clone();
  32833. const deltaX = endPt.x - startPt.x;
  32834. const deltaY = endPt.y - startPt.y;
  32835. const newX = deltaX * cosValue - deltaY * sinValue + startPt.x;
  32836. const newY = deltaX * sinValue + deltaY * cosValue + startPt.y;
  32837. const point = new mxcad2.McGePoint3d(newX, newY);
  32838. verticesArray.push(point);
  32839. }
  32840. return verticesArray;
  32841. }
  32842. function computePolygonVerticesFromEdge(startPoint, endPoint, sides) {
  32843. let dx = endPoint.x - startPoint.x;
  32844. let dy = endPoint.y - startPoint.y;
  32845. let length = Math.sqrt(dx * dx + dy * dy);
  32846. let angle = Math.atan2(dy, dx);
  32847. let angleIncrement = 2 * Math.PI / Math.max(3, sides);
  32848. let polygonVertices = [startPoint, endPoint];
  32849. for (let i2 = 0; i2 < sides; i2++) {
  32850. let x = startPoint.x + length * Math.cos(angle + i2 * angleIncrement);
  32851. let y = startPoint.y + length * Math.sin(angle + i2 * angleIncrement);
  32852. startPoint = new mxcad2.McGePoint3d(x, y);
  32853. polygonVertices.push(startPoint);
  32854. }
  32855. return polygonVertices;
  32856. }
  32857. class MxAiDrawPolygon {
  32858. call(param) {
  32859. return __async(this, null, function* () {
  32860. mxcad2.MxCpp.getCurrentMxCAD().newFile();
  32861. console.log(param);
  32862. let { isDrawToCenter, sideNum, startPoint, endPoint, radius, centerPoint, isTangentToTheCircle } = param;
  32863. if (!sideNum) {
  32864. const getInt = new mxcad2.MxCADUiPrInt();
  32865. getInt.setMessage("输入边的数目<5>");
  32866. getInt.setKeyWords("");
  32867. getInt.clearLastInputPoint();
  32868. sideNum = (yield getInt.go()) || 5;
  32869. }
  32870. if (isDrawToCenter) {
  32871. if (!centerPoint) {
  32872. const getPoint = new mxcad2.MxCADUiPrPoint();
  32873. getPoint.setMessage("\n指定正多变形的中心点");
  32874. getPoint.setKeyWords("");
  32875. getPoint.clearLastInputPoint();
  32876. centerPoint = yield getPoint.go();
  32877. if (!centerPoint)
  32878. return;
  32879. } else {
  32880. centerPoint = parsePoint(centerPoint);
  32881. }
  32882. let vet = mxcad2.McGeVector3d.kXAxis;
  32883. let vertexPoint;
  32884. if (!radius) {
  32885. const getPoint = new mxcad2.MxCADUiPrDist();
  32886. getPoint.setMessage(mxcad2._ML_String("MxAiDrawPolygon_radius", "指定圆的半径"));
  32887. getPoint.setKeyWords("");
  32888. getPoint.setBasePt(centerPoint);
  32889. getPoint.setUserDraw((pt, pw) => {
  32890. if (isTangentToTheCircle) {
  32891. const _radius2 = pt.distanceTo(centerPoint);
  32892. vet = pt.sub(centerPoint);
  32893. const midPoint = centerPoint.clone().addvec(pt.sub(centerPoint).normalize().mult(_radius2));
  32894. const points = computePolygonVerticesFromMidpoint(centerPoint, midPoint, sideNum);
  32895. const polygon2 = new mxcad2.McDbPolyline();
  32896. points.forEach((point) => {
  32897. polygon2.addVertexAt(point);
  32898. });
  32899. polygon2.isClosed = true;
  32900. pw.drawMcDbEntity(polygon2);
  32901. } else {
  32902. vertexPoint = pt;
  32903. const polygon2 = new mxcad2.McDbPolyline();
  32904. computeRegularPolygonVertices(centerPoint, pt, sideNum).forEach((point) => {
  32905. polygon2.addVertexAt(point);
  32906. });
  32907. polygon2.isClosed = true;
  32908. pw.drawMcDbEntity(polygon2);
  32909. }
  32910. });
  32911. const _radius = yield getPoint.go();
  32912. if (!_radius)
  32913. return;
  32914. radius = _radius;
  32915. }
  32916. const polygon = new mxcad2.McDbPolyline();
  32917. polygon.isClosed = true;
  32918. if (isTangentToTheCircle) {
  32919. const midPoint = centerPoint.clone().addvec(vet.normalize().mult(radius));
  32920. const points = computePolygonVerticesFromMidpoint(centerPoint, midPoint, sideNum);
  32921. points.forEach((point) => {
  32922. polygon.addVertexAt(point);
  32923. });
  32924. } else {
  32925. if (!vertexPoint) {
  32926. const vet2 = mxcad2.McGeVector3d.kXAxis.clone().rotateBy(Math.PI / sideNum).mult(radius);
  32927. vertexPoint = centerPoint.clone().addvec(vet2);
  32928. }
  32929. computeRegularPolygonVertices(centerPoint, vertexPoint, sideNum).forEach((point) => {
  32930. polygon.addVertexAt(point);
  32931. });
  32932. }
  32933. mxcad2.MxCpp.getCurrentMxCAD().drawEntity(polygon);
  32934. } else {
  32935. const createStarEndPointPolygon = (currentPoint) => {
  32936. const pPolyline = new mxcad2.McDbPolyline();
  32937. const points = computePolygonVerticesFromEdge(startPoint, currentPoint, sideNum || 5);
  32938. points.forEach((point) => {
  32939. pPolyline.addVertexAt(point);
  32940. });
  32941. pPolyline.isClosed = true;
  32942. return pPolyline;
  32943. };
  32944. if (!startPoint) {
  32945. const getPoint = new mxcad2.MxCADUiPrPoint();
  32946. getPoint.clearLastInputPoint();
  32947. getPoint.setMessage("\n指定边的第一个端点");
  32948. getPoint.setKeyWords("");
  32949. startPoint = yield getPoint.go();
  32950. if (!startPoint)
  32951. return;
  32952. getPoint.setUserDraw((currentPoint, pWorldDraw) => {
  32953. pWorldDraw.drawMcDbEntity(createStarEndPointPolygon(currentPoint));
  32954. });
  32955. } else {
  32956. startPoint = parsePoint(startPoint);
  32957. }
  32958. if (!endPoint) {
  32959. const getPoint = new mxcad2.MxCADUiPrPoint();
  32960. getPoint.setBasePt(startPoint);
  32961. getPoint.setMessage("\n指定边的第二个端点");
  32962. endPoint = yield getPoint.go();
  32963. } else {
  32964. endPoint = parsePoint(endPoint);
  32965. }
  32966. if (!endPoint)
  32967. return;
  32968. const polygon = createStarEndPointPolygon(endPoint);
  32969. mxcad2.MxCpp.getCurrentMxCAD().drawEntity(polygon);
  32970. }
  32971. });
  32972. }
  32973. regist_data() {
  32974. return {
  32975. filename: "DrawPolygon.json",
  32976. name: "draw_polygon",
  32977. description: "绘制正多边形",
  32978. params: [
  32979. {
  32980. name: "isDrawToCenter",
  32981. description: "是否用圆绘制多边形",
  32982. "type": "boolean",
  32983. "required": true
  32984. },
  32985. {
  32986. name: "sideNum",
  32987. description: "边数",
  32988. type: "int",
  32989. "required": true
  32990. },
  32991. {
  32992. name: "startPoint",
  32993. description: "边绘制提供开始点",
  32994. "type": "tuple[float, float]",
  32995. "required": true
  32996. },
  32997. {
  32998. name: "endPoint",
  32999. description: "边绘制提供结束点",
  33000. "type": "tuple[float, float]",
  33001. "required": true
  33002. },
  33003. {
  33004. name: "radius",
  33005. description: "圆的半径",
  33006. type: "number",
  33007. "required": true
  33008. },
  33009. {
  33010. name: "centerPoint",
  33011. description: "圆心",
  33012. "type": "tuple[float, float]",
  33013. "required": true
  33014. },
  33015. {
  33016. name: "isTangentToTheCircle",
  33017. description: "外切于圆",
  33018. "type": "boolean",
  33019. "required": true
  33020. }
  33021. ]
  33022. };
  33023. }
  33024. }
  33025. const init$b = () => {
  33026. MxAiModule.regist(MxAiDrawPolygon);
  33027. };
  33028. const rotatePoint = (center, point, angle) => {
  33029. const cosAngle = Math.cos(angle);
  33030. const sinAngle = Math.sin(angle);
  33031. const translatedX = point.x - center.x;
  33032. const translatedY = point.y - center.y;
  33033. const x = translatedX * cosAngle - translatedY * sinAngle + center.x;
  33034. const y = translatedX * sinAngle + translatedY * cosAngle + center.y;
  33035. const z = point.z;
  33036. return new mxcad2.McGePoint3d(x, y, z);
  33037. };
  33038. const getRectPoints = (pt1, pt3, angle = 0) => {
  33039. const center = new mxcad2.McGePoint3d((pt1.x + pt3.x) / 2, (pt1.y + pt3.y) / 2, (pt1.z + pt3.z) / 2);
  33040. const pt2 = new mxcad2.McGePoint3d(pt1.x, pt3.y, pt1.z);
  33041. const pt4 = new mxcad2.McGePoint3d(pt3.x, pt1.y, pt3.z);
  33042. const rotatedPt2 = rotatePoint(center, pt2, angle);
  33043. const rotatedPt4 = rotatePoint(center, pt4, angle);
  33044. return [pt1, rotatedPt2, pt3, rotatedPt4];
  33045. };
  33046. const getQuadrant = (pt1, pt3) => {
  33047. return [pt3.x >= pt1.x && pt3.y >= pt1.y, pt3.x < pt1.x && pt3.y >= pt1.y, pt3.x < pt1.x && pt3.y < pt1.y, pt3.x >= pt1.x && pt3.y < pt1.y];
  33048. };
  33049. function calculateRoundedRectangleVertices(points, chamferDistance1, chamferDistance2) {
  33050. if (chamferDistance1 === 0 && chamferDistance2 === 0)
  33051. return points;
  33052. const [pt1, pt2, pt3, pt4] = points;
  33053. const width = pt1.distanceTo(pt4);
  33054. const height = pt1.distanceTo(pt2);
  33055. const [_, isPt3InQuadrant2, isPt3InQuadrant3, isPt3InQuadrant4] = getQuadrant(pt1, pt3);
  33056. const chamferDistanceX = isPt3InQuadrant2 || isPt3InQuadrant3 ? -chamferDistance1 : chamferDistance1;
  33057. const chamferDistanceY = isPt3InQuadrant3 || isPt3InQuadrant4 ? -chamferDistance2 : chamferDistance2;
  33058. if (width - Math.abs(chamferDistanceX) * 2 <= 0)
  33059. return points;
  33060. if (height - Math.abs(chamferDistanceY) * 2 <= 0)
  33061. return points;
  33062. const chamferedPt1 = new mxcad2.McGePoint3d(pt1.x + chamferDistanceX, pt1.y, pt1.z);
  33063. const chamferedPt2 = new mxcad2.McGePoint3d(pt1.x, pt1.y + chamferDistanceY, pt1.z);
  33064. const chamferedPt3 = new mxcad2.McGePoint3d(pt2.x, pt2.y - chamferDistanceY, pt2.z);
  33065. const chamferedPt4 = new mxcad2.McGePoint3d(pt2.x + chamferDistanceX, pt2.y, pt2.z);
  33066. const chamferedPt5 = new mxcad2.McGePoint3d(pt3.x - chamferDistanceX, pt3.y, pt3.z);
  33067. const chamferedPt6 = new mxcad2.McGePoint3d(pt3.x, pt2.y - chamferDistanceY, pt3.z);
  33068. const chamferedPt7 = new mxcad2.McGePoint3d(pt4.x, pt4.y + chamferDistanceY, pt4.z);
  33069. const chamferedPt8 = new mxcad2.McGePoint3d(pt4.x - chamferDistanceX, pt4.y, pt4.z);
  33070. const chamferedPolygon = [
  33071. chamferedPt1,
  33072. chamferedPt2,
  33073. chamferedPt3,
  33074. chamferedPt4,
  33075. chamferedPt5,
  33076. chamferedPt6,
  33077. chamferedPt7,
  33078. chamferedPt8
  33079. ];
  33080. return chamferedPolygon;
  33081. }
  33082. function CMxDrawPolylineDragArcDraw_CalcArcBulge(firstPoint, nextPoint, vecArcTangent) {
  33083. if (firstPoint.isEqualTo(nextPoint))
  33084. return 0;
  33085. let midPt = firstPoint.c().addvec(nextPoint.c().sub(firstPoint).mult(0.5));
  33086. let vecMid = nextPoint.c().sub(firstPoint);
  33087. vecMid.rotateBy(Math.PI / 2, mxcad2.McGeVector3d.kZAxis);
  33088. let tmpMidLine = new mxcad2.McDbLine(midPt, midPt.c().addvec(vecMid));
  33089. let vecVertical = vecArcTangent.c();
  33090. vecVertical.rotateBy(Math.PI / 2, mxcad2.McGeVector3d.kZAxis);
  33091. let tmpVerticalLine = new mxcad2.McDbLine(firstPoint, firstPoint.c().addvec(vecVertical));
  33092. let aryPoint = tmpMidLine.IntersectWith(tmpVerticalLine, mxcad2.McDb.Intersect.kExtendBoth);
  33093. if (aryPoint.isEmpty())
  33094. return 0;
  33095. let arcCenPoint = aryPoint.at(0);
  33096. let dR = arcCenPoint.distanceTo(firstPoint);
  33097. vecMid.normalize();
  33098. vecMid.mult(dR);
  33099. let arcMidPt1 = arcCenPoint.c().addvec(vecMid);
  33100. let arcMidPt2 = arcCenPoint.c().subvec(vecMid);
  33101. let vecArcDir1 = arcMidPt1.c().sub(firstPoint);
  33102. let vecArcDir2 = arcMidPt2.c().sub(firstPoint);
  33103. let arcMidPt = arcMidPt1;
  33104. if (vecArcDir1.angleTo1(vecArcTangent) > vecArcDir2.angleTo1(vecArcTangent)) {
  33105. arcMidPt = arcMidPt2;
  33106. }
  33107. return mxcad2.MxCADUtility.calcBulge(firstPoint, arcMidPt, nextPoint).val;
  33108. }
  33109. class MxAiDrawRect {
  33110. call(param) {
  33111. return __async(this, null, function* () {
  33112. console.log(param);
  33113. mxcad2.MxCpp.getCurrentMxCAD().newFile();
  33114. let { pt1, pt2: pt3, chamfer1Length, chamfer2Length, filletRadius, lineWidth, area: area2, rectLength, rectWidth, rotationAngle } = param;
  33115. const createRect = (pt12, pt32) => {
  33116. const [_pt1, pt2, _pt3, pt4] = getRectPoints(pt12, pt32, rotationAngle);
  33117. const rect2 = new mxcad2.McDbPolyline();
  33118. rect2.addVertexAt(_pt1, 0, lineWidth, lineWidth);
  33119. rect2.addVertexAt(pt2, 0, lineWidth, lineWidth);
  33120. rect2.addVertexAt(_pt3, 0, lineWidth, lineWidth);
  33121. rect2.addVertexAt(pt4, 0, lineWidth, lineWidth);
  33122. rect2.isClosed = true;
  33123. if (lineWidth)
  33124. rect2.constantWidth = lineWidth;
  33125. return rect2;
  33126. };
  33127. const create = (pt12, pt32) => {
  33128. let rect2;
  33129. if (filletRadius) {
  33130. const points = calculateRoundedRectangleVertices(getRectPoints(pt12, pt32, rotationAngle), filletRadius, filletRadius);
  33131. const [_, isPt3InQuadrant2, isPt3InQuadrant3, isPt3InQuadrant4] = getQuadrant(pt12, pt32);
  33132. if (points.length === 8) {
  33133. if (!rect2)
  33134. rect2 = new mxcad2.McDbPolyline();
  33135. const addArc = (startPoint, endPoint, key) => {
  33136. let vecArcTangent = new mxcad2.McGeVector3d(key);
  33137. const bulge = CMxDrawPolylineDragArcDraw_CalcArcBulge(startPoint, endPoint, vecArcTangent);
  33138. rect2.addVertexAt(startPoint, bulge, lineWidth, lineWidth);
  33139. rect2.addVertexAt(endPoint, 0, lineWidth, lineWidth);
  33140. };
  33141. const vec1 = new mxcad2.McGeVector3d(-1, 0);
  33142. const vec2 = new mxcad2.McGeVector3d(0, 1);
  33143. const vec3 = new mxcad2.McGeVector3d(1, 0);
  33144. const vec4 = new mxcad2.McGeVector3d(0, -1);
  33145. if (isPt3InQuadrant4) {
  33146. vec2.y = -1;
  33147. vec3.x = 1;
  33148. vec4.y = 1;
  33149. }
  33150. if (isPt3InQuadrant2) {
  33151. vec1.x = 1;
  33152. vec2.y = 1;
  33153. vec3.x = -1;
  33154. vec4.y = -1;
  33155. }
  33156. if (isPt3InQuadrant3) {
  33157. vec1.x = 1;
  33158. vec2.y = -1;
  33159. vec3.x = -1;
  33160. vec4.y = 1;
  33161. }
  33162. addArc(points[0], points[1], vec1);
  33163. addArc(points[2], points[3], vec2);
  33164. addArc(points[4], points[5], vec3);
  33165. addArc(points[6], points[7], vec4);
  33166. rect2.isClosed = true;
  33167. }
  33168. } else if (chamfer1Length || chamfer2Length) {
  33169. if (!rect2)
  33170. rect2 = new mxcad2.McDbPolyline();
  33171. const points = calculateRoundedRectangleVertices(getRectPoints(pt12, pt32, rotationAngle), chamfer1Length || chamfer2Length, chamfer2Length || chamfer1Length);
  33172. points.forEach((point) => {
  33173. rect2.addVertexAt(point);
  33174. });
  33175. rect2.isClosed = true;
  33176. }
  33177. if (!rect2)
  33178. rect2 = createRect(pt12, pt32);
  33179. if (lineWidth)
  33180. rect2.constantWidth = lineWidth;
  33181. return rect2;
  33182. };
  33183. if (!pt1) {
  33184. const getPoint = new mxcad2.MxCADUiPrPoint();
  33185. getPoint.setMessage("指定第一个角点");
  33186. getPoint.setKeyWords("");
  33187. pt1 = yield getPoint.go();
  33188. if (!pt1)
  33189. return;
  33190. } else {
  33191. pt1 = parsePoint(pt1);
  33192. }
  33193. if (area2) {
  33194. if (rectLength) {
  33195. rectWidth = area2 / rectLength;
  33196. }
  33197. if (rectWidth) {
  33198. rectLength = area2 / rectWidth;
  33199. }
  33200. }
  33201. if (rectLength && rectWidth) {
  33202. pt3 = new mxcad2.McGePoint3d(pt1.x + rectWidth, pt1.y + rectLength, 0);
  33203. }
  33204. if (!pt3) {
  33205. const getPoint = new mxcad2.MxCADUiPrPoint();
  33206. getPoint.setMessage("指定第二个角点");
  33207. getPoint.setKeyWords("");
  33208. getPoint.setUserDraw((pt, pw) => {
  33209. pw.drawMcDbEntity(create(pt1, pt));
  33210. });
  33211. pt3 = yield getPoint.go();
  33212. if (!pt3)
  33213. return;
  33214. } else {
  33215. pt3 = parsePoint(pt3);
  33216. }
  33217. const rect = create(pt1, pt3);
  33218. mergeBaseMcDbEntityProps(rect, param);
  33219. mxcad2.MxCpp.getCurrentMxCAD().drawEntity(rect);
  33220. });
  33221. }
  33222. regist_data() {
  33223. return {
  33224. filename: "drawRect.json",
  33225. name: "draw_rect",
  33226. description: "根据一些信息绘制矩形",
  33227. params: [
  33228. {
  33229. name: "pt1",
  33230. description: "一个对角点",
  33231. "type": "tuple[float, float]",
  33232. "required": true
  33233. },
  33234. {
  33235. name: "pt2",
  33236. description: "另一个对角点",
  33237. "type": "tuple[float, float]",
  33238. "required": true
  33239. },
  33240. {
  33241. name: "lineWidth",
  33242. description: "矩形线的宽",
  33243. "type": "float",
  33244. "required": true
  33245. },
  33246. {
  33247. name: "filletRadius",
  33248. description: "圆角半径",
  33249. "type": "float",
  33250. "required": true
  33251. },
  33252. {
  33253. name: "chamfer1Length",
  33254. description: "第一个倒角距离",
  33255. "type": "float",
  33256. "required": true
  33257. },
  33258. {
  33259. name: "chamfer2Length",
  33260. description: "第二个倒角距离",
  33261. "type": "float",
  33262. "required": true
  33263. },
  33264. {
  33265. name: "rectLength",
  33266. description: "长度",
  33267. "type": "float",
  33268. "required": true
  33269. },
  33270. {
  33271. name: "rectWidth",
  33272. description: "矩形宽度",
  33273. "type": "float",
  33274. "required": true
  33275. },
  33276. {
  33277. name: "area",
  33278. description: "面积",
  33279. "type": "float",
  33280. "required": true
  33281. },
  33282. {
  33283. name: "rotationAngle",
  33284. description: "旋转角度",
  33285. "type": "float",
  33286. "required": true
  33287. },
  33288. ...baseParams
  33289. ]
  33290. };
  33291. }
  33292. }
  33293. function init$a() {
  33294. MxAiModule.regist(MxAiDrawRect);
  33295. }
  33296. const createEllipse = (endPoint1, endPoint2, halfAxisLength, startAngle, endAngle) => {
  33297. const ellipse = new mxcad2.McDbEllipse();
  33298. const center = new mxcad2.McGePoint3d((endPoint1.x + endPoint2.x) / 2, (endPoint2.y + endPoint2.y) / 2);
  33299. const majorAxis = endPoint1.sub(endPoint2);
  33300. const minorAxis = majorAxis;
  33301. const xRadius = endPoint1.distanceTo(endPoint2) / 2;
  33302. const yRadius = halfAxisLength / 2;
  33303. const radiusRatio = yRadius / xRadius;
  33304. ellipse.center = center;
  33305. ellipse.majorAxis = majorAxis;
  33306. ellipse.minorAxis = minorAxis;
  33307. ellipse.radiusRatio = radiusRatio;
  33308. ellipse.startAngle = startAngle;
  33309. ellipse.endAngle = endAngle;
  33310. return ellipse;
  33311. };
  33312. class MxAiDrawEllipse {
  33313. call(param) {
  33314. return __async(this, null, function* () {
  33315. let { endPoint1, endPoint2, halfAxisLength } = param;
  33316. const mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  33317. mxcad$1.newFile();
  33318. const getPoint = new mxcad2.MxCADUiPrPoint();
  33319. const getDist = new mxcad2.MxCADUiPrDist();
  33320. if (endPoint1)
  33321. endPoint1 = parsePoint(endPoint1);
  33322. if (endPoint2)
  33323. endPoint2 = parsePoint(endPoint2);
  33324. if (!endPoint1) {
  33325. getPoint.setMessage("指定椭圆的轴端点1");
  33326. getPoint.setKeyWords("");
  33327. getPoint.setUserDraw((pt, pw) => {
  33328. if (!endPoint2)
  33329. return;
  33330. if (!halfAxisLength)
  33331. return;
  33332. pw.drawMcDbEntity(createEllipse(pt, endPoint2, halfAxisLength, 0, Math.PI * 2));
  33333. });
  33334. endPoint1 = yield getPoint.go();
  33335. if (!endPoint1)
  33336. return;
  33337. }
  33338. if (!endPoint2) {
  33339. getPoint.setMessage("指定椭圆的轴端点2");
  33340. getPoint.setKeyWords("");
  33341. getPoint.setUserDraw((pt, pw) => {
  33342. if (!endPoint1)
  33343. return;
  33344. if (!halfAxisLength)
  33345. return;
  33346. pw.drawMcDbEntity(createEllipse(endPoint1, pt, halfAxisLength, 0, Math.PI * 2));
  33347. });
  33348. endPoint2 = yield getPoint.go();
  33349. if (!endPoint2)
  33350. return;
  33351. }
  33352. if (!halfAxisLength) {
  33353. getDist.setMessage("指定半轴长度");
  33354. getDist.setKeyWords("");
  33355. const center = new mxcad2.McGePoint3d((endPoint1.x + endPoint2.x) / 2, (endPoint2.y + endPoint2.y) / 2);
  33356. getDist.setBasePt(center);
  33357. getDist.setUserDraw((pt, pw) => {
  33358. if (!endPoint1)
  33359. return;
  33360. pw.drawMcDbEntity(createEllipse(endPoint1, endPoint2, center.distanceTo(pt), 0, Math.PI * 2));
  33361. });
  33362. halfAxisLength = yield getDist.go();
  33363. if (!halfAxisLength)
  33364. return;
  33365. }
  33366. const ellipse = createEllipse(endPoint1, endPoint2, halfAxisLength, 0, Math.PI * 2);
  33367. mergeBaseMcDbEntityProps(ellipse, param);
  33368. mxcad$1.drawEntity(ellipse);
  33369. });
  33370. }
  33371. regist_data() {
  33372. return {
  33373. filename: "drawellipse.json",
  33374. name: "draw_ellipse",
  33375. description: "绘制椭圆",
  33376. params: [
  33377. {
  33378. name: "endPoint1",
  33379. description: "椭圆端点1",
  33380. "type": "tuple[float, float]",
  33381. "required": true
  33382. },
  33383. {
  33384. name: "endPoint2",
  33385. description: "椭圆端点2",
  33386. "type": "tuple[float, float]",
  33387. "required": true
  33388. },
  33389. {
  33390. name: "halfAxisLength",
  33391. description: "半轴长度",
  33392. "type": "float",
  33393. "required": true
  33394. },
  33395. ...baseParams
  33396. ]
  33397. };
  33398. }
  33399. }
  33400. class MxAiDrawEllipseArc {
  33401. call(param) {
  33402. return __async(this, null, function* () {
  33403. let { endPoint1, endPoint2, halfAxisLength, startAngle, endAngle } = param;
  33404. const mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  33405. mxcad$1.newFile();
  33406. const getPoint = new mxcad2.MxCADUiPrPoint();
  33407. const getDist = new mxcad2.MxCADUiPrDist();
  33408. if (endPoint1)
  33409. endPoint1 = parsePoint(endPoint1);
  33410. if (endPoint2)
  33411. endPoint2 = parsePoint(endPoint2);
  33412. if (startAngle)
  33413. startAngle = startAngle * (Math.PI / 180);
  33414. if (endAngle)
  33415. endAngle = endAngle * (Math.PI / 180);
  33416. if (!endPoint1) {
  33417. getPoint.setMessage("指定椭圆的轴端点1");
  33418. getPoint.setKeyWords("");
  33419. getPoint.setUserDraw((pt, pw) => {
  33420. if (!endPoint2)
  33421. return;
  33422. if (!halfAxisLength)
  33423. return;
  33424. pw.drawMcDbEntity(createEllipse(pt, endPoint2, halfAxisLength, 0, Math.PI * 2));
  33425. });
  33426. endPoint1 = yield getPoint.go();
  33427. if (!endPoint1)
  33428. return;
  33429. }
  33430. if (!endPoint2) {
  33431. getPoint.setMessage("指定椭圆的轴端点2");
  33432. getPoint.setKeyWords("");
  33433. getPoint.setUserDraw((pt, pw) => {
  33434. if (!endPoint1)
  33435. return;
  33436. if (!halfAxisLength)
  33437. return;
  33438. pw.drawMcDbEntity(createEllipse(endPoint1, pt, halfAxisLength, 0, Math.PI * 2));
  33439. });
  33440. endPoint2 = yield getPoint.go();
  33441. if (!endPoint2)
  33442. return;
  33443. }
  33444. const center = new mxcad2.McGePoint3d((endPoint1.x + endPoint2.x) / 2, (endPoint2.y + endPoint2.y) / 2);
  33445. if (!halfAxisLength) {
  33446. getDist.setMessage("指定半轴长度");
  33447. getDist.setKeyWords("");
  33448. getDist.setBasePt(center);
  33449. getDist.setUserDraw((pt, pw) => {
  33450. if (!endPoint1)
  33451. return;
  33452. pw.drawMcDbEntity(createEllipse(endPoint1, endPoint2, center.distanceTo(pt), 0, Math.PI * 2));
  33453. });
  33454. halfAxisLength = yield getDist.go();
  33455. if (!halfAxisLength)
  33456. return;
  33457. }
  33458. const angle = angleTo(center.x, center.y, endPoint1.x, endPoint1.y);
  33459. if (!startAngle) {
  33460. getDist.setMessage(mxcad2._ML_String("EllipticalArc_startAngle", "指定起点角度"));
  33461. getDist.setKeyWords("");
  33462. getDist.setUserDraw((currentPoint, pWorldDraw) => {
  33463. startAngle = angleTo(center.x, center.y, currentPoint.x, currentPoint.y) - angle - Math.PI;
  33464. pWorldDraw.drawMcDbEntity(createEllipse(endPoint1, endPoint2, halfAxisLength, startAngle, Math.PI * 2));
  33465. });
  33466. const val = yield getDist.go();
  33467. if (!val)
  33468. return;
  33469. if (getDist.getDetailedResult() == mxdraw.DetailedResult.kCoordIn) {
  33470. startAngle = val * (180 / Math.PI);
  33471. }
  33472. }
  33473. if (!endAngle) {
  33474. getDist.setLastInputPoint(center);
  33475. getDist.setMessage(mxcad2._ML_String("EllipticalArc_endAngle", "指定端点角度"));
  33476. getDist.setKeyWords("");
  33477. getDist.setUserDraw((currentPoint, pWorldDraw) => {
  33478. endAngle = angleTo(center.x, center.y, currentPoint.x, currentPoint.y) - angle - Math.PI;
  33479. pWorldDraw.drawMcDbEntity(createEllipse(endPoint1, endPoint2, halfAxisLength, startAngle, endAngle));
  33480. });
  33481. const val1 = yield getDist.go();
  33482. if (!val1)
  33483. return;
  33484. if (getDist.getDetailedResult() === mxdraw.DetailedResult.kCoordIn) {
  33485. endAngle = val1 * (180 / Math.PI);
  33486. }
  33487. }
  33488. const ellipse = createEllipse(endPoint1, endPoint2, halfAxisLength, startAngle, endAngle);
  33489. mergeBaseMcDbEntityProps(ellipse, param);
  33490. mxcad$1.drawEntity(ellipse);
  33491. });
  33492. }
  33493. regist_data() {
  33494. return {
  33495. filename: "drawellipseArc.json",
  33496. name: "draw_ellipse_arc",
  33497. description: "绘制椭圆弧",
  33498. params: [
  33499. {
  33500. name: "endPoint1",
  33501. description: "椭圆弧端点1",
  33502. "type": "tuple[float, float]",
  33503. "required": true
  33504. },
  33505. {
  33506. name: "endPoint2",
  33507. description: "椭圆弧端点2",
  33508. "type": "tuple[float, float]",
  33509. "required": true
  33510. },
  33511. {
  33512. name: "halfAxisLength",
  33513. description: "半轴长度",
  33514. "type": "float",
  33515. "required": true
  33516. },
  33517. {
  33518. name: "startAngle",
  33519. description: "开始角度",
  33520. "type": "float",
  33521. "required": true
  33522. },
  33523. {
  33524. name: "endAngle",
  33525. description: "结束角度",
  33526. "type": "float",
  33527. "required": true
  33528. },
  33529. ...baseParams
  33530. ]
  33531. };
  33532. }
  33533. }
  33534. const init$9 = () => {
  33535. MxAiModule.regist(MxAiDrawEllipse);
  33536. MxAiModule.regist(MxAiDrawEllipseArc);
  33537. };
  33538. const _WallLine = class _WallLine {
  33539. constructor(start, end, width = 50) {
  33540. this.width = 50;
  33541. this.isDraw = false;
  33542. this.update(start, end, width);
  33543. }
  33544. update(start, end, width = this.width) {
  33545. let dirVector = start.clone().sub(end).normalize();
  33546. dirVector = new mxcad2.McGeVector3d(-dirVector.y, dirVector.x, 0).mult(width / 2);
  33547. const negateDirVector = dirVector.clone().negate();
  33548. this.outsidePoints = [start.clone().addvec(dirVector), end.clone().addvec(dirVector)];
  33549. this.insidePoints = [start.clone().addvec(negateDirVector), end.clone().addvec(negateDirVector)];
  33550. this.width = width;
  33551. this.startPoint = start.clone();
  33552. this.endPoint = end.clone();
  33553. if (!this.outsideLine) {
  33554. this.outsideLine = new mxcad2.McDbLine(this.outsidePoints[0], this.outsidePoints[1]);
  33555. } else {
  33556. this.outsideLine.startPoint = this.outsidePoints[0];
  33557. this.outsideLine.endPoint = this.outsidePoints[1];
  33558. }
  33559. if (!this.insideLine) {
  33560. this.insideLine = new mxcad2.McDbLine(this.insidePoints[0], this.insidePoints[1]);
  33561. } else {
  33562. this.insideLine.startPoint = this.insidePoints[0];
  33563. this.insideLine.endPoint = this.insidePoints[1];
  33564. }
  33565. if (!this.startClosedLine) {
  33566. this.startClosedLine = new mxcad2.McDbLine(this.outsidePoints[0], this.insidePoints[0]);
  33567. } else {
  33568. this.startClosedLine.startPoint = this.outsidePoints[0];
  33569. this.startClosedLine.endPoint = this.insidePoints[0];
  33570. }
  33571. if (!this.endClosedLine) {
  33572. this.endClosedLine = new mxcad2.McDbLine(this.outsidePoints[1], this.insidePoints[1]);
  33573. } else {
  33574. this.endClosedLine.startPoint = this.outsidePoints[1];
  33575. this.endClosedLine.endPoint = this.insidePoints[1];
  33576. }
  33577. }
  33578. clone() {
  33579. const line = new _WallLine(this.startPoint, this.endPoint, this.width);
  33580. line.insideLine = this.insideLine.clone();
  33581. line.outsideLine = this.outsideLine.clone();
  33582. return line;
  33583. }
  33584. hiddenStartClosedLine() {
  33585. this.startClosedLine.visible = false;
  33586. }
  33587. hiddenEndClosedLine() {
  33588. this.endClosedLine.visible = false;
  33589. }
  33590. /** 开始点闭合线与比较墙体内线的交点 (开始-内)*/
  33591. getClosedStartLineToDiffWallInsideLineIntersectionPoint(diffLine, is = false) {
  33592. return this.startClosedLine.visible ? findIntersection(diffLine.insideLine.startPoint, diffLine.insideLine.endPoint, this.startClosedLine.startPoint, this.startClosedLine.endPoint, is) : null;
  33593. }
  33594. /** 开始点闭合线与比较墙体外线的交点 (开始-外)*/
  33595. getClosedStartLineToDiffWallOutsideLineIntersectionPoint(diffLine, is = false) {
  33596. return this.startClosedLine.visible ? findIntersection(diffLine.outsideLine.startPoint, diffLine.outsideLine.endPoint, this.startClosedLine.startPoint, this.startClosedLine.endPoint, is) : null;
  33597. }
  33598. /** 结束点闭合线与比较墙体内线的交点 (结束-内)*/
  33599. getClosedEndLineToDiffWallInsideLineIntersectionPoint(diffLine, is = false) {
  33600. return this.endClosedLine.visible ? findIntersection(diffLine.insideLine.startPoint, diffLine.insideLine.endPoint, this.endClosedLine.startPoint, this.endClosedLine.endPoint, is) : null;
  33601. }
  33602. /** 开始点闭合线与比较墙体外线的交点 (结束-外)*/
  33603. getClosedEndLineToDiffWallOutsideLineIntersectionPoint(diffLine, is = false) {
  33604. return this.endClosedLine.visible ? findIntersection(diffLine.outsideLine.startPoint, diffLine.outsideLine.endPoint, this.endClosedLine.startPoint, this.endClosedLine.endPoint, is) : null;
  33605. }
  33606. /** 内线与比较墙体的内线交点 (内-内)*/
  33607. getInsideToDiffInsideIntersectionPoint(diffLine, is = false) {
  33608. return findIntersection(diffLine.insideLine.startPoint, diffLine.insideLine.endPoint, this.insideLine.startPoint, this.insideLine.endPoint, is);
  33609. }
  33610. /** 外线与比较墙体的外线交点 (外-外)*/
  33611. getOutsideToDiffOutsideIntersectionPoint(diffLine, is = false) {
  33612. return findIntersection(diffLine.outsideLine.startPoint, diffLine.outsideLine.endPoint, this.outsideLine.startPoint, this.outsideLine.endPoint, is);
  33613. }
  33614. /** 内线与比较墙体的外线交点 (内-外)*/
  33615. getInsideToDiffOutsideIntersectionPoint(diffLine, is = false) {
  33616. return findIntersection(diffLine.outsideLine.startPoint, diffLine.outsideLine.endPoint, this.insideLine.startPoint, this.insideLine.endPoint, is);
  33617. }
  33618. /** 外线与比较墙体的内线交点 (外-内)*/
  33619. getOutsideToDiffInsideIntersectionPoint(diffLine, is = false) {
  33620. return findIntersection(diffLine.insideLine.startPoint, diffLine.insideLine.endPoint, this.outsideLine.startPoint, this.outsideLine.endPoint, is);
  33621. }
  33622. /** 开始闭合线与比较墙体开始闭合线交点 (开始-开始)*/
  33623. getClosedStartLineToDiffLineClosedStartLineIntersectionPoint(diffLine, is = false) {
  33624. return this.startClosedLine.visible ? findIntersection(diffLine.startClosedLine.startPoint, diffLine.startClosedLine.endPoint, this.startClosedLine.startPoint, this.startClosedLine.endPoint, is) : null;
  33625. }
  33626. /** 开始闭合线与比较墙体结束闭合线交点 (开始-结束)*/
  33627. getClosedStartLineToDiffLineClosedEndLineIntersectionPoint(diffLine, is = false) {
  33628. return this.startClosedLine.visible ? findIntersection(diffLine.endClosedLine.startPoint, diffLine.endClosedLine.endPoint, this.startClosedLine.startPoint, this.startClosedLine.endPoint, is) : null;
  33629. }
  33630. /** 结束点闭合线与比较墙体开始闭合线交点 (结束-开始)*/
  33631. getClosedEndLineToDiffLineClosedStartLineIntersectionPoint(diffLine, is = false) {
  33632. return this.endClosedLine.visible ? findIntersection(diffLine.startClosedLine.startPoint, diffLine.startClosedLine.endPoint, this.endClosedLine.startPoint, this.endClosedLine.endPoint, is) : null;
  33633. }
  33634. /** 结束点闭合线与比较墙体结束点闭合线交点 (结束-结束)*/
  33635. getClosedEndLineToDiffLineClosedEndLineIntersectionPoint(diffLine, is = false) {
  33636. return this.endClosedLine.visible ? findIntersection(diffLine.endClosedLine.startPoint, diffLine.endClosedLine.endPoint, this.endClosedLine.startPoint, this.endClosedLine.endPoint, is) : null;
  33637. }
  33638. // 是否拐角
  33639. isCorner(diffLine) {
  33640. const v = diffLine.startPoint.sub(diffLine.endPoint).normalize();
  33641. const v1 = v.clone().mult(diffLine.width);
  33642. const v2 = v.clone().mult(-diffLine.width);
  33643. const pt1 = diffLine.insideLine.startPoint.clone().addvec(v1);
  33644. const pt2 = diffLine.insideLine.startPoint.clone().addvec(v2);
  33645. const pt3 = diffLine.outsideLine.startPoint.clone().addvec(v2);
  33646. const pt4 = diffLine.outsideLine.startPoint.clone().addvec(v1);
  33647. const pt5 = diffLine.insideLine.endPoint.clone().addvec(v1);
  33648. const pt6 = diffLine.insideLine.endPoint.clone().addvec(v2);
  33649. const pt7 = diffLine.outsideLine.endPoint.clone().addvec(v2);
  33650. const pt8 = diffLine.outsideLine.endPoint.clone().addvec(v1);
  33651. const start = insidePolygon([pt1, pt2, pt3, pt4], this.startPoint);
  33652. const end = insidePolygon([pt1, pt2, pt3, pt4], this.endPoint);
  33653. const start1 = insidePolygon([pt5, pt6, pt7, pt8], this.startPoint);
  33654. const end1 = insidePolygon([pt5, pt6, pt7, pt8], this.endPoint);
  33655. return [{
  33656. start,
  33657. end
  33658. }, {
  33659. start: start1,
  33660. end: end1
  33661. }];
  33662. }
  33663. // 处理拐角
  33664. handlingCorners(diffLine) {
  33665. const [startCorner, endCorner] = this.isCorner(diffLine);
  33666. if (endCorner.start) {
  33667. this.outsideLine.startPoint = diffLine.outsideLine.endPoint = this.getOutsideToDiffOutsideIntersectionPoint(diffLine, true);
  33668. this.insideLine.startPoint = diffLine.insideLine.endPoint = this.getInsideToDiffInsideIntersectionPoint(diffLine, true);
  33669. this.hiddenStartClosedLine();
  33670. diffLine.hiddenEndClosedLine();
  33671. return;
  33672. } else if (endCorner.end) {
  33673. this.outsideLine.endPoint = diffLine.insideLine.endPoint = this.getOutsideToDiffInsideIntersectionPoint(diffLine, true);
  33674. this.insideLine.endPoint = diffLine.outsideLine.endPoint = this.getInsideToDiffOutsideIntersectionPoint(diffLine, true);
  33675. this.hiddenEndClosedLine();
  33676. diffLine.hiddenEndClosedLine();
  33677. return;
  33678. } else if (startCorner.start) {
  33679. this.insideLine.startPoint = diffLine.outsideLine.startPoint = this.getInsideToDiffOutsideIntersectionPoint(diffLine, true);
  33680. this.outsideLine.startPoint = diffLine.insideLine.startPoint = this.getOutsideToDiffInsideIntersectionPoint(diffLine, true);
  33681. this.hiddenStartClosedLine();
  33682. diffLine.hiddenStartClosedLine();
  33683. return;
  33684. } else if (startCorner.end) {
  33685. this.outsideLine.endPoint = diffLine.outsideLine.startPoint = this.getOutsideToDiffOutsideIntersectionPoint(diffLine, true);
  33686. this.insideLine.endPoint = diffLine.insideLine.startPoint = this.getInsideToDiffInsideIntersectionPoint(diffLine, true);
  33687. this.hiddenEndClosedLine();
  33688. diffLine.hiddenStartClosedLine();
  33689. return;
  33690. }
  33691. }
  33692. // 交集处理
  33693. processingIntersection() {
  33694. const diffUpdate = [];
  33695. _WallLine.lines.forEach((diffLine) => {
  33696. const point = this.getInsideToDiffInsideIntersectionPoint(diffLine);
  33697. const point1 = this.getInsideToDiffOutsideIntersectionPoint(diffLine);
  33698. const point2 = this.getOutsideToDiffOutsideIntersectionPoint(diffLine);
  33699. const point3 = this.getOutsideToDiffInsideIntersectionPoint(diffLine);
  33700. if (point || point1 || point2 || point3) {
  33701. diffUpdate.push({
  33702. diffLine,
  33703. intersectionPoints: [point, point1, point2, point3]
  33704. });
  33705. }
  33706. });
  33707. diffUpdate.forEach(({ diffLine, intersectionPoints }) => {
  33708. const [startCorner, endCorner] = this.isCorner(diffLine);
  33709. startCorner.end || startCorner.start || endCorner.start || endCorner.start;
  33710. const [ii, io, oo, oi] = intersectionPoints;
  33711. const points = [diffLine.insideLine.startPoint, diffLine.insideLine.endPoint, diffLine.outsideLine.endPoint, diffLine.outsideLine.startPoint];
  33712. insidePolygon(points, this.startPoint);
  33713. insidePolygon(points, this.endPoint);
  33714. if (ii && io && oo && oi) {
  33715. const point = findIntersection(this.startPoint, this.endPoint, diffLine.startPoint, diffLine.endPoint);
  33716. const wall1 = new _WallLine(this.startPoint, point, this.width);
  33717. const wall2 = new _WallLine(point, this.endPoint, this.width);
  33718. const diffWall1 = new _WallLine(diffLine.startPoint, point, diffLine.width);
  33719. const diffWall2 = new _WallLine(point, diffLine.endPoint, diffLine.width);
  33720. wall1.insideLine.startPoint = this.insideLine.startPoint;
  33721. wall1.outsideLine.startPoint = this.outsideLine.startPoint;
  33722. wall2.insideLine.endPoint = this.insideLine.endPoint;
  33723. wall2.outsideLine.endPoint = this.outsideLine.endPoint;
  33724. diffLine.remove();
  33725. this.remove();
  33726. wall1.draw();
  33727. wall2.draw();
  33728. diffWall1.draw();
  33729. diffWall2.draw();
  33730. } else if (oo && io || ii && oi) {
  33731. const point = findIntersection(this.startPoint, this.endPoint, diffLine.startPoint, diffLine.endPoint, true);
  33732. const wall1 = new _WallLine(diffLine.startPoint, point, diffLine.width);
  33733. wall1.hiddenEndClosedLine();
  33734. const wall2 = new _WallLine(point, diffLine.endPoint, diffLine.width);
  33735. wall2.hiddenStartClosedLine();
  33736. diffLine.remove();
  33737. wall1.draw();
  33738. wall2.draw();
  33739. } else {
  33740. if (diffUpdate.length === 1)
  33741. return this.handlingCorners(diffLine);
  33742. if (endCorner.start) {
  33743. console.log("endCorner.start");
  33744. if (oo) {
  33745. diffLine.outsideLine.endPoint = this.outsideLine.startPoint = oo;
  33746. }
  33747. if (ii) {
  33748. diffLine.insideLine.endPoint = this.insideLine.startPoint = ii;
  33749. }
  33750. this.hiddenStartClosedLine();
  33751. diffLine.hiddenEndClosedLine();
  33752. } else if (endCorner.end) {
  33753. console.log("endCorner.end");
  33754. if (oi) {
  33755. diffLine.insideLine.endPoint = this.outsideLine.endPoint = oi;
  33756. }
  33757. if (io) {
  33758. diffLine.outsideLine.endPoint = this.insideLine.endPoint = io;
  33759. }
  33760. this.hiddenEndClosedLine();
  33761. diffLine.hiddenEndClosedLine();
  33762. } else if (startCorner.start) {
  33763. console.log("startCorner.start");
  33764. if (io) {
  33765. diffLine.outsideLine.startPoint = this.insideLine.startPoint = io;
  33766. }
  33767. if (oi) {
  33768. diffLine.insideLine.startPoint = this.outsideLine.startPoint = oi;
  33769. }
  33770. diffLine.hiddenStartClosedLine();
  33771. this.hiddenStartClosedLine();
  33772. } else if (startCorner.end) {
  33773. console.log("startCorner.end");
  33774. if (oo) {
  33775. diffLine.outsideLine.startPoint = this.outsideLine.endPoint = oo;
  33776. }
  33777. if (ii) {
  33778. diffLine.insideLine.startPoint = this.insideLine.endPoint = ii;
  33779. }
  33780. diffLine.hiddenStartClosedLine();
  33781. this.hiddenEndClosedLine();
  33782. }
  33783. }
  33784. });
  33785. }
  33786. draw(isIntersection = true) {
  33787. if (this.isDraw)
  33788. return;
  33789. const mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  33790. if (this.outsideLine) {
  33791. this.outsideLine.erase();
  33792. }
  33793. if (this.insideLine) {
  33794. this.insideLine.erase();
  33795. }
  33796. if (!mxcad$1)
  33797. return;
  33798. this.outsideLine.trueColor = new mxcad2.McCmColor(255, 0, 0);
  33799. this.outsideId = mxcad$1.drawEntity(this.outsideLine);
  33800. this.insideLine.trueColor = new mxcad2.McCmColor(0, 255, 255);
  33801. this.insideId = mxcad$1.drawEntity(this.insideLine);
  33802. const outsideLine = this.outsideId.getMcDbEntity();
  33803. if (outsideLine)
  33804. this.outsideLine = outsideLine;
  33805. const insideLine = this.insideId.getMcDbEntity();
  33806. if (insideLine)
  33807. this.insideLine = insideLine;
  33808. this.startClosedId = mxcad$1.drawEntity(this.startClosedLine);
  33809. this.endClosedId = mxcad$1.drawEntity(this.endClosedLine);
  33810. const startClosedLine = this.startClosedId.getMcDbEntity();
  33811. if (startClosedLine)
  33812. this.startClosedLine = startClosedLine;
  33813. const endClosedLine = this.endClosedId.getMcDbEntity();
  33814. if (endClosedLine)
  33815. this.endClosedLine = endClosedLine;
  33816. mxcad$1.updateDisplay();
  33817. _WallLine.lines.add(this);
  33818. this.isDraw = true;
  33819. if (isIntersection)
  33820. this.processingIntersection();
  33821. }
  33822. remove() {
  33823. this.endClosedId && this.endClosedId.erase();
  33824. this.startClosedId && this.startClosedId.erase();
  33825. this.insideId && this.insideId.erase();
  33826. this.outsideId && this.outsideId.erase();
  33827. _WallLine.lines.delete(this);
  33828. }
  33829. };
  33830. _WallLine.lines = /* @__PURE__ */ new Set();
  33831. let WallLine = _WallLine;
  33832. class Wall {
  33833. call(param) {
  33834. if (param && param.points) {
  33835. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  33836. const points = parseParamPoints(param.points);
  33837. if (points.length < 2)
  33838. return;
  33839. points.forEach((point, index) => {
  33840. const nextLine = points[index + 1];
  33841. if (!nextLine)
  33842. return;
  33843. const wall = new WallLine(point, nextLine, param.width);
  33844. wall.draw();
  33845. });
  33846. mxcad$1.updateDisplay();
  33847. }
  33848. }
  33849. regist_data() {
  33850. return {
  33851. filename: "drawWall.json",
  33852. name: "drawWall",
  33853. description: "根据坐标点合集绘制墙",
  33854. params: [
  33855. {
  33856. name: "points",
  33857. description: "绘制墙的坐标点",
  33858. "type": "str",
  33859. "required": true
  33860. },
  33861. {
  33862. name: "width",
  33863. description: "绘制墙的宽度",
  33864. "type": "float",
  33865. "required": false
  33866. },
  33867. ...baseParams
  33868. ]
  33869. };
  33870. }
  33871. }
  33872. setTimeout(() => {
  33873. let mxcad$1 = mxcad2.MxCpp.App.getCurrentMxCAD();
  33874. mxcad$1.insertBlock(new URL("data:application/octet-stream;base64,TXhXZWIxMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA3LjAuMy4zLjIwMjMwOTA2LjEAAAAAAAAAAAAAAAAAAAMCAxEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAPAAAAe3R5cGU6MH10eHQuc2h4FgAAAHt0eXBlOjB9e2JpZ31oenR4dC5zaHgAUACVogAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABdAEAAAJ++AAAAAAAAACaeBuZm8GkzZhpilRyOJBAn4tc//5R2bFAe3kyw6fWWTAWwe1PchVprNnl8tMN/pIaWS/hZsrTh7OpqqM6DRLbNLHLv444qfqMJUFd6pQqzE/GB36X84thmjIVMBlKvqvpMFCFQBOiWYZAI4QbTgIDKHKXlbSonTHsTBcWU+YgeAjST3E5p17PW/6vaFQrxuESiD6lUcUJb3tsNa7Xyu9Z9AvP6MaOXJMHWCDPMIiVvDMqBWlZ38zKJKgqyEnUJbRr3pTur3EfRKqhJuCSOHFG1YPFoGYKLGeSeStBcHpaCU2gQJiF0HdudLQPz9VcK0wePfr5JLL390wEmhRuzwgk90fTnBUNkA1c3A+QLGL2GsZSdyZrin7sleYrIImkwmnf8eYYi4XiH8bu8GHQgOcBP3XHnsn8UsZ6YuTRmqdwbfCJS2QK/9fWC9dq6RfjZu2y/yh9/WJ860OBLFs6bcYr3gsQJRJ9sH9SUEpC2DbXL5zJalvMwYS8ZiUWMHkm2JgLvHQDQthvTtBO8cNk085/KHm+GPvpkJYI2uWgM5G67Dd89R1mJA36ajdRZoAbCi9DWaHIabFTB8uUe6EjjIw/Lih1jrDWxJwaxUWTnPpv+NzVSef2xLC1pb5UGbsYUrox9pf1zDTZGCI62UD+WqRhWtTsaT/gM0gc2BadKMORGy7AQ5gDFSedSMCezVrfEG3Jq2GX5BO8bLOJ9LtLHQ9tIYkWXb4EdGrtjEcOBrEiBIAAcSqyk8k/f59G7XTxLgGyjGe4WUiIqh4Aof8tYOzH0gBAaY3ZcK2PNePhDCcUWfgh8nf5BdDSxHab0LQyABIKJITRuzOycyh4ZWuQPNuALUTOJ3PnE5xLFJ8rBy2RmWiDhiO5JAky0TiH/mgJcgwXUB3heK8XCBBh2+hHJ9xoCh3xPIl3ltaBaDvqrZgyO+uBzPvdLOeljgbNPqlKnYykEDV+/Uc/2lgqQf5FlCyPhYaV7GSbZIROrYeGI2IBu1hxBVZhPUpFFmamGLpVo9+T7fbvuHLe1wjEBz/AysTUBsMLLcQHfTqS6uDI6EPsapoSyC9Ja+RRHiKQzJyoj3JJokdefntZ23+2/Wy6aZAGBJseTI93qtZnMxVEBuzasJeI1JtPPOs9hbTtZV5pEA7taTycqBjVZK4WjZdPfPcB22Aapi91ngktqafjIXaVWQs4VxjXjFoV9nc+pmC8dITVbJnnpNEZF+u+O3Z3olp9xgcqgdgauoHpoz4MYWzNRv7CQ6PenT0xfwOpGnNn8p/Z0SVh1np5Dj87O4BquzWCY/h+CBc+hbpFx7/ljvhyxDhOWydYPVEEQ8Z2I4RXD14VpIsjJdKXArxFs/Ml9kGun32aU7SbQQpNFdQJbFkLN3zhQYqPkPFB330qg5p4FJjNHufIDX6XeJaxU/t/oOTclmdsnnj3t82+KK2rpyRkAPgjQxl4LSzZKpIKRiLJX8x6ZLygrdGjkP5qq8VW/aFVCDhTqju/8+8aYTgPjFK7dlmiyYCYszy/QxSF2spXChXZN/qtLmfi+4h/7PcvOOxz1KYe44E1YdYi0Urmf2d2Mc2d1bQ9hHwJpEntuFsSlIII9dOtPBoZTLszMdVSfq/K2pD/amOa0MeNKdEXDKJ/6vXkBhftUfbOwxAT29dzxWZdPuXAQM2JieVzJD4TJN2jssnPocwGTnExPu+SJq2YxE0/GVm5erg67LtOxhyfw9ddqt87oceqksrppzLCMbEKOsYuDulMJ4EARLtzJmzF4Aq2cqnD6Swgy3W1Qhvk6c8WujhW+9Bg1J1ju4a5FV/aaPsp0qKtQb5JcLkmqYAJkdp3QRPzoQiRdeVLBW+rr5vclybWUY7qy2S1XJAxifQ573cvciggQ8zMH0Y4Ra2wSPrhL+ClLyMR9OlcPbtlFlt6vrvAtlPio0pFedXSPmvu8BxngBKWkux2dk7rQMlyTswH924BSaQk86y1TXQD3FlRrY3sHDSYi8zr5LcTXh9C9Fz1sgXMDU2ieYg+jAi5iXKA47VuTQp3uiKxxEdnWBiA3PK7rDQL2NCGnBAeDhpbCue6qfJeGnqHKTUzpriuxMlCLB64NV92xTls2p+COV/KNgKO5bkDu8lpGYAavW1YMgi1+zz4G0fqQYalAkNM7dKU1oXG+Ir1EumBRSqwDkhPD+NY2ZP976WZN+VBEHZSsSoYMCYjRvysX7QkAfosVzAdWAVlDgB1bZB+LNGxBrKsIK8jxp+A2sek6+rVTZSm0igaWZ5ycIzCyU/JhYiSsJlS5YvG+MV5C5DdQo0JO32YknSThUX80LuWtTohFUVPc3b+2kXzv8hsWwk09rZvYW2X6SyWWjtuciRAgVVh0zqGszaWIjwEngnkUNm45n60wRoHYyygQ2o4qWiAFnqJffiWfVkPQpAsLhgzI42rhNjwmQtGbGBuH4+SxrIkPr8oZfvmHDFTdZOrDv/80tB8jRaf+RvYrQw2reClkO8orYaXmC2R9RV2vR9CvFRoDizVVmAYfEtx7vHAblwnCJFLzb1UdxGVwOhVPILp9jLBLXFkOT6bips7we7o+6eu3DcUfBhCJ0xqfte6AFzxpbP7ucb2lAIWieKGaw/I6YI93xISXIbmA5wfOqPP+rPHSHbEVUE3LCG6BQGoO06K/onrjDToxNSHkIiKvPdg1GnFGkcGyOHXXfUiCzF6zs24ahYQzDW7WRJ3HmWhxUbD6AvbBZ2X4nPACTNgysK5/k4y6NiUUe9Pdq/KYJnHiZuRgzm512BxTtKRA/2eoOW7Hpi9sCYumYvBRFZisTYZJ0X2TnCe7QWlrTcED8q929lKCWJ8nF770jTmHWpWDPXTLjM5zL5v+BHdmT5JPVOQFLDpXSKzuj7AJ2JqJRT0u1BIV+Fw/UukTWORcPsQDC1QLNkkzI5W/jRL4rRaDZ8e+wS6LQGH9Ztt2EFB3m1ryfvak+i7FXrguXoz09Fokm+oXVLY07GtmwYqlV4BGyzPbFrKYF1BTKDDN1wzQOYtMzNDIk1+aoSnB4sxPoxqr6/lydxHdYLjr0uetm7daDcmKHEBJs3c999DxB4z1hmFDZ/zIH+qtqEonDy0BCJ0FvTTljEfCCABs9m0Fy4/3qCo7/mCXXu8Gdd69EAGt++5qZ88b43rB/Dq9rKT+VbmF1Rg6lnvwFyBGlYsW+lHw/ddv9K2UQ0eGLnrzD9ycvNfNmSX3ko0l6YioJfFl2X98yevvHV2pE70IJ3OUFND18Acq8hraEc3Wp4D1+uGFrDjtf0QPwrNfLDhFx1m+6DrcwoPvlnG5G6cNbdS6GUMyflVy4lGl/5GZPXTq5qI+aYbHWaGW2t3C7NoG0Lk2TQY2zSJIoFx/+1zPKXcI93j6VqHoEiXoFNx1TThmtw0bSs1McyWUjkPcnDLwJAxfMdB6NqVNqxU82m1wYEEyCL4ZbolEs7epDtiEAHc3zkNLtI02uIOCejTc+1agdjaZ4hufthr/q8HLo+qwAeWwiuWTC5GJO1xykhgpLCZFddHRfhR515UavDgFm35/AWydtVu/d+N78pAmRmiqrwSivcqxZ9JmnxgbJYFwqjpFPL46jPl3vpilqn+BP1cCe0NbyhCYQsMJdi/2VTudgAerpf0xE+kx7a6Ug9JiAvnx0a5ud6b4C+cuhOYRmaAPU7VEUZ3CZj3/OK04xEBNTRhHnGS2j4RWPPgcJep16Bvyxqpf0QLGv7PcP2X8XUCeE0T0OZpx450yHRy52mb9LQeCDvExkAKfXV75XakgWB520i9QP/DvmLIbkOnfZvznBPn6RZrup60uGG2vcFXVVBS2jumF/e79HXkarU1k5RV+A4AGU6nm3ksNOtOGVAetMibgBjt2Fcp8FK18NtK5BBKdbNKyaBv0M/XZGgoEiHKxRX2C0TFggUXtfIfU/WNmReSTwjHvegUIsEhZlZHxnSxX6zd8hGZEZZi5sxyKMGh/PSmK3ZbO22g3KCvnWMeKrPGLBpH/MuwsHRUHLCf7G/VTqQjZ+WkAWKbZotF/C6XyOJ1Rn1Os2kAtfTIAnDjftfkvQYv0wi4t6HSO/9kPFskSiuBO0rK/b1kLk2jkdkeh7vcH86sKleI9UMPFCec7ZcAJiwvA3VjTzilcLYFqTLfVM9kcZGCUAfx3F+1w6gzLNXMvWYibVE/RFYRqxDLSS44z6r+o0Nuhzk6FglhbjPbZw9LXLyIqix5Vxc5maYzECAVIzpyNp8vQ5PO3Jvl62swcecBlE2tiF5ziz1mPygGBTlJbThtakFwLgtK2Zdevg1W2RIEMLFaOEleRtfYLI5eO9Sz7VovMhMKJnaeqJaidqzcVlA4EmwXQczWoWxXUPNUgJPAVB4GNWrI8Y+DH0DzR9E/g8W0gmzUPvT2m0UirF1dlbo1+6lky6pmZWC0LTEWMLBJZ/1vWJzRLp+LrSn+IP++to6ilv3pjuVI/9o81Xuupu3xSWmLrdJv57t4FHYLmiH9goEkdVcA5PkUysKC0nl9gxPeubVZqz2Hu0xcf+xyg3p6R1r6FrnLm+0XYSRSuFmfTYCRfySmYSjHe2yNemVzl02Ue4a5+8WGjHwyvbiEDoOVeHQGIDei4i03ADUoUQ1fn5Lax8wa7mWb/w44r+dwSAG0irQLMlOjbU6lRicXWjHFRAyOobb7UHPEx8BuO7wD8ViHbsnk36Q1qXwj0rVhpxFZkfJnRGUikhA1g5if3f5UktkvGGCwtOXM9oYC+jzG65yAUhFBPoRCyPSuM/JXGr+ZdaMmpo9B2HJ1b4uf8FyZ3LHG8gOCi3F7FK/pj49e7iX8++pxXgNpclhZca7NMBEfSWH3Hw8oYDcqbTHwhsTTRX1aseRlexsxOP5HjixpG1rzoIU0p2E9Od8O667bD3OzJ+3cIcRN7aq2D9FSTPQ87BIVeFdvQ29BYAfwJJajubtYkD2FtBAOiGgssNXoJiXVdzPv01Y/HKIPfewjGaaXtP4i/MBrf0DwiP96bnL71BuMyALItvwsMiuugG2wlcXHwN09g8CzSv95CSiKDSMSgFbKSKJTAtPad0gMnHXXD8OwN6I1FPMj7ER+CtDBsXldfQcotwL1OD0WLgSaXqu8Kyvg+1cQV6ZNf6bSs2NKwZGMdmtCRrz2mjKzhNHA/T2f9XBIQ9P0qSBsSuujZGykUoGvvEKclDp90wsNbPRgiwLWI5CEylzqveQ6dV6f7nQO2lc7x/ZLfAj0NIiYlnH7Uaixx8lOVGvUhOY6snnyaMTj2YTzuMqSjb9qmeWpzNJcF2jLKOwT59KXtHAvh2ai7fVGyM80jtCyBGbpQk8JHF8V6dVFmum8IjE+8s8p6DJBI7u8YWqSIAnxFzR95D/AiLnmjmyEVHVXO0PPZYv31KXTIohDwlVP3sWOJK1/LsSAx0R4VlUJ9AloAABsj3EaApiVDecz4LxaWYiBbKNIGZHKe8ZaMo06uJ8SCJy6uygjJRxUkKW07oRmshiEft22HKrmUe/9j9zqvwIdUp8hoh+mNFJP2TJq01C/R7TiSi0Bd4RHCl1s354OK9LYkWbbT7p8bIk4YVTsi9NVuN9WENcFpoKW77nIwJZFFa21w7OtX9+u5C2GolXjA20N0S9yvKlq94iTlDgXpo+IMYMzkiDajti9woG6bPUqRQqWLAkxy99v3/eaYYv+XlKSwSnGuv8F64juJ3bEBXNgi092/TNJa8yJ41OCwr9AXbB/CHN+dcY3Et0Q2KTOdJDvwJ2PZpHYj9Yg4xJYHdD9nbwHdr/NACB0+Gybc6J46foWrXfWrVfcbc8eyRPcGJgUDSXWik385WpyLsJtPqNYdQyucXBZA6IB0HEiI6q3Chet7cWRSBLValAhkkJya2+bvDoJaD9ytsQuO7LoVQ6UBd66+qvFFgNsNe56pCCIlrnYGerwId5ED0FpDcjFwv/iUI4Mm5UXeFzIowmtNhh7uPUEIFd+Kzh6geuwSdMdTq8REhb3Kfuooe/mkleRjlCGQo3USyGFhrMbn9iK8VVKHEEBXRjnVfpqz08P0UlJPEk8RQAN8v/A7B7U0Wt9ICYhPu6/3bmRTQ/GsjYLCi4zqB2EdPT8U2DY3gLPRuKtHsQRXm7GhW3g+c/2w7aKUYgZUJlwrNk7KaDhLV0KZs4hjApf0EjmqrPupHj52pykMlNMFvQeZYBf3fFgV0qTfR6BBb3DmE25aN7CeKvTQ7v9zi644EttTpwZITTRJ0UonrGL/BiXwK3UPHyPNJKUoDPv68OYgUQlEI0+GBHLO8FEIeOB2vwpJ61/gEYOPJ/kce7e0z/wkfy5b22SospLW9KGtWCcpV8NzngHH/3Ef8/D8H/hXaOTGvXmnpB1xVHyEuwlvr2vp233KIfqCxezaSo970i9f+JQF1hN7P6z6pxrgLxyHtQx9OzRJAIsdP606nQ5SdYYYWtJlnnSxNKHC06u+loAVdpRi8sLMugfvTRJFM3zN9p5my6sALEwq5VtWCtC2fCH6ralFt2PNZaRpKsyxSmAr04VPloS8P6+D7IPaYFUEhmMM6sIglpFezTbl9IPeL6gZL6IR2Td+x3jc4Q50eadapDCSlvp3vQWpMOcjVaqNacgnH1wH8r97tbEabgK80B3XwRMwS2BOw7+24mNTdK3lkSrBST0N71h7dxTAP+Nz73ytaXCvj8VFr5LJrL6ld0mW4bVsVptcyNnL1Y2L+WKY+SGlS5Yxsj5fLvfy9hXZM9LpFHOz6KQqHUlRK0a+oBIGQKPiGNwBqa4pnKdWZ4xzHav6T7WwLamMSYztyu2CZJh8CKQPZcHJsNk20Nav7ZuInrhTOZLKb3dDUnEP9FN7L2TpwY67hErFUiWh19otAITOSKdRziJ/tNFvZ1ldgzXJMUiiUpLZryAxII9QeKp5QZxRzInBX2sCOZoLKo7XuvF3F2oqTI2g31zPtDGoXKmXTXvlDGhh/otKi/NCFGsuRSGGj4sHBEsNydgk2RTg1XjX8oOViRK6pHgQ1PBGpzEOB8Wm97U93opxT9wBddzDo0yqaCuEEH0jyJ8Cwj1Wx5OTab3oLk1yQCn45L9QfSZpL+QPdJrwSh+fV0EKXGcTg1dpO7GUIP8lU7HMtCrWXqf5CNKvaOEWiR8Mi1FZ9IfqBMvSJj7JBdybXI6oK1QDSqOyP5YcJs/OQU+WrnaG2ARBdIz53uUUHdxz5h595wk/peFR2+FZXY2CppCWnVyeso5UMSi/FqFEFPf3wd1Ur0gM24utARGB9SG/TrBE/TGdAd2RgDdvbGig50ujLPoJftREuVkR2puYGa4LfjlEFHu42WHukcwRHwPHv2pKy5mmq24NLiHnLCizydGoeO5qtvt47/6Sx2uxrgolbfOIXpJcjPSRPxKOrcZGBwyVzmOJ+/AuzOizW+la0VPIl0iUoZsoORG9gRyAunh4D2FTizYRjblV28ClaEyOs1P898dVFHW1PWQRic6o2zU9PgR1XnDkhI8GyaXZMgShngs7u+yrKfrd+dylJw5lFYindJ/dj4i9WxZjzDBFbl+Jnh6hFxgSr+rw8L4bZencNVULNOpzy4LUKT/7Is0HkJbdMZYyxbUXs1w2SV/N8c0zrZ/WmDxKwrfMK8uJPhzbuwFEyPSdvwi+BGhI2GjcTWzN5X27ZbJoFhdlxf5+xrVwJJLJAeKyu0Z279YHkojxES9YIwkluFc07iGigbCBh8cmwvS5ITWrOi1DWfqQhwbrqh8UxhX1MZTB330U9ZkjJbul0nM2QfgqZPfeanDcWKMjzbRZkAgFFuSY/JFjfIPFF/CpOd42RSKQ5eH0K39XFOMkK/eS8qVgrGYN6b+JZx3T5zrUa4Tc8NzUSdkDX8nRaIvlrBeI1Fq+RqnkuCD+THVGyynCX/ZS3HJUT6/YeI41CweBotCuts9nO/t1PotKejClV/7tfq1O8sSH8toKQGuLLWE5YVl5fXoYOWS9nZ+e870fqfT5VeAa8iTidjja0RqV5EtN0wz2g0ebueipXqJG/ZbGCkXyWLfxgR37SK4cM3bhOg6GsaGo3cnOmuBarZwDg3/irukg9SQzdjJhQXLVvt9MV2PmuqwUsJzNFGaDoXe+llGRiVoLgpZvUyEmwyRjyzn0XZyjl1/LM+ny4UvPy4XX6cHCFtq19WZQhDPcfJqW2dqdoybITJYT1XnO6co6o4PKdW7VztlyuMWBaTIOdyS+vzJTKyiKDbrijATvDoxjCqSEAaVM3JnGoPrIyc/jrqBFk6Z/uLoJbVwhvKk3eUM7M1hIqKhuGgXeEwW3gtzbVXrKw4cVvKq3EYnKPgqVOBGqAm2c86n6+yMO5VOidFRSJopPAhglOy5RTBhCo2Q2p1+H/px03wPXJlxEnQ0yUzjOvUX0DzvXHmTrcaY+oY4Qfv09IxBAy+3kYxpvjJV/4lqQh34FHgDXy7srIA1G3wxnNAWdxKCUtiYgJq86ONevJOQqzx8B/kK5UzUG+ijg/LcFTzbDAkZJsiVaT368jKLxvQNiMMefQWEtZs3E5DL5o2Ij/0uHHXn9Pbh+6DbgcnYKYBNuHuHNAgR/qMcjazcsxxq/bXsRmhpa8a7ZcIt03V01iEWk6Sgh93hvfuexe5W81+/Ac6ewQJ7aaVL64bs8dlgr2OetUHWe2rJGV54jzNpw0KdM9xN2B1fBDQLrA+2IIYHuPcSd5SLAwMcD8L5PDkTUtqzAgkVn1zJ8lLNGeO2PWDBd3F1fLnbZFpC0WCdnN9Z3j/yA63Xv0NhkR1rDPA7JDyFz0837HPU2bhPYYjejiKEllEilnOMVor7npXwkbpDNNWXkVsrsK+JbQRrhjeZyToTebg8OidZ87NtGIW3VCCW3DVlvdTM2Sqnb8xj6jiiDfDUZQ270tyjgPXlD+LVC77jNmmsun1tXiwbskddbjFKPoh6tFFUBT2TUqSwrb+BqxUornpz522hDg6BhagK3x3jBwzi4rl3T7Mw4dQcAt1tmIOUU18A9PIU6W4P0Quct6RKhjpmpF1OwoHoZENcau2GdpPc3501ATcirpck9qoCOK8EqI9UMLtekHn0k6LFIE+ax1NX96tOaBW57U5+a4iCki+U9d8qeAxVq3JwkEdHiEZDQ3zhQ9E+Oqa74riIG88Nci2mbwlhMBuzg6bjgqlkTn3JW/+dCWuoeuHVNQRY8HstQZz2BdU9OKTwMDoV6O1dPYMdMaxeFNussu3DueOMsMzuN4jMon2goUj6kIFnjNRw0FFn8hsAxBk9sOlZI+pdovDBdEcr77kAELEiwoxn0reM/cNumRTd1OZiRhuKmEO4Pc6NNInW87+1Y4P2kzB+hqLhkGQjYzSUMPkyTuOhqr3KphZNCJC9dPsOOpKCkPEQPjn6Bsd6vLn4RgAAPq8c0fk3h1aN2SPjkP7aGlYIEqLYh6EHSCdo13b7qKmltbSuqJdsjTEil7CvOfPXdLSCsuv3Ru+6rSslHMmdncuVG3JwJwCf3mrPWoOP70ZAqR1ZimlmryUf0DnbQb+2zFiGE15Er75uCLlsh7ErhCEgBzGrFlwFe2j8I0+KK9hAhiIL3PxlFR8GxvpCM6KGxxYSeS7j5yqKCch9He3NA1Tu05Tu/4spzP4QElyDmQa2s6pqk2nio/2Avh3hTHkekNKKp1JOZqzL04jOKr7aaaPlVxhP8qVr/vLir1CGdyBDswaKTSsTB9vOIRDIH7ixN+PKCOL6UcctaI8gAZErs2EWvrU/d83cMdbJmI3hpPOajiHrVVMPIJ6/ox0UeW7zsg7rpuot6tuBYCB5F6HhC5KR+hcILALlgckpCtVG3vet4rME6gGTpOI/sobiGU65yxOMPwofkgyuGOmcbhixrVdHMfGTm819VjaDuWJBdKvZhl9bt3WMKN756Ip8wM3F2w39y97FigtexAye+1xLj863ld1DZXc6xopv1I9WanoOnHmAnffpjiSycAaeTGoeTujt54Kpf8GNxN6ZjE9QAaO/z86W5Mdv0PgOK5i9NRgTymoo2Z0TtrGsVdr1qDu2/C72sWmWR2BwH+mM1uGsY0nmwhigax9RCAkaMPxCFJ5sOKyYl1FShS6EWV5Bv5FyZi7Q5M7DQantsY4MeKHihsLvNmxE54l5pnxee76TIdAKuLA4nj5bApUIcDfdYXauV9SjxU63mn52niGX4Ye6Ea/bvCR3reS8dPb9pG/xNczQUe9XGd8iXnBZ8T4rSa5BVqbbfT2zzLV+8fu8+NMn4HpCYElUnWK6ORxdS9pvpyF6DkgJMvBwSJ33raNFTwLebpT1PjNVleCiKAa2YIWOrQ+9hHrNPVE6GAv/eIibecP+cLyr1TnghyU4n0d+lpWMe7JYDnz1uXkhr1pXNh06Kaqnw7aV4gfXa9E5wJ0vVByoQ1+RyaEm8GQYTPbCVE+kHZFCunENKDKTomH6IAXduotzNSGEGC0dBofc6v5Z3goWdW8rSiYI04eW7ciXeOdduBCq9VlRkdhbeeBLH0JhjgL/D8pc1ffl0lH8TrNzHTFbZyCZ6Jw+/SdnGKZi/lVdRZXYx6GWmnUcyx7vHFYDLwqL7HOdl7dF/c+8juZFsBFRcUTT+Hmi5pWgjcEG+B5/Y7HZ3h5R+/8BZgPCA3mNyXhNjnkb6iaAhuXqkFH8ElRSiCPzf30+Lu5xAecppULz5XDfk+p13q383+lwzlQglDOpG4rD2e0iz7fiWCJF9SQeVe8g6DWJ0d3LNUAT7CLb0/WG9/Qj3EMj3YaOnLguZe2vRCLGzpknS6RcW+tYK2hxFmUwMQkkEv6rMN2S5XyqfrOlWNumuwo1iqaSG7FPdp5kGwI4BrbS6QYCeY7gLo7lFFgoNhTPD0jM8tIEBvrt6bI8tv0PARaIivEjXTP/Zss7IkLI6iWUwgjZplaafcTC58cairqZxZKsg/R+UxtlPp1lNj8EHcWMM8wukDGoAdt6PqBIEC3P7A/tYv9oFhztSornbHBO9ESE8SqWUbGYa08MwqhBSrBDdeXNMxkr+XAIa+Clxrik1sLA/6exK06IIYmrZ5GwbuvuqiFvkW1/SWGoIYh21tKJNA+k3oVnozIa0JOX37bFbk4wCKLTpBkRZtnMh1eKhd22nHeiYCpN0IRS2fFSvbHfXoiLzvvSDr5spr1zQ88jYgXREW8vvGaqcMPNYMP57+dWQhdmvnh6e6TBxrI7GRiCzo8hffp3Lq0EwMeh/aufKN0RDbRBZk2veSHvd3ipUQAerYWz6I4jkENDRzPwxeCRsCVbpX+1dg8eeTeRnA6mX3RsupLGEctSZE9uB2mbosDJ7sTrmUWuqwatjpjGJ23n6Ob8xA+SAh0WUOyuTeIVHHSY+XwmRdNq7nc6h3PRL0DWbOeKtklre9smuYcjwX9KIH5G7FgiIDX/za/aB4C9EvaAcjtLWbAwRKWjtavjo6UO3bKWY5+zkhiotVE+S30Trcliz/u/JwuDYBNZS55OrIc2RTqi14ZbBLslgagWU9KWHBYEWWLNOgwEJ486hTBMV3VkCGrltEZwW6Mn5Ugqj3WhASWC5o9iw5vIzICvp9wkn6BWs8lKCLLHPrT9edR2LZivH6y3U1612I//oj9npjfw42cqIhAoc/5U2uQdTbTMhuGdxrp+iguEJGKMyH3OU0wv+Ldso0n97yX8BQ/f/x/7hm7gspZTn8EeaaEiuJio1P0NnZ5iN9TlK4VKPmL1WchDnZBrZwTApGhjN0+2lb/J3q1uf+GTMbznOOTaUPAB9RF0a9yar1W2Xy2xTbINFa0j6HiiBOymouQVb4K17w+sgTNekoP+Kr0rgf8Z8g0syWHFTosOrI7zZMScjbHDjVYZoUPCh+hwlWTTtGBp6y0wdn9g6rT3auvrBnlzv1MPaiJM74tVFne9gt6nyxnHQbURJhy7Gb9ZVInm1HH7ABAqLnqUnNhZypt7AVXGg83k+coX8JfNcZ9lYQeJ8OAn7tVDD5MDZAGJp0z5V2R5wVL7D8DXxt51/0VYdVy06V+j7v5k3RK3BdoDypofI/F/Q+YPF6EIYWcdjwwUUJtOOwNQPJSHJFs6LDXSs1UcA4s72hOF9zmnmcOiii3msv8TKbm1wRafVQXb9I38YGA0uKAiU0PxboFEt0OohFeNaRCI2GRNpoevLOkbi39Nt8WoIKitTzpn4+1lbCd8ItZ1I3nuLDjmz9TjZ+pJRqF01rIeTHYC5wHf69uxhsoOL8gwnvx/N9G1YsYQnXAYgAUU0OprA3GVZRrevPltF6mg27yxgviItjf7aMejtlHXxaEqjAoK0DSBdd90/I3wjKl0A/3JVjpTBbLdo75pUGH+VfiK6R1gKBGcrkI1ZmRt5iRf156mRT6FU5Ymw3xXcT2q6ql8M3Wyo8Qk9hT9EfMFgD4/Ea22xDpiq0ZVmifUjrjncbEYpnR0Rc7Kiy8WJ5t4jFeOO+f1n73jGSe3E4BDp0h84oNjyvSs4v2vAhqMM3T1br5G59bcu8GruOXnIGYG/ArNJkBPS637kxoWSkuGvtBMG77GCttiyJWxU6R6N9Z5O2j5cmDn/OI5qSblPbniIydAkFO/fvLRVohM6AYiuR5R9dUgoG0WAjQASM8rasCsER0S1Y+fOkGYzFRjVULtKoaGTu0YOq/oPi8D3Llc8c/vZraQNtkhgWbPDE/tY4DKVWibtlcYbWjFqAaLOqs1zY7FKOBqYWNmqBDTBIBGMM1jInGGGwQpJTWhl3L4rv7chAZnsxQoDRouwkiKttbsafQ2NiNP8h/9np+Vmd3FDU9CS5+lcxB+79OKSmvieSXrV6hZyEwmChtHbu9qC2Ab4cDlRgi44lVv2wrQmCVZH+ZW8eXnJFwWF96PBrVnwaiK+lfJlhsFys7DYg1SCX3C4kzqcFZiYBDgyvHDkUiy6d+Ltf4xtMkda/3EKAmPqAPV3005NM84tj+TkB06yD4/xudp61p6q1sjb1sb5CeHxN7ZurceRufbqJiGV8R5+nl55cO4hl2JFi693lZzvDyjN6L+G6Nr4utMN57KblNKxo2tpCFpofRAe/UQI4xY9m+xNJDkMVb8zBHBPcrFEPmPsrVeJ+XYcYhG5SVJ2VUognvfKyQOsE+RUpEJHibiuh+2bUvvBHYOWErJKVZmGZvsz/6x+cg3Kz7+5KeYLNG+MFoHYYaeJzPHJHLyyneTJwz6vIcaukhbQ4JrwzmNq9bi27mdyQ8pngtUb0TsNMmHUSSHgiysNZMVZFU4BcfXaeR4xD0Da6pGBLitBCE1Yusn6IMtRNBqzkUh2QE4y+Ze6PnSyh2MUhkZZGmT7Maev8wLz7VQl3igK/afybrK1C3YMIBnDBDqlt6fM5dLMICs48qX2S7geOocHyVW12gkAUJeTlkoQcx7kFxCaaBhqx0v53t4xHS1xjzITb4ZrWtMSHtGFkks/kKPehYUKfvksas+rS/Qp3D8zTdaGPa2Ma6WOmhhoB/U1Sjfq+7+Pf94zNrRHUPmBR81w7melzqD4YX8CASyPzZWHrie3xccS8Fz9ip9wtuC94CLFw++AiB7D0dOZMSD4eQnXe5O84b2hr2ZIyv40mJA0zkQngSNMNCo3TpPvnvBCF9oHppF06j0mXKi5267F6IlSpgTeJveFVDzrAGehk//YJmCTG7bwD29N48827k8tDp+5sa+cThOAzCjPD3khHdUDaUavEhOKv/rlaF82HijIlSBrK912AAYD0+TBq0KYYAYjIazw3wl5g64X/O4WIcM7vWLbHB8Rvd8dy9riWaf3wzCni5zLZD+Xrsumvh65s4mDSfMJkiHx2Z8HXYYIBM0y7npGP/yijqsnPch+5OFzr/tvIIwKz33hMj56TRG10BZ2b7jBSnnpanRupVJOwaMEg9zHP3V9SMquX/TXMEadJAOcAQ14PEM5nKkiuG1IuTWi0JtbgYZkpQf5WDpbCRUxJCApc5I1cDnrDuMybFW4dFNV6iemp47fEG/tUtjs/TyCo6qNz74BizTO1Ew64D/58RdgZWrH18whitpPZmIKSkjBhufcGshIoDgRxczIqwQ/obz4bUu9E41iVkODe0zLaXtlKRGVKpsl658yG83+PQ6R82zRGXx9TGHAarJ9jifFabmn6sTTjfjwpg0n++aaYNFJb3qU4w0stq/NRYsAg+43/lzAhbP3QaVQWTS6MgW94bQKN6klz9OrekuKOUsL38JSuED611yCKeZQTnvYp8REtxQkgci+9txu6VmeDCdBiAk3GIYSmL1eVqDimtDgMO9SoZ0O5TRyVWZ3xJF/emOmkd2aCV6Ikphv9Qpq4udajboGrEBH4FJWU9s1RelvnYzQMCP8LT1iYsZhORIjUXFH1X8oRXRkbNm2Cx1mmsOsTF2BQVD4WWnuHaAWlj46XchlSyWPSm0UJpZjWVzxpAHy9Z0u+U/qNsbaHpFHRm4A41F/Jp22jdzlGen9VbHO019GPMl2hp09R8uINCcTwWRYFaG+zq8tB7jePGWIGVay0dANmezdy4E5ENIbE4SaxoFWpbvVsdf3buTEUXr9QMD1aTL9i1zAmQmvAm0rlAeMq2x00/gYzeOvmkHOsXoTl0p9yzmxD02JcubC0hzgHKG57JnyEDFKUgVtnLhyIin4Ab6veMO9xA+0pj3fz/MsYCaT3mYs74PHMmyWdiJCu3iUENkUK7C8cSlZRQwJvYCkc/WUZcfQ3/ApOlbYsJPhCwenjB+ovEeqe7qyXDnmO5e1lrGtgo/v4NC6DOpM1fmBTxVoAUbjwuRTg+JAj6xguq4UWmG13zzrsUui1s0NLiVu5pSU+cj3Is3orm441Rij+kjZF8/Le6lj2HbrMX4aRVMthQCFWvGvhj6lVD4riQ64S7OR8m2FvFstqFXy/sVM+WTHiSxZx8rbzgTTYTD2T4ErzM8N9C7qGwVlFgidHw6OsNvhTXVLSpQR6gAsnr9gEQ9W1n9pvi+URYXzSVvJ6+sbNDKHbgvLeNL8jrIhXTjdNFmoRfdGcnlDcWBzAz9xxXdv4RAEm3aYV4sGUTO7fax2rzHs9ClBKiRatGH+6VeThI2wENTxMy0lqD8MnCeSp9gI7k19c29AuhFkIzPo37qGStnBDDlMrmafvM3e64TZn23gD8I/aIM6g1lI+N/U7ZSG1DpMlQN8DY4N5DPesyu30oodAli3a8MO/0daIpcbX+9zf1i/8+P7u6SzWPYuc6MXx2xDtvrPPwqYgCYM8z/dJH4iC65Y20xjaj8qvfIEENT/ndu7EjBptJ3G2AlQqOilw2JW688ULIjiLy7AwMXk02hotLwyJyKDW5tEPLTd5s9aN6yJiLEVRJAmKNKDvpVfcnbho1T7KKiXVfBlvt8Ss2Rl8g/J9xCt2mIWi7iAF8LHvoFJa7qZymEhUOe6yl8n1dpBCx7Lww/Ovm8l/3WBczVSX1dUIAr4QLZWEtv+SARivcnKC/Tval+clzknKhUtfIdk02I0w9XvDsv8TLZ8luF0XjBoyfM/gm5x2w7LetEiMkSyq/WvS/8h3fC3ReWRavLNm/rk5ZKxPItZlm/QnoP+OttYxa+yczjlZ7xynew+wM1v8t45etYP4Qa9fnET2bzEZ8e6Dth8KwFIGqR3WNO4W71Ktfql244gsYUdRYV5vzZ4wlXcKdWKMW14leuMXXBOtCCemD7UCLhNa5KSK6GA5YZ+blWYH/pm9aJDI3dhe5ZY5MMqNrrBo2mSLWiNvLA0+QPQlLx4qiaYuzbj+eITttkPHzc6P7tVJiD99DK6bPjuDxARK2VHgqhZ4rxL9o9+5SqyzlSJcQ1iKtkArtKAnlrHY/Z2KwNNSVZHcg4lo3HWYwovVAVMoLHPcbA2LZal63jv+WtAXLfYbdFeqa5k1vcLBs1KeuL/FYNyoM3AKIBLuZJ023uQs5+He2AW0oGSqcO52Epca8Ovu7Y4Cxekvyifq8a9qV43DH9R3fkLSJ8NEWGg5cFtSKWHJCd0IEP9MsigTa5kEH+wLJ/J42b2jEvu0NDeUallmUA1JdJ4Xo4Dmgg8Zgs2V/Ad9b0AXrgr9A2BVOsptxxZsvDr0IIWDBRAtSpw40cfwwr82WzEQyDHmC0Q4oorrSnSTX8tNiSG/meF7CUbMwbPUAL/f30hZ+cIH3A3d51b3DWA+QxKg+thSrMFvEYDDvq1IPbXXXAxudvvDQIUsrLepPggVylgtWpiJq8PAkuBGm/0f9RxRxK3iEbsRthUFWpQPyRL6cREOXHz3ODSq4npQIU7ysU38BrxQJ71KvtMRArZE+BiQKOkRMI7vlXP+oI94q4qfEjFYlKtJKVLZp4pzbUTQq+EzqiXqSgzSKq8JXgxd2MM8/duT9Fzh9G+gyipdSO1KUEQEU6NWenYoAsLaIOwRZ8CcQi/YNGiZa/5nNoGyKdp3KLR09Bac4g/GFJ7CD0aytUax2N77nALI+J0dZU4hp0jICzGM1LQFUemP1rKDVD0r1FnPobHOkKthYf6weNnbabqYfDrXxF5vqHQ3IFNw5jTK5KCbanDRfZf9nwmTPLSWTjVSJt+NgUUKucfkLvXid6HAsON3z97CE5qxSw2+u4TsAyAWdHbrbnTCJm8jb18zTly0Ro1vgl3lfKBJL9MPj/TOlQnV31yl8sve2QF435GxLt6ny9cr56PDI5RGh6jeIPwhlaY1Sqbgf6Di42lK6wQ3lnCEqObQ6pH66mcrCrIGYtMklwQzBBAO3f1f9SUG2EKRL6GcIfN+BaGKuw6HMPnEcpZ9IY8L+g3ObnNoZgCIVfQDvpyr+vntLtPID7WoQIEVv5okUB3rbXPWBY7HNDOcTO4+/IoqXiEXrTcNxNTA4BkYt9wqkLXEjVoXo0p8hYIXbieE7lmeX544Mp25+TKy/kbn4K5lZRiXfucQjZO5uoUOcEsVDymPAneUTD3GAgZex61eIKxZD3BQXFies0jkoxQqdBx/cVrFRGK3VfHXtiMxGs70lFhER6MJ3FLizCaq6U+2BEw+/JxuFXS9ekHTKsFG3253FkyWk4/3JP+PPeALVyWj0X7kG3wjzLKD/CMqg6NCYS2eRUtelOeogop+HhG0J0e43nh2Nuf8HC5nl9Lhqf/zBF1q0zx9s4r43h9kvlOIPEutCfOHJJJ+Ude49Hv/m5xYZDNNv4//PQzeHWM5mntZ6fiDJ2P2uJy9ZNO+NC8xBZLkH/hu0kCU8P1c319MYBAENggCqAQ++N5Uam9HW7v7aWPvJ70CO/YXoW56w2gJgz30C4fCUolgPrgWa5qlBSLsuMT2wp/zwhVNniiwJx60ElHIHfax5KggtWpNK0rLIdTctJZqhj2nWKHQTquEZ7UY+K1cKTNA+bcwsKVmuUPCaLjS1PVwAky0sRQt+3fSuvHrfURpeg23kZtyLv7jHhcg5FkvT1Kr7pSvyIhl4F5Ngw4R5VED6e+B5zNcv8x69GpbLZbdk9Fb+JK450xOpO+Dqgh1zEhW1ZElJWuGq6sodYCIq7vEUid91t2r88zBoC8ocHflQoWKrbvDjvvSvq9ua+bgRZLMdCvTjyo8eoBs2iC5qJN8aZk4YzgV1fUkmtWhji2GwcN4q070Yy1/ccR4I8cuek8d7zMJBFb9K9/euZm1Em9mlSe4ak92tSarqoDhlYLsQNTuWggfbeM+jWzos4L48yuWJQ979v2zevjy48mExpg3W1zU5SXhQNVandDIEltav9+zHfcXAOIHAVQ4gMrL/F8LKw66rnpvWxnBCA1LuQ9FKngXOXr2UAQp9zKGiULYGQPrBCxqwBISr15px2fsTZb7T824dZjiM3PwLm+12SI2EXcoSuB5QrYMeAj8NIaX4MH1qdDsdLZV5s2cVI+QlraHy1/Rxv1rXx1a7jGi9FhpOhUzFu+ke8W4280QSPI8vShGbPcTJzxCA8AbzP7xNl+OgEFZDQFsNRY5bqsY7kR1VoRI09lxskqvWQ5z7S2CrobQyc7O2HlqZ1rt7iIQwR9CrgEaCZPqDGcVq6v0PJrUN14WpzoI1YY+v3idvJcn0scs39iIp2MHMiHumejg04iZiCc0MTTCJCABisj3rRFSQTT+kDBoIKDoFMIuublQ2Zgp9jc/dK39D2kHXX+fVoNe5DHUqNLN/Dzccz61QBWj8+q/Ynsq17o6k+uLMAB9/r5k2QQw+Zhi3lusF3Qnw+Hi54Anzq6vlx9KN4brFR93WNnc+pv0dyvfr287xW/bQZBFNGoUdvX3R6Eo+t9hxacaBTsBpSWYpfvOHzvYsfiCtZhMNahZWZuv/Jslt6vUhEuI0QdRlJMkGtEvtHMG9n3PmWb5g30OR1r2daf4Qx13gopDhRAh/uFVGLJLRJwBCFZQrOUsSOi1uS9gc3sldGGyjeuLwlOFiuzbFpA9twDO4gEcJ9mA4YdegbHhrZwPVL+MtCFYuCmkZk8LNJEgUIWuUEhU9wFdHOk1DXvomBtNgD19EQIng2wdTBH1XFgFiFlpnC2E6AjwAwDvHpAjAV0EWvH+4bWfeZwrUbPoywwJMGRrcfmHxqRdvwobnwSyNMLuSejapA7lr2gas1Gd4VfoLqp2ER2hWobMRRYCRSvfkxqZHn1QHw8Hf3GvfXlB512OXso8Az9JeVcoKwJgGyUDDB4wERZhr3VJSKjiRmy+o+xLAibQz2yEphmY+aKoyGoR9z6zLyYcKUm5zNqfjVALDmmZKU08cThtTtJseCIkX3FtI7TeTiZBvsGPLrCBT7TE3K567SMl+92JZYqjPySAVpnoHyjlRLm9C4i9sDUJpS/D5yYWTG2cdQjuhvh9YTWJ+TQ65OAlWDa7ReJmZ4TSAUH3JKmdiLoQ613p4W7o9ph2ufSLwsrkwrfeTLIg/TuStMYXhW1nbHmOnyGx4ES3iCXWlYv4ebYBlY8/ISEgC8C2CC/5+hZEr93nr3C4quj8jBUb03G8Fk+M4GP486WW57W5qhEF/ZpO9n5bQYbdkkWPG41s4ohRCpl5n2CoEjeIjqnhUgbq4JlsnYNzpOlgJ0GXMBr6lLUgpg8QzOp2lDYb4KTwww2KG0FRkP15j4+gmiEAgu8Yl0dQe3S5r8w55JORasg2GQ58sPUc2GYc98npui7vJ7h9dbEUI7cKjlpH3j10RddaTZgWG6rGxDrv8/XZweOrl56Ct2qGkJzOFzXm7yQ1J/IR1/2RfY59tKLvPblt/3C8fKqjIj4cCTGLnIf8vzTW0r5f3F/bEljwfcWotKp2z2p+g5/iR/po7siWv5xWetaNETqsv3c5AsBYbiKqgqh8xSl+l1dmjMlju8Gx4kkxz2sSNWotmoOvo3f5JiwjCtFusmLEgQmsqKW0hXS3yLL6E8J5yxy3wU1mSG7bDPVBFbRfAC7CF8X3AkcYEruySDP8KUEqs9XXlCRfnHKZep4oPz9hPFDWZYbHbrznLgNnw6eB7xTzytigCUNGRZuklePmG8hF74QOVkA9l2H6unT/qkwC/iZ7DkDZ6zwX5h87p52nAx4+bk2H/ZNgflSPXC7YTWCo66H78XFn0EYiP680r4TxB2ANav1dqB5EHM0k4fkn3moKsl1Y4+EKrGu2kK7x7y8cU6p99juNoG4nd2b8Tz6surtRaKMhWtptAaP2fIB/WCPhgjeEXmSsr3KucVj+xft5I5SiI8G9a+l23IbrPXUI2DKcPEu0DW8xuDOPyl8rWKW8Ek+Pmd3M9Z1fNK6z5ZTBLBVFuL4gEkVHw5BcJVOJd8EuWU5Gl52V/mJKLF0Yg7YQX+I9qZ5CAeJZxk49twwwVsG49mGSFJU+ZtmxSlTa4DoM7Gwg5tiM3KxZBYWecnpmnRpdbf/+U/+k1umJNQCwBznBTI0Cb2gJy6yDDmBgZ1AIUCzP/xVUYaG0XMkdou3k/T4EMKC0uF/LdFhGTlG0KoIw4GRO2BQwM7VKiZwGLLbgBYk8TpgTP/MPibIMF04yB8XfZ8930gLv1qrgTMHUNLwOkaS+eViSp8pb61PQzCj+S8BlE3iX0SDQRTxcaLxfDBLHN+jyh0vSG2nqlnYOzJ8wY9kz4n8MqSkOs8ksuUybe6+/kxw5jsljkZtpLKz3lI5cHwtB26cAkaLN5Cu9STICwZArrseQJixvect5mlOTOVhw/yTBqgl2jFe1tOQFTKkCyqVtCk6sJ+hjn7DTwx7C2qOucNw2Az6i04BKc0Twd1CfnXIBiUU3hUSxl8MFs0jjY9M4v2aSxU8m9Jtbgo5TIyvybbyafcOrk5/OVVwCfCyaEW4UCFobIU5USRMWVA5NPkLuVsVVw9ZxTxWQAY0BReVxV11reOPKQFMlReqlZdfpNYEEWz6hVyzNs+nqaccbhnAWy5L2844SislOnlx9TqnuJlZ4TJM6JwqFi9ht94uNOpZXGQPMpwKCYVmW/7XrlZrUUBxegsgbzhBYmRFsB3XbOu6nEDwe0TMDrw2vBJujgdti+OOh2z6gzjhCr3XRen0k9BYN0sU7BjwsmaDitBOmw4qgHWN6BhB4tf1ZL+4iephYBwG6Sw3Oh8j2ZemQDMEyCsQ7WFbKRz/BT9Lm7EFipljAsq3XhwBH65KMiVtCN3g3QHXsTwWTeeZ0IeJpCxg9z0B05nsgb50wpQQUE1eOKSyaHi7ODOJJeJOYtCS0XAvuTtRaByw2R0mLISrkg+3eBzPFk9OsPLRvq9FkNUGl4vz+VRkFxfFrdkZ12BWcnwqFMydXdTCqFfjRodw3TAM0LFGTXR0VjqEqsQfM523wOW6I/+KO3cOFWWH8dSh0aLjex8VgbBW99hgpsoQUQ5PkLmu26A125ZK1lM0okl5d0bpf3rb26oHAAR2MIScOlgo+k6zOJR3XkvERnMHs6c3kfCSg0qBAuSv3g3f3Kc4C8pUarjybSwlt1EbEsQuWVZqYLkPpMRF3DJN7Zq+OG5bZgzpYgV7nAvPbIAN5Fp+uCrtaVnWNYG/aEf3SChLPve77PbT88RB3UMapnIdHZCljAtr1TdUdzvBpguD0J1Sr3Is/RwXo2ACh+C1ZxpiHgU4zINgJ0XXX1+fmrPNmbxW+g9BBquaV3kgYv6+9jvyPsyWImkK81+75/FmCtfMjJBvKqOtEyfMOVuxVqC5jCzD88Wcjj3QypriAYNQNvvVFMQQpAzxIvcD4OAhl0rFtUBYsNHCHQISBnezxx0ZQJ/Cp25AfEwLtBpYgbTRpbJVBQXsGRwre1XC+K5DVo+pOJr9/6lfEr0bJdOWV+m4r7HTQzU4GafymiY8lFJ1wjo3H5k10nErzc2zjCMJTJ78XM+HtXnPD9rI7/EIS+3xv2t25BqTb6VzwqCbbfp1iGBl7yW7OjMtYVPrTUKcWCSYZzID7TddkY4ZpzXSEAdsFWmlWFT3FI9J3izLnFrqbdHiDRRXyQceEc4DVsYPrKaeZ+f11psAG15C7d25gAcnZlvCtFpIxUGnZLp+aPtF/xWkrXiwPICw6y4MBDv0qvcpMsiEfvjxy4nx0FkWnU6+56sIftFzL4iXFzhi9Z5xIYS+Ch1XZa5AYN/4ig6qicdqAM5q8IgZ9mvxULIIppBDGSZ0tpVBL4sVZVkZs0I562M4SEi5I1lxQOkWUJktBWc6crroswJU25Yl7jRKqfrm0u/bD3awGkNkNc4ezQmcaMdxqhUMZX+kqaaePped/5/JN2zabhUI5Xr6IcoT9xPtTjx+QnRYsWKBTlhUDQ5jf2ZHugJ/jyWa/I4URFxOPpIbV7pRitp2c5aOyAsW6aGuTzy+MSVrl/TCHlGlhJI2a56kJSmvZ8eFw8F6+1tbFS25CQC4J85uph4iYlvmvloVWnBoPV4xz+bqzIUUwE/E0Hr7ehc87Hovgh768k/gtN1uJc8lOjeyiYRdD53Pn4S2SFB8KQtnisYOnW9bWYoW8x9A4bR+59YmolCOFz0GF3K2SJYnmVt2iCTK1pqMgw3c+zWekn4OFJ+TvSHNTN4B3uh1PZGYM4ZWMaeRQK8rVY0wjGxh1YYk8jQBaWLaYErn51Acu7eAu2iiGeQmkebKpFaNuc9f0SS2TxPdzD/2ZXhLSPO6hs2TCVHT2ke/isclYcQe4wjoChaZLFwrBTkYvHvaZdC7JiV5/wGsCKHVkhnv8mOqGlyJ5cifYUp8q9agvUdFhxy8L8/ybg8F5czuiM8Oos17CRdSsOE9DQUAXkGVKRKdEOl5AcicBXkCO5lmZ4BymA3QHXN4/w8WckLgRds7c9v8uHQXPAdJqDJxqeTsz3iBoMU99hDBM7W7hGmZX6jEzjTroG4hGnhaYt2RR1JnMSSF2Yk3z0wJ0ZWab4Q=", self.location).href, "树");
  33875. }, 2e3);
  33876. class Bock {
  33877. call(param) {
  33878. return __async(this, null, function* () {
  33879. let mxcad$1 = mxcad2.MxCpp.App.getCurrentMxCAD();
  33880. if (param.name) {
  33881. const table = mxcad$1.getDatabase().getBlockTable();
  33882. const blkrecId = table.get(param.name);
  33883. if (!blkrecId)
  33884. return;
  33885. if (!blkrecId.isValid())
  33886. return;
  33887. let blkRef = new mxcad2.McDbBlockReference();
  33888. blkRef.blockTableRecordId = blkrecId;
  33889. let box = blkRef.getBoundingBox();
  33890. let oldScale = 0;
  33891. if (box.ret) {
  33892. let dLen = box.maxPt.distanceTo(box.minPt);
  33893. if (dLen > 1e-5) {
  33894. oldScale = mxcad$1.getMxDrawObject().screenCoordLong2Doc(100) / dLen;
  33895. blkRef.setScale(oldScale);
  33896. }
  33897. }
  33898. blkRef.position = new mxcad2.McGePoint3d(param.pos[0], param.pos[1]);
  33899. mxcad$1.drawEntity(blkRef);
  33900. mxcad$1.updateDisplay();
  33901. }
  33902. });
  33903. }
  33904. regist_data() {
  33905. return {
  33906. filename: "insertBock.json",
  33907. name: "insertBock",
  33908. description: "放置插入某个物品",
  33909. params: [
  33910. {
  33911. name: "name",
  33912. description: "要放置插入的物品名称",
  33913. "type": "str",
  33914. "required": true
  33915. },
  33916. {
  33917. name: "pos",
  33918. description: "要放置插入物品的位置",
  33919. "type": "tuple[float, float]",
  33920. "required": true
  33921. }
  33922. ]
  33923. };
  33924. }
  33925. }
  33926. function init$8() {
  33927. MxAiModule.regist(Wall);
  33928. MxAiModule.regist(Bock);
  33929. }
  33930. class MxAiDrawText {
  33931. call(param) {
  33932. return __async(this, null, function* () {
  33933. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  33934. console.log(param);
  33935. mxcad$1.newFile();
  33936. let objId;
  33937. const isMText = typeof param.isMText === "undefined" ? false : param.isMText;
  33938. const createMText = () => {
  33939. const mText = new mxcad2.McDbMText();
  33940. mText.textHeight = param.textSize || 100;
  33941. mText.location = param.textPos || new mxcad2.McGePoint3d();
  33942. mText.contents = param.textString || "";
  33943. return mText;
  33944. };
  33945. const createText = () => {
  33946. const text = new mxcad2.McDbText();
  33947. text.height = param.textSize || 100;
  33948. text.textString = param.textString || "";
  33949. text.position = param.textPos || new mxcad2.McGePoint3d();
  33950. return text;
  33951. };
  33952. if (!param.textString) {
  33953. const getStr = new mxcad2.MxCADUiPrString();
  33954. getStr.setMessage("请输入文字");
  33955. const text = yield getStr.go();
  33956. if (!text)
  33957. return;
  33958. param.textString = text;
  33959. }
  33960. if (!param.textPos) {
  33961. const getPoint = new mxcad2.MxCADUiPrPoint();
  33962. getPoint.clearLastInputPoint();
  33963. getPoint.setMessage("请指定文字位置");
  33964. const point = yield getPoint.go();
  33965. getPoint.setUserDraw((pt, pw) => {
  33966. param.textPos = pt;
  33967. if (isMText) {
  33968. const mText = createMText();
  33969. pw.drawMcDbEntity(mText);
  33970. } else {
  33971. const text = createText();
  33972. pw.drawMcDbEntity(text);
  33973. }
  33974. });
  33975. if (!point)
  33976. return;
  33977. param.textPos = point;
  33978. } else {
  33979. param.textPos = parsePoint(param.textPos);
  33980. }
  33981. if (!param.textSize) {
  33982. const getDist = new mxcad2.MxCADUiPrPoint();
  33983. getDist.clearLastInputPoint();
  33984. getDist.setMessage("通过线段长度确定文字高度");
  33985. const point = yield getDist.go();
  33986. if (point) {
  33987. getDist.setUserDraw((pt, pw) => {
  33988. param.textSize = point.distanceTo(pt);
  33989. if (isMText) {
  33990. const mText = createMText();
  33991. pw.drawMcDbEntity(mText);
  33992. } else {
  33993. const text = createText();
  33994. pw.drawMcDbEntity(text);
  33995. }
  33996. });
  33997. const point1 = yield getDist.go();
  33998. if (point1) {
  33999. param.textSize = point1.distanceTo(point);
  34000. }
  34001. }
  34002. }
  34003. if (isMText) {
  34004. const mText = createMText();
  34005. objId = mxcad$1.drawEntity(mText);
  34006. } else {
  34007. const text = createText();
  34008. objId = mxcad$1.drawEntity(text);
  34009. }
  34010. mergeBaseMcDbEntityProps(objId.getMcDbEntity(), param);
  34011. mxcad$1.updateDisplay();
  34012. });
  34013. }
  34014. regist_data() {
  34015. return {
  34016. filename: "drawText.json",
  34017. name: "draw_text",
  34018. description: "绘制或者插入文字或者多行文字(文本)",
  34019. params: [
  34020. {
  34021. name: "isMText",
  34022. description: "绘制的文字是否为多行文字",
  34023. "type": "boolean",
  34024. "required": true
  34025. },
  34026. {
  34027. name: "textString",
  34028. description: "绘制的文字的内容",
  34029. "type": "str",
  34030. "required": true
  34031. },
  34032. {
  34033. name: "textPos",
  34034. description: "绘制的文字的位置",
  34035. "type": "tuple[float, float]",
  34036. "required": true
  34037. },
  34038. {
  34039. name: "textSize",
  34040. description: "绘制的文字的高度",
  34041. "type": "float",
  34042. "required": true
  34043. },
  34044. ...baseParams
  34045. ]
  34046. };
  34047. }
  34048. }
  34049. function init$7() {
  34050. MxAiModule.regist(MxAiDrawText);
  34051. }
  34052. class MxAiWithdrawAndRestore {
  34053. call(param) {
  34054. console.log(param);
  34055. if (param.isWithdraw) {
  34056. if (typeof param.withdrawNum !== "number")
  34057. param.withdrawNum = 1;
  34058. for (let index = 0; index < param.withdrawNum; index++) {
  34059. mxdraw.MxFun.sendStringToExecute("Mx_Undo");
  34060. }
  34061. }
  34062. if (param.isRestore) {
  34063. if (typeof param.restoreNum !== "number")
  34064. param.restoreNum = 1;
  34065. for (let index = 0; index < param.restoreNum; index++) {
  34066. mxdraw.MxFun.sendStringToExecute("Mx_Redo");
  34067. }
  34068. }
  34069. }
  34070. regist_data() {
  34071. return {
  34072. filename: "call_withdraw_restore.json",
  34073. name: "call_withdraw_restore",
  34074. description: "撤回撤销和恢复",
  34075. params: [
  34076. {
  34077. name: "isWithdraw",
  34078. description: "是否要撤回或撤销",
  34079. "type": "boolean",
  34080. "required": true
  34081. },
  34082. {
  34083. name: "isRestore",
  34084. description: "是否要恢复",
  34085. "type": "boolean",
  34086. "required": true
  34087. },
  34088. {
  34089. name: "withdrawNum",
  34090. description: "撤回撤销(上)几步",
  34091. "type": "int",
  34092. "required": false
  34093. },
  34094. {
  34095. name: "restoreNum",
  34096. description: "恢复(前)几步",
  34097. "type": "int",
  34098. "required": false
  34099. }
  34100. ]
  34101. };
  34102. }
  34103. }
  34104. function init$6() {
  34105. MxAiModule.regist(MxAiWithdrawAndRestore);
  34106. }
  34107. class MxAiModuleType {
  34108. constructor() {
  34109. this.aryRegData = [];
  34110. }
  34111. regist(type) {
  34112. let fun = new type();
  34113. let regdata = fun.regist_data();
  34114. mxcad2.MxCpp.Ai.addFunction(regdata.name, fun.call);
  34115. this.aryRegData.push(regdata);
  34116. }
  34117. regist_server(operation_code) {
  34118. this.aryRegData.forEach((val) => {
  34119. val.operation_code = operation_code;
  34120. mxcad2.MxCpp.Ai.registTool(val);
  34121. });
  34122. mxcad2.MxCpp.Ai.reloadTools({ operation_code });
  34123. }
  34124. }
  34125. let MxAiModule = new MxAiModuleType();
  34126. function Mx_Ai() {
  34127. return __async(this, null, function* () {
  34128. let getString = new mxcad2.MxCADUiPrString();
  34129. getString.setMessage("\n human:");
  34130. let str = yield getString.go();
  34131. if (!str)
  34132. return;
  34133. mxcad2.MxCpp.Ai.chat_tool(str);
  34134. });
  34135. }
  34136. function Mx_AiRegistServer() {
  34137. return __async(this, null, function* () {
  34138. let getString = new mxcad2.MxCADUiPrString();
  34139. getString.setMessage("\n 输入 server_operate_code:");
  34140. let str = yield getString.go();
  34141. if (!str)
  34142. return;
  34143. MxAiModule.regist_server(str);
  34144. });
  34145. }
  34146. function init$5() {
  34147. mxdraw.MxFun.addCommand("Mx_Ai", Mx_Ai);
  34148. mxdraw.MxFun.addCommand("Mx_AiRegistServer", Mx_AiRegistServer);
  34149. init$e();
  34150. init$d();
  34151. init$c();
  34152. init$b();
  34153. init$9();
  34154. init$8();
  34155. init$7();
  34156. init$6();
  34157. init$a();
  34158. }
  34159. function FindBlock(pt, blks) {
  34160. let dSearch = 40;
  34161. let filter = new mxcad2.MxCADResbuf();
  34162. filter.AddString("电杆层", 0);
  34163. filter.AddString("INSERT", 5020);
  34164. let ss = new mxcad2.MxCADSelectionSet();
  34165. ss.crossingSelect(pt.x - dSearch, pt.y - dSearch, pt.x + dSearch, pt.y + dSearch, filter);
  34166. let aryFind = [];
  34167. ss.forEach((id) => {
  34168. let ent = id.getMcDbEntity();
  34169. if (ent) {
  34170. let blkRef = ent;
  34171. if (blks[blkRef.getObjectID().id]) {
  34172. aryFind.push({ dist: blkRef.position.distanceTo(pt), blk: blks[blkRef.getObjectID().id] });
  34173. }
  34174. }
  34175. });
  34176. if (aryFind.length == 0)
  34177. return void 0;
  34178. aryFind.sort((a, b) => {
  34179. return a.dist - b.dist;
  34180. });
  34181. if (aryFind[0].dist < dSearch) {
  34182. return aryFind[0].blk;
  34183. }
  34184. return false;
  34185. }
  34186. function FindLine(key, blks, lines) {
  34187. let blkdata = blks[key];
  34188. let blkref = blkdata.ref;
  34189. let dSearch = 40;
  34190. let filter = new mxcad2.MxCADResbuf();
  34191. filter.AddString("0", 0);
  34192. filter.AddString("LINE", 5020);
  34193. let ss = new mxcad2.MxCADSelectionSet();
  34194. ss.crossingSelect(blkref.position.x - dSearch, blkref.position.y - dSearch, blkref.position.x + dSearch, blkref.position.y + dSearch, filter);
  34195. ss.forEach((id) => {
  34196. let ent = id.getMcDbEntity();
  34197. if (ent) {
  34198. let line = ent;
  34199. let nexPoint = line.endPoint;
  34200. let dist = line.startPoint.distanceTo(blkref.position);
  34201. if (dist > line.endPoint.distanceTo(blkref.position)) {
  34202. dist = line.endPoint.distanceTo(blkref.position);
  34203. nexPoint = line.startPoint;
  34204. }
  34205. if (dist < dSearch) {
  34206. if (!line[line.getObjectID().id]) {
  34207. let nexBlk = FindBlock(nexPoint, blks);
  34208. if (nexBlk) {
  34209. lines[line.getObjectID().id] = { tag1: blkdata.tag, tag2: nexBlk.tag, handle: line.getHandle() };
  34210. }
  34211. }
  34212. }
  34213. }
  34214. });
  34215. }
  34216. function MxTest_UserGetData() {
  34217. return __async(this, null, function* () {
  34218. let ss = new mxcad2.MxCADSelectionSet();
  34219. let filter = new mxcad2.MxCADResbuf();
  34220. filter.AddString("电杆层", 0);
  34221. filter.AddString("INSERT", 5020);
  34222. ss.allSelect(filter);
  34223. let blks = {};
  34224. ss.forEach((id) => {
  34225. let ent = id.getMcDbEntity();
  34226. if (ent) {
  34227. let blkRef = ent;
  34228. let aryId = blkRef.getAllAttribute();
  34229. let obj = {};
  34230. aryId.forEach((id2) => {
  34231. let attribt = id2.getMcDbEntity();
  34232. if (attribt.tag == "杆号") {
  34233. obj.tag = attribt.textString;
  34234. }
  34235. });
  34236. if (obj.tag) {
  34237. obj.handle = blkRef.getHandle();
  34238. blks[id.id] = { ref: blkRef, tag: obj.tag };
  34239. console.log(obj);
  34240. }
  34241. }
  34242. });
  34243. let lines = {};
  34244. Object.keys(blks).forEach((key) => {
  34245. FindLine(key, blks, lines);
  34246. });
  34247. Object.keys(lines).forEach((key) => {
  34248. console.log(lines[key]);
  34249. });
  34250. });
  34251. }
  34252. function init$4() {
  34253. mxdraw.MxFun.addCommand("MxTest_UserGetData", MxTest_UserGetData);
  34254. }
  34255. function init$3() {
  34256. init$4();
  34257. }
  34258. class McDbGisEntity extends mxcad2.McDbCustomEntity {
  34259. create(imp) {
  34260. throw new Error("Method not implemented.");
  34261. }
  34262. getTypeName() {
  34263. throw new Error("Method not implemented.");
  34264. }
  34265. dwgInFields(filter) {
  34266. throw new Error("Method not implemented.");
  34267. }
  34268. dwgOutFields(filter) {
  34269. throw new Error("Method not implemented.");
  34270. }
  34271. worldDraw(draw) {
  34272. throw new Error("Method not implemented.");
  34273. }
  34274. }
  34275. class McDbGisPoint extends McDbGisEntity {
  34276. constructor(imp) {
  34277. super(imp);
  34278. this.pt = new mxcad2.McGePoint3d();
  34279. }
  34280. create(imp) {
  34281. return new McDbGisPoint(imp);
  34282. }
  34283. getTypeName() {
  34284. return "McDbGisPoint";
  34285. }
  34286. dwgInFields(filter) {
  34287. this.pt = filter.readPoint("pt").val;
  34288. return true;
  34289. }
  34290. dwgOutFields(filter) {
  34291. filter.writePoint("pt", this.pt);
  34292. return true;
  34293. }
  34294. moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset) {
  34295. this.assertWrite();
  34296. if (iIndex == 0) {
  34297. this.pt.x += dXOffset;
  34298. this.pt.y += dYOffset;
  34299. this.pt.z += dZOffset;
  34300. }
  34301. }
  34302. getGripPoints() {
  34303. let ret = new mxcad2.McGePoint3dArray();
  34304. ret.append(this.pt);
  34305. return ret;
  34306. }
  34307. worldDraw(draw) {
  34308. draw.drawEntity(new mxcad2.McDbPoint(this.pt));
  34309. }
  34310. //
  34311. setPoint(pt) {
  34312. this.assertWrite();
  34313. this.pt = pt.clone();
  34314. }
  34315. getPoint() {
  34316. return this.pt;
  34317. }
  34318. }
  34319. class McDbGisMultiPoint extends McDbGisEntity {
  34320. constructor(imp) {
  34321. super(imp);
  34322. this.pts = [];
  34323. }
  34324. create(imp) {
  34325. return new McDbGisMultiPoint(imp);
  34326. }
  34327. getTypeName() {
  34328. return "McDbGisMultiPoint";
  34329. }
  34330. dwgInFields(filter) {
  34331. this.pts = filter.readPoints("pts").val;
  34332. return true;
  34333. }
  34334. dwgOutFields(filter) {
  34335. filter.writePoints("pts", this.pts);
  34336. return true;
  34337. }
  34338. moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset) {
  34339. this.assertWrite();
  34340. if (iIndex >= 0 && iIndex < this.pts.length) {
  34341. this.pts[iIndex].x += dXOffset;
  34342. this.pts[iIndex].y += dYOffset;
  34343. this.pts[iIndex].z += dZOffset;
  34344. }
  34345. }
  34346. getGripPoints() {
  34347. let ret = new mxcad2.McGePoint3dArray();
  34348. this.pts.forEach((val) => {
  34349. ret.append(val);
  34350. });
  34351. return ret;
  34352. }
  34353. worldDraw(draw) {
  34354. this.pts.forEach((val) => {
  34355. draw.drawEntity(new mxcad2.McDbPoint(val));
  34356. });
  34357. }
  34358. //
  34359. setPoint(index, pt) {
  34360. this.assertWrite();
  34361. if (index >= 0 && index < this.pts.length) {
  34362. this.pts[index] = pt.clone();
  34363. }
  34364. }
  34365. getPoint(index) {
  34366. if (index >= 0 && index < this.pts.length) {
  34367. return this.pts[index];
  34368. } else {
  34369. return new mxcad2.McGePoint3d();
  34370. }
  34371. }
  34372. addPoint(pt) {
  34373. this.pts.push(pt.clone());
  34374. }
  34375. removeAllPoint() {
  34376. this.pts = [];
  34377. }
  34378. getPointCount() {
  34379. return this.pts.length;
  34380. }
  34381. }
  34382. class McDbGisLineString extends McDbGisEntity {
  34383. constructor(imp) {
  34384. super(imp);
  34385. this.pts = [];
  34386. }
  34387. create(imp) {
  34388. return new McDbGisLineString(imp);
  34389. }
  34390. getTypeName() {
  34391. return "McDbGisLineString";
  34392. }
  34393. dwgInFields(filter) {
  34394. this.pts = filter.readPoints("pts").val;
  34395. return true;
  34396. }
  34397. dwgOutFields(filter) {
  34398. filter.writePoints("pts", this.pts);
  34399. return true;
  34400. }
  34401. moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset) {
  34402. this.assertWrite();
  34403. if (iIndex >= 0 && iIndex < this.pts.length) {
  34404. this.pts[iIndex].x += dXOffset;
  34405. this.pts[iIndex].y += dYOffset;
  34406. this.pts[iIndex].z += dZOffset;
  34407. }
  34408. }
  34409. getGripPoints() {
  34410. let ret = new mxcad2.McGePoint3dArray();
  34411. this.pts.forEach((val) => {
  34412. ret.append(val);
  34413. });
  34414. return ret;
  34415. }
  34416. worldDraw(draw) {
  34417. let pl = new mxcad2.McDbPolyline();
  34418. this.pts.forEach((val) => {
  34419. pl.addVertexAt(val);
  34420. });
  34421. draw.drawEntity(pl);
  34422. }
  34423. //
  34424. setPoint(index, pt) {
  34425. this.assertWrite();
  34426. if (index >= 0 && index < this.pts.length) {
  34427. this.pts[index] = pt.clone();
  34428. }
  34429. }
  34430. getPoint(index) {
  34431. if (index >= 0 && index < this.pts.length) {
  34432. return this.pts[index];
  34433. } else {
  34434. return new mxcad2.McGePoint3d();
  34435. }
  34436. }
  34437. addPoint(pt) {
  34438. this.pts.push(pt.clone());
  34439. }
  34440. removeAllPoint() {
  34441. this.pts = [];
  34442. }
  34443. getPointCount() {
  34444. return this.pts.length;
  34445. }
  34446. }
  34447. class McDbGisMultiLineString extends McDbGisEntity {
  34448. constructor(imp) {
  34449. super(imp);
  34450. this.ptss = [];
  34451. }
  34452. create(imp) {
  34453. return new McDbGisMultiLineString(imp);
  34454. }
  34455. getTypeName() {
  34456. return "McDbGisMultiLineString";
  34457. }
  34458. dwgInFields(filter) {
  34459. this.ptss = [];
  34460. let ptss_n = filter.readLong("ptss_n");
  34461. for (let i2 = 0; i2 < ptss_n.val; i2++) {
  34462. let pts = filter.readPoints("ptss_" + i2);
  34463. if (pts.ret) {
  34464. this.ptss.push(pts.val);
  34465. }
  34466. }
  34467. return true;
  34468. }
  34469. dwgOutFields(filter) {
  34470. filter.writeLong("ptss_n", this.ptss.length);
  34471. this.ptss.forEach((pts, index) => {
  34472. filter.writePoints("ptss_" + index, pts);
  34473. });
  34474. return true;
  34475. }
  34476. moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset) {
  34477. this.assertWrite();
  34478. let iCount = 0;
  34479. for (let i2 = 0; i2 < this.ptss.length; i2++) {
  34480. let pts = this.ptss[i2];
  34481. for (let j = 0; j < pts.length; j++) {
  34482. if (iCount == iIndex) {
  34483. this.ptss[i2][j].x += dXOffset;
  34484. this.ptss[i2][j].y += dYOffset;
  34485. this.ptss[i2][j].z += dZOffset;
  34486. i2 = this.ptss.length;
  34487. break;
  34488. }
  34489. iCount++;
  34490. }
  34491. }
  34492. }
  34493. getGripPoints() {
  34494. let ret = new mxcad2.McGePoint3dArray();
  34495. this.ptss.forEach((pts) => {
  34496. pts.forEach((pt) => {
  34497. ret.append(pt);
  34498. });
  34499. });
  34500. return ret;
  34501. }
  34502. worldDraw(draw) {
  34503. for (let i2 = 0; i2 < this.ptss.length; i2++) {
  34504. let pts = this.ptss[i2];
  34505. let pl = new mxcad2.McDbPolyline();
  34506. pts.forEach((val) => {
  34507. pl.addVertexAt(val);
  34508. });
  34509. draw.drawEntity(pl);
  34510. }
  34511. }
  34512. addPoints(pts) {
  34513. this.ptss.push(pts);
  34514. }
  34515. removeAllPoint() {
  34516. this.ptss = [];
  34517. }
  34518. getPointsCount() {
  34519. return this.ptss.length;
  34520. }
  34521. getPoints(index) {
  34522. if (index >= 0 && index < this.ptss.length) {
  34523. return this.ptss[index];
  34524. } else {
  34525. return [];
  34526. }
  34527. }
  34528. }
  34529. class McDbGisPolygon extends McDbGisEntity {
  34530. constructor(imp) {
  34531. super(imp);
  34532. this.ptss = [];
  34533. }
  34534. create(imp) {
  34535. return new McDbGisPolygon(imp);
  34536. }
  34537. getTypeName() {
  34538. return "McDbGisPolygon";
  34539. }
  34540. dwgInFields(filter) {
  34541. this.ptss = [];
  34542. let ptss_n = filter.readLong("ptss_n");
  34543. for (let i2 = 0; i2 < ptss_n.val; i2++) {
  34544. let pts = filter.readPoints("ptss_" + i2);
  34545. if (pts.ret) {
  34546. this.ptss.push(pts.val);
  34547. }
  34548. }
  34549. return true;
  34550. }
  34551. dwgOutFields(filter) {
  34552. filter.writeLong("ptss_n", this.ptss.length);
  34553. this.ptss.forEach((pts, index) => {
  34554. filter.writePoints("ptss_" + index, pts);
  34555. });
  34556. return true;
  34557. }
  34558. moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset) {
  34559. this.assertWrite();
  34560. let iCount = 0;
  34561. for (let i2 = 0; i2 < this.ptss.length; i2++) {
  34562. let pts = this.ptss[i2];
  34563. for (let j = 0; j < pts.length; j++) {
  34564. if (iCount == iIndex) {
  34565. this.ptss[i2][j].x += dXOffset;
  34566. this.ptss[i2][j].y += dYOffset;
  34567. this.ptss[i2][j].z += dZOffset;
  34568. i2 = this.ptss.length;
  34569. break;
  34570. }
  34571. iCount++;
  34572. }
  34573. }
  34574. }
  34575. getGripPoints() {
  34576. let ret = new mxcad2.McGePoint3dArray();
  34577. this.ptss.forEach((pts) => {
  34578. pts.forEach((pt) => {
  34579. ret.append(pt);
  34580. });
  34581. });
  34582. return ret;
  34583. }
  34584. worldDraw(draw) {
  34585. let solid = new mxcad2.McDbHatch();
  34586. for (let i2 = 0; i2 < this.ptss.length; i2++) {
  34587. let pts = this.ptss[i2];
  34588. if (pts.length > 2) {
  34589. solid.appendLoop(new mxcad2.McGePoint3dArray(pts));
  34590. }
  34591. }
  34592. if (solid.numLoops > 0) {
  34593. draw.drawEntity(solid);
  34594. }
  34595. }
  34596. addPoints(pts) {
  34597. this.ptss.push(pts);
  34598. }
  34599. removeAllPoint() {
  34600. this.ptss = [];
  34601. }
  34602. getPointsCount() {
  34603. return this.ptss.length;
  34604. }
  34605. getPoints(index) {
  34606. if (index >= 0 && index < this.ptss.length) {
  34607. return this.ptss[index];
  34608. } else {
  34609. return [];
  34610. }
  34611. }
  34612. }
  34613. function MxGis_DrawPoint() {
  34614. return __async(this, null, function* () {
  34615. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  34616. let getPoint = new mxcad2.MxCADUiPrPoint();
  34617. getPoint.setMessage("点取一个点坐标");
  34618. let pt = yield getPoint.go();
  34619. if (pt) {
  34620. let point = new McDbGisPoint();
  34621. point.setPoint(pt);
  34622. mxcad$1.drawEntity(point);
  34623. }
  34624. });
  34625. }
  34626. function MxGis_DrawMultiPoint() {
  34627. return __async(this, null, function* () {
  34628. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  34629. let getPoint = new mxcad2.MxCADUiPrPoint();
  34630. getPoint.setMessage("点取一个点坐标");
  34631. let points = new McDbGisMultiPoint();
  34632. let aryTmpEntityId = [];
  34633. while (true) {
  34634. getPoint.clearLastInputPoint();
  34635. getPoint.setDynamicInputType(mxdraw.DynamicInputType.kXYCoordInput);
  34636. let pt = yield getPoint.go();
  34637. if (pt) {
  34638. points.addPoint(pt);
  34639. let point = new mxcad2.McDbPoint(pt);
  34640. aryTmpEntityId.push(mxcad$1.drawEntity(point));
  34641. } else {
  34642. break;
  34643. }
  34644. }
  34645. if (points.getPointCount() > 0) {
  34646. mxcad$1.drawEntity(points);
  34647. }
  34648. aryTmpEntityId.forEach((id) => {
  34649. id.erase();
  34650. });
  34651. });
  34652. }
  34653. function MxGis_DrawLineString() {
  34654. return __async(this, null, function* () {
  34655. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  34656. let getPoint = new mxcad2.MxCADUiPrPoint();
  34657. getPoint.setMessage("点取一个点坐标");
  34658. let lines = new McDbGisLineString();
  34659. let aryTmpEntityId = [];
  34660. let prvPoint = void 0;
  34661. while (true) {
  34662. if (prvPoint) {
  34663. getPoint.setBasePt(prvPoint);
  34664. getPoint.setUseBasePt(true);
  34665. }
  34666. getPoint.setDynamicInputType(mxdraw.DynamicInputType.kXYCoordInput);
  34667. let pt = yield getPoint.go();
  34668. if (pt) {
  34669. lines.addPoint(pt);
  34670. if (prvPoint) {
  34671. let line = new mxcad2.McDbLine();
  34672. line.startPoint = prvPoint;
  34673. line.endPoint = pt;
  34674. aryTmpEntityId.push(mxcad$1.drawEntity(line));
  34675. }
  34676. prvPoint = pt;
  34677. } else {
  34678. break;
  34679. }
  34680. }
  34681. if (lines.getPointCount() > 1) {
  34682. mxcad$1.drawEntity(lines);
  34683. }
  34684. aryTmpEntityId.forEach((id) => {
  34685. id.erase();
  34686. });
  34687. });
  34688. }
  34689. function MxGis_DrawMultiLineString() {
  34690. return __async(this, null, function* () {
  34691. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  34692. let getPoint = new mxcad2.MxCADUiPrPoint();
  34693. getPoint.setMessage("点取一个点坐标");
  34694. getPoint.setKeyWords("[下一段线(N)]");
  34695. let lines = new McDbGisMultiLineString();
  34696. let pts = [];
  34697. let aryTmpEntityId = [];
  34698. let prvPoint = void 0;
  34699. while (true) {
  34700. if (prvPoint) {
  34701. getPoint.setBasePt(prvPoint);
  34702. } else {
  34703. getPoint.setUseBasePt(false);
  34704. }
  34705. getPoint.setDynamicInputType(mxdraw.DynamicInputType.kXYCoordInput);
  34706. let pt = yield getPoint.go();
  34707. if (getPoint.isKeyWordPicked("N")) {
  34708. if (pts.length > 1) {
  34709. lines.addPoints(pts);
  34710. }
  34711. pts = [];
  34712. prvPoint = void 0;
  34713. } else {
  34714. if (pt) {
  34715. pts.push(pt);
  34716. if (prvPoint) {
  34717. let line = new mxcad2.McDbLine();
  34718. line.startPoint = prvPoint;
  34719. line.endPoint = pt;
  34720. aryTmpEntityId.push(mxcad$1.drawEntity(line));
  34721. }
  34722. prvPoint = pt;
  34723. } else {
  34724. break;
  34725. }
  34726. }
  34727. }
  34728. if (pts.length > 1) {
  34729. lines.addPoints(pts);
  34730. }
  34731. if (lines.getPointsCount() > 0) {
  34732. mxcad$1.drawEntity(lines);
  34733. }
  34734. aryTmpEntityId.forEach((id) => {
  34735. id.erase();
  34736. });
  34737. });
  34738. }
  34739. function MxGis_DrawPolygon() {
  34740. return __async(this, null, function* () {
  34741. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  34742. let getPoint = new mxcad2.MxCADUiPrPoint();
  34743. getPoint.setMessage("点取一个点坐标");
  34744. let polygon = new McDbGisPolygon();
  34745. let pts = [];
  34746. let aryTmpEntityId = [];
  34747. let prvPoint = void 0;
  34748. while (true) {
  34749. if (prvPoint) {
  34750. getPoint.setBasePt(prvPoint);
  34751. } else {
  34752. getPoint.setUseBasePt(false);
  34753. }
  34754. if (pts.length > 2) {
  34755. getPoint.setKeyWords("[闭合(C)/退出(E)]");
  34756. }
  34757. getPoint.setDynamicInputType(mxdraw.DynamicInputType.kXYCoordInput);
  34758. let pt = yield getPoint.go();
  34759. if (getPoint.isKeyWordPicked("C")) {
  34760. let line = new mxcad2.McDbLine();
  34761. line.startPoint = pts[0];
  34762. line.endPoint = pts[pts.length - 1];
  34763. aryTmpEntityId.push(mxcad$1.drawEntity(line));
  34764. if (pts.length > 2) {
  34765. polygon.addPoints(pts);
  34766. }
  34767. pts = [];
  34768. prvPoint = void 0;
  34769. } else if (getPoint.isKeyWordPicked("E")) {
  34770. break;
  34771. } else {
  34772. if (pt) {
  34773. pts.push(pt);
  34774. if (prvPoint) {
  34775. let line = new mxcad2.McDbLine();
  34776. line.startPoint = prvPoint;
  34777. line.endPoint = pt;
  34778. aryTmpEntityId.push(mxcad$1.drawEntity(line));
  34779. }
  34780. prvPoint = pt;
  34781. } else {
  34782. break;
  34783. }
  34784. }
  34785. }
  34786. if (pts.length > 2) {
  34787. polygon.addPoints(pts);
  34788. }
  34789. if (polygon.getPointsCount() > 0) {
  34790. mxcad$1.drawEntity(polygon);
  34791. }
  34792. aryTmpEntityId.forEach((id) => {
  34793. id.erase();
  34794. });
  34795. });
  34796. }
  34797. function MxGis_Get_geojson() {
  34798. let ss = new mxcad2.MxCADSelectionSet();
  34799. let filter = new mxcad2.MxCADResbuf();
  34800. filter.AddMcDbEntityTypes("McDbCustomEntity");
  34801. ss.allSelect(filter);
  34802. let genjson = { "type": "FeatureCollection", "features": [] };
  34803. ss.forEach((id) => {
  34804. let ent = id.getMcDbEntity();
  34805. if (!ent)
  34806. return;
  34807. if (ent instanceof McDbGisPoint) {
  34808. let point = ent;
  34809. let pt = point.getPoint();
  34810. let feature = {
  34811. "type": "Feature",
  34812. "properties": {},
  34813. "geometry": {
  34814. "type": "Point",
  34815. "coordinates": [pt.x, pt.y, pt.z]
  34816. }
  34817. };
  34818. genjson.features.push(feature);
  34819. } else if (ent instanceof McDbGisMultiPoint) {
  34820. let points = ent;
  34821. let pts = [];
  34822. let len = points.getPointCount();
  34823. for (let i2 = 0; i2 < len; i2++) {
  34824. let pt = points.getPoint(i2);
  34825. pts.push([pt.x, pt.y, pt.z]);
  34826. }
  34827. let feature = {
  34828. "type": "Feature",
  34829. "properties": {},
  34830. "geometry": {
  34831. "type": "MultiPoint",
  34832. "coordinates": pts
  34833. }
  34834. };
  34835. genjson.features.push(feature);
  34836. } else if (ent instanceof McDbGisLineString) {
  34837. let line = ent;
  34838. let pts = [];
  34839. let len = line.getPointCount();
  34840. for (let i2 = 0; i2 < len; i2++) {
  34841. let pt = line.getPoint(i2);
  34842. pts.push([pt.x, pt.y, pt.z]);
  34843. }
  34844. let feature = {
  34845. "type": "Feature",
  34846. "properties": {},
  34847. "geometry": {
  34848. "type": "LineString",
  34849. "coordinates": pts
  34850. }
  34851. };
  34852. genjson.features.push(feature);
  34853. } else if (ent instanceof McDbGisMultiLineString) {
  34854. let lines = ent;
  34855. let ptss = [];
  34856. let len = lines.getPointsCount();
  34857. for (let i2 = 0; i2 < len; i2++) {
  34858. let pts = lines.getPoints(i2);
  34859. let ary = [];
  34860. for (let j = 0; j < pts.length; j++) {
  34861. let pt = pts[j];
  34862. ary.push([pt.x, pt.y, pt.z]);
  34863. }
  34864. ptss.push(ary);
  34865. }
  34866. let feature = {
  34867. "type": "Feature",
  34868. "properties": {},
  34869. "geometry": {
  34870. "type": "MultiLineString",
  34871. "coordinates": ptss
  34872. }
  34873. };
  34874. genjson.features.push(feature);
  34875. } else if (ent instanceof McDbGisPolygon) {
  34876. let lines = ent;
  34877. let ptss = [];
  34878. let len = lines.getPointsCount();
  34879. for (let i2 = 0; i2 < len; i2++) {
  34880. let pts = lines.getPoints(i2);
  34881. let ary = [];
  34882. for (let j = 0; j < pts.length; j++) {
  34883. let pt = pts[j];
  34884. ary.push([pt.x, pt.y, pt.z]);
  34885. }
  34886. ptss.push(ary);
  34887. }
  34888. let feature = {
  34889. "type": "Feature",
  34890. "properties": {},
  34891. "geometry": {
  34892. "type": "Polygon",
  34893. "coordinates": ptss
  34894. }
  34895. };
  34896. genjson.features.push(feature);
  34897. }
  34898. });
  34899. console.log(JSON.stringify(genjson));
  34900. }
  34901. function init$2() {
  34902. mxdraw.MxFun.addCommand("MxGis_DrawPoint", MxGis_DrawPoint);
  34903. mxdraw.MxFun.addCommand("MxGis_DrawMultiPoint", MxGis_DrawMultiPoint);
  34904. mxdraw.MxFun.addCommand("MxGis_DrawLineString", MxGis_DrawLineString);
  34905. mxdraw.MxFun.addCommand("MxGis_DrawMultiLineString", MxGis_DrawMultiLineString);
  34906. mxdraw.MxFun.addCommand("MxGis_DrawPolygon", MxGis_DrawPolygon);
  34907. mxdraw.MxFun.addCommand("MxGis_Get_geojson", MxGis_Get_geojson);
  34908. new McDbGisPoint().rxInit();
  34909. new McDbGisMultiPoint().rxInit();
  34910. new McDbGisLineString().rxInit();
  34911. new McDbGisMultiLineString().rxInit();
  34912. new McDbGisPolygon().rxInit();
  34913. }
  34914. var mapboxGl = { exports: {} };
  34915. (function(module, exports2) {
  34916. (function(global2, factory) {
  34917. module.exports = factory();
  34918. })(commonjsGlobal, function() {
  34919. var shared, worker, mapboxgl2;
  34920. function define(_, chunk) {
  34921. if (!shared) {
  34922. shared = chunk;
  34923. } else if (!worker) {
  34924. worker = chunk;
  34925. } else {
  34926. var workerBundleString = "self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; (" + shared + ")(sharedChunk); (" + worker + ")(sharedChunk); self.onerror = null;";
  34927. var sharedChunk = {};
  34928. shared(sharedChunk);
  34929. mapboxgl2 = chunk(sharedChunk);
  34930. if (typeof window !== "undefined" && window && window.URL && window.URL.createObjectURL) {
  34931. mapboxgl2.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: "text/javascript" }));
  34932. }
  34933. }
  34934. }
  34935. define(["exports"], function(t) {
  34936. var e = "2.8.2", r = n;
  34937. function n(t2, e2, r2, n2) {
  34938. this.cx = 3 * t2, this.bx = 3 * (r2 - t2) - this.cx, this.ax = 1 - this.cx - this.bx, this.cy = 3 * e2, this.by = 3 * (n2 - e2) - this.cy, this.ay = 1 - this.cy - this.by, this.p1x = t2, this.p1y = n2, this.p2x = r2, this.p2y = n2;
  34939. }
  34940. n.prototype.sampleCurveX = function(t2) {
  34941. return ((this.ax * t2 + this.bx) * t2 + this.cx) * t2;
  34942. }, n.prototype.sampleCurveY = function(t2) {
  34943. return ((this.ay * t2 + this.by) * t2 + this.cy) * t2;
  34944. }, n.prototype.sampleCurveDerivativeX = function(t2) {
  34945. return (3 * this.ax * t2 + 2 * this.bx) * t2 + this.cx;
  34946. }, n.prototype.solveCurveX = function(t2, e2) {
  34947. var r2, n2, i3, s2, a2;
  34948. for (void 0 === e2 && (e2 = 1e-6), i3 = t2, a2 = 0; a2 < 8; a2++) {
  34949. if (s2 = this.sampleCurveX(i3) - t2, Math.abs(s2) < e2)
  34950. return i3;
  34951. var o2 = this.sampleCurveDerivativeX(i3);
  34952. if (Math.abs(o2) < 1e-6)
  34953. break;
  34954. i3 -= s2 / o2;
  34955. }
  34956. if ((i3 = t2) < (r2 = 0))
  34957. return r2;
  34958. if (i3 > (n2 = 1))
  34959. return n2;
  34960. for (; r2 < n2; ) {
  34961. if (s2 = this.sampleCurveX(i3), Math.abs(s2 - t2) < e2)
  34962. return i3;
  34963. t2 > s2 ? r2 = i3 : n2 = i3, i3 = 0.5 * (n2 - r2) + r2;
  34964. }
  34965. return i3;
  34966. }, n.prototype.solve = function(t2, e2) {
  34967. return this.sampleCurveY(this.solveCurveX(t2, e2));
  34968. };
  34969. var i2 = s;
  34970. function s(t2, e2) {
  34971. this.x = t2, this.y = e2;
  34972. }
  34973. s.prototype = { clone: function() {
  34974. return new s(this.x, this.y);
  34975. }, add: function(t2) {
  34976. return this.clone()._add(t2);
  34977. }, sub: function(t2) {
  34978. return this.clone()._sub(t2);
  34979. }, multByPoint: function(t2) {
  34980. return this.clone()._multByPoint(t2);
  34981. }, divByPoint: function(t2) {
  34982. return this.clone()._divByPoint(t2);
  34983. }, mult: function(t2) {
  34984. return this.clone()._mult(t2);
  34985. }, div: function(t2) {
  34986. return this.clone()._div(t2);
  34987. }, rotate: function(t2) {
  34988. return this.clone()._rotate(t2);
  34989. }, rotateAround: function(t2, e2) {
  34990. return this.clone()._rotateAround(t2, e2);
  34991. }, matMult: function(t2) {
  34992. return this.clone()._matMult(t2);
  34993. }, unit: function() {
  34994. return this.clone()._unit();
  34995. }, perp: function() {
  34996. return this.clone()._perp();
  34997. }, round: function() {
  34998. return this.clone()._round();
  34999. }, mag: function() {
  35000. return Math.sqrt(this.x * this.x + this.y * this.y);
  35001. }, equals: function(t2) {
  35002. return this.x === t2.x && this.y === t2.y;
  35003. }, dist: function(t2) {
  35004. return Math.sqrt(this.distSqr(t2));
  35005. }, distSqr: function(t2) {
  35006. var e2 = t2.x - this.x, r2 = t2.y - this.y;
  35007. return e2 * e2 + r2 * r2;
  35008. }, angle: function() {
  35009. return Math.atan2(this.y, this.x);
  35010. }, angleTo: function(t2) {
  35011. return Math.atan2(this.y - t2.y, this.x - t2.x);
  35012. }, angleWith: function(t2) {
  35013. return this.angleWithSep(t2.x, t2.y);
  35014. }, angleWithSep: function(t2, e2) {
  35015. return Math.atan2(this.x * e2 - this.y * t2, this.x * t2 + this.y * e2);
  35016. }, _matMult: function(t2) {
  35017. var e2 = t2[2] * this.x + t2[3] * this.y;
  35018. return this.x = t2[0] * this.x + t2[1] * this.y, this.y = e2, this;
  35019. }, _add: function(t2) {
  35020. return this.x += t2.x, this.y += t2.y, this;
  35021. }, _sub: function(t2) {
  35022. return this.x -= t2.x, this.y -= t2.y, this;
  35023. }, _mult: function(t2) {
  35024. return this.x *= t2, this.y *= t2, this;
  35025. }, _div: function(t2) {
  35026. return this.x /= t2, this.y /= t2, this;
  35027. }, _multByPoint: function(t2) {
  35028. return this.x *= t2.x, this.y *= t2.y, this;
  35029. }, _divByPoint: function(t2) {
  35030. return this.x /= t2.x, this.y /= t2.y, this;
  35031. }, _unit: function() {
  35032. return this._div(this.mag()), this;
  35033. }, _perp: function() {
  35034. var t2 = this.y;
  35035. return this.y = this.x, this.x = -t2, this;
  35036. }, _rotate: function(t2) {
  35037. var e2 = Math.cos(t2), r2 = Math.sin(t2), n2 = r2 * this.x + e2 * this.y;
  35038. return this.x = e2 * this.x - r2 * this.y, this.y = n2, this;
  35039. }, _rotateAround: function(t2, e2) {
  35040. var r2 = Math.cos(t2), n2 = Math.sin(t2), i3 = e2.y + n2 * (this.x - e2.x) + r2 * (this.y - e2.y);
  35041. return this.x = e2.x + r2 * (this.x - e2.x) - n2 * (this.y - e2.y), this.y = i3, this;
  35042. }, _round: function() {
  35043. return this.x = Math.round(this.x), this.y = Math.round(this.y), this;
  35044. } }, s.convert = function(t2) {
  35045. return t2 instanceof s ? t2 : Array.isArray(t2) ? new s(t2[0], t2[1]) : t2;
  35046. };
  35047. var a = "undefined" != typeof self ? self : {};
  35048. const o = Math.PI / 180, l = 180 / Math.PI;
  35049. function u(t2) {
  35050. return t2 * o;
  35051. }
  35052. function c(t2) {
  35053. return t2 * l;
  35054. }
  35055. const h = [[0, 0], [1, 0], [1, 1], [0, 1]];
  35056. function p(t2) {
  35057. if (t2 <= 0)
  35058. return 0;
  35059. if (t2 >= 1)
  35060. return 1;
  35061. const e2 = t2 * t2, r2 = e2 * t2;
  35062. return 4 * (t2 < 0.5 ? r2 : 3 * (t2 - e2) + r2 - 0.75);
  35063. }
  35064. function f(t2, e2, n2, i3) {
  35065. const s2 = new r(t2, e2, n2, i3);
  35066. return function(t3) {
  35067. return s2.solve(t3);
  35068. };
  35069. }
  35070. const d = f(0.25, 0.1, 0.25, 1);
  35071. function y(t2, e2, r2) {
  35072. return Math.min(r2, Math.max(e2, t2));
  35073. }
  35074. function m(t2, e2, r2) {
  35075. return (r2 = y((r2 - t2) / (e2 - t2), 0, 1)) * r2 * (3 - 2 * r2);
  35076. }
  35077. function g(t2, e2, r2) {
  35078. const n2 = r2 - e2, i3 = ((t2 - e2) % n2 + n2) % n2 + e2;
  35079. return i3 === e2 ? r2 : i3;
  35080. }
  35081. function x(t2, e2, r2) {
  35082. if (!t2.length)
  35083. return r2(null, []);
  35084. let n2 = t2.length;
  35085. const i3 = new Array(t2.length);
  35086. let s2 = null;
  35087. t2.forEach((t3, a2) => {
  35088. e2(t3, (t4, e3) => {
  35089. t4 && (s2 = t4), i3[a2] = e3, 0 == --n2 && r2(s2, i3);
  35090. });
  35091. });
  35092. }
  35093. function v(t2) {
  35094. const e2 = [];
  35095. for (const r2 in t2)
  35096. e2.push(t2[r2]);
  35097. return e2;
  35098. }
  35099. function b(t2, ...e2) {
  35100. for (const r2 of e2)
  35101. for (const e3 in r2)
  35102. t2[e3] = r2[e3];
  35103. return t2;
  35104. }
  35105. let _ = 1;
  35106. function w() {
  35107. return _++;
  35108. }
  35109. function A() {
  35110. return function t2(e2) {
  35111. return e2 ? (e2 ^ Math.random() * (16 >> e2 / 4)).toString(16) : ([1e7] + -[1e3] + -4e3 + -8e3 + -1e11).replace(/[018]/g, t2);
  35112. }();
  35113. }
  35114. function k(t2) {
  35115. return t2 <= 1 ? 1 : Math.pow(2, Math.ceil(Math.log(t2) / Math.LN2));
  35116. }
  35117. function S(t2) {
  35118. return !!t2 && /^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t2);
  35119. }
  35120. function I(t2, e2) {
  35121. t2.forEach((t3) => {
  35122. e2[t3] && (e2[t3] = e2[t3].bind(e2));
  35123. });
  35124. }
  35125. function M(t2, e2) {
  35126. return -1 !== t2.indexOf(e2, t2.length - e2.length);
  35127. }
  35128. function T(t2, e2, r2) {
  35129. const n2 = {};
  35130. for (const i3 in t2)
  35131. n2[i3] = e2.call(r2 || this, t2[i3], i3, t2);
  35132. return n2;
  35133. }
  35134. function z(t2, e2, r2) {
  35135. const n2 = {};
  35136. for (const i3 in t2)
  35137. e2.call(r2 || this, t2[i3], i3, t2) && (n2[i3] = t2[i3]);
  35138. return n2;
  35139. }
  35140. function B(t2) {
  35141. return Array.isArray(t2) ? t2.map(B) : "object" == typeof t2 && t2 ? T(t2, B) : t2;
  35142. }
  35143. const E = {};
  35144. function C(t2) {
  35145. E[t2] || ("undefined" != typeof console && console.warn(t2), E[t2] = true);
  35146. }
  35147. function D(t2, e2, r2) {
  35148. return (r2.y - t2.y) * (e2.x - t2.x) > (e2.y - t2.y) * (r2.x - t2.x);
  35149. }
  35150. function P(t2) {
  35151. let e2 = 0;
  35152. for (let r2, n2, i3 = 0, s2 = t2.length, a2 = s2 - 1; i3 < s2; a2 = i3++)
  35153. r2 = t2[i3], n2 = t2[a2], e2 += (n2.x - r2.x) * (r2.y + n2.y);
  35154. return e2;
  35155. }
  35156. function V() {
  35157. return "undefined" != typeof WorkerGlobalScope && "undefined" != typeof self && self instanceof WorkerGlobalScope;
  35158. }
  35159. function F(t2) {
  35160. const e2 = {};
  35161. if (t2.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g, (t3, r2, n2, i3) => {
  35162. const s2 = n2 || i3;
  35163. return e2[r2] = !s2 || s2.toLowerCase(), "";
  35164. }), e2["max-age"]) {
  35165. const t3 = parseInt(e2["max-age"], 10);
  35166. isNaN(t3) ? delete e2["max-age"] : e2["max-age"] = t3;
  35167. }
  35168. return e2;
  35169. }
  35170. let L, R, U, $, j = null;
  35171. function O(t2) {
  35172. if (null == j) {
  35173. const e2 = t2.navigator ? t2.navigator.userAgent : null;
  35174. j = !!t2.safari || !(!e2 || !(/\b(iPad|iPhone|iPod)\b/.test(e2) || e2.match("Safari") && !e2.match("Chrome")));
  35175. }
  35176. return j;
  35177. }
  35178. function q(t2) {
  35179. try {
  35180. const e2 = a[t2];
  35181. return e2.setItem("_mapbox_test_", 1), e2.removeItem("_mapbox_test_"), true;
  35182. } catch (t3) {
  35183. return false;
  35184. }
  35185. }
  35186. const N = { now: () => void 0 !== U ? U : a.performance.now(), setNow(t2) {
  35187. U = t2;
  35188. }, restoreNow() {
  35189. U = void 0;
  35190. }, frame(t2) {
  35191. const e2 = a.requestAnimationFrame(t2);
  35192. return { cancel: () => a.cancelAnimationFrame(e2) };
  35193. }, getImageData(t2, e2 = 0) {
  35194. const { width: r2, height: n2 } = t2;
  35195. $ || ($ = a.document.createElement("canvas"));
  35196. const i3 = $.getContext("2d");
  35197. if (!i3)
  35198. throw new Error("failed to create canvas 2d context");
  35199. return (r2 > $.width || n2 > $.height) && ($.width = r2, $.height = n2), i3.clearRect(-e2, -e2, r2 + 2 * e2, n2 + 2 * e2), i3.drawImage(t2, 0, 0, r2, n2), i3.getImageData(-e2, -e2, r2 + 2 * e2, n2 + 2 * e2);
  35200. }, resolveURL: (t2) => (L || (L = a.document.createElement("a")), L.href = t2, L.href), get devicePixelRatio() {
  35201. return a.devicePixelRatio;
  35202. }, get prefersReducedMotion() {
  35203. return !!a.matchMedia && (null == R && (R = a.matchMedia("(prefers-reduced-motion: reduce)")), R.matches);
  35204. } };
  35205. let G;
  35206. const Z = { API_URL: "https://api.mapbox.com", get API_URL_REGEX() {
  35207. if (null == G) {
  35208. const t2 = /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;
  35209. try {
  35210. G = null != process.env.API_URL_REGEX ? new RegExp(process.env.API_URL_REGEX) : t2;
  35211. } catch (e2) {
  35212. G = t2;
  35213. }
  35214. }
  35215. return G;
  35216. }, get EVENTS_URL() {
  35217. return this.API_URL ? 0 === this.API_URL.indexOf("https://api.mapbox.cn") ? "https://events.mapbox.cn/events/v2" : 0 === this.API_URL.indexOf("https://api.mapbox.com") ? "https://events.mapbox.com/events/v2" : null : null;
  35218. }, SESSION_PATH: "/map-sessions/v1", FEEDBACK_URL: "https://apps.mapbox.com/feedback", TILE_URL_VERSION: "v4", RASTER_URL_PREFIX: "raster/v1", REQUIRE_ACCESS_TOKEN: true, ACCESS_TOKEN: null, MAX_PARALLEL_IMAGE_REQUESTS: 16 }, X = { supported: false, testSupport: function(t2) {
  35219. !H && Y && (W ? J(t2) : K = t2);
  35220. } };
  35221. let K, Y, H = false, W = false;
  35222. function J(t2) {
  35223. const e2 = t2.createTexture();
  35224. t2.bindTexture(t2.TEXTURE_2D, e2);
  35225. try {
  35226. if (t2.texImage2D(t2.TEXTURE_2D, 0, t2.RGBA, t2.RGBA, t2.UNSIGNED_BYTE, Y), t2.isContextLost())
  35227. return;
  35228. X.supported = true;
  35229. } catch (t3) {
  35230. }
  35231. t2.deleteTexture(e2), H = true;
  35232. }
  35233. a.document && (Y = a.document.createElement("img"), Y.onload = function() {
  35234. K && J(K), K = null, W = true;
  35235. }, Y.onerror = function() {
  35236. H = true, K = null;
  35237. }, Y.src = "data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");
  35238. const Q = "01", tt = "NO_ACCESS_TOKEN";
  35239. function et(t2) {
  35240. return 0 === t2.indexOf("mapbox:");
  35241. }
  35242. function rt(t2) {
  35243. return Z.API_URL_REGEX.test(t2);
  35244. }
  35245. const nt = /^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;
  35246. function it(t2) {
  35247. const e2 = t2.match(nt);
  35248. if (!e2)
  35249. throw new Error("Unable to parse URL object");
  35250. return { protocol: e2[1], authority: e2[2], path: e2[3] || "/", params: e2[4] ? e2[4].split("&") : [] };
  35251. }
  35252. function st(t2) {
  35253. const e2 = t2.params.length ? `?${t2.params.join("&")}` : "";
  35254. return `${t2.protocol}://${t2.authority}${t2.path}${e2}`;
  35255. }
  35256. function at(t2) {
  35257. if (!t2)
  35258. return null;
  35259. const e2 = t2.split(".");
  35260. if (!e2 || 3 !== e2.length)
  35261. return null;
  35262. try {
  35263. return JSON.parse(decodeURIComponent(a.atob(e2[1]).split("").map((t3) => "%" + ("00" + t3.charCodeAt(0).toString(16)).slice(-2)).join("")));
  35264. } catch (t3) {
  35265. return null;
  35266. }
  35267. }
  35268. class ot {
  35269. constructor(t2) {
  35270. this.type = t2, this.anonId = null, this.eventData = {}, this.queue = [], this.pendingRequest = null;
  35271. }
  35272. getStorageKey(t2) {
  35273. const e2 = at(Z.ACCESS_TOKEN);
  35274. let r2 = "";
  35275. return r2 = e2 && e2.u ? a.btoa(encodeURIComponent(e2.u).replace(/%([0-9A-F]{2})/g, (t3, e3) => String.fromCharCode(Number("0x" + e3)))) : Z.ACCESS_TOKEN || "", t2 ? `mapbox.eventData.${t2}:${r2}` : `mapbox.eventData:${r2}`;
  35276. }
  35277. fetchEventData() {
  35278. const t2 = q("localStorage"), e2 = this.getStorageKey(), r2 = this.getStorageKey("uuid");
  35279. if (t2)
  35280. try {
  35281. const t3 = a.localStorage.getItem(e2);
  35282. t3 && (this.eventData = JSON.parse(t3));
  35283. const n2 = a.localStorage.getItem(r2);
  35284. n2 && (this.anonId = n2);
  35285. } catch (t3) {
  35286. C("Unable to read from LocalStorage");
  35287. }
  35288. }
  35289. saveEventData() {
  35290. const t2 = q("localStorage"), e2 = this.getStorageKey(), r2 = this.getStorageKey("uuid");
  35291. if (t2)
  35292. try {
  35293. a.localStorage.setItem(r2, this.anonId), Object.keys(this.eventData).length >= 1 && a.localStorage.setItem(e2, JSON.stringify(this.eventData));
  35294. } catch (t3) {
  35295. C("Unable to write to LocalStorage");
  35296. }
  35297. }
  35298. processRequests(t2) {
  35299. }
  35300. postEvent(t2, r2, n2, i3) {
  35301. if (!Z.EVENTS_URL)
  35302. return;
  35303. const s2 = it(Z.EVENTS_URL);
  35304. s2.params.push(`access_token=${i3 || Z.ACCESS_TOKEN || ""}`);
  35305. const a2 = { event: this.type, created: new Date(t2).toISOString(), sdkIdentifier: "mapbox-gl-js", sdkVersion: e, skuId: Q, userId: this.anonId }, o2 = r2 ? b(a2, r2) : a2, l2 = { url: st(s2), headers: { "Content-Type": "text/plain" }, body: JSON.stringify([o2]) };
  35306. this.pendingRequest = Tt(l2, (t3) => {
  35307. this.pendingRequest = null, n2(t3), this.saveEventData(), this.processRequests(i3);
  35308. });
  35309. }
  35310. queueRequest(t2, e2) {
  35311. this.queue.push(t2), this.processRequests(e2);
  35312. }
  35313. }
  35314. const lt = new class extends ot {
  35315. constructor(t2) {
  35316. super("appUserTurnstile"), this._customAccessToken = t2;
  35317. }
  35318. postTurnstileEvent(t2, e2) {
  35319. Z.EVENTS_URL && Z.ACCESS_TOKEN && Array.isArray(t2) && t2.some((t3) => et(t3) || rt(t3)) && this.queueRequest(Date.now(), e2);
  35320. }
  35321. processRequests(t2) {
  35322. if (this.pendingRequest || 0 === this.queue.length)
  35323. return;
  35324. this.anonId && this.eventData.lastSuccess && this.eventData.tokenU || this.fetchEventData();
  35325. const e2 = at(Z.ACCESS_TOKEN), r2 = e2 ? e2.u : Z.ACCESS_TOKEN;
  35326. let n2 = r2 !== this.eventData.tokenU;
  35327. S(this.anonId) || (this.anonId = A(), n2 = true);
  35328. const i3 = this.queue.shift();
  35329. if (this.eventData.lastSuccess) {
  35330. const t3 = new Date(this.eventData.lastSuccess), e3 = new Date(i3), r3 = (i3 - this.eventData.lastSuccess) / 864e5;
  35331. n2 = n2 || r3 >= 1 || r3 < -1 || t3.getDate() !== e3.getDate();
  35332. } else
  35333. n2 = true;
  35334. n2 ? this.postEvent(i3, { "enabled.telemetry": false }, (t3) => {
  35335. t3 || (this.eventData.lastSuccess = i3, this.eventData.tokenU = r2);
  35336. }, t2) : this.processRequests();
  35337. }
  35338. }(), ut = lt.postTurnstileEvent.bind(lt), ct = new class extends ot {
  35339. constructor() {
  35340. super("map.load"), this.success = {}, this.skuToken = "";
  35341. }
  35342. postMapLoadEvent(t2, e2, r2, n2) {
  35343. this.skuToken = e2, this.errorCb = n2, Z.EVENTS_URL && (r2 || Z.ACCESS_TOKEN ? this.queueRequest({ id: t2, timestamp: Date.now() }, r2) : this.errorCb(new Error(tt)));
  35344. }
  35345. processRequests(t2) {
  35346. if (this.pendingRequest || 0 === this.queue.length)
  35347. return;
  35348. const { id: e2, timestamp: r2 } = this.queue.shift();
  35349. e2 && this.success[e2] || (this.anonId || this.fetchEventData(), S(this.anonId) || (this.anonId = A()), this.postEvent(r2, { skuToken: this.skuToken }, (t3) => {
  35350. t3 ? this.errorCb(t3) : e2 && (this.success[e2] = true);
  35351. }, t2));
  35352. }
  35353. }(), ht = ct.postMapLoadEvent.bind(ct), pt = new class extends ot {
  35354. constructor() {
  35355. super("map.auth"), this.success = {}, this.skuToken = "";
  35356. }
  35357. getSession(t2, e2, r2, n2) {
  35358. if (!Z.API_URL || !Z.SESSION_PATH)
  35359. return;
  35360. const i3 = it(Z.API_URL + Z.SESSION_PATH);
  35361. i3.params.push(`sku=${e2 || ""}`), i3.params.push(`access_token=${n2 || Z.ACCESS_TOKEN || ""}`);
  35362. const s2 = { url: st(i3), headers: { "Content-Type": "text/plain" } };
  35363. this.pendingRequest = zt(s2, (t3) => {
  35364. this.pendingRequest = null, r2(t3), this.saveEventData(), this.processRequests(n2);
  35365. });
  35366. }
  35367. getSessionAPI(t2, e2, r2, n2) {
  35368. this.skuToken = e2, this.errorCb = n2, Z.SESSION_PATH && Z.API_URL && (r2 || Z.ACCESS_TOKEN ? this.queueRequest({ id: t2, timestamp: Date.now() }, r2) : this.errorCb(new Error(tt)));
  35369. }
  35370. processRequests(t2) {
  35371. if (this.pendingRequest || 0 === this.queue.length)
  35372. return;
  35373. const { id: e2, timestamp: r2 } = this.queue.shift();
  35374. e2 && this.success[e2] || this.getSession(r2, this.skuToken, (t3) => {
  35375. t3 ? this.errorCb(t3) : e2 && (this.success[e2] = true);
  35376. }, t2);
  35377. }
  35378. }(), ft = pt.getSessionAPI.bind(pt), dt = /* @__PURE__ */ new Set(), yt = "mapbox-tiles";
  35379. let mt, gt, xt = 500, vt = 50;
  35380. function bt() {
  35381. a.caches && !mt && (mt = a.caches.open(yt));
  35382. }
  35383. function _t(t2) {
  35384. const e2 = t2.indexOf("?");
  35385. return e2 < 0 ? t2 : t2.slice(0, e2);
  35386. }
  35387. let wt = 1 / 0;
  35388. const At = { Unknown: "Unknown", Style: "Style", Source: "Source", Tile: "Tile", Glyphs: "Glyphs", SpriteImage: "SpriteImage", SpriteJSON: "SpriteJSON", Image: "Image" };
  35389. "function" == typeof Object.freeze && Object.freeze(At);
  35390. class kt extends Error {
  35391. constructor(t2, e2, r2) {
  35392. 401 === e2 && rt(r2) && (t2 += ": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"), super(t2), this.status = e2, this.url = r2;
  35393. }
  35394. toString() {
  35395. return `${this.name}: ${this.message} (${this.status}): ${this.url}`;
  35396. }
  35397. }
  35398. const St = V() ? () => self.worker && self.worker.referrer : () => ("blob:" === a.location.protocol ? a.parent : a).location.href;
  35399. const It = function(t2, e2) {
  35400. if (!(/^file:/.test(r2 = t2.url) || /^file:/.test(St()) && !/^\w+:/.test(r2))) {
  35401. if (a.fetch && a.Request && a.AbortController && a.Request.prototype.hasOwnProperty("signal"))
  35402. return function(t3, e3) {
  35403. const r3 = new a.AbortController(), n2 = new a.Request(t3.url, { method: t3.method || "GET", body: t3.body, credentials: t3.credentials, headers: t3.headers, referrer: St(), signal: r3.signal });
  35404. let i3 = false, s2 = false;
  35405. const o2 = (l2 = n2.url).indexOf("sku=") > 0 && rt(l2);
  35406. var l2;
  35407. "json" === t3.type && n2.headers.set("Accept", "application/json");
  35408. const u2 = (r4, i4, l3) => {
  35409. if (s2)
  35410. return;
  35411. if (r4 && "SecurityError" !== r4.message && C(r4), i4 && l3)
  35412. return c2(i4);
  35413. const u3 = Date.now();
  35414. a.fetch(n2).then((r5) => {
  35415. if (r5.ok) {
  35416. const t4 = o2 ? r5.clone() : null;
  35417. return c2(r5, t4, u3);
  35418. }
  35419. return e3(new kt(r5.statusText, r5.status, t3.url));
  35420. }).catch((t4) => {
  35421. 20 !== t4.code && e3(new Error(t4.message));
  35422. });
  35423. }, c2 = (r4, o3, l3) => {
  35424. ("arrayBuffer" === t3.type ? r4.arrayBuffer() : "json" === t3.type ? r4.json() : r4.text()).then((t4) => {
  35425. s2 || (o3 && l3 && function(t5, e4, r5) {
  35426. if (bt(), !mt)
  35427. return;
  35428. const n3 = { status: e4.status, statusText: e4.statusText, headers: new a.Headers() };
  35429. e4.headers.forEach((t6, e5) => n3.headers.set(e5, t6));
  35430. const i4 = F(e4.headers.get("Cache-Control") || "");
  35431. if (i4["no-store"])
  35432. return;
  35433. i4["max-age"] && n3.headers.set("Expires", new Date(r5 + 1e3 * i4["max-age"]).toUTCString());
  35434. const s3 = n3.headers.get("Expires");
  35435. s3 && (new Date(s3).getTime() - r5 < 42e4 || function(t6, e5) {
  35436. if (void 0 === gt)
  35437. try {
  35438. new Response(new ReadableStream()), gt = true;
  35439. } catch (t7) {
  35440. gt = false;
  35441. }
  35442. gt ? e5(t6.body) : t6.blob().then(e5);
  35443. }(e4, (e5) => {
  35444. const r6 = new a.Response(e5, n3);
  35445. bt(), mt && mt.then((e6) => e6.put(_t(t5.url), r6)).catch((t6) => C(t6.message));
  35446. }));
  35447. }(n2, o3, l3), i3 = true, e3(null, t4, r4.headers.get("Cache-Control"), r4.headers.get("Expires")));
  35448. }).catch((t4) => {
  35449. s2 || e3(new Error(t4.message));
  35450. });
  35451. };
  35452. return o2 ? function(t4, e4) {
  35453. if (bt(), !mt)
  35454. return e4(null);
  35455. const r4 = _t(t4.url);
  35456. mt.then((t5) => {
  35457. t5.match(r4).then((n3) => {
  35458. const i4 = function(t6) {
  35459. if (!t6)
  35460. return false;
  35461. const e5 = new Date(t6.headers.get("Expires") || 0), r5 = F(t6.headers.get("Cache-Control") || "");
  35462. return e5 > Date.now() && !r5["no-cache"];
  35463. }(n3);
  35464. t5.delete(r4), i4 && t5.put(r4, n3.clone()), e4(null, n3, i4);
  35465. }).catch(e4);
  35466. }).catch(e4);
  35467. }(n2, u2) : u2(null, null), { cancel: () => {
  35468. s2 = true, i3 || r3.abort();
  35469. } };
  35470. }(t2, e2);
  35471. if (V() && self.worker && self.worker.actor)
  35472. return self.worker.actor.send("getResource", t2, e2, void 0, true);
  35473. }
  35474. var r2;
  35475. return function(t3, e3) {
  35476. const r3 = new a.XMLHttpRequest();
  35477. r3.open(t3.method || "GET", t3.url, true), "arrayBuffer" === t3.type && (r3.responseType = "arraybuffer");
  35478. for (const e4 in t3.headers)
  35479. r3.setRequestHeader(e4, t3.headers[e4]);
  35480. return "json" === t3.type && (r3.responseType = "text", r3.setRequestHeader("Accept", "application/json")), r3.withCredentials = "include" === t3.credentials, r3.onerror = () => {
  35481. e3(new Error(r3.statusText));
  35482. }, r3.onload = () => {
  35483. if ((r3.status >= 200 && r3.status < 300 || 0 === r3.status) && null !== r3.response) {
  35484. let n2 = r3.response;
  35485. if ("json" === t3.type)
  35486. try {
  35487. n2 = JSON.parse(r3.response);
  35488. } catch (t4) {
  35489. return e3(t4);
  35490. }
  35491. e3(null, n2, r3.getResponseHeader("Cache-Control"), r3.getResponseHeader("Expires"));
  35492. } else
  35493. e3(new kt(r3.statusText, r3.status, t3.url));
  35494. }, r3.send(t3.body), { cancel: () => r3.abort() };
  35495. }(t2, e2);
  35496. }, Mt = function(t2, e2) {
  35497. return It(b(t2, { type: "arrayBuffer" }), e2);
  35498. }, Tt = function(t2, e2) {
  35499. return It(b(t2, { method: "POST" }), e2);
  35500. }, zt = function(t2, e2) {
  35501. return It(b(t2, { method: "GET" }), e2);
  35502. };
  35503. function Bt(t2) {
  35504. const e2 = a.document.createElement("a");
  35505. return e2.href = t2, e2.protocol === a.document.location.protocol && e2.host === a.document.location.host;
  35506. }
  35507. const Et = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";
  35508. let Ct, Dt;
  35509. Ct = [], Dt = 0;
  35510. const Pt = function(t2, e2) {
  35511. if (X.supported && (t2.headers || (t2.headers = {}), t2.headers.accept = "image/webp,*/*"), Dt >= Z.MAX_PARALLEL_IMAGE_REQUESTS) {
  35512. const r3 = { requestParameters: t2, callback: e2, cancelled: false, cancel() {
  35513. this.cancelled = true;
  35514. } };
  35515. return Ct.push(r3), r3;
  35516. }
  35517. Dt++;
  35518. let r2 = false;
  35519. const n2 = () => {
  35520. if (!r2)
  35521. for (r2 = true, Dt--; Ct.length && Dt < Z.MAX_PARALLEL_IMAGE_REQUESTS; ) {
  35522. const t3 = Ct.shift(), { requestParameters: e3, callback: r3, cancelled: n3 } = t3;
  35523. n3 || (t3.cancel = Pt(e3, r3).cancel);
  35524. }
  35525. }, i3 = Mt(t2, (t3, r3, i4, s2) => {
  35526. n2(), t3 ? e2(t3) : r3 && (a.createImageBitmap ? function(t4, e3) {
  35527. const r4 = new a.Blob([new Uint8Array(t4)], { type: "image/png" });
  35528. a.createImageBitmap(r4).then((t5) => {
  35529. e3(null, t5);
  35530. }).catch((t5) => {
  35531. e3(new Error(`Could not load image because of ${t5.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`));
  35532. });
  35533. }(r3, (t4, r4) => e2(t4, r4, i4, s2)) : function(t4, e3) {
  35534. const r4 = new a.Image(), n3 = a.URL;
  35535. r4.onload = () => {
  35536. e3(null, r4), n3.revokeObjectURL(r4.src), r4.onload = null, a.requestAnimationFrame(() => {
  35537. r4.src = Et;
  35538. });
  35539. }, r4.onerror = () => e3(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));
  35540. const i5 = new a.Blob([new Uint8Array(t4)], { type: "image/png" });
  35541. r4.src = t4.byteLength ? n3.createObjectURL(i5) : Et;
  35542. }(r3, (t4, r4) => e2(t4, r4, i4, s2)));
  35543. });
  35544. return { cancel: () => {
  35545. i3.cancel(), n2();
  35546. } };
  35547. };
  35548. function Vt(t2, e2, r2) {
  35549. r2[t2] && -1 !== r2[t2].indexOf(e2) || (r2[t2] = r2[t2] || [], r2[t2].push(e2));
  35550. }
  35551. function Ft(t2, e2, r2) {
  35552. if (r2 && r2[t2]) {
  35553. const n2 = r2[t2].indexOf(e2);
  35554. -1 !== n2 && r2[t2].splice(n2, 1);
  35555. }
  35556. }
  35557. class Lt {
  35558. constructor(t2, e2 = {}) {
  35559. b(this, e2), this.type = t2;
  35560. }
  35561. }
  35562. class Rt extends Lt {
  35563. constructor(t2, e2 = {}) {
  35564. super("error", b({ error: t2 }, e2));
  35565. }
  35566. }
  35567. class Ut {
  35568. on(t2, e2) {
  35569. return this._listeners = this._listeners || {}, Vt(t2, e2, this._listeners), this;
  35570. }
  35571. off(t2, e2) {
  35572. return Ft(t2, e2, this._listeners), Ft(t2, e2, this._oneTimeListeners), this;
  35573. }
  35574. once(t2, e2) {
  35575. return e2 ? (this._oneTimeListeners = this._oneTimeListeners || {}, Vt(t2, e2, this._oneTimeListeners), this) : new Promise((e3) => this.once(t2, e3));
  35576. }
  35577. fire(t2, e2) {
  35578. "string" == typeof t2 && (t2 = new Lt(t2, e2 || {}));
  35579. const r2 = t2.type;
  35580. if (this.listens(r2)) {
  35581. t2.target = this;
  35582. const e3 = this._listeners && this._listeners[r2] ? this._listeners[r2].slice() : [];
  35583. for (const r3 of e3)
  35584. r3.call(this, t2);
  35585. const n2 = this._oneTimeListeners && this._oneTimeListeners[r2] ? this._oneTimeListeners[r2].slice() : [];
  35586. for (const e4 of n2)
  35587. Ft(r2, e4, this._oneTimeListeners), e4.call(this, t2);
  35588. const i3 = this._eventedParent;
  35589. i3 && (b(t2, "function" == typeof this._eventedParentData ? this._eventedParentData() : this._eventedParentData), i3.fire(t2));
  35590. } else
  35591. t2 instanceof Rt && console.error(t2.error);
  35592. return this;
  35593. }
  35594. listens(t2) {
  35595. return !!(this._listeners && this._listeners[t2] && this._listeners[t2].length > 0 || this._oneTimeListeners && this._oneTimeListeners[t2] && this._oneTimeListeners[t2].length > 0 || this._eventedParent && this._eventedParent.listens(t2));
  35596. }
  35597. setEventedParent(t2, e2) {
  35598. return this._eventedParent = t2, this._eventedParentData = e2, this;
  35599. }
  35600. }
  35601. var $t = JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":0.1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');
  35602. function jt(t2, ...e2) {
  35603. for (const r2 of e2)
  35604. for (const e3 in r2)
  35605. t2[e3] = r2[e3];
  35606. return t2;
  35607. }
  35608. function Ot(t2) {
  35609. return t2 instanceof Number || t2 instanceof String || t2 instanceof Boolean ? t2.valueOf() : t2;
  35610. }
  35611. function qt(t2) {
  35612. if (Array.isArray(t2))
  35613. return t2.map(qt);
  35614. if (t2 instanceof Object && !(t2 instanceof Number || t2 instanceof String || t2 instanceof Boolean)) {
  35615. const e2 = {};
  35616. for (const r2 in t2)
  35617. e2[r2] = qt(t2[r2]);
  35618. return e2;
  35619. }
  35620. return Ot(t2);
  35621. }
  35622. class Nt extends Error {
  35623. constructor(t2, e2) {
  35624. super(e2), this.message = e2, this.key = t2;
  35625. }
  35626. }
  35627. class Gt {
  35628. constructor(t2, e2 = []) {
  35629. this.parent = t2, this.bindings = {};
  35630. for (const [t3, r2] of e2)
  35631. this.bindings[t3] = r2;
  35632. }
  35633. concat(t2) {
  35634. return new Gt(this, t2);
  35635. }
  35636. get(t2) {
  35637. if (this.bindings[t2])
  35638. return this.bindings[t2];
  35639. if (this.parent)
  35640. return this.parent.get(t2);
  35641. throw new Error(`${t2} not found in scope.`);
  35642. }
  35643. has(t2) {
  35644. return !!this.bindings[t2] || !!this.parent && this.parent.has(t2);
  35645. }
  35646. }
  35647. const Zt = { kind: "null" }, Xt = { kind: "number" }, Kt = { kind: "string" }, Yt = { kind: "boolean" }, Ht = { kind: "color" }, Wt = { kind: "object" }, Jt = { kind: "value" }, Qt = { kind: "collator" }, te = { kind: "formatted" }, ee = { kind: "resolvedImage" };
  35648. function re(t2, e2) {
  35649. return { kind: "array", itemType: t2, N: e2 };
  35650. }
  35651. function ne(t2) {
  35652. if ("array" === t2.kind) {
  35653. const e2 = ne(t2.itemType);
  35654. return "number" == typeof t2.N ? `array<${e2}, ${t2.N}>` : "value" === t2.itemType.kind ? "array" : `array<${e2}>`;
  35655. }
  35656. return t2.kind;
  35657. }
  35658. const ie = [Zt, Xt, Kt, Yt, Ht, te, Wt, re(Jt), ee];
  35659. function se(t2, e2) {
  35660. if ("error" === e2.kind)
  35661. return null;
  35662. if ("array" === t2.kind) {
  35663. if ("array" === e2.kind && (0 === e2.N && "value" === e2.itemType.kind || !se(t2.itemType, e2.itemType)) && ("number" != typeof t2.N || t2.N === e2.N))
  35664. return null;
  35665. } else {
  35666. if (t2.kind === e2.kind)
  35667. return null;
  35668. if ("value" === t2.kind) {
  35669. for (const t3 of ie)
  35670. if (!se(t3, e2))
  35671. return null;
  35672. }
  35673. }
  35674. return `Expected ${ne(t2)} but found ${ne(e2)} instead.`;
  35675. }
  35676. function ae(t2, e2) {
  35677. return e2.some((e3) => e3.kind === t2.kind);
  35678. }
  35679. function oe(t2, e2) {
  35680. return e2.some((e3) => "null" === e3 ? null === t2 : "array" === e3 ? Array.isArray(t2) : "object" === e3 ? t2 && !Array.isArray(t2) && "object" == typeof t2 : e3 === typeof t2);
  35681. }
  35682. function le(t2) {
  35683. var e2 = { exports: {} };
  35684. return t2(e2, e2.exports), e2.exports;
  35685. }
  35686. var ue = le(function(t2, e2) {
  35687. var r2 = { transparent: [0, 0, 0, 0], aliceblue: [240, 248, 255, 1], antiquewhite: [250, 235, 215, 1], aqua: [0, 255, 255, 1], aquamarine: [127, 255, 212, 1], azure: [240, 255, 255, 1], beige: [245, 245, 220, 1], bisque: [255, 228, 196, 1], black: [0, 0, 0, 1], blanchedalmond: [255, 235, 205, 1], blue: [0, 0, 255, 1], blueviolet: [138, 43, 226, 1], brown: [165, 42, 42, 1], burlywood: [222, 184, 135, 1], cadetblue: [95, 158, 160, 1], chartreuse: [127, 255, 0, 1], chocolate: [210, 105, 30, 1], coral: [255, 127, 80, 1], cornflowerblue: [100, 149, 237, 1], cornsilk: [255, 248, 220, 1], crimson: [220, 20, 60, 1], cyan: [0, 255, 255, 1], darkblue: [0, 0, 139, 1], darkcyan: [0, 139, 139, 1], darkgoldenrod: [184, 134, 11, 1], darkgray: [169, 169, 169, 1], darkgreen: [0, 100, 0, 1], darkgrey: [169, 169, 169, 1], darkkhaki: [189, 183, 107, 1], darkmagenta: [139, 0, 139, 1], darkolivegreen: [85, 107, 47, 1], darkorange: [255, 140, 0, 1], darkorchid: [153, 50, 204, 1], darkred: [139, 0, 0, 1], darksalmon: [233, 150, 122, 1], darkseagreen: [143, 188, 143, 1], darkslateblue: [72, 61, 139, 1], darkslategray: [47, 79, 79, 1], darkslategrey: [47, 79, 79, 1], darkturquoise: [0, 206, 209, 1], darkviolet: [148, 0, 211, 1], deeppink: [255, 20, 147, 1], deepskyblue: [0, 191, 255, 1], dimgray: [105, 105, 105, 1], dimgrey: [105, 105, 105, 1], dodgerblue: [30, 144, 255, 1], firebrick: [178, 34, 34, 1], floralwhite: [255, 250, 240, 1], forestgreen: [34, 139, 34, 1], fuchsia: [255, 0, 255, 1], gainsboro: [220, 220, 220, 1], ghostwhite: [248, 248, 255, 1], gold: [255, 215, 0, 1], goldenrod: [218, 165, 32, 1], gray: [128, 128, 128, 1], green: [0, 128, 0, 1], greenyellow: [173, 255, 47, 1], grey: [128, 128, 128, 1], honeydew: [240, 255, 240, 1], hotpink: [255, 105, 180, 1], indianred: [205, 92, 92, 1], indigo: [75, 0, 130, 1], ivory: [255, 255, 240, 1], khaki: [240, 230, 140, 1], lavender: [230, 230, 250, 1], lavenderblush: [255, 240, 245, 1], lawngreen: [124, 252, 0, 1], lemonchiffon: [255, 250, 205, 1], lightblue: [173, 216, 230, 1], lightcoral: [240, 128, 128, 1], lightcyan: [224, 255, 255, 1], lightgoldenrodyellow: [250, 250, 210, 1], lightgray: [211, 211, 211, 1], lightgreen: [144, 238, 144, 1], lightgrey: [211, 211, 211, 1], lightpink: [255, 182, 193, 1], lightsalmon: [255, 160, 122, 1], lightseagreen: [32, 178, 170, 1], lightskyblue: [135, 206, 250, 1], lightslategray: [119, 136, 153, 1], lightslategrey: [119, 136, 153, 1], lightsteelblue: [176, 196, 222, 1], lightyellow: [255, 255, 224, 1], lime: [0, 255, 0, 1], limegreen: [50, 205, 50, 1], linen: [250, 240, 230, 1], magenta: [255, 0, 255, 1], maroon: [128, 0, 0, 1], mediumaquamarine: [102, 205, 170, 1], mediumblue: [0, 0, 205, 1], mediumorchid: [186, 85, 211, 1], mediumpurple: [147, 112, 219, 1], mediumseagreen: [60, 179, 113, 1], mediumslateblue: [123, 104, 238, 1], mediumspringgreen: [0, 250, 154, 1], mediumturquoise: [72, 209, 204, 1], mediumvioletred: [199, 21, 133, 1], midnightblue: [25, 25, 112, 1], mintcream: [245, 255, 250, 1], mistyrose: [255, 228, 225, 1], moccasin: [255, 228, 181, 1], navajowhite: [255, 222, 173, 1], navy: [0, 0, 128, 1], oldlace: [253, 245, 230, 1], olive: [128, 128, 0, 1], olivedrab: [107, 142, 35, 1], orange: [255, 165, 0, 1], orangered: [255, 69, 0, 1], orchid: [218, 112, 214, 1], palegoldenrod: [238, 232, 170, 1], palegreen: [152, 251, 152, 1], paleturquoise: [175, 238, 238, 1], palevioletred: [219, 112, 147, 1], papayawhip: [255, 239, 213, 1], peachpuff: [255, 218, 185, 1], peru: [205, 133, 63, 1], pink: [255, 192, 203, 1], plum: [221, 160, 221, 1], powderblue: [176, 224, 230, 1], purple: [128, 0, 128, 1], rebeccapurple: [102, 51, 153, 1], red: [255, 0, 0, 1], rosybrown: [188, 143, 143, 1], royalblue: [65, 105, 225, 1], saddlebrown: [139, 69, 19, 1], salmon: [250, 128, 114, 1], sandybrown: [244, 164, 96, 1], seagreen: [46, 139, 87, 1], seashell: [255, 245, 238, 1], sienna: [160, 82, 45, 1], silver: [192, 192, 192, 1], skyblue: [135, 206, 235, 1], slateblue: [106, 90, 205, 1], slategray: [112, 128, 144, 1], slategrey: [112, 128, 144, 1], snow: [255, 250, 250, 1], springgreen: [0, 255, 127, 1], steelblue: [70, 130, 180, 1], tan: [210, 180, 140, 1], teal: [0, 128, 128, 1], thistle: [216, 191, 216, 1], tomato: [255, 99, 71, 1], turquoise: [64, 224, 208, 1], violet: [238, 130, 238, 1], wheat: [245, 222, 179, 1], white: [255, 255, 255, 1], whitesmoke: [245, 245, 245, 1], yellow: [255, 255, 0, 1], yellowgreen: [154, 205, 50, 1] };
  35688. function n2(t3) {
  35689. return (t3 = Math.round(t3)) < 0 ? 0 : t3 > 255 ? 255 : t3;
  35690. }
  35691. function i3(t3) {
  35692. return n2("%" === t3[t3.length - 1] ? parseFloat(t3) / 100 * 255 : parseInt(t3));
  35693. }
  35694. function s2(t3) {
  35695. return (e3 = "%" === t3[t3.length - 1] ? parseFloat(t3) / 100 : parseFloat(t3)) < 0 ? 0 : e3 > 1 ? 1 : e3;
  35696. var e3;
  35697. }
  35698. function a2(t3, e3, r3) {
  35699. return r3 < 0 ? r3 += 1 : r3 > 1 && (r3 -= 1), 6 * r3 < 1 ? t3 + (e3 - t3) * r3 * 6 : 2 * r3 < 1 ? e3 : 3 * r3 < 2 ? t3 + (e3 - t3) * (2 / 3 - r3) * 6 : t3;
  35700. }
  35701. try {
  35702. e2.parseCSSColor = function(t3) {
  35703. var e3, o2 = t3.replace(/ /g, "").toLowerCase();
  35704. if (o2 in r2)
  35705. return r2[o2].slice();
  35706. if ("#" === o2[0])
  35707. return 4 === o2.length ? (e3 = parseInt(o2.substr(1), 16)) >= 0 && e3 <= 4095 ? [(3840 & e3) >> 4 | (3840 & e3) >> 8, 240 & e3 | (240 & e3) >> 4, 15 & e3 | (15 & e3) << 4, 1] : null : 7 === o2.length && (e3 = parseInt(o2.substr(1), 16)) >= 0 && e3 <= 16777215 ? [(16711680 & e3) >> 16, (65280 & e3) >> 8, 255 & e3, 1] : null;
  35708. var l2 = o2.indexOf("("), u2 = o2.indexOf(")");
  35709. if (-1 !== l2 && u2 + 1 === o2.length) {
  35710. var c2 = o2.substr(0, l2), h2 = o2.substr(l2 + 1, u2 - (l2 + 1)).split(","), p2 = 1;
  35711. switch (c2) {
  35712. case "rgba":
  35713. if (4 !== h2.length)
  35714. return null;
  35715. p2 = s2(h2.pop());
  35716. case "rgb":
  35717. return 3 !== h2.length ? null : [i3(h2[0]), i3(h2[1]), i3(h2[2]), p2];
  35718. case "hsla":
  35719. if (4 !== h2.length)
  35720. return null;
  35721. p2 = s2(h2.pop());
  35722. case "hsl":
  35723. if (3 !== h2.length)
  35724. return null;
  35725. var f2 = (parseFloat(h2[0]) % 360 + 360) % 360 / 360, d2 = s2(h2[1]), y2 = s2(h2[2]), m2 = y2 <= 0.5 ? y2 * (d2 + 1) : y2 + d2 - y2 * d2, g2 = 2 * y2 - m2;
  35726. return [n2(255 * a2(g2, m2, f2 + 1 / 3)), n2(255 * a2(g2, m2, f2)), n2(255 * a2(g2, m2, f2 - 1 / 3)), p2];
  35727. default:
  35728. return null;
  35729. }
  35730. }
  35731. return null;
  35732. };
  35733. } catch (t3) {
  35734. }
  35735. });
  35736. class ce {
  35737. constructor(t2, e2, r2, n2 = 1) {
  35738. this.r = t2, this.g = e2, this.b = r2, this.a = n2;
  35739. }
  35740. static parse(t2) {
  35741. if (!t2)
  35742. return;
  35743. if (t2 instanceof ce)
  35744. return t2;
  35745. if ("string" != typeof t2)
  35746. return;
  35747. const e2 = ue.parseCSSColor(t2);
  35748. return e2 ? new ce(e2[0] / 255 * e2[3], e2[1] / 255 * e2[3], e2[2] / 255 * e2[3], e2[3]) : void 0;
  35749. }
  35750. toString() {
  35751. const [t2, e2, r2, n2] = this.toArray();
  35752. return `rgba(${Math.round(t2)},${Math.round(e2)},${Math.round(r2)},${n2})`;
  35753. }
  35754. toArray() {
  35755. const { r: t2, g: e2, b: r2, a: n2 } = this;
  35756. return 0 === n2 ? [0, 0, 0, 0] : [255 * t2 / n2, 255 * e2 / n2, 255 * r2 / n2, n2];
  35757. }
  35758. }
  35759. ce.black = new ce(0, 0, 0, 1), ce.white = new ce(1, 1, 1, 1), ce.transparent = new ce(0, 0, 0, 0), ce.red = new ce(1, 0, 0, 1), ce.blue = new ce(0, 0, 1, 1);
  35760. class he {
  35761. constructor(t2, e2, r2) {
  35762. this.sensitivity = t2 ? e2 ? "variant" : "case" : e2 ? "accent" : "base", this.locale = r2, this.collator = new Intl.Collator(this.locale ? this.locale : [], { sensitivity: this.sensitivity, usage: "search" });
  35763. }
  35764. compare(t2, e2) {
  35765. return this.collator.compare(t2, e2);
  35766. }
  35767. resolvedLocale() {
  35768. return new Intl.Collator(this.locale ? this.locale : []).resolvedOptions().locale;
  35769. }
  35770. }
  35771. class pe {
  35772. constructor(t2, e2, r2, n2, i3) {
  35773. this.text = t2.normalize ? t2.normalize() : t2, this.image = e2, this.scale = r2, this.fontStack = n2, this.textColor = i3;
  35774. }
  35775. }
  35776. class fe {
  35777. constructor(t2) {
  35778. this.sections = t2;
  35779. }
  35780. static fromString(t2) {
  35781. return new fe([new pe(t2, null, null, null, null)]);
  35782. }
  35783. isEmpty() {
  35784. return 0 === this.sections.length || !this.sections.some((t2) => 0 !== t2.text.length || t2.image && 0 !== t2.image.name.length);
  35785. }
  35786. static factory(t2) {
  35787. return t2 instanceof fe ? t2 : fe.fromString(t2);
  35788. }
  35789. toString() {
  35790. return 0 === this.sections.length ? "" : this.sections.map((t2) => t2.text).join("");
  35791. }
  35792. serialize() {
  35793. const t2 = ["format"];
  35794. for (const e2 of this.sections) {
  35795. if (e2.image) {
  35796. t2.push(["image", e2.image.name]);
  35797. continue;
  35798. }
  35799. t2.push(e2.text);
  35800. const r2 = {};
  35801. e2.fontStack && (r2["text-font"] = ["literal", e2.fontStack.split(",")]), e2.scale && (r2["font-scale"] = e2.scale), e2.textColor && (r2["text-color"] = ["rgba"].concat(e2.textColor.toArray())), t2.push(r2);
  35802. }
  35803. return t2;
  35804. }
  35805. }
  35806. class de {
  35807. constructor(t2) {
  35808. this.name = t2.name, this.available = t2.available;
  35809. }
  35810. toString() {
  35811. return this.name;
  35812. }
  35813. static fromString(t2) {
  35814. return t2 ? new de({ name: t2, available: false }) : null;
  35815. }
  35816. serialize() {
  35817. return ["image", this.name];
  35818. }
  35819. }
  35820. function ye(t2, e2, r2, n2) {
  35821. return "number" == typeof t2 && t2 >= 0 && t2 <= 255 && "number" == typeof e2 && e2 >= 0 && e2 <= 255 && "number" == typeof r2 && r2 >= 0 && r2 <= 255 ? void 0 === n2 || "number" == typeof n2 && n2 >= 0 && n2 <= 1 ? null : `Invalid rgba value [${[t2, e2, r2, n2].join(", ")}]: 'a' must be between 0 and 1.` : `Invalid rgba value [${("number" == typeof n2 ? [t2, e2, r2, n2] : [t2, e2, r2]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`;
  35822. }
  35823. function me(t2) {
  35824. if (null === t2)
  35825. return true;
  35826. if ("string" == typeof t2)
  35827. return true;
  35828. if ("boolean" == typeof t2)
  35829. return true;
  35830. if ("number" == typeof t2)
  35831. return true;
  35832. if (t2 instanceof ce)
  35833. return true;
  35834. if (t2 instanceof he)
  35835. return true;
  35836. if (t2 instanceof fe)
  35837. return true;
  35838. if (t2 instanceof de)
  35839. return true;
  35840. if (Array.isArray(t2)) {
  35841. for (const e2 of t2)
  35842. if (!me(e2))
  35843. return false;
  35844. return true;
  35845. }
  35846. if ("object" == typeof t2) {
  35847. for (const e2 in t2)
  35848. if (!me(t2[e2]))
  35849. return false;
  35850. return true;
  35851. }
  35852. return false;
  35853. }
  35854. function ge(t2) {
  35855. if (null === t2)
  35856. return Zt;
  35857. if ("string" == typeof t2)
  35858. return Kt;
  35859. if ("boolean" == typeof t2)
  35860. return Yt;
  35861. if ("number" == typeof t2)
  35862. return Xt;
  35863. if (t2 instanceof ce)
  35864. return Ht;
  35865. if (t2 instanceof he)
  35866. return Qt;
  35867. if (t2 instanceof fe)
  35868. return te;
  35869. if (t2 instanceof de)
  35870. return ee;
  35871. if (Array.isArray(t2)) {
  35872. const e2 = t2.length;
  35873. let r2;
  35874. for (const e3 of t2) {
  35875. const t3 = ge(e3);
  35876. if (r2) {
  35877. if (r2 === t3)
  35878. continue;
  35879. r2 = Jt;
  35880. break;
  35881. }
  35882. r2 = t3;
  35883. }
  35884. return re(r2 || Jt, e2);
  35885. }
  35886. return Wt;
  35887. }
  35888. function xe(t2) {
  35889. const e2 = typeof t2;
  35890. return null === t2 ? "" : "string" === e2 || "number" === e2 || "boolean" === e2 ? String(t2) : t2 instanceof ce || t2 instanceof fe || t2 instanceof de ? t2.toString() : JSON.stringify(t2);
  35891. }
  35892. class ve {
  35893. constructor(t2, e2) {
  35894. this.type = t2, this.value = e2;
  35895. }
  35896. static parse(t2, e2) {
  35897. if (2 !== t2.length)
  35898. return e2.error(`'literal' expression requires exactly one argument, but found ${t2.length - 1} instead.`);
  35899. if (!me(t2[1]))
  35900. return e2.error("invalid value");
  35901. const r2 = t2[1];
  35902. let n2 = ge(r2);
  35903. const i3 = e2.expectedType;
  35904. return "array" !== n2.kind || 0 !== n2.N || !i3 || "array" !== i3.kind || "number" == typeof i3.N && 0 !== i3.N || (n2 = i3), new ve(n2, r2);
  35905. }
  35906. evaluate() {
  35907. return this.value;
  35908. }
  35909. eachChild() {
  35910. }
  35911. outputDefined() {
  35912. return true;
  35913. }
  35914. serialize() {
  35915. return "array" === this.type.kind || "object" === this.type.kind ? ["literal", this.value] : this.value instanceof ce ? ["rgba"].concat(this.value.toArray()) : this.value instanceof fe ? this.value.serialize() : this.value;
  35916. }
  35917. }
  35918. class be {
  35919. constructor(t2) {
  35920. this.name = "ExpressionEvaluationError", this.message = t2;
  35921. }
  35922. toJSON() {
  35923. return this.message;
  35924. }
  35925. }
  35926. const _e = { string: Kt, number: Xt, boolean: Yt, object: Wt };
  35927. class we {
  35928. constructor(t2, e2) {
  35929. this.type = t2, this.args = e2;
  35930. }
  35931. static parse(t2, e2) {
  35932. if (t2.length < 2)
  35933. return e2.error("Expected at least one argument.");
  35934. let r2, n2 = 1;
  35935. const i3 = t2[0];
  35936. if ("array" === i3) {
  35937. let i4, s3;
  35938. if (t2.length > 2) {
  35939. const r3 = t2[1];
  35940. if ("string" != typeof r3 || !(r3 in _e) || "object" === r3)
  35941. return e2.error('The item type argument of "array" must be one of string, number, boolean', 1);
  35942. i4 = _e[r3], n2++;
  35943. } else
  35944. i4 = Jt;
  35945. if (t2.length > 3) {
  35946. if (null !== t2[2] && ("number" != typeof t2[2] || t2[2] < 0 || t2[2] !== Math.floor(t2[2])))
  35947. return e2.error('The length argument to "array" must be a positive integer literal', 2);
  35948. s3 = t2[2], n2++;
  35949. }
  35950. r2 = re(i4, s3);
  35951. } else
  35952. r2 = _e[i3];
  35953. const s2 = [];
  35954. for (; n2 < t2.length; n2++) {
  35955. const r3 = e2.parse(t2[n2], n2, Jt);
  35956. if (!r3)
  35957. return null;
  35958. s2.push(r3);
  35959. }
  35960. return new we(r2, s2);
  35961. }
  35962. evaluate(t2) {
  35963. for (let e2 = 0; e2 < this.args.length; e2++) {
  35964. const r2 = this.args[e2].evaluate(t2);
  35965. if (!se(this.type, ge(r2)))
  35966. return r2;
  35967. if (e2 === this.args.length - 1)
  35968. throw new be(`Expected value to be of type ${ne(this.type)}, but found ${ne(ge(r2))} instead.`);
  35969. }
  35970. return null;
  35971. }
  35972. eachChild(t2) {
  35973. this.args.forEach(t2);
  35974. }
  35975. outputDefined() {
  35976. return this.args.every((t2) => t2.outputDefined());
  35977. }
  35978. serialize() {
  35979. const t2 = this.type, e2 = [t2.kind];
  35980. if ("array" === t2.kind) {
  35981. const r2 = t2.itemType;
  35982. if ("string" === r2.kind || "number" === r2.kind || "boolean" === r2.kind) {
  35983. e2.push(r2.kind);
  35984. const n2 = t2.N;
  35985. ("number" == typeof n2 || this.args.length > 1) && e2.push(n2);
  35986. }
  35987. }
  35988. return e2.concat(this.args.map((t3) => t3.serialize()));
  35989. }
  35990. }
  35991. class Ae {
  35992. constructor(t2) {
  35993. this.type = te, this.sections = t2;
  35994. }
  35995. static parse(t2, e2) {
  35996. if (t2.length < 2)
  35997. return e2.error("Expected at least one argument.");
  35998. const r2 = t2[1];
  35999. if (!Array.isArray(r2) && "object" == typeof r2)
  36000. return e2.error("First argument must be an image or text section.");
  36001. const n2 = [];
  36002. let i3 = false;
  36003. for (let r3 = 1; r3 <= t2.length - 1; ++r3) {
  36004. const s2 = t2[r3];
  36005. if (i3 && "object" == typeof s2 && !Array.isArray(s2)) {
  36006. i3 = false;
  36007. let t3 = null;
  36008. if (s2["font-scale"] && (t3 = e2.parse(s2["font-scale"], 1, Xt), !t3))
  36009. return null;
  36010. let r4 = null;
  36011. if (s2["text-font"] && (r4 = e2.parse(s2["text-font"], 1, re(Kt)), !r4))
  36012. return null;
  36013. let a2 = null;
  36014. if (s2["text-color"] && (a2 = e2.parse(s2["text-color"], 1, Ht), !a2))
  36015. return null;
  36016. const o2 = n2[n2.length - 1];
  36017. o2.scale = t3, o2.font = r4, o2.textColor = a2;
  36018. } else {
  36019. const s3 = e2.parse(t2[r3], 1, Jt);
  36020. if (!s3)
  36021. return null;
  36022. const a2 = s3.type.kind;
  36023. if ("string" !== a2 && "value" !== a2 && "null" !== a2 && "resolvedImage" !== a2)
  36024. return e2.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");
  36025. i3 = true, n2.push({ content: s3, scale: null, font: null, textColor: null });
  36026. }
  36027. }
  36028. return new Ae(n2);
  36029. }
  36030. evaluate(t2) {
  36031. return new fe(this.sections.map((e2) => {
  36032. const r2 = e2.content.evaluate(t2);
  36033. return ge(r2) === ee ? new pe("", r2, null, null, null) : new pe(xe(r2), null, e2.scale ? e2.scale.evaluate(t2) : null, e2.font ? e2.font.evaluate(t2).join(",") : null, e2.textColor ? e2.textColor.evaluate(t2) : null);
  36034. }));
  36035. }
  36036. eachChild(t2) {
  36037. for (const e2 of this.sections)
  36038. t2(e2.content), e2.scale && t2(e2.scale), e2.font && t2(e2.font), e2.textColor && t2(e2.textColor);
  36039. }
  36040. outputDefined() {
  36041. return false;
  36042. }
  36043. serialize() {
  36044. const t2 = ["format"];
  36045. for (const e2 of this.sections) {
  36046. t2.push(e2.content.serialize());
  36047. const r2 = {};
  36048. e2.scale && (r2["font-scale"] = e2.scale.serialize()), e2.font && (r2["text-font"] = e2.font.serialize()), e2.textColor && (r2["text-color"] = e2.textColor.serialize()), t2.push(r2);
  36049. }
  36050. return t2;
  36051. }
  36052. }
  36053. class ke {
  36054. constructor(t2) {
  36055. this.type = ee, this.input = t2;
  36056. }
  36057. static parse(t2, e2) {
  36058. if (2 !== t2.length)
  36059. return e2.error("Expected two arguments.");
  36060. const r2 = e2.parse(t2[1], 1, Kt);
  36061. return r2 ? new ke(r2) : e2.error("No image name provided.");
  36062. }
  36063. evaluate(t2) {
  36064. const e2 = this.input.evaluate(t2), r2 = de.fromString(e2);
  36065. return r2 && t2.availableImages && (r2.available = t2.availableImages.indexOf(e2) > -1), r2;
  36066. }
  36067. eachChild(t2) {
  36068. t2(this.input);
  36069. }
  36070. outputDefined() {
  36071. return false;
  36072. }
  36073. serialize() {
  36074. return ["image", this.input.serialize()];
  36075. }
  36076. }
  36077. const Se = { "to-boolean": Yt, "to-color": Ht, "to-number": Xt, "to-string": Kt };
  36078. class Ie {
  36079. constructor(t2, e2) {
  36080. this.type = t2, this.args = e2;
  36081. }
  36082. static parse(t2, e2) {
  36083. if (t2.length < 2)
  36084. return e2.error("Expected at least one argument.");
  36085. const r2 = t2[0];
  36086. if (("to-boolean" === r2 || "to-string" === r2) && 2 !== t2.length)
  36087. return e2.error("Expected one argument.");
  36088. const n2 = Se[r2], i3 = [];
  36089. for (let r3 = 1; r3 < t2.length; r3++) {
  36090. const n3 = e2.parse(t2[r3], r3, Jt);
  36091. if (!n3)
  36092. return null;
  36093. i3.push(n3);
  36094. }
  36095. return new Ie(n2, i3);
  36096. }
  36097. evaluate(t2) {
  36098. if ("boolean" === this.type.kind)
  36099. return Boolean(this.args[0].evaluate(t2));
  36100. if ("color" === this.type.kind) {
  36101. let e2, r2;
  36102. for (const n2 of this.args) {
  36103. if (e2 = n2.evaluate(t2), r2 = null, e2 instanceof ce)
  36104. return e2;
  36105. if ("string" == typeof e2) {
  36106. const r3 = t2.parseColor(e2);
  36107. if (r3)
  36108. return r3;
  36109. } else if (Array.isArray(e2) && (r2 = e2.length < 3 || e2.length > 4 ? `Invalid rbga value ${JSON.stringify(e2)}: expected an array containing either three or four numeric values.` : ye(e2[0], e2[1], e2[2], e2[3]), !r2))
  36110. return new ce(e2[0] / 255, e2[1] / 255, e2[2] / 255, e2[3]);
  36111. }
  36112. throw new be(r2 || `Could not parse color from value '${"string" == typeof e2 ? e2 : String(JSON.stringify(e2))}'`);
  36113. }
  36114. if ("number" === this.type.kind) {
  36115. let e2 = null;
  36116. for (const r2 of this.args) {
  36117. if (e2 = r2.evaluate(t2), null === e2)
  36118. return 0;
  36119. const n2 = Number(e2);
  36120. if (!isNaN(n2))
  36121. return n2;
  36122. }
  36123. throw new be(`Could not convert ${JSON.stringify(e2)} to number.`);
  36124. }
  36125. return "formatted" === this.type.kind ? fe.fromString(xe(this.args[0].evaluate(t2))) : "resolvedImage" === this.type.kind ? de.fromString(xe(this.args[0].evaluate(t2))) : xe(this.args[0].evaluate(t2));
  36126. }
  36127. eachChild(t2) {
  36128. this.args.forEach(t2);
  36129. }
  36130. outputDefined() {
  36131. return this.args.every((t2) => t2.outputDefined());
  36132. }
  36133. serialize() {
  36134. if ("formatted" === this.type.kind)
  36135. return new Ae([{ content: this.args[0], scale: null, font: null, textColor: null }]).serialize();
  36136. if ("resolvedImage" === this.type.kind)
  36137. return new ke(this.args[0]).serialize();
  36138. const t2 = [`to-${this.type.kind}`];
  36139. return this.eachChild((e2) => {
  36140. t2.push(e2.serialize());
  36141. }), t2;
  36142. }
  36143. }
  36144. const Me = ["Unknown", "Point", "LineString", "Polygon"];
  36145. class Te {
  36146. constructor() {
  36147. this.globals = null, this.feature = null, this.featureState = null, this.formattedSection = null, this._parseColorCache = {}, this.availableImages = null, this.canonical = null, this.featureTileCoord = null, this.featureDistanceData = null;
  36148. }
  36149. id() {
  36150. return this.feature && "id" in this.feature && this.feature.id ? this.feature.id : null;
  36151. }
  36152. geometryType() {
  36153. return this.feature ? "number" == typeof this.feature.type ? Me[this.feature.type] : this.feature.type : null;
  36154. }
  36155. geometry() {
  36156. return this.feature && "geometry" in this.feature ? this.feature.geometry : null;
  36157. }
  36158. canonicalID() {
  36159. return this.canonical;
  36160. }
  36161. properties() {
  36162. return this.feature && this.feature.properties || {};
  36163. }
  36164. distanceFromCenter() {
  36165. if (this.featureTileCoord && this.featureDistanceData) {
  36166. const t2 = this.featureDistanceData.center, e2 = this.featureDistanceData.scale, { x: r2, y: n2 } = this.featureTileCoord;
  36167. return this.featureDistanceData.bearing[0] * (r2 * e2 - t2[0]) + this.featureDistanceData.bearing[1] * (n2 * e2 - t2[1]);
  36168. }
  36169. return 0;
  36170. }
  36171. parseColor(t2) {
  36172. let e2 = this._parseColorCache[t2];
  36173. return e2 || (e2 = this._parseColorCache[t2] = ce.parse(t2)), e2;
  36174. }
  36175. }
  36176. class ze {
  36177. constructor(t2, e2, r2, n2) {
  36178. this.name = t2, this.type = e2, this._evaluate = r2, this.args = n2;
  36179. }
  36180. evaluate(t2) {
  36181. return this._evaluate(t2, this.args);
  36182. }
  36183. eachChild(t2) {
  36184. this.args.forEach(t2);
  36185. }
  36186. outputDefined() {
  36187. return false;
  36188. }
  36189. serialize() {
  36190. return [this.name].concat(this.args.map((t2) => t2.serialize()));
  36191. }
  36192. static parse(t2, e2) {
  36193. const r2 = t2[0], n2 = ze.definitions[r2];
  36194. if (!n2)
  36195. return e2.error(`Unknown expression "${r2}". If you wanted a literal array, use ["literal", [...]].`, 0);
  36196. const i3 = Array.isArray(n2) ? n2[0] : n2.type, s2 = Array.isArray(n2) ? [[n2[1], n2[2]]] : n2.overloads, a2 = s2.filter(([e3]) => !Array.isArray(e3) || e3.length === t2.length - 1);
  36197. let o2 = null;
  36198. for (const [n3, s3] of a2) {
  36199. o2 = new Je(e2.registry, e2.path, null, e2.scope);
  36200. const a3 = [];
  36201. let l2 = false;
  36202. for (let e3 = 1; e3 < t2.length; e3++) {
  36203. const r3 = t2[e3], i4 = Array.isArray(n3) ? n3[e3 - 1] : n3.type, s4 = o2.parse(r3, 1 + a3.length, i4);
  36204. if (!s4) {
  36205. l2 = true;
  36206. break;
  36207. }
  36208. a3.push(s4);
  36209. }
  36210. if (!l2)
  36211. if (Array.isArray(n3) && n3.length !== a3.length)
  36212. o2.error(`Expected ${n3.length} arguments, but found ${a3.length} instead.`);
  36213. else {
  36214. for (let t3 = 0; t3 < a3.length; t3++) {
  36215. const e3 = Array.isArray(n3) ? n3[t3] : n3.type, r3 = a3[t3];
  36216. o2.concat(t3 + 1).checkSubtype(e3, r3.type);
  36217. }
  36218. if (0 === o2.errors.length)
  36219. return new ze(r2, i3, s3, a3);
  36220. }
  36221. }
  36222. if (1 === a2.length)
  36223. e2.errors.push(...o2.errors);
  36224. else {
  36225. const r3 = (a2.length ? a2 : s2).map(([t3]) => {
  36226. return e3 = t3, Array.isArray(e3) ? `(${e3.map(ne).join(", ")})` : `(${ne(e3.type)}...)`;
  36227. var e3;
  36228. }).join(" | "), n3 = [];
  36229. for (let r4 = 1; r4 < t2.length; r4++) {
  36230. const i4 = e2.parse(t2[r4], 1 + n3.length);
  36231. if (!i4)
  36232. return null;
  36233. n3.push(ne(i4.type));
  36234. }
  36235. e2.error(`Expected arguments of type ${r3}, but found (${n3.join(", ")}) instead.`);
  36236. }
  36237. return null;
  36238. }
  36239. static register(t2, e2) {
  36240. ze.definitions = e2;
  36241. for (const r2 in e2)
  36242. t2[r2] = ze;
  36243. }
  36244. }
  36245. class Be {
  36246. constructor(t2, e2, r2) {
  36247. this.type = Qt, this.locale = r2, this.caseSensitive = t2, this.diacriticSensitive = e2;
  36248. }
  36249. static parse(t2, e2) {
  36250. if (2 !== t2.length)
  36251. return e2.error("Expected one argument.");
  36252. const r2 = t2[1];
  36253. if ("object" != typeof r2 || Array.isArray(r2))
  36254. return e2.error("Collator options argument must be an object.");
  36255. const n2 = e2.parse(void 0 !== r2["case-sensitive"] && r2["case-sensitive"], 1, Yt);
  36256. if (!n2)
  36257. return null;
  36258. const i3 = e2.parse(void 0 !== r2["diacritic-sensitive"] && r2["diacritic-sensitive"], 1, Yt);
  36259. if (!i3)
  36260. return null;
  36261. let s2 = null;
  36262. return r2.locale && (s2 = e2.parse(r2.locale, 1, Kt), !s2) ? null : new Be(n2, i3, s2);
  36263. }
  36264. evaluate(t2) {
  36265. return new he(this.caseSensitive.evaluate(t2), this.diacriticSensitive.evaluate(t2), this.locale ? this.locale.evaluate(t2) : null);
  36266. }
  36267. eachChild(t2) {
  36268. t2(this.caseSensitive), t2(this.diacriticSensitive), this.locale && t2(this.locale);
  36269. }
  36270. outputDefined() {
  36271. return false;
  36272. }
  36273. serialize() {
  36274. const t2 = {};
  36275. return t2["case-sensitive"] = this.caseSensitive.serialize(), t2["diacritic-sensitive"] = this.diacriticSensitive.serialize(), this.locale && (t2.locale = this.locale.serialize()), ["collator", t2];
  36276. }
  36277. }
  36278. const Ee = 8192;
  36279. function Ce(t2, e2) {
  36280. t2[0] = Math.min(t2[0], e2[0]), t2[1] = Math.min(t2[1], e2[1]), t2[2] = Math.max(t2[2], e2[0]), t2[3] = Math.max(t2[3], e2[1]);
  36281. }
  36282. function De(t2, e2) {
  36283. return !(t2[0] <= e2[0] || t2[2] >= e2[2] || t2[1] <= e2[1] || t2[3] >= e2[3]);
  36284. }
  36285. function Pe(t2, e2) {
  36286. const r2 = (180 + t2[0]) / 360, n2 = (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + t2[1] * Math.PI / 360))) / 360, i3 = Math.pow(2, e2.z);
  36287. return [Math.round(r2 * i3 * Ee), Math.round(n2 * i3 * Ee)];
  36288. }
  36289. function Ve(t2, e2, r2) {
  36290. const n2 = t2[0] - e2[0], i3 = t2[1] - e2[1], s2 = t2[0] - r2[0], a2 = t2[1] - r2[1];
  36291. return n2 * a2 - s2 * i3 == 0 && n2 * s2 <= 0 && i3 * a2 <= 0;
  36292. }
  36293. function Fe(t2, e2) {
  36294. let r2 = false;
  36295. for (let a2 = 0, o2 = e2.length; a2 < o2; a2++) {
  36296. const o3 = e2[a2];
  36297. for (let e3 = 0, a3 = o3.length; e3 < a3 - 1; e3++) {
  36298. if (Ve(t2, o3[e3], o3[e3 + 1]))
  36299. return false;
  36300. (i3 = o3[e3])[1] > (n2 = t2)[1] != (s2 = o3[e3 + 1])[1] > n2[1] && n2[0] < (s2[0] - i3[0]) * (n2[1] - i3[1]) / (s2[1] - i3[1]) + i3[0] && (r2 = !r2);
  36301. }
  36302. }
  36303. var n2, i3, s2;
  36304. return r2;
  36305. }
  36306. function Le(t2, e2) {
  36307. for (let r2 = 0; r2 < e2.length; r2++)
  36308. if (Fe(t2, e2[r2]))
  36309. return true;
  36310. return false;
  36311. }
  36312. function Re(t2, e2, r2, n2) {
  36313. const i3 = n2[0] - r2[0], s2 = n2[1] - r2[1], a2 = (t2[0] - r2[0]) * s2 - i3 * (t2[1] - r2[1]), o2 = (e2[0] - r2[0]) * s2 - i3 * (e2[1] - r2[1]);
  36314. return a2 > 0 && o2 < 0 || a2 < 0 && o2 > 0;
  36315. }
  36316. function Ue(t2, e2, r2) {
  36317. for (const u2 of r2)
  36318. for (let r3 = 0; r3 < u2.length - 1; ++r3)
  36319. if (0 != (o2 = [(a2 = u2[r3 + 1])[0] - (s2 = u2[r3])[0], a2[1] - s2[1]])[0] * (l2 = [(i3 = e2)[0] - (n2 = t2)[0], i3[1] - n2[1]])[1] - o2[1] * l2[0] && Re(n2, i3, s2, a2) && Re(s2, a2, n2, i3))
  36320. return true;
  36321. var n2, i3, s2, a2, o2, l2;
  36322. return false;
  36323. }
  36324. function $e(t2, e2) {
  36325. for (let r2 = 0; r2 < t2.length; ++r2)
  36326. if (!Fe(t2[r2], e2))
  36327. return false;
  36328. for (let r2 = 0; r2 < t2.length - 1; ++r2)
  36329. if (Ue(t2[r2], t2[r2 + 1], e2))
  36330. return false;
  36331. return true;
  36332. }
  36333. function je(t2, e2) {
  36334. for (let r2 = 0; r2 < e2.length; r2++)
  36335. if ($e(t2, e2[r2]))
  36336. return true;
  36337. return false;
  36338. }
  36339. function Oe(t2, e2, r2) {
  36340. const n2 = [];
  36341. for (let i3 = 0; i3 < t2.length; i3++) {
  36342. const s2 = [];
  36343. for (let n3 = 0; n3 < t2[i3].length; n3++) {
  36344. const a2 = Pe(t2[i3][n3], r2);
  36345. Ce(e2, a2), s2.push(a2);
  36346. }
  36347. n2.push(s2);
  36348. }
  36349. return n2;
  36350. }
  36351. function qe(t2, e2, r2) {
  36352. const n2 = [];
  36353. for (let i3 = 0; i3 < t2.length; i3++) {
  36354. const s2 = Oe(t2[i3], e2, r2);
  36355. n2.push(s2);
  36356. }
  36357. return n2;
  36358. }
  36359. function Ne(t2, e2, r2, n2) {
  36360. if (t2[0] < r2[0] || t2[0] > r2[2]) {
  36361. const e3 = 0.5 * n2;
  36362. let i3 = t2[0] - r2[0] > e3 ? -n2 : r2[0] - t2[0] > e3 ? n2 : 0;
  36363. 0 === i3 && (i3 = t2[0] - r2[2] > e3 ? -n2 : r2[2] - t2[0] > e3 ? n2 : 0), t2[0] += i3;
  36364. }
  36365. Ce(e2, t2);
  36366. }
  36367. function Ge(t2, e2, r2, n2) {
  36368. const i3 = Math.pow(2, n2.z) * Ee, s2 = [n2.x * Ee, n2.y * Ee], a2 = [];
  36369. if (!t2)
  36370. return a2;
  36371. for (const n3 of t2)
  36372. for (const t3 of n3) {
  36373. const n4 = [t3.x + s2[0], t3.y + s2[1]];
  36374. Ne(n4, e2, r2, i3), a2.push(n4);
  36375. }
  36376. return a2;
  36377. }
  36378. function Ze(t2, e2, r2, n2) {
  36379. const i3 = Math.pow(2, n2.z) * Ee, s2 = [n2.x * Ee, n2.y * Ee], a2 = [];
  36380. if (!t2)
  36381. return a2;
  36382. for (const r3 of t2) {
  36383. const t3 = [];
  36384. for (const n3 of r3) {
  36385. const r4 = [n3.x + s2[0], n3.y + s2[1]];
  36386. Ce(e2, r4), t3.push(r4);
  36387. }
  36388. a2.push(t3);
  36389. }
  36390. if (e2[2] - e2[0] <= i3 / 2) {
  36391. (o2 = e2)[0] = o2[1] = 1 / 0, o2[2] = o2[3] = -1 / 0;
  36392. for (const t3 of a2)
  36393. for (const n3 of t3)
  36394. Ne(n3, e2, r2, i3);
  36395. }
  36396. var o2;
  36397. return a2;
  36398. }
  36399. class Xe {
  36400. constructor(t2, e2) {
  36401. this.type = Yt, this.geojson = t2, this.geometries = e2;
  36402. }
  36403. static parse(t2, e2) {
  36404. if (2 !== t2.length)
  36405. return e2.error(`'within' expression requires exactly one argument, but found ${t2.length - 1} instead.`);
  36406. if (me(t2[1])) {
  36407. const e3 = t2[1];
  36408. if ("FeatureCollection" === e3.type)
  36409. for (let t3 = 0; t3 < e3.features.length; ++t3) {
  36410. const r2 = e3.features[t3].geometry.type;
  36411. if ("Polygon" === r2 || "MultiPolygon" === r2)
  36412. return new Xe(e3, e3.features[t3].geometry);
  36413. }
  36414. else if ("Feature" === e3.type) {
  36415. const t3 = e3.geometry.type;
  36416. if ("Polygon" === t3 || "MultiPolygon" === t3)
  36417. return new Xe(e3, e3.geometry);
  36418. } else if ("Polygon" === e3.type || "MultiPolygon" === e3.type)
  36419. return new Xe(e3, e3);
  36420. }
  36421. return e2.error("'within' expression requires valid geojson object that contains polygon geometry type.");
  36422. }
  36423. evaluate(t2) {
  36424. if (null != t2.geometry() && null != t2.canonicalID()) {
  36425. if ("Point" === t2.geometryType())
  36426. return function(t3, e2) {
  36427. const r2 = [1 / 0, 1 / 0, -1 / 0, -1 / 0], n2 = [1 / 0, 1 / 0, -1 / 0, -1 / 0], i3 = t3.canonicalID();
  36428. if (!i3)
  36429. return false;
  36430. if ("Polygon" === e2.type) {
  36431. const s2 = Oe(e2.coordinates, n2, i3), a2 = Ge(t3.geometry(), r2, n2, i3);
  36432. if (!De(r2, n2))
  36433. return false;
  36434. for (const t4 of a2)
  36435. if (!Fe(t4, s2))
  36436. return false;
  36437. }
  36438. if ("MultiPolygon" === e2.type) {
  36439. const s2 = qe(e2.coordinates, n2, i3), a2 = Ge(t3.geometry(), r2, n2, i3);
  36440. if (!De(r2, n2))
  36441. return false;
  36442. for (const t4 of a2)
  36443. if (!Le(t4, s2))
  36444. return false;
  36445. }
  36446. return true;
  36447. }(t2, this.geometries);
  36448. if ("LineString" === t2.geometryType())
  36449. return function(t3, e2) {
  36450. const r2 = [1 / 0, 1 / 0, -1 / 0, -1 / 0], n2 = [1 / 0, 1 / 0, -1 / 0, -1 / 0], i3 = t3.canonicalID();
  36451. if (!i3)
  36452. return false;
  36453. if ("Polygon" === e2.type) {
  36454. const s2 = Oe(e2.coordinates, n2, i3), a2 = Ze(t3.geometry(), r2, n2, i3);
  36455. if (!De(r2, n2))
  36456. return false;
  36457. for (const t4 of a2)
  36458. if (!$e(t4, s2))
  36459. return false;
  36460. }
  36461. if ("MultiPolygon" === e2.type) {
  36462. const s2 = qe(e2.coordinates, n2, i3), a2 = Ze(t3.geometry(), r2, n2, i3);
  36463. if (!De(r2, n2))
  36464. return false;
  36465. for (const t4 of a2)
  36466. if (!je(t4, s2))
  36467. return false;
  36468. }
  36469. return true;
  36470. }(t2, this.geometries);
  36471. }
  36472. return false;
  36473. }
  36474. eachChild() {
  36475. }
  36476. outputDefined() {
  36477. return true;
  36478. }
  36479. serialize() {
  36480. return ["within", this.geojson];
  36481. }
  36482. }
  36483. function Ke(t2) {
  36484. if (t2 instanceof ze) {
  36485. if ("get" === t2.name && 1 === t2.args.length)
  36486. return false;
  36487. if ("feature-state" === t2.name)
  36488. return false;
  36489. if ("has" === t2.name && 1 === t2.args.length)
  36490. return false;
  36491. if ("properties" === t2.name || "geometry-type" === t2.name || "id" === t2.name)
  36492. return false;
  36493. if (/^filter-/.test(t2.name))
  36494. return false;
  36495. }
  36496. if (t2 instanceof Xe)
  36497. return false;
  36498. let e2 = true;
  36499. return t2.eachChild((t3) => {
  36500. e2 && !Ke(t3) && (e2 = false);
  36501. }), e2;
  36502. }
  36503. function Ye(t2) {
  36504. if (t2 instanceof ze && "feature-state" === t2.name)
  36505. return false;
  36506. let e2 = true;
  36507. return t2.eachChild((t3) => {
  36508. e2 && !Ye(t3) && (e2 = false);
  36509. }), e2;
  36510. }
  36511. function He(t2, e2) {
  36512. if (t2 instanceof ze && e2.indexOf(t2.name) >= 0)
  36513. return false;
  36514. let r2 = true;
  36515. return t2.eachChild((t3) => {
  36516. r2 && !He(t3, e2) && (r2 = false);
  36517. }), r2;
  36518. }
  36519. class We {
  36520. constructor(t2, e2) {
  36521. this.type = e2.type, this.name = t2, this.boundExpression = e2;
  36522. }
  36523. static parse(t2, e2) {
  36524. if (2 !== t2.length || "string" != typeof t2[1])
  36525. return e2.error("'var' expression requires exactly one string literal argument.");
  36526. const r2 = t2[1];
  36527. return e2.scope.has(r2) ? new We(r2, e2.scope.get(r2)) : e2.error(`Unknown variable "${r2}". Make sure "${r2}" has been bound in an enclosing "let" expression before using it.`, 1);
  36528. }
  36529. evaluate(t2) {
  36530. return this.boundExpression.evaluate(t2);
  36531. }
  36532. eachChild() {
  36533. }
  36534. outputDefined() {
  36535. return false;
  36536. }
  36537. serialize() {
  36538. return ["var", this.name];
  36539. }
  36540. }
  36541. class Je {
  36542. constructor(t2, e2 = [], r2, n2 = new Gt(), i3 = []) {
  36543. this.registry = t2, this.path = e2, this.key = e2.map((t3) => `[${t3}]`).join(""), this.scope = n2, this.errors = i3, this.expectedType = r2;
  36544. }
  36545. parse(t2, e2, r2, n2, i3 = {}) {
  36546. return e2 ? this.concat(e2, r2, n2)._parse(t2, i3) : this._parse(t2, i3);
  36547. }
  36548. _parse(t2, e2) {
  36549. function r2(t3, e3, r3) {
  36550. return "assert" === r3 ? new we(e3, [t3]) : "coerce" === r3 ? new Ie(e3, [t3]) : t3;
  36551. }
  36552. if (null !== t2 && "string" != typeof t2 && "boolean" != typeof t2 && "number" != typeof t2 || (t2 = ["literal", t2]), Array.isArray(t2)) {
  36553. if (0 === t2.length)
  36554. return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');
  36555. const n2 = t2[0];
  36556. if ("string" != typeof n2)
  36557. return this.error(`Expression name must be a string, but found ${typeof n2} instead. If you wanted a literal array, use ["literal", [...]].`, 0), null;
  36558. const i3 = this.registry[n2];
  36559. if (i3) {
  36560. let n3 = i3.parse(t2, this);
  36561. if (!n3)
  36562. return null;
  36563. if (this.expectedType) {
  36564. const t3 = this.expectedType, i4 = n3.type;
  36565. if ("string" !== t3.kind && "number" !== t3.kind && "boolean" !== t3.kind && "object" !== t3.kind && "array" !== t3.kind || "value" !== i4.kind)
  36566. if ("color" !== t3.kind && "formatted" !== t3.kind && "resolvedImage" !== t3.kind || "value" !== i4.kind && "string" !== i4.kind) {
  36567. if (this.checkSubtype(t3, i4))
  36568. return null;
  36569. } else
  36570. n3 = r2(n3, t3, e2.typeAnnotation || "coerce");
  36571. else
  36572. n3 = r2(n3, t3, e2.typeAnnotation || "assert");
  36573. }
  36574. if (!(n3 instanceof ve) && "resolvedImage" !== n3.type.kind && Qe(n3)) {
  36575. const t3 = new Te();
  36576. try {
  36577. n3 = new ve(n3.type, n3.evaluate(t3));
  36578. } catch (t4) {
  36579. return this.error(t4.message), null;
  36580. }
  36581. }
  36582. return n3;
  36583. }
  36584. return this.error(`Unknown expression "${n2}". If you wanted a literal array, use ["literal", [...]].`, 0);
  36585. }
  36586. return this.error(void 0 === t2 ? "'undefined' value invalid. Use null instead." : "object" == typeof t2 ? 'Bare objects invalid. Use ["literal", {...}] instead.' : `Expected an array, but found ${typeof t2} instead.`);
  36587. }
  36588. concat(t2, e2, r2) {
  36589. const n2 = "number" == typeof t2 ? this.path.concat(t2) : this.path, i3 = r2 ? this.scope.concat(r2) : this.scope;
  36590. return new Je(this.registry, n2, e2 || null, i3, this.errors);
  36591. }
  36592. error(t2, ...e2) {
  36593. const r2 = `${this.key}${e2.map((t3) => `[${t3}]`).join("")}`;
  36594. this.errors.push(new Nt(r2, t2));
  36595. }
  36596. checkSubtype(t2, e2) {
  36597. const r2 = se(t2, e2);
  36598. return r2 && this.error(r2), r2;
  36599. }
  36600. }
  36601. function Qe(t2) {
  36602. if (t2 instanceof We)
  36603. return Qe(t2.boundExpression);
  36604. if (t2 instanceof ze && "error" === t2.name)
  36605. return false;
  36606. if (t2 instanceof Be)
  36607. return false;
  36608. if (t2 instanceof Xe)
  36609. return false;
  36610. const e2 = t2 instanceof Ie || t2 instanceof we;
  36611. let r2 = true;
  36612. return t2.eachChild((t3) => {
  36613. r2 = e2 ? r2 && Qe(t3) : r2 && t3 instanceof ve;
  36614. }), !!r2 && Ke(t2) && He(t2, ["zoom", "heatmap-density", "line-progress", "sky-radial-progress", "accumulated", "is-supported-script", "pitch", "distance-from-center"]);
  36615. }
  36616. function tr(t2, e2) {
  36617. const r2 = t2.length - 1;
  36618. let n2, i3, s2 = 0, a2 = r2, o2 = 0;
  36619. for (; s2 <= a2; )
  36620. if (o2 = Math.floor((s2 + a2) / 2), n2 = t2[o2], i3 = t2[o2 + 1], n2 <= e2) {
  36621. if (o2 === r2 || e2 < i3)
  36622. return o2;
  36623. s2 = o2 + 1;
  36624. } else {
  36625. if (!(n2 > e2))
  36626. throw new be("Input is not a number.");
  36627. a2 = o2 - 1;
  36628. }
  36629. return 0;
  36630. }
  36631. class er {
  36632. constructor(t2, e2, r2) {
  36633. this.type = t2, this.input = e2, this.labels = [], this.outputs = [];
  36634. for (const [t3, e3] of r2)
  36635. this.labels.push(t3), this.outputs.push(e3);
  36636. }
  36637. static parse(t2, e2) {
  36638. if (t2.length - 1 < 4)
  36639. return e2.error(`Expected at least 4 arguments, but found only ${t2.length - 1}.`);
  36640. if ((t2.length - 1) % 2 != 0)
  36641. return e2.error("Expected an even number of arguments.");
  36642. const r2 = e2.parse(t2[1], 1, Xt);
  36643. if (!r2)
  36644. return null;
  36645. const n2 = [];
  36646. let i3 = null;
  36647. e2.expectedType && "value" !== e2.expectedType.kind && (i3 = e2.expectedType);
  36648. for (let r3 = 1; r3 < t2.length; r3 += 2) {
  36649. const s2 = 1 === r3 ? -1 / 0 : t2[r3], a2 = t2[r3 + 1], o2 = r3, l2 = r3 + 1;
  36650. if ("number" != typeof s2)
  36651. return e2.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.', o2);
  36652. if (n2.length && n2[n2.length - 1][0] >= s2)
  36653. return e2.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.', o2);
  36654. const u2 = e2.parse(a2, l2, i3);
  36655. if (!u2)
  36656. return null;
  36657. i3 = i3 || u2.type, n2.push([s2, u2]);
  36658. }
  36659. return new er(i3, r2, n2);
  36660. }
  36661. evaluate(t2) {
  36662. const e2 = this.labels, r2 = this.outputs;
  36663. if (1 === e2.length)
  36664. return r2[0].evaluate(t2);
  36665. const n2 = this.input.evaluate(t2);
  36666. if (n2 <= e2[0])
  36667. return r2[0].evaluate(t2);
  36668. const i3 = e2.length;
  36669. return n2 >= e2[i3 - 1] ? r2[i3 - 1].evaluate(t2) : r2[tr(e2, n2)].evaluate(t2);
  36670. }
  36671. eachChild(t2) {
  36672. t2(this.input);
  36673. for (const e2 of this.outputs)
  36674. t2(e2);
  36675. }
  36676. outputDefined() {
  36677. return this.outputs.every((t2) => t2.outputDefined());
  36678. }
  36679. serialize() {
  36680. const t2 = ["step", this.input.serialize()];
  36681. for (let e2 = 0; e2 < this.labels.length; e2++)
  36682. e2 > 0 && t2.push(this.labels[e2]), t2.push(this.outputs[e2].serialize());
  36683. return t2;
  36684. }
  36685. }
  36686. function rr(t2, e2, r2) {
  36687. return t2 * (1 - r2) + e2 * r2;
  36688. }
  36689. var nr = Object.freeze({ __proto__: null, number: rr, color: function(t2, e2, r2) {
  36690. return new ce(rr(t2.r, e2.r, r2), rr(t2.g, e2.g, r2), rr(t2.b, e2.b, r2), rr(t2.a, e2.a, r2));
  36691. }, array: function(t2, e2, r2) {
  36692. return t2.map((t3, n2) => rr(t3, e2[n2], r2));
  36693. } });
  36694. const ir = 0.95047, sr = 1.08883, ar = 4 / 29, or = 6 / 29, lr = 3 * or * or, ur = Math.PI / 180, cr = 180 / Math.PI;
  36695. function hr(t2) {
  36696. return t2 > 0.008856451679035631 ? Math.pow(t2, 1 / 3) : t2 / lr + ar;
  36697. }
  36698. function pr(t2) {
  36699. return t2 > or ? t2 * t2 * t2 : lr * (t2 - ar);
  36700. }
  36701. function fr(t2) {
  36702. return 255 * (t2 <= 31308e-7 ? 12.92 * t2 : 1.055 * Math.pow(t2, 1 / 2.4) - 0.055);
  36703. }
  36704. function dr(t2) {
  36705. return (t2 /= 255) <= 0.04045 ? t2 / 12.92 : Math.pow((t2 + 0.055) / 1.055, 2.4);
  36706. }
  36707. function yr(t2) {
  36708. const e2 = dr(t2.r), r2 = dr(t2.g), n2 = dr(t2.b), i3 = hr((0.4124564 * e2 + 0.3575761 * r2 + 0.1804375 * n2) / ir), s2 = hr((0.2126729 * e2 + 0.7151522 * r2 + 0.072175 * n2) / 1);
  36709. return { l: 116 * s2 - 16, a: 500 * (i3 - s2), b: 200 * (s2 - hr((0.0193339 * e2 + 0.119192 * r2 + 0.9503041 * n2) / sr)), alpha: t2.a };
  36710. }
  36711. function mr(t2) {
  36712. let e2 = (t2.l + 16) / 116, r2 = isNaN(t2.a) ? e2 : e2 + t2.a / 500, n2 = isNaN(t2.b) ? e2 : e2 - t2.b / 200;
  36713. return e2 = 1 * pr(e2), r2 = ir * pr(r2), n2 = sr * pr(n2), new ce(fr(3.2404542 * r2 - 1.5371385 * e2 - 0.4985314 * n2), fr(-0.969266 * r2 + 1.8760108 * e2 + 0.041556 * n2), fr(0.0556434 * r2 - 0.2040259 * e2 + 1.0572252 * n2), t2.alpha);
  36714. }
  36715. function gr(t2, e2, r2) {
  36716. const n2 = e2 - t2;
  36717. return t2 + r2 * (n2 > 180 || n2 < -180 ? n2 - 360 * Math.round(n2 / 360) : n2);
  36718. }
  36719. const xr = { forward: yr, reverse: mr, interpolate: function(t2, e2, r2) {
  36720. return { l: rr(t2.l, e2.l, r2), a: rr(t2.a, e2.a, r2), b: rr(t2.b, e2.b, r2), alpha: rr(t2.alpha, e2.alpha, r2) };
  36721. } }, vr = { forward: function(t2) {
  36722. const { l: e2, a: r2, b: n2 } = yr(t2), i3 = Math.atan2(n2, r2) * cr;
  36723. return { h: i3 < 0 ? i3 + 360 : i3, c: Math.sqrt(r2 * r2 + n2 * n2), l: e2, alpha: t2.a };
  36724. }, reverse: function(t2) {
  36725. const e2 = t2.h * ur, r2 = t2.c;
  36726. return mr({ l: t2.l, a: Math.cos(e2) * r2, b: Math.sin(e2) * r2, alpha: t2.alpha });
  36727. }, interpolate: function(t2, e2, r2) {
  36728. return { h: gr(t2.h, e2.h, r2), c: rr(t2.c, e2.c, r2), l: rr(t2.l, e2.l, r2), alpha: rr(t2.alpha, e2.alpha, r2) };
  36729. } };
  36730. var br = Object.freeze({ __proto__: null, lab: xr, hcl: vr });
  36731. class _r {
  36732. constructor(t2, e2, r2, n2, i3) {
  36733. this.type = t2, this.operator = e2, this.interpolation = r2, this.input = n2, this.labels = [], this.outputs = [];
  36734. for (const [t3, e3] of i3)
  36735. this.labels.push(t3), this.outputs.push(e3);
  36736. }
  36737. static interpolationFactor(t2, e2, n2, i3) {
  36738. let s2 = 0;
  36739. if ("exponential" === t2.name)
  36740. s2 = wr(e2, t2.base, n2, i3);
  36741. else if ("linear" === t2.name)
  36742. s2 = wr(e2, 1, n2, i3);
  36743. else if ("cubic-bezier" === t2.name) {
  36744. const a2 = t2.controlPoints;
  36745. s2 = new r(a2[0], a2[1], a2[2], a2[3]).solve(wr(e2, 1, n2, i3));
  36746. }
  36747. return s2;
  36748. }
  36749. static parse(t2, e2) {
  36750. let [r2, n2, i3, ...s2] = t2;
  36751. if (!Array.isArray(n2) || 0 === n2.length)
  36752. return e2.error("Expected an interpolation type expression.", 1);
  36753. if ("linear" === n2[0])
  36754. n2 = { name: "linear" };
  36755. else if ("exponential" === n2[0]) {
  36756. const t3 = n2[1];
  36757. if ("number" != typeof t3)
  36758. return e2.error("Exponential interpolation requires a numeric base.", 1, 1);
  36759. n2 = { name: "exponential", base: t3 };
  36760. } else {
  36761. if ("cubic-bezier" !== n2[0])
  36762. return e2.error(`Unknown interpolation type ${String(n2[0])}`, 1, 0);
  36763. {
  36764. const t3 = n2.slice(1);
  36765. if (4 !== t3.length || t3.some((t4) => "number" != typeof t4 || t4 < 0 || t4 > 1))
  36766. return e2.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.", 1);
  36767. n2 = { name: "cubic-bezier", controlPoints: t3 };
  36768. }
  36769. }
  36770. if (t2.length - 1 < 4)
  36771. return e2.error(`Expected at least 4 arguments, but found only ${t2.length - 1}.`);
  36772. if ((t2.length - 1) % 2 != 0)
  36773. return e2.error("Expected an even number of arguments.");
  36774. if (i3 = e2.parse(i3, 2, Xt), !i3)
  36775. return null;
  36776. const a2 = [];
  36777. let o2 = null;
  36778. "interpolate-hcl" === r2 || "interpolate-lab" === r2 ? o2 = Ht : e2.expectedType && "value" !== e2.expectedType.kind && (o2 = e2.expectedType);
  36779. for (let t3 = 0; t3 < s2.length; t3 += 2) {
  36780. const r3 = s2[t3], n3 = s2[t3 + 1], i4 = t3 + 3, l2 = t3 + 4;
  36781. if ("number" != typeof r3)
  36782. return e2.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.', i4);
  36783. if (a2.length && a2[a2.length - 1][0] >= r3)
  36784. return e2.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.', i4);
  36785. const u2 = e2.parse(n3, l2, o2);
  36786. if (!u2)
  36787. return null;
  36788. o2 = o2 || u2.type, a2.push([r3, u2]);
  36789. }
  36790. return "number" === o2.kind || "color" === o2.kind || "array" === o2.kind && "number" === o2.itemType.kind && "number" == typeof o2.N ? new _r(o2, r2, n2, i3, a2) : e2.error(`Type ${ne(o2)} is not interpolatable.`);
  36791. }
  36792. evaluate(t2) {
  36793. const e2 = this.labels, r2 = this.outputs;
  36794. if (1 === e2.length)
  36795. return r2[0].evaluate(t2);
  36796. const n2 = this.input.evaluate(t2);
  36797. if (n2 <= e2[0])
  36798. return r2[0].evaluate(t2);
  36799. const i3 = e2.length;
  36800. if (n2 >= e2[i3 - 1])
  36801. return r2[i3 - 1].evaluate(t2);
  36802. const s2 = tr(e2, n2), a2 = _r.interpolationFactor(this.interpolation, n2, e2[s2], e2[s2 + 1]), o2 = r2[s2].evaluate(t2), l2 = r2[s2 + 1].evaluate(t2);
  36803. return "interpolate" === this.operator ? nr[this.type.kind.toLowerCase()](o2, l2, a2) : "interpolate-hcl" === this.operator ? vr.reverse(vr.interpolate(vr.forward(o2), vr.forward(l2), a2)) : xr.reverse(xr.interpolate(xr.forward(o2), xr.forward(l2), a2));
  36804. }
  36805. eachChild(t2) {
  36806. t2(this.input);
  36807. for (const e2 of this.outputs)
  36808. t2(e2);
  36809. }
  36810. outputDefined() {
  36811. return this.outputs.every((t2) => t2.outputDefined());
  36812. }
  36813. serialize() {
  36814. let t2;
  36815. t2 = "linear" === this.interpolation.name ? ["linear"] : "exponential" === this.interpolation.name ? 1 === this.interpolation.base ? ["linear"] : ["exponential", this.interpolation.base] : ["cubic-bezier"].concat(this.interpolation.controlPoints);
  36816. const e2 = [this.operator, t2, this.input.serialize()];
  36817. for (let t3 = 0; t3 < this.labels.length; t3++)
  36818. e2.push(this.labels[t3], this.outputs[t3].serialize());
  36819. return e2;
  36820. }
  36821. }
  36822. function wr(t2, e2, r2, n2) {
  36823. const i3 = n2 - r2, s2 = t2 - r2;
  36824. return 0 === i3 ? 0 : 1 === e2 ? s2 / i3 : (Math.pow(e2, s2) - 1) / (Math.pow(e2, i3) - 1);
  36825. }
  36826. class Ar {
  36827. constructor(t2, e2) {
  36828. this.type = t2, this.args = e2;
  36829. }
  36830. static parse(t2, e2) {
  36831. if (t2.length < 2)
  36832. return e2.error("Expectected at least one argument.");
  36833. let r2 = null;
  36834. const n2 = e2.expectedType;
  36835. n2 && "value" !== n2.kind && (r2 = n2);
  36836. const i3 = [];
  36837. for (const n3 of t2.slice(1)) {
  36838. const t3 = e2.parse(n3, 1 + i3.length, r2, void 0, { typeAnnotation: "omit" });
  36839. if (!t3)
  36840. return null;
  36841. r2 = r2 || t3.type, i3.push(t3);
  36842. }
  36843. const s2 = n2 && i3.some((t3) => se(n2, t3.type));
  36844. return new Ar(s2 ? Jt : r2, i3);
  36845. }
  36846. evaluate(t2) {
  36847. let e2, r2 = null, n2 = 0;
  36848. for (const i3 of this.args) {
  36849. if (n2++, r2 = i3.evaluate(t2), r2 && r2 instanceof de && !r2.available && (e2 || (e2 = r2), r2 = null, n2 === this.args.length))
  36850. return e2;
  36851. if (null !== r2)
  36852. break;
  36853. }
  36854. return r2;
  36855. }
  36856. eachChild(t2) {
  36857. this.args.forEach(t2);
  36858. }
  36859. outputDefined() {
  36860. return this.args.every((t2) => t2.outputDefined());
  36861. }
  36862. serialize() {
  36863. const t2 = ["coalesce"];
  36864. return this.eachChild((e2) => {
  36865. t2.push(e2.serialize());
  36866. }), t2;
  36867. }
  36868. }
  36869. class kr {
  36870. constructor(t2, e2) {
  36871. this.type = e2.type, this.bindings = [].concat(t2), this.result = e2;
  36872. }
  36873. evaluate(t2) {
  36874. return this.result.evaluate(t2);
  36875. }
  36876. eachChild(t2) {
  36877. for (const e2 of this.bindings)
  36878. t2(e2[1]);
  36879. t2(this.result);
  36880. }
  36881. static parse(t2, e2) {
  36882. if (t2.length < 4)
  36883. return e2.error(`Expected at least 3 arguments, but found ${t2.length - 1} instead.`);
  36884. const r2 = [];
  36885. for (let n3 = 1; n3 < t2.length - 1; n3 += 2) {
  36886. const i3 = t2[n3];
  36887. if ("string" != typeof i3)
  36888. return e2.error(`Expected string, but found ${typeof i3} instead.`, n3);
  36889. if (/[^a-zA-Z0-9_]/.test(i3))
  36890. return e2.error("Variable names must contain only alphanumeric characters or '_'.", n3);
  36891. const s2 = e2.parse(t2[n3 + 1], n3 + 1);
  36892. if (!s2)
  36893. return null;
  36894. r2.push([i3, s2]);
  36895. }
  36896. const n2 = e2.parse(t2[t2.length - 1], t2.length - 1, e2.expectedType, r2);
  36897. return n2 ? new kr(r2, n2) : null;
  36898. }
  36899. outputDefined() {
  36900. return this.result.outputDefined();
  36901. }
  36902. serialize() {
  36903. const t2 = ["let"];
  36904. for (const [e2, r2] of this.bindings)
  36905. t2.push(e2, r2.serialize());
  36906. return t2.push(this.result.serialize()), t2;
  36907. }
  36908. }
  36909. class Sr {
  36910. constructor(t2, e2, r2) {
  36911. this.type = t2, this.index = e2, this.input = r2;
  36912. }
  36913. static parse(t2, e2) {
  36914. if (3 !== t2.length)
  36915. return e2.error(`Expected 2 arguments, but found ${t2.length - 1} instead.`);
  36916. const r2 = e2.parse(t2[1], 1, Xt), n2 = e2.parse(t2[2], 2, re(e2.expectedType || Jt));
  36917. return r2 && n2 ? new Sr(n2.type.itemType, r2, n2) : null;
  36918. }
  36919. evaluate(t2) {
  36920. const e2 = this.index.evaluate(t2), r2 = this.input.evaluate(t2);
  36921. if (e2 < 0)
  36922. throw new be(`Array index out of bounds: ${e2} < 0.`);
  36923. if (e2 >= r2.length)
  36924. throw new be(`Array index out of bounds: ${e2} > ${r2.length - 1}.`);
  36925. if (e2 !== Math.floor(e2))
  36926. throw new be(`Array index must be an integer, but found ${e2} instead.`);
  36927. return r2[e2];
  36928. }
  36929. eachChild(t2) {
  36930. t2(this.index), t2(this.input);
  36931. }
  36932. outputDefined() {
  36933. return false;
  36934. }
  36935. serialize() {
  36936. return ["at", this.index.serialize(), this.input.serialize()];
  36937. }
  36938. }
  36939. class Ir {
  36940. constructor(t2, e2) {
  36941. this.type = Yt, this.needle = t2, this.haystack = e2;
  36942. }
  36943. static parse(t2, e2) {
  36944. if (3 !== t2.length)
  36945. return e2.error(`Expected 2 arguments, but found ${t2.length - 1} instead.`);
  36946. const r2 = e2.parse(t2[1], 1, Jt), n2 = e2.parse(t2[2], 2, Jt);
  36947. return r2 && n2 ? ae(r2.type, [Yt, Kt, Xt, Zt, Jt]) ? new Ir(r2, n2) : e2.error(`Expected first argument to be of type boolean, string, number or null, but found ${ne(r2.type)} instead`) : null;
  36948. }
  36949. evaluate(t2) {
  36950. const e2 = this.needle.evaluate(t2), r2 = this.haystack.evaluate(t2);
  36951. if (null == r2)
  36952. return false;
  36953. if (!oe(e2, ["boolean", "string", "number", "null"]))
  36954. throw new be(`Expected first argument to be of type boolean, string, number or null, but found ${ne(ge(e2))} instead.`);
  36955. if (!oe(r2, ["string", "array"]))
  36956. throw new be(`Expected second argument to be of type array or string, but found ${ne(ge(r2))} instead.`);
  36957. return r2.indexOf(e2) >= 0;
  36958. }
  36959. eachChild(t2) {
  36960. t2(this.needle), t2(this.haystack);
  36961. }
  36962. outputDefined() {
  36963. return true;
  36964. }
  36965. serialize() {
  36966. return ["in", this.needle.serialize(), this.haystack.serialize()];
  36967. }
  36968. }
  36969. class Mr {
  36970. constructor(t2, e2, r2) {
  36971. this.type = Xt, this.needle = t2, this.haystack = e2, this.fromIndex = r2;
  36972. }
  36973. static parse(t2, e2) {
  36974. if (t2.length <= 2 || t2.length >= 5)
  36975. return e2.error(`Expected 3 or 4 arguments, but found ${t2.length - 1} instead.`);
  36976. const r2 = e2.parse(t2[1], 1, Jt), n2 = e2.parse(t2[2], 2, Jt);
  36977. if (!r2 || !n2)
  36978. return null;
  36979. if (!ae(r2.type, [Yt, Kt, Xt, Zt, Jt]))
  36980. return e2.error(`Expected first argument to be of type boolean, string, number or null, but found ${ne(r2.type)} instead`);
  36981. if (4 === t2.length) {
  36982. const i3 = e2.parse(t2[3], 3, Xt);
  36983. return i3 ? new Mr(r2, n2, i3) : null;
  36984. }
  36985. return new Mr(r2, n2);
  36986. }
  36987. evaluate(t2) {
  36988. const e2 = this.needle.evaluate(t2), r2 = this.haystack.evaluate(t2);
  36989. if (!oe(e2, ["boolean", "string", "number", "null"]))
  36990. throw new be(`Expected first argument to be of type boolean, string, number or null, but found ${ne(ge(e2))} instead.`);
  36991. if (!oe(r2, ["string", "array"]))
  36992. throw new be(`Expected second argument to be of type array or string, but found ${ne(ge(r2))} instead.`);
  36993. if (this.fromIndex) {
  36994. const n2 = this.fromIndex.evaluate(t2);
  36995. return r2.indexOf(e2, n2);
  36996. }
  36997. return r2.indexOf(e2);
  36998. }
  36999. eachChild(t2) {
  37000. t2(this.needle), t2(this.haystack), this.fromIndex && t2(this.fromIndex);
  37001. }
  37002. outputDefined() {
  37003. return false;
  37004. }
  37005. serialize() {
  37006. if (null != this.fromIndex && void 0 !== this.fromIndex) {
  37007. const t2 = this.fromIndex.serialize();
  37008. return ["index-of", this.needle.serialize(), this.haystack.serialize(), t2];
  37009. }
  37010. return ["index-of", this.needle.serialize(), this.haystack.serialize()];
  37011. }
  37012. }
  37013. class Tr {
  37014. constructor(t2, e2, r2, n2, i3, s2) {
  37015. this.inputType = t2, this.type = e2, this.input = r2, this.cases = n2, this.outputs = i3, this.otherwise = s2;
  37016. }
  37017. static parse(t2, e2) {
  37018. if (t2.length < 5)
  37019. return e2.error(`Expected at least 4 arguments, but found only ${t2.length - 1}.`);
  37020. if (t2.length % 2 != 1)
  37021. return e2.error("Expected an even number of arguments.");
  37022. let r2, n2;
  37023. e2.expectedType && "value" !== e2.expectedType.kind && (n2 = e2.expectedType);
  37024. const i3 = {}, s2 = [];
  37025. for (let a3 = 2; a3 < t2.length - 1; a3 += 2) {
  37026. let o3 = t2[a3];
  37027. const l2 = t2[a3 + 1];
  37028. Array.isArray(o3) || (o3 = [o3]);
  37029. const u2 = e2.concat(a3);
  37030. if (0 === o3.length)
  37031. return u2.error("Expected at least one branch label.");
  37032. for (const t3 of o3) {
  37033. if ("number" != typeof t3 && "string" != typeof t3)
  37034. return u2.error("Branch labels must be numbers or strings.");
  37035. if ("number" == typeof t3 && Math.abs(t3) > Number.MAX_SAFE_INTEGER)
  37036. return u2.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);
  37037. if ("number" == typeof t3 && Math.floor(t3) !== t3)
  37038. return u2.error("Numeric branch labels must be integer values.");
  37039. if (r2) {
  37040. if (u2.checkSubtype(r2, ge(t3)))
  37041. return null;
  37042. } else
  37043. r2 = ge(t3);
  37044. if (void 0 !== i3[String(t3)])
  37045. return u2.error("Branch labels must be unique.");
  37046. i3[String(t3)] = s2.length;
  37047. }
  37048. const c2 = e2.parse(l2, a3, n2);
  37049. if (!c2)
  37050. return null;
  37051. n2 = n2 || c2.type, s2.push(c2);
  37052. }
  37053. const a2 = e2.parse(t2[1], 1, Jt);
  37054. if (!a2)
  37055. return null;
  37056. const o2 = e2.parse(t2[t2.length - 1], t2.length - 1, n2);
  37057. return o2 ? "value" !== a2.type.kind && e2.concat(1).checkSubtype(r2, a2.type) ? null : new Tr(r2, n2, a2, i3, s2, o2) : null;
  37058. }
  37059. evaluate(t2) {
  37060. const e2 = this.input.evaluate(t2);
  37061. return (ge(e2) === this.inputType && this.outputs[this.cases[e2]] || this.otherwise).evaluate(t2);
  37062. }
  37063. eachChild(t2) {
  37064. t2(this.input), this.outputs.forEach(t2), t2(this.otherwise);
  37065. }
  37066. outputDefined() {
  37067. return this.outputs.every((t2) => t2.outputDefined()) && this.otherwise.outputDefined();
  37068. }
  37069. serialize() {
  37070. const t2 = ["match", this.input.serialize()], e2 = Object.keys(this.cases).sort(), r2 = [], n2 = {};
  37071. for (const t3 of e2) {
  37072. const e3 = n2[this.cases[t3]];
  37073. void 0 === e3 ? (n2[this.cases[t3]] = r2.length, r2.push([this.cases[t3], [t3]])) : r2[e3][1].push(t3);
  37074. }
  37075. const i3 = (t3) => "number" === this.inputType.kind ? Number(t3) : t3;
  37076. for (const [e3, n3] of r2)
  37077. t2.push(1 === n3.length ? i3(n3[0]) : n3.map(i3)), t2.push(this.outputs[e3].serialize());
  37078. return t2.push(this.otherwise.serialize()), t2;
  37079. }
  37080. }
  37081. class zr {
  37082. constructor(t2, e2, r2) {
  37083. this.type = t2, this.branches = e2, this.otherwise = r2;
  37084. }
  37085. static parse(t2, e2) {
  37086. if (t2.length < 4)
  37087. return e2.error(`Expected at least 3 arguments, but found only ${t2.length - 1}.`);
  37088. if (t2.length % 2 != 0)
  37089. return e2.error("Expected an odd number of arguments.");
  37090. let r2;
  37091. e2.expectedType && "value" !== e2.expectedType.kind && (r2 = e2.expectedType);
  37092. const n2 = [];
  37093. for (let i4 = 1; i4 < t2.length - 1; i4 += 2) {
  37094. const s2 = e2.parse(t2[i4], i4, Yt);
  37095. if (!s2)
  37096. return null;
  37097. const a2 = e2.parse(t2[i4 + 1], i4 + 1, r2);
  37098. if (!a2)
  37099. return null;
  37100. n2.push([s2, a2]), r2 = r2 || a2.type;
  37101. }
  37102. const i3 = e2.parse(t2[t2.length - 1], t2.length - 1, r2);
  37103. return i3 ? new zr(r2, n2, i3) : null;
  37104. }
  37105. evaluate(t2) {
  37106. for (const [e2, r2] of this.branches)
  37107. if (e2.evaluate(t2))
  37108. return r2.evaluate(t2);
  37109. return this.otherwise.evaluate(t2);
  37110. }
  37111. eachChild(t2) {
  37112. for (const [e2, r2] of this.branches)
  37113. t2(e2), t2(r2);
  37114. t2(this.otherwise);
  37115. }
  37116. outputDefined() {
  37117. return this.branches.every(([t2, e2]) => e2.outputDefined()) && this.otherwise.outputDefined();
  37118. }
  37119. serialize() {
  37120. const t2 = ["case"];
  37121. return this.eachChild((e2) => {
  37122. t2.push(e2.serialize());
  37123. }), t2;
  37124. }
  37125. }
  37126. class Br {
  37127. constructor(t2, e2, r2, n2) {
  37128. this.type = t2, this.input = e2, this.beginIndex = r2, this.endIndex = n2;
  37129. }
  37130. static parse(t2, e2) {
  37131. if (t2.length <= 2 || t2.length >= 5)
  37132. return e2.error(`Expected 3 or 4 arguments, but found ${t2.length - 1} instead.`);
  37133. const r2 = e2.parse(t2[1], 1, Jt), n2 = e2.parse(t2[2], 2, Xt);
  37134. if (!r2 || !n2)
  37135. return null;
  37136. if (!ae(r2.type, [re(Jt), Kt, Jt]))
  37137. return e2.error(`Expected first argument to be of type array or string, but found ${ne(r2.type)} instead`);
  37138. if (4 === t2.length) {
  37139. const i3 = e2.parse(t2[3], 3, Xt);
  37140. return i3 ? new Br(r2.type, r2, n2, i3) : null;
  37141. }
  37142. return new Br(r2.type, r2, n2);
  37143. }
  37144. evaluate(t2) {
  37145. const e2 = this.input.evaluate(t2), r2 = this.beginIndex.evaluate(t2);
  37146. if (!oe(e2, ["string", "array"]))
  37147. throw new be(`Expected first argument to be of type array or string, but found ${ne(ge(e2))} instead.`);
  37148. if (this.endIndex) {
  37149. const n2 = this.endIndex.evaluate(t2);
  37150. return e2.slice(r2, n2);
  37151. }
  37152. return e2.slice(r2);
  37153. }
  37154. eachChild(t2) {
  37155. t2(this.input), t2(this.beginIndex), this.endIndex && t2(this.endIndex);
  37156. }
  37157. outputDefined() {
  37158. return false;
  37159. }
  37160. serialize() {
  37161. if (null != this.endIndex && void 0 !== this.endIndex) {
  37162. const t2 = this.endIndex.serialize();
  37163. return ["slice", this.input.serialize(), this.beginIndex.serialize(), t2];
  37164. }
  37165. return ["slice", this.input.serialize(), this.beginIndex.serialize()];
  37166. }
  37167. }
  37168. function Er(t2, e2) {
  37169. return "==" === t2 || "!=" === t2 ? "boolean" === e2.kind || "string" === e2.kind || "number" === e2.kind || "null" === e2.kind || "value" === e2.kind : "string" === e2.kind || "number" === e2.kind || "value" === e2.kind;
  37170. }
  37171. function Cr(t2, e2, r2, n2) {
  37172. return 0 === n2.compare(e2, r2);
  37173. }
  37174. function Dr(t2, e2, r2) {
  37175. const n2 = "==" !== t2 && "!=" !== t2;
  37176. return class i3 {
  37177. constructor(t3, e3, r3) {
  37178. this.type = Yt, this.lhs = t3, this.rhs = e3, this.collator = r3, this.hasUntypedArgument = "value" === t3.type.kind || "value" === e3.type.kind;
  37179. }
  37180. static parse(t3, e3) {
  37181. if (3 !== t3.length && 4 !== t3.length)
  37182. return e3.error("Expected two or three arguments.");
  37183. const r3 = t3[0];
  37184. let s2 = e3.parse(t3[1], 1, Jt);
  37185. if (!s2)
  37186. return null;
  37187. if (!Er(r3, s2.type))
  37188. return e3.concat(1).error(`"${r3}" comparisons are not supported for type '${ne(s2.type)}'.`);
  37189. let a2 = e3.parse(t3[2], 2, Jt);
  37190. if (!a2)
  37191. return null;
  37192. if (!Er(r3, a2.type))
  37193. return e3.concat(2).error(`"${r3}" comparisons are not supported for type '${ne(a2.type)}'.`);
  37194. if (s2.type.kind !== a2.type.kind && "value" !== s2.type.kind && "value" !== a2.type.kind)
  37195. return e3.error(`Cannot compare types '${ne(s2.type)}' and '${ne(a2.type)}'.`);
  37196. n2 && ("value" === s2.type.kind && "value" !== a2.type.kind ? s2 = new we(a2.type, [s2]) : "value" !== s2.type.kind && "value" === a2.type.kind && (a2 = new we(s2.type, [a2])));
  37197. let o2 = null;
  37198. if (4 === t3.length) {
  37199. if ("string" !== s2.type.kind && "string" !== a2.type.kind && "value" !== s2.type.kind && "value" !== a2.type.kind)
  37200. return e3.error("Cannot use collator to compare non-string types.");
  37201. if (o2 = e3.parse(t3[3], 3, Qt), !o2)
  37202. return null;
  37203. }
  37204. return new i3(s2, a2, o2);
  37205. }
  37206. evaluate(i4) {
  37207. const s2 = this.lhs.evaluate(i4), a2 = this.rhs.evaluate(i4);
  37208. if (n2 && this.hasUntypedArgument) {
  37209. const e3 = ge(s2), r3 = ge(a2);
  37210. if (e3.kind !== r3.kind || "string" !== e3.kind && "number" !== e3.kind)
  37211. throw new be(`Expected arguments for "${t2}" to be (string, string) or (number, number), but found (${e3.kind}, ${r3.kind}) instead.`);
  37212. }
  37213. if (this.collator && !n2 && this.hasUntypedArgument) {
  37214. const t3 = ge(s2), r3 = ge(a2);
  37215. if ("string" !== t3.kind || "string" !== r3.kind)
  37216. return e2(i4, s2, a2);
  37217. }
  37218. return this.collator ? r2(i4, s2, a2, this.collator.evaluate(i4)) : e2(i4, s2, a2);
  37219. }
  37220. eachChild(t3) {
  37221. t3(this.lhs), t3(this.rhs), this.collator && t3(this.collator);
  37222. }
  37223. outputDefined() {
  37224. return true;
  37225. }
  37226. serialize() {
  37227. const e3 = [t2];
  37228. return this.eachChild((t3) => {
  37229. e3.push(t3.serialize());
  37230. }), e3;
  37231. }
  37232. };
  37233. }
  37234. const Pr = Dr("==", function(t2, e2, r2) {
  37235. return e2 === r2;
  37236. }, Cr), Vr = Dr("!=", function(t2, e2, r2) {
  37237. return e2 !== r2;
  37238. }, function(t2, e2, r2, n2) {
  37239. return !Cr(0, e2, r2, n2);
  37240. }), Fr = Dr("<", function(t2, e2, r2) {
  37241. return e2 < r2;
  37242. }, function(t2, e2, r2, n2) {
  37243. return n2.compare(e2, r2) < 0;
  37244. }), Lr = Dr(">", function(t2, e2, r2) {
  37245. return e2 > r2;
  37246. }, function(t2, e2, r2, n2) {
  37247. return n2.compare(e2, r2) > 0;
  37248. }), Rr = Dr("<=", function(t2, e2, r2) {
  37249. return e2 <= r2;
  37250. }, function(t2, e2, r2, n2) {
  37251. return n2.compare(e2, r2) <= 0;
  37252. }), Ur = Dr(">=", function(t2, e2, r2) {
  37253. return e2 >= r2;
  37254. }, function(t2, e2, r2, n2) {
  37255. return n2.compare(e2, r2) >= 0;
  37256. });
  37257. class $r {
  37258. constructor(t2, e2, r2, n2, i3) {
  37259. this.type = Kt, this.number = t2, this.locale = e2, this.currency = r2, this.minFractionDigits = n2, this.maxFractionDigits = i3;
  37260. }
  37261. static parse(t2, e2) {
  37262. if (3 !== t2.length)
  37263. return e2.error("Expected two arguments.");
  37264. const r2 = e2.parse(t2[1], 1, Xt);
  37265. if (!r2)
  37266. return null;
  37267. const n2 = t2[2];
  37268. if ("object" != typeof n2 || Array.isArray(n2))
  37269. return e2.error("NumberFormat options argument must be an object.");
  37270. let i3 = null;
  37271. if (n2.locale && (i3 = e2.parse(n2.locale, 1, Kt), !i3))
  37272. return null;
  37273. let s2 = null;
  37274. if (n2.currency && (s2 = e2.parse(n2.currency, 1, Kt), !s2))
  37275. return null;
  37276. let a2 = null;
  37277. if (n2["min-fraction-digits"] && (a2 = e2.parse(n2["min-fraction-digits"], 1, Xt), !a2))
  37278. return null;
  37279. let o2 = null;
  37280. return n2["max-fraction-digits"] && (o2 = e2.parse(n2["max-fraction-digits"], 1, Xt), !o2) ? null : new $r(r2, i3, s2, a2, o2);
  37281. }
  37282. evaluate(t2) {
  37283. return new Intl.NumberFormat(this.locale ? this.locale.evaluate(t2) : [], { style: this.currency ? "currency" : "decimal", currency: this.currency ? this.currency.evaluate(t2) : void 0, minimumFractionDigits: this.minFractionDigits ? this.minFractionDigits.evaluate(t2) : void 0, maximumFractionDigits: this.maxFractionDigits ? this.maxFractionDigits.evaluate(t2) : void 0 }).format(this.number.evaluate(t2));
  37284. }
  37285. eachChild(t2) {
  37286. t2(this.number), this.locale && t2(this.locale), this.currency && t2(this.currency), this.minFractionDigits && t2(this.minFractionDigits), this.maxFractionDigits && t2(this.maxFractionDigits);
  37287. }
  37288. outputDefined() {
  37289. return false;
  37290. }
  37291. serialize() {
  37292. const t2 = {};
  37293. return this.locale && (t2.locale = this.locale.serialize()), this.currency && (t2.currency = this.currency.serialize()), this.minFractionDigits && (t2["min-fraction-digits"] = this.minFractionDigits.serialize()), this.maxFractionDigits && (t2["max-fraction-digits"] = this.maxFractionDigits.serialize()), ["number-format", this.number.serialize(), t2];
  37294. }
  37295. }
  37296. class jr {
  37297. constructor(t2) {
  37298. this.type = Xt, this.input = t2;
  37299. }
  37300. static parse(t2, e2) {
  37301. if (2 !== t2.length)
  37302. return e2.error(`Expected 1 argument, but found ${t2.length - 1} instead.`);
  37303. const r2 = e2.parse(t2[1], 1);
  37304. return r2 ? "array" !== r2.type.kind && "string" !== r2.type.kind && "value" !== r2.type.kind ? e2.error(`Expected argument of type string or array, but found ${ne(r2.type)} instead.`) : new jr(r2) : null;
  37305. }
  37306. evaluate(t2) {
  37307. const e2 = this.input.evaluate(t2);
  37308. if ("string" == typeof e2)
  37309. return e2.length;
  37310. if (Array.isArray(e2))
  37311. return e2.length;
  37312. throw new be(`Expected value to be of type string or array, but found ${ne(ge(e2))} instead.`);
  37313. }
  37314. eachChild(t2) {
  37315. t2(this.input);
  37316. }
  37317. outputDefined() {
  37318. return false;
  37319. }
  37320. serialize() {
  37321. const t2 = ["length"];
  37322. return this.eachChild((e2) => {
  37323. t2.push(e2.serialize());
  37324. }), t2;
  37325. }
  37326. }
  37327. const Or = { "==": Pr, "!=": Vr, ">": Lr, "<": Fr, ">=": Ur, "<=": Rr, array: we, at: Sr, boolean: we, case: zr, coalesce: Ar, collator: Be, format: Ae, image: ke, in: Ir, "index-of": Mr, interpolate: _r, "interpolate-hcl": _r, "interpolate-lab": _r, length: jr, let: kr, literal: ve, match: Tr, number: we, "number-format": $r, object: we, slice: Br, step: er, string: we, "to-boolean": Ie, "to-color": Ie, "to-number": Ie, "to-string": Ie, var: We, within: Xe };
  37328. function qr(t2, [e2, r2, n2, i3]) {
  37329. e2 = e2.evaluate(t2), r2 = r2.evaluate(t2), n2 = n2.evaluate(t2);
  37330. const s2 = i3 ? i3.evaluate(t2) : 1, a2 = ye(e2, r2, n2, s2);
  37331. if (a2)
  37332. throw new be(a2);
  37333. return new ce(e2 / 255 * s2, r2 / 255 * s2, n2 / 255 * s2, s2);
  37334. }
  37335. function Nr(t2, e2) {
  37336. return t2 in e2;
  37337. }
  37338. function Gr(t2, e2) {
  37339. const r2 = e2[t2];
  37340. return void 0 === r2 ? null : r2;
  37341. }
  37342. function Zr(t2) {
  37343. return { type: t2 };
  37344. }
  37345. function Xr(t2) {
  37346. return { result: "success", value: t2 };
  37347. }
  37348. function Kr(t2) {
  37349. return { result: "error", value: t2 };
  37350. }
  37351. function Yr(t2) {
  37352. return "data-driven" === t2["property-type"] || "cross-faded-data-driven" === t2["property-type"];
  37353. }
  37354. function Hr(t2) {
  37355. return !!t2.expression && t2.expression.parameters.indexOf("zoom") > -1;
  37356. }
  37357. function Wr(t2) {
  37358. return !!t2.expression && t2.expression.interpolated;
  37359. }
  37360. function Jr(t2) {
  37361. return t2 instanceof Number ? "number" : t2 instanceof String ? "string" : t2 instanceof Boolean ? "boolean" : Array.isArray(t2) ? "array" : null === t2 ? "null" : typeof t2;
  37362. }
  37363. function Qr(t2) {
  37364. return "object" == typeof t2 && null !== t2 && !Array.isArray(t2);
  37365. }
  37366. function tn(t2) {
  37367. return t2;
  37368. }
  37369. function en(t2, e2) {
  37370. const r2 = "color" === e2.type, n2 = t2.stops && "object" == typeof t2.stops[0][0], i3 = n2 || !(n2 || void 0 !== t2.property), s2 = t2.type || (Wr(e2) ? "exponential" : "interval");
  37371. if (r2 && ((t2 = jt({}, t2)).stops && (t2.stops = t2.stops.map((t3) => [t3[0], ce.parse(t3[1])])), t2.default = ce.parse(t2.default ? t2.default : e2.default)), t2.colorSpace && "rgb" !== t2.colorSpace && !br[t2.colorSpace])
  37372. throw new Error(`Unknown color space: ${t2.colorSpace}`);
  37373. let a2, o2, l2;
  37374. if ("exponential" === s2)
  37375. a2 = an;
  37376. else if ("interval" === s2)
  37377. a2 = sn;
  37378. else if ("categorical" === s2) {
  37379. a2 = nn, o2 = /* @__PURE__ */ Object.create(null);
  37380. for (const e3 of t2.stops)
  37381. o2[e3[0]] = e3[1];
  37382. l2 = typeof t2.stops[0][0];
  37383. } else {
  37384. if ("identity" !== s2)
  37385. throw new Error(`Unknown function type "${s2}"`);
  37386. a2 = on;
  37387. }
  37388. if (n2) {
  37389. const r3 = {}, n3 = [];
  37390. for (let e3 = 0; e3 < t2.stops.length; e3++) {
  37391. const i5 = t2.stops[e3], s4 = i5[0].zoom;
  37392. void 0 === r3[s4] && (r3[s4] = { zoom: s4, type: t2.type, property: t2.property, default: t2.default, stops: [] }, n3.push(s4)), r3[s4].stops.push([i5[0].value, i5[1]]);
  37393. }
  37394. const i4 = [];
  37395. for (const t3 of n3)
  37396. i4.push([r3[t3].zoom, en(r3[t3], e2)]);
  37397. const s3 = { name: "linear" };
  37398. return { kind: "composite", interpolationType: s3, interpolationFactor: _r.interpolationFactor.bind(void 0, s3), zoomStops: i4.map((t3) => t3[0]), evaluate: ({ zoom: r4 }, n4) => an({ stops: i4, base: t2.base }, e2, r4).evaluate(r4, n4) };
  37399. }
  37400. if (i3) {
  37401. const r3 = "exponential" === s2 ? { name: "exponential", base: void 0 !== t2.base ? t2.base : 1 } : null;
  37402. return { kind: "camera", interpolationType: r3, interpolationFactor: _r.interpolationFactor.bind(void 0, r3), zoomStops: t2.stops.map((t3) => t3[0]), evaluate: ({ zoom: r4 }) => a2(t2, e2, r4, o2, l2) };
  37403. }
  37404. return { kind: "source", evaluate(r3, n3) {
  37405. const i4 = n3 && n3.properties ? n3.properties[t2.property] : void 0;
  37406. return void 0 === i4 ? rn(t2.default, e2.default) : a2(t2, e2, i4, o2, l2);
  37407. } };
  37408. }
  37409. function rn(t2, e2, r2) {
  37410. return void 0 !== t2 ? t2 : void 0 !== e2 ? e2 : void 0 !== r2 ? r2 : void 0;
  37411. }
  37412. function nn(t2, e2, r2, n2, i3) {
  37413. return rn(typeof r2 === i3 ? n2[r2] : void 0, t2.default, e2.default);
  37414. }
  37415. function sn(t2, e2, r2) {
  37416. if ("number" !== Jr(r2))
  37417. return rn(t2.default, e2.default);
  37418. const n2 = t2.stops.length;
  37419. if (1 === n2)
  37420. return t2.stops[0][1];
  37421. if (r2 <= t2.stops[0][0])
  37422. return t2.stops[0][1];
  37423. if (r2 >= t2.stops[n2 - 1][0])
  37424. return t2.stops[n2 - 1][1];
  37425. const i3 = tr(t2.stops.map((t3) => t3[0]), r2);
  37426. return t2.stops[i3][1];
  37427. }
  37428. function an(t2, e2, r2) {
  37429. const n2 = void 0 !== t2.base ? t2.base : 1;
  37430. if ("number" !== Jr(r2))
  37431. return rn(t2.default, e2.default);
  37432. const i3 = t2.stops.length;
  37433. if (1 === i3)
  37434. return t2.stops[0][1];
  37435. if (r2 <= t2.stops[0][0])
  37436. return t2.stops[0][1];
  37437. if (r2 >= t2.stops[i3 - 1][0])
  37438. return t2.stops[i3 - 1][1];
  37439. const s2 = tr(t2.stops.map((t3) => t3[0]), r2), a2 = function(t3, e3, r3, n3) {
  37440. const i4 = n3 - r3, s3 = t3 - r3;
  37441. return 0 === i4 ? 0 : 1 === e3 ? s3 / i4 : (Math.pow(e3, s3) - 1) / (Math.pow(e3, i4) - 1);
  37442. }(r2, n2, t2.stops[s2][0], t2.stops[s2 + 1][0]), o2 = t2.stops[s2][1], l2 = t2.stops[s2 + 1][1];
  37443. let u2 = nr[e2.type] || tn;
  37444. if (t2.colorSpace && "rgb" !== t2.colorSpace) {
  37445. const e3 = br[t2.colorSpace];
  37446. u2 = (t3, r3) => e3.reverse(e3.interpolate(e3.forward(t3), e3.forward(r3), a2));
  37447. }
  37448. return "function" == typeof o2.evaluate ? { evaluate(...t3) {
  37449. const e3 = o2.evaluate.apply(void 0, t3), r3 = l2.evaluate.apply(void 0, t3);
  37450. if (void 0 !== e3 && void 0 !== r3)
  37451. return u2(e3, r3, a2);
  37452. } } : u2(o2, l2, a2);
  37453. }
  37454. function on(t2, e2, r2) {
  37455. return "color" === e2.type ? r2 = ce.parse(r2) : "formatted" === e2.type ? r2 = fe.fromString(r2.toString()) : "resolvedImage" === e2.type ? r2 = de.fromString(r2.toString()) : Jr(r2) === e2.type || "enum" === e2.type && e2.values[r2] || (r2 = void 0), rn(r2, t2.default, e2.default);
  37456. }
  37457. ze.register(Or, { error: [{ kind: "error" }, [Kt], (t2, [e2]) => {
  37458. throw new be(e2.evaluate(t2));
  37459. }], typeof: [Kt, [Jt], (t2, [e2]) => ne(ge(e2.evaluate(t2)))], "to-rgba": [re(Xt, 4), [Ht], (t2, [e2]) => e2.evaluate(t2).toArray()], rgb: [Ht, [Xt, Xt, Xt], qr], rgba: [Ht, [Xt, Xt, Xt, Xt], qr], has: { type: Yt, overloads: [[[Kt], (t2, [e2]) => Nr(e2.evaluate(t2), t2.properties())], [[Kt, Wt], (t2, [e2, r2]) => Nr(e2.evaluate(t2), r2.evaluate(t2))]] }, get: { type: Jt, overloads: [[[Kt], (t2, [e2]) => Gr(e2.evaluate(t2), t2.properties())], [[Kt, Wt], (t2, [e2, r2]) => Gr(e2.evaluate(t2), r2.evaluate(t2))]] }, "feature-state": [Jt, [Kt], (t2, [e2]) => Gr(e2.evaluate(t2), t2.featureState || {})], properties: [Wt, [], (t2) => t2.properties()], "geometry-type": [Kt, [], (t2) => t2.geometryType()], id: [Jt, [], (t2) => t2.id()], zoom: [Xt, [], (t2) => t2.globals.zoom], pitch: [Xt, [], (t2) => t2.globals.pitch || 0], "distance-from-center": [Xt, [], (t2) => t2.distanceFromCenter()], "heatmap-density": [Xt, [], (t2) => t2.globals.heatmapDensity || 0], "line-progress": [Xt, [], (t2) => t2.globals.lineProgress || 0], "sky-radial-progress": [Xt, [], (t2) => t2.globals.skyRadialProgress || 0], accumulated: [Jt, [], (t2) => void 0 === t2.globals.accumulated ? null : t2.globals.accumulated], "+": [Xt, Zr(Xt), (t2, e2) => {
  37460. let r2 = 0;
  37461. for (const n2 of e2)
  37462. r2 += n2.evaluate(t2);
  37463. return r2;
  37464. }], "*": [Xt, Zr(Xt), (t2, e2) => {
  37465. let r2 = 1;
  37466. for (const n2 of e2)
  37467. r2 *= n2.evaluate(t2);
  37468. return r2;
  37469. }], "-": { type: Xt, overloads: [[[Xt, Xt], (t2, [e2, r2]) => e2.evaluate(t2) - r2.evaluate(t2)], [[Xt], (t2, [e2]) => -e2.evaluate(t2)]] }, "/": [Xt, [Xt, Xt], (t2, [e2, r2]) => e2.evaluate(t2) / r2.evaluate(t2)], "%": [Xt, [Xt, Xt], (t2, [e2, r2]) => e2.evaluate(t2) % r2.evaluate(t2)], ln2: [Xt, [], () => Math.LN2], pi: [Xt, [], () => Math.PI], e: [Xt, [], () => Math.E], "^": [Xt, [Xt, Xt], (t2, [e2, r2]) => Math.pow(e2.evaluate(t2), r2.evaluate(t2))], sqrt: [Xt, [Xt], (t2, [e2]) => Math.sqrt(e2.evaluate(t2))], log10: [Xt, [Xt], (t2, [e2]) => Math.log(e2.evaluate(t2)) / Math.LN10], ln: [Xt, [Xt], (t2, [e2]) => Math.log(e2.evaluate(t2))], log2: [Xt, [Xt], (t2, [e2]) => Math.log(e2.evaluate(t2)) / Math.LN2], sin: [Xt, [Xt], (t2, [e2]) => Math.sin(e2.evaluate(t2))], cos: [Xt, [Xt], (t2, [e2]) => Math.cos(e2.evaluate(t2))], tan: [Xt, [Xt], (t2, [e2]) => Math.tan(e2.evaluate(t2))], asin: [Xt, [Xt], (t2, [e2]) => Math.asin(e2.evaluate(t2))], acos: [Xt, [Xt], (t2, [e2]) => Math.acos(e2.evaluate(t2))], atan: [Xt, [Xt], (t2, [e2]) => Math.atan(e2.evaluate(t2))], min: [Xt, Zr(Xt), (t2, e2) => Math.min(...e2.map((e3) => e3.evaluate(t2)))], max: [Xt, Zr(Xt), (t2, e2) => Math.max(...e2.map((e3) => e3.evaluate(t2)))], abs: [Xt, [Xt], (t2, [e2]) => Math.abs(e2.evaluate(t2))], round: [Xt, [Xt], (t2, [e2]) => {
  37470. const r2 = e2.evaluate(t2);
  37471. return r2 < 0 ? -Math.round(-r2) : Math.round(r2);
  37472. }], floor: [Xt, [Xt], (t2, [e2]) => Math.floor(e2.evaluate(t2))], ceil: [Xt, [Xt], (t2, [e2]) => Math.ceil(e2.evaluate(t2))], "filter-==": [Yt, [Kt, Jt], (t2, [e2, r2]) => t2.properties()[e2.value] === r2.value], "filter-id-==": [Yt, [Jt], (t2, [e2]) => t2.id() === e2.value], "filter-type-==": [Yt, [Kt], (t2, [e2]) => t2.geometryType() === e2.value], "filter-<": [Yt, [Kt, Jt], (t2, [e2, r2]) => {
  37473. const n2 = t2.properties()[e2.value], i3 = r2.value;
  37474. return typeof n2 == typeof i3 && n2 < i3;
  37475. }], "filter-id-<": [Yt, [Jt], (t2, [e2]) => {
  37476. const r2 = t2.id(), n2 = e2.value;
  37477. return typeof r2 == typeof n2 && r2 < n2;
  37478. }], "filter->": [Yt, [Kt, Jt], (t2, [e2, r2]) => {
  37479. const n2 = t2.properties()[e2.value], i3 = r2.value;
  37480. return typeof n2 == typeof i3 && n2 > i3;
  37481. }], "filter-id->": [Yt, [Jt], (t2, [e2]) => {
  37482. const r2 = t2.id(), n2 = e2.value;
  37483. return typeof r2 == typeof n2 && r2 > n2;
  37484. }], "filter-<=": [Yt, [Kt, Jt], (t2, [e2, r2]) => {
  37485. const n2 = t2.properties()[e2.value], i3 = r2.value;
  37486. return typeof n2 == typeof i3 && n2 <= i3;
  37487. }], "filter-id-<=": [Yt, [Jt], (t2, [e2]) => {
  37488. const r2 = t2.id(), n2 = e2.value;
  37489. return typeof r2 == typeof n2 && r2 <= n2;
  37490. }], "filter->=": [Yt, [Kt, Jt], (t2, [e2, r2]) => {
  37491. const n2 = t2.properties()[e2.value], i3 = r2.value;
  37492. return typeof n2 == typeof i3 && n2 >= i3;
  37493. }], "filter-id->=": [Yt, [Jt], (t2, [e2]) => {
  37494. const r2 = t2.id(), n2 = e2.value;
  37495. return typeof r2 == typeof n2 && r2 >= n2;
  37496. }], "filter-has": [Yt, [Jt], (t2, [e2]) => e2.value in t2.properties()], "filter-has-id": [Yt, [], (t2) => null !== t2.id() && void 0 !== t2.id()], "filter-type-in": [Yt, [re(Kt)], (t2, [e2]) => e2.value.indexOf(t2.geometryType()) >= 0], "filter-id-in": [Yt, [re(Jt)], (t2, [e2]) => e2.value.indexOf(t2.id()) >= 0], "filter-in-small": [Yt, [Kt, re(Jt)], (t2, [e2, r2]) => r2.value.indexOf(t2.properties()[e2.value]) >= 0], "filter-in-large": [Yt, [Kt, re(Jt)], (t2, [e2, r2]) => function(t3, e3, r3, n2) {
  37497. for (; r3 <= n2; ) {
  37498. const i3 = r3 + n2 >> 1;
  37499. if (e3[i3] === t3)
  37500. return true;
  37501. e3[i3] > t3 ? n2 = i3 - 1 : r3 = i3 + 1;
  37502. }
  37503. return false;
  37504. }(t2.properties()[e2.value], r2.value, 0, r2.value.length - 1)], all: { type: Yt, overloads: [[[Yt, Yt], (t2, [e2, r2]) => e2.evaluate(t2) && r2.evaluate(t2)], [Zr(Yt), (t2, e2) => {
  37505. for (const r2 of e2)
  37506. if (!r2.evaluate(t2))
  37507. return false;
  37508. return true;
  37509. }]] }, any: { type: Yt, overloads: [[[Yt, Yt], (t2, [e2, r2]) => e2.evaluate(t2) || r2.evaluate(t2)], [Zr(Yt), (t2, e2) => {
  37510. for (const r2 of e2)
  37511. if (r2.evaluate(t2))
  37512. return true;
  37513. return false;
  37514. }]] }, "!": [Yt, [Yt], (t2, [e2]) => !e2.evaluate(t2)], "is-supported-script": [Yt, [Kt], (t2, [e2]) => {
  37515. const r2 = t2.globals && t2.globals.isSupportedScript;
  37516. return !r2 || r2(e2.evaluate(t2));
  37517. }], upcase: [Kt, [Kt], (t2, [e2]) => e2.evaluate(t2).toUpperCase()], downcase: [Kt, [Kt], (t2, [e2]) => e2.evaluate(t2).toLowerCase()], concat: [Kt, Zr(Jt), (t2, e2) => e2.map((e3) => xe(e3.evaluate(t2))).join("")], "resolved-locale": [Kt, [Qt], (t2, [e2]) => e2.evaluate(t2).resolvedLocale()] });
  37518. class ln {
  37519. constructor(t2, e2) {
  37520. this.expression = t2, this._warningHistory = {}, this._evaluator = new Te(), this._defaultValue = e2 ? function(t3) {
  37521. return "color" === t3.type && Qr(t3.default) ? new ce(0, 0, 0, 0) : "color" === t3.type ? ce.parse(t3.default) || null : void 0 === t3.default ? null : t3.default;
  37522. }(e2) : null, this._enumValues = e2 && "enum" === e2.type ? e2.values : null;
  37523. }
  37524. evaluateWithoutErrorHandling(t2, e2, r2, n2, i3, s2, a2, o2) {
  37525. return this._evaluator.globals = t2, this._evaluator.feature = e2, this._evaluator.featureState = r2, this._evaluator.canonical = n2 || null, this._evaluator.availableImages = i3 || null, this._evaluator.formattedSection = s2, this._evaluator.featureTileCoord = a2 || null, this._evaluator.featureDistanceData = o2 || null, this.expression.evaluate(this._evaluator);
  37526. }
  37527. evaluate(t2, e2, r2, n2, i3, s2, a2, o2) {
  37528. this._evaluator.globals = t2, this._evaluator.feature = e2 || null, this._evaluator.featureState = r2 || null, this._evaluator.canonical = n2 || null, this._evaluator.availableImages = i3 || null, this._evaluator.formattedSection = s2 || null, this._evaluator.featureTileCoord = a2 || null, this._evaluator.featureDistanceData = o2 || null;
  37529. try {
  37530. const t3 = this.expression.evaluate(this._evaluator);
  37531. if (null == t3 || "number" == typeof t3 && t3 != t3)
  37532. return this._defaultValue;
  37533. if (this._enumValues && !(t3 in this._enumValues))
  37534. throw new be(`Expected value to be one of ${Object.keys(this._enumValues).map((t4) => JSON.stringify(t4)).join(", ")}, but found ${JSON.stringify(t3)} instead.`);
  37535. return t3;
  37536. } catch (t3) {
  37537. return this._warningHistory[t3.message] || (this._warningHistory[t3.message] = true, "undefined" != typeof console && console.warn(t3.message)), this._defaultValue;
  37538. }
  37539. }
  37540. }
  37541. function un(t2) {
  37542. return Array.isArray(t2) && t2.length > 0 && "string" == typeof t2[0] && t2[0] in Or;
  37543. }
  37544. function cn(t2, e2) {
  37545. const r2 = new Je(Or, [], e2 ? function(t3) {
  37546. const e3 = { color: Ht, string: Kt, number: Xt, enum: Kt, boolean: Yt, formatted: te, resolvedImage: ee };
  37547. return "array" === t3.type ? re(e3[t3.value] || Jt, t3.length) : e3[t3.type];
  37548. }(e2) : void 0), n2 = r2.parse(t2, void 0, void 0, void 0, e2 && "string" === e2.type ? { typeAnnotation: "coerce" } : void 0);
  37549. return n2 ? Xr(new ln(n2, e2)) : Kr(r2.errors);
  37550. }
  37551. class hn {
  37552. constructor(t2, e2) {
  37553. this.kind = t2, this._styleExpression = e2, this.isStateDependent = "constant" !== t2 && !Ye(e2.expression);
  37554. }
  37555. evaluateWithoutErrorHandling(t2, e2, r2, n2, i3, s2) {
  37556. return this._styleExpression.evaluateWithoutErrorHandling(t2, e2, r2, n2, i3, s2);
  37557. }
  37558. evaluate(t2, e2, r2, n2, i3, s2) {
  37559. return this._styleExpression.evaluate(t2, e2, r2, n2, i3, s2);
  37560. }
  37561. }
  37562. class pn {
  37563. constructor(t2, e2, r2, n2) {
  37564. this.kind = t2, this.zoomStops = r2, this._styleExpression = e2, this.isStateDependent = "camera" !== t2 && !Ye(e2.expression), this.interpolationType = n2;
  37565. }
  37566. evaluateWithoutErrorHandling(t2, e2, r2, n2, i3, s2) {
  37567. return this._styleExpression.evaluateWithoutErrorHandling(t2, e2, r2, n2, i3, s2);
  37568. }
  37569. evaluate(t2, e2, r2, n2, i3, s2) {
  37570. return this._styleExpression.evaluate(t2, e2, r2, n2, i3, s2);
  37571. }
  37572. interpolationFactor(t2, e2, r2) {
  37573. return this.interpolationType ? _r.interpolationFactor(this.interpolationType, t2, e2, r2) : 0;
  37574. }
  37575. }
  37576. function fn(t2, e2) {
  37577. if ("error" === (t2 = cn(t2, e2)).result)
  37578. return t2;
  37579. const r2 = t2.value.expression, n2 = Ke(r2);
  37580. if (!n2 && !Yr(e2))
  37581. return Kr([new Nt("", "data expressions not supported")]);
  37582. const i3 = He(r2, ["zoom", "pitch", "distance-from-center"]);
  37583. if (!i3 && !Hr(e2))
  37584. return Kr([new Nt("", "zoom expressions not supported")]);
  37585. const s2 = yn(r2);
  37586. return s2 || i3 ? s2 instanceof Nt ? Kr([s2]) : s2 instanceof _r && !Wr(e2) ? Kr([new Nt("", '"interpolate" expressions cannot be used with this property')]) : Xr(s2 ? new pn(n2 ? "camera" : "composite", t2.value, s2.labels, s2 instanceof _r ? s2.interpolation : void 0) : new hn(n2 ? "constant" : "source", t2.value)) : Kr([new Nt("", '"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);
  37587. }
  37588. class dn {
  37589. constructor(t2, e2) {
  37590. this._parameters = t2, this._specification = e2, jt(this, en(this._parameters, this._specification));
  37591. }
  37592. static deserialize(t2) {
  37593. return new dn(t2._parameters, t2._specification);
  37594. }
  37595. static serialize(t2) {
  37596. return { _parameters: t2._parameters, _specification: t2._specification };
  37597. }
  37598. }
  37599. function yn(t2) {
  37600. let e2 = null;
  37601. if (t2 instanceof kr)
  37602. e2 = yn(t2.result);
  37603. else if (t2 instanceof Ar) {
  37604. for (const r2 of t2.args)
  37605. if (e2 = yn(r2), e2)
  37606. break;
  37607. } else
  37608. (t2 instanceof er || t2 instanceof _r) && t2.input instanceof ze && "zoom" === t2.input.name && (e2 = t2);
  37609. return e2 instanceof Nt || t2.eachChild((t3) => {
  37610. const r2 = yn(t3);
  37611. r2 instanceof Nt ? e2 = r2 : !e2 && r2 ? e2 = new Nt("", '"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.') : e2 && r2 && e2 !== r2 && (e2 = new Nt("", 'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));
  37612. }), e2;
  37613. }
  37614. class mn {
  37615. constructor(t2, e2, r2, n2) {
  37616. this.message = (t2 ? `${t2}: ` : "") + r2, n2 && (this.identifier = n2), null != e2 && e2.__line__ && (this.line = e2.__line__);
  37617. }
  37618. }
  37619. function gn(t2) {
  37620. const e2 = t2.key, r2 = t2.value, n2 = t2.valueSpec || {}, i3 = t2.objectElementValidators || {}, s2 = t2.style, a2 = t2.styleSpec;
  37621. let o2 = [];
  37622. const l2 = Jr(r2);
  37623. if ("object" !== l2)
  37624. return [new mn(e2, r2, `object expected, ${l2} found`)];
  37625. for (const t3 in r2) {
  37626. const l3 = t3.split(".")[0], u2 = n2[l3] || n2["*"];
  37627. let c2;
  37628. i3[l3] ? c2 = i3[l3] : n2[l3] ? c2 = Hn : i3["*"] ? c2 = i3["*"] : n2["*"] && (c2 = Hn), c2 ? o2 = o2.concat(c2({ key: (e2 ? `${e2}.` : e2) + t3, value: r2[t3], valueSpec: u2, style: s2, styleSpec: a2, object: r2, objectKey: t3 }, r2)) : o2.push(new mn(e2, r2[t3], `unknown property "${t3}"`));
  37629. }
  37630. for (const t3 in n2)
  37631. i3[t3] || n2[t3].required && void 0 === n2[t3].default && void 0 === r2[t3] && o2.push(new mn(e2, r2, `missing required property "${t3}"`));
  37632. return o2;
  37633. }
  37634. function xn(t2) {
  37635. const e2 = t2.value, r2 = t2.valueSpec, n2 = t2.style, i3 = t2.styleSpec, s2 = t2.key, a2 = t2.arrayElementValidator || Hn;
  37636. if ("array" !== Jr(e2))
  37637. return [new mn(s2, e2, `array expected, ${Jr(e2)} found`)];
  37638. if (r2.length && e2.length !== r2.length)
  37639. return [new mn(s2, e2, `array length ${r2.length} expected, length ${e2.length} found`)];
  37640. if (r2["min-length"] && e2.length < r2["min-length"])
  37641. return [new mn(s2, e2, `array length at least ${r2["min-length"]} expected, length ${e2.length} found`)];
  37642. let o2 = { type: r2.value, values: r2.values, minimum: r2.minimum, maximum: r2.maximum, function: void 0 };
  37643. i3.$version < 7 && (o2.function = r2.function), "object" === Jr(r2.value) && (o2 = r2.value);
  37644. let l2 = [];
  37645. for (let t3 = 0; t3 < e2.length; t3++)
  37646. l2 = l2.concat(a2({ array: e2, arrayIndex: t3, value: e2[t3], valueSpec: o2, style: n2, styleSpec: i3, key: `${s2}[${t3}]` }));
  37647. return l2;
  37648. }
  37649. function vn(t2) {
  37650. const e2 = t2.key, r2 = t2.value, n2 = t2.valueSpec;
  37651. let i3 = Jr(r2);
  37652. if ("number" === i3 && r2 != r2 && (i3 = "NaN"), "number" !== i3)
  37653. return [new mn(e2, r2, `number expected, ${i3} found`)];
  37654. if ("minimum" in n2) {
  37655. let i4 = n2.minimum;
  37656. if ("array" === Jr(n2.minimum) && (i4 = n2.minimum[t2.arrayIndex]), r2 < i4)
  37657. return [new mn(e2, r2, `${r2} is less than the minimum value ${i4}`)];
  37658. }
  37659. if ("maximum" in n2) {
  37660. let i4 = n2.maximum;
  37661. if ("array" === Jr(n2.maximum) && (i4 = n2.maximum[t2.arrayIndex]), r2 > i4)
  37662. return [new mn(e2, r2, `${r2} is greater than the maximum value ${i4}`)];
  37663. }
  37664. return [];
  37665. }
  37666. function bn(t2) {
  37667. const e2 = t2.valueSpec, r2 = Ot(t2.value.type);
  37668. let n2, i3, s2, a2 = {};
  37669. const o2 = "categorical" !== r2 && void 0 === t2.value.property, l2 = !o2, u2 = "array" === Jr(t2.value.stops) && "array" === Jr(t2.value.stops[0]) && "object" === Jr(t2.value.stops[0][0]), c2 = gn({ key: t2.key, value: t2.value, valueSpec: t2.styleSpec.function, style: t2.style, styleSpec: t2.styleSpec, objectElementValidators: { stops: function(t3) {
  37670. if ("identity" === r2)
  37671. return [new mn(t3.key, t3.value, 'identity function may not have a "stops" property')];
  37672. let e3 = [];
  37673. const n3 = t3.value;
  37674. return e3 = e3.concat(xn({ key: t3.key, value: n3, valueSpec: t3.valueSpec, style: t3.style, styleSpec: t3.styleSpec, arrayElementValidator: h2 })), "array" === Jr(n3) && 0 === n3.length && e3.push(new mn(t3.key, n3, "array must have at least one stop")), e3;
  37675. }, default: function(t3) {
  37676. return Hn({ key: t3.key, value: t3.value, valueSpec: e2, style: t3.style, styleSpec: t3.styleSpec });
  37677. } } });
  37678. return "identity" === r2 && o2 && c2.push(new mn(t2.key, t2.value, 'missing required property "property"')), "identity" === r2 || t2.value.stops || c2.push(new mn(t2.key, t2.value, 'missing required property "stops"')), "exponential" === r2 && t2.valueSpec.expression && !Wr(t2.valueSpec) && c2.push(new mn(t2.key, t2.value, "exponential functions not supported")), t2.styleSpec.$version >= 8 && (l2 && !Yr(t2.valueSpec) ? c2.push(new mn(t2.key, t2.value, "property functions not supported")) : o2 && !Hr(t2.valueSpec) && c2.push(new mn(t2.key, t2.value, "zoom functions not supported"))), "categorical" !== r2 && !u2 || void 0 !== t2.value.property || c2.push(new mn(t2.key, t2.value, '"property" property is required')), c2;
  37679. function h2(t3) {
  37680. let r3 = [];
  37681. const n3 = t3.value, o3 = t3.key;
  37682. if ("array" !== Jr(n3))
  37683. return [new mn(o3, n3, `array expected, ${Jr(n3)} found`)];
  37684. if (2 !== n3.length)
  37685. return [new mn(o3, n3, `array length 2 expected, length ${n3.length} found`)];
  37686. if (u2) {
  37687. if ("object" !== Jr(n3[0]))
  37688. return [new mn(o3, n3, `object expected, ${Jr(n3[0])} found`)];
  37689. if (void 0 === n3[0].zoom)
  37690. return [new mn(o3, n3, "object stop key must have zoom")];
  37691. if (void 0 === n3[0].value)
  37692. return [new mn(o3, n3, "object stop key must have value")];
  37693. const e3 = Ot(n3[0].zoom);
  37694. if ("number" != typeof e3)
  37695. return [new mn(o3, n3[0].zoom, "stop zoom values must be numbers")];
  37696. if (s2 && s2 > e3)
  37697. return [new mn(o3, n3[0].zoom, "stop zoom values must appear in ascending order")];
  37698. e3 !== s2 && (s2 = e3, i3 = void 0, a2 = {}), r3 = r3.concat(gn({ key: `${o3}[0]`, value: n3[0], valueSpec: { zoom: {} }, style: t3.style, styleSpec: t3.styleSpec, objectElementValidators: { zoom: vn, value: p2 } }));
  37699. } else
  37700. r3 = r3.concat(p2({ key: `${o3}[0]`, value: n3[0], valueSpec: {}, style: t3.style, styleSpec: t3.styleSpec }, n3));
  37701. return un(qt(n3[1])) ? r3.concat([new mn(`${o3}[1]`, n3[1], "expressions are not allowed in function stops.")]) : r3.concat(Hn({ key: `${o3}[1]`, value: n3[1], valueSpec: e2, style: t3.style, styleSpec: t3.styleSpec }));
  37702. }
  37703. function p2(t3, s3) {
  37704. const o3 = Jr(t3.value), l3 = Ot(t3.value), u3 = null !== t3.value ? t3.value : s3;
  37705. if (n2) {
  37706. if (o3 !== n2)
  37707. return [new mn(t3.key, u3, `${o3} stop domain type must match previous stop domain type ${n2}`)];
  37708. } else
  37709. n2 = o3;
  37710. if ("number" !== o3 && "string" !== o3 && "boolean" !== o3 && "number" != typeof l3 && "string" != typeof l3 && "boolean" != typeof l3)
  37711. return [new mn(t3.key, u3, "stop domain value must be a number, string, or boolean")];
  37712. if ("number" !== o3 && "categorical" !== r2) {
  37713. let n3 = `number expected, ${o3} found`;
  37714. return Yr(e2) && void 0 === r2 && (n3 += '\nIf you intended to use a categorical function, specify `"type": "categorical"`.'), [new mn(t3.key, u3, n3)];
  37715. }
  37716. return "categorical" !== r2 || "number" !== o3 || "number" == typeof l3 && isFinite(l3) && Math.floor(l3) === l3 ? "categorical" !== r2 && "number" === o3 && "number" == typeof l3 && "number" == typeof i3 && void 0 !== i3 && l3 < i3 ? [new mn(t3.key, u3, "stop domain values must appear in ascending order")] : (i3 = l3, "categorical" === r2 && l3 in a2 ? [new mn(t3.key, u3, "stop domain values must be unique")] : (a2[l3] = true, [])) : [new mn(t3.key, u3, `integer expected, found ${String(l3)}`)];
  37717. }
  37718. }
  37719. function _n(t2) {
  37720. const e2 = ("property" === t2.expressionContext ? fn : cn)(qt(t2.value), t2.valueSpec);
  37721. if ("error" === e2.result)
  37722. return e2.value.map((e3) => new mn(`${t2.key}${e3.key}`, t2.value, e3.message));
  37723. const r2 = e2.value.expression || e2.value._styleExpression.expression;
  37724. if ("property" === t2.expressionContext && "text-font" === t2.propertyKey && !r2.outputDefined())
  37725. return [new mn(t2.key, t2.value, `Invalid data expression for "${t2.propertyKey}". Output values must be contained as literals within the expression.`)];
  37726. if ("property" === t2.expressionContext && "layout" === t2.propertyType && !Ye(r2))
  37727. return [new mn(t2.key, t2.value, '"feature-state" data expressions are not supported with layout properties.')];
  37728. if ("filter" === t2.expressionContext)
  37729. return wn(r2, t2);
  37730. if (t2.expressionContext && 0 === t2.expressionContext.indexOf("cluster")) {
  37731. if (!He(r2, ["zoom", "feature-state"]))
  37732. return [new mn(t2.key, t2.value, '"zoom" and "feature-state" expressions are not supported with cluster properties.')];
  37733. if ("cluster-initial" === t2.expressionContext && !Ke(r2))
  37734. return [new mn(t2.key, t2.value, "Feature data expressions are not supported with initial expression part of cluster properties.")];
  37735. }
  37736. return [];
  37737. }
  37738. function wn(t2, e2) {
  37739. const r2 = /* @__PURE__ */ new Set(["zoom", "feature-state", "pitch", "distance-from-center"]);
  37740. if (e2.valueSpec && e2.valueSpec.expression)
  37741. for (const t3 of e2.valueSpec.expression.parameters)
  37742. r2.delete(t3);
  37743. if (0 === r2.size)
  37744. return [];
  37745. const n2 = [];
  37746. return t2 instanceof ze && r2.has(t2.name) ? [new mn(e2.key, e2.value, `["${t2.name}"] expression is not supported in a filter for a ${e2.object.type} layer with id: ${e2.object.id}`)] : (t2.eachChild((t3) => {
  37747. n2.push(...wn(t3, e2));
  37748. }), n2);
  37749. }
  37750. function An(t2) {
  37751. const e2 = t2.key, r2 = t2.value, n2 = t2.valueSpec, i3 = [];
  37752. return Array.isArray(n2.values) ? -1 === n2.values.indexOf(Ot(r2)) && i3.push(new mn(e2, r2, `expected one of [${n2.values.join(", ")}], ${JSON.stringify(r2)} found`)) : -1 === Object.keys(n2.values).indexOf(Ot(r2)) && i3.push(new mn(e2, r2, `expected one of [${Object.keys(n2.values).join(", ")}], ${JSON.stringify(r2)} found`)), i3;
  37753. }
  37754. function kn(t2) {
  37755. if (true === t2 || false === t2)
  37756. return true;
  37757. if (!Array.isArray(t2) || 0 === t2.length)
  37758. return false;
  37759. switch (t2[0]) {
  37760. case "has":
  37761. return t2.length >= 2 && "$id" !== t2[1] && "$type" !== t2[1];
  37762. case "in":
  37763. return t2.length >= 3 && ("string" != typeof t2[1] || Array.isArray(t2[2]));
  37764. case "!in":
  37765. case "!has":
  37766. case "none":
  37767. return false;
  37768. case "==":
  37769. case "!=":
  37770. case ">":
  37771. case ">=":
  37772. case "<":
  37773. case "<=":
  37774. return 3 !== t2.length || Array.isArray(t2[1]) || Array.isArray(t2[2]);
  37775. case "any":
  37776. case "all":
  37777. for (const e2 of t2.slice(1))
  37778. if (!kn(e2) && "boolean" != typeof e2)
  37779. return false;
  37780. return true;
  37781. default:
  37782. return true;
  37783. }
  37784. }
  37785. function Sn(t2, e2 = "fill") {
  37786. if (null == t2)
  37787. return { filter: () => true, needGeometry: false, needFeature: false };
  37788. kn(t2) || (t2 = Cn(t2));
  37789. const r2 = t2;
  37790. let n2 = true;
  37791. try {
  37792. n2 = function(t3) {
  37793. if (!Tn(t3))
  37794. return t3;
  37795. let e3 = qt(t3);
  37796. return Mn(e3), e3 = In(e3), e3;
  37797. }(r2);
  37798. } catch (t3) {
  37799. console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.
  37800. This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md
  37801. and paste the contents of this message in the report.
  37802. Thank you!
  37803. Filter Expression:
  37804. ${JSON.stringify(r2, null, 2)}
  37805. `);
  37806. }
  37807. const i3 = $t[`filter_${e2}`], s2 = cn(n2, i3);
  37808. let a2 = null;
  37809. if ("error" === s2.result)
  37810. throw new Error(s2.value.map((t3) => `${t3.key}: ${t3.message}`).join(", "));
  37811. a2 = (t3, e3, r3) => s2.value.evaluate(t3, e3, {}, r3);
  37812. let o2 = null, l2 = null;
  37813. if (n2 !== r2) {
  37814. const t3 = cn(r2, i3);
  37815. if ("error" === t3.result)
  37816. throw new Error(t3.value.map((t4) => `${t4.key}: ${t4.message}`).join(", "));
  37817. o2 = (e3, r3, n3, i4, s3) => t3.value.evaluate(e3, r3, {}, n3, void 0, void 0, i4, s3), l2 = !Ke(t3.value.expression);
  37818. }
  37819. return a2 = a2, { filter: a2, dynamicFilter: o2 || void 0, needGeometry: En(n2), needFeature: !!l2 };
  37820. }
  37821. function In(t2) {
  37822. if (!Array.isArray(t2))
  37823. return t2;
  37824. const e2 = function(t3) {
  37825. if (zn.has(t3[0])) {
  37826. for (let e3 = 1; e3 < t3.length; e3++)
  37827. if (Tn(t3[e3]))
  37828. return true;
  37829. }
  37830. return t3;
  37831. }(t2);
  37832. return true === e2 ? e2 : e2.map((t3) => In(t3));
  37833. }
  37834. function Mn(t2) {
  37835. let e2 = false;
  37836. const r2 = [];
  37837. if ("case" === t2[0]) {
  37838. for (let n2 = 1; n2 < t2.length - 1; n2 += 2)
  37839. e2 = e2 || Tn(t2[n2]), r2.push(t2[n2 + 1]);
  37840. r2.push(t2[t2.length - 1]);
  37841. } else if ("match" === t2[0]) {
  37842. e2 = e2 || Tn(t2[1]);
  37843. for (let e3 = 2; e3 < t2.length - 1; e3 += 2)
  37844. r2.push(t2[e3 + 1]);
  37845. r2.push(t2[t2.length - 1]);
  37846. } else if ("step" === t2[0]) {
  37847. e2 = e2 || Tn(t2[1]);
  37848. for (let e3 = 1; e3 < t2.length - 1; e3 += 2)
  37849. r2.push(t2[e3 + 1]);
  37850. }
  37851. e2 && (t2.length = 0, t2.push("any", ...r2));
  37852. for (let e3 = 1; e3 < t2.length; e3++)
  37853. Mn(t2[e3]);
  37854. }
  37855. function Tn(t2) {
  37856. if (!Array.isArray(t2))
  37857. return false;
  37858. if ("pitch" === (e2 = t2[0]) || "distance-from-center" === e2)
  37859. return true;
  37860. var e2;
  37861. for (let e3 = 1; e3 < t2.length; e3++)
  37862. if (Tn(t2[e3]))
  37863. return true;
  37864. return false;
  37865. }
  37866. const zn = /* @__PURE__ */ new Set(["in", "==", "!=", ">", ">=", "<", "<=", "to-boolean"]);
  37867. function Bn(t2, e2) {
  37868. return t2 < e2 ? -1 : t2 > e2 ? 1 : 0;
  37869. }
  37870. function En(t2) {
  37871. if (!Array.isArray(t2))
  37872. return false;
  37873. if ("within" === t2[0])
  37874. return true;
  37875. for (let e2 = 1; e2 < t2.length; e2++)
  37876. if (En(t2[e2]))
  37877. return true;
  37878. return false;
  37879. }
  37880. function Cn(t2) {
  37881. if (!t2)
  37882. return true;
  37883. const e2 = t2[0];
  37884. return t2.length <= 1 ? "any" !== e2 : "==" === e2 ? Dn(t2[1], t2[2], "==") : "!=" === e2 ? Fn(Dn(t2[1], t2[2], "==")) : "<" === e2 || ">" === e2 || "<=" === e2 || ">=" === e2 ? Dn(t2[1], t2[2], e2) : "any" === e2 ? (r2 = t2.slice(1), ["any"].concat(r2.map(Cn))) : "all" === e2 ? ["all"].concat(t2.slice(1).map(Cn)) : "none" === e2 ? ["all"].concat(t2.slice(1).map(Cn).map(Fn)) : "in" === e2 ? Pn(t2[1], t2.slice(2)) : "!in" === e2 ? Fn(Pn(t2[1], t2.slice(2))) : "has" === e2 ? Vn(t2[1]) : "!has" === e2 ? Fn(Vn(t2[1])) : "within" !== e2 || t2;
  37885. var r2;
  37886. }
  37887. function Dn(t2, e2, r2) {
  37888. switch (t2) {
  37889. case "$type":
  37890. return [`filter-type-${r2}`, e2];
  37891. case "$id":
  37892. return [`filter-id-${r2}`, e2];
  37893. default:
  37894. return [`filter-${r2}`, t2, e2];
  37895. }
  37896. }
  37897. function Pn(t2, e2) {
  37898. if (0 === e2.length)
  37899. return false;
  37900. switch (t2) {
  37901. case "$type":
  37902. return ["filter-type-in", ["literal", e2]];
  37903. case "$id":
  37904. return ["filter-id-in", ["literal", e2]];
  37905. default:
  37906. return e2.length > 200 && !e2.some((t3) => typeof t3 != typeof e2[0]) ? ["filter-in-large", t2, ["literal", e2.sort(Bn)]] : ["filter-in-small", t2, ["literal", e2]];
  37907. }
  37908. }
  37909. function Vn(t2) {
  37910. switch (t2) {
  37911. case "$type":
  37912. return true;
  37913. case "$id":
  37914. return ["filter-has-id"];
  37915. default:
  37916. return ["filter-has", t2];
  37917. }
  37918. }
  37919. function Fn(t2) {
  37920. return ["!", t2];
  37921. }
  37922. function Ln(t2) {
  37923. return kn(qt(t2.value)) ? _n(jt({}, t2, { expressionContext: "filter", valueSpec: t2.styleSpec[`filter_${t2.layerType || "fill"}`] })) : Rn(t2);
  37924. }
  37925. function Rn(t2) {
  37926. const e2 = t2.value, r2 = t2.key;
  37927. if ("array" !== Jr(e2))
  37928. return [new mn(r2, e2, `array expected, ${Jr(e2)} found`)];
  37929. const n2 = t2.styleSpec;
  37930. let i3, s2 = [];
  37931. if (e2.length < 1)
  37932. return [new mn(r2, e2, "filter array must have at least 1 element")];
  37933. switch (s2 = s2.concat(An({ key: `${r2}[0]`, value: e2[0], valueSpec: n2.filter_operator, style: t2.style, styleSpec: t2.styleSpec })), Ot(e2[0])) {
  37934. case "<":
  37935. case "<=":
  37936. case ">":
  37937. case ">=":
  37938. e2.length >= 2 && "$type" === Ot(e2[1]) && s2.push(new mn(r2, e2, `"$type" cannot be use with operator "${e2[0]}"`));
  37939. case "==":
  37940. case "!=":
  37941. 3 !== e2.length && s2.push(new mn(r2, e2, `filter array for operator "${e2[0]}" must have 3 elements`));
  37942. case "in":
  37943. case "!in":
  37944. e2.length >= 2 && (i3 = Jr(e2[1]), "string" !== i3 && s2.push(new mn(`${r2}[1]`, e2[1], `string expected, ${i3} found`)));
  37945. for (let a2 = 2; a2 < e2.length; a2++)
  37946. i3 = Jr(e2[a2]), "$type" === Ot(e2[1]) ? s2 = s2.concat(An({ key: `${r2}[${a2}]`, value: e2[a2], valueSpec: n2.geometry_type, style: t2.style, styleSpec: t2.styleSpec })) : "string" !== i3 && "number" !== i3 && "boolean" !== i3 && s2.push(new mn(`${r2}[${a2}]`, e2[a2], `string, number, or boolean expected, ${i3} found`));
  37947. break;
  37948. case "any":
  37949. case "all":
  37950. case "none":
  37951. for (let n3 = 1; n3 < e2.length; n3++)
  37952. s2 = s2.concat(Rn({ key: `${r2}[${n3}]`, value: e2[n3], style: t2.style, styleSpec: t2.styleSpec }));
  37953. break;
  37954. case "has":
  37955. case "!has":
  37956. i3 = Jr(e2[1]), 2 !== e2.length ? s2.push(new mn(r2, e2, `filter array for "${e2[0]}" operator must have 2 elements`)) : "string" !== i3 && s2.push(new mn(`${r2}[1]`, e2[1], `string expected, ${i3} found`));
  37957. break;
  37958. case "within":
  37959. i3 = Jr(e2[1]), 2 !== e2.length ? s2.push(new mn(r2, e2, `filter array for "${e2[0]}" operator must have 2 elements`)) : "object" !== i3 && s2.push(new mn(`${r2}[1]`, e2[1], `object expected, ${i3} found`));
  37960. }
  37961. return s2;
  37962. }
  37963. function Un(t2, e2) {
  37964. const r2 = t2.key, n2 = t2.style, i3 = t2.styleSpec, s2 = t2.value, a2 = t2.objectKey, o2 = i3[`${e2}_${t2.layerType}`];
  37965. if (!o2)
  37966. return [];
  37967. const l2 = a2.match(/^(.*)-transition$/);
  37968. if ("paint" === e2 && l2 && o2[l2[1]] && o2[l2[1]].transition)
  37969. return Hn({ key: r2, value: s2, valueSpec: i3.transition, style: n2, styleSpec: i3 });
  37970. const u2 = t2.valueSpec || o2[a2];
  37971. if (!u2)
  37972. return [new mn(r2, s2, `unknown property "${a2}"`)];
  37973. let c2;
  37974. if ("string" === Jr(s2) && Yr(u2) && !u2.tokens && (c2 = /^{([^}]+)}$/.exec(s2)))
  37975. return [new mn(r2, s2, `"${a2}" does not support interpolation syntax
  37976. Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(c2[1])} }\`.`)];
  37977. const h2 = [];
  37978. return "symbol" === t2.layerType && ("text-field" === a2 && n2 && !n2.glyphs && h2.push(new mn(r2, s2, 'use of "text-field" requires a style "glyphs" property')), "text-font" === a2 && Qr(qt(s2)) && "identity" === Ot(s2.type) && h2.push(new mn(r2, s2, '"text-font" does not support identity functions'))), h2.concat(Hn({ key: t2.key, value: s2, valueSpec: u2, style: n2, styleSpec: i3, expressionContext: "property", propertyType: e2, propertyKey: a2 }));
  37979. }
  37980. function $n(t2) {
  37981. return Un(t2, "paint");
  37982. }
  37983. function jn(t2) {
  37984. return Un(t2, "layout");
  37985. }
  37986. function On(t2) {
  37987. let e2 = [];
  37988. const r2 = t2.value, n2 = t2.key, i3 = t2.style, s2 = t2.styleSpec;
  37989. r2.type || r2.ref || e2.push(new mn(n2, r2, 'either "type" or "ref" is required'));
  37990. let a2 = Ot(r2.type);
  37991. const o2 = Ot(r2.ref);
  37992. if (r2.id) {
  37993. const s3 = Ot(r2.id);
  37994. for (let a3 = 0; a3 < t2.arrayIndex; a3++) {
  37995. const t3 = i3.layers[a3];
  37996. Ot(t3.id) === s3 && e2.push(new mn(n2, r2.id, `duplicate layer id "${r2.id}", previously used at line ${t3.id.__line__}`));
  37997. }
  37998. }
  37999. if ("ref" in r2) {
  38000. let t3;
  38001. ["type", "source", "source-layer", "filter", "layout"].forEach((t4) => {
  38002. t4 in r2 && e2.push(new mn(n2, r2[t4], `"${t4}" is prohibited for ref layers`));
  38003. }), i3.layers.forEach((e3) => {
  38004. Ot(e3.id) === o2 && (t3 = e3);
  38005. }), t3 ? t3.ref ? e2.push(new mn(n2, r2.ref, "ref cannot reference another ref layer")) : a2 = Ot(t3.type) : "string" == typeof o2 && e2.push(new mn(n2, r2.ref, `ref layer "${o2}" not found`));
  38006. } else if ("background" !== a2 && "sky" !== a2)
  38007. if (r2.source) {
  38008. const t3 = i3.sources && i3.sources[r2.source], s3 = t3 && Ot(t3.type);
  38009. t3 ? "vector" === s3 && "raster" === a2 ? e2.push(new mn(n2, r2.source, `layer "${r2.id}" requires a raster source`)) : "raster" === s3 && "raster" !== a2 ? e2.push(new mn(n2, r2.source, `layer "${r2.id}" requires a vector source`)) : "vector" !== s3 || r2["source-layer"] ? "raster-dem" === s3 && "hillshade" !== a2 ? e2.push(new mn(n2, r2.source, "raster-dem source can only be used with layer type 'hillshade'.")) : "line" !== a2 || !r2.paint || !r2.paint["line-gradient"] || "geojson" === s3 && t3.lineMetrics || e2.push(new mn(n2, r2, `layer "${r2.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)) : e2.push(new mn(n2, r2, `layer "${r2.id}" must specify a "source-layer"`)) : e2.push(new mn(n2, r2.source, `source "${r2.source}" not found`));
  38010. } else
  38011. e2.push(new mn(n2, r2, 'missing required property "source"'));
  38012. return e2 = e2.concat(gn({ key: n2, value: r2, valueSpec: s2.layer, style: t2.style, styleSpec: t2.styleSpec, objectElementValidators: { "*": () => [], type: () => Hn({ key: `${n2}.type`, value: r2.type, valueSpec: s2.layer.type, style: t2.style, styleSpec: t2.styleSpec, object: r2, objectKey: "type" }), filter: (t3) => Ln(jt({ layerType: a2 }, t3)), layout: (t3) => gn({ layer: r2, key: t3.key, value: t3.value, valueSpec: {}, style: t3.style, styleSpec: t3.styleSpec, objectElementValidators: { "*": (t4) => jn(jt({ layerType: a2 }, t4)) } }), paint: (t3) => gn({ layer: r2, key: t3.key, value: t3.value, valueSpec: {}, style: t3.style, styleSpec: t3.styleSpec, objectElementValidators: { "*": (t4) => $n(jt({ layerType: a2 }, t4)) } }) } })), e2;
  38013. }
  38014. function qn(t2) {
  38015. const e2 = t2.value, r2 = t2.key, n2 = Jr(e2);
  38016. return "string" !== n2 ? [new mn(r2, e2, `string expected, ${n2} found`)] : [];
  38017. }
  38018. const Nn = { promoteId: function({ key: t2, value: e2 }) {
  38019. if ("string" === Jr(e2))
  38020. return qn({ key: t2, value: e2 });
  38021. {
  38022. const r2 = [];
  38023. for (const n2 in e2)
  38024. r2.push(...qn({ key: `${t2}.${n2}`, value: e2[n2] }));
  38025. return r2;
  38026. }
  38027. } };
  38028. function Gn(t2) {
  38029. const e2 = t2.value, r2 = t2.key, n2 = t2.styleSpec, i3 = t2.style;
  38030. if (!e2.type)
  38031. return [new mn(r2, e2, '"type" is required')];
  38032. const s2 = Ot(e2.type);
  38033. let a2;
  38034. switch (s2) {
  38035. case "vector":
  38036. case "raster":
  38037. case "raster-dem":
  38038. return a2 = gn({ key: r2, value: e2, valueSpec: n2[`source_${s2.replace("-", "_")}`], style: t2.style, styleSpec: n2, objectElementValidators: Nn }), a2;
  38039. case "geojson":
  38040. if (a2 = gn({ key: r2, value: e2, valueSpec: n2.source_geojson, style: i3, styleSpec: n2, objectElementValidators: Nn }), e2.cluster)
  38041. for (const t3 in e2.clusterProperties) {
  38042. const [n3, i4] = e2.clusterProperties[t3], s3 = "string" == typeof n3 ? [n3, ["accumulated"], ["get", t3]] : n3;
  38043. a2.push(..._n({ key: `${r2}.${t3}.map`, value: i4, expressionContext: "cluster-map" })), a2.push(..._n({ key: `${r2}.${t3}.reduce`, value: s3, expressionContext: "cluster-reduce" }));
  38044. }
  38045. return a2;
  38046. case "video":
  38047. return gn({ key: r2, value: e2, valueSpec: n2.source_video, style: i3, styleSpec: n2 });
  38048. case "image":
  38049. return gn({ key: r2, value: e2, valueSpec: n2.source_image, style: i3, styleSpec: n2 });
  38050. case "canvas":
  38051. return [new mn(r2, null, "Please use runtime APIs to add canvas sources, rather than including them in stylesheets.", "source.canvas")];
  38052. default:
  38053. return An({ key: `${r2}.type`, value: e2.type, valueSpec: { values: ["vector", "raster", "raster-dem", "geojson", "video", "image"] }, style: i3, styleSpec: n2 });
  38054. }
  38055. }
  38056. function Zn(t2) {
  38057. const e2 = t2.value, r2 = t2.styleSpec, n2 = r2.light, i3 = t2.style;
  38058. let s2 = [];
  38059. const a2 = Jr(e2);
  38060. if (void 0 === e2)
  38061. return s2;
  38062. if ("object" !== a2)
  38063. return s2 = s2.concat([new mn("light", e2, `object expected, ${a2} found`)]), s2;
  38064. for (const t3 in e2) {
  38065. const a3 = t3.match(/^(.*)-transition$/);
  38066. s2 = s2.concat(a3 && n2[a3[1]] && n2[a3[1]].transition ? Hn({ key: t3, value: e2[t3], valueSpec: r2.transition, style: i3, styleSpec: r2 }) : n2[t3] ? Hn({ key: t3, value: e2[t3], valueSpec: n2[t3], style: i3, styleSpec: r2 }) : [new mn(t3, e2[t3], `unknown property "${t3}"`)]);
  38067. }
  38068. return s2;
  38069. }
  38070. function Xn(t2) {
  38071. const e2 = t2.value, r2 = t2.key, n2 = t2.style, i3 = t2.styleSpec, s2 = i3.terrain;
  38072. let a2 = [];
  38073. const o2 = Jr(e2);
  38074. if (void 0 === e2)
  38075. return a2;
  38076. if ("object" !== o2)
  38077. return a2 = a2.concat([new mn("terrain", e2, `object expected, ${o2} found`)]), a2;
  38078. for (const t3 in e2) {
  38079. const r3 = t3.match(/^(.*)-transition$/);
  38080. a2 = a2.concat(r3 && s2[r3[1]] && s2[r3[1]].transition ? Hn({ key: t3, value: e2[t3], valueSpec: i3.transition, style: n2, styleSpec: i3 }) : s2[t3] ? Hn({ key: t3, value: e2[t3], valueSpec: s2[t3], style: n2, styleSpec: i3 }) : [new mn(t3, e2[t3], `unknown property "${t3}"`)]);
  38081. }
  38082. if (e2.source) {
  38083. const t3 = n2.sources && n2.sources[e2.source], i4 = t3 && Ot(t3.type);
  38084. t3 ? "raster-dem" !== i4 && a2.push(new mn(r2, e2.source, `terrain cannot be used with a source of type ${String(i4)}, it only be used with a "raster-dem" source type`)) : a2.push(new mn(r2, e2.source, `source "${e2.source}" not found`));
  38085. } else
  38086. a2.push(new mn(r2, e2, 'terrain is missing required property "source"'));
  38087. return a2;
  38088. }
  38089. function Kn(t2) {
  38090. const e2 = t2.value, r2 = t2.style, n2 = t2.styleSpec, i3 = n2.fog;
  38091. let s2 = [];
  38092. const a2 = Jr(e2);
  38093. if (void 0 === e2)
  38094. return s2;
  38095. if ("object" !== a2)
  38096. return s2 = s2.concat([new mn("fog", e2, `object expected, ${a2} found`)]), s2;
  38097. for (const t3 in e2) {
  38098. const a3 = t3.match(/^(.*)-transition$/);
  38099. s2 = s2.concat(a3 && i3[a3[1]] && i3[a3[1]].transition ? Hn({ key: t3, value: e2[t3], valueSpec: n2.transition, style: r2, styleSpec: n2 }) : i3[t3] ? Hn({ key: t3, value: e2[t3], valueSpec: i3[t3], style: r2, styleSpec: n2 }) : [new mn(t3, e2[t3], `unknown property "${t3}"`)]);
  38100. }
  38101. return s2;
  38102. }
  38103. const Yn = { "*": () => [], array: xn, boolean: function(t2) {
  38104. const e2 = t2.value, r2 = t2.key, n2 = Jr(e2);
  38105. return "boolean" !== n2 ? [new mn(r2, e2, `boolean expected, ${n2} found`)] : [];
  38106. }, number: vn, color: function(t2) {
  38107. const e2 = t2.key, r2 = t2.value, n2 = Jr(r2);
  38108. return "string" !== n2 ? [new mn(e2, r2, `color expected, ${n2} found`)] : null === ue.parseCSSColor(r2) ? [new mn(e2, r2, `color expected, "${r2}" found`)] : [];
  38109. }, enum: An, filter: Ln, function: bn, layer: On, object: gn, source: Gn, light: Zn, terrain: Xn, fog: Kn, string: qn, formatted: function(t2) {
  38110. return 0 === qn(t2).length ? [] : _n(t2);
  38111. }, resolvedImage: function(t2) {
  38112. return 0 === qn(t2).length ? [] : _n(t2);
  38113. }, projection: function(t2) {
  38114. const e2 = t2.value, r2 = t2.styleSpec, n2 = r2.projection, i3 = t2.style;
  38115. let s2 = [];
  38116. const a2 = Jr(e2);
  38117. if ("object" === a2)
  38118. for (const t3 in e2)
  38119. s2 = s2.concat(Hn({ key: t3, value: e2[t3], valueSpec: n2[t3], style: i3, styleSpec: r2 }));
  38120. else
  38121. "string" !== a2 && (s2 = s2.concat([new mn("projection", e2, `object or string expected, ${a2} found`)]));
  38122. return s2;
  38123. } };
  38124. function Hn(t2) {
  38125. const e2 = t2.value, r2 = t2.valueSpec, n2 = t2.styleSpec;
  38126. return r2.expression && Qr(Ot(e2)) ? bn(t2) : r2.expression && un(qt(e2)) ? _n(t2) : r2.type && Yn[r2.type] ? Yn[r2.type](t2) : gn(jt({}, t2, { valueSpec: r2.type ? n2[r2.type] : r2 }));
  38127. }
  38128. function Wn(t2) {
  38129. const e2 = t2.value, r2 = t2.key, n2 = qn(t2);
  38130. return n2.length || (-1 === e2.indexOf("{fontstack}") && n2.push(new mn(r2, e2, '"glyphs" url must include a "{fontstack}" token')), -1 === e2.indexOf("{range}") && n2.push(new mn(r2, e2, '"glyphs" url must include a "{range}" token'))), n2;
  38131. }
  38132. function Jn(t2, e2 = $t) {
  38133. return ei(Hn({ key: "", value: t2, valueSpec: e2.$root, styleSpec: e2, style: t2, objectElementValidators: { glyphs: Wn, "*": () => [] } }));
  38134. }
  38135. const Qn = (t2) => ei($n(t2)), ti = (t2) => ei(jn(t2));
  38136. function ei(t2) {
  38137. return t2.slice().sort((t3, e2) => t3.line && e2.line ? t3.line - e2.line : 0);
  38138. }
  38139. function ri(t2, e2) {
  38140. let r2 = false;
  38141. if (e2 && e2.length)
  38142. for (const n2 of e2)
  38143. t2.fire(new Rt(new Error(n2.message))), r2 = true;
  38144. return r2;
  38145. }
  38146. var ni = ii;
  38147. function ii(t2, e2, r2) {
  38148. var n2 = this.cells = [];
  38149. if (t2 instanceof ArrayBuffer) {
  38150. this.arrayBuffer = t2;
  38151. var i3 = new Int32Array(this.arrayBuffer);
  38152. t2 = i3[0], this.d = (e2 = i3[1]) + 2 * (r2 = i3[2]);
  38153. for (var s2 = 0; s2 < this.d * this.d; s2++) {
  38154. var a2 = i3[3 + s2], o2 = i3[3 + s2 + 1];
  38155. n2.push(a2 === o2 ? null : i3.subarray(a2, o2));
  38156. }
  38157. var l2 = i3[3 + n2.length + 1];
  38158. this.keys = i3.subarray(i3[3 + n2.length], l2), this.bboxes = i3.subarray(l2), this.insert = this._insertReadonly;
  38159. } else {
  38160. this.d = e2 + 2 * r2;
  38161. for (var u2 = 0; u2 < this.d * this.d; u2++)
  38162. n2.push([]);
  38163. this.keys = [], this.bboxes = [];
  38164. }
  38165. this.n = e2, this.extent = t2, this.padding = r2, this.scale = e2 / t2, this.uid = 0;
  38166. var c2 = r2 / e2 * t2;
  38167. this.min = -c2, this.max = t2 + c2;
  38168. }
  38169. ii.prototype.insert = function(t2, e2, r2, n2, i3) {
  38170. this._forEachCell(e2, r2, n2, i3, this._insertCell, this.uid++), this.keys.push(t2), this.bboxes.push(e2), this.bboxes.push(r2), this.bboxes.push(n2), this.bboxes.push(i3);
  38171. }, ii.prototype._insertReadonly = function() {
  38172. throw "Cannot insert into a GridIndex created from an ArrayBuffer.";
  38173. }, ii.prototype._insertCell = function(t2, e2, r2, n2, i3, s2) {
  38174. this.cells[i3].push(s2);
  38175. }, ii.prototype.query = function(t2, e2, r2, n2, i3) {
  38176. var s2 = this.min, a2 = this.max;
  38177. if (t2 <= s2 && e2 <= s2 && a2 <= r2 && a2 <= n2 && !i3)
  38178. return Array.prototype.slice.call(this.keys);
  38179. var o2 = [];
  38180. return this._forEachCell(t2, e2, r2, n2, this._queryCell, o2, {}, i3), o2;
  38181. }, ii.prototype._queryCell = function(t2, e2, r2, n2, i3, s2, a2, o2) {
  38182. var l2 = this.cells[i3];
  38183. if (null !== l2)
  38184. for (var u2 = this.keys, c2 = this.bboxes, h2 = 0; h2 < l2.length; h2++) {
  38185. var p2 = l2[h2];
  38186. if (void 0 === a2[p2]) {
  38187. var f2 = 4 * p2;
  38188. (o2 ? o2(c2[f2 + 0], c2[f2 + 1], c2[f2 + 2], c2[f2 + 3]) : t2 <= c2[f2 + 2] && e2 <= c2[f2 + 3] && r2 >= c2[f2 + 0] && n2 >= c2[f2 + 1]) ? (a2[p2] = true, s2.push(u2[p2])) : a2[p2] = false;
  38189. }
  38190. }
  38191. }, ii.prototype._forEachCell = function(t2, e2, r2, n2, i3, s2, a2, o2) {
  38192. for (var l2 = this._convertToCellCoord(t2), u2 = this._convertToCellCoord(e2), c2 = this._convertToCellCoord(r2), h2 = this._convertToCellCoord(n2), p2 = l2; p2 <= c2; p2++)
  38193. for (var f2 = u2; f2 <= h2; f2++) {
  38194. var d2 = this.d * f2 + p2;
  38195. if ((!o2 || o2(this._convertFromCellCoord(p2), this._convertFromCellCoord(f2), this._convertFromCellCoord(p2 + 1), this._convertFromCellCoord(f2 + 1))) && i3.call(this, t2, e2, r2, n2, d2, s2, a2, o2))
  38196. return;
  38197. }
  38198. }, ii.prototype._convertFromCellCoord = function(t2) {
  38199. return (t2 - this.padding) / this.scale;
  38200. }, ii.prototype._convertToCellCoord = function(t2) {
  38201. return Math.max(0, Math.min(this.d - 1, Math.floor(t2 * this.scale) + this.padding));
  38202. }, ii.prototype.toArrayBuffer = function() {
  38203. if (this.arrayBuffer)
  38204. return this.arrayBuffer;
  38205. for (var t2 = this.cells, e2 = 3 + this.cells.length + 1 + 1, r2 = 0, n2 = 0; n2 < this.cells.length; n2++)
  38206. r2 += this.cells[n2].length;
  38207. var i3 = new Int32Array(e2 + r2 + this.keys.length + this.bboxes.length);
  38208. i3[0] = this.extent, i3[1] = this.n, i3[2] = this.padding;
  38209. for (var s2 = e2, a2 = 0; a2 < t2.length; a2++) {
  38210. var o2 = t2[a2];
  38211. i3[3 + a2] = s2, i3.set(o2, s2), s2 += o2.length;
  38212. }
  38213. return i3[3 + t2.length] = s2, i3.set(this.keys, s2), i3[3 + t2.length + 1] = s2 += this.keys.length, i3.set(this.bboxes, s2), s2 += this.bboxes.length, i3.buffer;
  38214. };
  38215. const si = {};
  38216. function ai(t2, e2, r2 = {}) {
  38217. Object.defineProperty(t2, "_classRegistryKey", { value: e2, writeable: false }), si[e2] = { klass: t2, omit: r2.omit || [] };
  38218. }
  38219. ai(Object, "Object"), ni.serialize = function(t2, e2) {
  38220. const r2 = t2.toArrayBuffer();
  38221. return e2 && e2.push(r2), { buffer: r2 };
  38222. }, ni.deserialize = function(t2) {
  38223. return new ni(t2.buffer);
  38224. }, Object.defineProperty(ni, "name", { value: "Grid" }), ai(ni, "Grid"), ai(ce, "Color"), ai(Error, "Error"), ai(kt, "AJAXError"), ai(de, "ResolvedImage"), ai(dn, "StylePropertyFunction"), ai(ln, "StyleExpression", { omit: ["_evaluator"] }), ai(pn, "ZoomDependentExpression"), ai(hn, "ZoomConstantExpression"), ai(ze, "CompoundExpression", { omit: ["_evaluate"] });
  38225. for (const t2 in Or)
  38226. si[Or[t2]._classRegistryKey] || ai(Or[t2], `Expression${t2}`);
  38227. function oi(t2) {
  38228. return t2 && "undefined" != typeof ArrayBuffer && (t2 instanceof ArrayBuffer || t2.constructor && "ArrayBuffer" === t2.constructor.name);
  38229. }
  38230. function li(t2) {
  38231. return a.ImageBitmap && t2 instanceof a.ImageBitmap;
  38232. }
  38233. function ui(t2, e2) {
  38234. if (null == t2 || "boolean" == typeof t2 || "number" == typeof t2 || "string" == typeof t2 || t2 instanceof Boolean || t2 instanceof Number || t2 instanceof String || t2 instanceof Date || t2 instanceof RegExp)
  38235. return t2;
  38236. if (oi(t2) || li(t2))
  38237. return e2 && e2.push(t2), t2;
  38238. if (ArrayBuffer.isView(t2)) {
  38239. const r2 = t2;
  38240. return e2 && e2.push(r2.buffer), r2;
  38241. }
  38242. if (t2 instanceof a.ImageData)
  38243. return e2 && e2.push(t2.data.buffer), t2;
  38244. if (Array.isArray(t2)) {
  38245. const r2 = [];
  38246. for (const n2 of t2)
  38247. r2.push(ui(n2, e2));
  38248. return r2;
  38249. }
  38250. if ("object" == typeof t2) {
  38251. const r2 = t2.constructor, n2 = r2._classRegistryKey;
  38252. if (!n2)
  38253. throw new Error(`can't serialize object of unregistered class ${n2}`);
  38254. const i3 = r2.serialize ? r2.serialize(t2, e2) : {};
  38255. if (!r2.serialize) {
  38256. for (const r3 in t2)
  38257. t2.hasOwnProperty(r3) && (si[n2].omit.indexOf(r3) >= 0 || (i3[r3] = ui(t2[r3], e2)));
  38258. t2 instanceof Error && (i3.message = t2.message);
  38259. }
  38260. if (i3.$name)
  38261. throw new Error("$name property is reserved for worker serialization logic.");
  38262. return "Object" !== n2 && (i3.$name = n2), i3;
  38263. }
  38264. throw new Error("can't serialize object of type " + typeof t2);
  38265. }
  38266. function ci(t2) {
  38267. if (null == t2 || "boolean" == typeof t2 || "number" == typeof t2 || "string" == typeof t2 || t2 instanceof Boolean || t2 instanceof Number || t2 instanceof String || t2 instanceof Date || t2 instanceof RegExp || oi(t2) || li(t2) || ArrayBuffer.isView(t2) || t2 instanceof a.ImageData)
  38268. return t2;
  38269. if (Array.isArray(t2))
  38270. return t2.map(ci);
  38271. if ("object" == typeof t2) {
  38272. const e2 = t2.$name || "Object", { klass: r2 } = si[e2];
  38273. if (!r2)
  38274. throw new Error(`can't deserialize unregistered class ${e2}`);
  38275. if (r2.deserialize)
  38276. return r2.deserialize(t2);
  38277. const n2 = Object.create(r2.prototype);
  38278. for (const e3 of Object.keys(t2))
  38279. "$name" !== e3 && (n2[e3] = ci(t2[e3]));
  38280. return n2;
  38281. }
  38282. throw new Error("can't deserialize object of type " + typeof t2);
  38283. }
  38284. class hi {
  38285. constructor() {
  38286. this.first = true;
  38287. }
  38288. update(t2, e2) {
  38289. const r2 = Math.floor(t2);
  38290. return this.first ? (this.first = false, this.lastIntegerZoom = r2, this.lastIntegerZoomTime = 0, this.lastZoom = t2, this.lastFloorZoom = r2, true) : (this.lastFloorZoom > r2 ? (this.lastIntegerZoom = r2 + 1, this.lastIntegerZoomTime = e2) : this.lastFloorZoom < r2 && (this.lastIntegerZoom = r2, this.lastIntegerZoomTime = e2), t2 !== this.lastZoom && (this.lastZoom = t2, this.lastFloorZoom = r2, true));
  38291. }
  38292. }
  38293. const pi = (t2) => t2 >= 1536 && t2 <= 1791, fi = (t2) => t2 >= 1872 && t2 <= 1919, di = (t2) => t2 >= 2208 && t2 <= 2303, yi = (t2) => t2 >= 11904 && t2 <= 12031, mi = (t2) => t2 >= 12032 && t2 <= 12255, gi = (t2) => t2 >= 12272 && t2 <= 12287, xi = (t2) => t2 >= 12288 && t2 <= 12351, vi = (t2) => t2 >= 12352 && t2 <= 12447, bi = (t2) => t2 >= 12448 && t2 <= 12543, _i = (t2) => t2 >= 12544 && t2 <= 12591, wi = (t2) => t2 >= 12704 && t2 <= 12735, Ai = (t2) => t2 >= 12736 && t2 <= 12783, ki = (t2) => t2 >= 12784 && t2 <= 12799, Si = (t2) => t2 >= 12800 && t2 <= 13055, Ii = (t2) => t2 >= 13056 && t2 <= 13311, Mi = (t2) => t2 >= 13312 && t2 <= 19903, Ti = (t2) => t2 >= 19968 && t2 <= 40959, zi = (t2) => t2 >= 40960 && t2 <= 42127, Bi = (t2) => t2 >= 42128 && t2 <= 42191, Ei = (t2) => t2 >= 44032 && t2 <= 55215, Ci = (t2) => t2 >= 63744 && t2 <= 64255, Di = (t2) => t2 >= 64336 && t2 <= 65023, Pi = (t2) => t2 >= 65040 && t2 <= 65055, Vi = (t2) => t2 >= 65072 && t2 <= 65103, Fi = (t2) => t2 >= 65104 && t2 <= 65135, Li = (t2) => t2 >= 65136 && t2 <= 65279, Ri = (t2) => t2 >= 65280 && t2 <= 65519;
  38294. function Ui(t2) {
  38295. for (const e2 of t2)
  38296. if (Oi(e2.charCodeAt(0)))
  38297. return true;
  38298. return false;
  38299. }
  38300. function $i(t2) {
  38301. for (const e2 of t2)
  38302. if (!ji(e2.charCodeAt(0)))
  38303. return false;
  38304. return true;
  38305. }
  38306. function ji(t2) {
  38307. return !(pi(t2) || fi(t2) || di(t2) || Di(t2) || Li(t2));
  38308. }
  38309. function Oi(t2) {
  38310. return !(746 !== t2 && 747 !== t2 && (t2 < 4352 || !(wi(t2) || _i(t2) || Vi(t2) && !(t2 >= 65097 && t2 <= 65103) || Ci(t2) || Ii(t2) || yi(t2) || Ai(t2) || !(!xi(t2) || t2 >= 12296 && t2 <= 12305 || t2 >= 12308 && t2 <= 12319 || 12336 === t2) || Mi(t2) || Ti(t2) || Si(t2) || ((t3) => t3 >= 12592 && t3 <= 12687)(t2) || ((t3) => t3 >= 43360 && t3 <= 43391)(t2) || ((t3) => t3 >= 55216 && t3 <= 55295)(t2) || ((t3) => t3 >= 4352 && t3 <= 4607)(t2) || Ei(t2) || vi(t2) || gi(t2) || ((t3) => t3 >= 12688 && t3 <= 12703)(t2) || mi(t2) || ki(t2) || bi(t2) && 12540 !== t2 || !(!Ri(t2) || 65288 === t2 || 65289 === t2 || 65293 === t2 || t2 >= 65306 && t2 <= 65310 || 65339 === t2 || 65341 === t2 || 65343 === t2 || t2 >= 65371 && t2 <= 65503 || 65507 === t2 || t2 >= 65512 && t2 <= 65519) || !(!Fi(t2) || t2 >= 65112 && t2 <= 65118 || t2 >= 65123 && t2 <= 65126) || ((t3) => t3 >= 5120 && t3 <= 5759)(t2) || ((t3) => t3 >= 6320 && t3 <= 6399)(t2) || Pi(t2) || ((t3) => t3 >= 19904 && t3 <= 19967)(t2) || zi(t2) || Bi(t2))));
  38311. }
  38312. function qi(t2) {
  38313. return !(Oi(t2) || function(t3) {
  38314. return !!(((t4) => t4 >= 128 && t4 <= 255)(t3) && (167 === t3 || 169 === t3 || 174 === t3 || 177 === t3 || 188 === t3 || 189 === t3 || 190 === t3 || 215 === t3 || 247 === t3) || ((t4) => t4 >= 8192 && t4 <= 8303)(t3) && (8214 === t3 || 8224 === t3 || 8225 === t3 || 8240 === t3 || 8241 === t3 || 8251 === t3 || 8252 === t3 || 8258 === t3 || 8263 === t3 || 8264 === t3 || 8265 === t3 || 8273 === t3) || ((t4) => t4 >= 8448 && t4 <= 8527)(t3) || ((t4) => t4 >= 8528 && t4 <= 8591)(t3) || ((t4) => t4 >= 8960 && t4 <= 9215)(t3) && (t3 >= 8960 && t3 <= 8967 || t3 >= 8972 && t3 <= 8991 || t3 >= 8996 && t3 <= 9e3 || 9003 === t3 || t3 >= 9085 && t3 <= 9114 || t3 >= 9150 && t3 <= 9165 || 9167 === t3 || t3 >= 9169 && t3 <= 9179 || t3 >= 9186 && t3 <= 9215) || ((t4) => t4 >= 9216 && t4 <= 9279)(t3) && 9251 !== t3 || ((t4) => t4 >= 9280 && t4 <= 9311)(t3) || ((t4) => t4 >= 9312 && t4 <= 9471)(t3) || ((t4) => t4 >= 9632 && t4 <= 9727)(t3) || ((t4) => t4 >= 9728 && t4 <= 9983)(t3) && !(t3 >= 9754 && t3 <= 9759) || ((t4) => t4 >= 11008 && t4 <= 11263)(t3) && (t3 >= 11026 && t3 <= 11055 || t3 >= 11088 && t3 <= 11097 || t3 >= 11192 && t3 <= 11243) || xi(t3) || bi(t3) || ((t4) => t4 >= 57344 && t4 <= 63743)(t3) || Vi(t3) || Fi(t3) || Ri(t3) || 8734 === t3 || 8756 === t3 || 8757 === t3 || t3 >= 9984 && t3 <= 10087 || t3 >= 10102 && t3 <= 10131 || 65532 === t3 || 65533 === t3);
  38315. }(t2));
  38316. }
  38317. function Ni(t2) {
  38318. return t2 >= 1424 && t2 <= 2303 || Di(t2) || Li(t2);
  38319. }
  38320. function Gi(t2, e2) {
  38321. return !(!e2 && Ni(t2) || t2 >= 2304 && t2 <= 3583 || t2 >= 3840 && t2 <= 4255 || ((t3) => t3 >= 6016 && t3 <= 6143)(t2));
  38322. }
  38323. function Zi(t2) {
  38324. for (const e2 of t2)
  38325. if (Ni(e2.charCodeAt(0)))
  38326. return true;
  38327. return false;
  38328. }
  38329. const Xi = "deferred", Ki = "loading", Yi = "loaded";
  38330. let Hi = null, Wi = "unavailable", Ji = null;
  38331. const Qi = function(t2) {
  38332. t2 && "string" == typeof t2 && t2.indexOf("NetworkError") > -1 && (Wi = "error"), Hi && Hi(t2);
  38333. };
  38334. function ts() {
  38335. es.fire(new Lt("pluginStateChange", { pluginStatus: Wi, pluginURL: Ji }));
  38336. }
  38337. const es = new Ut(), rs = function() {
  38338. return Wi;
  38339. }, ns = function() {
  38340. if (Wi !== Xi || !Ji)
  38341. throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");
  38342. Wi = Ki, ts(), Ji && Mt({ url: Ji }, (t2) => {
  38343. t2 ? Qi(t2) : (Wi = Yi, ts());
  38344. });
  38345. }, is = { applyArabicShaping: null, processBidirectionalText: null, processStyledBidirectionalText: null, isLoaded: () => Wi === Yi || null != is.applyArabicShaping, isLoading: () => Wi === Ki, setState(t2) {
  38346. Wi = t2.pluginStatus, Ji = t2.pluginURL;
  38347. }, isParsed: () => null != is.applyArabicShaping && null != is.processBidirectionalText && null != is.processStyledBidirectionalText, getPluginURL: () => Ji };
  38348. class ss {
  38349. constructor(t2, e2) {
  38350. this.zoom = t2, e2 ? (this.now = e2.now, this.fadeDuration = e2.fadeDuration, this.zoomHistory = e2.zoomHistory, this.transition = e2.transition, this.pitch = e2.pitch) : (this.now = 0, this.fadeDuration = 0, this.zoomHistory = new hi(), this.transition = {}, this.pitch = 0);
  38351. }
  38352. isSupportedScript(t2) {
  38353. return function(t3, e2) {
  38354. for (const r2 of t3)
  38355. if (!Gi(r2.charCodeAt(0), e2))
  38356. return false;
  38357. return true;
  38358. }(t2, is.isLoaded());
  38359. }
  38360. crossFadingFactor() {
  38361. return 0 === this.fadeDuration ? 1 : Math.min((this.now - this.zoomHistory.lastIntegerZoomTime) / this.fadeDuration, 1);
  38362. }
  38363. getCrossfadeParameters() {
  38364. const t2 = this.zoom, e2 = t2 - Math.floor(t2), r2 = this.crossFadingFactor();
  38365. return t2 > this.zoomHistory.lastIntegerZoom ? { fromScale: 2, toScale: 1, t: e2 + (1 - e2) * r2 } : { fromScale: 0.5, toScale: 1, t: 1 - (1 - r2) * e2 };
  38366. }
  38367. }
  38368. class as {
  38369. constructor(t2, e2) {
  38370. this.property = t2, this.value = e2, this.expression = function(t3, e3) {
  38371. if (Qr(t3))
  38372. return new dn(t3, e3);
  38373. if (un(t3)) {
  38374. const r2 = fn(t3, e3);
  38375. if ("error" === r2.result)
  38376. throw new Error(r2.value.map((t4) => `${t4.key}: ${t4.message}`).join(", "));
  38377. return r2.value;
  38378. }
  38379. {
  38380. let r2 = t3;
  38381. return "string" == typeof t3 && "color" === e3.type && (r2 = ce.parse(t3)), { kind: "constant", evaluate: () => r2 };
  38382. }
  38383. }(void 0 === e2 ? t2.specification.default : e2, t2.specification);
  38384. }
  38385. isDataDriven() {
  38386. return "source" === this.expression.kind || "composite" === this.expression.kind;
  38387. }
  38388. possiblyEvaluate(t2, e2, r2) {
  38389. return this.property.possiblyEvaluate(this, t2, e2, r2);
  38390. }
  38391. }
  38392. class os {
  38393. constructor(t2) {
  38394. this.property = t2, this.value = new as(t2, void 0);
  38395. }
  38396. transitioned(t2, e2) {
  38397. return new us(this.property, this.value, e2, b({}, t2.transition, this.transition), t2.now);
  38398. }
  38399. untransitioned() {
  38400. return new us(this.property, this.value, null, {}, 0);
  38401. }
  38402. }
  38403. class ls {
  38404. constructor(t2) {
  38405. this._properties = t2, this._values = Object.create(t2.defaultTransitionablePropertyValues);
  38406. }
  38407. getValue(t2) {
  38408. return B(this._values[t2].value.value);
  38409. }
  38410. setValue(t2, e2) {
  38411. this._values.hasOwnProperty(t2) || (this._values[t2] = new os(this._values[t2].property)), this._values[t2].value = new as(this._values[t2].property, null === e2 ? void 0 : B(e2));
  38412. }
  38413. getTransition(t2) {
  38414. return B(this._values[t2].transition);
  38415. }
  38416. setTransition(t2, e2) {
  38417. this._values.hasOwnProperty(t2) || (this._values[t2] = new os(this._values[t2].property)), this._values[t2].transition = B(e2) || void 0;
  38418. }
  38419. serialize() {
  38420. const t2 = {};
  38421. for (const e2 of Object.keys(this._values)) {
  38422. const r2 = this.getValue(e2);
  38423. void 0 !== r2 && (t2[e2] = r2);
  38424. const n2 = this.getTransition(e2);
  38425. void 0 !== n2 && (t2[`${e2}-transition`] = n2);
  38426. }
  38427. return t2;
  38428. }
  38429. transitioned(t2, e2) {
  38430. const r2 = new cs(this._properties);
  38431. for (const n2 of Object.keys(this._values))
  38432. r2._values[n2] = this._values[n2].transitioned(t2, e2._values[n2]);
  38433. return r2;
  38434. }
  38435. untransitioned() {
  38436. const t2 = new cs(this._properties);
  38437. for (const e2 of Object.keys(this._values))
  38438. t2._values[e2] = this._values[e2].untransitioned();
  38439. return t2;
  38440. }
  38441. }
  38442. class us {
  38443. constructor(t2, e2, r2, n2, i3) {
  38444. const s2 = n2.delay || 0, a2 = n2.duration || 0;
  38445. i3 = i3 || 0, this.property = t2, this.value = e2, this.begin = i3 + s2, this.end = this.begin + a2, t2.specification.transition && (n2.delay || n2.duration) && (this.prior = r2);
  38446. }
  38447. possiblyEvaluate(t2, e2, r2) {
  38448. const n2 = t2.now || 0, i3 = this.value.possiblyEvaluate(t2, e2, r2), s2 = this.prior;
  38449. if (s2) {
  38450. if (n2 > this.end)
  38451. return this.prior = null, i3;
  38452. if (this.value.isDataDriven())
  38453. return this.prior = null, i3;
  38454. if (n2 < this.begin)
  38455. return s2.possiblyEvaluate(t2, e2, r2);
  38456. {
  38457. const a2 = (n2 - this.begin) / (this.end - this.begin);
  38458. return this.property.interpolate(s2.possiblyEvaluate(t2, e2, r2), i3, p(a2));
  38459. }
  38460. }
  38461. return i3;
  38462. }
  38463. }
  38464. class cs {
  38465. constructor(t2) {
  38466. this._properties = t2, this._values = Object.create(t2.defaultTransitioningPropertyValues);
  38467. }
  38468. possiblyEvaluate(t2, e2, r2) {
  38469. const n2 = new fs(this._properties);
  38470. for (const i3 of Object.keys(this._values))
  38471. n2._values[i3] = this._values[i3].possiblyEvaluate(t2, e2, r2);
  38472. return n2;
  38473. }
  38474. hasTransition() {
  38475. for (const t2 of Object.keys(this._values))
  38476. if (this._values[t2].prior)
  38477. return true;
  38478. return false;
  38479. }
  38480. }
  38481. class hs {
  38482. constructor(t2) {
  38483. this._properties = t2, this._values = Object.create(t2.defaultPropertyValues);
  38484. }
  38485. getValue(t2) {
  38486. return B(this._values[t2].value);
  38487. }
  38488. setValue(t2, e2) {
  38489. this._values[t2] = new as(this._values[t2].property, null === e2 ? void 0 : B(e2));
  38490. }
  38491. serialize() {
  38492. const t2 = {};
  38493. for (const e2 of Object.keys(this._values)) {
  38494. const r2 = this.getValue(e2);
  38495. void 0 !== r2 && (t2[e2] = r2);
  38496. }
  38497. return t2;
  38498. }
  38499. possiblyEvaluate(t2, e2, r2) {
  38500. const n2 = new fs(this._properties);
  38501. for (const i3 of Object.keys(this._values))
  38502. n2._values[i3] = this._values[i3].possiblyEvaluate(t2, e2, r2);
  38503. return n2;
  38504. }
  38505. }
  38506. class ps {
  38507. constructor(t2, e2, r2) {
  38508. this.property = t2, this.value = e2, this.parameters = r2;
  38509. }
  38510. isConstant() {
  38511. return "constant" === this.value.kind;
  38512. }
  38513. constantOr(t2) {
  38514. return "constant" === this.value.kind ? this.value.value : t2;
  38515. }
  38516. evaluate(t2, e2, r2, n2) {
  38517. return this.property.evaluate(this.value, this.parameters, t2, e2, r2, n2);
  38518. }
  38519. }
  38520. class fs {
  38521. constructor(t2) {
  38522. this._properties = t2, this._values = Object.create(t2.defaultPossiblyEvaluatedValues);
  38523. }
  38524. get(t2) {
  38525. return this._values[t2];
  38526. }
  38527. }
  38528. class ds {
  38529. constructor(t2) {
  38530. this.specification = t2;
  38531. }
  38532. possiblyEvaluate(t2, e2) {
  38533. return t2.expression.evaluate(e2);
  38534. }
  38535. interpolate(t2, e2, r2) {
  38536. const n2 = nr[this.specification.type];
  38537. return n2 ? n2(t2, e2, r2) : t2;
  38538. }
  38539. }
  38540. class ys {
  38541. constructor(t2, e2) {
  38542. this.specification = t2, this.overrides = e2;
  38543. }
  38544. possiblyEvaluate(t2, e2, r2, n2) {
  38545. return new ps(this, "constant" === t2.expression.kind || "camera" === t2.expression.kind ? { kind: "constant", value: t2.expression.evaluate(e2, null, {}, r2, n2) } : t2.expression, e2);
  38546. }
  38547. interpolate(t2, e2, r2) {
  38548. if ("constant" !== t2.value.kind || "constant" !== e2.value.kind)
  38549. return t2;
  38550. if (void 0 === t2.value.value || void 0 === e2.value.value)
  38551. return new ps(this, { kind: "constant", value: void 0 }, t2.parameters);
  38552. const n2 = nr[this.specification.type];
  38553. return n2 ? new ps(this, { kind: "constant", value: n2(t2.value.value, e2.value.value, r2) }, t2.parameters) : t2;
  38554. }
  38555. evaluate(t2, e2, r2, n2, i3, s2) {
  38556. return "constant" === t2.kind ? t2.value : t2.evaluate(e2, r2, n2, i3, s2);
  38557. }
  38558. }
  38559. class ms extends ys {
  38560. possiblyEvaluate(t2, e2, r2, n2) {
  38561. if (void 0 === t2.value)
  38562. return new ps(this, { kind: "constant", value: void 0 }, e2);
  38563. if ("constant" === t2.expression.kind) {
  38564. const i3 = t2.expression.evaluate(e2, null, {}, r2, n2), s2 = "resolvedImage" === t2.property.specification.type && "string" != typeof i3 ? i3.name : i3, a2 = this._calculate(s2, s2, s2, e2);
  38565. return new ps(this, { kind: "constant", value: a2 }, e2);
  38566. }
  38567. if ("camera" === t2.expression.kind) {
  38568. const r3 = this._calculate(t2.expression.evaluate({ zoom: e2.zoom - 1 }), t2.expression.evaluate({ zoom: e2.zoom }), t2.expression.evaluate({ zoom: e2.zoom + 1 }), e2);
  38569. return new ps(this, { kind: "constant", value: r3 }, e2);
  38570. }
  38571. return new ps(this, t2.expression, e2);
  38572. }
  38573. evaluate(t2, e2, r2, n2, i3, s2) {
  38574. if ("source" === t2.kind) {
  38575. const a2 = t2.evaluate(e2, r2, n2, i3, s2);
  38576. return this._calculate(a2, a2, a2, e2);
  38577. }
  38578. return "composite" === t2.kind ? this._calculate(t2.evaluate({ zoom: Math.floor(e2.zoom) - 1 }, r2, n2), t2.evaluate({ zoom: Math.floor(e2.zoom) }, r2, n2), t2.evaluate({ zoom: Math.floor(e2.zoom) + 1 }, r2, n2), e2) : t2.value;
  38579. }
  38580. _calculate(t2, e2, r2, n2) {
  38581. return n2.zoom > n2.zoomHistory.lastIntegerZoom ? { from: t2, to: e2, other: r2 } : { from: r2, to: e2, other: t2 };
  38582. }
  38583. interpolate(t2) {
  38584. return t2;
  38585. }
  38586. }
  38587. class gs {
  38588. constructor(t2) {
  38589. this.specification = t2;
  38590. }
  38591. possiblyEvaluate(t2, e2, r2, n2) {
  38592. if (void 0 !== t2.value) {
  38593. if ("constant" === t2.expression.kind) {
  38594. const i3 = t2.expression.evaluate(e2, null, {}, r2, n2);
  38595. return this._calculate(i3, i3, i3, e2);
  38596. }
  38597. return this._calculate(t2.expression.evaluate(new ss(Math.floor(e2.zoom - 1), e2)), t2.expression.evaluate(new ss(Math.floor(e2.zoom), e2)), t2.expression.evaluate(new ss(Math.floor(e2.zoom + 1), e2)), e2);
  38598. }
  38599. }
  38600. _calculate(t2, e2, r2, n2) {
  38601. return n2.zoom > n2.zoomHistory.lastIntegerZoom ? { from: t2, to: e2 } : { from: r2, to: e2 };
  38602. }
  38603. interpolate(t2) {
  38604. return t2;
  38605. }
  38606. }
  38607. class xs {
  38608. constructor(t2) {
  38609. this.specification = t2;
  38610. }
  38611. possiblyEvaluate(t2, e2, r2, n2) {
  38612. return !!t2.expression.evaluate(e2, null, {}, r2, n2);
  38613. }
  38614. interpolate() {
  38615. return false;
  38616. }
  38617. }
  38618. class vs {
  38619. constructor(t2) {
  38620. this.properties = t2, this.defaultPropertyValues = {}, this.defaultTransitionablePropertyValues = {}, this.defaultTransitioningPropertyValues = {}, this.defaultPossiblyEvaluatedValues = {}, this.overridableProperties = [];
  38621. for (const e2 in t2) {
  38622. const r2 = t2[e2];
  38623. r2.specification.overridable && this.overridableProperties.push(e2);
  38624. const n2 = this.defaultPropertyValues[e2] = new as(r2, void 0), i3 = this.defaultTransitionablePropertyValues[e2] = new os(r2);
  38625. this.defaultTransitioningPropertyValues[e2] = i3.untransitioned(), this.defaultPossiblyEvaluatedValues[e2] = n2.possiblyEvaluate({});
  38626. }
  38627. }
  38628. }
  38629. function bs(t2, e2) {
  38630. return 256 * (t2 = y(Math.floor(t2), 0, 255)) + y(Math.floor(e2), 0, 255);
  38631. }
  38632. ai(ys, "DataDrivenProperty"), ai(ds, "DataConstantProperty"), ai(ms, "CrossFadedDataDrivenProperty"), ai(gs, "CrossFadedProperty"), ai(xs, "ColorRampProperty");
  38633. const _s = { Int8: Int8Array, Uint8: Uint8Array, Int16: Int16Array, Uint16: Uint16Array, Int32: Int32Array, Uint32: Uint32Array, Float32: Float32Array };
  38634. class ws {
  38635. constructor(t2, e2) {
  38636. this._structArray = t2, this._pos1 = e2 * this.size, this._pos2 = this._pos1 / 2, this._pos4 = this._pos1 / 4, this._pos8 = this._pos1 / 8;
  38637. }
  38638. }
  38639. class As {
  38640. constructor() {
  38641. this.isTransferred = false, this.capacity = -1, this.resize(0);
  38642. }
  38643. static serialize(t2, e2) {
  38644. return t2._trim(), e2 && (t2.isTransferred = true, e2.push(t2.arrayBuffer)), { length: t2.length, arrayBuffer: t2.arrayBuffer };
  38645. }
  38646. static deserialize(t2) {
  38647. const e2 = Object.create(this.prototype);
  38648. return e2.arrayBuffer = t2.arrayBuffer, e2.length = t2.length, e2.capacity = t2.arrayBuffer.byteLength / e2.bytesPerElement, e2._refreshViews(), e2;
  38649. }
  38650. _trim() {
  38651. this.length !== this.capacity && (this.capacity = this.length, this.arrayBuffer = this.arrayBuffer.slice(0, this.length * this.bytesPerElement), this._refreshViews());
  38652. }
  38653. clear() {
  38654. this.length = 0;
  38655. }
  38656. resize(t2) {
  38657. this.reserve(t2), this.length = t2;
  38658. }
  38659. reserve(t2) {
  38660. if (t2 > this.capacity) {
  38661. this.capacity = Math.max(t2, Math.floor(5 * this.capacity), 128), this.arrayBuffer = new ArrayBuffer(this.capacity * this.bytesPerElement);
  38662. const e2 = this.uint8;
  38663. this._refreshViews(), e2 && this.uint8.set(e2);
  38664. }
  38665. }
  38666. _refreshViews() {
  38667. throw new Error("_refreshViews() must be implemented by each concrete StructArray layout");
  38668. }
  38669. destroy() {
  38670. this.int8 = this.uint8 = this.int16 = this.uint16 = this.int32 = this.uint32 = this.float32 = null, this.arrayBuffer = null;
  38671. }
  38672. }
  38673. function ks(t2, e2 = 1) {
  38674. let r2 = 0, n2 = 0;
  38675. return { members: t2.map((t3) => {
  38676. const i3 = _s[t3.type].BYTES_PER_ELEMENT, s2 = r2 = Ss(r2, Math.max(e2, i3)), a2 = t3.components || 1;
  38677. return n2 = Math.max(n2, i3), r2 += i3 * a2, { name: t3.name, type: t3.type, components: a2, offset: s2 };
  38678. }), size: Ss(r2, Math.max(n2, e2)), alignment: e2 };
  38679. }
  38680. function Ss(t2, e2) {
  38681. return Math.ceil(t2 / e2) * e2;
  38682. }
  38683. class Is extends As {
  38684. _refreshViews() {
  38685. this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
  38686. }
  38687. emplaceBack(t2, e2) {
  38688. const r2 = this.length;
  38689. return this.resize(r2 + 1), this.emplace(r2, t2, e2);
  38690. }
  38691. emplace(t2, e2, r2) {
  38692. const n2 = 2 * t2;
  38693. return this.int16[n2 + 0] = e2, this.int16[n2 + 1] = r2, t2;
  38694. }
  38695. }
  38696. Is.prototype.bytesPerElement = 4, ai(Is, "StructArrayLayout2i4");
  38697. class Ms extends As {
  38698. _refreshViews() {
  38699. this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
  38700. }
  38701. emplaceBack(t2, e2, r2) {
  38702. const n2 = this.length;
  38703. return this.resize(n2 + 1), this.emplace(n2, t2, e2, r2);
  38704. }
  38705. emplace(t2, e2, r2, n2) {
  38706. const i3 = 3 * t2;
  38707. return this.int16[i3 + 0] = e2, this.int16[i3 + 1] = r2, this.int16[i3 + 2] = n2, t2;
  38708. }
  38709. }
  38710. Ms.prototype.bytesPerElement = 6, ai(Ms, "StructArrayLayout3i6");
  38711. class Ts extends As {
  38712. _refreshViews() {
  38713. this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
  38714. }
  38715. emplaceBack(t2, e2, r2, n2) {
  38716. const i3 = this.length;
  38717. return this.resize(i3 + 1), this.emplace(i3, t2, e2, r2, n2);
  38718. }
  38719. emplace(t2, e2, r2, n2, i3) {
  38720. const s2 = 4 * t2;
  38721. return this.int16[s2 + 0] = e2, this.int16[s2 + 1] = r2, this.int16[s2 + 2] = n2, this.int16[s2 + 3] = i3, t2;
  38722. }
  38723. }
  38724. Ts.prototype.bytesPerElement = 8, ai(Ts, "StructArrayLayout4i8");
  38725. class zs extends As {
  38726. _refreshViews() {
  38727. this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
  38728. }
  38729. emplaceBack(t2, e2, r2, n2, i3, s2, a2) {
  38730. const o2 = this.length;
  38731. return this.resize(o2 + 1), this.emplace(o2, t2, e2, r2, n2, i3, s2, a2);
  38732. }
  38733. emplace(t2, e2, r2, n2, i3, s2, a2, o2) {
  38734. const l2 = 6 * t2, u2 = 12 * t2, c2 = 3 * t2;
  38735. return this.int16[l2 + 0] = e2, this.int16[l2 + 1] = r2, this.uint8[u2 + 4] = n2, this.uint8[u2 + 5] = i3, this.uint8[u2 + 6] = s2, this.uint8[u2 + 7] = a2, this.float32[c2 + 2] = o2, t2;
  38736. }
  38737. }
  38738. zs.prototype.bytesPerElement = 12, ai(zs, "StructArrayLayout2i4ub1f12");
  38739. class Bs extends As {
  38740. _refreshViews() {
  38741. this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
  38742. }
  38743. emplaceBack(t2, e2, r2, n2) {
  38744. const i3 = this.length;
  38745. return this.resize(i3 + 1), this.emplace(i3, t2, e2, r2, n2);
  38746. }
  38747. emplace(t2, e2, r2, n2, i3) {
  38748. const s2 = 4 * t2;
  38749. return this.float32[s2 + 0] = e2, this.float32[s2 + 1] = r2, this.float32[s2 + 2] = n2, this.float32[s2 + 3] = i3, t2;
  38750. }
  38751. }
  38752. Bs.prototype.bytesPerElement = 16, ai(Bs, "StructArrayLayout4f16");
  38753. class Es extends As {
  38754. _refreshViews() {
  38755. this.uint8 = new Uint8Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
  38756. }
  38757. emplaceBack(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2) {
  38758. const c2 = this.length;
  38759. return this.resize(c2 + 1), this.emplace(c2, t2, e2, r2, n2, i3, s2, a2, o2, l2, u2);
  38760. }
  38761. emplace(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2) {
  38762. const h2 = 10 * t2;
  38763. return this.uint16[h2 + 0] = e2, this.uint16[h2 + 1] = r2, this.uint16[h2 + 2] = n2, this.uint16[h2 + 3] = i3, this.uint16[h2 + 4] = s2, this.uint16[h2 + 5] = a2, this.uint16[h2 + 6] = o2, this.uint16[h2 + 7] = l2, this.uint16[h2 + 8] = u2, this.uint16[h2 + 9] = c2, t2;
  38764. }
  38765. }
  38766. Es.prototype.bytesPerElement = 20, ai(Es, "StructArrayLayout10ui20");
  38767. class Cs extends As {
  38768. _refreshViews() {
  38769. this.uint8 = new Uint8Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
  38770. }
  38771. emplaceBack(t2, e2, r2, n2, i3, s2, a2, o2) {
  38772. const l2 = this.length;
  38773. return this.resize(l2 + 1), this.emplace(l2, t2, e2, r2, n2, i3, s2, a2, o2);
  38774. }
  38775. emplace(t2, e2, r2, n2, i3, s2, a2, o2, l2) {
  38776. const u2 = 8 * t2;
  38777. return this.uint16[u2 + 0] = e2, this.uint16[u2 + 1] = r2, this.uint16[u2 + 2] = n2, this.uint16[u2 + 3] = i3, this.uint16[u2 + 4] = s2, this.uint16[u2 + 5] = a2, this.uint16[u2 + 6] = o2, this.uint16[u2 + 7] = l2, t2;
  38778. }
  38779. }
  38780. Cs.prototype.bytesPerElement = 16, ai(Cs, "StructArrayLayout8ui16");
  38781. class Ds extends As {
  38782. _refreshViews() {
  38783. this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
  38784. }
  38785. emplaceBack(t2, e2, r2, n2, i3, s2) {
  38786. const a2 = this.length;
  38787. return this.resize(a2 + 1), this.emplace(a2, t2, e2, r2, n2, i3, s2);
  38788. }
  38789. emplace(t2, e2, r2, n2, i3, s2, a2) {
  38790. const o2 = 6 * t2;
  38791. return this.int16[o2 + 0] = e2, this.int16[o2 + 1] = r2, this.int16[o2 + 2] = n2, this.int16[o2 + 3] = i3, this.int16[o2 + 4] = s2, this.int16[o2 + 5] = a2, t2;
  38792. }
  38793. }
  38794. Ds.prototype.bytesPerElement = 12, ai(Ds, "StructArrayLayout6i12");
  38795. class Ps extends As {
  38796. _refreshViews() {
  38797. this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
  38798. }
  38799. emplaceBack(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2) {
  38800. const m2 = this.length;
  38801. return this.resize(m2 + 1), this.emplace(m2, t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2);
  38802. }
  38803. emplace(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2, m2) {
  38804. const g2 = 16 * t2;
  38805. return this.int16[g2 + 0] = e2, this.int16[g2 + 1] = r2, this.int16[g2 + 2] = n2, this.int16[g2 + 3] = i3, this.uint16[g2 + 4] = s2, this.uint16[g2 + 5] = a2, this.uint16[g2 + 6] = o2, this.uint16[g2 + 7] = l2, this.int16[g2 + 8] = u2, this.int16[g2 + 9] = c2, this.int16[g2 + 10] = h2, this.int16[g2 + 11] = p2, this.int16[g2 + 12] = f2, this.int16[g2 + 13] = d2, this.int16[g2 + 14] = y2, this.int16[g2 + 15] = m2, t2;
  38806. }
  38807. }
  38808. Ps.prototype.bytesPerElement = 32, ai(Ps, "StructArrayLayout4i4ui4i4i32");
  38809. class Vs extends As {
  38810. _refreshViews() {
  38811. this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
  38812. }
  38813. emplaceBack(t2, e2, r2) {
  38814. const n2 = this.length;
  38815. return this.resize(n2 + 1), this.emplace(n2, t2, e2, r2);
  38816. }
  38817. emplace(t2, e2, r2, n2) {
  38818. const i3 = 3 * t2;
  38819. return this.float32[i3 + 0] = e2, this.float32[i3 + 1] = r2, this.float32[i3 + 2] = n2, t2;
  38820. }
  38821. }
  38822. Vs.prototype.bytesPerElement = 12, ai(Vs, "StructArrayLayout3f12");
  38823. class Fs extends As {
  38824. _refreshViews() {
  38825. this.uint8 = new Uint8Array(this.arrayBuffer), this.uint32 = new Uint32Array(this.arrayBuffer);
  38826. }
  38827. emplaceBack(t2) {
  38828. const e2 = this.length;
  38829. return this.resize(e2 + 1), this.emplace(e2, t2);
  38830. }
  38831. emplace(t2, e2) {
  38832. return this.uint32[1 * t2 + 0] = e2, t2;
  38833. }
  38834. }
  38835. Fs.prototype.bytesPerElement = 4, ai(Fs, "StructArrayLayout1ul4");
  38836. class Ls extends As {
  38837. _refreshViews() {
  38838. this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer), this.uint32 = new Uint32Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
  38839. }
  38840. emplaceBack(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2) {
  38841. const f2 = this.length;
  38842. return this.resize(f2 + 1), this.emplace(f2, t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2);
  38843. }
  38844. emplace(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2) {
  38845. const d2 = 20 * t2, y2 = 10 * t2;
  38846. return this.int16[d2 + 0] = e2, this.int16[d2 + 1] = r2, this.int16[d2 + 2] = n2, this.int16[d2 + 3] = i3, this.int16[d2 + 4] = s2, this.float32[y2 + 3] = a2, this.float32[y2 + 4] = o2, this.float32[y2 + 5] = l2, this.float32[y2 + 6] = u2, this.int16[d2 + 14] = c2, this.uint32[y2 + 8] = h2, this.uint16[d2 + 18] = p2, this.uint16[d2 + 19] = f2, t2;
  38847. }
  38848. }
  38849. Ls.prototype.bytesPerElement = 40, ai(Ls, "StructArrayLayout5i4f1i1ul2ui40");
  38850. class Rs extends As {
  38851. _refreshViews() {
  38852. this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
  38853. }
  38854. emplaceBack(t2, e2, r2, n2, i3, s2, a2) {
  38855. const o2 = this.length;
  38856. return this.resize(o2 + 1), this.emplace(o2, t2, e2, r2, n2, i3, s2, a2);
  38857. }
  38858. emplace(t2, e2, r2, n2, i3, s2, a2, o2) {
  38859. const l2 = 8 * t2;
  38860. return this.int16[l2 + 0] = e2, this.int16[l2 + 1] = r2, this.int16[l2 + 2] = n2, this.int16[l2 + 4] = i3, this.int16[l2 + 5] = s2, this.int16[l2 + 6] = a2, this.int16[l2 + 7] = o2, t2;
  38861. }
  38862. }
  38863. Rs.prototype.bytesPerElement = 16, ai(Rs, "StructArrayLayout3i2i2i16");
  38864. class Us extends As {
  38865. _refreshViews() {
  38866. this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
  38867. }
  38868. emplaceBack(t2, e2, r2, n2, i3) {
  38869. const s2 = this.length;
  38870. return this.resize(s2 + 1), this.emplace(s2, t2, e2, r2, n2, i3);
  38871. }
  38872. emplace(t2, e2, r2, n2, i3, s2) {
  38873. const a2 = 4 * t2, o2 = 8 * t2;
  38874. return this.float32[a2 + 0] = e2, this.float32[a2 + 1] = r2, this.float32[a2 + 2] = n2, this.int16[o2 + 6] = i3, this.int16[o2 + 7] = s2, t2;
  38875. }
  38876. }
  38877. Us.prototype.bytesPerElement = 16, ai(Us, "StructArrayLayout2f1f2i16");
  38878. class $s extends As {
  38879. _refreshViews() {
  38880. this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
  38881. }
  38882. emplaceBack(t2, e2, r2, n2) {
  38883. const i3 = this.length;
  38884. return this.resize(i3 + 1), this.emplace(i3, t2, e2, r2, n2);
  38885. }
  38886. emplace(t2, e2, r2, n2, i3) {
  38887. const s2 = 12 * t2, a2 = 3 * t2;
  38888. return this.uint8[s2 + 0] = e2, this.uint8[s2 + 1] = r2, this.float32[a2 + 1] = n2, this.float32[a2 + 2] = i3, t2;
  38889. }
  38890. }
  38891. $s.prototype.bytesPerElement = 12, ai($s, "StructArrayLayout2ub2f12");
  38892. class js extends As {
  38893. _refreshViews() {
  38894. this.uint8 = new Uint8Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
  38895. }
  38896. emplaceBack(t2, e2, r2) {
  38897. const n2 = this.length;
  38898. return this.resize(n2 + 1), this.emplace(n2, t2, e2, r2);
  38899. }
  38900. emplace(t2, e2, r2, n2) {
  38901. const i3 = 3 * t2;
  38902. return this.uint16[i3 + 0] = e2, this.uint16[i3 + 1] = r2, this.uint16[i3 + 2] = n2, t2;
  38903. }
  38904. }
  38905. js.prototype.bytesPerElement = 6, ai(js, "StructArrayLayout3ui6");
  38906. class Os extends As {
  38907. _refreshViews() {
  38908. this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer), this.uint32 = new Uint32Array(this.arrayBuffer);
  38909. }
  38910. emplaceBack(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2, m2, g2, x2, v2, b2) {
  38911. const _2 = this.length;
  38912. return this.resize(_2 + 1), this.emplace(_2, t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2, m2, g2, x2, v2, b2);
  38913. }
  38914. emplace(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2, m2, g2, x2, v2, b2, _2) {
  38915. const w2 = 30 * t2, A2 = 15 * t2, k2 = 60 * t2;
  38916. return this.int16[w2 + 0] = e2, this.int16[w2 + 1] = r2, this.int16[w2 + 2] = n2, this.float32[A2 + 2] = i3, this.float32[A2 + 3] = s2, this.uint16[w2 + 8] = a2, this.uint16[w2 + 9] = o2, this.uint32[A2 + 5] = l2, this.uint32[A2 + 6] = u2, this.uint32[A2 + 7] = c2, this.uint16[w2 + 16] = h2, this.uint16[w2 + 17] = p2, this.uint16[w2 + 18] = f2, this.float32[A2 + 10] = d2, this.float32[A2 + 11] = y2, this.uint8[k2 + 48] = m2, this.uint8[k2 + 49] = g2, this.uint8[k2 + 50] = x2, this.uint32[A2 + 13] = v2, this.int16[w2 + 28] = b2, this.uint8[k2 + 58] = _2, t2;
  38917. }
  38918. }
  38919. Os.prototype.bytesPerElement = 60, ai(Os, "StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");
  38920. class qs extends As {
  38921. _refreshViews() {
  38922. this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer), this.uint32 = new Uint32Array(this.arrayBuffer);
  38923. }
  38924. emplaceBack(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2, m2, g2, x2, v2, b2, _2, w2, A2, k2, S2, I2, M2, T2, z2) {
  38925. const B2 = this.length;
  38926. return this.resize(B2 + 1), this.emplace(B2, t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2, m2, g2, x2, v2, b2, _2, w2, A2, k2, S2, I2, M2, T2, z2);
  38927. }
  38928. emplace(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2, m2, g2, x2, v2, b2, _2, w2, A2, k2, S2, I2, M2, T2, z2, B2) {
  38929. const E2 = 38 * t2, C2 = 19 * t2;
  38930. return this.int16[E2 + 0] = e2, this.int16[E2 + 1] = r2, this.int16[E2 + 2] = n2, this.float32[C2 + 2] = i3, this.float32[C2 + 3] = s2, this.int16[E2 + 8] = a2, this.int16[E2 + 9] = o2, this.int16[E2 + 10] = l2, this.int16[E2 + 11] = u2, this.int16[E2 + 12] = c2, this.int16[E2 + 13] = h2, this.uint16[E2 + 14] = p2, this.uint16[E2 + 15] = f2, this.uint16[E2 + 16] = d2, this.uint16[E2 + 17] = y2, this.uint16[E2 + 18] = m2, this.uint16[E2 + 19] = g2, this.uint16[E2 + 20] = x2, this.uint16[E2 + 21] = v2, this.uint16[E2 + 22] = b2, this.uint16[E2 + 23] = _2, this.uint16[E2 + 24] = w2, this.uint16[E2 + 25] = A2, this.uint16[E2 + 26] = k2, this.uint16[E2 + 27] = S2, this.uint16[E2 + 28] = I2, this.uint32[C2 + 15] = M2, this.float32[C2 + 16] = T2, this.float32[C2 + 17] = z2, this.float32[C2 + 18] = B2, t2;
  38931. }
  38932. }
  38933. qs.prototype.bytesPerElement = 76, ai(qs, "StructArrayLayout3i2f6i15ui1ul3f76");
  38934. class Ns extends As {
  38935. _refreshViews() {
  38936. this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
  38937. }
  38938. emplaceBack(t2) {
  38939. const e2 = this.length;
  38940. return this.resize(e2 + 1), this.emplace(e2, t2);
  38941. }
  38942. emplace(t2, e2) {
  38943. return this.float32[1 * t2 + 0] = e2, t2;
  38944. }
  38945. }
  38946. Ns.prototype.bytesPerElement = 4, ai(Ns, "StructArrayLayout1f4");
  38947. class Gs extends As {
  38948. _refreshViews() {
  38949. this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
  38950. }
  38951. emplaceBack(t2, e2, r2, n2, i3, s2, a2) {
  38952. const o2 = this.length;
  38953. return this.resize(o2 + 1), this.emplace(o2, t2, e2, r2, n2, i3, s2, a2);
  38954. }
  38955. emplace(t2, e2, r2, n2, i3, s2, a2, o2) {
  38956. const l2 = 7 * t2;
  38957. return this.float32[l2 + 0] = e2, this.float32[l2 + 1] = r2, this.float32[l2 + 2] = n2, this.float32[l2 + 3] = i3, this.float32[l2 + 4] = s2, this.float32[l2 + 5] = a2, this.float32[l2 + 6] = o2, t2;
  38958. }
  38959. }
  38960. Gs.prototype.bytesPerElement = 28, ai(Gs, "StructArrayLayout7f28");
  38961. class Zs extends As {
  38962. _refreshViews() {
  38963. this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
  38964. }
  38965. emplaceBack(t2, e2, r2, n2, i3) {
  38966. const s2 = this.length;
  38967. return this.resize(s2 + 1), this.emplace(s2, t2, e2, r2, n2, i3);
  38968. }
  38969. emplace(t2, e2, r2, n2, i3, s2) {
  38970. const a2 = 5 * t2;
  38971. return this.float32[a2 + 0] = e2, this.float32[a2 + 1] = r2, this.float32[a2 + 2] = n2, this.float32[a2 + 3] = i3, this.float32[a2 + 4] = s2, t2;
  38972. }
  38973. }
  38974. Zs.prototype.bytesPerElement = 20, ai(Zs, "StructArrayLayout5f20");
  38975. class Xs extends As {
  38976. _refreshViews() {
  38977. this.uint8 = new Uint8Array(this.arrayBuffer), this.uint32 = new Uint32Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
  38978. }
  38979. emplaceBack(t2, e2, r2, n2) {
  38980. const i3 = this.length;
  38981. return this.resize(i3 + 1), this.emplace(i3, t2, e2, r2, n2);
  38982. }
  38983. emplace(t2, e2, r2, n2, i3) {
  38984. const s2 = 6 * t2;
  38985. return this.uint32[3 * t2 + 0] = e2, this.uint16[s2 + 2] = r2, this.uint16[s2 + 3] = n2, this.uint16[s2 + 4] = i3, t2;
  38986. }
  38987. }
  38988. Xs.prototype.bytesPerElement = 12, ai(Xs, "StructArrayLayout1ul3ui12");
  38989. class Ks extends As {
  38990. _refreshViews() {
  38991. this.uint8 = new Uint8Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
  38992. }
  38993. emplaceBack(t2, e2) {
  38994. const r2 = this.length;
  38995. return this.resize(r2 + 1), this.emplace(r2, t2, e2);
  38996. }
  38997. emplace(t2, e2, r2) {
  38998. const n2 = 2 * t2;
  38999. return this.uint16[n2 + 0] = e2, this.uint16[n2 + 1] = r2, t2;
  39000. }
  39001. }
  39002. Ks.prototype.bytesPerElement = 4, ai(Ks, "StructArrayLayout2ui4");
  39003. class Ys extends As {
  39004. _refreshViews() {
  39005. this.uint8 = new Uint8Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
  39006. }
  39007. emplaceBack(t2) {
  39008. const e2 = this.length;
  39009. return this.resize(e2 + 1), this.emplace(e2, t2);
  39010. }
  39011. emplace(t2, e2) {
  39012. return this.uint16[1 * t2 + 0] = e2, t2;
  39013. }
  39014. }
  39015. Ys.prototype.bytesPerElement = 2, ai(Ys, "StructArrayLayout1ui2");
  39016. class Hs extends As {
  39017. _refreshViews() {
  39018. this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
  39019. }
  39020. emplaceBack(t2, e2) {
  39021. const r2 = this.length;
  39022. return this.resize(r2 + 1), this.emplace(r2, t2, e2);
  39023. }
  39024. emplace(t2, e2, r2) {
  39025. const n2 = 2 * t2;
  39026. return this.float32[n2 + 0] = e2, this.float32[n2 + 1] = r2, t2;
  39027. }
  39028. }
  39029. Hs.prototype.bytesPerElement = 8, ai(Hs, "StructArrayLayout2f8");
  39030. class Ws extends As {
  39031. _refreshViews() {
  39032. this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
  39033. }
  39034. emplaceBack(t2, e2, r2, n2, i3, s2, a2) {
  39035. const o2 = this.length;
  39036. return this.resize(o2 + 1), this.emplace(o2, t2, e2, r2, n2, i3, s2, a2);
  39037. }
  39038. emplace(t2, e2, r2, n2, i3, s2, a2, o2) {
  39039. const l2 = 8 * t2, u2 = 4 * t2;
  39040. return this.int16[l2 + 0] = e2, this.int16[l2 + 1] = r2, this.int16[l2 + 2] = n2, this.int16[l2 + 3] = i3, this.int16[l2 + 4] = s2, this.int16[l2 + 5] = a2, this.float32[u2 + 3] = o2, t2;
  39041. }
  39042. }
  39043. Ws.prototype.bytesPerElement = 16, ai(Ws, "StructArrayLayout6i1f16");
  39044. class Js extends ws {
  39045. get a_pos_30() {
  39046. return this._structArray.int16[this._pos2 + 0];
  39047. }
  39048. get a_pos_31() {
  39049. return this._structArray.int16[this._pos2 + 1];
  39050. }
  39051. get a_pos_32() {
  39052. return this._structArray.int16[this._pos2 + 2];
  39053. }
  39054. get a_pos_normal_30() {
  39055. return this._structArray.int16[this._pos2 + 3];
  39056. }
  39057. get a_pos_normal_31() {
  39058. return this._structArray.int16[this._pos2 + 4];
  39059. }
  39060. get a_pos_normal_32() {
  39061. return this._structArray.int16[this._pos2 + 5];
  39062. }
  39063. }
  39064. Js.prototype.size = 12;
  39065. class Qs extends Ds {
  39066. get(t2) {
  39067. return new Js(this, t2);
  39068. }
  39069. }
  39070. ai(Qs, "FillExtrusionExtArray");
  39071. class ta extends ws {
  39072. get projectedAnchorX() {
  39073. return this._structArray.int16[this._pos2 + 0];
  39074. }
  39075. get projectedAnchorY() {
  39076. return this._structArray.int16[this._pos2 + 1];
  39077. }
  39078. get projectedAnchorZ() {
  39079. return this._structArray.int16[this._pos2 + 2];
  39080. }
  39081. get tileAnchorX() {
  39082. return this._structArray.int16[this._pos2 + 3];
  39083. }
  39084. get tileAnchorY() {
  39085. return this._structArray.int16[this._pos2 + 4];
  39086. }
  39087. get x1() {
  39088. return this._structArray.float32[this._pos4 + 3];
  39089. }
  39090. get y1() {
  39091. return this._structArray.float32[this._pos4 + 4];
  39092. }
  39093. get x2() {
  39094. return this._structArray.float32[this._pos4 + 5];
  39095. }
  39096. get y2() {
  39097. return this._structArray.float32[this._pos4 + 6];
  39098. }
  39099. get padding() {
  39100. return this._structArray.int16[this._pos2 + 14];
  39101. }
  39102. get featureIndex() {
  39103. return this._structArray.uint32[this._pos4 + 8];
  39104. }
  39105. get sourceLayerIndex() {
  39106. return this._structArray.uint16[this._pos2 + 18];
  39107. }
  39108. get bucketIndex() {
  39109. return this._structArray.uint16[this._pos2 + 19];
  39110. }
  39111. }
  39112. ta.prototype.size = 40;
  39113. class ea extends Ls {
  39114. get(t2) {
  39115. return new ta(this, t2);
  39116. }
  39117. }
  39118. ai(ea, "CollisionBoxArray");
  39119. class ra extends ws {
  39120. get projectedAnchorX() {
  39121. return this._structArray.int16[this._pos2 + 0];
  39122. }
  39123. get projectedAnchorY() {
  39124. return this._structArray.int16[this._pos2 + 1];
  39125. }
  39126. get projectedAnchorZ() {
  39127. return this._structArray.int16[this._pos2 + 2];
  39128. }
  39129. get tileAnchorX() {
  39130. return this._structArray.float32[this._pos4 + 2];
  39131. }
  39132. get tileAnchorY() {
  39133. return this._structArray.float32[this._pos4 + 3];
  39134. }
  39135. get glyphStartIndex() {
  39136. return this._structArray.uint16[this._pos2 + 8];
  39137. }
  39138. get numGlyphs() {
  39139. return this._structArray.uint16[this._pos2 + 9];
  39140. }
  39141. get vertexStartIndex() {
  39142. return this._structArray.uint32[this._pos4 + 5];
  39143. }
  39144. get lineStartIndex() {
  39145. return this._structArray.uint32[this._pos4 + 6];
  39146. }
  39147. get lineLength() {
  39148. return this._structArray.uint32[this._pos4 + 7];
  39149. }
  39150. get segment() {
  39151. return this._structArray.uint16[this._pos2 + 16];
  39152. }
  39153. get lowerSize() {
  39154. return this._structArray.uint16[this._pos2 + 17];
  39155. }
  39156. get upperSize() {
  39157. return this._structArray.uint16[this._pos2 + 18];
  39158. }
  39159. get lineOffsetX() {
  39160. return this._structArray.float32[this._pos4 + 10];
  39161. }
  39162. get lineOffsetY() {
  39163. return this._structArray.float32[this._pos4 + 11];
  39164. }
  39165. get writingMode() {
  39166. return this._structArray.uint8[this._pos1 + 48];
  39167. }
  39168. get placedOrientation() {
  39169. return this._structArray.uint8[this._pos1 + 49];
  39170. }
  39171. set placedOrientation(t2) {
  39172. this._structArray.uint8[this._pos1 + 49] = t2;
  39173. }
  39174. get hidden() {
  39175. return this._structArray.uint8[this._pos1 + 50];
  39176. }
  39177. set hidden(t2) {
  39178. this._structArray.uint8[this._pos1 + 50] = t2;
  39179. }
  39180. get crossTileID() {
  39181. return this._structArray.uint32[this._pos4 + 13];
  39182. }
  39183. set crossTileID(t2) {
  39184. this._structArray.uint32[this._pos4 + 13] = t2;
  39185. }
  39186. get associatedIconIndex() {
  39187. return this._structArray.int16[this._pos2 + 28];
  39188. }
  39189. get flipState() {
  39190. return this._structArray.uint8[this._pos1 + 58];
  39191. }
  39192. set flipState(t2) {
  39193. this._structArray.uint8[this._pos1 + 58] = t2;
  39194. }
  39195. }
  39196. ra.prototype.size = 60;
  39197. class na extends Os {
  39198. get(t2) {
  39199. return new ra(this, t2);
  39200. }
  39201. }
  39202. ai(na, "PlacedSymbolArray");
  39203. class ia extends ws {
  39204. get projectedAnchorX() {
  39205. return this._structArray.int16[this._pos2 + 0];
  39206. }
  39207. get projectedAnchorY() {
  39208. return this._structArray.int16[this._pos2 + 1];
  39209. }
  39210. get projectedAnchorZ() {
  39211. return this._structArray.int16[this._pos2 + 2];
  39212. }
  39213. get tileAnchorX() {
  39214. return this._structArray.float32[this._pos4 + 2];
  39215. }
  39216. get tileAnchorY() {
  39217. return this._structArray.float32[this._pos4 + 3];
  39218. }
  39219. get rightJustifiedTextSymbolIndex() {
  39220. return this._structArray.int16[this._pos2 + 8];
  39221. }
  39222. get centerJustifiedTextSymbolIndex() {
  39223. return this._structArray.int16[this._pos2 + 9];
  39224. }
  39225. get leftJustifiedTextSymbolIndex() {
  39226. return this._structArray.int16[this._pos2 + 10];
  39227. }
  39228. get verticalPlacedTextSymbolIndex() {
  39229. return this._structArray.int16[this._pos2 + 11];
  39230. }
  39231. get placedIconSymbolIndex() {
  39232. return this._structArray.int16[this._pos2 + 12];
  39233. }
  39234. get verticalPlacedIconSymbolIndex() {
  39235. return this._structArray.int16[this._pos2 + 13];
  39236. }
  39237. get key() {
  39238. return this._structArray.uint16[this._pos2 + 14];
  39239. }
  39240. get textBoxStartIndex() {
  39241. return this._structArray.uint16[this._pos2 + 15];
  39242. }
  39243. get textBoxEndIndex() {
  39244. return this._structArray.uint16[this._pos2 + 16];
  39245. }
  39246. get verticalTextBoxStartIndex() {
  39247. return this._structArray.uint16[this._pos2 + 17];
  39248. }
  39249. get verticalTextBoxEndIndex() {
  39250. return this._structArray.uint16[this._pos2 + 18];
  39251. }
  39252. get iconBoxStartIndex() {
  39253. return this._structArray.uint16[this._pos2 + 19];
  39254. }
  39255. get iconBoxEndIndex() {
  39256. return this._structArray.uint16[this._pos2 + 20];
  39257. }
  39258. get verticalIconBoxStartIndex() {
  39259. return this._structArray.uint16[this._pos2 + 21];
  39260. }
  39261. get verticalIconBoxEndIndex() {
  39262. return this._structArray.uint16[this._pos2 + 22];
  39263. }
  39264. get featureIndex() {
  39265. return this._structArray.uint16[this._pos2 + 23];
  39266. }
  39267. get numHorizontalGlyphVertices() {
  39268. return this._structArray.uint16[this._pos2 + 24];
  39269. }
  39270. get numVerticalGlyphVertices() {
  39271. return this._structArray.uint16[this._pos2 + 25];
  39272. }
  39273. get numIconVertices() {
  39274. return this._structArray.uint16[this._pos2 + 26];
  39275. }
  39276. get numVerticalIconVertices() {
  39277. return this._structArray.uint16[this._pos2 + 27];
  39278. }
  39279. get useRuntimeCollisionCircles() {
  39280. return this._structArray.uint16[this._pos2 + 28];
  39281. }
  39282. get crossTileID() {
  39283. return this._structArray.uint32[this._pos4 + 15];
  39284. }
  39285. set crossTileID(t2) {
  39286. this._structArray.uint32[this._pos4 + 15] = t2;
  39287. }
  39288. get textOffset0() {
  39289. return this._structArray.float32[this._pos4 + 16];
  39290. }
  39291. get textOffset1() {
  39292. return this._structArray.float32[this._pos4 + 17];
  39293. }
  39294. get collisionCircleDiameter() {
  39295. return this._structArray.float32[this._pos4 + 18];
  39296. }
  39297. }
  39298. ia.prototype.size = 76;
  39299. class sa extends qs {
  39300. get(t2) {
  39301. return new ia(this, t2);
  39302. }
  39303. }
  39304. ai(sa, "SymbolInstanceArray");
  39305. class aa extends Ns {
  39306. getoffsetX(t2) {
  39307. return this.float32[1 * t2 + 0];
  39308. }
  39309. }
  39310. ai(aa, "GlyphOffsetArray");
  39311. class oa extends Ms {
  39312. getx(t2) {
  39313. return this.int16[3 * t2 + 0];
  39314. }
  39315. gety(t2) {
  39316. return this.int16[3 * t2 + 1];
  39317. }
  39318. gettileUnitDistanceFromAnchor(t2) {
  39319. return this.int16[3 * t2 + 2];
  39320. }
  39321. }
  39322. ai(oa, "SymbolLineVertexArray");
  39323. class la extends ws {
  39324. get featureIndex() {
  39325. return this._structArray.uint32[this._pos4 + 0];
  39326. }
  39327. get sourceLayerIndex() {
  39328. return this._structArray.uint16[this._pos2 + 2];
  39329. }
  39330. get bucketIndex() {
  39331. return this._structArray.uint16[this._pos2 + 3];
  39332. }
  39333. get layoutVertexArrayOffset() {
  39334. return this._structArray.uint16[this._pos2 + 4];
  39335. }
  39336. }
  39337. la.prototype.size = 12;
  39338. class ua extends Xs {
  39339. get(t2) {
  39340. return new la(this, t2);
  39341. }
  39342. }
  39343. ai(ua, "FeatureIndexArray");
  39344. class ca extends ws {
  39345. get a_centroid_pos0() {
  39346. return this._structArray.uint16[this._pos2 + 0];
  39347. }
  39348. get a_centroid_pos1() {
  39349. return this._structArray.uint16[this._pos2 + 1];
  39350. }
  39351. }
  39352. ca.prototype.size = 4;
  39353. class ha extends Ks {
  39354. get(t2) {
  39355. return new ca(this, t2);
  39356. }
  39357. }
  39358. ai(ha, "FillExtrusionCentroidArray");
  39359. class pa extends ws {
  39360. get a_pos_30() {
  39361. return this._structArray.int16[this._pos2 + 0];
  39362. }
  39363. get a_pos_31() {
  39364. return this._structArray.int16[this._pos2 + 1];
  39365. }
  39366. get a_pos_32() {
  39367. return this._structArray.int16[this._pos2 + 2];
  39368. }
  39369. get a_pos_normal_30() {
  39370. return this._structArray.int16[this._pos2 + 3];
  39371. }
  39372. get a_pos_normal_31() {
  39373. return this._structArray.int16[this._pos2 + 4];
  39374. }
  39375. get a_pos_normal_32() {
  39376. return this._structArray.int16[this._pos2 + 5];
  39377. }
  39378. get a_scale() {
  39379. return this._structArray.float32[this._pos4 + 3];
  39380. }
  39381. }
  39382. pa.prototype.size = 16;
  39383. class fa extends Ws {
  39384. get(t2) {
  39385. return new pa(this, t2);
  39386. }
  39387. }
  39388. ai(fa, "CircleGlobeExtArray");
  39389. const da = ks([{ name: "a_pattern_to", components: 4, type: "Uint16" }, { name: "a_pattern_from", components: 4, type: "Uint16" }, { name: "a_pixel_ratio_to", components: 1, type: "Uint16" }, { name: "a_pixel_ratio_from", components: 1, type: "Uint16" }]), ya = ks([{ name: "a_dash_to", components: 4, type: "Uint16" }, { name: "a_dash_from", components: 4, type: "Uint16" }]);
  39390. var ma = le(function(t2) {
  39391. t2.exports = function(t3, e2) {
  39392. var r2, n2, i3, s2, a2, o2, l2, u2;
  39393. for (n2 = t3.length - (r2 = 3 & t3.length), i3 = e2, a2 = 3432918353, o2 = 461845907, u2 = 0; u2 < n2; )
  39394. l2 = 255 & t3.charCodeAt(u2) | (255 & t3.charCodeAt(++u2)) << 8 | (255 & t3.charCodeAt(++u2)) << 16 | (255 & t3.charCodeAt(++u2)) << 24, ++u2, i3 = 27492 + (65535 & (s2 = 5 * (65535 & (i3 = (i3 ^= l2 = (65535 & (l2 = (l2 = (65535 & l2) * a2 + (((l2 >>> 16) * a2 & 65535) << 16) & 4294967295) << 15 | l2 >>> 17)) * o2 + (((l2 >>> 16) * o2 & 65535) << 16) & 4294967295) << 13 | i3 >>> 19)) + ((5 * (i3 >>> 16) & 65535) << 16) & 4294967295)) + ((58964 + (s2 >>> 16) & 65535) << 16);
  39395. switch (l2 = 0, r2) {
  39396. case 3:
  39397. l2 ^= (255 & t3.charCodeAt(u2 + 2)) << 16;
  39398. case 2:
  39399. l2 ^= (255 & t3.charCodeAt(u2 + 1)) << 8;
  39400. case 1:
  39401. i3 ^= l2 = (65535 & (l2 = (l2 = (65535 & (l2 ^= 255 & t3.charCodeAt(u2))) * a2 + (((l2 >>> 16) * a2 & 65535) << 16) & 4294967295) << 15 | l2 >>> 17)) * o2 + (((l2 >>> 16) * o2 & 65535) << 16) & 4294967295;
  39402. }
  39403. return i3 ^= t3.length, i3 = 2246822507 * (65535 & (i3 ^= i3 >>> 16)) + ((2246822507 * (i3 >>> 16) & 65535) << 16) & 4294967295, i3 = 3266489909 * (65535 & (i3 ^= i3 >>> 13)) + ((3266489909 * (i3 >>> 16) & 65535) << 16) & 4294967295, (i3 ^= i3 >>> 16) >>> 0;
  39404. };
  39405. }), ga = le(function(t2) {
  39406. t2.exports = function(t3, e2) {
  39407. for (var r2, n2 = t3.length, i3 = e2 ^ n2, s2 = 0; n2 >= 4; )
  39408. r2 = 1540483477 * (65535 & (r2 = 255 & t3.charCodeAt(s2) | (255 & t3.charCodeAt(++s2)) << 8 | (255 & t3.charCodeAt(++s2)) << 16 | (255 & t3.charCodeAt(++s2)) << 24)) + ((1540483477 * (r2 >>> 16) & 65535) << 16), i3 = 1540483477 * (65535 & i3) + ((1540483477 * (i3 >>> 16) & 65535) << 16) ^ (r2 = 1540483477 * (65535 & (r2 ^= r2 >>> 24)) + ((1540483477 * (r2 >>> 16) & 65535) << 16)), n2 -= 4, ++s2;
  39409. switch (n2) {
  39410. case 3:
  39411. i3 ^= (255 & t3.charCodeAt(s2 + 2)) << 16;
  39412. case 2:
  39413. i3 ^= (255 & t3.charCodeAt(s2 + 1)) << 8;
  39414. case 1:
  39415. i3 = 1540483477 * (65535 & (i3 ^= 255 & t3.charCodeAt(s2))) + ((1540483477 * (i3 >>> 16) & 65535) << 16);
  39416. }
  39417. return i3 = 1540483477 * (65535 & (i3 ^= i3 >>> 13)) + ((1540483477 * (i3 >>> 16) & 65535) << 16), (i3 ^= i3 >>> 15) >>> 0;
  39418. };
  39419. }), xa = ma, va = ga;
  39420. xa.murmur3 = ma, xa.murmur2 = va;
  39421. class ba {
  39422. constructor() {
  39423. this.ids = [], this.positions = [], this.indexed = false;
  39424. }
  39425. add(t2, e2, r2, n2) {
  39426. this.ids.push(_a(t2)), this.positions.push(e2, r2, n2);
  39427. }
  39428. getPositions(t2) {
  39429. const e2 = _a(t2);
  39430. let r2 = 0, n2 = this.ids.length - 1;
  39431. for (; r2 < n2; ) {
  39432. const t3 = r2 + n2 >> 1;
  39433. this.ids[t3] >= e2 ? n2 = t3 : r2 = t3 + 1;
  39434. }
  39435. const i3 = [];
  39436. for (; this.ids[r2] === e2; )
  39437. i3.push({ index: this.positions[3 * r2], start: this.positions[3 * r2 + 1], end: this.positions[3 * r2 + 2] }), r2++;
  39438. return i3;
  39439. }
  39440. static serialize(t2, e2) {
  39441. const r2 = new Float64Array(t2.ids), n2 = new Uint32Array(t2.positions);
  39442. return wa(r2, n2, 0, r2.length - 1), e2 && e2.push(r2.buffer, n2.buffer), { ids: r2, positions: n2 };
  39443. }
  39444. static deserialize(t2) {
  39445. const e2 = new ba();
  39446. return e2.ids = t2.ids, e2.positions = t2.positions, e2.indexed = true, e2;
  39447. }
  39448. }
  39449. function _a(t2) {
  39450. const e2 = +t2;
  39451. return !isNaN(e2) && Number.MIN_SAFE_INTEGER <= e2 && e2 <= Number.MAX_SAFE_INTEGER ? e2 : xa(String(t2));
  39452. }
  39453. function wa(t2, e2, r2, n2) {
  39454. for (; r2 < n2; ) {
  39455. const i3 = t2[r2 + n2 >> 1];
  39456. let s2 = r2 - 1, a2 = n2 + 1;
  39457. for (; ; ) {
  39458. do {
  39459. s2++;
  39460. } while (t2[s2] < i3);
  39461. do {
  39462. a2--;
  39463. } while (t2[a2] > i3);
  39464. if (s2 >= a2)
  39465. break;
  39466. Aa(t2, s2, a2), Aa(e2, 3 * s2, 3 * a2), Aa(e2, 3 * s2 + 1, 3 * a2 + 1), Aa(e2, 3 * s2 + 2, 3 * a2 + 2);
  39467. }
  39468. a2 - r2 < n2 - a2 ? (wa(t2, e2, r2, a2), r2 = a2 + 1) : (wa(t2, e2, a2 + 1, n2), n2 = a2);
  39469. }
  39470. }
  39471. function Aa(t2, e2, r2) {
  39472. const n2 = t2[e2];
  39473. t2[e2] = t2[r2], t2[r2] = n2;
  39474. }
  39475. ai(ba, "FeaturePositionMap");
  39476. class ka {
  39477. constructor(t2, e2) {
  39478. this.gl = t2.gl, this.location = e2;
  39479. }
  39480. }
  39481. class Sa extends ka {
  39482. constructor(t2, e2) {
  39483. super(t2, e2), this.current = 0;
  39484. }
  39485. set(t2) {
  39486. this.current !== t2 && (this.current = t2, this.gl.uniform1f(this.location, t2));
  39487. }
  39488. }
  39489. class Ia extends ka {
  39490. constructor(t2, e2) {
  39491. super(t2, e2), this.current = [0, 0, 0, 0];
  39492. }
  39493. set(t2) {
  39494. t2[0] === this.current[0] && t2[1] === this.current[1] && t2[2] === this.current[2] && t2[3] === this.current[3] || (this.current = t2, this.gl.uniform4f(this.location, t2[0], t2[1], t2[2], t2[3]));
  39495. }
  39496. }
  39497. class Ma extends ka {
  39498. constructor(t2, e2) {
  39499. super(t2, e2), this.current = ce.transparent;
  39500. }
  39501. set(t2) {
  39502. t2.r === this.current.r && t2.g === this.current.g && t2.b === this.current.b && t2.a === this.current.a || (this.current = t2, this.gl.uniform4f(this.location, t2.r, t2.g, t2.b, t2.a));
  39503. }
  39504. }
  39505. const Ta = new Float32Array(16), za = new Float32Array(9), Ba = new Float32Array(4);
  39506. function Ea(t2) {
  39507. return [bs(255 * t2.r, 255 * t2.g), bs(255 * t2.b, 255 * t2.a)];
  39508. }
  39509. class Ca {
  39510. constructor(t2, e2, r2) {
  39511. this.value = t2, this.uniformNames = e2.map((t3) => `u_${t3}`), this.type = r2;
  39512. }
  39513. setUniform(t2, e2, r2) {
  39514. t2.set(r2.constantOr(this.value));
  39515. }
  39516. getBinding(t2, e2, r2) {
  39517. return "color" === this.type ? new Ma(t2, e2) : new Sa(t2, e2);
  39518. }
  39519. }
  39520. class Da {
  39521. constructor(t2, e2) {
  39522. this.uniformNames = e2.map((t3) => `u_${t3}`), this.patternFrom = null, this.patternTo = null, this.pixelRatioFrom = 1, this.pixelRatioTo = 1;
  39523. }
  39524. setConstantPatternPositions(t2, e2) {
  39525. this.pixelRatioFrom = e2.pixelRatio || 1, this.pixelRatioTo = t2.pixelRatio || 1, this.patternFrom = e2.tl.concat(e2.br), this.patternTo = t2.tl.concat(t2.br);
  39526. }
  39527. setUniform(t2, e2, r2, n2) {
  39528. const i3 = "u_pattern_to" === n2 || "u_dash_to" === n2 ? this.patternTo : "u_pattern_from" === n2 || "u_dash_from" === n2 ? this.patternFrom : "u_pixel_ratio_to" === n2 ? this.pixelRatioTo : "u_pixel_ratio_from" === n2 ? this.pixelRatioFrom : null;
  39529. i3 && t2.set(i3);
  39530. }
  39531. getBinding(t2, e2, r2) {
  39532. return "u_pattern_from" === r2 || "u_pattern_to" === r2 || "u_dash_from" === r2 || "u_dash_to" === r2 ? new Ia(t2, e2) : new Sa(t2, e2);
  39533. }
  39534. }
  39535. class Pa {
  39536. constructor(t2, e2, r2, n2) {
  39537. this.expression = t2, this.type = r2, this.maxValue = 0, this.paintVertexAttributes = e2.map((t3) => ({ name: `a_${t3}`, type: "Float32", components: "color" === r2 ? 2 : 1, offset: 0 })), this.paintVertexArray = new n2();
  39538. }
  39539. populatePaintArray(t2, e2, r2, n2, i3, s2) {
  39540. const a2 = this.paintVertexArray.length, o2 = this.expression.evaluate(new ss(0), e2, {}, i3, n2, s2);
  39541. this.paintVertexArray.resize(t2), this._setPaintValue(a2, t2, o2);
  39542. }
  39543. updatePaintArray(t2, e2, r2, n2, i3) {
  39544. const s2 = this.expression.evaluate({ zoom: 0 }, r2, n2, void 0, i3);
  39545. this._setPaintValue(t2, e2, s2);
  39546. }
  39547. _setPaintValue(t2, e2, r2) {
  39548. if ("color" === this.type) {
  39549. const n2 = Ea(r2);
  39550. for (let r3 = t2; r3 < e2; r3++)
  39551. this.paintVertexArray.emplace(r3, n2[0], n2[1]);
  39552. } else {
  39553. for (let n2 = t2; n2 < e2; n2++)
  39554. this.paintVertexArray.emplace(n2, r2);
  39555. this.maxValue = Math.max(this.maxValue, Math.abs(r2));
  39556. }
  39557. }
  39558. upload(t2) {
  39559. this.paintVertexArray && this.paintVertexArray.arrayBuffer && (this.paintVertexBuffer && this.paintVertexBuffer.buffer ? this.paintVertexBuffer.updateData(this.paintVertexArray) : this.paintVertexBuffer = t2.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent));
  39560. }
  39561. destroy() {
  39562. this.paintVertexBuffer && this.paintVertexBuffer.destroy();
  39563. }
  39564. }
  39565. class Va {
  39566. constructor(t2, e2, r2, n2, i3, s2) {
  39567. this.expression = t2, this.uniformNames = e2.map((t3) => `u_${t3}_t`), this.type = r2, this.useIntegerZoom = n2, this.zoom = i3, this.maxValue = 0, this.paintVertexAttributes = e2.map((t3) => ({ name: `a_${t3}`, type: "Float32", components: "color" === r2 ? 4 : 2, offset: 0 })), this.paintVertexArray = new s2();
  39568. }
  39569. populatePaintArray(t2, e2, r2, n2, i3, s2) {
  39570. const a2 = this.expression.evaluate(new ss(this.zoom), e2, {}, i3, n2, s2), o2 = this.expression.evaluate(new ss(this.zoom + 1), e2, {}, i3, n2, s2), l2 = this.paintVertexArray.length;
  39571. this.paintVertexArray.resize(t2), this._setPaintValue(l2, t2, a2, o2);
  39572. }
  39573. updatePaintArray(t2, e2, r2, n2, i3) {
  39574. const s2 = this.expression.evaluate({ zoom: this.zoom }, r2, n2, void 0, i3), a2 = this.expression.evaluate({ zoom: this.zoom + 1 }, r2, n2, void 0, i3);
  39575. this._setPaintValue(t2, e2, s2, a2);
  39576. }
  39577. _setPaintValue(t2, e2, r2, n2) {
  39578. if ("color" === this.type) {
  39579. const i3 = Ea(r2), s2 = Ea(n2);
  39580. for (let r3 = t2; r3 < e2; r3++)
  39581. this.paintVertexArray.emplace(r3, i3[0], i3[1], s2[0], s2[1]);
  39582. } else {
  39583. for (let i3 = t2; i3 < e2; i3++)
  39584. this.paintVertexArray.emplace(i3, r2, n2);
  39585. this.maxValue = Math.max(this.maxValue, Math.abs(r2), Math.abs(n2));
  39586. }
  39587. }
  39588. upload(t2) {
  39589. this.paintVertexArray && this.paintVertexArray.arrayBuffer && (this.paintVertexBuffer && this.paintVertexBuffer.buffer ? this.paintVertexBuffer.updateData(this.paintVertexArray) : this.paintVertexBuffer = t2.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent));
  39590. }
  39591. destroy() {
  39592. this.paintVertexBuffer && this.paintVertexBuffer.destroy();
  39593. }
  39594. setUniform(t2, e2) {
  39595. const r2 = this.useIntegerZoom ? Math.floor(e2.zoom) : e2.zoom, n2 = y(this.expression.interpolationFactor(r2, this.zoom, this.zoom + 1), 0, 1);
  39596. t2.set(n2);
  39597. }
  39598. getBinding(t2, e2, r2) {
  39599. return new Sa(t2, e2);
  39600. }
  39601. }
  39602. class Fa {
  39603. constructor(t2, e2, r2, n2, i3, s2, a2) {
  39604. this.expression = t2, this.type = r2, this.useIntegerZoom = n2, this.zoom = i3, this.layerId = a2, this.paintVertexAttributes = ("array" === r2 ? ya : da).members;
  39605. for (let t3 = 0; t3 < e2.length; ++t3)
  39606. ;
  39607. this.zoomInPaintVertexArray = new s2(), this.zoomOutPaintVertexArray = new s2();
  39608. }
  39609. populatePaintArray(t2, e2, r2) {
  39610. const n2 = this.zoomInPaintVertexArray.length;
  39611. this.zoomInPaintVertexArray.resize(t2), this.zoomOutPaintVertexArray.resize(t2), this._setPaintValues(n2, t2, e2.patterns && e2.patterns[this.layerId], r2);
  39612. }
  39613. updatePaintArray(t2, e2, r2, n2, i3, s2) {
  39614. this._setPaintValues(t2, e2, r2.patterns && r2.patterns[this.layerId], s2);
  39615. }
  39616. _setPaintValues(t2, e2, r2, n2) {
  39617. if (!n2 || !r2)
  39618. return;
  39619. const { min: i3, mid: s2, max: a2 } = r2, o2 = n2[i3], l2 = n2[s2], u2 = n2[a2];
  39620. if (o2 && l2 && u2)
  39621. for (let r3 = t2; r3 < e2; r3++)
  39622. this._setPaintValue(this.zoomInPaintVertexArray, r3, l2, o2), this._setPaintValue(this.zoomOutPaintVertexArray, r3, l2, u2);
  39623. }
  39624. _setPaintValue(t2, e2, r2, n2) {
  39625. t2.emplace(e2, r2.tl[0], r2.tl[1], r2.br[0], r2.br[1], n2.tl[0], n2.tl[1], n2.br[0], n2.br[1], r2.pixelRatio, n2.pixelRatio);
  39626. }
  39627. upload(t2) {
  39628. this.zoomInPaintVertexArray && this.zoomInPaintVertexArray.arrayBuffer && this.zoomOutPaintVertexArray && this.zoomOutPaintVertexArray.arrayBuffer && (this.zoomInPaintVertexBuffer = t2.createVertexBuffer(this.zoomInPaintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent), this.zoomOutPaintVertexBuffer = t2.createVertexBuffer(this.zoomOutPaintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent));
  39629. }
  39630. destroy() {
  39631. this.zoomOutPaintVertexBuffer && this.zoomOutPaintVertexBuffer.destroy(), this.zoomInPaintVertexBuffer && this.zoomInPaintVertexBuffer.destroy();
  39632. }
  39633. }
  39634. class La {
  39635. constructor(t2, e2, r2 = () => true) {
  39636. this.binders = {}, this._buffers = [];
  39637. const n2 = [];
  39638. for (const i3 in t2.paint._values) {
  39639. if (!r2(i3))
  39640. continue;
  39641. const s2 = t2.paint.get(i3);
  39642. if (!(s2 instanceof ps && Yr(s2.property.specification)))
  39643. continue;
  39644. const a2 = $a(i3, t2.type), o2 = s2.value, l2 = s2.property.specification.type, u2 = s2.property.useIntegerZoom, c2 = s2.property.specification["property-type"], h2 = "cross-faded" === c2 || "cross-faded-data-driven" === c2, p2 = "line-dasharray" === String(i3) && "constant" !== t2.layout.get("line-cap").value.kind;
  39645. if ("constant" !== o2.kind || p2)
  39646. if ("source" === o2.kind || p2 || h2) {
  39647. const r3 = qa(i3, l2, "source");
  39648. this.binders[i3] = h2 ? new Fa(o2, a2, l2, u2, e2, r3, t2.id) : new Pa(o2, a2, l2, r3), n2.push(`/a_${i3}`);
  39649. } else {
  39650. const t3 = qa(i3, l2, "composite");
  39651. this.binders[i3] = new Va(o2, a2, l2, u2, e2, t3), n2.push(`/z_${i3}`);
  39652. }
  39653. else
  39654. this.binders[i3] = h2 ? new Da(o2.value, a2) : new Ca(o2.value, a2, l2), n2.push(`/u_${i3}`);
  39655. }
  39656. this.cacheKey = n2.sort().join("");
  39657. }
  39658. getMaxValue(t2) {
  39659. const e2 = this.binders[t2];
  39660. return e2 instanceof Pa || e2 instanceof Va ? e2.maxValue : 0;
  39661. }
  39662. populatePaintArrays(t2, e2, r2, n2, i3, s2) {
  39663. for (const a2 in this.binders) {
  39664. const o2 = this.binders[a2];
  39665. (o2 instanceof Pa || o2 instanceof Va || o2 instanceof Fa) && o2.populatePaintArray(t2, e2, r2, n2, i3, s2);
  39666. }
  39667. }
  39668. setConstantPatternPositions(t2, e2) {
  39669. for (const r2 in this.binders) {
  39670. const n2 = this.binders[r2];
  39671. n2 instanceof Da && n2.setConstantPatternPositions(t2, e2);
  39672. }
  39673. }
  39674. updatePaintArrays(t2, e2, r2, n2, i3, s2) {
  39675. let a2 = false;
  39676. for (const o2 in t2) {
  39677. const l2 = e2.getPositions(o2);
  39678. for (const e3 of l2) {
  39679. const l3 = r2.feature(e3.index);
  39680. for (const r3 in this.binders) {
  39681. const u2 = this.binders[r3];
  39682. if ((u2 instanceof Pa || u2 instanceof Va || u2 instanceof Fa) && true === u2.expression.isStateDependent) {
  39683. const c2 = n2.paint.get(r3);
  39684. u2.expression = c2.value, u2.updatePaintArray(e3.start, e3.end, l3, t2[o2], i3, s2), a2 = true;
  39685. }
  39686. }
  39687. }
  39688. }
  39689. return a2;
  39690. }
  39691. defines() {
  39692. const t2 = [];
  39693. for (const e2 in this.binders) {
  39694. const r2 = this.binders[e2];
  39695. (r2 instanceof Ca || r2 instanceof Da) && t2.push(...r2.uniformNames.map((t3) => `#define HAS_UNIFORM_${t3}`));
  39696. }
  39697. return t2;
  39698. }
  39699. getBinderAttributes() {
  39700. const t2 = [];
  39701. for (const e2 in this.binders) {
  39702. const r2 = this.binders[e2];
  39703. if (r2 instanceof Pa || r2 instanceof Va || r2 instanceof Fa)
  39704. for (let e3 = 0; e3 < r2.paintVertexAttributes.length; e3++)
  39705. t2.push(r2.paintVertexAttributes[e3].name);
  39706. }
  39707. return t2;
  39708. }
  39709. getBinderUniforms() {
  39710. const t2 = [];
  39711. for (const e2 in this.binders) {
  39712. const r2 = this.binders[e2];
  39713. if (r2 instanceof Ca || r2 instanceof Da || r2 instanceof Va)
  39714. for (const e3 of r2.uniformNames)
  39715. t2.push(e3);
  39716. }
  39717. return t2;
  39718. }
  39719. getPaintVertexBuffers() {
  39720. return this._buffers;
  39721. }
  39722. getUniforms(t2, e2) {
  39723. const r2 = [];
  39724. for (const n2 in this.binders) {
  39725. const i3 = this.binders[n2];
  39726. if (i3 instanceof Ca || i3 instanceof Da || i3 instanceof Va) {
  39727. for (const s2 of i3.uniformNames)
  39728. if (e2[s2]) {
  39729. const a2 = i3.getBinding(t2, e2[s2], s2);
  39730. r2.push({ name: s2, property: n2, binding: a2 });
  39731. }
  39732. }
  39733. }
  39734. return r2;
  39735. }
  39736. setUniforms(t2, e2, r2, n2) {
  39737. for (const { name: t3, property: i3, binding: s2 } of e2)
  39738. this.binders[i3].setUniform(s2, n2, r2.get(i3), t3);
  39739. }
  39740. updatePaintBuffers(t2) {
  39741. this._buffers = [];
  39742. for (const e2 in this.binders) {
  39743. const r2 = this.binders[e2];
  39744. if (t2 && r2 instanceof Fa) {
  39745. const e3 = 2 === t2.fromScale ? r2.zoomInPaintVertexBuffer : r2.zoomOutPaintVertexBuffer;
  39746. e3 && this._buffers.push(e3);
  39747. } else
  39748. (r2 instanceof Pa || r2 instanceof Va) && r2.paintVertexBuffer && this._buffers.push(r2.paintVertexBuffer);
  39749. }
  39750. }
  39751. upload(t2) {
  39752. for (const e2 in this.binders) {
  39753. const r2 = this.binders[e2];
  39754. (r2 instanceof Pa || r2 instanceof Va || r2 instanceof Fa) && r2.upload(t2);
  39755. }
  39756. this.updatePaintBuffers();
  39757. }
  39758. destroy() {
  39759. for (const t2 in this.binders) {
  39760. const e2 = this.binders[t2];
  39761. (e2 instanceof Pa || e2 instanceof Va || e2 instanceof Fa) && e2.destroy();
  39762. }
  39763. }
  39764. }
  39765. class Ra {
  39766. constructor(t2, e2, r2 = () => true) {
  39767. this.programConfigurations = {};
  39768. for (const n2 of t2)
  39769. this.programConfigurations[n2.id] = new La(n2, e2, r2);
  39770. this.needsUpload = false, this._featureMap = new ba(), this._bufferOffset = 0;
  39771. }
  39772. populatePaintArrays(t2, e2, r2, n2, i3, s2, a2) {
  39773. for (const r3 in this.programConfigurations)
  39774. this.programConfigurations[r3].populatePaintArrays(t2, e2, n2, i3, s2, a2);
  39775. void 0 !== e2.id && this._featureMap.add(e2.id, r2, this._bufferOffset, t2), this._bufferOffset = t2, this.needsUpload = true;
  39776. }
  39777. updatePaintArrays(t2, e2, r2, n2, i3) {
  39778. for (const s2 of r2)
  39779. this.needsUpload = this.programConfigurations[s2.id].updatePaintArrays(t2, this._featureMap, e2, s2, n2, i3) || this.needsUpload;
  39780. }
  39781. get(t2) {
  39782. return this.programConfigurations[t2];
  39783. }
  39784. upload(t2) {
  39785. if (this.needsUpload) {
  39786. for (const e2 in this.programConfigurations)
  39787. this.programConfigurations[e2].upload(t2);
  39788. this.needsUpload = false;
  39789. }
  39790. }
  39791. destroy() {
  39792. for (const t2 in this.programConfigurations)
  39793. this.programConfigurations[t2].destroy();
  39794. }
  39795. }
  39796. const Ua = { "text-opacity": ["opacity"], "icon-opacity": ["opacity"], "text-color": ["fill_color"], "icon-color": ["fill_color"], "text-halo-color": ["halo_color"], "icon-halo-color": ["halo_color"], "text-halo-blur": ["halo_blur"], "icon-halo-blur": ["halo_blur"], "text-halo-width": ["halo_width"], "icon-halo-width": ["halo_width"], "line-gap-width": ["gapwidth"], "line-pattern": ["pattern_to", "pattern_from", "pixel_ratio_to", "pixel_ratio_from"], "fill-pattern": ["pattern_to", "pattern_from", "pixel_ratio_to", "pixel_ratio_from"], "fill-extrusion-pattern": ["pattern_to", "pattern_from", "pixel_ratio_to", "pixel_ratio_from"], "line-dasharray": ["dash_to", "dash_from"] };
  39797. function $a(t2, e2) {
  39798. return Ua[t2] || [t2.replace(`${e2}-`, "").replace(/-/g, "_")];
  39799. }
  39800. const ja = { "line-pattern": { source: Es, composite: Es }, "fill-pattern": { source: Es, composite: Es }, "fill-extrusion-pattern": { source: Es, composite: Es }, "line-dasharray": { source: Cs, composite: Cs } }, Oa = { color: { source: Hs, composite: Bs }, number: { source: Ns, composite: Hs } };
  39801. function qa(t2, e2, r2) {
  39802. const n2 = ja[t2];
  39803. return n2 && n2[r2] || Oa[e2][r2];
  39804. }
  39805. ai(Ca, "ConstantBinder"), ai(Da, "CrossFadedConstantBinder"), ai(Pa, "SourceExpressionBinder"), ai(Fa, "CrossFadedCompositeBinder"), ai(Va, "CompositeExpressionBinder"), ai(La, "ProgramConfiguration", { omit: ["_buffers"] }), ai(Ra, "ProgramConfigurationSet");
  39806. const Na = "-transition";
  39807. class Ga extends Ut {
  39808. constructor(t2, e2) {
  39809. if (super(), this.id = t2.id, this.type = t2.type, this._featureFilter = { filter: () => true, needGeometry: false, needFeature: false }, this._filterCompiled = false, "custom" !== t2.type && (this.metadata = (t2 = t2).metadata, this.minzoom = t2.minzoom, this.maxzoom = t2.maxzoom, "background" !== t2.type && "sky" !== t2.type && (this.source = t2.source, this.sourceLayer = t2["source-layer"], this.filter = t2.filter), e2.layout && (this._unevaluatedLayout = new hs(e2.layout)), e2.paint)) {
  39810. this._transitionablePaint = new ls(e2.paint);
  39811. for (const e3 in t2.paint)
  39812. this.setPaintProperty(e3, t2.paint[e3], { validate: false });
  39813. for (const e3 in t2.layout)
  39814. this.setLayoutProperty(e3, t2.layout[e3], { validate: false });
  39815. this._transitioningPaint = this._transitionablePaint.untransitioned(), this.paint = new fs(e2.paint);
  39816. }
  39817. }
  39818. getCrossfadeParameters() {
  39819. return this._crossfadeParameters;
  39820. }
  39821. getLayoutProperty(t2) {
  39822. return "visibility" === t2 ? this.visibility : this._unevaluatedLayout.getValue(t2);
  39823. }
  39824. setLayoutProperty(t2, e2, r2 = {}) {
  39825. null != e2 && this._validate(ti, `layers.${this.id}.layout.${t2}`, t2, e2, r2) || ("visibility" !== t2 ? this._unevaluatedLayout.setValue(t2, e2) : this.visibility = e2);
  39826. }
  39827. getPaintProperty(t2) {
  39828. return M(t2, Na) ? this._transitionablePaint.getTransition(t2.slice(0, -Na.length)) : this._transitionablePaint.getValue(t2);
  39829. }
  39830. setPaintProperty(t2, e2, r2 = {}) {
  39831. if (null != e2 && this._validate(Qn, `layers.${this.id}.paint.${t2}`, t2, e2, r2))
  39832. return false;
  39833. if (M(t2, Na))
  39834. return this._transitionablePaint.setTransition(t2.slice(0, -Na.length), e2 || void 0), false;
  39835. {
  39836. const r3 = this._transitionablePaint._values[t2], n2 = "cross-faded-data-driven" === r3.property.specification["property-type"], i3 = r3.value.isDataDriven(), s2 = r3.value;
  39837. this._transitionablePaint.setValue(t2, e2), this._handleSpecialPaintPropertyUpdate(t2);
  39838. const a2 = this._transitionablePaint._values[t2].value;
  39839. return a2.isDataDriven() || i3 || n2 || this._handleOverridablePaintPropertyUpdate(t2, s2, a2);
  39840. }
  39841. }
  39842. _handleSpecialPaintPropertyUpdate(t2) {
  39843. }
  39844. getProgramIds() {
  39845. return null;
  39846. }
  39847. getProgramConfiguration(t2) {
  39848. return null;
  39849. }
  39850. _handleOverridablePaintPropertyUpdate(t2, e2, r2) {
  39851. return false;
  39852. }
  39853. isHidden(t2) {
  39854. return !!(this.minzoom && t2 < this.minzoom) || !!(this.maxzoom && t2 >= this.maxzoom) || "none" === this.visibility;
  39855. }
  39856. updateTransitions(t2) {
  39857. this._transitioningPaint = this._transitionablePaint.transitioned(t2, this._transitioningPaint);
  39858. }
  39859. hasTransition() {
  39860. return this._transitioningPaint.hasTransition();
  39861. }
  39862. recalculate(t2, e2) {
  39863. t2.getCrossfadeParameters && (this._crossfadeParameters = t2.getCrossfadeParameters()), this._unevaluatedLayout && (this.layout = this._unevaluatedLayout.possiblyEvaluate(t2, void 0, e2)), this.paint = this._transitioningPaint.possiblyEvaluate(t2, void 0, e2);
  39864. }
  39865. serialize() {
  39866. const t2 = { id: this.id, type: this.type, source: this.source, "source-layer": this.sourceLayer, metadata: this.metadata, minzoom: this.minzoom, maxzoom: this.maxzoom, filter: this.filter, layout: this._unevaluatedLayout && this._unevaluatedLayout.serialize(), paint: this._transitionablePaint && this._transitionablePaint.serialize() };
  39867. return this.visibility && (t2.layout = t2.layout || {}, t2.layout.visibility = this.visibility), z(t2, (t3, e2) => !(void 0 === t3 || "layout" === e2 && !Object.keys(t3).length || "paint" === e2 && !Object.keys(t3).length));
  39868. }
  39869. _validate(t2, e2, r2, n2, i3 = {}) {
  39870. return (!i3 || false !== i3.validate) && ri(this, t2.call(Jn, { key: e2, layerType: this.type, objectKey: r2, value: n2, styleSpec: $t, style: { glyphs: true, sprite: true } }));
  39871. }
  39872. is3D() {
  39873. return false;
  39874. }
  39875. isSky() {
  39876. return false;
  39877. }
  39878. isTileClipped() {
  39879. return false;
  39880. }
  39881. hasOffscreenPass() {
  39882. return false;
  39883. }
  39884. resize() {
  39885. }
  39886. isStateDependent() {
  39887. for (const t2 in this.paint._values) {
  39888. const e2 = this.paint.get(t2);
  39889. if (e2 instanceof ps && Yr(e2.property.specification) && ("source" === e2.value.kind || "composite" === e2.value.kind) && e2.value.isStateDependent)
  39890. return true;
  39891. }
  39892. return false;
  39893. }
  39894. compileFilter() {
  39895. this._filterCompiled || (this._featureFilter = Sn(this.filter), this._filterCompiled = true);
  39896. }
  39897. invalidateCompiledFilter() {
  39898. this._filterCompiled = false;
  39899. }
  39900. dynamicFilter() {
  39901. return this._featureFilter.dynamicFilter;
  39902. }
  39903. dynamicFilterNeedsFeature() {
  39904. return this._featureFilter.needFeature;
  39905. }
  39906. }
  39907. const Za = ks([{ name: "a_pos", components: 2, type: "Int16" }], 4), Xa = ks([{ name: "a_pos_3", components: 3, type: "Int16" }, { name: "a_pos_normal_3", components: 3, type: "Int16" }, { name: "a_scale", components: 1, type: "Float32" }]);
  39908. class Ka {
  39909. constructor(t2 = []) {
  39910. this.segments = t2;
  39911. }
  39912. prepareSegment(t2, e2, r2, n2) {
  39913. let i3 = this.segments[this.segments.length - 1];
  39914. return t2 > Ka.MAX_VERTEX_ARRAY_LENGTH && C(`Max vertices per segment is ${Ka.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t2}`), (!i3 || i3.vertexLength + t2 > Ka.MAX_VERTEX_ARRAY_LENGTH || i3.sortKey !== n2) && (i3 = { vertexOffset: e2.length, primitiveOffset: r2.length, vertexLength: 0, primitiveLength: 0 }, void 0 !== n2 && (i3.sortKey = n2), this.segments.push(i3)), i3;
  39915. }
  39916. get() {
  39917. return this.segments;
  39918. }
  39919. destroy() {
  39920. for (const t2 of this.segments)
  39921. for (const e2 in t2.vaos)
  39922. t2.vaos[e2].destroy();
  39923. }
  39924. static simpleSegment(t2, e2, r2, n2) {
  39925. return new Ka([{ vertexOffset: t2, primitiveOffset: e2, vertexLength: r2, primitiveLength: n2, vaos: {}, sortKey: 0 }]);
  39926. }
  39927. }
  39928. Ka.MAX_VERTEX_ARRAY_LENGTH = Math.pow(2, 16) - 1, ai(Ka, "SegmentVector");
  39929. var Ya = 8192;
  39930. class Ha {
  39931. constructor(t2, e2) {
  39932. t2 && (e2 ? this.setSouthWest(t2).setNorthEast(e2) : 4 === t2.length ? this.setSouthWest([t2[0], t2[1]]).setNorthEast([t2[2], t2[3]]) : this.setSouthWest(t2[0]).setNorthEast(t2[1]));
  39933. }
  39934. setNorthEast(t2) {
  39935. return this._ne = t2 instanceof Ja ? new Ja(t2.lng, t2.lat) : Ja.convert(t2), this;
  39936. }
  39937. setSouthWest(t2) {
  39938. return this._sw = t2 instanceof Ja ? new Ja(t2.lng, t2.lat) : Ja.convert(t2), this;
  39939. }
  39940. extend(t2) {
  39941. const e2 = this._sw, r2 = this._ne;
  39942. let n2, i3;
  39943. if (t2 instanceof Ja)
  39944. n2 = t2, i3 = t2;
  39945. else {
  39946. if (!(t2 instanceof Ha))
  39947. return Array.isArray(t2) ? 4 === t2.length || t2.every(Array.isArray) ? this.extend(Ha.convert(t2)) : this.extend(Ja.convert(t2)) : this;
  39948. if (n2 = t2._sw, i3 = t2._ne, !n2 || !i3)
  39949. return this;
  39950. }
  39951. return e2 || r2 ? (e2.lng = Math.min(n2.lng, e2.lng), e2.lat = Math.min(n2.lat, e2.lat), r2.lng = Math.max(i3.lng, r2.lng), r2.lat = Math.max(i3.lat, r2.lat)) : (this._sw = new Ja(n2.lng, n2.lat), this._ne = new Ja(i3.lng, i3.lat)), this;
  39952. }
  39953. getCenter() {
  39954. return new Ja((this._sw.lng + this._ne.lng) / 2, (this._sw.lat + this._ne.lat) / 2);
  39955. }
  39956. getSouthWest() {
  39957. return this._sw;
  39958. }
  39959. getNorthEast() {
  39960. return this._ne;
  39961. }
  39962. getNorthWest() {
  39963. return new Ja(this.getWest(), this.getNorth());
  39964. }
  39965. getSouthEast() {
  39966. return new Ja(this.getEast(), this.getSouth());
  39967. }
  39968. getWest() {
  39969. return this._sw.lng;
  39970. }
  39971. getSouth() {
  39972. return this._sw.lat;
  39973. }
  39974. getEast() {
  39975. return this._ne.lng;
  39976. }
  39977. getNorth() {
  39978. return this._ne.lat;
  39979. }
  39980. toArray() {
  39981. return [this._sw.toArray(), this._ne.toArray()];
  39982. }
  39983. toString() {
  39984. return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`;
  39985. }
  39986. isEmpty() {
  39987. return !(this._sw && this._ne);
  39988. }
  39989. contains(t2) {
  39990. const { lng: e2, lat: r2 } = Ja.convert(t2);
  39991. let n2 = this._sw.lng <= e2 && e2 <= this._ne.lng;
  39992. return this._sw.lng > this._ne.lng && (n2 = this._sw.lng >= e2 && e2 >= this._ne.lng), this._sw.lat <= r2 && r2 <= this._ne.lat && n2;
  39993. }
  39994. static convert(t2) {
  39995. return !t2 || t2 instanceof Ha ? t2 : new Ha(t2);
  39996. }
  39997. }
  39998. const Wa = 63710088e-1;
  39999. class Ja {
  40000. constructor(t2, e2) {
  40001. if (isNaN(t2) || isNaN(e2))
  40002. throw new Error(`Invalid LngLat object: (${t2}, ${e2})`);
  40003. if (this.lng = +t2, this.lat = +e2, this.lat > 90 || this.lat < -90)
  40004. throw new Error("Invalid LngLat latitude value: must be between -90 and 90");
  40005. }
  40006. wrap() {
  40007. return new Ja(g(this.lng, -180, 180), this.lat);
  40008. }
  40009. toArray() {
  40010. return [this.lng, this.lat];
  40011. }
  40012. toString() {
  40013. return `LngLat(${this.lng}, ${this.lat})`;
  40014. }
  40015. distanceTo(t2) {
  40016. const e2 = Math.PI / 180, r2 = this.lat * e2, n2 = t2.lat * e2, i3 = Math.sin(r2) * Math.sin(n2) + Math.cos(r2) * Math.cos(n2) * Math.cos((t2.lng - this.lng) * e2);
  40017. return Wa * Math.acos(Math.min(i3, 1));
  40018. }
  40019. toBounds(t2 = 0) {
  40020. const e2 = 360 * t2 / 40075017, r2 = e2 / Math.cos(Math.PI / 180 * this.lat);
  40021. return new Ha(new Ja(this.lng - r2, this.lat - e2), new Ja(this.lng + r2, this.lat + e2));
  40022. }
  40023. static convert(t2) {
  40024. if (t2 instanceof Ja)
  40025. return t2;
  40026. if (Array.isArray(t2) && (2 === t2.length || 3 === t2.length))
  40027. return new Ja(Number(t2[0]), Number(t2[1]));
  40028. if (!Array.isArray(t2) && "object" == typeof t2 && null !== t2)
  40029. return new Ja(Number("lng" in t2 ? t2.lng : t2.lon), Number(t2.lat));
  40030. throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]");
  40031. }
  40032. }
  40033. const Qa = 2 * Math.PI * Wa;
  40034. function to(t2) {
  40035. return Qa * Math.cos(t2 * Math.PI / 180);
  40036. }
  40037. function eo(t2) {
  40038. return (180 + t2) / 360;
  40039. }
  40040. function ro(t2) {
  40041. return (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + t2 * Math.PI / 360))) / 360;
  40042. }
  40043. function no(t2, e2) {
  40044. return t2 / to(e2);
  40045. }
  40046. function io(t2) {
  40047. return 360 * t2 - 180;
  40048. }
  40049. function so(t2) {
  40050. return 360 / Math.PI * Math.atan(Math.exp((180 - 360 * t2) * Math.PI / 180)) - 90;
  40051. }
  40052. function ao(t2, e2) {
  40053. return t2 * to(so(e2));
  40054. }
  40055. const oo = 85.051129;
  40056. class lo {
  40057. constructor(t2, e2, r2 = 0) {
  40058. this.x = +t2, this.y = +e2, this.z = +r2;
  40059. }
  40060. static fromLngLat(t2, e2 = 0) {
  40061. const r2 = Ja.convert(t2);
  40062. return new lo(eo(r2.lng), ro(r2.lat), no(e2, r2.lat));
  40063. }
  40064. toLngLat() {
  40065. return new Ja(io(this.x), so(this.y));
  40066. }
  40067. toAltitude() {
  40068. return ao(this.z, this.y);
  40069. }
  40070. meterInMercatorCoordinateUnits() {
  40071. return 1 / Qa * (t2 = so(this.y), 1 / Math.cos(t2 * Math.PI / 180));
  40072. var t2;
  40073. }
  40074. }
  40075. function uo(t2, e2, r2, n2, s2, a2, o2, l2, u2) {
  40076. const c2 = (e2 + n2) / 2, h2 = (r2 + s2) / 2, p2 = new i2(c2, h2);
  40077. l2(p2), function(t3, e3, r3, n3, i3, s3) {
  40078. const a3 = r3 - i3, o3 = n3 - s3;
  40079. return Math.abs((n3 - e3) * a3 - (r3 - t3) * o3) / Math.hypot(a3, o3);
  40080. }(p2.x, p2.y, a2.x, a2.y, o2.x, o2.y) >= u2 ? (uo(t2, e2, r2, c2, h2, a2, p2, l2, u2), uo(t2, c2, h2, n2, s2, p2, o2, l2, u2)) : t2.push(o2);
  40081. }
  40082. function co(t2, e2, r2) {
  40083. let n2 = t2[0], i3 = n2.x, s2 = n2.y;
  40084. e2(n2);
  40085. const a2 = [n2];
  40086. for (let o2 = 1; o2 < t2.length; o2++) {
  40087. const l2 = t2[o2], { x: u2, y: c2 } = l2;
  40088. e2(l2), uo(a2, i3, s2, u2, c2, n2, l2, e2, r2), i3 = u2, s2 = c2, n2 = l2;
  40089. }
  40090. return a2;
  40091. }
  40092. const ho = Math.pow(2, 14) - 1, po = -ho - 1;
  40093. function fo(t2, e2) {
  40094. const r2 = Math.round(t2.x * e2), n2 = Math.round(t2.y * e2);
  40095. return t2.x = y(r2, po, ho), t2.y = y(n2, po, ho), (r2 < t2.x || r2 > t2.x + 1 || n2 < t2.y || n2 > t2.y + 1) && C("Geometry exceeds allowed extent, reduce your vector tile buffer size"), t2;
  40096. }
  40097. function yo(t2, e2, r2) {
  40098. const n2 = t2.loadGeometry(), i3 = t2.extent, s2 = Ya / i3;
  40099. if (e2 && r2 && r2.projection.isReprojectedInTileSpace) {
  40100. const s3 = 1 << e2.z, { scale: a2, x: o2, y: l2, projection: u2 } = r2, c2 = (t3) => {
  40101. const r3 = io((e2.x + t3.x / i3) / s3), n3 = so((e2.y + t3.y / i3) / s3), c3 = u2.project(r3, n3);
  40102. t3.x = (c3.x * a2 - o2) * i3, t3.y = (c3.y * a2 - l2) * i3;
  40103. };
  40104. for (let e3 = 0; e3 < n2.length; e3++)
  40105. if (1 !== t2.type)
  40106. n2[e3] = co(n2[e3], c2, 1);
  40107. else {
  40108. const t3 = [];
  40109. for (const r3 of n2[e3])
  40110. r3.x < 0 || r3.x >= i3 || r3.y < 0 || r3.y >= i3 || (c2(r3), t3.push(r3));
  40111. n2[e3] = t3;
  40112. }
  40113. }
  40114. for (const t3 of n2)
  40115. for (const e3 of t3)
  40116. fo(e3, s2);
  40117. return n2;
  40118. }
  40119. function mo(t2, e2) {
  40120. return { type: t2.type, id: t2.id, properties: t2.properties, geometry: e2 ? yo(t2) : [] };
  40121. }
  40122. function go(t2, e2, r2, n2, i3) {
  40123. t2.emplaceBack(2 * e2 + (n2 + 1) / 2, 2 * r2 + (i3 + 1) / 2);
  40124. }
  40125. function xo(t2, e2, r2, n2) {
  40126. const i3 = 16384;
  40127. t2.emplaceBack(e2.x, e2.y, e2.z, r2[0] * i3, r2[1] * i3, r2[2] * i3, n2);
  40128. }
  40129. class vo {
  40130. constructor(t2) {
  40131. this.zoom = t2.zoom, this.overscaling = t2.overscaling, this.layers = t2.layers, this.layerIds = this.layers.map((t3) => t3.id), this.index = t2.index, this.hasPattern = false, this.projection = t2.projection, this.layoutVertexArray = new Is(), this.indexArray = new js(), this.segments = new Ka(), this.programConfigurations = new Ra(t2.layers, t2.zoom), this.stateDependentLayerIds = this.layers.filter((t3) => t3.isStateDependent()).map((t3) => t3.id);
  40132. }
  40133. populate(t2, e2, r2, n2) {
  40134. const i3 = this.layers[0], s2 = [];
  40135. let a2 = null;
  40136. "circle" === i3.type && (a2 = i3.layout.get("circle-sort-key"));
  40137. for (const { feature: e3, id: i4, index: o3, sourceLayerIndex: l2 } of t2) {
  40138. const t3 = this.layers[0]._featureFilter.needGeometry, u2 = mo(e3, t3);
  40139. if (!this.layers[0]._featureFilter.filter(new ss(this.zoom), u2, r2))
  40140. continue;
  40141. const c2 = a2 ? a2.evaluate(u2, {}, r2) : void 0, h2 = { id: i4, properties: e3.properties, type: e3.type, sourceLayerIndex: l2, index: o3, geometry: t3 ? u2.geometry : yo(e3, r2, n2), patterns: {}, sortKey: c2 };
  40142. s2.push(h2);
  40143. }
  40144. a2 && s2.sort((t3, e3) => t3.sortKey - e3.sortKey);
  40145. let o2 = null;
  40146. "globe" === n2.projection.name && (this.globeExtVertexArray = new fa(), o2 = n2.projection);
  40147. for (const n3 of s2) {
  40148. const { geometry: i4, index: s3, sourceLayerIndex: a3 } = n3, l2 = t2[s3].feature;
  40149. this.addFeature(n3, i4, s3, e2.availableImages, r2, o2), e2.featureIndex.insert(l2, i4, s3, a3, this.index);
  40150. }
  40151. }
  40152. update(t2, e2, r2, n2) {
  40153. this.stateDependentLayers.length && this.programConfigurations.updatePaintArrays(t2, e2, this.stateDependentLayers, r2, n2);
  40154. }
  40155. isEmpty() {
  40156. return 0 === this.layoutVertexArray.length;
  40157. }
  40158. uploadPending() {
  40159. return !this.uploaded || this.programConfigurations.needsUpload;
  40160. }
  40161. upload(t2) {
  40162. this.uploaded || (this.layoutVertexBuffer = t2.createVertexBuffer(this.layoutVertexArray, Za.members), this.indexBuffer = t2.createIndexBuffer(this.indexArray), this.globeExtVertexArray && (this.globeExtVertexBuffer = t2.createVertexBuffer(this.globeExtVertexArray, Xa.members))), this.programConfigurations.upload(t2), this.uploaded = true;
  40163. }
  40164. destroy() {
  40165. this.layoutVertexBuffer && (this.layoutVertexBuffer.destroy(), this.indexBuffer.destroy(), this.programConfigurations.destroy(), this.segments.destroy(), this.globeExtVertexBuffer && this.globeExtVertexBuffer.destroy());
  40166. }
  40167. addFeature(t2, e2, r2, n2, i3, s2) {
  40168. for (const r3 of e2)
  40169. for (const e3 of r3) {
  40170. const r4 = e3.x, n3 = e3.y;
  40171. if (r4 < 0 || r4 >= Ya || n3 < 0 || n3 >= Ya)
  40172. continue;
  40173. if (s2) {
  40174. const t3 = s2.projectTilePoint(r4, n3, i3), e4 = s2.upVector(i3, r4, n3), a3 = so((n3 / Ya + i3.y) / (1 << i3.z)), o3 = s2.pixelsPerMeter(a3, 1) / no(1, a3), l2 = this.globeExtVertexArray;
  40175. xo(l2, t3, e4, o3), xo(l2, t3, e4, o3), xo(l2, t3, e4, o3), xo(l2, t3, e4, o3);
  40176. }
  40177. const a2 = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray, t2.sortKey), o2 = a2.vertexLength;
  40178. go(this.layoutVertexArray, r4, n3, -1, -1), go(this.layoutVertexArray, r4, n3, 1, -1), go(this.layoutVertexArray, r4, n3, 1, 1), go(this.layoutVertexArray, r4, n3, -1, 1), this.indexArray.emplaceBack(o2, o2 + 1, o2 + 2), this.indexArray.emplaceBack(o2, o2 + 3, o2 + 2), a2.vertexLength += 4, a2.primitiveLength += 2;
  40179. }
  40180. this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, t2, r2, {}, n2, i3);
  40181. }
  40182. }
  40183. function bo(t2, e2) {
  40184. for (let r2 = 0; r2 < t2.length; r2++)
  40185. if (zo(e2, t2[r2]))
  40186. return true;
  40187. for (let r2 = 0; r2 < e2.length; r2++)
  40188. if (zo(t2, e2[r2]))
  40189. return true;
  40190. return !!ko(t2, e2);
  40191. }
  40192. function _o(t2, e2, r2) {
  40193. return !!zo(t2, e2) || !!Io(e2, t2, r2);
  40194. }
  40195. function wo(t2, e2) {
  40196. if (1 === t2.length)
  40197. return To(e2, t2[0]);
  40198. for (let r2 = 0; r2 < e2.length; r2++) {
  40199. const n2 = e2[r2];
  40200. for (let e3 = 0; e3 < n2.length; e3++)
  40201. if (zo(t2, n2[e3]))
  40202. return true;
  40203. }
  40204. for (let r2 = 0; r2 < t2.length; r2++)
  40205. if (To(e2, t2[r2]))
  40206. return true;
  40207. for (let r2 = 0; r2 < e2.length; r2++)
  40208. if (ko(t2, e2[r2]))
  40209. return true;
  40210. return false;
  40211. }
  40212. function Ao(t2, e2, r2) {
  40213. if (t2.length > 1) {
  40214. if (ko(t2, e2))
  40215. return true;
  40216. for (let n2 = 0; n2 < e2.length; n2++)
  40217. if (Io(e2[n2], t2, r2))
  40218. return true;
  40219. }
  40220. for (let n2 = 0; n2 < t2.length; n2++)
  40221. if (Io(t2[n2], e2, r2))
  40222. return true;
  40223. return false;
  40224. }
  40225. function ko(t2, e2) {
  40226. if (0 === t2.length || 0 === e2.length)
  40227. return false;
  40228. for (let r2 = 0; r2 < t2.length - 1; r2++) {
  40229. const n2 = t2[r2], i3 = t2[r2 + 1];
  40230. for (let t3 = 0; t3 < e2.length - 1; t3++)
  40231. if (So(n2, i3, e2[t3], e2[t3 + 1]))
  40232. return true;
  40233. }
  40234. return false;
  40235. }
  40236. function So(t2, e2, r2, n2) {
  40237. return D(t2, r2, n2) !== D(e2, r2, n2) && D(t2, e2, r2) !== D(t2, e2, n2);
  40238. }
  40239. function Io(t2, e2, r2) {
  40240. const n2 = r2 * r2;
  40241. if (1 === e2.length)
  40242. return t2.distSqr(e2[0]) < n2;
  40243. for (let r3 = 1; r3 < e2.length; r3++)
  40244. if (Mo(t2, e2[r3 - 1], e2[r3]) < n2)
  40245. return true;
  40246. return false;
  40247. }
  40248. function Mo(t2, e2, r2) {
  40249. const n2 = e2.distSqr(r2);
  40250. if (0 === n2)
  40251. return t2.distSqr(e2);
  40252. const i3 = ((t2.x - e2.x) * (r2.x - e2.x) + (t2.y - e2.y) * (r2.y - e2.y)) / n2;
  40253. return t2.distSqr(i3 < 0 ? e2 : i3 > 1 ? r2 : r2.sub(e2)._mult(i3)._add(e2));
  40254. }
  40255. function To(t2, e2) {
  40256. let r2, n2, i3, s2 = false;
  40257. for (let a2 = 0; a2 < t2.length; a2++) {
  40258. r2 = t2[a2];
  40259. for (let t3 = 0, a3 = r2.length - 1; t3 < r2.length; a3 = t3++)
  40260. n2 = r2[t3], i3 = r2[a3], n2.y > e2.y != i3.y > e2.y && e2.x < (i3.x - n2.x) * (e2.y - n2.y) / (i3.y - n2.y) + n2.x && (s2 = !s2);
  40261. }
  40262. return s2;
  40263. }
  40264. function zo(t2, e2) {
  40265. let r2 = false;
  40266. for (let n2 = 0, i3 = t2.length - 1; n2 < t2.length; i3 = n2++) {
  40267. const s2 = t2[n2], a2 = t2[i3];
  40268. s2.y > e2.y != a2.y > e2.y && e2.x < (a2.x - s2.x) * (e2.y - s2.y) / (a2.y - s2.y) + s2.x && (r2 = !r2);
  40269. }
  40270. return r2;
  40271. }
  40272. function Bo(t2, e2, r2, n2, s2) {
  40273. for (const i3 of t2)
  40274. if (e2 <= i3.x && r2 <= i3.y && n2 >= i3.x && s2 >= i3.y)
  40275. return true;
  40276. const a2 = [new i2(e2, r2), new i2(e2, s2), new i2(n2, s2), new i2(n2, r2)];
  40277. if (t2.length > 2) {
  40278. for (const e3 of a2)
  40279. if (zo(t2, e3))
  40280. return true;
  40281. }
  40282. for (let e3 = 0; e3 < t2.length - 1; e3++)
  40283. if (Eo(t2[e3], t2[e3 + 1], a2))
  40284. return true;
  40285. return false;
  40286. }
  40287. function Eo(t2, e2, r2) {
  40288. const n2 = r2[0], i3 = r2[2];
  40289. if (t2.x < n2.x && e2.x < n2.x || t2.x > i3.x && e2.x > i3.x || t2.y < n2.y && e2.y < n2.y || t2.y > i3.y && e2.y > i3.y)
  40290. return false;
  40291. const s2 = D(t2, e2, r2[0]);
  40292. return s2 !== D(t2, e2, r2[1]) || s2 !== D(t2, e2, r2[2]) || s2 !== D(t2, e2, r2[3]);
  40293. }
  40294. function Co(t2, e2, r2) {
  40295. const n2 = e2.paint.get(t2).value;
  40296. return "constant" === n2.kind ? n2.value : r2.programConfigurations.get(e2.id).getMaxValue(t2);
  40297. }
  40298. function Do(t2) {
  40299. return Math.sqrt(t2[0] * t2[0] + t2[1] * t2[1]);
  40300. }
  40301. function Po(t2, e2, r2, n2, s2) {
  40302. if (!e2[0] && !e2[1])
  40303. return t2;
  40304. const a2 = i2.convert(e2)._mult(s2);
  40305. "viewport" === r2 && a2._rotate(-n2);
  40306. const o2 = [];
  40307. for (let e3 = 0; e3 < t2.length; e3++)
  40308. o2.push(t2[e3].sub(a2));
  40309. return o2;
  40310. }
  40311. function Vo(t2, e2, r2, n2) {
  40312. const s2 = i2.convert(t2)._mult(n2);
  40313. return "viewport" === e2 && s2._rotate(-r2), s2;
  40314. }
  40315. ai(vo, "CircleBucket", { omit: ["layers"] });
  40316. const Fo = new vs({ "circle-sort-key": new ys($t.layout_circle["circle-sort-key"]) });
  40317. var Lo = { paint: new vs({ "circle-radius": new ys($t.paint_circle["circle-radius"]), "circle-color": new ys($t.paint_circle["circle-color"]), "circle-blur": new ys($t.paint_circle["circle-blur"]), "circle-opacity": new ys($t.paint_circle["circle-opacity"]), "circle-translate": new ds($t.paint_circle["circle-translate"]), "circle-translate-anchor": new ds($t.paint_circle["circle-translate-anchor"]), "circle-pitch-scale": new ds($t.paint_circle["circle-pitch-scale"]), "circle-pitch-alignment": new ds($t.paint_circle["circle-pitch-alignment"]), "circle-stroke-width": new ys($t.paint_circle["circle-stroke-width"]), "circle-stroke-color": new ys($t.paint_circle["circle-stroke-color"]), "circle-stroke-opacity": new ys($t.paint_circle["circle-stroke-opacity"]) }), layout: Fo }, Ro = 1e-6, Uo = "undefined" != typeof Float32Array ? Float32Array : Array;
  40318. function $o() {
  40319. var t2 = new Uo(9);
  40320. return Uo != Float32Array && (t2[1] = 0, t2[2] = 0, t2[3] = 0, t2[5] = 0, t2[6] = 0, t2[7] = 0), t2[0] = 1, t2[4] = 1, t2[8] = 1, t2;
  40321. }
  40322. function jo(t2) {
  40323. return t2[0] = 1, t2[1] = 0, t2[2] = 0, t2[3] = 0, t2[4] = 0, t2[5] = 1, t2[6] = 0, t2[7] = 0, t2[8] = 0, t2[9] = 0, t2[10] = 1, t2[11] = 0, t2[12] = 0, t2[13] = 0, t2[14] = 0, t2[15] = 1, t2;
  40324. }
  40325. function Oo(t2, e2, r2) {
  40326. var n2 = e2[0], i3 = e2[1], s2 = e2[2], a2 = e2[3], o2 = e2[4], l2 = e2[5], u2 = e2[6], c2 = e2[7], h2 = e2[8], p2 = e2[9], f2 = e2[10], d2 = e2[11], y2 = e2[12], m2 = e2[13], g2 = e2[14], x2 = e2[15], v2 = r2[0], b2 = r2[1], _2 = r2[2], w2 = r2[3];
  40327. return t2[0] = v2 * n2 + b2 * o2 + _2 * h2 + w2 * y2, t2[1] = v2 * i3 + b2 * l2 + _2 * p2 + w2 * m2, t2[2] = v2 * s2 + b2 * u2 + _2 * f2 + w2 * g2, t2[3] = v2 * a2 + b2 * c2 + _2 * d2 + w2 * x2, t2[4] = (v2 = r2[4]) * n2 + (b2 = r2[5]) * o2 + (_2 = r2[6]) * h2 + (w2 = r2[7]) * y2, t2[5] = v2 * i3 + b2 * l2 + _2 * p2 + w2 * m2, t2[6] = v2 * s2 + b2 * u2 + _2 * f2 + w2 * g2, t2[7] = v2 * a2 + b2 * c2 + _2 * d2 + w2 * x2, t2[8] = (v2 = r2[8]) * n2 + (b2 = r2[9]) * o2 + (_2 = r2[10]) * h2 + (w2 = r2[11]) * y2, t2[9] = v2 * i3 + b2 * l2 + _2 * p2 + w2 * m2, t2[10] = v2 * s2 + b2 * u2 + _2 * f2 + w2 * g2, t2[11] = v2 * a2 + b2 * c2 + _2 * d2 + w2 * x2, t2[12] = (v2 = r2[12]) * n2 + (b2 = r2[13]) * o2 + (_2 = r2[14]) * h2 + (w2 = r2[15]) * y2, t2[13] = v2 * i3 + b2 * l2 + _2 * p2 + w2 * m2, t2[14] = v2 * s2 + b2 * u2 + _2 * f2 + w2 * g2, t2[15] = v2 * a2 + b2 * c2 + _2 * d2 + w2 * x2, t2;
  40328. }
  40329. function qo(t2, e2, r2) {
  40330. var n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2 = r2[0], m2 = r2[1], g2 = r2[2];
  40331. return e2 === t2 ? (t2[12] = e2[0] * y2 + e2[4] * m2 + e2[8] * g2 + e2[12], t2[13] = e2[1] * y2 + e2[5] * m2 + e2[9] * g2 + e2[13], t2[14] = e2[2] * y2 + e2[6] * m2 + e2[10] * g2 + e2[14], t2[15] = e2[3] * y2 + e2[7] * m2 + e2[11] * g2 + e2[15]) : (i3 = e2[1], s2 = e2[2], a2 = e2[3], o2 = e2[4], l2 = e2[5], u2 = e2[6], c2 = e2[7], h2 = e2[8], p2 = e2[9], f2 = e2[10], d2 = e2[11], t2[0] = n2 = e2[0], t2[1] = i3, t2[2] = s2, t2[3] = a2, t2[4] = o2, t2[5] = l2, t2[6] = u2, t2[7] = c2, t2[8] = h2, t2[9] = p2, t2[10] = f2, t2[11] = d2, t2[12] = n2 * y2 + o2 * m2 + h2 * g2 + e2[12], t2[13] = i3 * y2 + l2 * m2 + p2 * g2 + e2[13], t2[14] = s2 * y2 + u2 * m2 + f2 * g2 + e2[14], t2[15] = a2 * y2 + c2 * m2 + d2 * g2 + e2[15]), t2;
  40332. }
  40333. function No(t2, e2, r2) {
  40334. var n2 = r2[0], i3 = r2[1], s2 = r2[2];
  40335. return t2[0] = e2[0] * n2, t2[1] = e2[1] * n2, t2[2] = e2[2] * n2, t2[3] = e2[3] * n2, t2[4] = e2[4] * i3, t2[5] = e2[5] * i3, t2[6] = e2[6] * i3, t2[7] = e2[7] * i3, t2[8] = e2[8] * s2, t2[9] = e2[9] * s2, t2[10] = e2[10] * s2, t2[11] = e2[11] * s2, t2[12] = e2[12], t2[13] = e2[13], t2[14] = e2[14], t2[15] = e2[15], t2;
  40336. }
  40337. function Go(t2, e2, r2) {
  40338. var n2 = Math.sin(r2), i3 = Math.cos(r2), s2 = e2[4], a2 = e2[5], o2 = e2[6], l2 = e2[7], u2 = e2[8], c2 = e2[9], h2 = e2[10], p2 = e2[11];
  40339. return e2 !== t2 && (t2[0] = e2[0], t2[1] = e2[1], t2[2] = e2[2], t2[3] = e2[3], t2[12] = e2[12], t2[13] = e2[13], t2[14] = e2[14], t2[15] = e2[15]), t2[4] = s2 * i3 + u2 * n2, t2[5] = a2 * i3 + c2 * n2, t2[6] = o2 * i3 + h2 * n2, t2[7] = l2 * i3 + p2 * n2, t2[8] = u2 * i3 - s2 * n2, t2[9] = c2 * i3 - a2 * n2, t2[10] = h2 * i3 - o2 * n2, t2[11] = p2 * i3 - l2 * n2, t2;
  40340. }
  40341. function Zo(t2, e2, r2) {
  40342. var n2 = Math.sin(r2), i3 = Math.cos(r2), s2 = e2[0], a2 = e2[1], o2 = e2[2], l2 = e2[3], u2 = e2[8], c2 = e2[9], h2 = e2[10], p2 = e2[11];
  40343. return e2 !== t2 && (t2[4] = e2[4], t2[5] = e2[5], t2[6] = e2[6], t2[7] = e2[7], t2[12] = e2[12], t2[13] = e2[13], t2[14] = e2[14], t2[15] = e2[15]), t2[0] = s2 * i3 - u2 * n2, t2[1] = a2 * i3 - c2 * n2, t2[2] = o2 * i3 - h2 * n2, t2[3] = l2 * i3 - p2 * n2, t2[8] = s2 * n2 + u2 * i3, t2[9] = a2 * n2 + c2 * i3, t2[10] = o2 * n2 + h2 * i3, t2[11] = l2 * n2 + p2 * i3, t2;
  40344. }
  40345. Math.hypot || (Math.hypot = function() {
  40346. for (var t2 = 0, e2 = arguments.length; e2--; )
  40347. t2 += arguments[e2] * arguments[e2];
  40348. return Math.sqrt(t2);
  40349. });
  40350. var Xo = Oo;
  40351. function Ko() {
  40352. var t2 = new Uo(3);
  40353. return Uo != Float32Array && (t2[0] = 0, t2[1] = 0, t2[2] = 0), t2;
  40354. }
  40355. function Yo(t2) {
  40356. var e2 = new Uo(3);
  40357. return e2[0] = t2[0], e2[1] = t2[1], e2[2] = t2[2], e2;
  40358. }
  40359. function Ho(t2) {
  40360. return Math.hypot(t2[0], t2[1], t2[2]);
  40361. }
  40362. function Wo(t2, e2, r2) {
  40363. var n2 = new Uo(3);
  40364. return n2[0] = t2, n2[1] = e2, n2[2] = r2, n2;
  40365. }
  40366. function Jo(t2, e2, r2) {
  40367. return t2[0] = e2[0] + r2[0], t2[1] = e2[1] + r2[1], t2[2] = e2[2] + r2[2], t2;
  40368. }
  40369. function Qo(t2, e2, r2) {
  40370. return t2[0] = e2[0] - r2[0], t2[1] = e2[1] - r2[1], t2[2] = e2[2] - r2[2], t2;
  40371. }
  40372. function tl(t2, e2, r2) {
  40373. return t2[0] = e2[0] * r2[0], t2[1] = e2[1] * r2[1], t2[2] = e2[2] * r2[2], t2;
  40374. }
  40375. function el(t2, e2, r2) {
  40376. return t2[0] = Math.min(e2[0], r2[0]), t2[1] = Math.min(e2[1], r2[1]), t2[2] = Math.min(e2[2], r2[2]), t2;
  40377. }
  40378. function rl(t2, e2, r2) {
  40379. return t2[0] = Math.max(e2[0], r2[0]), t2[1] = Math.max(e2[1], r2[1]), t2[2] = Math.max(e2[2], r2[2]), t2;
  40380. }
  40381. function nl(t2, e2, r2) {
  40382. return t2[0] = e2[0] * r2, t2[1] = e2[1] * r2, t2[2] = e2[2] * r2, t2;
  40383. }
  40384. function il(t2, e2, r2, n2) {
  40385. return t2[0] = e2[0] + r2[0] * n2, t2[1] = e2[1] + r2[1] * n2, t2[2] = e2[2] + r2[2] * n2, t2;
  40386. }
  40387. function sl(t2, e2) {
  40388. var r2 = e2[0], n2 = e2[1], i3 = e2[2], s2 = r2 * r2 + n2 * n2 + i3 * i3;
  40389. return s2 > 0 && (s2 = 1 / Math.sqrt(s2)), t2[0] = e2[0] * s2, t2[1] = e2[1] * s2, t2[2] = e2[2] * s2, t2;
  40390. }
  40391. function al(t2, e2) {
  40392. return t2[0] * e2[0] + t2[1] * e2[1] + t2[2] * e2[2];
  40393. }
  40394. function ol(t2, e2, r2) {
  40395. var n2 = e2[0], i3 = e2[1], s2 = e2[2], a2 = r2[0], o2 = r2[1], l2 = r2[2];
  40396. return t2[0] = i3 * l2 - s2 * o2, t2[1] = s2 * a2 - n2 * l2, t2[2] = n2 * o2 - i3 * a2, t2;
  40397. }
  40398. function ll(t2, e2, r2) {
  40399. var n2 = e2[0], i3 = e2[1], s2 = e2[2], a2 = r2[3] * n2 + r2[7] * i3 + r2[11] * s2 + r2[15];
  40400. return t2[0] = (r2[0] * n2 + r2[4] * i3 + r2[8] * s2 + r2[12]) / (a2 = a2 || 1), t2[1] = (r2[1] * n2 + r2[5] * i3 + r2[9] * s2 + r2[13]) / a2, t2[2] = (r2[2] * n2 + r2[6] * i3 + r2[10] * s2 + r2[14]) / a2, t2;
  40401. }
  40402. function ul(t2, e2, r2) {
  40403. var n2 = r2[0], i3 = r2[1], s2 = r2[2], a2 = e2[0], o2 = e2[1], l2 = e2[2], u2 = i3 * l2 - s2 * o2, c2 = s2 * a2 - n2 * l2, h2 = n2 * o2 - i3 * a2, p2 = i3 * h2 - s2 * c2, f2 = s2 * u2 - n2 * h2, d2 = n2 * c2 - i3 * u2, y2 = 2 * r2[3];
  40404. return c2 *= y2, h2 *= y2, f2 *= 2, d2 *= 2, t2[0] = a2 + (u2 *= y2) + (p2 *= 2), t2[1] = o2 + c2 + f2, t2[2] = l2 + h2 + d2, t2;
  40405. }
  40406. var cl, hl = Qo, pl = tl, fl = Ho;
  40407. function dl(t2, e2, r2) {
  40408. var n2 = e2[0], i3 = e2[1], s2 = e2[2], a2 = e2[3];
  40409. return t2[0] = r2[0] * n2 + r2[4] * i3 + r2[8] * s2 + r2[12] * a2, t2[1] = r2[1] * n2 + r2[5] * i3 + r2[9] * s2 + r2[13] * a2, t2[2] = r2[2] * n2 + r2[6] * i3 + r2[10] * s2 + r2[14] * a2, t2[3] = r2[3] * n2 + r2[7] * i3 + r2[11] * s2 + r2[15] * a2, t2;
  40410. }
  40411. function yl() {
  40412. var t2 = new Uo(4);
  40413. return Uo != Float32Array && (t2[0] = 0, t2[1] = 0, t2[2] = 0), t2[3] = 1, t2;
  40414. }
  40415. function ml(t2) {
  40416. return t2[0] = 0, t2[1] = 0, t2[2] = 0, t2[3] = 1, t2;
  40417. }
  40418. function gl(t2, e2, r2) {
  40419. r2 *= 0.5;
  40420. var n2 = e2[0], i3 = e2[1], s2 = e2[2], a2 = e2[3], o2 = Math.sin(r2), l2 = Math.cos(r2);
  40421. return t2[0] = n2 * l2 + a2 * o2, t2[1] = i3 * l2 + s2 * o2, t2[2] = s2 * l2 - i3 * o2, t2[3] = a2 * l2 - n2 * o2, t2;
  40422. }
  40423. Ko(), cl = new Uo(4), Uo != Float32Array && (cl[0] = 0, cl[1] = 0, cl[2] = 0, cl[3] = 0), Ko(), Wo(1, 0, 0), Wo(0, 1, 0), yl(), yl(), $o();
  40424. class xl {
  40425. constructor(t2, e2) {
  40426. this.points = t2, this.planes = e2;
  40427. }
  40428. static fromInvProjectionMatrix(t2, e2, r2, n2) {
  40429. const i3 = Math.pow(2, r2), s2 = [[-1, 1, -1, 1], [1, 1, -1, 1], [1, -1, -1, 1], [-1, -1, -1, 1], [-1, 1, 1, 1], [1, 1, 1, 1], [1, -1, 1, 1], [-1, -1, 1, 1]].map((r3) => {
  40430. const s3 = dl([], r3, t2), a3 = 1 / s3[3] / e2 * i3;
  40431. return function(t3, e3, r4) {
  40432. return t3[0] = e3[0] * r4[0], t3[1] = e3[1] * r4[1], t3[2] = e3[2] * r4[2], t3[3] = e3[3] * r4[3], t3;
  40433. }(s3, s3, [a3, a3, n2 ? 1 / s3[3] : a3, a3]);
  40434. }), a2 = [[0, 1, 2], [6, 5, 4], [0, 3, 7], [2, 1, 5], [3, 2, 6], [0, 4, 5]].map((t3) => {
  40435. const e3 = sl([], ol([], hl([], s2[t3[0]], s2[t3[1]]), hl([], s2[t3[2]], s2[t3[1]]))), r3 = -al(e3, s2[t3[1]]);
  40436. return e3.concat(r3);
  40437. });
  40438. return new xl(s2, a2);
  40439. }
  40440. }
  40441. class vl {
  40442. constructor(t2, e2) {
  40443. this.min = t2, this.max = e2, this.center = nl([], Jo([], this.min, this.max), 0.5);
  40444. }
  40445. quadrant(t2) {
  40446. const e2 = [t2 % 2 == 0, t2 < 2], r2 = Yo(this.min), n2 = Yo(this.max);
  40447. for (let t3 = 0; t3 < e2.length; t3++)
  40448. r2[t3] = e2[t3] ? this.min[t3] : this.center[t3], n2[t3] = e2[t3] ? this.center[t3] : this.max[t3];
  40449. return n2[2] = this.max[2], new vl(r2, n2);
  40450. }
  40451. distanceX(t2) {
  40452. return Math.max(Math.min(this.max[0], t2[0]), this.min[0]) - t2[0];
  40453. }
  40454. distanceY(t2) {
  40455. return Math.max(Math.min(this.max[1], t2[1]), this.min[1]) - t2[1];
  40456. }
  40457. distanceZ(t2) {
  40458. return Math.max(Math.min(this.max[2], t2[2]), this.min[2]) - t2[2];
  40459. }
  40460. getCorners() {
  40461. const t2 = this.min, e2 = this.max;
  40462. return [[t2[0], t2[1], t2[2]], [e2[0], t2[1], t2[2]], [e2[0], e2[1], t2[2]], [t2[0], e2[1], t2[2]], [t2[0], t2[1], e2[2]], [e2[0], t2[1], e2[2]], [e2[0], e2[1], e2[2]], [t2[0], e2[1], e2[2]]];
  40463. }
  40464. intersects(t2) {
  40465. const e2 = this.getCorners();
  40466. let r2 = true;
  40467. for (let n2 = 0; n2 < t2.planes.length; n2++) {
  40468. const i3 = t2.planes[n2];
  40469. let s2 = 0;
  40470. for (let t3 = 0; t3 < e2.length; t3++)
  40471. s2 += al(i3, e2[t3]) + i3[3] >= 0;
  40472. if (0 === s2)
  40473. return 0;
  40474. s2 !== e2.length && (r2 = false);
  40475. }
  40476. if (r2)
  40477. return 2;
  40478. for (let e3 = 0; e3 < 3; e3++) {
  40479. let r3 = Number.MAX_VALUE, n2 = -Number.MAX_VALUE;
  40480. for (let i3 = 0; i3 < t2.points.length; i3++) {
  40481. const s2 = t2.points[i3][e3] - this.min[e3];
  40482. r3 = Math.min(r3, s2), n2 = Math.max(n2, s2);
  40483. }
  40484. if (n2 < 0 || r3 > this.max[e3] - this.min[e3])
  40485. return 0;
  40486. }
  40487. return 1;
  40488. }
  40489. }
  40490. function bl(t2, e2, r2, n2, i3, s2, a2, o2, l2) {
  40491. if (s2 && t2.queryGeometry.isAboveHorizon)
  40492. return false;
  40493. s2 && (l2 *= t2.pixelToTileUnitsFactor);
  40494. for (const u2 of e2)
  40495. for (const e3 of u2) {
  40496. const u3 = e3.add(o2), c2 = i3 && r2.elevation ? r2.elevation.exaggeration() * i3.getElevationAt(u3.x, u3.y, true) : 0, h2 = s2 ? u3 : _l(u3, c2, n2), p2 = s2 ? t2.tilespaceRays.map((t3) => kl(t3, c2)) : t2.queryGeometry.screenGeometry, f2 = dl([], [e3.x, e3.y, c2, 1], n2);
  40497. if (!a2 && s2 ? l2 *= f2[3] / r2.cameraToCenterDistance : a2 && !s2 && (l2 *= r2.cameraToCenterDistance / f2[3]), _o(p2, h2, l2))
  40498. return true;
  40499. }
  40500. return false;
  40501. }
  40502. function _l(t2, e2, r2) {
  40503. const n2 = dl([], [t2.x, t2.y, e2, 1], r2);
  40504. return new i2(n2[0] / n2[3], n2[1] / n2[3]);
  40505. }
  40506. const wl = Wo(0, 0, 0), Al = Wo(0, 0, 1);
  40507. function kl(t2, e2) {
  40508. const r2 = Ko();
  40509. return wl[2] = e2, t2.intersectsPlane(wl, Al, r2), new i2(r2[0], r2[1]);
  40510. }
  40511. class Sl extends vo {
  40512. }
  40513. function Il(t2, { width: e2, height: r2 }, n2, i3) {
  40514. if (i3) {
  40515. if (i3 instanceof Uint8ClampedArray)
  40516. i3 = new Uint8Array(i3.buffer);
  40517. else if (i3.length !== e2 * r2 * n2)
  40518. throw new RangeError("mismatched image size");
  40519. } else
  40520. i3 = new Uint8Array(e2 * r2 * n2);
  40521. return t2.width = e2, t2.height = r2, t2.data = i3, t2;
  40522. }
  40523. function Ml(t2, e2, r2) {
  40524. const { width: n2, height: i3 } = e2;
  40525. n2 === t2.width && i3 === t2.height || (Tl(t2, e2, { x: 0, y: 0 }, { x: 0, y: 0 }, { width: Math.min(t2.width, n2), height: Math.min(t2.height, i3) }, r2), t2.width = n2, t2.height = i3, t2.data = e2.data);
  40526. }
  40527. function Tl(t2, e2, r2, n2, i3, s2) {
  40528. if (0 === i3.width || 0 === i3.height)
  40529. return e2;
  40530. if (i3.width > t2.width || i3.height > t2.height || r2.x > t2.width - i3.width || r2.y > t2.height - i3.height)
  40531. throw new RangeError("out of range source coordinates for image copy");
  40532. if (i3.width > e2.width || i3.height > e2.height || n2.x > e2.width - i3.width || n2.y > e2.height - i3.height)
  40533. throw new RangeError("out of range destination coordinates for image copy");
  40534. const a2 = t2.data, o2 = e2.data;
  40535. for (let l2 = 0; l2 < i3.height; l2++) {
  40536. const u2 = ((r2.y + l2) * t2.width + r2.x) * s2, c2 = ((n2.y + l2) * e2.width + n2.x) * s2;
  40537. for (let t3 = 0; t3 < i3.width * s2; t3++)
  40538. o2[c2 + t3] = a2[u2 + t3];
  40539. }
  40540. return e2;
  40541. }
  40542. ai(Sl, "HeatmapBucket", { omit: ["layers"] });
  40543. class zl {
  40544. constructor(t2, e2) {
  40545. Il(this, t2, 1, e2);
  40546. }
  40547. resize(t2) {
  40548. Ml(this, new zl(t2), 1);
  40549. }
  40550. clone() {
  40551. return new zl({ width: this.width, height: this.height }, new Uint8Array(this.data));
  40552. }
  40553. static copy(t2, e2, r2, n2, i3) {
  40554. Tl(t2, e2, r2, n2, i3, 1);
  40555. }
  40556. }
  40557. class Bl {
  40558. constructor(t2, e2) {
  40559. Il(this, t2, 4, e2);
  40560. }
  40561. resize(t2) {
  40562. Ml(this, new Bl(t2), 4);
  40563. }
  40564. replace(t2, e2) {
  40565. e2 ? this.data.set(t2) : this.data = t2 instanceof Uint8ClampedArray ? new Uint8Array(t2.buffer) : t2;
  40566. }
  40567. clone() {
  40568. return new Bl({ width: this.width, height: this.height }, new Uint8Array(this.data));
  40569. }
  40570. static copy(t2, e2, r2, n2, i3) {
  40571. Tl(t2, e2, r2, n2, i3, 4);
  40572. }
  40573. }
  40574. ai(zl, "AlphaImage"), ai(Bl, "RGBAImage");
  40575. var El = { paint: new vs({ "heatmap-radius": new ys($t.paint_heatmap["heatmap-radius"]), "heatmap-weight": new ys($t.paint_heatmap["heatmap-weight"]), "heatmap-intensity": new ds($t.paint_heatmap["heatmap-intensity"]), "heatmap-color": new xs($t.paint_heatmap["heatmap-color"]), "heatmap-opacity": new ds($t.paint_heatmap["heatmap-opacity"]) }) };
  40576. function Cl(t2) {
  40577. const e2 = {}, r2 = t2.resolution || 256, n2 = t2.clips ? t2.clips.length : 1, i3 = t2.image || new Bl({ width: r2, height: n2 }), s2 = (r3, n3, s3) => {
  40578. e2[t2.evaluationKey] = s3;
  40579. const a2 = t2.expression.evaluate(e2);
  40580. i3.data[r3 + n3 + 0] = Math.floor(255 * a2.r / a2.a), i3.data[r3 + n3 + 1] = Math.floor(255 * a2.g / a2.a), i3.data[r3 + n3 + 2] = Math.floor(255 * a2.b / a2.a), i3.data[r3 + n3 + 3] = Math.floor(255 * a2.a);
  40581. };
  40582. if (t2.clips)
  40583. for (let e3 = 0, i4 = 0; e3 < n2; ++e3, i4 += 4 * r2)
  40584. for (let n3 = 0, a2 = 0; n3 < r2; n3++, a2 += 4) {
  40585. const o2 = n3 / (r2 - 1), { start: l2, end: u2 } = t2.clips[e3];
  40586. s2(i4, a2, l2 * (1 - o2) + u2 * o2);
  40587. }
  40588. else
  40589. for (let t3 = 0, e3 = 0; t3 < r2; t3++, e3 += 4)
  40590. s2(0, e3, t3 / (r2 - 1));
  40591. return i3;
  40592. }
  40593. var Dl = { paint: new vs({ "hillshade-illumination-direction": new ds($t.paint_hillshade["hillshade-illumination-direction"]), "hillshade-illumination-anchor": new ds($t.paint_hillshade["hillshade-illumination-anchor"]), "hillshade-exaggeration": new ds($t.paint_hillshade["hillshade-exaggeration"]), "hillshade-shadow-color": new ds($t.paint_hillshade["hillshade-shadow-color"]), "hillshade-highlight-color": new ds($t.paint_hillshade["hillshade-highlight-color"]), "hillshade-accent-color": new ds($t.paint_hillshade["hillshade-accent-color"]) }) };
  40594. const Pl = ks([{ name: "a_pos", components: 2, type: "Int16" }], 4), { members: Vl } = Pl;
  40595. var Fl = Rl, Ll = Rl;
  40596. function Rl(t2, e2, r2) {
  40597. r2 = r2 || 2;
  40598. var n2, i3, s2, a2, o2, l2, u2, c2 = e2 && e2.length, h2 = c2 ? e2[0] * r2 : t2.length, p2 = Ul(t2, 0, h2, r2, true), f2 = [];
  40599. if (!p2 || p2.next === p2.prev)
  40600. return f2;
  40601. if (c2 && (p2 = function(t3, e3, r3, n3) {
  40602. var i4, s3, a3, o3 = [];
  40603. for (i4 = 0, s3 = e3.length; i4 < s3; i4++)
  40604. (a3 = Ul(t3, e3[i4] * n3, i4 < s3 - 1 ? e3[i4 + 1] * n3 : t3.length, n3, false)) === a3.next && (a3.steiner = true), o3.push(Hl(a3));
  40605. for (o3.sort(Zl), i4 = 0; i4 < o3.length; i4++)
  40606. r3 = $l(r3 = Xl(o3[i4], r3), r3.next);
  40607. return r3;
  40608. }(t2, e2, p2, r2)), t2.length > 80 * r2) {
  40609. n2 = s2 = t2[0], i3 = a2 = t2[1];
  40610. for (var d2 = r2; d2 < h2; d2 += r2)
  40611. (o2 = t2[d2]) < n2 && (n2 = o2), (l2 = t2[d2 + 1]) < i3 && (i3 = l2), o2 > s2 && (s2 = o2), l2 > a2 && (a2 = l2);
  40612. u2 = 0 !== (u2 = Math.max(s2 - n2, a2 - i3)) ? 1 / u2 : 0;
  40613. }
  40614. return jl(p2, f2, r2, n2, i3, u2), f2;
  40615. }
  40616. function Ul(t2, e2, r2, n2, i3) {
  40617. var s2, a2;
  40618. if (i3 === uu(t2, e2, r2, n2) > 0)
  40619. for (s2 = e2; s2 < r2; s2 += n2)
  40620. a2 = au(s2, t2[s2], t2[s2 + 1], a2);
  40621. else
  40622. for (s2 = r2 - n2; s2 >= e2; s2 -= n2)
  40623. a2 = au(s2, t2[s2], t2[s2 + 1], a2);
  40624. return a2 && tu(a2, a2.next) && (ou(a2), a2 = a2.next), a2;
  40625. }
  40626. function $l(t2, e2) {
  40627. if (!t2)
  40628. return t2;
  40629. e2 || (e2 = t2);
  40630. var r2, n2 = t2;
  40631. do {
  40632. if (r2 = false, n2.steiner || !tu(n2, n2.next) && 0 !== Ql(n2.prev, n2, n2.next))
  40633. n2 = n2.next;
  40634. else {
  40635. if (ou(n2), (n2 = e2 = n2.prev) === n2.next)
  40636. break;
  40637. r2 = true;
  40638. }
  40639. } while (r2 || n2 !== e2);
  40640. return e2;
  40641. }
  40642. function jl(t2, e2, r2, n2, i3, s2, a2) {
  40643. if (t2) {
  40644. !a2 && s2 && function(t3, e3, r3, n3) {
  40645. var i4 = t3;
  40646. do {
  40647. null === i4.z && (i4.z = Yl(i4.x, i4.y, e3, r3, n3)), i4.prevZ = i4.prev, i4.nextZ = i4.next, i4 = i4.next;
  40648. } while (i4 !== t3);
  40649. i4.prevZ.nextZ = null, i4.prevZ = null, function(t4) {
  40650. var e4, r4, n4, i5, s3, a3, o3, l3, u3 = 1;
  40651. do {
  40652. for (r4 = t4, t4 = null, s3 = null, a3 = 0; r4; ) {
  40653. for (a3++, n4 = r4, o3 = 0, e4 = 0; e4 < u3 && (o3++, n4 = n4.nextZ); e4++)
  40654. ;
  40655. for (l3 = u3; o3 > 0 || l3 > 0 && n4; )
  40656. 0 !== o3 && (0 === l3 || !n4 || r4.z <= n4.z) ? (i5 = r4, r4 = r4.nextZ, o3--) : (i5 = n4, n4 = n4.nextZ, l3--), s3 ? s3.nextZ = i5 : t4 = i5, i5.prevZ = s3, s3 = i5;
  40657. r4 = n4;
  40658. }
  40659. s3.nextZ = null, u3 *= 2;
  40660. } while (a3 > 1);
  40661. }(i4);
  40662. }(t2, n2, i3, s2);
  40663. for (var o2, l2, u2 = t2; t2.prev !== t2.next; )
  40664. if (o2 = t2.prev, l2 = t2.next, s2 ? ql(t2, n2, i3, s2) : Ol(t2))
  40665. e2.push(o2.i / r2), e2.push(t2.i / r2), e2.push(l2.i / r2), ou(t2), t2 = l2.next, u2 = l2.next;
  40666. else if ((t2 = l2) === u2) {
  40667. a2 ? 1 === a2 ? jl(t2 = Nl($l(t2), e2, r2), e2, r2, n2, i3, s2, 2) : 2 === a2 && Gl(t2, e2, r2, n2, i3, s2) : jl($l(t2), e2, r2, n2, i3, s2, 1);
  40668. break;
  40669. }
  40670. }
  40671. }
  40672. function Ol(t2) {
  40673. var e2 = t2.prev, r2 = t2, n2 = t2.next;
  40674. if (Ql(e2, r2, n2) >= 0)
  40675. return false;
  40676. for (var i3 = t2.next.next; i3 !== t2.prev; ) {
  40677. if (Wl(e2.x, e2.y, r2.x, r2.y, n2.x, n2.y, i3.x, i3.y) && Ql(i3.prev, i3, i3.next) >= 0)
  40678. return false;
  40679. i3 = i3.next;
  40680. }
  40681. return true;
  40682. }
  40683. function ql(t2, e2, r2, n2) {
  40684. var i3 = t2.prev, s2 = t2, a2 = t2.next;
  40685. if (Ql(i3, s2, a2) >= 0)
  40686. return false;
  40687. for (var o2 = i3.x > s2.x ? i3.x > a2.x ? i3.x : a2.x : s2.x > a2.x ? s2.x : a2.x, l2 = i3.y > s2.y ? i3.y > a2.y ? i3.y : a2.y : s2.y > a2.y ? s2.y : a2.y, u2 = Yl(i3.x < s2.x ? i3.x < a2.x ? i3.x : a2.x : s2.x < a2.x ? s2.x : a2.x, i3.y < s2.y ? i3.y < a2.y ? i3.y : a2.y : s2.y < a2.y ? s2.y : a2.y, e2, r2, n2), c2 = Yl(o2, l2, e2, r2, n2), h2 = t2.prevZ, p2 = t2.nextZ; h2 && h2.z >= u2 && p2 && p2.z <= c2; ) {
  40688. if (h2 !== t2.prev && h2 !== t2.next && Wl(i3.x, i3.y, s2.x, s2.y, a2.x, a2.y, h2.x, h2.y) && Ql(h2.prev, h2, h2.next) >= 0)
  40689. return false;
  40690. if (h2 = h2.prevZ, p2 !== t2.prev && p2 !== t2.next && Wl(i3.x, i3.y, s2.x, s2.y, a2.x, a2.y, p2.x, p2.y) && Ql(p2.prev, p2, p2.next) >= 0)
  40691. return false;
  40692. p2 = p2.nextZ;
  40693. }
  40694. for (; h2 && h2.z >= u2; ) {
  40695. if (h2 !== t2.prev && h2 !== t2.next && Wl(i3.x, i3.y, s2.x, s2.y, a2.x, a2.y, h2.x, h2.y) && Ql(h2.prev, h2, h2.next) >= 0)
  40696. return false;
  40697. h2 = h2.prevZ;
  40698. }
  40699. for (; p2 && p2.z <= c2; ) {
  40700. if (p2 !== t2.prev && p2 !== t2.next && Wl(i3.x, i3.y, s2.x, s2.y, a2.x, a2.y, p2.x, p2.y) && Ql(p2.prev, p2, p2.next) >= 0)
  40701. return false;
  40702. p2 = p2.nextZ;
  40703. }
  40704. return true;
  40705. }
  40706. function Nl(t2, e2, r2) {
  40707. var n2 = t2;
  40708. do {
  40709. var i3 = n2.prev, s2 = n2.next.next;
  40710. !tu(i3, s2) && eu(i3, n2, n2.next, s2) && iu(i3, s2) && iu(s2, i3) && (e2.push(i3.i / r2), e2.push(n2.i / r2), e2.push(s2.i / r2), ou(n2), ou(n2.next), n2 = t2 = s2), n2 = n2.next;
  40711. } while (n2 !== t2);
  40712. return $l(n2);
  40713. }
  40714. function Gl(t2, e2, r2, n2, i3, s2) {
  40715. var a2 = t2;
  40716. do {
  40717. for (var o2 = a2.next.next; o2 !== a2.prev; ) {
  40718. if (a2.i !== o2.i && Jl(a2, o2)) {
  40719. var l2 = su(a2, o2);
  40720. return a2 = $l(a2, a2.next), l2 = $l(l2, l2.next), jl(a2, e2, r2, n2, i3, s2), void jl(l2, e2, r2, n2, i3, s2);
  40721. }
  40722. o2 = o2.next;
  40723. }
  40724. a2 = a2.next;
  40725. } while (a2 !== t2);
  40726. }
  40727. function Zl(t2, e2) {
  40728. return t2.x - e2.x;
  40729. }
  40730. function Xl(t2, e2) {
  40731. var r2 = function(t3, e3) {
  40732. var r3, n3 = e3, i4 = t3.x, s2 = t3.y, a2 = -1 / 0;
  40733. do {
  40734. if (s2 <= n3.y && s2 >= n3.next.y && n3.next.y !== n3.y) {
  40735. var o2 = n3.x + (s2 - n3.y) * (n3.next.x - n3.x) / (n3.next.y - n3.y);
  40736. if (o2 <= i4 && o2 > a2) {
  40737. if (a2 = o2, o2 === i4) {
  40738. if (s2 === n3.y)
  40739. return n3;
  40740. if (s2 === n3.next.y)
  40741. return n3.next;
  40742. }
  40743. r3 = n3.x < n3.next.x ? n3 : n3.next;
  40744. }
  40745. }
  40746. n3 = n3.next;
  40747. } while (n3 !== e3);
  40748. if (!r3)
  40749. return null;
  40750. if (i4 === a2)
  40751. return r3;
  40752. var l2, u2 = r3, c2 = r3.x, h2 = r3.y, p2 = 1 / 0;
  40753. n3 = r3;
  40754. do {
  40755. i4 >= n3.x && n3.x >= c2 && i4 !== n3.x && Wl(s2 < h2 ? i4 : a2, s2, c2, h2, s2 < h2 ? a2 : i4, s2, n3.x, n3.y) && (l2 = Math.abs(s2 - n3.y) / (i4 - n3.x), iu(n3, t3) && (l2 < p2 || l2 === p2 && (n3.x > r3.x || n3.x === r3.x && Kl(r3, n3))) && (r3 = n3, p2 = l2)), n3 = n3.next;
  40756. } while (n3 !== u2);
  40757. return r3;
  40758. }(t2, e2);
  40759. if (!r2)
  40760. return e2;
  40761. var n2 = su(r2, t2), i3 = $l(r2, r2.next);
  40762. return $l(n2, n2.next), e2 === r2 ? i3 : e2;
  40763. }
  40764. function Kl(t2, e2) {
  40765. return Ql(t2.prev, t2, e2.prev) < 0 && Ql(e2.next, t2, t2.next) < 0;
  40766. }
  40767. function Yl(t2, e2, r2, n2, i3) {
  40768. return (t2 = 1431655765 & ((t2 = 858993459 & ((t2 = 252645135 & ((t2 = 16711935 & ((t2 = 32767 * (t2 - r2) * i3) | t2 << 8)) | t2 << 4)) | t2 << 2)) | t2 << 1)) | (e2 = 1431655765 & ((e2 = 858993459 & ((e2 = 252645135 & ((e2 = 16711935 & ((e2 = 32767 * (e2 - n2) * i3) | e2 << 8)) | e2 << 4)) | e2 << 2)) | e2 << 1)) << 1;
  40769. }
  40770. function Hl(t2) {
  40771. var e2 = t2, r2 = t2;
  40772. do {
  40773. (e2.x < r2.x || e2.x === r2.x && e2.y < r2.y) && (r2 = e2), e2 = e2.next;
  40774. } while (e2 !== t2);
  40775. return r2;
  40776. }
  40777. function Wl(t2, e2, r2, n2, i3, s2, a2, o2) {
  40778. return (i3 - a2) * (e2 - o2) - (t2 - a2) * (s2 - o2) >= 0 && (t2 - a2) * (n2 - o2) - (r2 - a2) * (e2 - o2) >= 0 && (r2 - a2) * (s2 - o2) - (i3 - a2) * (n2 - o2) >= 0;
  40779. }
  40780. function Jl(t2, e2) {
  40781. return t2.next.i !== e2.i && t2.prev.i !== e2.i && !function(t3, e3) {
  40782. var r2 = t3;
  40783. do {
  40784. if (r2.i !== t3.i && r2.next.i !== t3.i && r2.i !== e3.i && r2.next.i !== e3.i && eu(r2, r2.next, t3, e3))
  40785. return true;
  40786. r2 = r2.next;
  40787. } while (r2 !== t3);
  40788. return false;
  40789. }(t2, e2) && (iu(t2, e2) && iu(e2, t2) && function(t3, e3) {
  40790. var r2 = t3, n2 = false, i3 = (t3.x + e3.x) / 2, s2 = (t3.y + e3.y) / 2;
  40791. do {
  40792. r2.y > s2 != r2.next.y > s2 && r2.next.y !== r2.y && i3 < (r2.next.x - r2.x) * (s2 - r2.y) / (r2.next.y - r2.y) + r2.x && (n2 = !n2), r2 = r2.next;
  40793. } while (r2 !== t3);
  40794. return n2;
  40795. }(t2, e2) && (Ql(t2.prev, t2, e2.prev) || Ql(t2, e2.prev, e2)) || tu(t2, e2) && Ql(t2.prev, t2, t2.next) > 0 && Ql(e2.prev, e2, e2.next) > 0);
  40796. }
  40797. function Ql(t2, e2, r2) {
  40798. return (e2.y - t2.y) * (r2.x - e2.x) - (e2.x - t2.x) * (r2.y - e2.y);
  40799. }
  40800. function tu(t2, e2) {
  40801. return t2.x === e2.x && t2.y === e2.y;
  40802. }
  40803. function eu(t2, e2, r2, n2) {
  40804. var i3 = nu(Ql(t2, e2, r2)), s2 = nu(Ql(t2, e2, n2)), a2 = nu(Ql(r2, n2, t2)), o2 = nu(Ql(r2, n2, e2));
  40805. return i3 !== s2 && a2 !== o2 || !(0 !== i3 || !ru(t2, r2, e2)) || !(0 !== s2 || !ru(t2, n2, e2)) || !(0 !== a2 || !ru(r2, t2, n2)) || !(0 !== o2 || !ru(r2, e2, n2));
  40806. }
  40807. function ru(t2, e2, r2) {
  40808. return e2.x <= Math.max(t2.x, r2.x) && e2.x >= Math.min(t2.x, r2.x) && e2.y <= Math.max(t2.y, r2.y) && e2.y >= Math.min(t2.y, r2.y);
  40809. }
  40810. function nu(t2) {
  40811. return t2 > 0 ? 1 : t2 < 0 ? -1 : 0;
  40812. }
  40813. function iu(t2, e2) {
  40814. return Ql(t2.prev, t2, t2.next) < 0 ? Ql(t2, e2, t2.next) >= 0 && Ql(t2, t2.prev, e2) >= 0 : Ql(t2, e2, t2.prev) < 0 || Ql(t2, t2.next, e2) < 0;
  40815. }
  40816. function su(t2, e2) {
  40817. var r2 = new lu(t2.i, t2.x, t2.y), n2 = new lu(e2.i, e2.x, e2.y), i3 = t2.next, s2 = e2.prev;
  40818. return t2.next = e2, e2.prev = t2, r2.next = i3, i3.prev = r2, n2.next = r2, r2.prev = n2, s2.next = n2, n2.prev = s2, n2;
  40819. }
  40820. function au(t2, e2, r2, n2) {
  40821. var i3 = new lu(t2, e2, r2);
  40822. return n2 ? (i3.next = n2.next, i3.prev = n2, n2.next.prev = i3, n2.next = i3) : (i3.prev = i3, i3.next = i3), i3;
  40823. }
  40824. function ou(t2) {
  40825. t2.next.prev = t2.prev, t2.prev.next = t2.next, t2.prevZ && (t2.prevZ.nextZ = t2.nextZ), t2.nextZ && (t2.nextZ.prevZ = t2.prevZ);
  40826. }
  40827. function lu(t2, e2, r2) {
  40828. this.i = t2, this.x = e2, this.y = r2, this.prev = null, this.next = null, this.z = null, this.prevZ = null, this.nextZ = null, this.steiner = false;
  40829. }
  40830. function uu(t2, e2, r2, n2) {
  40831. for (var i3 = 0, s2 = e2, a2 = r2 - n2; s2 < r2; s2 += n2)
  40832. i3 += (t2[a2] - t2[s2]) * (t2[s2 + 1] + t2[a2 + 1]), a2 = s2;
  40833. return i3;
  40834. }
  40835. function cu(t2, e2, r2, n2, i3) {
  40836. hu(t2, e2, r2 || 0, n2 || t2.length - 1, i3 || fu);
  40837. }
  40838. function hu(t2, e2, r2, n2, i3) {
  40839. for (; n2 > r2; ) {
  40840. if (n2 - r2 > 600) {
  40841. var s2 = n2 - r2 + 1, a2 = e2 - r2 + 1, o2 = Math.log(s2), l2 = 0.5 * Math.exp(2 * o2 / 3), u2 = 0.5 * Math.sqrt(o2 * l2 * (s2 - l2) / s2) * (a2 - s2 / 2 < 0 ? -1 : 1);
  40842. hu(t2, e2, Math.max(r2, Math.floor(e2 - a2 * l2 / s2 + u2)), Math.min(n2, Math.floor(e2 + (s2 - a2) * l2 / s2 + u2)), i3);
  40843. }
  40844. var c2 = t2[e2], h2 = r2, p2 = n2;
  40845. for (pu(t2, r2, e2), i3(t2[n2], c2) > 0 && pu(t2, r2, n2); h2 < p2; ) {
  40846. for (pu(t2, h2, p2), h2++, p2--; i3(t2[h2], c2) < 0; )
  40847. h2++;
  40848. for (; i3(t2[p2], c2) > 0; )
  40849. p2--;
  40850. }
  40851. 0 === i3(t2[r2], c2) ? pu(t2, r2, p2) : pu(t2, ++p2, n2), p2 <= e2 && (r2 = p2 + 1), e2 <= p2 && (n2 = p2 - 1);
  40852. }
  40853. }
  40854. function pu(t2, e2, r2) {
  40855. var n2 = t2[e2];
  40856. t2[e2] = t2[r2], t2[r2] = n2;
  40857. }
  40858. function fu(t2, e2) {
  40859. return t2 < e2 ? -1 : t2 > e2 ? 1 : 0;
  40860. }
  40861. function du(t2, e2) {
  40862. const r2 = t2.length;
  40863. if (r2 <= 1)
  40864. return [t2];
  40865. const n2 = [];
  40866. let i3, s2;
  40867. for (let e3 = 0; e3 < r2; e3++) {
  40868. const r3 = P(t2[e3]);
  40869. 0 !== r3 && (t2[e3].area = Math.abs(r3), void 0 === s2 && (s2 = r3 < 0), s2 === r3 < 0 ? (i3 && n2.push(i3), i3 = [t2[e3]]) : i3.push(t2[e3]));
  40870. }
  40871. if (i3 && n2.push(i3), e2 > 1)
  40872. for (let t3 = 0; t3 < n2.length; t3++)
  40873. n2[t3].length <= e2 || (cu(n2[t3], e2, 1, n2[t3].length - 1, yu), n2[t3] = n2[t3].slice(0, e2));
  40874. return n2;
  40875. }
  40876. function yu(t2, e2) {
  40877. return e2.area - t2.area;
  40878. }
  40879. function mu(t2, e2, r2) {
  40880. const n2 = r2.patternDependencies;
  40881. let i3 = false;
  40882. for (const r3 of e2) {
  40883. const e3 = r3.paint.get(`${t2}-pattern`);
  40884. e3.isConstant() || (i3 = true);
  40885. const s2 = e3.constantOr(null);
  40886. s2 && (i3 = true, n2[s2.to] = true, n2[s2.from] = true);
  40887. }
  40888. return i3;
  40889. }
  40890. function gu(t2, e2, r2, n2, i3) {
  40891. const s2 = i3.patternDependencies;
  40892. for (const a2 of e2) {
  40893. const e3 = a2.paint.get(`${t2}-pattern`).value;
  40894. if ("constant" !== e3.kind) {
  40895. let t3 = e3.evaluate({ zoom: n2 - 1 }, r2, {}, i3.availableImages), o2 = e3.evaluate({ zoom: n2 }, r2, {}, i3.availableImages), l2 = e3.evaluate({ zoom: n2 + 1 }, r2, {}, i3.availableImages);
  40896. t3 = t3 && t3.name ? t3.name : t3, o2 = o2 && o2.name ? o2.name : o2, l2 = l2 && l2.name ? l2.name : l2, s2[t3] = true, s2[o2] = true, s2[l2] = true, r2.patterns[a2.id] = { min: t3, mid: o2, max: l2 };
  40897. }
  40898. }
  40899. return r2;
  40900. }
  40901. Rl.deviation = function(t2, e2, r2, n2) {
  40902. var i3 = e2 && e2.length, s2 = Math.abs(uu(t2, 0, i3 ? e2[0] * r2 : t2.length, r2));
  40903. if (i3)
  40904. for (var a2 = 0, o2 = e2.length; a2 < o2; a2++)
  40905. s2 -= Math.abs(uu(t2, e2[a2] * r2, a2 < o2 - 1 ? e2[a2 + 1] * r2 : t2.length, r2));
  40906. var l2 = 0;
  40907. for (a2 = 0; a2 < n2.length; a2 += 3) {
  40908. var u2 = n2[a2] * r2, c2 = n2[a2 + 1] * r2, h2 = n2[a2 + 2] * r2;
  40909. l2 += Math.abs((t2[u2] - t2[h2]) * (t2[c2 + 1] - t2[u2 + 1]) - (t2[u2] - t2[c2]) * (t2[h2 + 1] - t2[u2 + 1]));
  40910. }
  40911. return 0 === s2 && 0 === l2 ? 0 : Math.abs((l2 - s2) / s2);
  40912. }, Rl.flatten = function(t2) {
  40913. for (var e2 = t2[0][0].length, r2 = { vertices: [], holes: [], dimensions: e2 }, n2 = 0, i3 = 0; i3 < t2.length; i3++) {
  40914. for (var s2 = 0; s2 < t2[i3].length; s2++)
  40915. for (var a2 = 0; a2 < e2; a2++)
  40916. r2.vertices.push(t2[i3][s2][a2]);
  40917. i3 > 0 && r2.holes.push(n2 += t2[i3 - 1].length);
  40918. }
  40919. return r2;
  40920. }, Fl.default = Ll;
  40921. class xu {
  40922. constructor(t2) {
  40923. this.zoom = t2.zoom, this.overscaling = t2.overscaling, this.layers = t2.layers, this.layerIds = this.layers.map((t3) => t3.id), this.index = t2.index, this.hasPattern = false, this.patternFeatures = [], this.layoutVertexArray = new Is(), this.indexArray = new js(), this.indexArray2 = new Ks(), this.programConfigurations = new Ra(t2.layers, t2.zoom), this.segments = new Ka(), this.segments2 = new Ka(), this.stateDependentLayerIds = this.layers.filter((t3) => t3.isStateDependent()).map((t3) => t3.id), this.projection = t2.projection;
  40924. }
  40925. populate(t2, e2, r2, n2) {
  40926. this.hasPattern = mu("fill", this.layers, e2);
  40927. const i3 = this.layers[0].layout.get("fill-sort-key"), s2 = [];
  40928. for (const { feature: a2, id: o2, index: l2, sourceLayerIndex: u2 } of t2) {
  40929. const t3 = this.layers[0]._featureFilter.needGeometry, c2 = mo(a2, t3);
  40930. if (!this.layers[0]._featureFilter.filter(new ss(this.zoom), c2, r2))
  40931. continue;
  40932. const h2 = i3 ? i3.evaluate(c2, {}, r2, e2.availableImages) : void 0, p2 = { id: o2, properties: a2.properties, type: a2.type, sourceLayerIndex: u2, index: l2, geometry: t3 ? c2.geometry : yo(a2, r2, n2), patterns: {}, sortKey: h2 };
  40933. s2.push(p2);
  40934. }
  40935. i3 && s2.sort((t3, e3) => t3.sortKey - e3.sortKey);
  40936. for (const n3 of s2) {
  40937. const { geometry: i4, index: s3, sourceLayerIndex: a2 } = n3;
  40938. if (this.hasPattern) {
  40939. const t3 = gu("fill", this.layers, n3, this.zoom, e2);
  40940. this.patternFeatures.push(t3);
  40941. } else
  40942. this.addFeature(n3, i4, s3, r2, {}, e2.availableImages);
  40943. e2.featureIndex.insert(t2[s3].feature, i4, s3, a2, this.index);
  40944. }
  40945. }
  40946. update(t2, e2, r2, n2) {
  40947. this.stateDependentLayers.length && this.programConfigurations.updatePaintArrays(t2, e2, this.stateDependentLayers, r2, n2);
  40948. }
  40949. addFeatures(t2, e2, r2, n2, i3) {
  40950. for (const t3 of this.patternFeatures)
  40951. this.addFeature(t3, t3.geometry, t3.index, e2, r2, n2);
  40952. }
  40953. isEmpty() {
  40954. return 0 === this.layoutVertexArray.length;
  40955. }
  40956. uploadPending() {
  40957. return !this.uploaded || this.programConfigurations.needsUpload;
  40958. }
  40959. upload(t2) {
  40960. this.uploaded || (this.layoutVertexBuffer = t2.createVertexBuffer(this.layoutVertexArray, Vl), this.indexBuffer = t2.createIndexBuffer(this.indexArray), this.indexBuffer2 = t2.createIndexBuffer(this.indexArray2)), this.programConfigurations.upload(t2), this.uploaded = true;
  40961. }
  40962. destroy() {
  40963. this.layoutVertexBuffer && (this.layoutVertexBuffer.destroy(), this.indexBuffer.destroy(), this.indexBuffer2.destroy(), this.programConfigurations.destroy(), this.segments.destroy(), this.segments2.destroy());
  40964. }
  40965. addFeature(t2, e2, r2, n2, i3, s2 = []) {
  40966. for (const t3 of du(e2, 500)) {
  40967. let e3 = 0;
  40968. for (const r4 of t3)
  40969. e3 += r4.length;
  40970. const r3 = this.segments.prepareSegment(e3, this.layoutVertexArray, this.indexArray), n3 = r3.vertexLength, i4 = [], s3 = [];
  40971. for (const e4 of t3) {
  40972. if (0 === e4.length)
  40973. continue;
  40974. e4 !== t3[0] && s3.push(i4.length / 2);
  40975. const r4 = this.segments2.prepareSegment(e4.length, this.layoutVertexArray, this.indexArray2), n4 = r4.vertexLength;
  40976. this.layoutVertexArray.emplaceBack(e4[0].x, e4[0].y), this.indexArray2.emplaceBack(n4 + e4.length - 1, n4), i4.push(e4[0].x), i4.push(e4[0].y);
  40977. for (let t4 = 1; t4 < e4.length; t4++)
  40978. this.layoutVertexArray.emplaceBack(e4[t4].x, e4[t4].y), this.indexArray2.emplaceBack(n4 + t4 - 1, n4 + t4), i4.push(e4[t4].x), i4.push(e4[t4].y);
  40979. r4.vertexLength += e4.length, r4.primitiveLength += e4.length;
  40980. }
  40981. const a2 = Fl(i4, s3);
  40982. for (let t4 = 0; t4 < a2.length; t4 += 3)
  40983. this.indexArray.emplaceBack(n3 + a2[t4], n3 + a2[t4 + 1], n3 + a2[t4 + 2]);
  40984. r3.vertexLength += e3, r3.primitiveLength += a2.length / 3;
  40985. }
  40986. this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, t2, r2, i3, s2, n2);
  40987. }
  40988. }
  40989. ai(xu, "FillBucket", { omit: ["layers", "patternFeatures"] });
  40990. const vu = new vs({ "fill-sort-key": new ys($t.layout_fill["fill-sort-key"]) });
  40991. var bu = { paint: new vs({ "fill-antialias": new ds($t.paint_fill["fill-antialias"]), "fill-opacity": new ys($t.paint_fill["fill-opacity"]), "fill-color": new ys($t.paint_fill["fill-color"]), "fill-outline-color": new ys($t.paint_fill["fill-outline-color"]), "fill-translate": new ds($t.paint_fill["fill-translate"]), "fill-translate-anchor": new ds($t.paint_fill["fill-translate-anchor"]), "fill-pattern": new ms($t.paint_fill["fill-pattern"]) }), layout: vu };
  40992. const _u = ks([{ name: "a_pos_normal_ed", components: 4, type: "Int16" }]), wu = ks([{ name: "a_centroid_pos", components: 2, type: "Uint16" }]), Au = ks([{ name: "a_pos_3", components: 3, type: "Int16" }, { name: "a_pos_normal_3", components: 3, type: "Int16" }]), { members: ku } = _u;
  40993. var Su = Iu;
  40994. function Iu(t2, e2, r2, n2, i3) {
  40995. this.properties = {}, this.extent = r2, this.type = 0, this._pbf = t2, this._geometry = -1, this._keys = n2, this._values = i3, t2.readFields(Mu, this, e2);
  40996. }
  40997. function Mu(t2, e2, r2) {
  40998. 1 == t2 ? e2.id = r2.readVarint() : 2 == t2 ? function(t3, e3) {
  40999. for (var r3 = t3.readVarint() + t3.pos; t3.pos < r3; ) {
  41000. var n2 = e3._keys[t3.readVarint()], i3 = e3._values[t3.readVarint()];
  41001. e3.properties[n2] = i3;
  41002. }
  41003. }(r2, e2) : 3 == t2 ? e2.type = r2.readVarint() : 4 == t2 && (e2._geometry = r2.pos);
  41004. }
  41005. function Tu(t2) {
  41006. for (var e2, r2, n2 = 0, i3 = 0, s2 = t2.length, a2 = s2 - 1; i3 < s2; a2 = i3++)
  41007. n2 += ((r2 = t2[a2]).x - (e2 = t2[i3]).x) * (e2.y + r2.y);
  41008. return n2;
  41009. }
  41010. Iu.types = ["Unknown", "Point", "LineString", "Polygon"], Iu.prototype.loadGeometry = function() {
  41011. var t2 = this._pbf;
  41012. t2.pos = this._geometry;
  41013. for (var e2, r2 = t2.readVarint() + t2.pos, n2 = 1, s2 = 0, a2 = 0, o2 = 0, l2 = []; t2.pos < r2; ) {
  41014. if (s2 <= 0) {
  41015. var u2 = t2.readVarint();
  41016. n2 = 7 & u2, s2 = u2 >> 3;
  41017. }
  41018. if (s2--, 1 === n2 || 2 === n2)
  41019. a2 += t2.readSVarint(), o2 += t2.readSVarint(), 1 === n2 && (e2 && l2.push(e2), e2 = []), e2.push(new i2(a2, o2));
  41020. else {
  41021. if (7 !== n2)
  41022. throw new Error("unknown command " + n2);
  41023. e2 && e2.push(e2[0].clone());
  41024. }
  41025. }
  41026. return e2 && l2.push(e2), l2;
  41027. }, Iu.prototype.bbox = function() {
  41028. var t2 = this._pbf;
  41029. t2.pos = this._geometry;
  41030. for (var e2 = t2.readVarint() + t2.pos, r2 = 1, n2 = 0, i3 = 0, s2 = 0, a2 = 1 / 0, o2 = -1 / 0, l2 = 1 / 0, u2 = -1 / 0; t2.pos < e2; ) {
  41031. if (n2 <= 0) {
  41032. var c2 = t2.readVarint();
  41033. r2 = 7 & c2, n2 = c2 >> 3;
  41034. }
  41035. if (n2--, 1 === r2 || 2 === r2)
  41036. (i3 += t2.readSVarint()) < a2 && (a2 = i3), i3 > o2 && (o2 = i3), (s2 += t2.readSVarint()) < l2 && (l2 = s2), s2 > u2 && (u2 = s2);
  41037. else if (7 !== r2)
  41038. throw new Error("unknown command " + r2);
  41039. }
  41040. return [a2, l2, o2, u2];
  41041. }, Iu.prototype.toGeoJSON = function(t2, e2, r2) {
  41042. var n2, i3, s2 = this.extent * Math.pow(2, r2), a2 = this.extent * t2, o2 = this.extent * e2, l2 = this.loadGeometry(), u2 = Iu.types[this.type];
  41043. function c2(t3) {
  41044. for (var e3 = 0; e3 < t3.length; e3++) {
  41045. var r3 = t3[e3];
  41046. t3[e3] = [360 * (r3.x + a2) / s2 - 180, 360 / Math.PI * Math.atan(Math.exp((180 - 360 * (r3.y + o2) / s2) * Math.PI / 180)) - 90];
  41047. }
  41048. }
  41049. switch (this.type) {
  41050. case 1:
  41051. var h2 = [];
  41052. for (n2 = 0; n2 < l2.length; n2++)
  41053. h2[n2] = l2[n2][0];
  41054. c2(l2 = h2);
  41055. break;
  41056. case 2:
  41057. for (n2 = 0; n2 < l2.length; n2++)
  41058. c2(l2[n2]);
  41059. break;
  41060. case 3:
  41061. for (l2 = function(t3) {
  41062. var e3 = t3.length;
  41063. if (e3 <= 1)
  41064. return [t3];
  41065. for (var r3, n3, i4 = [], s3 = 0; s3 < e3; s3++) {
  41066. var a3 = Tu(t3[s3]);
  41067. 0 !== a3 && (void 0 === n3 && (n3 = a3 < 0), n3 === a3 < 0 ? (r3 && i4.push(r3), r3 = [t3[s3]]) : r3.push(t3[s3]));
  41068. }
  41069. return r3 && i4.push(r3), i4;
  41070. }(l2), n2 = 0; n2 < l2.length; n2++)
  41071. for (i3 = 0; i3 < l2[n2].length; i3++)
  41072. c2(l2[n2][i3]);
  41073. }
  41074. 1 === l2.length ? l2 = l2[0] : u2 = "Multi" + u2;
  41075. var p2 = { type: "Feature", geometry: { type: u2, coordinates: l2 }, properties: this.properties };
  41076. return "id" in this && (p2.id = this.id), p2;
  41077. };
  41078. var zu = Bu;
  41079. function Bu(t2, e2) {
  41080. this.version = 1, this.name = null, this.extent = 4096, this.length = 0, this._pbf = t2, this._keys = [], this._values = [], this._features = [], t2.readFields(Eu, this, e2), this.length = this._features.length;
  41081. }
  41082. function Eu(t2, e2, r2) {
  41083. 15 === t2 ? e2.version = r2.readVarint() : 1 === t2 ? e2.name = r2.readString() : 5 === t2 ? e2.extent = r2.readVarint() : 2 === t2 ? e2._features.push(r2.pos) : 3 === t2 ? e2._keys.push(r2.readString()) : 4 === t2 && e2._values.push(function(t3) {
  41084. for (var e3 = null, r3 = t3.readVarint() + t3.pos; t3.pos < r3; ) {
  41085. var n2 = t3.readVarint() >> 3;
  41086. e3 = 1 === n2 ? t3.readString() : 2 === n2 ? t3.readFloat() : 3 === n2 ? t3.readDouble() : 4 === n2 ? t3.readVarint64() : 5 === n2 ? t3.readVarint() : 6 === n2 ? t3.readSVarint() : 7 === n2 ? t3.readBoolean() : null;
  41087. }
  41088. return e3;
  41089. }(r2));
  41090. }
  41091. function Cu(t2, e2, r2) {
  41092. if (3 === t2) {
  41093. var n2 = new zu(r2, r2.readVarint() + r2.pos);
  41094. n2.length && (e2[n2.name] = n2);
  41095. }
  41096. }
  41097. Bu.prototype.feature = function(t2) {
  41098. if (t2 < 0 || t2 >= this._features.length)
  41099. throw new Error("feature index out of bounds");
  41100. this._pbf.pos = this._features[t2];
  41101. var e2 = this._pbf.readVarint() + this._pbf.pos;
  41102. return new Su(this._pbf, e2, this.extent, this._keys, this._values);
  41103. };
  41104. var Du = { VectorTile: function(t2, e2) {
  41105. this.layers = t2.readFields(Cu, {}, e2);
  41106. }, VectorTileFeature: Su, VectorTileLayer: zu };
  41107. function Pu(t2, e2, r2, n2) {
  41108. const s2 = [], a2 = 0 === n2 ? (t3, e3, r3, n3, s3, a3) => {
  41109. t3.push(new i2(a3, r3 + (a3 - e3) / (n3 - e3) * (s3 - r3)));
  41110. } : (t3, e3, r3, n3, s3, a3) => {
  41111. t3.push(new i2(e3 + (a3 - r3) / (s3 - r3) * (n3 - e3), a3));
  41112. };
  41113. for (const i3 of t2) {
  41114. const t3 = [];
  41115. for (const s3 of i3) {
  41116. if (s3.length <= 2)
  41117. continue;
  41118. const i4 = [];
  41119. for (let t4 = 0; t4 < s3.length - 1; t4++) {
  41120. const o3 = s3[t4].x, l3 = s3[t4].y, u2 = s3[t4 + 1].x, c2 = s3[t4 + 1].y, h2 = 0 === n2 ? o3 : l3, p2 = 0 === n2 ? u2 : c2;
  41121. h2 < e2 ? p2 > e2 && a2(i4, o3, l3, u2, c2, e2) : h2 > r2 ? p2 < r2 && a2(i4, o3, l3, u2, c2, r2) : i4.push(s3[t4]), p2 < e2 && h2 >= e2 && a2(i4, o3, l3, u2, c2, e2), p2 > r2 && h2 <= r2 && a2(i4, o3, l3, u2, c2, r2);
  41122. }
  41123. let o2 = s3[s3.length - 1];
  41124. const l2 = 0 === n2 ? o2.x : o2.y;
  41125. l2 >= e2 && l2 <= r2 && i4.push(o2), i4.length && (o2 = i4[i4.length - 1], i4[0].x === o2.x && i4[0].y === o2.y || i4.push(i4[0]), t3.push(i4));
  41126. }
  41127. t3.length && s2.push(t3);
  41128. }
  41129. return s2;
  41130. }
  41131. const Vu = Du.VectorTileFeature.types, Fu = Math.pow(2, 13);
  41132. function Lu(t2, e2, r2, n2, i3, s2, a2, o2) {
  41133. t2.emplaceBack((e2 << 1) + a2, (r2 << 1) + s2, (Math.floor(n2 * Fu) << 1) + i3, Math.round(o2));
  41134. }
  41135. function Ru(t2, e2, r2) {
  41136. const n2 = 16384;
  41137. t2.emplaceBack(e2.x, e2.y, e2.z, r2[0] * n2, r2[1] * n2, r2[2] * n2);
  41138. }
  41139. class Uu {
  41140. constructor() {
  41141. this.acc = new i2(0, 0), this.polyCount = [];
  41142. }
  41143. startRing(t2) {
  41144. this.currentPolyCount = { edges: 0, top: 0 }, this.polyCount.push(this.currentPolyCount), this.min || (this.min = new i2(t2.x, t2.y), this.max = new i2(t2.x, t2.y));
  41145. }
  41146. append(t2, e2) {
  41147. this.currentPolyCount.edges++, this.acc._add(t2);
  41148. const r2 = this.min, n2 = this.max;
  41149. t2.x < r2.x ? r2.x = t2.x : t2.x > n2.x && (n2.x = t2.x), t2.y < r2.y ? r2.y = t2.y : t2.y > n2.y && (n2.y = t2.y), ((0 === t2.x || t2.x === Ya) && t2.x === e2.x) != ((0 === t2.y || t2.y === Ya) && t2.y === e2.y) && this.processBorderOverlap(t2, e2), e2.x < 0 != t2.x < 0 && this.addBorderIntersection(0, rr(e2.y, t2.y, (0 - e2.x) / (t2.x - e2.x))), e2.x > Ya != t2.x > Ya && this.addBorderIntersection(1, rr(e2.y, t2.y, (Ya - e2.x) / (t2.x - e2.x))), e2.y < 0 != t2.y < 0 && this.addBorderIntersection(2, rr(e2.x, t2.x, (0 - e2.y) / (t2.y - e2.y))), e2.y > Ya != t2.y > Ya && this.addBorderIntersection(3, rr(e2.x, t2.x, (Ya - e2.y) / (t2.y - e2.y)));
  41150. }
  41151. addBorderIntersection(t2, e2) {
  41152. this.borders || (this.borders = [[Number.MAX_VALUE, -Number.MAX_VALUE], [Number.MAX_VALUE, -Number.MAX_VALUE], [Number.MAX_VALUE, -Number.MAX_VALUE], [Number.MAX_VALUE, -Number.MAX_VALUE]]);
  41153. const r2 = this.borders[t2];
  41154. e2 < r2[0] && (r2[0] = e2), e2 > r2[1] && (r2[1] = e2);
  41155. }
  41156. processBorderOverlap(t2, e2) {
  41157. if (t2.x === e2.x) {
  41158. if (t2.y === e2.y)
  41159. return;
  41160. const r2 = 0 === t2.x ? 0 : 1;
  41161. this.addBorderIntersection(r2, e2.y), this.addBorderIntersection(r2, t2.y);
  41162. } else {
  41163. const r2 = 0 === t2.y ? 2 : 3;
  41164. this.addBorderIntersection(r2, e2.x), this.addBorderIntersection(r2, t2.x);
  41165. }
  41166. }
  41167. centroid() {
  41168. const t2 = this.polyCount.reduce((t3, e2) => t3 + e2.edges, 0);
  41169. return 0 !== t2 ? this.acc.div(t2)._round() : new i2(0, 0);
  41170. }
  41171. span() {
  41172. return new i2(this.max.x - this.min.x, this.max.y - this.min.y);
  41173. }
  41174. intersectsCount() {
  41175. return this.borders.reduce((t2, e2) => t2 + +(e2[0] !== Number.MAX_VALUE), 0);
  41176. }
  41177. }
  41178. class $u {
  41179. constructor(t2) {
  41180. this.zoom = t2.zoom, this.canonical = t2.canonical, this.overscaling = t2.overscaling, this.layers = t2.layers, this.layerIds = this.layers.map((t3) => t3.id), this.index = t2.index, this.hasPattern = false, this.projection = t2.projection, this.layoutVertexArray = new Ts(), this.centroidVertexArray = new ha(), this.indexArray = new js(), this.programConfigurations = new Ra(t2.layers, t2.zoom), this.segments = new Ka(), this.stateDependentLayerIds = this.layers.filter((t3) => t3.isStateDependent()).map((t3) => t3.id), this.enableTerrain = t2.enableTerrain;
  41181. }
  41182. populate(t2, e2, r2, n2) {
  41183. this.features = [], this.hasPattern = mu("fill-extrusion", this.layers, e2), this.featuresOnBorder = [], this.borders = [[], [], [], []], this.borderDoneWithNeighborZ = [-1, -1, -1, -1], this.tileToMeter = function(t3) {
  41184. const e3 = Math.exp(Math.PI * (1 - t3.y / (1 << t3.z) * 2));
  41185. return 80150034 * e3 / (e3 * e3 + 1) / Ya / (1 << t3.z);
  41186. }(r2);
  41187. for (const { feature: i3, id: s2, index: a2, sourceLayerIndex: o2 } of t2) {
  41188. const t3 = this.layers[0]._featureFilter.needGeometry, l2 = mo(i3, t3);
  41189. if (!this.layers[0]._featureFilter.filter(new ss(this.zoom), l2, r2))
  41190. continue;
  41191. const u2 = { id: s2, sourceLayerIndex: o2, index: a2, geometry: t3 ? l2.geometry : yo(i3, r2, n2), properties: i3.properties, type: i3.type, patterns: {} }, c2 = this.layoutVertexArray.length;
  41192. this.hasPattern ? this.features.push(gu("fill-extrusion", this.layers, u2, this.zoom, e2)) : this.addFeature(u2, u2.geometry, a2, r2, {}, e2.availableImages, n2), e2.featureIndex.insert(i3, u2.geometry, a2, o2, this.index, c2);
  41193. }
  41194. this.sortBorders();
  41195. }
  41196. addFeatures(t2, e2, r2, n2, i3) {
  41197. for (const t3 of this.features) {
  41198. const { geometry: s2 } = t3;
  41199. this.addFeature(t3, s2, t3.index, e2, r2, n2, i3);
  41200. }
  41201. this.sortBorders();
  41202. }
  41203. update(t2, e2, r2, n2) {
  41204. this.stateDependentLayers.length && this.programConfigurations.updatePaintArrays(t2, e2, this.stateDependentLayers, r2, n2);
  41205. }
  41206. isEmpty() {
  41207. return 0 === this.layoutVertexArray.length;
  41208. }
  41209. uploadPending() {
  41210. return !this.uploaded || this.programConfigurations.needsUpload;
  41211. }
  41212. upload(t2) {
  41213. this.uploaded || (this.layoutVertexBuffer = t2.createVertexBuffer(this.layoutVertexArray, ku), this.indexBuffer = t2.createIndexBuffer(this.indexArray), this.layoutVertexExtArray && (this.layoutVertexExtBuffer = t2.createVertexBuffer(this.layoutVertexExtArray, Au.members, true))), this.programConfigurations.upload(t2), this.uploaded = true;
  41214. }
  41215. uploadCentroid(t2) {
  41216. 0 !== this.centroidVertexArray.length && (this.centroidVertexBuffer ? this.needsCentroidUpdate && this.centroidVertexBuffer.updateData(this.centroidVertexArray) : this.centroidVertexBuffer = t2.createVertexBuffer(this.centroidVertexArray, wu.members, true), this.needsCentroidUpdate = false);
  41217. }
  41218. destroy() {
  41219. this.layoutVertexBuffer && (this.layoutVertexBuffer.destroy(), this.centroidVertexBuffer && this.centroidVertexBuffer.destroy(), this.layoutVertexExtBuffer && this.layoutVertexExtBuffer.destroy(), this.indexBuffer.destroy(), this.programConfigurations.destroy(), this.segments.destroy());
  41220. }
  41221. addFeature(t2, e2, r2, n2, s2, a2, o2) {
  41222. const l2 = [new i2(0, 0), new i2(Ya, Ya)], u2 = o2.projection, c2 = "globe" === u2.name, h2 = this.enableTerrain && !c2 ? new Uu() : null;
  41223. c2 && !this.layoutVertexExtArray && (this.layoutVertexExtArray = new Qs());
  41224. const p2 = du(e2, 500);
  41225. for (let t3 = p2.length - 1; t3 >= 0; t3--) {
  41226. const e3 = p2[t3];
  41227. (0 === e3.length || (f2 = e3[0]).every((t4) => t4.x <= 0) || f2.every((t4) => t4.x >= Ya) || f2.every((t4) => t4.y <= 0) || f2.every((t4) => t4.y >= Ya)) && p2.splice(t3, 1);
  41228. }
  41229. var f2;
  41230. let d2;
  41231. if (c2) {
  41232. const t3 = 11.25, e3 = 1 << n2.z, r3 = io(n2.x / e3), s3 = io((n2.x + 1) / e3), a3 = so(n2.y / e3), o3 = so((n2.y + 1) / e3);
  41233. d2 = function(t4, e4, r4, n3, s4 = 0, a4) {
  41234. const o4 = [];
  41235. if (!t4.length || !r4 || !n3)
  41236. return o4;
  41237. const l3 = (t5, e5) => {
  41238. for (const r5 of t5)
  41239. o4.push({ polygon: r5, bounds: e5 });
  41240. }, u3 = Math.ceil(Math.log2(r4)), c3 = Math.ceil(Math.log2(n3)), h3 = u3 - c3, p3 = [];
  41241. for (let t5 = 0; t5 < Math.abs(h3); t5++)
  41242. p3.push(h3 > 0 ? 0 : 1);
  41243. for (let t5 = 0; t5 < Math.min(u3, c3); t5++)
  41244. p3.push(0), p3.push(1);
  41245. let f3 = t4;
  41246. if (f3 = Pu(f3, e4[0].y - s4, e4[1].y + s4, 1), f3 = Pu(f3, e4[0].x - s4, e4[1].x + s4, 0), !f3.length)
  41247. return o4;
  41248. const d3 = [];
  41249. for (p3.length ? d3.push({ polygons: f3, bounds: e4, depth: 0 }) : l3(f3, e4); d3.length; ) {
  41250. const t5 = d3.pop(), e5 = t5.depth, r5 = p3[e5], n4 = t5.bounds[0], o5 = t5.bounds[1], u4 = 0 === r5 ? n4.x : n4.y, c4 = 0 === r5 ? o5.x : o5.y, h4 = a4 ? a4(r5, u4, c4) : 0.5 * (u4 + c4), f4 = Pu(t5.polygons, u4 - s4, h4 + s4, r5), y2 = Pu(t5.polygons, h4 - s4, c4 + s4, r5);
  41251. if (f4.length) {
  41252. const t6 = [n4, new i2(0 === r5 ? h4 : o5.x, 1 === r5 ? h4 : o5.y)];
  41253. p3.length > e5 + 1 ? d3.push({ polygons: f4, bounds: t6, depth: e5 + 1 }) : l3(f4, t6);
  41254. }
  41255. if (y2.length) {
  41256. const t6 = [new i2(0 === r5 ? h4 : n4.x, 1 === r5 ? h4 : n4.y), o5];
  41257. p3.length > e5 + 1 ? d3.push({ polygons: y2, bounds: t6, depth: e5 + 1 }) : l3(y2, t6);
  41258. }
  41259. }
  41260. return o4;
  41261. }(p2, l2, Math.ceil((s3 - r3) / t3), Math.ceil((a3 - o3) / t3), 1, (t4, r4, i3) => {
  41262. if (0 === t4)
  41263. return 0.5 * (r4 + i3);
  41264. {
  41265. const t5 = so((n2.y + r4 / Ya) / e3);
  41266. return (ro(0.5 * (so((n2.y + i3 / Ya) / e3) + t5)) * e3 - n2.y) * Ya;
  41267. }
  41268. });
  41269. } else {
  41270. d2 = [];
  41271. for (const t3 of p2)
  41272. d2.push({ polygon: t3, bounds: l2 });
  41273. }
  41274. for (const e3 of d2) {
  41275. const r3 = e3.polygon;
  41276. let i3 = 0, s3 = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray);
  41277. for (let t3 = 0; t3 < r3.length; t3++) {
  41278. const a4 = r3[t3];
  41279. if (0 === a4.length)
  41280. continue;
  41281. i3 += a4.length;
  41282. let o4 = 0;
  41283. h2 && h2.startRing(a4[0]);
  41284. for (let t4 = 0; t4 < a4.length; t4++) {
  41285. const r4 = a4[t4];
  41286. if (t4 >= 1) {
  41287. const i4 = a4[t4 - 1];
  41288. if (!ju(r4, i4, e3.bounds)) {
  41289. h2 && h2.append(r4, i4), s3.vertexLength + 4 > Ka.MAX_VERTEX_ARRAY_LENGTH && (s3 = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray));
  41290. const t5 = r4.sub(i4)._perp(), e4 = t5.x / (Math.abs(t5.x) + Math.abs(t5.y)), a5 = t5.y > 0 ? 1 : 0, l4 = i4.dist(r4);
  41291. o4 + l4 > 32768 && (o4 = 0), Lu(this.layoutVertexArray, r4.x, r4.y, e4, a5, 0, 0, o4), Lu(this.layoutVertexArray, r4.x, r4.y, e4, a5, 0, 1, o4), o4 += l4, Lu(this.layoutVertexArray, i4.x, i4.y, e4, a5, 0, 0, o4), Lu(this.layoutVertexArray, i4.x, i4.y, e4, a5, 0, 1, o4);
  41292. const p4 = s3.vertexLength;
  41293. if (this.indexArray.emplaceBack(p4, p4 + 2, p4 + 1), this.indexArray.emplaceBack(p4 + 1, p4 + 2, p4 + 3), s3.vertexLength += 4, s3.primitiveLength += 2, c2) {
  41294. const t6 = this.layoutVertexExtArray, e5 = u2.projectTilePoint(r4.x, r4.y, n2), s4 = u2.projectTilePoint(i4.x, i4.y, n2), a6 = u2.upVector(n2, r4.x, r4.y), o5 = u2.upVector(n2, i4.x, i4.y);
  41295. Ru(t6, e5, a6), Ru(t6, e5, a6), Ru(t6, s4, o5), Ru(t6, s4, o5);
  41296. }
  41297. }
  41298. }
  41299. }
  41300. }
  41301. if (s3.vertexLength + i3 > Ka.MAX_VERTEX_ARRAY_LENGTH && (s3 = this.segments.prepareSegment(i3, this.layoutVertexArray, this.indexArray)), "Polygon" !== Vu[t2.type])
  41302. continue;
  41303. const a3 = [], o3 = [], l3 = s3.vertexLength;
  41304. for (let t3 = 0; t3 < r3.length; t3++) {
  41305. const e4 = r3[t3];
  41306. if (0 !== e4.length) {
  41307. e4 !== r3[0] && o3.push(a3.length / 2);
  41308. for (let t4 = 0; t4 < e4.length; t4++) {
  41309. const r4 = e4[t4];
  41310. Lu(this.layoutVertexArray, r4.x, r4.y, 0, 0, 1, 1, 0), a3.push(r4.x), a3.push(r4.y), h2 && h2.currentPolyCount.top++, c2 && Ru(this.layoutVertexExtArray, u2.projectTilePoint(r4.x, r4.y, n2), u2.upVector(n2, r4.x, r4.y));
  41311. }
  41312. }
  41313. }
  41314. const p3 = Fl(a3, o3);
  41315. for (let t3 = 0; t3 < p3.length; t3 += 3)
  41316. this.indexArray.emplaceBack(l3 + p3[t3], l3 + p3[t3 + 2], l3 + p3[t3 + 1]);
  41317. s3.primitiveLength += p3.length / 3, s3.vertexLength += i3;
  41318. }
  41319. if (h2 && h2.polyCount.length > 0) {
  41320. if (h2.borders) {
  41321. h2.vertexArrayOffset = this.centroidVertexArray.length;
  41322. const t3 = h2.borders, e3 = this.featuresOnBorder.push(h2) - 1;
  41323. for (let r3 = 0; r3 < 4; r3++)
  41324. t3[r3][0] !== Number.MAX_VALUE && this.borders[r3].push(e3);
  41325. }
  41326. this.encodeCentroid(h2.borders ? void 0 : h2.centroid(), h2);
  41327. }
  41328. this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, t2, r2, s2, a2, n2);
  41329. }
  41330. sortBorders() {
  41331. for (let t2 = 0; t2 < 4; t2++)
  41332. this.borders[t2].sort((e2, r2) => this.featuresOnBorder[e2].borders[t2][0] - this.featuresOnBorder[r2].borders[t2][0]);
  41333. }
  41334. encodeCentroid(t2, e2, r2 = true) {
  41335. let n2, i3;
  41336. if (t2)
  41337. if (0 !== t2.y) {
  41338. const r3 = e2.span()._mult(this.tileToMeter);
  41339. n2 = (Math.max(t2.x, 1) << 3) + Math.min(7, Math.round(r3.x / 10)), i3 = (Math.max(t2.y, 1) << 3) + Math.min(7, Math.round(r3.y / 10));
  41340. } else
  41341. n2 = Math.ceil(7 * (t2.x + 450)), i3 = 0;
  41342. else
  41343. n2 = 0, i3 = +r2;
  41344. let s2 = r2 ? this.centroidVertexArray.length : e2.vertexArrayOffset;
  41345. for (const t3 of e2.polyCount) {
  41346. r2 && this.centroidVertexArray.resize(this.centroidVertexArray.length + 4 * t3.edges + t3.top);
  41347. for (let e3 = 0; e3 < 2 * t3.edges; e3++)
  41348. this.centroidVertexArray.emplace(s2++, 0, i3), this.centroidVertexArray.emplace(s2++, n2, i3);
  41349. for (let e3 = 0; e3 < t3.top; e3++)
  41350. this.centroidVertexArray.emplace(s2++, n2, i3);
  41351. }
  41352. }
  41353. }
  41354. function ju(t2, e2, r2) {
  41355. return t2.x === e2.x && (t2.x < r2[0].x || t2.x > r2[1].x) || t2.y === e2.y && (t2.y < r2[0].y || t2.y > r2[1].y);
  41356. }
  41357. ai($u, "FillExtrusionBucket", { omit: ["layers", "features"] }), ai(Uu, "PartMetadata");
  41358. var Ou = { paint: new vs({ "fill-extrusion-opacity": new ds($t["paint_fill-extrusion"]["fill-extrusion-opacity"]), "fill-extrusion-color": new ys($t["paint_fill-extrusion"]["fill-extrusion-color"]), "fill-extrusion-translate": new ds($t["paint_fill-extrusion"]["fill-extrusion-translate"]), "fill-extrusion-translate-anchor": new ds($t["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]), "fill-extrusion-pattern": new ms($t["paint_fill-extrusion"]["fill-extrusion-pattern"]), "fill-extrusion-height": new ys($t["paint_fill-extrusion"]["fill-extrusion-height"]), "fill-extrusion-base": new ys($t["paint_fill-extrusion"]["fill-extrusion-base"]), "fill-extrusion-vertical-gradient": new ds($t["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]) }) };
  41359. function qu(t2, e2) {
  41360. return t2.x * e2.x + t2.y * e2.y;
  41361. }
  41362. function Nu(t2, e2) {
  41363. if (1 === t2.length) {
  41364. let r2 = 0;
  41365. const n2 = e2[r2++];
  41366. let i3;
  41367. for (; !i3 || n2.equals(i3); )
  41368. if (i3 = e2[r2++], !i3)
  41369. return 1 / 0;
  41370. for (; r2 < e2.length; r2++) {
  41371. const s2 = e2[r2], a2 = t2[0], o2 = i3.sub(n2), l2 = s2.sub(n2), u2 = a2.sub(n2), c2 = qu(o2, o2), h2 = qu(o2, l2), p2 = qu(l2, l2), f2 = qu(u2, o2), d2 = qu(u2, l2), y2 = c2 * p2 - h2 * h2, m2 = (p2 * f2 - h2 * d2) / y2, g2 = (c2 * d2 - h2 * f2) / y2, x2 = n2.z * (1 - m2 - g2) + i3.z * m2 + s2.z * g2;
  41372. if (isFinite(x2))
  41373. return x2;
  41374. }
  41375. return 1 / 0;
  41376. }
  41377. {
  41378. let t3 = 1 / 0;
  41379. for (const r2 of e2)
  41380. t3 = Math.min(t3, r2.z);
  41381. return t3;
  41382. }
  41383. }
  41384. function Gu(t2) {
  41385. const e2 = new i2(t2[0], t2[1]);
  41386. return e2.z = t2[2], e2;
  41387. }
  41388. function Zu(t2, e2, r2, n2, i3, s2, a2, o2) {
  41389. const l2 = a2 * i3.getElevationAt(t2, e2, true, true), u2 = 0 !== s2[0], c2 = u2 ? 0 === s2[1] ? a2 * (s2[0] / 7 - 450) : a2 * function(t3, e3, r3) {
  41390. const n3 = Math.floor(e3[0] / 8), i4 = Math.floor(e3[1] / 8), s3 = 10 * (e3[0] - 8 * n3), a3 = 10 * (e3[1] - 8 * i4), o3 = t3.getElevationAt(n3, i4, true, true), l3 = t3.getMeterToDEM(r3), u3 = Math.floor(0.5 * (s3 * l3 - 1)), c3 = Math.floor(0.5 * (a3 * l3 - 1)), h2 = t3.tileCoordToPixel(n3, i4), p2 = 2 * u3 + 1, f2 = 2 * c3 + 1, d2 = function(t4, e4, r4, n4, i5) {
  41391. return [t4.getElevationAtPixel(e4, r4, true), t4.getElevationAtPixel(e4 + i5, r4, true), t4.getElevationAtPixel(e4, r4 + i5, true), t4.getElevationAtPixel(e4 + n4, r4 + i5, true)];
  41392. }(t3, h2.x - u3, h2.y - c3, p2, f2), y2 = Math.abs(d2[0] - d2[1]), m2 = Math.abs(d2[2] - d2[3]), g2 = Math.abs(d2[0] - d2[2]) + Math.abs(d2[1] - d2[3]), x2 = Math.min(0.25, 0.5 * l3 * (y2 + m2) / p2), v2 = Math.min(0.25, 0.5 * l3 * g2 / f2);
  41393. return o3 + Math.max(x2 * s3, v2 * a3);
  41394. }(i3, s2, o2) : l2;
  41395. return { base: l2 + (0 === r2) ? -1 : r2, top: u2 ? Math.max(c2 + n2, l2 + r2 + 2) : l2 + n2 };
  41396. }
  41397. const Xu = ks([{ name: "a_pos_normal", components: 2, type: "Int16" }, { name: "a_data", components: 4, type: "Uint8" }, { name: "a_linesofar", components: 1, type: "Float32" }], 4), { members: Ku } = Xu, Yu = ks([{ name: "a_packed", components: 3, type: "Float32" }]), { members: Hu } = Yu, Wu = Du.VectorTileFeature.types, Ju = Math.cos(Math.PI / 180 * 37.5);
  41398. class Qu {
  41399. constructor(t2) {
  41400. this.zoom = t2.zoom, this.overscaling = t2.overscaling, this.layers = t2.layers, this.layerIds = this.layers.map((t3) => t3.id), this.index = t2.index, this.projection = t2.projection, this.hasPattern = false, this.patternFeatures = [], this.lineClipsArray = [], this.gradients = {}, this.layers.forEach((t3) => {
  41401. this.gradients[t3.id] = {};
  41402. }), this.layoutVertexArray = new zs(), this.layoutVertexArray2 = new Vs(), this.indexArray = new js(), this.programConfigurations = new Ra(t2.layers, t2.zoom), this.segments = new Ka(), this.maxLineLength = 0, this.stateDependentLayerIds = this.layers.filter((t3) => t3.isStateDependent()).map((t3) => t3.id);
  41403. }
  41404. populate(t2, e2, r2, n2) {
  41405. this.hasPattern = mu("line", this.layers, e2);
  41406. const i3 = this.layers[0].layout.get("line-sort-key"), s2 = [];
  41407. for (const { feature: e3, id: a3, index: o3, sourceLayerIndex: l3 } of t2) {
  41408. const t3 = this.layers[0]._featureFilter.needGeometry, u2 = mo(e3, t3);
  41409. if (!this.layers[0]._featureFilter.filter(new ss(this.zoom), u2, r2))
  41410. continue;
  41411. const c2 = i3 ? i3.evaluate(u2, {}, r2) : void 0, h2 = { id: a3, properties: e3.properties, type: e3.type, sourceLayerIndex: l3, index: o3, geometry: t3 ? u2.geometry : yo(e3, r2, n2), patterns: {}, sortKey: c2 };
  41412. s2.push(h2);
  41413. }
  41414. i3 && s2.sort((t3, e3) => t3.sortKey - e3.sortKey);
  41415. const { lineAtlas: a2, featureIndex: o2 } = e2, l2 = this.addConstantDashes(a2);
  41416. for (const n3 of s2) {
  41417. const { geometry: i4, index: s3, sourceLayerIndex: u2 } = n3;
  41418. if (l2 && this.addFeatureDashes(n3, a2), this.hasPattern) {
  41419. const t3 = gu("line", this.layers, n3, this.zoom, e2);
  41420. this.patternFeatures.push(t3);
  41421. } else
  41422. this.addFeature(n3, i4, s3, r2, a2.positions, e2.availableImages);
  41423. o2.insert(t2[s3].feature, i4, s3, u2, this.index);
  41424. }
  41425. }
  41426. addConstantDashes(t2) {
  41427. let e2 = false;
  41428. for (const r2 of this.layers) {
  41429. const n2 = r2.paint.get("line-dasharray").value, i3 = r2.layout.get("line-cap").value;
  41430. if ("constant" !== n2.kind || "constant" !== i3.kind)
  41431. e2 = true;
  41432. else {
  41433. const e3 = i3.value, r3 = n2.value;
  41434. if (!r3)
  41435. continue;
  41436. t2.addDash(r3.from, e3), t2.addDash(r3.to, e3), r3.other && t2.addDash(r3.other, e3);
  41437. }
  41438. }
  41439. return e2;
  41440. }
  41441. addFeatureDashes(t2, e2) {
  41442. const r2 = this.zoom;
  41443. for (const n2 of this.layers) {
  41444. const i3 = n2.paint.get("line-dasharray").value, s2 = n2.layout.get("line-cap").value;
  41445. if ("constant" === i3.kind && "constant" === s2.kind)
  41446. continue;
  41447. let a2, o2, l2, u2, c2, h2;
  41448. if ("constant" === i3.kind) {
  41449. const t3 = i3.value;
  41450. if (!t3)
  41451. continue;
  41452. a2 = t3.other || t3.to, o2 = t3.to, l2 = t3.from;
  41453. } else
  41454. a2 = i3.evaluate({ zoom: r2 - 1 }, t2), o2 = i3.evaluate({ zoom: r2 }, t2), l2 = i3.evaluate({ zoom: r2 + 1 }, t2);
  41455. "constant" === s2.kind ? u2 = c2 = h2 = s2.value : (u2 = s2.evaluate({ zoom: r2 - 1 }, t2), c2 = s2.evaluate({ zoom: r2 }, t2), h2 = s2.evaluate({ zoom: r2 + 1 }, t2)), e2.addDash(a2, u2), e2.addDash(o2, c2), e2.addDash(l2, h2);
  41456. const p2 = e2.getKey(a2, u2), f2 = e2.getKey(o2, c2), d2 = e2.getKey(l2, h2);
  41457. t2.patterns[n2.id] = { min: p2, mid: f2, max: d2 };
  41458. }
  41459. }
  41460. update(t2, e2, r2, n2) {
  41461. this.stateDependentLayers.length && this.programConfigurations.updatePaintArrays(t2, e2, this.stateDependentLayers, r2, n2);
  41462. }
  41463. addFeatures(t2, e2, r2, n2, i3) {
  41464. for (const t3 of this.patternFeatures)
  41465. this.addFeature(t3, t3.geometry, t3.index, e2, r2, n2);
  41466. }
  41467. isEmpty() {
  41468. return 0 === this.layoutVertexArray.length;
  41469. }
  41470. uploadPending() {
  41471. return !this.uploaded || this.programConfigurations.needsUpload;
  41472. }
  41473. upload(t2) {
  41474. this.uploaded || (0 !== this.layoutVertexArray2.length && (this.layoutVertexBuffer2 = t2.createVertexBuffer(this.layoutVertexArray2, Hu)), this.layoutVertexBuffer = t2.createVertexBuffer(this.layoutVertexArray, Ku), this.indexBuffer = t2.createIndexBuffer(this.indexArray)), this.programConfigurations.upload(t2), this.uploaded = true;
  41475. }
  41476. destroy() {
  41477. this.layoutVertexBuffer && (this.layoutVertexBuffer.destroy(), this.indexBuffer.destroy(), this.programConfigurations.destroy(), this.segments.destroy());
  41478. }
  41479. lineFeatureClips(t2) {
  41480. if (t2.properties && t2.properties.hasOwnProperty("mapbox_clip_start") && t2.properties.hasOwnProperty("mapbox_clip_end"))
  41481. return { start: +t2.properties.mapbox_clip_start, end: +t2.properties.mapbox_clip_end };
  41482. }
  41483. addFeature(t2, e2, r2, n2, i3, s2) {
  41484. const a2 = this.layers[0].layout, o2 = a2.get("line-join").evaluate(t2, {}), l2 = a2.get("line-cap").evaluate(t2, {}), u2 = a2.get("line-miter-limit"), c2 = a2.get("line-round-limit");
  41485. this.lineClips = this.lineFeatureClips(t2);
  41486. for (const r3 of e2)
  41487. this.addLine(r3, t2, o2, l2, u2, c2);
  41488. this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, t2, r2, i3, s2, n2);
  41489. }
  41490. addLine(t2, e2, r2, n2, i3, s2) {
  41491. if (this.distance = 0, this.scaledDistance = 0, this.totalDistance = 0, this.lineSoFar = 0, this.lineClips) {
  41492. this.lineClipsArray.push(this.lineClips);
  41493. for (let e3 = 0; e3 < t2.length - 1; e3++)
  41494. this.totalDistance += t2[e3].dist(t2[e3 + 1]);
  41495. this.updateScaledDistance(), this.maxLineLength = Math.max(this.maxLineLength, this.totalDistance);
  41496. }
  41497. const a2 = "Polygon" === Wu[e2.type];
  41498. let o2 = t2.length;
  41499. for (; o2 >= 2 && t2[o2 - 1].equals(t2[o2 - 2]); )
  41500. o2--;
  41501. let l2 = 0;
  41502. for (; l2 < o2 - 1 && t2[l2].equals(t2[l2 + 1]); )
  41503. l2++;
  41504. if (o2 < (a2 ? 3 : 2))
  41505. return;
  41506. "bevel" === r2 && (i3 = 1.05);
  41507. const u2 = this.overscaling <= 16 ? 122880 / (512 * this.overscaling) : 0, c2 = this.segments.prepareSegment(10 * o2, this.layoutVertexArray, this.indexArray);
  41508. let h2, p2, f2, d2, y2;
  41509. this.e1 = this.e2 = -1, a2 && (h2 = t2[o2 - 2], y2 = t2[l2].sub(h2)._unit()._perp());
  41510. for (let e3 = l2; e3 < o2; e3++) {
  41511. if (f2 = e3 === o2 - 1 ? a2 ? t2[l2 + 1] : void 0 : t2[e3 + 1], f2 && t2[e3].equals(f2))
  41512. continue;
  41513. y2 && (d2 = y2), h2 && (p2 = h2), h2 = t2[e3], y2 = f2 ? f2.sub(h2)._unit()._perp() : d2, d2 = d2 || y2;
  41514. let m2 = d2.add(y2);
  41515. 0 === m2.x && 0 === m2.y || m2._unit();
  41516. const g2 = d2.x * y2.x + d2.y * y2.y, x2 = m2.x * y2.x + m2.y * y2.y, v2 = 0 !== x2 ? 1 / x2 : 1 / 0, b2 = 2 * Math.sqrt(2 - 2 * x2), _2 = x2 < Ju && p2 && f2, w2 = d2.x * y2.y - d2.y * y2.x > 0;
  41517. if (_2 && e3 > l2) {
  41518. const t3 = h2.dist(p2);
  41519. if (t3 > 2 * u2) {
  41520. const e4 = h2.sub(h2.sub(p2)._mult(u2 / t3)._round());
  41521. this.updateDistance(p2, e4), this.addCurrentVertex(e4, d2, 0, 0, c2), p2 = e4;
  41522. }
  41523. }
  41524. const A2 = p2 && f2;
  41525. let k2 = A2 ? r2 : a2 ? "butt" : n2;
  41526. if (A2 && "round" === k2 && (v2 < s2 ? k2 = "miter" : v2 <= 2 && (k2 = "fakeround")), "miter" === k2 && v2 > i3 && (k2 = "bevel"), "bevel" === k2 && (v2 > 2 && (k2 = "flipbevel"), v2 < i3 && (k2 = "miter")), p2 && this.updateDistance(p2, h2), "miter" === k2)
  41527. m2._mult(v2), this.addCurrentVertex(h2, m2, 0, 0, c2);
  41528. else if ("flipbevel" === k2) {
  41529. if (v2 > 100)
  41530. m2 = y2.mult(-1);
  41531. else {
  41532. const t3 = v2 * d2.add(y2).mag() / d2.sub(y2).mag();
  41533. m2._perp()._mult(t3 * (w2 ? -1 : 1));
  41534. }
  41535. this.addCurrentVertex(h2, m2, 0, 0, c2), this.addCurrentVertex(h2, m2.mult(-1), 0, 0, c2);
  41536. } else if ("bevel" === k2 || "fakeround" === k2) {
  41537. const t3 = -Math.sqrt(v2 * v2 - 1), e4 = w2 ? t3 : 0, r3 = w2 ? 0 : t3;
  41538. if (p2 && this.addCurrentVertex(h2, d2, e4, r3, c2), "fakeround" === k2) {
  41539. const t4 = Math.round(180 * b2 / Math.PI / 20);
  41540. for (let e5 = 1; e5 < t4; e5++) {
  41541. let r4 = e5 / t4;
  41542. if (0.5 !== r4) {
  41543. const t5 = r4 - 0.5;
  41544. r4 += r4 * t5 * (r4 - 1) * ((1.0904 + g2 * (g2 * (3.55645 - 1.43519 * g2) - 3.2452)) * t5 * t5 + (0.848013 + g2 * (0.215638 * g2 - 1.06021)));
  41545. }
  41546. const n3 = y2.sub(d2)._mult(r4)._add(d2)._unit()._mult(w2 ? -1 : 1);
  41547. this.addHalfVertex(h2, n3.x, n3.y, false, w2, 0, c2);
  41548. }
  41549. }
  41550. f2 && this.addCurrentVertex(h2, y2, -e4, -r3, c2);
  41551. } else if ("butt" === k2)
  41552. this.addCurrentVertex(h2, m2, 0, 0, c2);
  41553. else if ("square" === k2) {
  41554. const t3 = p2 ? 1 : -1;
  41555. p2 || this.addCurrentVertex(h2, m2, t3, t3, c2), this.addCurrentVertex(h2, m2, 0, 0, c2), p2 && this.addCurrentVertex(h2, m2, t3, t3, c2);
  41556. } else
  41557. "round" === k2 && (p2 && (this.addCurrentVertex(h2, d2, 0, 0, c2), this.addCurrentVertex(h2, d2, 1, 1, c2, true)), f2 && (this.addCurrentVertex(h2, y2, -1, -1, c2, true), this.addCurrentVertex(h2, y2, 0, 0, c2)));
  41558. if (_2 && e3 < o2 - 1) {
  41559. const t3 = h2.dist(f2);
  41560. if (t3 > 2 * u2) {
  41561. const e4 = h2.add(f2.sub(h2)._mult(u2 / t3)._round());
  41562. this.updateDistance(h2, e4), this.addCurrentVertex(e4, y2, 0, 0, c2), h2 = e4;
  41563. }
  41564. }
  41565. }
  41566. }
  41567. addCurrentVertex(t2, e2, r2, n2, i3, s2 = false) {
  41568. const a2 = e2.y * n2 - e2.x, o2 = -e2.y - e2.x * n2;
  41569. this.addHalfVertex(t2, e2.x + e2.y * r2, e2.y - e2.x * r2, s2, false, r2, i3), this.addHalfVertex(t2, a2, o2, s2, true, -n2, i3);
  41570. }
  41571. addHalfVertex({ x: t2, y: e2 }, r2, n2, i3, s2, a2, o2) {
  41572. this.layoutVertexArray.emplaceBack((t2 << 1) + (i3 ? 1 : 0), (e2 << 1) + (s2 ? 1 : 0), Math.round(63 * r2) + 128, Math.round(63 * n2) + 128, 1 + (0 === a2 ? 0 : a2 < 0 ? -1 : 1), 0, this.lineSoFar), this.lineClips && this.layoutVertexArray2.emplaceBack(this.scaledDistance, this.lineClipsArray.length, this.lineSoFar);
  41573. const l2 = o2.vertexLength++;
  41574. this.e1 >= 0 && this.e2 >= 0 && (this.indexArray.emplaceBack(this.e1, this.e2, l2), o2.primitiveLength++), s2 ? this.e2 = l2 : this.e1 = l2;
  41575. }
  41576. updateScaledDistance() {
  41577. if (this.lineClips) {
  41578. const t2 = this.totalDistance / (this.lineClips.end - this.lineClips.start);
  41579. this.scaledDistance = this.distance / this.totalDistance, this.lineSoFar = t2 * this.lineClips.start + this.distance;
  41580. } else
  41581. this.lineSoFar = this.distance;
  41582. }
  41583. updateDistance(t2, e2) {
  41584. this.distance += t2.dist(e2), this.updateScaledDistance();
  41585. }
  41586. }
  41587. ai(Qu, "LineBucket", { omit: ["layers", "patternFeatures"] });
  41588. const tc = new vs({ "line-cap": new ys($t.layout_line["line-cap"]), "line-join": new ys($t.layout_line["line-join"]), "line-miter-limit": new ds($t.layout_line["line-miter-limit"]), "line-round-limit": new ds($t.layout_line["line-round-limit"]), "line-sort-key": new ys($t.layout_line["line-sort-key"]) });
  41589. var ec = { paint: new vs({ "line-opacity": new ys($t.paint_line["line-opacity"]), "line-color": new ys($t.paint_line["line-color"]), "line-translate": new ds($t.paint_line["line-translate"]), "line-translate-anchor": new ds($t.paint_line["line-translate-anchor"]), "line-width": new ys($t.paint_line["line-width"]), "line-gap-width": new ys($t.paint_line["line-gap-width"]), "line-offset": new ys($t.paint_line["line-offset"]), "line-blur": new ys($t.paint_line["line-blur"]), "line-dasharray": new ms($t.paint_line["line-dasharray"]), "line-pattern": new ms($t.paint_line["line-pattern"]), "line-gradient": new xs($t.paint_line["line-gradient"]) }), layout: tc };
  41590. const rc = new class extends ys {
  41591. possiblyEvaluate(t2, e2) {
  41592. return e2 = new ss(Math.floor(e2.zoom), { now: e2.now, fadeDuration: e2.fadeDuration, zoomHistory: e2.zoomHistory, transition: e2.transition }), super.possiblyEvaluate(t2, e2);
  41593. }
  41594. evaluate(t2, e2, r2, n2) {
  41595. return e2 = b({}, e2, { zoom: Math.floor(e2.zoom) }), super.evaluate(t2, e2, r2, n2);
  41596. }
  41597. }(ec.paint.properties["line-width"].specification);
  41598. function nc(t2, e2) {
  41599. return e2 > 0 ? e2 + 2 * t2 : t2;
  41600. }
  41601. rc.useIntegerZoom = true;
  41602. const ic = ks([{ name: "a_pos_offset", components: 4, type: "Int16" }, { name: "a_tex_size", components: 4, type: "Uint16" }, { name: "a_pixeloffset", components: 4, type: "Int16" }, { name: "a_z_tile_anchor", components: 4, type: "Int16" }], 4), sc = ks([{ name: "a_projected_pos", components: 3, type: "Float32" }], 4);
  41603. ks([{ name: "a_fade_opacity", components: 1, type: "Uint32" }], 4);
  41604. const ac = ks([{ name: "a_placed", components: 2, type: "Uint8" }, { name: "a_shift", components: 2, type: "Float32" }]), oc = ks([{ name: "a_size_scale", components: 1, type: "Float32" }, { name: "a_padding", components: 2, type: "Float32" }]);
  41605. ks([{ type: "Int16", name: "projectedAnchorX" }, { type: "Int16", name: "projectedAnchorY" }, { type: "Int16", name: "projectedAnchorZ" }, { type: "Int16", name: "tileAnchorX" }, { type: "Int16", name: "tileAnchorY" }, { type: "Float32", name: "x1" }, { type: "Float32", name: "y1" }, { type: "Float32", name: "x2" }, { type: "Float32", name: "y2" }, { type: "Int16", name: "padding" }, { type: "Uint32", name: "featureIndex" }, { type: "Uint16", name: "sourceLayerIndex" }, { type: "Uint16", name: "bucketIndex" }]);
  41606. const lc = ks([{ name: "a_pos", components: 3, type: "Int16" }, { name: "a_anchor_pos", components: 2, type: "Int16" }, { name: "a_extrude", components: 2, type: "Int16" }], 4), uc = ks([{ name: "a_pos_2f", components: 2, type: "Float32" }, { name: "a_radius", components: 1, type: "Float32" }, { name: "a_flags", components: 2, type: "Int16" }], 4);
  41607. ks([{ name: "triangle", components: 3, type: "Uint16" }]), ks([{ type: "Int16", name: "projectedAnchorX" }, { type: "Int16", name: "projectedAnchorY" }, { type: "Int16", name: "projectedAnchorZ" }, { type: "Float32", name: "tileAnchorX" }, { type: "Float32", name: "tileAnchorY" }, { type: "Uint16", name: "glyphStartIndex" }, { type: "Uint16", name: "numGlyphs" }, { type: "Uint32", name: "vertexStartIndex" }, { type: "Uint32", name: "lineStartIndex" }, { type: "Uint32", name: "lineLength" }, { type: "Uint16", name: "segment" }, { type: "Uint16", name: "lowerSize" }, { type: "Uint16", name: "upperSize" }, { type: "Float32", name: "lineOffsetX" }, { type: "Float32", name: "lineOffsetY" }, { type: "Uint8", name: "writingMode" }, { type: "Uint8", name: "placedOrientation" }, { type: "Uint8", name: "hidden" }, { type: "Uint32", name: "crossTileID" }, { type: "Int16", name: "associatedIconIndex" }, { type: "Uint8", name: "flipState" }]), ks([{ type: "Int16", name: "projectedAnchorX" }, { type: "Int16", name: "projectedAnchorY" }, { type: "Int16", name: "projectedAnchorZ" }, { type: "Float32", name: "tileAnchorX" }, { type: "Float32", name: "tileAnchorY" }, { type: "Int16", name: "rightJustifiedTextSymbolIndex" }, { type: "Int16", name: "centerJustifiedTextSymbolIndex" }, { type: "Int16", name: "leftJustifiedTextSymbolIndex" }, { type: "Int16", name: "verticalPlacedTextSymbolIndex" }, { type: "Int16", name: "placedIconSymbolIndex" }, { type: "Int16", name: "verticalPlacedIconSymbolIndex" }, { type: "Uint16", name: "key" }, { type: "Uint16", name: "textBoxStartIndex" }, { type: "Uint16", name: "textBoxEndIndex" }, { type: "Uint16", name: "verticalTextBoxStartIndex" }, { type: "Uint16", name: "verticalTextBoxEndIndex" }, { type: "Uint16", name: "iconBoxStartIndex" }, { type: "Uint16", name: "iconBoxEndIndex" }, { type: "Uint16", name: "verticalIconBoxStartIndex" }, { type: "Uint16", name: "verticalIconBoxEndIndex" }, { type: "Uint16", name: "featureIndex" }, { type: "Uint16", name: "numHorizontalGlyphVertices" }, { type: "Uint16", name: "numVerticalGlyphVertices" }, { type: "Uint16", name: "numIconVertices" }, { type: "Uint16", name: "numVerticalIconVertices" }, { type: "Uint16", name: "useRuntimeCollisionCircles" }, { type: "Uint32", name: "crossTileID" }, { type: "Float32", components: 2, name: "textOffset" }, { type: "Float32", name: "collisionCircleDiameter" }]), ks([{ type: "Float32", name: "offsetX" }]), ks([{ type: "Int16", name: "x" }, { type: "Int16", name: "y" }, { type: "Int16", name: "tileUnitDistanceFromAnchor" }]);
  41608. var cc = 24;
  41609. const hc = 128;
  41610. function pc(t2, e2) {
  41611. const { expression: r2 } = e2;
  41612. if ("constant" === r2.kind)
  41613. return { kind: "constant", layoutSize: r2.evaluate(new ss(t2 + 1)) };
  41614. if ("source" === r2.kind)
  41615. return { kind: "source" };
  41616. {
  41617. const { zoomStops: e3, interpolationType: n2 } = r2;
  41618. let i3 = 0;
  41619. for (; i3 < e3.length && e3[i3] <= t2; )
  41620. i3++;
  41621. i3 = Math.max(0, i3 - 1);
  41622. let s2 = i3;
  41623. for (; s2 < e3.length && e3[s2] < t2 + 1; )
  41624. s2++;
  41625. s2 = Math.min(e3.length - 1, s2);
  41626. const a2 = e3[i3], o2 = e3[s2];
  41627. return "composite" === r2.kind ? { kind: "composite", minZoom: a2, maxZoom: o2, interpolationType: n2 } : { kind: "camera", minZoom: a2, maxZoom: o2, minSize: r2.evaluate(new ss(a2)), maxSize: r2.evaluate(new ss(o2)), interpolationType: n2 };
  41628. }
  41629. }
  41630. function fc(t2, { uSize: e2, uSizeT: r2 }, { lowerSize: n2, upperSize: i3 }) {
  41631. return "source" === t2.kind ? n2 / hc : "composite" === t2.kind ? rr(n2 / hc, i3 / hc, r2) : e2;
  41632. }
  41633. function dc(t2, e2) {
  41634. let r2 = 0, n2 = 0;
  41635. if ("constant" === t2.kind)
  41636. n2 = t2.layoutSize;
  41637. else if ("source" !== t2.kind) {
  41638. const { interpolationType: i3, minZoom: s2, maxZoom: a2 } = t2, o2 = i3 ? y(_r.interpolationFactor(i3, e2, s2, a2), 0, 1) : 0;
  41639. "camera" === t2.kind ? n2 = rr(t2.minSize, t2.maxSize, o2) : r2 = o2;
  41640. }
  41641. return { uSizeT: r2, uSize: n2 };
  41642. }
  41643. var yc = Object.freeze({ __proto__: null, getSizeData: pc, evaluateSizeForFeature: fc, evaluateSizeForZoom: dc, SIZE_PACK_FACTOR: hc });
  41644. function mc(t2, e2, r2) {
  41645. return t2.sections.forEach((t3) => {
  41646. t3.text = function(t4, e3, r3) {
  41647. const n2 = e3.layout.get("text-transform").evaluate(r3, {});
  41648. return "uppercase" === n2 ? t4 = t4.toLocaleUpperCase() : "lowercase" === n2 && (t4 = t4.toLocaleLowerCase()), is.applyArabicShaping && (t4 = is.applyArabicShaping(t4)), t4;
  41649. }(t3.text, e2, r2);
  41650. }), t2;
  41651. }
  41652. const gc = { "!": "︕", "#": "#", $: "$", "%": "%", "&": "&", "(": "︵", ")": "︶", "*": "*", "+": "+", ",": "︐", "-": "︲", ".": "・", "/": "/", ":": "︓", ";": "︔", "<": "︿", "=": "=", ">": "﹀", "?": "︖", "@": "@", "[": "﹇", "\\": "\", "]": "﹈", "^": "^", _: "︳", "`": "`", "{": "︷", "|": "―", "}": "︸", "~": "~", "¢": "¢", "£": "£", "¥": "¥", "¦": "¦", "¬": "¬", "¯": " ̄", "–": "︲", "—": "︱", "‘": "﹃", "’": "﹄", "“": "﹁", "”": "﹂", "…": "︙", "‧": "・", "₩": "₩", "、": "︑", "。": "︒", "〈": "︿", "〉": "﹀", "《": "︽", "》": "︾", "「": "﹁", "」": "﹂", "『": "﹃", "』": "﹄", "【": "︻", "】": "︼", "〔": "︹", "〕": "︺", "〖": "︗", "〗": "︘", "!": "︕", "(": "︵", ")": "︶", ",": "︐", "-": "︲", ".": "・", ":": "︓", ";": "︔", "<": "︿", ">": "﹀", "?": "︖", "[": "﹇", "]": "﹈", "_": "︳", "{": "︷", "|": "―", "}": "︸", "⦅": "︵", "⦆": "︶", "。": "︒", "「": "﹁", "」": "﹂" };
  41653. function xc(t2) {
  41654. return "︶" === t2 || "﹈" === t2 || "︸" === t2 || "﹄" === t2 || "﹂" === t2 || "︾" === t2 || "︼" === t2 || "︺" === t2 || "︘" === t2 || "﹀" === t2 || "︐" === t2 || "︓" === t2 || "︔" === t2 || "`" === t2 || " ̄" === t2 || "︑" === t2 || "︒" === t2;
  41655. }
  41656. function vc(t2) {
  41657. return "︵" === t2 || "﹇" === t2 || "︷" === t2 || "﹃" === t2 || "﹁" === t2 || "︽" === t2 || "︻" === t2 || "︹" === t2 || "︗" === t2 || "︿" === t2;
  41658. }
  41659. var bc = function(t2, e2, r2, n2, i3) {
  41660. var s2, a2, o2 = 8 * i3 - n2 - 1, l2 = (1 << o2) - 1, u2 = l2 >> 1, c2 = -7, h2 = r2 ? i3 - 1 : 0, p2 = r2 ? -1 : 1, f2 = t2[e2 + h2];
  41661. for (h2 += p2, s2 = f2 & (1 << -c2) - 1, f2 >>= -c2, c2 += o2; c2 > 0; s2 = 256 * s2 + t2[e2 + h2], h2 += p2, c2 -= 8)
  41662. ;
  41663. for (a2 = s2 & (1 << -c2) - 1, s2 >>= -c2, c2 += n2; c2 > 0; a2 = 256 * a2 + t2[e2 + h2], h2 += p2, c2 -= 8)
  41664. ;
  41665. if (0 === s2)
  41666. s2 = 1 - u2;
  41667. else {
  41668. if (s2 === l2)
  41669. return a2 ? NaN : 1 / 0 * (f2 ? -1 : 1);
  41670. a2 += Math.pow(2, n2), s2 -= u2;
  41671. }
  41672. return (f2 ? -1 : 1) * a2 * Math.pow(2, s2 - n2);
  41673. }, _c = function(t2, e2, r2, n2, i3, s2) {
  41674. var a2, o2, l2, u2 = 8 * s2 - i3 - 1, c2 = (1 << u2) - 1, h2 = c2 >> 1, p2 = 23 === i3 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, f2 = n2 ? 0 : s2 - 1, d2 = n2 ? 1 : -1, y2 = e2 < 0 || 0 === e2 && 1 / e2 < 0 ? 1 : 0;
  41675. for (e2 = Math.abs(e2), isNaN(e2) || e2 === 1 / 0 ? (o2 = isNaN(e2) ? 1 : 0, a2 = c2) : (a2 = Math.floor(Math.log(e2) / Math.LN2), e2 * (l2 = Math.pow(2, -a2)) < 1 && (a2--, l2 *= 2), (e2 += a2 + h2 >= 1 ? p2 / l2 : p2 * Math.pow(2, 1 - h2)) * l2 >= 2 && (a2++, l2 /= 2), a2 + h2 >= c2 ? (o2 = 0, a2 = c2) : a2 + h2 >= 1 ? (o2 = (e2 * l2 - 1) * Math.pow(2, i3), a2 += h2) : (o2 = e2 * Math.pow(2, h2 - 1) * Math.pow(2, i3), a2 = 0)); i3 >= 8; t2[r2 + f2] = 255 & o2, f2 += d2, o2 /= 256, i3 -= 8)
  41676. ;
  41677. for (a2 = a2 << i3 | o2, u2 += i3; u2 > 0; t2[r2 + f2] = 255 & a2, f2 += d2, a2 /= 256, u2 -= 8)
  41678. ;
  41679. t2[r2 + f2 - d2] |= 128 * y2;
  41680. }, wc = Ac;
  41681. function Ac(t2) {
  41682. this.buf = ArrayBuffer.isView && ArrayBuffer.isView(t2) ? t2 : new Uint8Array(t2 || 0), this.pos = 0, this.type = 0, this.length = this.buf.length;
  41683. }
  41684. Ac.Varint = 0, Ac.Fixed64 = 1, Ac.Bytes = 2, Ac.Fixed32 = 5;
  41685. var kc = 4294967296, Sc = 1 / kc, Ic = "undefined" == typeof TextDecoder ? null : new TextDecoder("utf8");
  41686. function Mc(t2) {
  41687. return t2.type === Ac.Bytes ? t2.readVarint() + t2.pos : t2.pos + 1;
  41688. }
  41689. function Tc(t2, e2, r2) {
  41690. return r2 ? 4294967296 * e2 + (t2 >>> 0) : 4294967296 * (e2 >>> 0) + (t2 >>> 0);
  41691. }
  41692. function zc(t2, e2, r2) {
  41693. var n2 = e2 <= 16383 ? 1 : e2 <= 2097151 ? 2 : e2 <= 268435455 ? 3 : Math.floor(Math.log(e2) / (7 * Math.LN2));
  41694. r2.realloc(n2);
  41695. for (var i3 = r2.pos - 1; i3 >= t2; i3--)
  41696. r2.buf[i3 + n2] = r2.buf[i3];
  41697. }
  41698. function Bc(t2, e2) {
  41699. for (var r2 = 0; r2 < t2.length; r2++)
  41700. e2.writeVarint(t2[r2]);
  41701. }
  41702. function Ec(t2, e2) {
  41703. for (var r2 = 0; r2 < t2.length; r2++)
  41704. e2.writeSVarint(t2[r2]);
  41705. }
  41706. function Cc(t2, e2) {
  41707. for (var r2 = 0; r2 < t2.length; r2++)
  41708. e2.writeFloat(t2[r2]);
  41709. }
  41710. function Dc(t2, e2) {
  41711. for (var r2 = 0; r2 < t2.length; r2++)
  41712. e2.writeDouble(t2[r2]);
  41713. }
  41714. function Pc(t2, e2) {
  41715. for (var r2 = 0; r2 < t2.length; r2++)
  41716. e2.writeBoolean(t2[r2]);
  41717. }
  41718. function Vc(t2, e2) {
  41719. for (var r2 = 0; r2 < t2.length; r2++)
  41720. e2.writeFixed32(t2[r2]);
  41721. }
  41722. function Fc(t2, e2) {
  41723. for (var r2 = 0; r2 < t2.length; r2++)
  41724. e2.writeSFixed32(t2[r2]);
  41725. }
  41726. function Lc(t2, e2) {
  41727. for (var r2 = 0; r2 < t2.length; r2++)
  41728. e2.writeFixed64(t2[r2]);
  41729. }
  41730. function Rc(t2, e2) {
  41731. for (var r2 = 0; r2 < t2.length; r2++)
  41732. e2.writeSFixed64(t2[r2]);
  41733. }
  41734. function Uc(t2, e2) {
  41735. return (t2[e2] | t2[e2 + 1] << 8 | t2[e2 + 2] << 16) + 16777216 * t2[e2 + 3];
  41736. }
  41737. function $c(t2, e2, r2) {
  41738. t2[r2] = e2, t2[r2 + 1] = e2 >>> 8, t2[r2 + 2] = e2 >>> 16, t2[r2 + 3] = e2 >>> 24;
  41739. }
  41740. function jc(t2, e2) {
  41741. return (t2[e2] | t2[e2 + 1] << 8 | t2[e2 + 2] << 16) + (t2[e2 + 3] << 24);
  41742. }
  41743. function Oc(t2, e2, r2) {
  41744. e2.glyphs = [], 1 === t2 && r2.readMessage(qc, e2);
  41745. }
  41746. function qc(t2, e2, r2) {
  41747. if (3 === t2) {
  41748. const { id: t3, bitmap: n2, width: i3, height: s2, left: a2, top: o2, advance: l2 } = r2.readMessage(Nc, {});
  41749. e2.glyphs.push({ id: t3, bitmap: new zl({ width: i3 + 6, height: s2 + 6 }, n2), metrics: { width: i3, height: s2, left: a2, top: o2, advance: l2 } });
  41750. } else
  41751. 4 === t2 ? e2.ascender = r2.readSVarint() : 5 === t2 && (e2.descender = r2.readSVarint());
  41752. }
  41753. function Nc(t2, e2, r2) {
  41754. 1 === t2 ? e2.id = r2.readVarint() : 2 === t2 ? e2.bitmap = r2.readBytes() : 3 === t2 ? e2.width = r2.readVarint() : 4 === t2 ? e2.height = r2.readVarint() : 5 === t2 ? e2.left = r2.readSVarint() : 6 === t2 ? e2.top = r2.readSVarint() : 7 === t2 && (e2.advance = r2.readVarint());
  41755. }
  41756. function Gc(t2) {
  41757. let e2 = 0, r2 = 0;
  41758. for (const n3 of t2)
  41759. e2 += n3.w * n3.h, r2 = Math.max(r2, n3.w);
  41760. t2.sort((t3, e3) => e3.h - t3.h);
  41761. const n2 = [{ x: 0, y: 0, w: Math.max(Math.ceil(Math.sqrt(e2 / 0.95)), r2), h: 1 / 0 }];
  41762. let i3 = 0, s2 = 0;
  41763. for (const e3 of t2)
  41764. for (let t3 = n2.length - 1; t3 >= 0; t3--) {
  41765. const r3 = n2[t3];
  41766. if (!(e3.w > r3.w || e3.h > r3.h)) {
  41767. if (e3.x = r3.x, e3.y = r3.y, s2 = Math.max(s2, e3.y + e3.h), i3 = Math.max(i3, e3.x + e3.w), e3.w === r3.w && e3.h === r3.h) {
  41768. const e4 = n2.pop();
  41769. t3 < n2.length && (n2[t3] = e4);
  41770. } else
  41771. e3.h === r3.h ? (r3.x += e3.w, r3.w -= e3.w) : e3.w === r3.w ? (r3.y += e3.h, r3.h -= e3.h) : (n2.push({ x: r3.x + e3.w, y: r3.y, w: r3.w - e3.w, h: e3.h }), r3.y += e3.h, r3.h -= e3.h);
  41772. break;
  41773. }
  41774. }
  41775. return { w: i3, h: s2, fill: e2 / (i3 * s2) || 0 };
  41776. }
  41777. Ac.prototype = { destroy: function() {
  41778. this.buf = null;
  41779. }, readFields: function(t2, e2, r2) {
  41780. for (r2 = r2 || this.length; this.pos < r2; ) {
  41781. var n2 = this.readVarint(), i3 = n2 >> 3, s2 = this.pos;
  41782. this.type = 7 & n2, t2(i3, e2, this), this.pos === s2 && this.skip(n2);
  41783. }
  41784. return e2;
  41785. }, readMessage: function(t2, e2) {
  41786. return this.readFields(t2, e2, this.readVarint() + this.pos);
  41787. }, readFixed32: function() {
  41788. var t2 = Uc(this.buf, this.pos);
  41789. return this.pos += 4, t2;
  41790. }, readSFixed32: function() {
  41791. var t2 = jc(this.buf, this.pos);
  41792. return this.pos += 4, t2;
  41793. }, readFixed64: function() {
  41794. var t2 = Uc(this.buf, this.pos) + Uc(this.buf, this.pos + 4) * kc;
  41795. return this.pos += 8, t2;
  41796. }, readSFixed64: function() {
  41797. var t2 = Uc(this.buf, this.pos) + jc(this.buf, this.pos + 4) * kc;
  41798. return this.pos += 8, t2;
  41799. }, readFloat: function() {
  41800. var t2 = bc(this.buf, this.pos, true, 23, 4);
  41801. return this.pos += 4, t2;
  41802. }, readDouble: function() {
  41803. var t2 = bc(this.buf, this.pos, true, 52, 8);
  41804. return this.pos += 8, t2;
  41805. }, readVarint: function(t2) {
  41806. var e2, r2, n2 = this.buf;
  41807. return e2 = 127 & (r2 = n2[this.pos++]), r2 < 128 ? e2 : (e2 |= (127 & (r2 = n2[this.pos++])) << 7, r2 < 128 ? e2 : (e2 |= (127 & (r2 = n2[this.pos++])) << 14, r2 < 128 ? e2 : (e2 |= (127 & (r2 = n2[this.pos++])) << 21, r2 < 128 ? e2 : function(t3, e3, r3) {
  41808. var n3, i3, s2 = r3.buf;
  41809. if (n3 = (112 & (i3 = s2[r3.pos++])) >> 4, i3 < 128)
  41810. return Tc(t3, n3, e3);
  41811. if (n3 |= (127 & (i3 = s2[r3.pos++])) << 3, i3 < 128)
  41812. return Tc(t3, n3, e3);
  41813. if (n3 |= (127 & (i3 = s2[r3.pos++])) << 10, i3 < 128)
  41814. return Tc(t3, n3, e3);
  41815. if (n3 |= (127 & (i3 = s2[r3.pos++])) << 17, i3 < 128)
  41816. return Tc(t3, n3, e3);
  41817. if (n3 |= (127 & (i3 = s2[r3.pos++])) << 24, i3 < 128)
  41818. return Tc(t3, n3, e3);
  41819. if (n3 |= (1 & (i3 = s2[r3.pos++])) << 31, i3 < 128)
  41820. return Tc(t3, n3, e3);
  41821. throw new Error("Expected varint not more than 10 bytes");
  41822. }(e2 |= (15 & (r2 = n2[this.pos])) << 28, t2, this))));
  41823. }, readVarint64: function() {
  41824. return this.readVarint(true);
  41825. }, readSVarint: function() {
  41826. var t2 = this.readVarint();
  41827. return t2 % 2 == 1 ? (t2 + 1) / -2 : t2 / 2;
  41828. }, readBoolean: function() {
  41829. return Boolean(this.readVarint());
  41830. }, readString: function() {
  41831. var t2 = this.readVarint() + this.pos, e2 = this.pos;
  41832. return this.pos = t2, t2 - e2 >= 12 && Ic ? function(t3, e3, r2) {
  41833. return Ic.decode(t3.subarray(e3, r2));
  41834. }(this.buf, e2, t2) : function(t3, e3, r2) {
  41835. for (var n2 = "", i3 = e3; i3 < r2; ) {
  41836. var s2, a2, o2, l2 = t3[i3], u2 = null, c2 = l2 > 239 ? 4 : l2 > 223 ? 3 : l2 > 191 ? 2 : 1;
  41837. if (i3 + c2 > r2)
  41838. break;
  41839. 1 === c2 ? l2 < 128 && (u2 = l2) : 2 === c2 ? 128 == (192 & (s2 = t3[i3 + 1])) && (u2 = (31 & l2) << 6 | 63 & s2) <= 127 && (u2 = null) : 3 === c2 ? (a2 = t3[i3 + 2], 128 == (192 & (s2 = t3[i3 + 1])) && 128 == (192 & a2) && ((u2 = (15 & l2) << 12 | (63 & s2) << 6 | 63 & a2) <= 2047 || u2 >= 55296 && u2 <= 57343) && (u2 = null)) : 4 === c2 && (a2 = t3[i3 + 2], o2 = t3[i3 + 3], 128 == (192 & (s2 = t3[i3 + 1])) && 128 == (192 & a2) && 128 == (192 & o2) && ((u2 = (15 & l2) << 18 | (63 & s2) << 12 | (63 & a2) << 6 | 63 & o2) <= 65535 || u2 >= 1114112) && (u2 = null)), null === u2 ? (u2 = 65533, c2 = 1) : u2 > 65535 && (u2 -= 65536, n2 += String.fromCharCode(u2 >>> 10 & 1023 | 55296), u2 = 56320 | 1023 & u2), n2 += String.fromCharCode(u2), i3 += c2;
  41840. }
  41841. return n2;
  41842. }(this.buf, e2, t2);
  41843. }, readBytes: function() {
  41844. var t2 = this.readVarint() + this.pos, e2 = this.buf.subarray(this.pos, t2);
  41845. return this.pos = t2, e2;
  41846. }, readPackedVarint: function(t2, e2) {
  41847. if (this.type !== Ac.Bytes)
  41848. return t2.push(this.readVarint(e2));
  41849. var r2 = Mc(this);
  41850. for (t2 = t2 || []; this.pos < r2; )
  41851. t2.push(this.readVarint(e2));
  41852. return t2;
  41853. }, readPackedSVarint: function(t2) {
  41854. if (this.type !== Ac.Bytes)
  41855. return t2.push(this.readSVarint());
  41856. var e2 = Mc(this);
  41857. for (t2 = t2 || []; this.pos < e2; )
  41858. t2.push(this.readSVarint());
  41859. return t2;
  41860. }, readPackedBoolean: function(t2) {
  41861. if (this.type !== Ac.Bytes)
  41862. return t2.push(this.readBoolean());
  41863. var e2 = Mc(this);
  41864. for (t2 = t2 || []; this.pos < e2; )
  41865. t2.push(this.readBoolean());
  41866. return t2;
  41867. }, readPackedFloat: function(t2) {
  41868. if (this.type !== Ac.Bytes)
  41869. return t2.push(this.readFloat());
  41870. var e2 = Mc(this);
  41871. for (t2 = t2 || []; this.pos < e2; )
  41872. t2.push(this.readFloat());
  41873. return t2;
  41874. }, readPackedDouble: function(t2) {
  41875. if (this.type !== Ac.Bytes)
  41876. return t2.push(this.readDouble());
  41877. var e2 = Mc(this);
  41878. for (t2 = t2 || []; this.pos < e2; )
  41879. t2.push(this.readDouble());
  41880. return t2;
  41881. }, readPackedFixed32: function(t2) {
  41882. if (this.type !== Ac.Bytes)
  41883. return t2.push(this.readFixed32());
  41884. var e2 = Mc(this);
  41885. for (t2 = t2 || []; this.pos < e2; )
  41886. t2.push(this.readFixed32());
  41887. return t2;
  41888. }, readPackedSFixed32: function(t2) {
  41889. if (this.type !== Ac.Bytes)
  41890. return t2.push(this.readSFixed32());
  41891. var e2 = Mc(this);
  41892. for (t2 = t2 || []; this.pos < e2; )
  41893. t2.push(this.readSFixed32());
  41894. return t2;
  41895. }, readPackedFixed64: function(t2) {
  41896. if (this.type !== Ac.Bytes)
  41897. return t2.push(this.readFixed64());
  41898. var e2 = Mc(this);
  41899. for (t2 = t2 || []; this.pos < e2; )
  41900. t2.push(this.readFixed64());
  41901. return t2;
  41902. }, readPackedSFixed64: function(t2) {
  41903. if (this.type !== Ac.Bytes)
  41904. return t2.push(this.readSFixed64());
  41905. var e2 = Mc(this);
  41906. for (t2 = t2 || []; this.pos < e2; )
  41907. t2.push(this.readSFixed64());
  41908. return t2;
  41909. }, skip: function(t2) {
  41910. var e2 = 7 & t2;
  41911. if (e2 === Ac.Varint)
  41912. for (; this.buf[this.pos++] > 127; )
  41913. ;
  41914. else if (e2 === Ac.Bytes)
  41915. this.pos = this.readVarint() + this.pos;
  41916. else if (e2 === Ac.Fixed32)
  41917. this.pos += 4;
  41918. else {
  41919. if (e2 !== Ac.Fixed64)
  41920. throw new Error("Unimplemented type: " + e2);
  41921. this.pos += 8;
  41922. }
  41923. }, writeTag: function(t2, e2) {
  41924. this.writeVarint(t2 << 3 | e2);
  41925. }, realloc: function(t2) {
  41926. for (var e2 = this.length || 16; e2 < this.pos + t2; )
  41927. e2 *= 2;
  41928. if (e2 !== this.length) {
  41929. var r2 = new Uint8Array(e2);
  41930. r2.set(this.buf), this.buf = r2, this.length = e2;
  41931. }
  41932. }, finish: function() {
  41933. return this.length = this.pos, this.pos = 0, this.buf.subarray(0, this.length);
  41934. }, writeFixed32: function(t2) {
  41935. this.realloc(4), $c(this.buf, t2, this.pos), this.pos += 4;
  41936. }, writeSFixed32: function(t2) {
  41937. this.realloc(4), $c(this.buf, t2, this.pos), this.pos += 4;
  41938. }, writeFixed64: function(t2) {
  41939. this.realloc(8), $c(this.buf, -1 & t2, this.pos), $c(this.buf, Math.floor(t2 * Sc), this.pos + 4), this.pos += 8;
  41940. }, writeSFixed64: function(t2) {
  41941. this.realloc(8), $c(this.buf, -1 & t2, this.pos), $c(this.buf, Math.floor(t2 * Sc), this.pos + 4), this.pos += 8;
  41942. }, writeVarint: function(t2) {
  41943. (t2 = +t2 || 0) > 268435455 || t2 < 0 ? function(t3, e2) {
  41944. var r2, n2;
  41945. if (t3 >= 0 ? (r2 = t3 % 4294967296 | 0, n2 = t3 / 4294967296 | 0) : (n2 = ~(-t3 / 4294967296), 4294967295 ^ (r2 = ~(-t3 % 4294967296)) ? r2 = r2 + 1 | 0 : (r2 = 0, n2 = n2 + 1 | 0)), t3 >= 18446744073709552e3 || t3 < -18446744073709552e3)
  41946. throw new Error("Given varint doesn't fit into 10 bytes");
  41947. e2.realloc(10), function(t4, e3, r3) {
  41948. r3.buf[r3.pos++] = 127 & t4 | 128, t4 >>>= 7, r3.buf[r3.pos++] = 127 & t4 | 128, t4 >>>= 7, r3.buf[r3.pos++] = 127 & t4 | 128, t4 >>>= 7, r3.buf[r3.pos++] = 127 & t4 | 128, r3.buf[r3.pos] = 127 & (t4 >>>= 7);
  41949. }(r2, 0, e2), function(t4, e3) {
  41950. var r3 = (7 & t4) << 4;
  41951. e3.buf[e3.pos++] |= r3 | ((t4 >>>= 3) ? 128 : 0), t4 && (e3.buf[e3.pos++] = 127 & t4 | ((t4 >>>= 7) ? 128 : 0), t4 && (e3.buf[e3.pos++] = 127 & t4 | ((t4 >>>= 7) ? 128 : 0), t4 && (e3.buf[e3.pos++] = 127 & t4 | ((t4 >>>= 7) ? 128 : 0), t4 && (e3.buf[e3.pos++] = 127 & t4 | ((t4 >>>= 7) ? 128 : 0), t4 && (e3.buf[e3.pos++] = 127 & t4)))));
  41952. }(n2, e2);
  41953. }(t2, this) : (this.realloc(4), this.buf[this.pos++] = 127 & t2 | (t2 > 127 ? 128 : 0), t2 <= 127 || (this.buf[this.pos++] = 127 & (t2 >>>= 7) | (t2 > 127 ? 128 : 0), t2 <= 127 || (this.buf[this.pos++] = 127 & (t2 >>>= 7) | (t2 > 127 ? 128 : 0), t2 <= 127 || (this.buf[this.pos++] = t2 >>> 7 & 127))));
  41954. }, writeSVarint: function(t2) {
  41955. this.writeVarint(t2 < 0 ? 2 * -t2 - 1 : 2 * t2);
  41956. }, writeBoolean: function(t2) {
  41957. this.writeVarint(Boolean(t2));
  41958. }, writeString: function(t2) {
  41959. t2 = String(t2), this.realloc(4 * t2.length), this.pos++;
  41960. var e2 = this.pos;
  41961. this.pos = function(t3, e3, r3) {
  41962. for (var n2, i3, s2 = 0; s2 < e3.length; s2++) {
  41963. if ((n2 = e3.charCodeAt(s2)) > 55295 && n2 < 57344) {
  41964. if (!i3) {
  41965. n2 > 56319 || s2 + 1 === e3.length ? (t3[r3++] = 239, t3[r3++] = 191, t3[r3++] = 189) : i3 = n2;
  41966. continue;
  41967. }
  41968. if (n2 < 56320) {
  41969. t3[r3++] = 239, t3[r3++] = 191, t3[r3++] = 189, i3 = n2;
  41970. continue;
  41971. }
  41972. n2 = i3 - 55296 << 10 | n2 - 56320 | 65536, i3 = null;
  41973. } else
  41974. i3 && (t3[r3++] = 239, t3[r3++] = 191, t3[r3++] = 189, i3 = null);
  41975. n2 < 128 ? t3[r3++] = n2 : (n2 < 2048 ? t3[r3++] = n2 >> 6 | 192 : (n2 < 65536 ? t3[r3++] = n2 >> 12 | 224 : (t3[r3++] = n2 >> 18 | 240, t3[r3++] = n2 >> 12 & 63 | 128), t3[r3++] = n2 >> 6 & 63 | 128), t3[r3++] = 63 & n2 | 128);
  41976. }
  41977. return r3;
  41978. }(this.buf, t2, this.pos);
  41979. var r2 = this.pos - e2;
  41980. r2 >= 128 && zc(e2, r2, this), this.pos = e2 - 1, this.writeVarint(r2), this.pos += r2;
  41981. }, writeFloat: function(t2) {
  41982. this.realloc(4), _c(this.buf, t2, this.pos, true, 23, 4), this.pos += 4;
  41983. }, writeDouble: function(t2) {
  41984. this.realloc(8), _c(this.buf, t2, this.pos, true, 52, 8), this.pos += 8;
  41985. }, writeBytes: function(t2) {
  41986. var e2 = t2.length;
  41987. this.writeVarint(e2), this.realloc(e2);
  41988. for (var r2 = 0; r2 < e2; r2++)
  41989. this.buf[this.pos++] = t2[r2];
  41990. }, writeRawMessage: function(t2, e2) {
  41991. this.pos++;
  41992. var r2 = this.pos;
  41993. t2(e2, this);
  41994. var n2 = this.pos - r2;
  41995. n2 >= 128 && zc(r2, n2, this), this.pos = r2 - 1, this.writeVarint(n2), this.pos += n2;
  41996. }, writeMessage: function(t2, e2, r2) {
  41997. this.writeTag(t2, Ac.Bytes), this.writeRawMessage(e2, r2);
  41998. }, writePackedVarint: function(t2, e2) {
  41999. e2.length && this.writeMessage(t2, Bc, e2);
  42000. }, writePackedSVarint: function(t2, e2) {
  42001. e2.length && this.writeMessage(t2, Ec, e2);
  42002. }, writePackedBoolean: function(t2, e2) {
  42003. e2.length && this.writeMessage(t2, Pc, e2);
  42004. }, writePackedFloat: function(t2, e2) {
  42005. e2.length && this.writeMessage(t2, Cc, e2);
  42006. }, writePackedDouble: function(t2, e2) {
  42007. e2.length && this.writeMessage(t2, Dc, e2);
  42008. }, writePackedFixed32: function(t2, e2) {
  42009. e2.length && this.writeMessage(t2, Vc, e2);
  42010. }, writePackedSFixed32: function(t2, e2) {
  42011. e2.length && this.writeMessage(t2, Fc, e2);
  42012. }, writePackedFixed64: function(t2, e2) {
  42013. e2.length && this.writeMessage(t2, Lc, e2);
  42014. }, writePackedSFixed64: function(t2, e2) {
  42015. e2.length && this.writeMessage(t2, Rc, e2);
  42016. }, writeBytesField: function(t2, e2) {
  42017. this.writeTag(t2, Ac.Bytes), this.writeBytes(e2);
  42018. }, writeFixed32Field: function(t2, e2) {
  42019. this.writeTag(t2, Ac.Fixed32), this.writeFixed32(e2);
  42020. }, writeSFixed32Field: function(t2, e2) {
  42021. this.writeTag(t2, Ac.Fixed32), this.writeSFixed32(e2);
  42022. }, writeFixed64Field: function(t2, e2) {
  42023. this.writeTag(t2, Ac.Fixed64), this.writeFixed64(e2);
  42024. }, writeSFixed64Field: function(t2, e2) {
  42025. this.writeTag(t2, Ac.Fixed64), this.writeSFixed64(e2);
  42026. }, writeVarintField: function(t2, e2) {
  42027. this.writeTag(t2, Ac.Varint), this.writeVarint(e2);
  42028. }, writeSVarintField: function(t2, e2) {
  42029. this.writeTag(t2, Ac.Varint), this.writeSVarint(e2);
  42030. }, writeStringField: function(t2, e2) {
  42031. this.writeTag(t2, Ac.Bytes), this.writeString(e2);
  42032. }, writeFloatField: function(t2, e2) {
  42033. this.writeTag(t2, Ac.Fixed32), this.writeFloat(e2);
  42034. }, writeDoubleField: function(t2, e2) {
  42035. this.writeTag(t2, Ac.Fixed64), this.writeDouble(e2);
  42036. }, writeBooleanField: function(t2, e2) {
  42037. this.writeVarintField(t2, Boolean(e2));
  42038. } };
  42039. class Zc {
  42040. constructor(t2, { pixelRatio: e2, version: r2, stretchX: n2, stretchY: i3, content: s2 }) {
  42041. this.paddedRect = t2, this.pixelRatio = e2, this.stretchX = n2, this.stretchY = i3, this.content = s2, this.version = r2;
  42042. }
  42043. get tl() {
  42044. return [this.paddedRect.x + 1, this.paddedRect.y + 1];
  42045. }
  42046. get br() {
  42047. return [this.paddedRect.x + this.paddedRect.w - 1, this.paddedRect.y + this.paddedRect.h - 1];
  42048. }
  42049. get displaySize() {
  42050. return [(this.paddedRect.w - 2) / this.pixelRatio, (this.paddedRect.h - 2) / this.pixelRatio];
  42051. }
  42052. }
  42053. class Xc {
  42054. constructor(t2, e2) {
  42055. const r2 = {}, n2 = {};
  42056. this.haveRenderCallbacks = [];
  42057. const i3 = [];
  42058. this.addImages(t2, r2, i3), this.addImages(e2, n2, i3);
  42059. const { w: s2, h: a2 } = Gc(i3), o2 = new Bl({ width: s2 || 1, height: a2 || 1 });
  42060. for (const e3 in t2) {
  42061. const n3 = t2[e3], i4 = r2[e3].paddedRect;
  42062. Bl.copy(n3.data, o2, { x: 0, y: 0 }, { x: i4.x + 1, y: i4.y + 1 }, n3.data);
  42063. }
  42064. for (const t3 in e2) {
  42065. const r3 = e2[t3], i4 = n2[t3].paddedRect, s3 = i4.x + 1, a3 = i4.y + 1, l2 = r3.data.width, u2 = r3.data.height;
  42066. Bl.copy(r3.data, o2, { x: 0, y: 0 }, { x: s3, y: a3 }, r3.data), Bl.copy(r3.data, o2, { x: 0, y: u2 - 1 }, { x: s3, y: a3 - 1 }, { width: l2, height: 1 }), Bl.copy(r3.data, o2, { x: 0, y: 0 }, { x: s3, y: a3 + u2 }, { width: l2, height: 1 }), Bl.copy(r3.data, o2, { x: l2 - 1, y: 0 }, { x: s3 - 1, y: a3 }, { width: 1, height: u2 }), Bl.copy(r3.data, o2, { x: 0, y: 0 }, { x: s3 + l2, y: a3 }, { width: 1, height: u2 });
  42067. }
  42068. this.image = o2, this.iconPositions = r2, this.patternPositions = n2;
  42069. }
  42070. addImages(t2, e2, r2) {
  42071. for (const n2 in t2) {
  42072. const i3 = t2[n2], s2 = { x: 0, y: 0, w: i3.data.width + 2, h: i3.data.height + 2 };
  42073. r2.push(s2), e2[n2] = new Zc(s2, i3), i3.hasRenderCallback && this.haveRenderCallbacks.push(n2);
  42074. }
  42075. }
  42076. patchUpdatedImages(t2, e2) {
  42077. this.haveRenderCallbacks = this.haveRenderCallbacks.filter((e3) => t2.hasImage(e3)), t2.dispatchRenderCallbacks(this.haveRenderCallbacks);
  42078. for (const r2 in t2.updatedImages)
  42079. this.patchUpdatedImage(this.iconPositions[r2], t2.getImage(r2), e2), this.patchUpdatedImage(this.patternPositions[r2], t2.getImage(r2), e2);
  42080. }
  42081. patchUpdatedImage(t2, e2, r2) {
  42082. if (!t2 || !e2)
  42083. return;
  42084. if (t2.version === e2.version)
  42085. return;
  42086. t2.version = e2.version;
  42087. const [n2, i3] = t2.tl;
  42088. r2.update(e2.data, void 0, { x: n2, y: i3 });
  42089. }
  42090. }
  42091. ai(Zc, "ImagePosition"), ai(Xc, "ImageAtlas");
  42092. const Kc = { horizontal: 1, vertical: 2, horizontalOnly: 3 };
  42093. class Yc {
  42094. constructor() {
  42095. this.scale = 1, this.fontStack = "", this.imageName = null;
  42096. }
  42097. static forText(t2, e2) {
  42098. const r2 = new Yc();
  42099. return r2.scale = t2 || 1, r2.fontStack = e2, r2;
  42100. }
  42101. static forImage(t2) {
  42102. const e2 = new Yc();
  42103. return e2.imageName = t2, e2;
  42104. }
  42105. }
  42106. class Hc {
  42107. constructor() {
  42108. this.text = "", this.sectionIndex = [], this.sections = [], this.imageSectionID = null;
  42109. }
  42110. static fromFeature(t2, e2) {
  42111. const r2 = new Hc();
  42112. for (let n2 = 0; n2 < t2.sections.length; n2++) {
  42113. const i3 = t2.sections[n2];
  42114. i3.image ? r2.addImageSection(i3) : r2.addTextSection(i3, e2);
  42115. }
  42116. return r2;
  42117. }
  42118. length() {
  42119. return this.text.length;
  42120. }
  42121. getSection(t2) {
  42122. return this.sections[this.sectionIndex[t2]];
  42123. }
  42124. getSections() {
  42125. return this.sections;
  42126. }
  42127. getSectionIndex(t2) {
  42128. return this.sectionIndex[t2];
  42129. }
  42130. getCharCode(t2) {
  42131. return this.text.charCodeAt(t2);
  42132. }
  42133. verticalizePunctuation(t2) {
  42134. this.text = function(t3, e2) {
  42135. let r2 = "";
  42136. for (let n2 = 0; n2 < t3.length; n2++) {
  42137. const i3 = t3.charCodeAt(n2 + 1) || null, s2 = t3.charCodeAt(n2 - 1) || null;
  42138. r2 += !e2 && (i3 && qi(i3) && !gc[t3[n2 + 1]] || s2 && qi(s2) && !gc[t3[n2 - 1]]) || !gc[t3[n2]] ? t3[n2] : gc[t3[n2]];
  42139. }
  42140. return r2;
  42141. }(this.text, t2);
  42142. }
  42143. trim() {
  42144. let t2 = 0;
  42145. for (let e3 = 0; e3 < this.text.length && Jc[this.text.charCodeAt(e3)]; e3++)
  42146. t2++;
  42147. let e2 = this.text.length;
  42148. for (let r2 = this.text.length - 1; r2 >= 0 && r2 >= t2 && Jc[this.text.charCodeAt(r2)]; r2--)
  42149. e2--;
  42150. this.text = this.text.substring(t2, e2), this.sectionIndex = this.sectionIndex.slice(t2, e2);
  42151. }
  42152. substring(t2, e2) {
  42153. const r2 = new Hc();
  42154. return r2.text = this.text.substring(t2, e2), r2.sectionIndex = this.sectionIndex.slice(t2, e2), r2.sections = this.sections, r2;
  42155. }
  42156. toString() {
  42157. return this.text;
  42158. }
  42159. getMaxScale() {
  42160. return this.sectionIndex.reduce((t2, e2) => Math.max(t2, this.sections[e2].scale), 0);
  42161. }
  42162. addTextSection(t2, e2) {
  42163. this.text += t2.text, this.sections.push(Yc.forText(t2.scale, t2.fontStack || e2));
  42164. const r2 = this.sections.length - 1;
  42165. for (let e3 = 0; e3 < t2.text.length; ++e3)
  42166. this.sectionIndex.push(r2);
  42167. }
  42168. addImageSection(t2) {
  42169. const e2 = t2.image ? t2.image.name : "";
  42170. if (0 === e2.length)
  42171. return void C("Can't add FormattedSection with an empty image.");
  42172. const r2 = this.getNextImageSectionCharCode();
  42173. r2 ? (this.text += String.fromCharCode(r2), this.sections.push(Yc.forImage(e2)), this.sectionIndex.push(this.sections.length - 1)) : C("Reached maximum number of images 6401");
  42174. }
  42175. getNextImageSectionCharCode() {
  42176. return this.imageSectionID ? this.imageSectionID >= 63743 ? null : ++this.imageSectionID : (this.imageSectionID = 57344, this.imageSectionID);
  42177. }
  42178. }
  42179. function Wc(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2) {
  42180. const m2 = Hc.fromFeature(t2, i3);
  42181. let g2;
  42182. h2 === Kc.vertical && m2.verticalizePunctuation(p2);
  42183. const { processBidirectionalText: x2, processStyledBidirectionalText: v2 } = is;
  42184. if (x2 && 1 === m2.sections.length) {
  42185. g2 = [];
  42186. const t3 = x2(m2.toString(), sh(m2, u2, s2, e2, n2, f2, d2));
  42187. for (const e3 of t3) {
  42188. const t4 = new Hc();
  42189. t4.text = e3, t4.sections = m2.sections;
  42190. for (let r3 = 0; r3 < e3.length; r3++)
  42191. t4.sectionIndex.push(0);
  42192. g2.push(t4);
  42193. }
  42194. } else if (v2) {
  42195. g2 = [];
  42196. const t3 = v2(m2.text, m2.sectionIndex, sh(m2, u2, s2, e2, n2, f2, d2));
  42197. for (const e3 of t3) {
  42198. const t4 = new Hc();
  42199. t4.text = e3[0], t4.sectionIndex = e3[1], t4.sections = m2.sections, g2.push(t4);
  42200. }
  42201. } else
  42202. g2 = function(t3, e3) {
  42203. const r3 = [], n3 = t3.text;
  42204. let i4 = 0;
  42205. for (const n4 of e3)
  42206. r3.push(t3.substring(i4, n4)), i4 = n4;
  42207. return i4 < n3.length && r3.push(t3.substring(i4, n3.length)), r3;
  42208. }(m2, sh(m2, u2, s2, e2, n2, f2, d2));
  42209. const b2 = [], _2 = { positionedLines: b2, text: m2.toString(), top: c2[1], bottom: c2[1], left: c2[0], right: c2[0], writingMode: h2, iconsInText: false, verticalizable: false, hasBaseline: false };
  42210. return function(t3, e3, r3, n3, i4, s3, a3, o3, l3, u3, c3, h3) {
  42211. let p3 = 0, f3 = 0, d3 = 0;
  42212. const y3 = "right" === o3 ? 1 : "left" === o3 ? 0 : 0.5;
  42213. let m3 = false;
  42214. for (const t4 of i4) {
  42215. const r4 = t4.getSections();
  42216. for (const t5 of r4) {
  42217. if (t5.imageName)
  42218. continue;
  42219. const r5 = e3[t5.fontStack];
  42220. if (r5 && (m3 = void 0 !== r5.ascender && void 0 !== r5.descender, !m3))
  42221. break;
  42222. }
  42223. if (!m3)
  42224. break;
  42225. }
  42226. let g3 = 0;
  42227. for (const a4 of i4) {
  42228. a4.trim();
  42229. const i5 = a4.getMaxScale(), o4 = (i5 - 1) * cc, v4 = { positionedGlyphs: [], lineOffset: 0 };
  42230. t3.positionedLines[g3] = v4;
  42231. const b4 = v4.positionedGlyphs;
  42232. let _4 = 0;
  42233. if (!a4.length()) {
  42234. f3 += s3, ++g3;
  42235. continue;
  42236. }
  42237. let w2 = 0, A2 = 0;
  42238. for (let s4 = 0; s4 < a4.length(); s4++) {
  42239. const o5 = a4.getSection(s4), d4 = a4.getSectionIndex(s4), y4 = a4.getCharCode(s4);
  42240. let g4 = o5.scale, v5 = null, k3 = null, S2 = null, I2 = cc, M2 = 0;
  42241. const T2 = !(l3 === Kc.horizontal || !c3 && !Oi(y4) || c3 && (Jc[y4] || (x3 = y4, pi(x3) || fi(x3) || di(x3) || Di(x3) || Li(x3))));
  42242. if (o5.imageName) {
  42243. const e4 = n3[o5.imageName];
  42244. if (!e4)
  42245. continue;
  42246. S2 = o5.imageName, t3.iconsInText = t3.iconsInText || true, k3 = e4.paddedRect;
  42247. const r4 = e4.displaySize;
  42248. g4 = g4 * cc / h3, v5 = { width: r4[0], height: r4[1], left: 1, top: -3, advance: T2 ? r4[1] : r4[0], localGlyph: false }, M2 = m3 ? -v5.height * g4 : i5 * cc - 17 - r4[1] * g4, I2 = v5.advance;
  42249. const s5 = (T2 ? r4[0] : r4[1]) * g4 - cc * i5;
  42250. s5 > 0 && s5 > _4 && (_4 = s5);
  42251. } else {
  42252. const t4 = r3[o5.fontStack];
  42253. if (!t4)
  42254. continue;
  42255. t4[y4] && (k3 = t4[y4]);
  42256. const n4 = e3[o5.fontStack];
  42257. if (!n4)
  42258. continue;
  42259. const s5 = n4.glyphs[y4];
  42260. if (!s5)
  42261. continue;
  42262. if (v5 = s5.metrics, I2 = 8203 !== y4 ? cc : 0, m3) {
  42263. const t5 = void 0 !== n4.ascender ? Math.abs(n4.ascender) : 0, e4 = void 0 !== n4.descender ? Math.abs(n4.descender) : 0, r4 = (t5 + e4) * g4;
  42264. w2 < r4 && (w2 = r4, A2 = (t5 - e4) / 2 * g4), M2 = -t5 * g4;
  42265. } else
  42266. M2 = (i5 - g4) * cc - 17;
  42267. }
  42268. T2 ? (t3.verticalizable = true, b4.push({ glyph: y4, imageName: S2, x: p3, y: f3 + M2, vertical: T2, scale: g4, localGlyph: v5.localGlyph, fontStack: o5.fontStack, sectionIndex: d4, metrics: v5, rect: k3 }), p3 += I2 * g4 + u3) : (b4.push({ glyph: y4, imageName: S2, x: p3, y: f3 + M2, vertical: T2, scale: g4, localGlyph: v5.localGlyph, fontStack: o5.fontStack, sectionIndex: d4, metrics: v5, rect: k3 }), p3 += v5.advance * g4 + u3);
  42269. }
  42270. 0 !== b4.length && (d3 = Math.max(p3 - u3, d3), m3 ? oh(b4, y3, _4, A2, s3 * i5 / 2) : oh(b4, y3, _4, 0, s3 / 2)), p3 = 0;
  42271. const k2 = s3 * i5 + _4;
  42272. v4.lineOffset = Math.max(_4, o4), f3 += k2, ++g3;
  42273. }
  42274. var x3;
  42275. const v3 = f3, { horizontalAlign: b3, verticalAlign: _3 } = ah(a3);
  42276. (function(t4, e4, r4, n4, i5, s4) {
  42277. const a4 = (e4 - r4) * i5, o4 = -s4 * n4;
  42278. for (const e5 of t4)
  42279. for (const t5 of e5.positionedGlyphs)
  42280. t5.x += a4, t5.y += o4;
  42281. })(t3.positionedLines, y3, b3, _3, d3, v3), t3.top += -_3 * v3, t3.bottom = t3.top + v3, t3.left += -b3 * d3, t3.right = t3.left + d3, t3.hasBaseline = m3;
  42282. }(_2, e2, r2, n2, g2, a2, o2, l2, h2, u2, p2, y2), !function(t3) {
  42283. for (const e3 of t3)
  42284. if (0 !== e3.positionedGlyphs.length)
  42285. return false;
  42286. return true;
  42287. }(b2) && _2;
  42288. }
  42289. const Jc = { 9: true, 10: true, 11: true, 12: true, 13: true, 32: true }, Qc = { 10: true, 32: true, 38: true, 40: true, 41: true, 43: true, 45: true, 47: true, 173: true, 183: true, 8203: true, 8208: true, 8211: true, 8231: true };
  42290. function th(t2, e2, r2, n2, i3, s2) {
  42291. if (e2.imageName) {
  42292. const t3 = n2[e2.imageName];
  42293. return t3 ? t3.displaySize[0] * e2.scale * cc / s2 + i3 : 0;
  42294. }
  42295. {
  42296. const n3 = r2[e2.fontStack], s3 = n3 && n3.glyphs[t2];
  42297. return s3 ? s3.metrics.advance * e2.scale + i3 : 0;
  42298. }
  42299. }
  42300. function eh(t2, e2, r2, n2) {
  42301. const i3 = Math.pow(t2 - e2, 2);
  42302. return n2 ? t2 < e2 ? i3 / 2 : 2 * i3 : i3 + Math.abs(r2) * r2;
  42303. }
  42304. function rh(t2, e2, r2) {
  42305. let n2 = 0;
  42306. return 10 === t2 && (n2 -= 1e4), r2 && (n2 += 150), 40 !== t2 && 65288 !== t2 || (n2 += 50), 41 !== e2 && 65289 !== e2 || (n2 += 50), n2;
  42307. }
  42308. function nh(t2, e2, r2, n2, i3, s2) {
  42309. let a2 = null, o2 = eh(e2, r2, i3, s2);
  42310. for (const t3 of n2) {
  42311. const n3 = eh(e2 - t3.x, r2, i3, s2) + t3.badness;
  42312. n3 <= o2 && (a2 = t3, o2 = n3);
  42313. }
  42314. return { index: t2, x: e2, priorBreak: a2, badness: o2 };
  42315. }
  42316. function ih(t2) {
  42317. return t2 ? ih(t2.priorBreak).concat(t2.index) : [];
  42318. }
  42319. function sh(t2, e2, r2, n2, i3, s2, a2) {
  42320. if ("point" !== s2)
  42321. return [];
  42322. if (!t2)
  42323. return [];
  42324. const o2 = [], l2 = function(t3, e3, r3, n3, i4, s3) {
  42325. let a3 = 0;
  42326. for (let r4 = 0; r4 < t3.length(); r4++) {
  42327. const o3 = t3.getSection(r4);
  42328. a3 += th(t3.getCharCode(r4), o3, n3, i4, e3, s3);
  42329. }
  42330. return a3 / Math.max(1, Math.ceil(a3 / r3));
  42331. }(t2, e2, r2, n2, i3, a2), u2 = t2.text.indexOf("​") >= 0;
  42332. let c2 = 0;
  42333. for (let r3 = 0; r3 < t2.length(); r3++) {
  42334. const s3 = t2.getSection(r3), p2 = t2.getCharCode(r3);
  42335. if (Jc[p2] || (c2 += th(p2, s3, n2, i3, e2, a2)), r3 < t2.length() - 1) {
  42336. const e3 = !((h2 = p2) < 11904 || !(wi(h2) || _i(h2) || Vi(h2) || Ci(h2) || Ii(h2) || yi(h2) || Ai(h2) || xi(h2) || Mi(h2) || Ti(h2) || Si(h2) || Ri(h2) || vi(h2) || gi(h2) || mi(h2) || ki(h2) || bi(h2) || Pi(h2) || Bi(h2) || zi(h2)));
  42337. (Qc[p2] || e3 || s3.imageName) && o2.push(nh(r3 + 1, c2, l2, o2, rh(p2, t2.getCharCode(r3 + 1), e3 && u2), false));
  42338. }
  42339. }
  42340. var h2;
  42341. return ih(nh(t2.length(), c2, l2, o2, 0, true));
  42342. }
  42343. function ah(t2) {
  42344. let e2 = 0.5, r2 = 0.5;
  42345. switch (t2) {
  42346. case "right":
  42347. case "top-right":
  42348. case "bottom-right":
  42349. e2 = 1;
  42350. break;
  42351. case "left":
  42352. case "top-left":
  42353. case "bottom-left":
  42354. e2 = 0;
  42355. }
  42356. switch (t2) {
  42357. case "bottom":
  42358. case "bottom-right":
  42359. case "bottom-left":
  42360. r2 = 1;
  42361. break;
  42362. case "top":
  42363. case "top-right":
  42364. case "top-left":
  42365. r2 = 0;
  42366. }
  42367. return { horizontalAlign: e2, verticalAlign: r2 };
  42368. }
  42369. function oh(t2, e2, r2, n2, i3) {
  42370. if (!(e2 || r2 || n2 || i3))
  42371. return;
  42372. const s2 = t2.length - 1, a2 = t2[s2], o2 = (a2.x + a2.metrics.advance * a2.scale) * e2;
  42373. for (let e3 = 0; e3 <= s2; e3++)
  42374. t2[e3].x -= o2, t2[e3].y += r2 + n2 + i3;
  42375. }
  42376. function lh(t2, e2, r2) {
  42377. const { horizontalAlign: n2, verticalAlign: i3 } = ah(r2), s2 = e2[0] - t2.displaySize[0] * n2, a2 = e2[1] - t2.displaySize[1] * i3;
  42378. return { image: t2, top: a2, bottom: a2 + t2.displaySize[1], left: s2, right: s2 + t2.displaySize[0] };
  42379. }
  42380. function uh(t2, e2, r2, n2, i3, s2) {
  42381. const a2 = t2.image;
  42382. let o2;
  42383. if (a2.content) {
  42384. const t3 = a2.content, e3 = a2.pixelRatio || 1;
  42385. o2 = [t3[0] / e3, t3[1] / e3, a2.displaySize[0] - t3[2] / e3, a2.displaySize[1] - t3[3] / e3];
  42386. }
  42387. const l2 = e2.left * s2, u2 = e2.right * s2;
  42388. let c2, h2, p2, f2;
  42389. "width" === r2 || "both" === r2 ? (f2 = i3[0] + l2 - n2[3], h2 = i3[0] + u2 + n2[1]) : (f2 = i3[0] + (l2 + u2 - a2.displaySize[0]) / 2, h2 = f2 + a2.displaySize[0]);
  42390. const d2 = e2.top * s2, y2 = e2.bottom * s2;
  42391. return "height" === r2 || "both" === r2 ? (c2 = i3[1] + d2 - n2[0], p2 = i3[1] + y2 + n2[2]) : (c2 = i3[1] + (d2 + y2 - a2.displaySize[1]) / 2, p2 = c2 + a2.displaySize[1]), { image: a2, top: c2, right: h2, bottom: p2, left: f2, collisionPadding: o2 };
  42392. }
  42393. class ch extends i2 {
  42394. constructor(t2, e2, r2, n2, i3) {
  42395. super(t2, e2), this.angle = n2, this.z = r2, void 0 !== i3 && (this.segment = i3);
  42396. }
  42397. clone() {
  42398. return new ch(this.x, this.y, this.z, this.angle, this.segment);
  42399. }
  42400. }
  42401. function hh(t2, e2, r2, n2, i3) {
  42402. if (void 0 === e2.segment)
  42403. return true;
  42404. let s2 = e2, a2 = e2.segment + 1, o2 = 0;
  42405. for (; o2 > -r2 / 2; ) {
  42406. if (a2--, a2 < 0)
  42407. return false;
  42408. o2 -= t2[a2].dist(s2), s2 = t2[a2];
  42409. }
  42410. o2 += t2[a2].dist(t2[a2 + 1]), a2++;
  42411. const l2 = [];
  42412. let u2 = 0;
  42413. for (; o2 < r2 / 2; ) {
  42414. const e3 = t2[a2], r3 = t2[a2 + 1];
  42415. if (!r3)
  42416. return false;
  42417. let s3 = t2[a2 - 1].angleTo(e3) - e3.angleTo(r3);
  42418. for (s3 = Math.abs((s3 + 3 * Math.PI) % (2 * Math.PI) - Math.PI), l2.push({ distance: o2, angleDelta: s3 }), u2 += s3; o2 - l2[0].distance > n2; )
  42419. u2 -= l2.shift().angleDelta;
  42420. if (u2 > i3)
  42421. return false;
  42422. a2++, o2 += e3.dist(r3);
  42423. }
  42424. return true;
  42425. }
  42426. function ph(t2) {
  42427. let e2 = 0;
  42428. for (let r2 = 0; r2 < t2.length - 1; r2++)
  42429. e2 += t2[r2].dist(t2[r2 + 1]);
  42430. return e2;
  42431. }
  42432. function fh(t2, e2, r2) {
  42433. return t2 ? 0.6 * e2 * r2 : 0;
  42434. }
  42435. function dh(t2, e2) {
  42436. return Math.max(t2 ? t2.right - t2.left : 0, e2 ? e2.right - e2.left : 0);
  42437. }
  42438. function yh(t2, e2, r2, n2, i3, s2) {
  42439. const a2 = fh(r2, i3, s2), o2 = dh(r2, n2) * s2;
  42440. let l2 = 0;
  42441. const u2 = ph(t2) / 2;
  42442. for (let r3 = 0; r3 < t2.length - 1; r3++) {
  42443. const n3 = t2[r3], i4 = t2[r3 + 1], s3 = n3.dist(i4);
  42444. if (l2 + s3 > u2) {
  42445. const c2 = (u2 - l2) / s3, h2 = rr(n3.x, i4.x, c2), p2 = rr(n3.y, i4.y, c2), f2 = new ch(h2, p2, 0, i4.angleTo(n3), r3);
  42446. return !a2 || hh(t2, f2, o2, a2, e2) ? f2 : void 0;
  42447. }
  42448. l2 += s3;
  42449. }
  42450. }
  42451. function mh(t2, e2, r2, n2, i3, s2, a2, o2, l2) {
  42452. const u2 = fh(n2, s2, a2), c2 = dh(n2, i3), h2 = c2 * a2, p2 = 0 === t2[0].x || t2[0].x === l2 || 0 === t2[0].y || t2[0].y === l2;
  42453. return e2 - h2 < e2 / 4 && (e2 = h2 + e2 / 4), gh(t2, p2 ? e2 / 2 * o2 % e2 : (c2 / 2 + 2 * s2) * a2 * o2 % e2, e2, u2, r2, h2, p2, false, l2);
  42454. }
  42455. function gh(t2, e2, r2, n2, i3, s2, a2, o2, l2) {
  42456. const u2 = s2 / 2, c2 = ph(t2);
  42457. let h2 = 0, p2 = e2 - r2, f2 = [];
  42458. for (let e3 = 0; e3 < t2.length - 1; e3++) {
  42459. const a3 = t2[e3], o3 = t2[e3 + 1], d2 = a3.dist(o3), y2 = o3.angleTo(a3);
  42460. for (; p2 + r2 < h2 + d2; ) {
  42461. p2 += r2;
  42462. const m2 = (p2 - h2) / d2, g2 = rr(a3.x, o3.x, m2), x2 = rr(a3.y, o3.y, m2);
  42463. if (g2 >= 0 && g2 < l2 && x2 >= 0 && x2 < l2 && p2 - u2 >= 0 && p2 + u2 <= c2) {
  42464. const r3 = new ch(g2, x2, 0, y2, e3);
  42465. r3._round(), n2 && !hh(t2, r3, s2, n2, i3) || f2.push(r3);
  42466. }
  42467. }
  42468. h2 += d2;
  42469. }
  42470. return o2 || f2.length || a2 || (f2 = gh(t2, h2 / 2, r2, n2, i3, s2, a2, true, l2)), f2;
  42471. }
  42472. function xh(t2, e2, r2, n2, s2) {
  42473. const a2 = [];
  42474. for (let o2 = 0; o2 < t2.length; o2++) {
  42475. const l2 = t2[o2];
  42476. let u2;
  42477. for (let t3 = 0; t3 < l2.length - 1; t3++) {
  42478. let o3 = l2[t3], c2 = l2[t3 + 1];
  42479. o3.x < e2 && c2.x < e2 || (o3.x < e2 ? o3 = new i2(e2, o3.y + (e2 - o3.x) / (c2.x - o3.x) * (c2.y - o3.y))._round() : c2.x < e2 && (c2 = new i2(e2, o3.y + (e2 - o3.x) / (c2.x - o3.x) * (c2.y - o3.y))._round()), o3.y < r2 && c2.y < r2 || (o3.y < r2 ? o3 = new i2(o3.x + (r2 - o3.y) / (c2.y - o3.y) * (c2.x - o3.x), r2)._round() : c2.y < r2 && (c2 = new i2(o3.x + (r2 - o3.y) / (c2.y - o3.y) * (c2.x - o3.x), r2)._round()), o3.x >= n2 && c2.x >= n2 || (o3.x >= n2 ? o3 = new i2(n2, o3.y + (n2 - o3.x) / (c2.x - o3.x) * (c2.y - o3.y))._round() : c2.x >= n2 && (c2 = new i2(n2, o3.y + (n2 - o3.x) / (c2.x - o3.x) * (c2.y - o3.y))._round()), o3.y >= s2 && c2.y >= s2 || (o3.y >= s2 ? o3 = new i2(o3.x + (s2 - o3.y) / (c2.y - o3.y) * (c2.x - o3.x), s2)._round() : c2.y >= s2 && (c2 = new i2(o3.x + (s2 - o3.y) / (c2.y - o3.y) * (c2.x - o3.x), s2)._round()), u2 && o3.equals(u2[u2.length - 1]) || (u2 = [o3], a2.push(u2)), u2.push(c2)))));
  42480. }
  42481. }
  42482. return a2;
  42483. }
  42484. ai(ch, "Anchor");
  42485. const vh = 1e20;
  42486. function bh(t2, e2, r2, n2, i3, s2, a2, o2, l2) {
  42487. for (let u2 = e2; u2 < e2 + n2; u2++)
  42488. _h(t2, r2 * s2 + u2, s2, i3, a2, o2, l2);
  42489. for (let u2 = r2; u2 < r2 + i3; u2++)
  42490. _h(t2, u2 * s2 + e2, 1, n2, a2, o2, l2);
  42491. }
  42492. function _h(t2, e2, r2, n2, i3, s2, a2) {
  42493. s2[0] = 0, a2[0] = -vh, a2[1] = vh, i3[0] = t2[e2];
  42494. for (let o2 = 1, l2 = 0, u2 = 0; o2 < n2; o2++) {
  42495. i3[o2] = t2[e2 + o2 * r2];
  42496. const n3 = o2 * o2;
  42497. do {
  42498. const t3 = s2[l2];
  42499. u2 = (i3[o2] - i3[t3] + n3 - t3 * t3) / (o2 - t3) / 2;
  42500. } while (u2 <= a2[l2] && --l2 > -1);
  42501. l2++, s2[l2] = o2, a2[l2] = u2, a2[l2 + 1] = vh;
  42502. }
  42503. for (let o2 = 0, l2 = 0; o2 < n2; o2++) {
  42504. for (; a2[l2 + 1] < o2; )
  42505. l2++;
  42506. const n3 = s2[l2], u2 = o2 - n3;
  42507. t2[e2 + o2 * r2] = i3[n3] + u2 * u2;
  42508. }
  42509. }
  42510. const wh = { none: 0, ideographs: 1, all: 2 };
  42511. class Ah {
  42512. constructor(t2, e2, r2) {
  42513. this.requestManager = t2, this.localGlyphMode = e2, this.localFontFamily = r2, this.entries = {}, this.localGlyphs = { 200: {}, 400: {}, 500: {}, 900: {} };
  42514. }
  42515. setURL(t2) {
  42516. this.url = t2;
  42517. }
  42518. getGlyphs(t2, e2) {
  42519. const r2 = [];
  42520. for (const e3 in t2)
  42521. for (const n2 of t2[e3])
  42522. r2.push({ stack: e3, id: n2 });
  42523. x(r2, ({ stack: t3, id: e3 }, r3) => {
  42524. let n2 = this.entries[t3];
  42525. n2 || (n2 = this.entries[t3] = { glyphs: {}, requests: {}, ranges: {}, ascender: void 0, descender: void 0 });
  42526. let i3 = n2.glyphs[e3];
  42527. if (void 0 !== i3)
  42528. return void r3(null, { stack: t3, id: e3, glyph: i3 });
  42529. if (i3 = this._tinySDF(n2, t3, e3), i3)
  42530. return n2.glyphs[e3] = i3, void r3(null, { stack: t3, id: e3, glyph: i3 });
  42531. const s2 = Math.floor(e3 / 256);
  42532. if (256 * s2 > 65535)
  42533. return void r3(new Error("glyphs > 65535 not supported"));
  42534. if (n2.ranges[s2])
  42535. return void r3(null, { stack: t3, id: e3, glyph: i3 });
  42536. let a2 = n2.requests[s2];
  42537. a2 || (a2 = n2.requests[s2] = [], Ah.loadGlyphRange(t3, s2, this.url, this.requestManager, (t4, e4) => {
  42538. if (e4) {
  42539. n2.ascender = e4.ascender, n2.descender = e4.descender;
  42540. for (const t5 in e4.glyphs)
  42541. this._doesCharSupportLocalGlyph(+t5) || (n2.glyphs[+t5] = e4.glyphs[+t5]);
  42542. n2.ranges[s2] = true;
  42543. }
  42544. for (const r4 of a2)
  42545. r4(t4, e4);
  42546. delete n2.requests[s2];
  42547. })), a2.push((n3, i4) => {
  42548. n3 ? r3(n3) : i4 && r3(null, { stack: t3, id: e3, glyph: i4.glyphs[e3] || null });
  42549. });
  42550. }, (t3, r3) => {
  42551. if (t3)
  42552. e2(t3);
  42553. else if (r3) {
  42554. const t4 = {};
  42555. for (const { stack: e3, id: n2, glyph: i3 } of r3)
  42556. void 0 === t4[e3] && (t4[e3] = {}), void 0 === t4[e3].glyphs && (t4[e3].glyphs = {}), t4[e3].glyphs[n2] = i3 && { id: i3.id, bitmap: i3.bitmap.clone(), metrics: i3.metrics }, t4[e3].ascender = this.entries[e3].ascender, t4[e3].descender = this.entries[e3].descender;
  42557. e2(null, t4);
  42558. }
  42559. });
  42560. }
  42561. _doesCharSupportLocalGlyph(t2) {
  42562. return this.localGlyphMode !== wh.none && (this.localGlyphMode === wh.all ? !!this.localFontFamily : !!this.localFontFamily && (Ti(t2) || Ei(t2) || vi(t2) || bi(t2) || xi(t2)));
  42563. }
  42564. _tinySDF(t2, e2, r2) {
  42565. const n2 = this.localFontFamily;
  42566. if (!n2 || !this._doesCharSupportLocalGlyph(r2))
  42567. return;
  42568. let i3 = t2.tinySDF;
  42569. if (!i3) {
  42570. let r3 = "400";
  42571. /bold/i.test(e2) ? r3 = "900" : /medium/i.test(e2) ? r3 = "500" : /light/i.test(e2) && (r3 = "200"), i3 = t2.tinySDF = new Ah.TinySDF({ fontFamily: n2, fontWeight: r3, fontSize: 48, buffer: 6, radius: 16 }), i3.fontWeight = r3;
  42572. }
  42573. if (this.localGlyphs[i3.fontWeight][r2])
  42574. return this.localGlyphs[i3.fontWeight][r2];
  42575. const s2 = String.fromCharCode(r2), { data: a2, width: o2, height: l2, glyphWidth: u2, glyphHeight: c2, glyphLeft: h2, glyphTop: p2, glyphAdvance: f2 } = i3.draw(s2);
  42576. return this.localGlyphs[i3.fontWeight][r2] = { id: r2, bitmap: new zl({ width: o2, height: l2 }, a2), metrics: { width: u2 / 2, height: c2 / 2, left: h2 / 2, top: p2 / 2 - 27, advance: f2 / 2, localGlyph: true } };
  42577. }
  42578. }
  42579. function kh(t2, e2, r2, n2) {
  42580. const s2 = [], a2 = t2.image, o2 = a2.pixelRatio, l2 = a2.paddedRect.w - 2, u2 = a2.paddedRect.h - 2, c2 = t2.right - t2.left, h2 = t2.bottom - t2.top, p2 = a2.stretchX || [[0, l2]], f2 = a2.stretchY || [[0, u2]], d2 = (t3, e3) => t3 + e3[1] - e3[0], y2 = p2.reduce(d2, 0), m2 = f2.reduce(d2, 0), g2 = l2 - y2, x2 = u2 - m2;
  42581. let v2 = 0, b2 = y2, _2 = 0, w2 = m2, A2 = 0, k2 = g2, S2 = 0, I2 = x2;
  42582. if (a2.content && n2) {
  42583. const t3 = a2.content;
  42584. v2 = Sh(p2, 0, t3[0]), _2 = Sh(f2, 0, t3[1]), b2 = Sh(p2, t3[0], t3[2]), w2 = Sh(f2, t3[1], t3[3]), A2 = t3[0] - v2, S2 = t3[1] - _2, k2 = t3[2] - t3[0] - b2, I2 = t3[3] - t3[1] - w2;
  42585. }
  42586. const M2 = (n3, s3, l3, u3) => {
  42587. const p3 = Mh(n3.stretch - v2, b2, c2, t2.left), f3 = Th(n3.fixed - A2, k2, n3.stretch, y2), d3 = Mh(s3.stretch - _2, w2, h2, t2.top), g3 = Th(s3.fixed - S2, I2, s3.stretch, m2), x3 = Mh(l3.stretch - v2, b2, c2, t2.left), M3 = Th(l3.fixed - A2, k2, l3.stretch, y2), T2 = Mh(u3.stretch - _2, w2, h2, t2.top), z2 = Th(u3.fixed - S2, I2, u3.stretch, m2), B2 = new i2(p3, d3), E2 = new i2(x3, d3), C2 = new i2(x3, T2), D2 = new i2(p3, T2), P2 = new i2(f3 / o2, g3 / o2), V2 = new i2(M3 / o2, z2 / o2), F2 = e2 * Math.PI / 180;
  42588. if (F2) {
  42589. const t3 = Math.sin(F2), e3 = Math.cos(F2), r3 = [e3, -t3, t3, e3];
  42590. B2._matMult(r3), E2._matMult(r3), D2._matMult(r3), C2._matMult(r3);
  42591. }
  42592. const L2 = n3.stretch + n3.fixed, R2 = s3.stretch + s3.fixed;
  42593. return { tl: B2, tr: E2, bl: D2, br: C2, tex: { x: a2.paddedRect.x + 1 + L2, y: a2.paddedRect.y + 1 + R2, w: l3.stretch + l3.fixed - L2, h: u3.stretch + u3.fixed - R2 }, writingMode: void 0, glyphOffset: [0, 0], sectionIndex: 0, pixelOffsetTL: P2, pixelOffsetBR: V2, minFontScaleX: k2 / o2 / c2, minFontScaleY: I2 / o2 / h2, isSDF: r2 };
  42594. };
  42595. if (n2 && (a2.stretchX || a2.stretchY)) {
  42596. const t3 = Ih(p2, g2, y2), e3 = Ih(f2, x2, m2);
  42597. for (let r3 = 0; r3 < t3.length - 1; r3++) {
  42598. const n3 = t3[r3], i3 = t3[r3 + 1];
  42599. for (let t4 = 0; t4 < e3.length - 1; t4++)
  42600. s2.push(M2(n3, e3[t4], i3, e3[t4 + 1]));
  42601. }
  42602. } else
  42603. s2.push(M2({ fixed: 0, stretch: -1 }, { fixed: 0, stretch: -1 }, { fixed: 0, stretch: l2 + 1 }, { fixed: 0, stretch: u2 + 1 }));
  42604. return s2;
  42605. }
  42606. function Sh(t2, e2, r2) {
  42607. let n2 = 0;
  42608. for (const i3 of t2)
  42609. n2 += Math.max(e2, Math.min(r2, i3[1])) - Math.max(e2, Math.min(r2, i3[0]));
  42610. return n2;
  42611. }
  42612. function Ih(t2, e2, r2) {
  42613. const n2 = [{ fixed: -1, stretch: 0 }];
  42614. for (const [e3, r3] of t2) {
  42615. const t3 = n2[n2.length - 1];
  42616. n2.push({ fixed: e3 - t3.stretch, stretch: t3.stretch }), n2.push({ fixed: e3 - t3.stretch, stretch: t3.stretch + (r3 - e3) });
  42617. }
  42618. return n2.push({ fixed: e2 + 1, stretch: r2 }), n2;
  42619. }
  42620. function Mh(t2, e2, r2, n2) {
  42621. return t2 / e2 * r2 + n2;
  42622. }
  42623. function Th(t2, e2, r2, n2) {
  42624. return t2 - e2 * r2 / n2;
  42625. }
  42626. function zh(t2, e2, r2, n2) {
  42627. const i3 = e2 + t2.positionedLines[n2].lineOffset;
  42628. return 0 === n2 ? r2 + i3 / 2 : r2 + (i3 + (e2 + t2.positionedLines[n2 - 1].lineOffset)) / 2;
  42629. }
  42630. Ah.loadGlyphRange = function(t2, e2, r2, n2, i3) {
  42631. const s2 = 256 * e2, a2 = s2 + 255, o2 = n2.transformRequest(n2.normalizeGlyphsURL(r2).replace("{fontstack}", t2).replace("{range}", `${s2}-${a2}`), At.Glyphs);
  42632. Mt(o2, (t3, e3) => {
  42633. if (t3)
  42634. i3(t3);
  42635. else if (e3) {
  42636. const t4 = {}, r3 = function(t5) {
  42637. return new wc(t5).readFields(Oc, {});
  42638. }(e3);
  42639. for (const e4 of r3.glyphs)
  42640. t4[e4.id] = e4;
  42641. i3(null, { glyphs: t4, ascender: r3.ascender, descender: r3.descender });
  42642. }
  42643. });
  42644. }, Ah.TinySDF = class {
  42645. constructor({ fontSize: t2 = 24, buffer: e2 = 3, radius: r2 = 8, cutoff: n2 = 0.25, fontFamily: i3 = "sans-serif", fontWeight: s2 = "normal", fontStyle: a2 = "normal" }) {
  42646. this.buffer = e2, this.cutoff = n2, this.radius = r2;
  42647. const o2 = this.size = t2 + 4 * e2, l2 = this._createCanvas(o2), u2 = this.ctx = l2.getContext("2d", { willReadFrequently: true });
  42648. u2.font = `${a2} ${s2} ${t2}px ${i3}`, u2.textBaseline = "alphabetic", u2.textAlign = "left", u2.fillStyle = "black", this.gridOuter = new Float64Array(o2 * o2), this.gridInner = new Float64Array(o2 * o2), this.f = new Float64Array(o2), this.z = new Float64Array(o2 + 1), this.v = new Uint16Array(o2);
  42649. }
  42650. _createCanvas(t2) {
  42651. const e2 = document.createElement("canvas");
  42652. return e2.width = e2.height = t2, e2;
  42653. }
  42654. draw(t2) {
  42655. const { width: e2, actualBoundingBoxAscent: r2, actualBoundingBoxDescent: n2, actualBoundingBoxLeft: i3, actualBoundingBoxRight: s2 } = this.ctx.measureText(t2), a2 = Math.floor(r2), o2 = Math.min(this.size - this.buffer, Math.ceil(s2 - i3)), l2 = Math.min(this.size - this.buffer, Math.ceil(r2) + Math.ceil(n2)), u2 = o2 + 2 * this.buffer, c2 = l2 + 2 * this.buffer, h2 = u2 * c2, p2 = new Uint8ClampedArray(h2), f2 = { data: p2, width: u2, height: c2, glyphWidth: o2, glyphHeight: l2, glyphTop: a2, glyphLeft: 0, glyphAdvance: e2 };
  42656. if (0 === o2 || 0 === l2)
  42657. return f2;
  42658. const { ctx: d2, buffer: y2, gridInner: m2, gridOuter: g2 } = this;
  42659. d2.clearRect(y2, y2, o2, l2), d2.fillText(t2, y2, y2 + a2 + 1);
  42660. const x2 = d2.getImageData(y2, y2, o2, l2);
  42661. g2.fill(vh, 0, h2), m2.fill(0, 0, h2);
  42662. for (let t3 = 0; t3 < l2; t3++)
  42663. for (let e3 = 0; e3 < o2; e3++) {
  42664. const r3 = x2.data[4 * (t3 * o2 + e3) + 3] / 255;
  42665. if (0 === r3)
  42666. continue;
  42667. const n3 = (t3 + y2) * u2 + e3 + y2;
  42668. if (1 === r3)
  42669. g2[n3] = 0, m2[n3] = vh;
  42670. else {
  42671. const t4 = 0.5 - r3;
  42672. g2[n3] = t4 > 0 ? t4 * t4 : 0, m2[n3] = t4 < 0 ? t4 * t4 : 0;
  42673. }
  42674. }
  42675. bh(g2, 0, 0, u2, c2, u2, this.f, this.v, this.z), bh(m2, y2, y2, o2, l2, u2, this.f, this.v, this.z);
  42676. for (let t3 = 0; t3 < h2; t3++) {
  42677. const e3 = Math.sqrt(g2[t3]) - Math.sqrt(m2[t3]);
  42678. p2[t3] = Math.round(255 - 255 * (e3 / this.radius + this.cutoff));
  42679. }
  42680. return f2;
  42681. }
  42682. };
  42683. class Bh {
  42684. constructor(t2 = [], e2 = Eh) {
  42685. if (this.data = t2, this.length = this.data.length, this.compare = e2, this.length > 0)
  42686. for (let t3 = (this.length >> 1) - 1; t3 >= 0; t3--)
  42687. this._down(t3);
  42688. }
  42689. push(t2) {
  42690. this.data.push(t2), this.length++, this._up(this.length - 1);
  42691. }
  42692. pop() {
  42693. if (0 === this.length)
  42694. return;
  42695. const t2 = this.data[0], e2 = this.data.pop();
  42696. return this.length--, this.length > 0 && (this.data[0] = e2, this._down(0)), t2;
  42697. }
  42698. peek() {
  42699. return this.data[0];
  42700. }
  42701. _up(t2) {
  42702. const { data: e2, compare: r2 } = this, n2 = e2[t2];
  42703. for (; t2 > 0; ) {
  42704. const i3 = t2 - 1 >> 1, s2 = e2[i3];
  42705. if (r2(n2, s2) >= 0)
  42706. break;
  42707. e2[t2] = s2, t2 = i3;
  42708. }
  42709. e2[t2] = n2;
  42710. }
  42711. _down(t2) {
  42712. const { data: e2, compare: r2 } = this, n2 = this.length >> 1, i3 = e2[t2];
  42713. for (; t2 < n2; ) {
  42714. let n3 = 1 + (t2 << 1), s2 = e2[n3];
  42715. const a2 = n3 + 1;
  42716. if (a2 < this.length && r2(e2[a2], s2) < 0 && (n3 = a2, s2 = e2[a2]), r2(s2, i3) >= 0)
  42717. break;
  42718. e2[t2] = s2, t2 = n3;
  42719. }
  42720. e2[t2] = i3;
  42721. }
  42722. }
  42723. function Eh(t2, e2) {
  42724. return t2 < e2 ? -1 : t2 > e2 ? 1 : 0;
  42725. }
  42726. function Ch(t2, e2 = 1, r2 = false) {
  42727. let n2 = 1 / 0, s2 = 1 / 0, a2 = -1 / 0, o2 = -1 / 0;
  42728. const l2 = t2[0];
  42729. for (let t3 = 0; t3 < l2.length; t3++) {
  42730. const e3 = l2[t3];
  42731. (!t3 || e3.x < n2) && (n2 = e3.x), (!t3 || e3.y < s2) && (s2 = e3.y), (!t3 || e3.x > a2) && (a2 = e3.x), (!t3 || e3.y > o2) && (o2 = e3.y);
  42732. }
  42733. const u2 = Math.min(a2 - n2, o2 - s2);
  42734. let c2 = u2 / 2;
  42735. const h2 = new Bh([], Dh);
  42736. if (0 === u2)
  42737. return new i2(n2, s2);
  42738. for (let e3 = n2; e3 < a2; e3 += u2)
  42739. for (let r3 = s2; r3 < o2; r3 += u2)
  42740. h2.push(new Ph(e3 + c2, r3 + c2, c2, t2));
  42741. let p2 = function(t3) {
  42742. let e3 = 0, r3 = 0, n3 = 0;
  42743. const i3 = t3[0];
  42744. for (let t4 = 0, s3 = i3.length, a3 = s3 - 1; t4 < s3; a3 = t4++) {
  42745. const s4 = i3[t4], o3 = i3[a3], l3 = s4.x * o3.y - o3.x * s4.y;
  42746. r3 += (s4.x + o3.x) * l3, n3 += (s4.y + o3.y) * l3, e3 += 3 * l3;
  42747. }
  42748. return new Ph(r3 / e3, n3 / e3, 0, t3);
  42749. }(t2), f2 = h2.length;
  42750. for (; h2.length; ) {
  42751. const n3 = h2.pop();
  42752. (n3.d > p2.d || !p2.d) && (p2 = n3, r2 && console.log("found best %d after %d probes", Math.round(1e4 * n3.d) / 1e4, f2)), n3.max - p2.d <= e2 || (c2 = n3.h / 2, h2.push(new Ph(n3.p.x - c2, n3.p.y - c2, c2, t2)), h2.push(new Ph(n3.p.x + c2, n3.p.y - c2, c2, t2)), h2.push(new Ph(n3.p.x - c2, n3.p.y + c2, c2, t2)), h2.push(new Ph(n3.p.x + c2, n3.p.y + c2, c2, t2)), f2 += 4);
  42753. }
  42754. return r2 && (console.log(`num probes: ${f2}`), console.log(`best distance: ${p2.d}`)), p2.p;
  42755. }
  42756. function Dh(t2, e2) {
  42757. return e2.max - t2.max;
  42758. }
  42759. function Ph(t2, e2, r2, n2) {
  42760. this.p = new i2(t2, e2), this.h = r2, this.d = function(t3, e3) {
  42761. let r3 = false, n3 = 1 / 0;
  42762. for (let i3 = 0; i3 < e3.length; i3++) {
  42763. const s2 = e3[i3];
  42764. for (let e4 = 0, i4 = s2.length, a2 = i4 - 1; e4 < i4; a2 = e4++) {
  42765. const i5 = s2[e4], o2 = s2[a2];
  42766. i5.y > t3.y != o2.y > t3.y && t3.x < (o2.x - i5.x) * (t3.y - i5.y) / (o2.y - i5.y) + i5.x && (r3 = !r3), n3 = Math.min(n3, Mo(t3, i5, o2));
  42767. }
  42768. }
  42769. return (r3 ? 1 : -1) * Math.sqrt(n3);
  42770. }(this.p, n2), this.max = this.d + this.h * Math.SQRT2;
  42771. }
  42772. const Vh = Number.POSITIVE_INFINITY, Fh = Math.sqrt(2);
  42773. function Lh(t2, e2) {
  42774. return e2[1] !== Vh ? function(t3, e3, r2) {
  42775. let n2 = 0, i3 = 0;
  42776. switch (e3 = Math.abs(e3), r2 = Math.abs(r2), t3) {
  42777. case "top-right":
  42778. case "top-left":
  42779. case "top":
  42780. i3 = r2 - 7;
  42781. break;
  42782. case "bottom-right":
  42783. case "bottom-left":
  42784. case "bottom":
  42785. i3 = 7 - r2;
  42786. }
  42787. switch (t3) {
  42788. case "top-right":
  42789. case "bottom-right":
  42790. case "right":
  42791. n2 = -e3;
  42792. break;
  42793. case "top-left":
  42794. case "bottom-left":
  42795. case "left":
  42796. n2 = e3;
  42797. }
  42798. return [n2, i3];
  42799. }(t2, e2[0], e2[1]) : function(t3, e3) {
  42800. let r2 = 0, n2 = 0;
  42801. e3 < 0 && (e3 = 0);
  42802. const i3 = e3 / Fh;
  42803. switch (t3) {
  42804. case "top-right":
  42805. case "top-left":
  42806. n2 = i3 - 7;
  42807. break;
  42808. case "bottom-right":
  42809. case "bottom-left":
  42810. n2 = 7 - i3;
  42811. break;
  42812. case "bottom":
  42813. n2 = 7 - e3;
  42814. break;
  42815. case "top":
  42816. n2 = e3 - 7;
  42817. }
  42818. switch (t3) {
  42819. case "top-right":
  42820. case "bottom-right":
  42821. r2 = -i3;
  42822. break;
  42823. case "top-left":
  42824. case "bottom-left":
  42825. r2 = i3;
  42826. break;
  42827. case "left":
  42828. r2 = e3;
  42829. break;
  42830. case "right":
  42831. r2 = -e3;
  42832. }
  42833. return [r2, n2];
  42834. }(t2, e2[0]);
  42835. }
  42836. function Rh(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2) {
  42837. t2.createArrays(), t2.tilePixelRatio = Ya / (512 * t2.overscaling), t2.compareText = {}, t2.iconsNeedLinear = false;
  42838. const c2 = t2.layers[0].layout, h2 = t2.layers[0]._unevaluatedLayout._values, p2 = {};
  42839. if ("composite" === t2.textSizeData.kind) {
  42840. const { minZoom: e3, maxZoom: r3 } = t2.textSizeData;
  42841. p2.compositeTextSizes = [h2["text-size"].possiblyEvaluate(new ss(e3), o2), h2["text-size"].possiblyEvaluate(new ss(r3), o2)];
  42842. }
  42843. if ("composite" === t2.iconSizeData.kind) {
  42844. const { minZoom: e3, maxZoom: r3 } = t2.iconSizeData;
  42845. p2.compositeIconSizes = [h2["icon-size"].possiblyEvaluate(new ss(e3), o2), h2["icon-size"].possiblyEvaluate(new ss(r3), o2)];
  42846. }
  42847. p2.layoutTextSize = h2["text-size"].possiblyEvaluate(new ss(l2 + 1), o2), p2.layoutIconSize = h2["icon-size"].possiblyEvaluate(new ss(l2 + 1), o2), p2.textMaxSize = h2["text-size"].possiblyEvaluate(new ss(18), o2);
  42848. const f2 = "map" === c2.get("text-rotation-alignment") && "point" !== c2.get("symbol-placement"), d2 = c2.get("text-size");
  42849. for (const s3 of t2.features) {
  42850. const l3 = c2.get("text-font").evaluate(s3, {}, o2).join(","), h3 = d2.evaluate(s3, {}, o2), y2 = p2.layoutTextSize.evaluate(s3, {}, o2), m2 = (p2.layoutIconSize.evaluate(s3, {}, o2), { horizontal: {}, vertical: void 0 }), g2 = s3.text;
  42851. let x2, v2 = [0, 0];
  42852. if (g2) {
  42853. const n3 = g2.toString(), a3 = c2.get("text-letter-spacing").evaluate(s3, {}, o2) * cc, u3 = c2.get("text-line-height").evaluate(s3, {}, o2) * cc, p3 = $i(n3) ? a3 : 0, d3 = c2.get("text-anchor").evaluate(s3, {}, o2), x3 = c2.get("text-variable-anchor");
  42854. if (!x3) {
  42855. const t3 = c2.get("text-radial-offset").evaluate(s3, {}, o2);
  42856. v2 = t3 ? Lh(d3, [t3 * cc, Vh]) : c2.get("text-offset").evaluate(s3, {}, o2).map((t4) => t4 * cc);
  42857. }
  42858. let b3 = f2 ? "center" : c2.get("text-justify").evaluate(s3, {}, o2);
  42859. const _3 = c2.get("symbol-placement"), w2 = "point" === _3, A2 = "point" === _3 ? c2.get("text-max-width").evaluate(s3, {}, o2) * cc : 0, k2 = (s4) => {
  42860. t2.allowVerticalPlacement && Ui(n3) && (m2.vertical = Wc(g2, e2, r2, i3, l3, A2, u3, d3, s4, p3, v2, Kc.vertical, true, _3, y2, h3));
  42861. };
  42862. if (!f2 && x3) {
  42863. const t3 = "auto" === b3 ? x3.map((t4) => Uh(t4)) : [b3];
  42864. let n4 = false;
  42865. for (let s4 = 0; s4 < t3.length; s4++) {
  42866. const a4 = t3[s4];
  42867. if (!m2.horizontal[a4])
  42868. if (n4)
  42869. m2.horizontal[a4] = m2.horizontal[0];
  42870. else {
  42871. const t4 = Wc(g2, e2, r2, i3, l3, A2, u3, "center", a4, p3, v2, Kc.horizontal, false, _3, y2, h3);
  42872. t4 && (m2.horizontal[a4] = t4, n4 = 1 === t4.positionedLines.length);
  42873. }
  42874. }
  42875. k2("left");
  42876. } else {
  42877. if ("auto" === b3 && (b3 = Uh(d3)), w2 || c2.get("text-writing-mode").indexOf("horizontal") >= 0 || !Ui(n3)) {
  42878. const t3 = Wc(g2, e2, r2, i3, l3, A2, u3, d3, b3, p3, v2, Kc.horizontal, false, _3, y2, h3);
  42879. t3 && (m2.horizontal[b3] = t3);
  42880. }
  42881. k2("point" === _3 ? "left" : b3);
  42882. }
  42883. }
  42884. let b2 = false;
  42885. if (s3.icon && s3.icon.name) {
  42886. const e3 = n2[s3.icon.name];
  42887. e3 && (x2 = lh(i3[s3.icon.name], c2.get("icon-offset").evaluate(s3, {}, o2), c2.get("icon-anchor").evaluate(s3, {}, o2)), b2 = e3.sdf, void 0 === t2.sdfIcons ? t2.sdfIcons = e3.sdf : t2.sdfIcons !== e3.sdf && C("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"), (e3.pixelRatio !== t2.pixelRatio || 0 !== c2.get("icon-rotate").constantOr(1)) && (t2.iconsNeedLinear = true));
  42888. }
  42889. const _2 = qh(m2.horizontal) || m2.vertical;
  42890. t2.iconsInText || (t2.iconsInText = !!_2 && _2.iconsInText), (_2 || x2) && $h(t2, s3, m2, x2, n2, p2, y2, 0, v2, b2, a2, o2, u2);
  42891. }
  42892. s2 && t2.generateCollisionDebugBuffers(l2, t2.collisionBoxArray);
  42893. }
  42894. function Uh(t2) {
  42895. switch (t2) {
  42896. case "right":
  42897. case "top-right":
  42898. case "bottom-right":
  42899. return "right";
  42900. case "left":
  42901. case "top-left":
  42902. case "bottom-left":
  42903. return "left";
  42904. }
  42905. return "center";
  42906. }
  42907. function $h(t2, e2, r2, n2, i3, s2, a2, o2, l2, c2, h2, p2, f2) {
  42908. let d2 = s2.textMaxSize.evaluate(e2, {}, p2);
  42909. void 0 === d2 && (d2 = a2);
  42910. const y2 = t2.layers[0].layout, m2 = y2.get("icon-offset").evaluate(e2, {}, p2), g2 = qh(r2.horizontal) || r2.vertical, x2 = a2 / 24, v2 = t2.tilePixelRatio * d2 / 24, b2 = (T2 = t2.overscaling, t2.zoom > 18 && T2 > 2 && (T2 >>= 1), Math.max(Ya / (512 * T2), 1) * y2.get("symbol-spacing")), _2 = y2.get("text-padding") * t2.tilePixelRatio, w2 = y2.get("icon-padding") * t2.tilePixelRatio, A2 = u(y2.get("text-max-angle")), k2 = "map" === y2.get("text-rotation-alignment") && "point" !== y2.get("symbol-placement"), S2 = "map" === y2.get("icon-rotation-alignment") && "point" !== y2.get("symbol-placement"), I2 = y2.get("symbol-placement"), M2 = b2 / 2;
  42911. var T2;
  42912. const z2 = y2.get("icon-text-fit");
  42913. let B2;
  42914. n2 && "none" !== z2 && (t2.allowVerticalPlacement && r2.vertical && (B2 = uh(n2, r2.vertical, z2, y2.get("icon-text-fit-padding"), m2, x2)), g2 && (n2 = uh(n2, g2, z2, y2.get("icon-text-fit-padding"), m2, x2)));
  42915. const E2 = (a3, o3, u2) => {
  42916. if (o3.x < 0 || o3.x >= Ya || o3.y < 0 || o3.y >= Ya)
  42917. return;
  42918. const { x: d3, y: y3, z: g3 } = f2.projectTilePoint(o3.x, o3.y, u2), x3 = new ch(d3, y3, g3, 0, void 0);
  42919. !function(t3, e3, r3, n3, i4, s3, a4, o4, l3, u3, c3, h3, p3, f3, d4, y4, m3, g4, x4, v3, b3, _3, w3, A3, k3) {
  42920. const S3 = t3.addToLineVertexArray(e3, n3);
  42921. let I3, M3, T3, z3, B3, E3, D2, P2 = 0, V2 = 0, F2 = 0, L2 = 0, R2 = -1, U2 = -1;
  42922. const $2 = {};
  42923. let j2 = xa(""), O2 = 0, q2 = 0;
  42924. if (void 0 === l3._unevaluatedLayout.getValue("text-radial-offset") ? [O2, q2] = l3.layout.get("text-offset").evaluate(b3, {}, k3).map((t4) => t4 * cc) : (O2 = l3.layout.get("text-radial-offset").evaluate(b3, {}, k3) * cc, q2 = Vh), t3.allowVerticalPlacement && i4.vertical) {
  42925. const t4 = i4.vertical;
  42926. if (d4)
  42927. E3 = Gh(t4), o4 && (D2 = Gh(o4));
  42928. else {
  42929. const n4 = l3.layout.get("text-rotate").evaluate(b3, {}, k3) + 90;
  42930. T3 = Nh(u3, r3, e3, c3, h3, p3, t4, f3, n4, y4), o4 && (z3 = Nh(u3, r3, e3, c3, h3, p3, o4, g4, n4));
  42931. }
  42932. }
  42933. if (s3) {
  42934. const n4 = l3.layout.get("icon-rotate").evaluate(b3, {}, k3), i5 = "none" !== l3.layout.get("icon-text-fit"), a5 = kh(s3, n4, w3, i5), f4 = o4 ? kh(o4, n4, w3, i5) : void 0;
  42935. M3 = Nh(u3, r3, e3, c3, h3, p3, s3, g4, n4), P2 = 4 * a5.length;
  42936. const d5 = t3.iconSizeData;
  42937. let y5 = null;
  42938. "source" === d5.kind ? (y5 = [hc * l3.layout.get("icon-size").evaluate(b3, {}, k3)], y5[0] > jh && C(`${t3.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)) : "composite" === d5.kind && (y5 = [hc * _3.compositeIconSizes[0].evaluate(b3, {}, k3), hc * _3.compositeIconSizes[1].evaluate(b3, {}, k3)], (y5[0] > jh || y5[1] > jh) && C(`${t3.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)), t3.addSymbols(t3.icon, a5, y5, v3, x4, b3, false, r3, e3, S3.lineStartIndex, S3.lineLength, -1, A3, k3), R2 = t3.icon.placedSymbolArray.length - 1, f4 && (V2 = 4 * f4.length, t3.addSymbols(t3.icon, f4, y5, v3, x4, b3, Kc.vertical, r3, e3, S3.lineStartIndex, S3.lineLength, -1, A3, k3), U2 = t3.icon.placedSymbolArray.length - 1);
  42939. }
  42940. for (const n4 in i4.horizontal) {
  42941. const s4 = i4.horizontal[n4];
  42942. I3 || (j2 = xa(s4.text), d4 ? B3 = Gh(s4) : I3 = Nh(u3, r3, e3, c3, h3, p3, s4, f3, l3.layout.get("text-rotate").evaluate(b3, {}, k3), y4));
  42943. const o5 = 1 === s4.positionedLines.length;
  42944. if (F2 += Oh(t3, r3, e3, s4, a4, l3, d4, b3, y4, S3, i4.vertical ? Kc.horizontal : Kc.horizontalOnly, o5 ? Object.keys(i4.horizontal) : [n4], $2, R2, _3, A3, k3), o5)
  42945. break;
  42946. }
  42947. i4.vertical && (L2 += Oh(t3, r3, e3, i4.vertical, a4, l3, d4, b3, y4, S3, Kc.vertical, ["vertical"], $2, U2, _3, A3, k3));
  42948. let N2 = -1;
  42949. const G2 = (t4, e4) => t4 ? Math.max(t4, e4) : e4;
  42950. N2 = G2(B3, N2), N2 = G2(E3, N2), N2 = G2(D2, N2);
  42951. const Z2 = N2 > -1 ? 1 : 0;
  42952. t3.glyphOffsetArray.length >= tp.MAX_GLYPHS && C("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"), void 0 !== b3.sortKey && t3.addToSortKeyRanges(t3.symbolInstances.length, b3.sortKey), t3.symbolInstances.emplaceBack(r3.x, r3.y, r3.z, e3.x, e3.y, $2.right >= 0 ? $2.right : -1, $2.center >= 0 ? $2.center : -1, $2.left >= 0 ? $2.left : -1, $2.vertical >= 0 ? $2.vertical : -1, R2, U2, j2, void 0 !== I3 ? I3 : t3.collisionBoxArray.length, void 0 !== I3 ? I3 + 1 : t3.collisionBoxArray.length, void 0 !== T3 ? T3 : t3.collisionBoxArray.length, void 0 !== T3 ? T3 + 1 : t3.collisionBoxArray.length, void 0 !== M3 ? M3 : t3.collisionBoxArray.length, void 0 !== M3 ? M3 + 1 : t3.collisionBoxArray.length, z3 || t3.collisionBoxArray.length, z3 ? z3 + 1 : t3.collisionBoxArray.length, c3, F2, L2, P2, V2, Z2, 0, O2, q2, N2);
  42953. }(t2, o3, x3, a3, r2, n2, i3, B2, t2.layers[0], t2.collisionBoxArray, e2.index, e2.sourceLayerIndex, t2.index, _2, k2, l2, 0, w2, S2, m2, e2, s2, c2, h2, p2);
  42954. };
  42955. if ("line" === I2)
  42956. for (const i4 of xh(e2.geometry, 0, 0, Ya, Ya)) {
  42957. const e3 = mh(i4, b2, A2, r2.vertical || g2, n2, 24, v2, t2.overscaling, Ya);
  42958. for (const r3 of e3) {
  42959. const e4 = g2;
  42960. e4 && Zh(t2, e4.text, M2, r3) || E2(i4, r3, p2);
  42961. }
  42962. }
  42963. else if ("line-center" === I2) {
  42964. for (const t3 of e2.geometry)
  42965. if (t3.length > 1) {
  42966. const e3 = yh(t3, A2, r2.vertical || g2, n2, 24, v2);
  42967. e3 && E2(t3, e3, p2);
  42968. }
  42969. } else if ("Polygon" === e2.type)
  42970. for (const t3 of du(e2.geometry, 0)) {
  42971. const e3 = Ch(t3, 16);
  42972. E2(t3[0], new ch(e3.x, e3.y, 0, 0, void 0), p2);
  42973. }
  42974. else if ("LineString" === e2.type)
  42975. for (const t3 of e2.geometry)
  42976. E2(t3, new ch(t3[0].x, t3[0].y, 0, 0, void 0), p2);
  42977. else if ("Point" === e2.type)
  42978. for (const t3 of e2.geometry)
  42979. for (const e3 of t3)
  42980. E2([e3], new ch(e3.x, e3.y, 0, 0, void 0), p2);
  42981. }
  42982. const jh = 32640;
  42983. function Oh(t2, e2, r2, n2, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2, m2, g2) {
  42984. const x2 = function(t3, e3, r3, n3, s3, a3, o3, l3) {
  42985. const u3 = [];
  42986. if (0 === e3.positionedLines.length)
  42987. return u3;
  42988. const c3 = n3.layout.get("text-rotate").evaluate(a3, {}) * Math.PI / 180, h3 = function(t4) {
  42989. const e4 = t4[0], r4 = t4[1], n4 = e4 * r4;
  42990. return n4 > 0 ? [e4, -r4] : n4 < 0 ? [-e4, r4] : 0 === e4 ? [r4, e4] : [r4, -e4];
  42991. }(r3);
  42992. let p3 = Math.abs(e3.top - e3.bottom);
  42993. for (const t4 of e3.positionedLines)
  42994. p3 -= t4.lineOffset;
  42995. const f3 = e3.positionedLines.length, d3 = p3 / f3;
  42996. let y3 = e3.top - r3[1];
  42997. for (let t4 = 0; t4 < f3; ++t4) {
  42998. const n4 = e3.positionedLines[t4];
  42999. y3 = zh(e3, d3, y3, t4);
  43000. for (const t5 of n4.positionedGlyphs) {
  43001. if (!t5.rect)
  43002. continue;
  43003. const n5 = t5.rect || {};
  43004. let a4 = 4, p4 = true, f4 = 1, d4 = 0;
  43005. if (t5.imageName) {
  43006. const e4 = o3[t5.imageName];
  43007. if (!e4)
  43008. continue;
  43009. if (e4.sdf) {
  43010. C("SDF images are not supported in formatted text and will be ignored.");
  43011. continue;
  43012. }
  43013. p4 = false, f4 = e4.pixelRatio, a4 = 1 / f4;
  43014. }
  43015. const m3 = (s3 || l3) && t5.vertical, g3 = t5.metrics.advance * t5.scale / 2, x3 = t5.metrics, v3 = t5.rect;
  43016. if (null === v3)
  43017. continue;
  43018. l3 && e3.verticalizable && (d4 = t5.imageName ? g3 - t5.metrics.width * t5.scale / 2 : 0);
  43019. const b3 = s3 ? [t5.x + g3, t5.y] : [0, 0];
  43020. let _2 = [0, 0], w2 = [0, 0], A2 = false;
  43021. s3 || (m3 ? (w2 = [t5.x + g3 + h3[0], t5.y + h3[1] - d4], A2 = true) : _2 = [t5.x + g3 + r3[0], t5.y + r3[1] - d4]);
  43022. const k2 = v3.w * t5.scale / (f4 * (t5.localGlyph ? 2 : 1)), S2 = v3.h * t5.scale / (f4 * (t5.localGlyph ? 2 : 1));
  43023. let I2, M2, T2, z2;
  43024. if (m3) {
  43025. const e4 = t5.y - y3, r4 = new i2(-g3, g3 - e4), n6 = -Math.PI / 2, s4 = new i2(...w2);
  43026. I2 = new i2(-g3 + _2[0], _2[1]), I2._rotateAround(n6, r4)._add(s4), I2.x += -e4 + g3, I2.y -= (x3.left - a4) * t5.scale;
  43027. const o4 = t5.imageName ? x3.advance * t5.scale : cc * t5.scale, l4 = String.fromCharCode(t5.glyph);
  43028. xc(l4) ? I2.x += (1 - a4) * t5.scale : vc(l4) ? I2.x += o4 - x3.height * t5.scale + (-a4 - 1) * t5.scale : I2.x += t5.imageName || x3.width + 2 * a4 === v3.w && x3.height + 2 * a4 === v3.h ? (o4 - S2) / 2 : (o4 - (x3.height + 2 * a4) * t5.scale) / 2, M2 = new i2(I2.x, I2.y - k2), T2 = new i2(I2.x + S2, I2.y), z2 = new i2(I2.x + S2, I2.y - k2);
  43029. } else {
  43030. const e4 = (x3.left - a4) * t5.scale - g3 + _2[0], r4 = (-x3.top - a4) * t5.scale + _2[1], n6 = e4 + k2, s4 = r4 + S2;
  43031. I2 = new i2(e4, r4), M2 = new i2(n6, r4), T2 = new i2(e4, s4), z2 = new i2(n6, s4);
  43032. }
  43033. if (c3) {
  43034. let t6;
  43035. t6 = s3 ? new i2(0, 0) : A2 ? new i2(h3[0], h3[1]) : new i2(r3[0], r3[1]), I2._rotateAround(c3, t6), M2._rotateAround(c3, t6), T2._rotateAround(c3, t6), z2._rotateAround(c3, t6);
  43036. }
  43037. const B2 = new i2(0, 0), E2 = new i2(0, 0);
  43038. u3.push({ tl: I2, tr: M2, bl: T2, br: z2, tex: n5, writingMode: e3.writingMode, glyphOffset: b3, sectionIndex: t5.sectionIndex, isSDF: p4, pixelOffsetTL: B2, pixelOffsetBR: E2, minFontScaleX: 0, minFontScaleY: 0 });
  43039. }
  43040. }
  43041. return u3;
  43042. }(0, n2, u2, a2, o2, l2, s2, t2.allowVerticalPlacement), v2 = t2.textSizeData;
  43043. let b2 = null;
  43044. "source" === v2.kind ? (b2 = [hc * a2.layout.get("text-size").evaluate(l2, {}, g2)], b2[0] > jh && C(`${t2.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)) : "composite" === v2.kind && (b2 = [hc * y2.compositeTextSizes[0].evaluate(l2, {}, g2), hc * y2.compositeTextSizes[1].evaluate(l2, {}, g2)], (b2[0] > jh || b2[1] > jh) && C(`${t2.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)), t2.addSymbols(t2.text, x2, b2, u2, o2, l2, h2, e2, r2, c2.lineStartIndex, c2.lineLength, d2, m2, g2);
  43045. for (const e3 of p2)
  43046. f2[e3] = t2.text.placedSymbolArray.length - 1;
  43047. return 4 * x2.length;
  43048. }
  43049. function qh(t2) {
  43050. for (const e2 in t2)
  43051. return t2[e2];
  43052. return null;
  43053. }
  43054. function Nh(t2, e2, r2, n2, s2, a2, o2, l2, c2, h2) {
  43055. let p2 = o2.top, f2 = o2.bottom, d2 = o2.left, y2 = o2.right;
  43056. const m2 = o2.collisionPadding;
  43057. if (m2 && (d2 -= m2[0], p2 -= m2[1], y2 += m2[2], f2 += m2[3]), c2) {
  43058. const t3 = new i2(d2, p2), e3 = new i2(y2, p2), r3 = new i2(d2, f2), n3 = new i2(y2, f2), s3 = u(c2);
  43059. let a3 = new i2(0, 0);
  43060. h2 && (a3 = new i2(h2[0], h2[1])), t3._rotateAround(s3, a3), e3._rotateAround(s3, a3), r3._rotateAround(s3, a3), n3._rotateAround(s3, a3), d2 = Math.min(t3.x, e3.x, r3.x, n3.x), y2 = Math.max(t3.x, e3.x, r3.x, n3.x), p2 = Math.min(t3.y, e3.y, r3.y, n3.y), f2 = Math.max(t3.y, e3.y, r3.y, n3.y);
  43061. }
  43062. return t2.emplaceBack(e2.x, e2.y, e2.z, r2.x, r2.y, d2, p2, y2, f2, l2, n2, s2, a2), t2.length - 1;
  43063. }
  43064. function Gh(t2) {
  43065. t2.collisionPadding && (t2.top -= t2.collisionPadding[1], t2.bottom += t2.collisionPadding[3]);
  43066. const e2 = t2.bottom - t2.top;
  43067. return e2 > 0 ? Math.max(10, e2) : null;
  43068. }
  43069. function Zh(t2, e2, r2, n2) {
  43070. const i3 = t2.compareText;
  43071. if (e2 in i3) {
  43072. const t3 = i3[e2];
  43073. for (let e3 = t3.length - 1; e3 >= 0; e3--)
  43074. if (n2.dist(t3[e3]) < r2)
  43075. return true;
  43076. } else
  43077. i3[e2] = [];
  43078. return i3[e2].push(n2), false;
  43079. }
  43080. const Xh = Du.VectorTileFeature.types, Kh = [{ name: "a_fade_opacity", components: 1, type: "Uint8", offset: 0 }];
  43081. function Yh(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2) {
  43082. const m2 = c2 ? Math.min(jh, Math.round(c2[0])) : 0, g2 = c2 ? Math.min(jh, Math.round(c2[1])) : 0;
  43083. t2.emplaceBack(e2, r2, Math.round(32 * a2), Math.round(32 * o2), l2, u2, (m2 << 1) + (h2 ? 1 : 0), g2, 16 * p2, 16 * f2, 256 * d2, 256 * y2, n2, i3, s2, 0);
  43084. }
  43085. function Hh(t2, e2, r2) {
  43086. t2.emplaceBack(e2.x, e2.y, r2), t2.emplaceBack(e2.x, e2.y, r2), t2.emplaceBack(e2.x, e2.y, r2), t2.emplaceBack(e2.x, e2.y, r2);
  43087. }
  43088. function Wh(t2) {
  43089. for (const e2 of t2.sections)
  43090. if (Zi(e2.text))
  43091. return true;
  43092. return false;
  43093. }
  43094. class Jh {
  43095. constructor(t2) {
  43096. this.layoutVertexArray = new Ps(), this.indexArray = new js(), this.programConfigurations = t2, this.segments = new Ka(), this.dynamicLayoutVertexArray = new Vs(), this.opacityVertexArray = new Fs(), this.placedSymbolArray = new na();
  43097. }
  43098. isEmpty() {
  43099. return 0 === this.layoutVertexArray.length && 0 === this.indexArray.length && 0 === this.dynamicLayoutVertexArray.length && 0 === this.opacityVertexArray.length;
  43100. }
  43101. upload(t2, e2, r2, n2) {
  43102. this.isEmpty() || (r2 && (this.layoutVertexBuffer = t2.createVertexBuffer(this.layoutVertexArray, ic.members), this.indexBuffer = t2.createIndexBuffer(this.indexArray, e2), this.dynamicLayoutVertexBuffer = t2.createVertexBuffer(this.dynamicLayoutVertexArray, sc.members, true), this.opacityVertexBuffer = t2.createVertexBuffer(this.opacityVertexArray, Kh, true), this.opacityVertexBuffer.itemSize = 1), (r2 || n2) && this.programConfigurations.upload(t2));
  43103. }
  43104. destroy() {
  43105. this.layoutVertexBuffer && (this.layoutVertexBuffer.destroy(), this.indexBuffer.destroy(), this.programConfigurations.destroy(), this.segments.destroy(), this.dynamicLayoutVertexBuffer.destroy(), this.opacityVertexBuffer.destroy());
  43106. }
  43107. }
  43108. ai(Jh, "SymbolBuffers");
  43109. class Qh {
  43110. constructor(t2, e2, r2) {
  43111. this.layoutVertexArray = new t2(), this.layoutAttributes = e2, this.indexArray = new r2(), this.segments = new Ka(), this.collisionVertexArray = new $s(), this.collisionVertexArrayExt = new Vs();
  43112. }
  43113. upload(t2) {
  43114. this.layoutVertexBuffer = t2.createVertexBuffer(this.layoutVertexArray, this.layoutAttributes), this.indexBuffer = t2.createIndexBuffer(this.indexArray), this.collisionVertexBuffer = t2.createVertexBuffer(this.collisionVertexArray, ac.members, true), this.collisionVertexBufferExt = t2.createVertexBuffer(this.collisionVertexArrayExt, oc.members, true);
  43115. }
  43116. destroy() {
  43117. this.layoutVertexBuffer && (this.layoutVertexBuffer.destroy(), this.indexBuffer.destroy(), this.segments.destroy(), this.collisionVertexBuffer.destroy(), this.collisionVertexBufferExt.destroy());
  43118. }
  43119. }
  43120. ai(Qh, "CollisionBuffers");
  43121. class tp {
  43122. constructor(t2) {
  43123. this.collisionBoxArray = t2.collisionBoxArray, this.zoom = t2.zoom, this.overscaling = t2.overscaling, this.layers = t2.layers, this.layerIds = this.layers.map((t3) => t3.id), this.index = t2.index, this.pixelRatio = t2.pixelRatio, this.sourceLayerIndex = t2.sourceLayerIndex, this.hasPattern = false, this.hasRTLText = false, this.fullyClipped = false, this.sortKeyRanges = [], this.collisionCircleArray = [], this.placementInvProjMatrix = jo([]), this.placementViewportMatrix = jo([]);
  43124. const e2 = this.layers[0]._unevaluatedLayout._values;
  43125. this.textSizeData = pc(this.zoom, e2["text-size"]), this.iconSizeData = pc(this.zoom, e2["icon-size"]);
  43126. const r2 = this.layers[0].layout, n2 = r2.get("symbol-sort-key"), i3 = r2.get("symbol-z-order");
  43127. this.canOverlap = r2.get("text-allow-overlap") || r2.get("icon-allow-overlap") || r2.get("text-ignore-placement") || r2.get("icon-ignore-placement"), this.sortFeaturesByKey = "viewport-y" !== i3 && void 0 !== n2.constantOr(1), this.sortFeaturesByY = ("viewport-y" === i3 || "auto" === i3 && !this.sortFeaturesByKey) && this.canOverlap, this.writingModes = r2.get("text-writing-mode").map((t3) => Kc[t3]), this.stateDependentLayerIds = this.layers.filter((t3) => t3.isStateDependent()).map((t3) => t3.id), this.sourceID = t2.sourceID, this.projection = t2.projection;
  43128. }
  43129. createArrays() {
  43130. this.text = new Jh(new Ra(this.layers, this.zoom, (t2) => /^text/.test(t2))), this.icon = new Jh(new Ra(this.layers, this.zoom, (t2) => /^icon/.test(t2))), this.glyphOffsetArray = new aa(), this.lineVertexArray = new oa(), this.symbolInstances = new sa();
  43131. }
  43132. calculateGlyphDependencies(t2, e2, r2, n2, i3) {
  43133. for (let r3 = 0; r3 < t2.length; r3++)
  43134. if (e2[t2.charCodeAt(r3)] = true, n2 && i3) {
  43135. const n3 = gc[t2.charAt(r3)];
  43136. n3 && (e2[n3.charCodeAt(0)] = true);
  43137. }
  43138. }
  43139. populate(t2, e2, r2, n2) {
  43140. const i3 = this.layers[0], s2 = i3.layout, a2 = s2.get("text-font"), o2 = s2.get("text-field"), l2 = s2.get("icon-image"), u2 = ("constant" !== o2.value.kind || o2.value.value instanceof fe && !o2.value.value.isEmpty() || o2.value.value.toString().length > 0) && ("constant" !== a2.value.kind || a2.value.value.length > 0), c2 = "constant" !== l2.value.kind || !!l2.value.value || Object.keys(l2.parameters).length > 0, h2 = s2.get("symbol-sort-key");
  43141. if (this.features = [], !u2 && !c2)
  43142. return;
  43143. const p2 = e2.iconDependencies, f2 = e2.glyphDependencies, d2 = e2.availableImages, y2 = new ss(this.zoom);
  43144. for (const { feature: e3, id: o3, index: l3, sourceLayerIndex: m2 } of t2) {
  43145. const t3 = i3._featureFilter.needGeometry, g2 = mo(e3, t3);
  43146. if (!i3._featureFilter.filter(y2, g2, r2))
  43147. continue;
  43148. let x2, v2;
  43149. if (t3 || (g2.geometry = yo(e3, r2, n2)), u2) {
  43150. const t4 = i3.getValueAndResolveTokens("text-field", g2, r2, d2), e4 = fe.factory(t4);
  43151. Wh(e4) && (this.hasRTLText = true), (!this.hasRTLText || "unavailable" === rs() || this.hasRTLText && is.isParsed()) && (x2 = mc(e4, i3, g2));
  43152. }
  43153. if (c2) {
  43154. const t4 = i3.getValueAndResolveTokens("icon-image", g2, r2, d2);
  43155. v2 = t4 instanceof de ? t4 : de.fromString(t4);
  43156. }
  43157. if (!x2 && !v2)
  43158. continue;
  43159. const b2 = this.sortFeaturesByKey ? h2.evaluate(g2, {}, r2) : void 0;
  43160. if (this.features.push({ id: o3, text: x2, icon: v2, index: l3, sourceLayerIndex: m2, geometry: g2.geometry, properties: e3.properties, type: Xh[e3.type], sortKey: b2 }), v2 && (p2[v2.name] = true), x2) {
  43161. const t4 = a2.evaluate(g2, {}, r2).join(","), e4 = "map" === s2.get("text-rotation-alignment") && "point" !== s2.get("symbol-placement");
  43162. this.allowVerticalPlacement = this.writingModes && this.writingModes.indexOf(Kc.vertical) >= 0;
  43163. for (const r3 of x2.sections)
  43164. if (r3.image)
  43165. p2[r3.image.name] = true;
  43166. else {
  43167. const n3 = Ui(x2.toString()), i4 = r3.fontStack || t4, s3 = f2[i4] = f2[i4] || {};
  43168. this.calculateGlyphDependencies(r3.text, s3, e4, this.allowVerticalPlacement, n3);
  43169. }
  43170. }
  43171. }
  43172. "line" === s2.get("symbol-placement") && (this.features = function(t3) {
  43173. const e3 = {}, r3 = {}, n3 = [];
  43174. let i4 = 0;
  43175. function s3(e4) {
  43176. n3.push(t3[e4]), i4++;
  43177. }
  43178. function a3(t4, e4, i5) {
  43179. const s4 = r3[t4];
  43180. return delete r3[t4], r3[e4] = s4, n3[s4].geometry[0].pop(), n3[s4].geometry[0] = n3[s4].geometry[0].concat(i5[0]), s4;
  43181. }
  43182. function o3(t4, r4, i5) {
  43183. const s4 = e3[r4];
  43184. return delete e3[r4], e3[t4] = s4, n3[s4].geometry[0].shift(), n3[s4].geometry[0] = i5[0].concat(n3[s4].geometry[0]), s4;
  43185. }
  43186. function l3(t4, e4, r4) {
  43187. const n4 = r4 ? e4[0][e4[0].length - 1] : e4[0][0];
  43188. return `${t4}:${n4.x}:${n4.y}`;
  43189. }
  43190. for (let u3 = 0; u3 < t3.length; u3++) {
  43191. const c3 = t3[u3], h3 = c3.geometry, p3 = c3.text ? c3.text.toString() : null;
  43192. if (!p3) {
  43193. s3(u3);
  43194. continue;
  43195. }
  43196. const f3 = l3(p3, h3), d3 = l3(p3, h3, true);
  43197. if (f3 in r3 && d3 in e3 && r3[f3] !== e3[d3]) {
  43198. const t4 = o3(f3, d3, h3), i5 = a3(f3, d3, n3[t4].geometry);
  43199. delete e3[f3], delete r3[d3], r3[l3(p3, n3[i5].geometry, true)] = i5, n3[t4].geometry = null;
  43200. } else
  43201. f3 in r3 ? a3(f3, d3, h3) : d3 in e3 ? o3(f3, d3, h3) : (s3(u3), e3[f3] = i4 - 1, r3[d3] = i4 - 1);
  43202. }
  43203. return n3.filter((t4) => t4.geometry);
  43204. }(this.features)), this.sortFeaturesByKey && this.features.sort((t3, e3) => t3.sortKey - e3.sortKey);
  43205. }
  43206. update(t2, e2, r2, n2) {
  43207. this.stateDependentLayers.length && (this.text.programConfigurations.updatePaintArrays(t2, e2, this.layers, r2, n2), this.icon.programConfigurations.updatePaintArrays(t2, e2, this.layers, r2, n2));
  43208. }
  43209. isEmpty() {
  43210. return 0 === this.symbolInstances.length && !this.hasRTLText;
  43211. }
  43212. uploadPending() {
  43213. return !this.uploaded || this.text.programConfigurations.needsUpload || this.icon.programConfigurations.needsUpload;
  43214. }
  43215. upload(t2) {
  43216. !this.uploaded && this.hasDebugData() && (this.textCollisionBox.upload(t2), this.iconCollisionBox.upload(t2)), this.text.upload(t2, this.sortFeaturesByY, !this.uploaded, this.text.programConfigurations.needsUpload), this.icon.upload(t2, this.sortFeaturesByY, !this.uploaded, this.icon.programConfigurations.needsUpload), this.uploaded = true;
  43217. }
  43218. destroyDebugData() {
  43219. this.textCollisionBox.destroy(), this.iconCollisionBox.destroy();
  43220. }
  43221. destroy() {
  43222. this.text.destroy(), this.icon.destroy(), this.hasDebugData() && this.destroyDebugData();
  43223. }
  43224. addToLineVertexArray(t2, e2) {
  43225. const r2 = this.lineVertexArray.length, n2 = t2.segment;
  43226. if (void 0 !== n2) {
  43227. let r3 = t2.dist(e2[n2 + 1]), i3 = t2.dist(e2[n2]);
  43228. const s2 = {};
  43229. for (let t3 = n2 + 1; t3 < e2.length; t3++)
  43230. s2[t3] = { x: e2[t3].x, y: e2[t3].y, tileUnitDistanceFromAnchor: r3 }, t3 < e2.length - 1 && (r3 += e2[t3 + 1].dist(e2[t3]));
  43231. for (let t3 = n2 || 0; t3 >= 0; t3--)
  43232. s2[t3] = { x: e2[t3].x, y: e2[t3].y, tileUnitDistanceFromAnchor: i3 }, t3 > 0 && (i3 += e2[t3 - 1].dist(e2[t3]));
  43233. for (let t3 = 0; t3 < e2.length; t3++) {
  43234. const e3 = s2[t3];
  43235. this.lineVertexArray.emplaceBack(e3.x, e3.y, e3.tileUnitDistanceFromAnchor);
  43236. }
  43237. }
  43238. return { lineStartIndex: r2, lineLength: this.lineVertexArray.length - r2 };
  43239. }
  43240. addSymbols(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2) {
  43241. const d2 = t2.indexArray, y2 = t2.layoutVertexArray, m2 = t2.segments.prepareSegment(4 * e2.length, y2, d2, this.canOverlap ? s2.sortKey : void 0), g2 = this.glyphOffsetArray.length, x2 = m2.vertexLength, v2 = this.allowVerticalPlacement && a2 === Kc.vertical ? Math.PI / 2 : 0, b2 = s2.text && s2.text.sections;
  43242. for (let n3 = 0; n3 < e2.length; n3++) {
  43243. const { tl: i4, tr: a3, bl: u3, br: c3, tex: h3, pixelOffsetTL: g3, pixelOffsetBR: x3, minFontScaleX: _2, minFontScaleY: w2, glyphOffset: A2, isSDF: k2, sectionIndex: S2 } = e2[n3], I2 = m2.vertexLength, M2 = A2[1];
  43244. Yh(y2, o2.x, o2.y, o2.z, l2.x, l2.y, i4.x, M2 + i4.y, h3.x, h3.y, r2, k2, g3.x, g3.y, _2, w2), Yh(y2, o2.x, o2.y, o2.z, l2.x, l2.y, a3.x, M2 + a3.y, h3.x + h3.w, h3.y, r2, k2, x3.x, g3.y, _2, w2), Yh(y2, o2.x, o2.y, o2.z, l2.x, l2.y, u3.x, M2 + u3.y, h3.x, h3.y + h3.h, r2, k2, g3.x, x3.y, _2, w2), Yh(y2, o2.x, o2.y, o2.z, l2.x, l2.y, c3.x, M2 + c3.y, h3.x + h3.w, h3.y + h3.h, r2, k2, x3.x, x3.y, _2, w2), Hh(t2.dynamicLayoutVertexArray, o2, v2), d2.emplaceBack(I2, I2 + 1, I2 + 2), d2.emplaceBack(I2 + 1, I2 + 2, I2 + 3), m2.vertexLength += 4, m2.primitiveLength += 2, this.glyphOffsetArray.emplaceBack(A2[0]), n3 !== e2.length - 1 && S2 === e2[n3 + 1].sectionIndex || t2.programConfigurations.populatePaintArrays(y2.length, s2, s2.index, {}, p2, f2, b2 && b2[S2]);
  43245. }
  43246. t2.placedSymbolArray.emplaceBack(o2.x, o2.y, o2.z, l2.x, l2.y, g2, this.glyphOffsetArray.length - g2, x2, u2, c2, l2.segment, r2 ? r2[0] : 0, r2 ? r2[1] : 0, n2[0], n2[1], a2, 0, false, 0, h2, 0);
  43247. }
  43248. _commitLayoutVertex(t2, e2, r2, n2, i3, s2, a2) {
  43249. t2.emplaceBack(e2, r2, n2, i3, s2, Math.round(a2.x), Math.round(a2.y));
  43250. }
  43251. _addCollisionDebugVertices(t2, e2, r2, n2, s2, a2, o2) {
  43252. const l2 = r2.segments.prepareSegment(4, r2.layoutVertexArray, r2.indexArray), u2 = l2.vertexLength, c2 = o2.tileAnchorX, h2 = o2.tileAnchorY;
  43253. for (let t3 = 0; t3 < 4; t3++)
  43254. r2.collisionVertexArray.emplaceBack(0, 0, 0, 0);
  43255. r2.collisionVertexArrayExt.emplaceBack(e2, -t2.padding, -t2.padding), r2.collisionVertexArrayExt.emplaceBack(e2, t2.padding, -t2.padding), r2.collisionVertexArrayExt.emplaceBack(e2, t2.padding, t2.padding), r2.collisionVertexArrayExt.emplaceBack(e2, -t2.padding, t2.padding), this._commitLayoutVertex(r2.layoutVertexArray, n2, s2, a2, c2, h2, new i2(t2.x1, t2.y1)), this._commitLayoutVertex(r2.layoutVertexArray, n2, s2, a2, c2, h2, new i2(t2.x2, t2.y1)), this._commitLayoutVertex(r2.layoutVertexArray, n2, s2, a2, c2, h2, new i2(t2.x2, t2.y2)), this._commitLayoutVertex(r2.layoutVertexArray, n2, s2, a2, c2, h2, new i2(t2.x1, t2.y2)), l2.vertexLength += 4;
  43256. const p2 = r2.indexArray;
  43257. p2.emplaceBack(u2, u2 + 1), p2.emplaceBack(u2 + 1, u2 + 2), p2.emplaceBack(u2 + 2, u2 + 3), p2.emplaceBack(u2 + 3, u2), l2.primitiveLength += 4;
  43258. }
  43259. _addTextDebugCollisionBoxes(t2, e2, r2, n2, i3, s2) {
  43260. for (let a2 = n2; a2 < i3; a2++) {
  43261. const n3 = r2.get(a2), i4 = this.getSymbolInstanceTextSize(t2, s2, e2, a2);
  43262. this._addCollisionDebugVertices(n3, i4, this.textCollisionBox, n3.projectedAnchorX, n3.projectedAnchorY, n3.projectedAnchorZ, s2);
  43263. }
  43264. }
  43265. _addIconDebugCollisionBoxes(t2, e2, r2, n2, i3, s2) {
  43266. for (let a2 = n2; a2 < i3; a2++) {
  43267. const n3 = r2.get(a2), i4 = this.getSymbolInstanceIconSize(t2, e2, a2);
  43268. this._addCollisionDebugVertices(n3, i4, this.iconCollisionBox, n3.projectedAnchorX, n3.projectedAnchorY, n3.projectedAnchorZ, s2);
  43269. }
  43270. }
  43271. generateCollisionDebugBuffers(t2, e2) {
  43272. this.hasDebugData() && this.destroyDebugData(), this.textCollisionBox = new Qh(Rs, lc.members, Ks), this.iconCollisionBox = new Qh(Rs, lc.members, Ks);
  43273. const r2 = dc(this.iconSizeData, t2), n2 = dc(this.textSizeData, t2);
  43274. for (let i3 = 0; i3 < this.symbolInstances.length; i3++) {
  43275. const s2 = this.symbolInstances.get(i3);
  43276. this._addTextDebugCollisionBoxes(n2, t2, e2, s2.textBoxStartIndex, s2.textBoxEndIndex, s2), this._addTextDebugCollisionBoxes(n2, t2, e2, s2.verticalTextBoxStartIndex, s2.verticalTextBoxEndIndex, s2), this._addIconDebugCollisionBoxes(r2, t2, e2, s2.iconBoxStartIndex, s2.iconBoxEndIndex, s2), this._addIconDebugCollisionBoxes(r2, t2, e2, s2.verticalIconBoxStartIndex, s2.verticalIconBoxEndIndex, s2);
  43277. }
  43278. }
  43279. getSymbolInstanceTextSize(t2, e2, r2, n2) {
  43280. const i3 = this.text.placedSymbolArray.get(e2.rightJustifiedTextSymbolIndex >= 0 ? e2.rightJustifiedTextSymbolIndex : e2.centerJustifiedTextSymbolIndex >= 0 ? e2.centerJustifiedTextSymbolIndex : e2.leftJustifiedTextSymbolIndex >= 0 ? e2.leftJustifiedTextSymbolIndex : e2.verticalPlacedTextSymbolIndex >= 0 ? e2.verticalPlacedTextSymbolIndex : n2), s2 = fc(this.textSizeData, t2, i3) / cc;
  43281. return this.tilePixelRatio * s2;
  43282. }
  43283. getSymbolInstanceIconSize(t2, e2, r2) {
  43284. const n2 = this.icon.placedSymbolArray.get(r2), i3 = fc(this.iconSizeData, t2, n2);
  43285. return this.tilePixelRatio * i3;
  43286. }
  43287. _commitDebugCollisionVertexUpdate(t2, e2, r2) {
  43288. t2.emplaceBack(e2, -r2, -r2), t2.emplaceBack(e2, r2, -r2), t2.emplaceBack(e2, r2, r2), t2.emplaceBack(e2, -r2, r2);
  43289. }
  43290. _updateTextDebugCollisionBoxes(t2, e2, r2, n2, i3, s2) {
  43291. for (let a2 = n2; a2 < i3; a2++) {
  43292. const n3 = r2.get(a2), i4 = this.getSymbolInstanceTextSize(t2, s2, e2, a2);
  43293. this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt, i4, n3.padding);
  43294. }
  43295. }
  43296. _updateIconDebugCollisionBoxes(t2, e2, r2, n2, i3) {
  43297. for (let s2 = n2; s2 < i3; s2++) {
  43298. const n3 = r2.get(s2), i4 = this.getSymbolInstanceIconSize(t2, e2, s2);
  43299. this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt, i4, n3.padding);
  43300. }
  43301. }
  43302. updateCollisionDebugBuffers(t2, e2) {
  43303. if (!this.hasDebugData())
  43304. return;
  43305. this.hasTextCollisionBoxData() && this.textCollisionBox.collisionVertexArrayExt.clear(), this.hasIconCollisionBoxData() && this.iconCollisionBox.collisionVertexArrayExt.clear();
  43306. const r2 = dc(this.iconSizeData, t2), n2 = dc(this.textSizeData, t2);
  43307. for (let i3 = 0; i3 < this.symbolInstances.length; i3++) {
  43308. const s2 = this.symbolInstances.get(i3);
  43309. this._updateTextDebugCollisionBoxes(n2, t2, e2, s2.textBoxStartIndex, s2.textBoxEndIndex, s2), this._updateTextDebugCollisionBoxes(n2, t2, e2, s2.verticalTextBoxStartIndex, s2.verticalTextBoxEndIndex, s2), this._updateIconDebugCollisionBoxes(r2, t2, e2, s2.iconBoxStartIndex, s2.iconBoxEndIndex), this._updateIconDebugCollisionBoxes(r2, t2, e2, s2.verticalIconBoxStartIndex, s2.verticalIconBoxEndIndex);
  43310. }
  43311. this.hasTextCollisionBoxData() && this.textCollisionBox.collisionVertexBufferExt && this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt), this.hasIconCollisionBoxData() && this.iconCollisionBox.collisionVertexBufferExt && this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt);
  43312. }
  43313. _deserializeCollisionBoxesForSymbol(t2, e2, r2, n2, i3, s2, a2, o2, l2) {
  43314. const u2 = {};
  43315. for (let n3 = e2; n3 < r2; n3++) {
  43316. const e3 = t2.get(n3);
  43317. u2.textBox = { x1: e3.x1, y1: e3.y1, x2: e3.x2, y2: e3.y2, padding: e3.padding, projectedAnchorX: e3.projectedAnchorX, projectedAnchorY: e3.projectedAnchorY, projectedAnchorZ: e3.projectedAnchorZ, tileAnchorX: e3.tileAnchorX, tileAnchorY: e3.tileAnchorY }, u2.textFeatureIndex = e3.featureIndex;
  43318. break;
  43319. }
  43320. for (let e3 = n2; e3 < i3; e3++) {
  43321. const r3 = t2.get(e3);
  43322. u2.verticalTextBox = { x1: r3.x1, y1: r3.y1, x2: r3.x2, y2: r3.y2, padding: r3.padding, projectedAnchorX: r3.projectedAnchorX, projectedAnchorY: r3.projectedAnchorY, projectedAnchorZ: r3.projectedAnchorZ, tileAnchorX: r3.tileAnchorX, tileAnchorY: r3.tileAnchorY }, u2.verticalTextFeatureIndex = r3.featureIndex;
  43323. break;
  43324. }
  43325. for (let e3 = s2; e3 < a2; e3++) {
  43326. const r3 = t2.get(e3);
  43327. u2.iconBox = { x1: r3.x1, y1: r3.y1, x2: r3.x2, y2: r3.y2, padding: r3.padding, projectedAnchorX: r3.projectedAnchorX, projectedAnchorY: r3.projectedAnchorY, projectedAnchorZ: r3.projectedAnchorZ, tileAnchorX: r3.tileAnchorX, tileAnchorY: r3.tileAnchorY }, u2.iconFeatureIndex = r3.featureIndex;
  43328. break;
  43329. }
  43330. for (let e3 = o2; e3 < l2; e3++) {
  43331. const r3 = t2.get(e3);
  43332. u2.verticalIconBox = { x1: r3.x1, y1: r3.y1, x2: r3.x2, y2: r3.y2, padding: r3.padding, projectedAnchorX: r3.projectedAnchorX, projectedAnchorY: r3.projectedAnchorY, projectedAnchorZ: r3.projectedAnchorZ, tileAnchorX: r3.tileAnchorX, tileAnchorY: r3.tileAnchorY }, u2.verticalIconFeatureIndex = r3.featureIndex;
  43333. break;
  43334. }
  43335. return u2;
  43336. }
  43337. deserializeCollisionBoxes(t2) {
  43338. this.collisionArrays = [];
  43339. for (let e2 = 0; e2 < this.symbolInstances.length; e2++) {
  43340. const r2 = this.symbolInstances.get(e2);
  43341. this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t2, r2.textBoxStartIndex, r2.textBoxEndIndex, r2.verticalTextBoxStartIndex, r2.verticalTextBoxEndIndex, r2.iconBoxStartIndex, r2.iconBoxEndIndex, r2.verticalIconBoxStartIndex, r2.verticalIconBoxEndIndex));
  43342. }
  43343. }
  43344. hasTextData() {
  43345. return this.text.segments.get().length > 0;
  43346. }
  43347. hasIconData() {
  43348. return this.icon.segments.get().length > 0;
  43349. }
  43350. hasDebugData() {
  43351. return this.textCollisionBox && this.iconCollisionBox;
  43352. }
  43353. hasTextCollisionBoxData() {
  43354. return this.hasDebugData() && this.textCollisionBox.segments.get().length > 0;
  43355. }
  43356. hasIconCollisionBoxData() {
  43357. return this.hasDebugData() && this.iconCollisionBox.segments.get().length > 0;
  43358. }
  43359. addIndicesForPlacedSymbol(t2, e2) {
  43360. const r2 = t2.placedSymbolArray.get(e2), n2 = r2.vertexStartIndex + 4 * r2.numGlyphs;
  43361. for (let e3 = r2.vertexStartIndex; e3 < n2; e3 += 4)
  43362. t2.indexArray.emplaceBack(e3, e3 + 1, e3 + 2), t2.indexArray.emplaceBack(e3 + 1, e3 + 2, e3 + 3);
  43363. }
  43364. getSortedSymbolIndexes(t2) {
  43365. if (this.sortedAngle === t2 && void 0 !== this.symbolInstanceIndexes)
  43366. return this.symbolInstanceIndexes;
  43367. const e2 = Math.sin(t2), r2 = Math.cos(t2), n2 = [], i3 = [], s2 = [];
  43368. for (let t3 = 0; t3 < this.symbolInstances.length; ++t3) {
  43369. s2.push(t3);
  43370. const a2 = this.symbolInstances.get(t3);
  43371. n2.push(0 | Math.round(e2 * a2.tileAnchorX + r2 * a2.tileAnchorY)), i3.push(a2.featureIndex);
  43372. }
  43373. return s2.sort((t3, e3) => n2[t3] - n2[e3] || i3[e3] - i3[t3]), s2;
  43374. }
  43375. addToSortKeyRanges(t2, e2) {
  43376. const r2 = this.sortKeyRanges[this.sortKeyRanges.length - 1];
  43377. r2 && r2.sortKey === e2 ? r2.symbolInstanceEnd = t2 + 1 : this.sortKeyRanges.push({ sortKey: e2, symbolInstanceStart: t2, symbolInstanceEnd: t2 + 1 });
  43378. }
  43379. sortFeatures(t2) {
  43380. if (this.sortFeaturesByY && this.sortedAngle !== t2 && !(this.text.segments.get().length > 1 || this.icon.segments.get().length > 1)) {
  43381. this.symbolInstanceIndexes = this.getSortedSymbolIndexes(t2), this.sortedAngle = t2, this.text.indexArray.clear(), this.icon.indexArray.clear(), this.featureSortOrder = [];
  43382. for (const t3 of this.symbolInstanceIndexes) {
  43383. const e2 = this.symbolInstances.get(t3);
  43384. this.featureSortOrder.push(e2.featureIndex), [e2.rightJustifiedTextSymbolIndex, e2.centerJustifiedTextSymbolIndex, e2.leftJustifiedTextSymbolIndex].forEach((t4, e3, r2) => {
  43385. t4 >= 0 && r2.indexOf(t4) === e3 && this.addIndicesForPlacedSymbol(this.text, t4);
  43386. }), e2.verticalPlacedTextSymbolIndex >= 0 && this.addIndicesForPlacedSymbol(this.text, e2.verticalPlacedTextSymbolIndex), e2.placedIconSymbolIndex >= 0 && this.addIndicesForPlacedSymbol(this.icon, e2.placedIconSymbolIndex), e2.verticalPlacedIconSymbolIndex >= 0 && this.addIndicesForPlacedSymbol(this.icon, e2.verticalPlacedIconSymbolIndex);
  43387. }
  43388. this.text.indexBuffer && this.text.indexBuffer.updateData(this.text.indexArray), this.icon.indexBuffer && this.icon.indexBuffer.updateData(this.icon.indexArray);
  43389. }
  43390. }
  43391. }
  43392. ai(tp, "SymbolBucket", { omit: ["layers", "collisionBoxArray", "features", "compareText"] }), tp.MAX_GLYPHS = 65535, tp.addDynamicAttributes = Hh;
  43393. const ep = new vs({ "symbol-placement": new ds($t.layout_symbol["symbol-placement"]), "symbol-spacing": new ds($t.layout_symbol["symbol-spacing"]), "symbol-avoid-edges": new ds($t.layout_symbol["symbol-avoid-edges"]), "symbol-sort-key": new ys($t.layout_symbol["symbol-sort-key"]), "symbol-z-order": new ds($t.layout_symbol["symbol-z-order"]), "icon-allow-overlap": new ds($t.layout_symbol["icon-allow-overlap"]), "icon-ignore-placement": new ds($t.layout_symbol["icon-ignore-placement"]), "icon-optional": new ds($t.layout_symbol["icon-optional"]), "icon-rotation-alignment": new ds($t.layout_symbol["icon-rotation-alignment"]), "icon-size": new ys($t.layout_symbol["icon-size"]), "icon-text-fit": new ds($t.layout_symbol["icon-text-fit"]), "icon-text-fit-padding": new ds($t.layout_symbol["icon-text-fit-padding"]), "icon-image": new ys($t.layout_symbol["icon-image"]), "icon-rotate": new ys($t.layout_symbol["icon-rotate"]), "icon-padding": new ds($t.layout_symbol["icon-padding"]), "icon-keep-upright": new ds($t.layout_symbol["icon-keep-upright"]), "icon-offset": new ys($t.layout_symbol["icon-offset"]), "icon-anchor": new ys($t.layout_symbol["icon-anchor"]), "icon-pitch-alignment": new ds($t.layout_symbol["icon-pitch-alignment"]), "text-pitch-alignment": new ds($t.layout_symbol["text-pitch-alignment"]), "text-rotation-alignment": new ds($t.layout_symbol["text-rotation-alignment"]), "text-field": new ys($t.layout_symbol["text-field"]), "text-font": new ys($t.layout_symbol["text-font"]), "text-size": new ys($t.layout_symbol["text-size"]), "text-max-width": new ys($t.layout_symbol["text-max-width"]), "text-line-height": new ys($t.layout_symbol["text-line-height"]), "text-letter-spacing": new ys($t.layout_symbol["text-letter-spacing"]), "text-justify": new ys($t.layout_symbol["text-justify"]), "text-radial-offset": new ys($t.layout_symbol["text-radial-offset"]), "text-variable-anchor": new ds($t.layout_symbol["text-variable-anchor"]), "text-anchor": new ys($t.layout_symbol["text-anchor"]), "text-max-angle": new ds($t.layout_symbol["text-max-angle"]), "text-writing-mode": new ds($t.layout_symbol["text-writing-mode"]), "text-rotate": new ys($t.layout_symbol["text-rotate"]), "text-padding": new ds($t.layout_symbol["text-padding"]), "text-keep-upright": new ds($t.layout_symbol["text-keep-upright"]), "text-transform": new ys($t.layout_symbol["text-transform"]), "text-offset": new ys($t.layout_symbol["text-offset"]), "text-allow-overlap": new ds($t.layout_symbol["text-allow-overlap"]), "text-ignore-placement": new ds($t.layout_symbol["text-ignore-placement"]), "text-optional": new ds($t.layout_symbol["text-optional"]) });
  43394. var rp = { paint: new vs({ "icon-opacity": new ys($t.paint_symbol["icon-opacity"]), "icon-color": new ys($t.paint_symbol["icon-color"]), "icon-halo-color": new ys($t.paint_symbol["icon-halo-color"]), "icon-halo-width": new ys($t.paint_symbol["icon-halo-width"]), "icon-halo-blur": new ys($t.paint_symbol["icon-halo-blur"]), "icon-translate": new ds($t.paint_symbol["icon-translate"]), "icon-translate-anchor": new ds($t.paint_symbol["icon-translate-anchor"]), "text-opacity": new ys($t.paint_symbol["text-opacity"]), "text-color": new ys($t.paint_symbol["text-color"], { runtimeType: Ht, getOverride: (t2) => t2.textColor, hasOverride: (t2) => !!t2.textColor }), "text-halo-color": new ys($t.paint_symbol["text-halo-color"]), "text-halo-width": new ys($t.paint_symbol["text-halo-width"]), "text-halo-blur": new ys($t.paint_symbol["text-halo-blur"]), "text-translate": new ds($t.paint_symbol["text-translate"]), "text-translate-anchor": new ds($t.paint_symbol["text-translate-anchor"]) }), layout: ep };
  43395. class np {
  43396. constructor(t2) {
  43397. this.type = t2.property.overrides ? t2.property.overrides.runtimeType : Zt, this.defaultValue = t2;
  43398. }
  43399. evaluate(t2) {
  43400. if (t2.formattedSection) {
  43401. const e2 = this.defaultValue.property.overrides;
  43402. if (e2 && e2.hasOverride(t2.formattedSection))
  43403. return e2.getOverride(t2.formattedSection);
  43404. }
  43405. return t2.feature && t2.featureState ? this.defaultValue.evaluate(t2.feature, t2.featureState) : this.defaultValue.property.specification.default;
  43406. }
  43407. eachChild(t2) {
  43408. this.defaultValue.isConstant() || t2(this.defaultValue.value._styleExpression.expression);
  43409. }
  43410. outputDefined() {
  43411. return false;
  43412. }
  43413. serialize() {
  43414. return null;
  43415. }
  43416. }
  43417. ai(np, "FormatSectionOverride", { omit: ["defaultValue"] });
  43418. class ip extends Ga {
  43419. constructor(t2) {
  43420. super(t2, rp);
  43421. }
  43422. recalculate(t2, e2) {
  43423. super.recalculate(t2, e2), "auto" === this.layout.get("icon-rotation-alignment") && (this.layout._values["icon-rotation-alignment"] = "point" !== this.layout.get("symbol-placement") ? "map" : "viewport"), "auto" === this.layout.get("text-rotation-alignment") && (this.layout._values["text-rotation-alignment"] = "point" !== this.layout.get("symbol-placement") ? "map" : "viewport"), "auto" === this.layout.get("text-pitch-alignment") && (this.layout._values["text-pitch-alignment"] = this.layout.get("text-rotation-alignment")), "auto" === this.layout.get("icon-pitch-alignment") && (this.layout._values["icon-pitch-alignment"] = this.layout.get("icon-rotation-alignment"));
  43424. const r2 = this.layout.get("text-writing-mode");
  43425. if (r2) {
  43426. const t3 = [];
  43427. for (const e3 of r2)
  43428. t3.indexOf(e3) < 0 && t3.push(e3);
  43429. this.layout._values["text-writing-mode"] = t3;
  43430. } else
  43431. this.layout._values["text-writing-mode"] = "point" === this.layout.get("symbol-placement") ? ["horizontal"] : ["horizontal", "vertical"];
  43432. this._setPaintOverrides();
  43433. }
  43434. getValueAndResolveTokens(t2, e2, r2, n2) {
  43435. const i3 = this.layout.get(t2).evaluate(e2, {}, r2, n2), s2 = this._unevaluatedLayout._values[t2];
  43436. return s2.isDataDriven() || un(s2.value) || !i3 ? i3 : function(t3, e3) {
  43437. return e3.replace(/{([^{}]+)}/g, (e4, r3) => r3 in t3 ? String(t3[r3]) : "");
  43438. }(e2.properties, i3);
  43439. }
  43440. createBucket(t2) {
  43441. return new tp(t2);
  43442. }
  43443. queryRadius() {
  43444. return 0;
  43445. }
  43446. queryIntersectsFeature() {
  43447. return false;
  43448. }
  43449. _setPaintOverrides() {
  43450. for (const t2 of rp.paint.overridableProperties) {
  43451. if (!ip.hasPaintOverride(this.layout, t2))
  43452. continue;
  43453. const e2 = this.paint.get(t2), r2 = new np(e2), n2 = new ln(r2, e2.property.specification);
  43454. let i3 = null;
  43455. i3 = "constant" === e2.value.kind || "source" === e2.value.kind ? new hn("source", n2) : new pn("composite", n2, e2.value.zoomStops, e2.value._interpolationType), this.paint._values[t2] = new ps(e2.property, i3, e2.parameters);
  43456. }
  43457. }
  43458. _handleOverridablePaintPropertyUpdate(t2, e2, r2) {
  43459. return !(!this.layout || e2.isDataDriven() || r2.isDataDriven()) && ip.hasPaintOverride(this.layout, t2);
  43460. }
  43461. static hasPaintOverride(t2, e2) {
  43462. const r2 = t2.get("text-field"), n2 = rp.paint.properties[e2];
  43463. let i3 = false;
  43464. const s2 = (t3) => {
  43465. for (const e3 of t3)
  43466. if (n2.overrides && n2.overrides.hasOverride(e3))
  43467. return void (i3 = true);
  43468. };
  43469. if ("constant" === r2.value.kind && r2.value.value instanceof fe)
  43470. s2(r2.value.value.sections);
  43471. else if ("source" === r2.value.kind) {
  43472. const t3 = (e4) => {
  43473. i3 || (e4 instanceof ve && ge(e4.value) === te ? s2(e4.value.sections) : e4 instanceof Ae ? s2(e4.sections) : e4.eachChild(t3));
  43474. }, e3 = r2.value;
  43475. e3._styleExpression && t3(e3._styleExpression.expression);
  43476. }
  43477. return i3;
  43478. }
  43479. getProgramConfiguration(t2) {
  43480. return new La(this, t2);
  43481. }
  43482. }
  43483. var sp = { paint: new vs({ "background-color": new ds($t.paint_background["background-color"]), "background-pattern": new gs($t.paint_background["background-pattern"]), "background-opacity": new ds($t.paint_background["background-opacity"]) }) }, ap = { paint: new vs({ "raster-opacity": new ds($t.paint_raster["raster-opacity"]), "raster-hue-rotate": new ds($t.paint_raster["raster-hue-rotate"]), "raster-brightness-min": new ds($t.paint_raster["raster-brightness-min"]), "raster-brightness-max": new ds($t.paint_raster["raster-brightness-max"]), "raster-saturation": new ds($t.paint_raster["raster-saturation"]), "raster-contrast": new ds($t.paint_raster["raster-contrast"]), "raster-resampling": new ds($t.paint_raster["raster-resampling"]), "raster-fade-duration": new ds($t.paint_raster["raster-fade-duration"]) }) };
  43484. class op extends Ga {
  43485. constructor(t2) {
  43486. super(t2, {}), this.implementation = t2;
  43487. }
  43488. is3D() {
  43489. return "3d" === this.implementation.renderingMode;
  43490. }
  43491. hasOffscreenPass() {
  43492. return void 0 !== this.implementation.prerender;
  43493. }
  43494. recalculate() {
  43495. }
  43496. updateTransitions() {
  43497. }
  43498. hasTransition() {
  43499. return false;
  43500. }
  43501. serialize() {
  43502. }
  43503. onAdd(t2) {
  43504. this.implementation.onAdd && this.implementation.onAdd(t2, t2.painter.context.gl);
  43505. }
  43506. onRemove(t2) {
  43507. this.implementation.onRemove && this.implementation.onRemove(t2, t2.painter.context.gl);
  43508. }
  43509. }
  43510. var lp = { paint: new vs({ "sky-type": new ds($t.paint_sky["sky-type"]), "sky-atmosphere-sun": new ds($t.paint_sky["sky-atmosphere-sun"]), "sky-atmosphere-sun-intensity": new ds($t.paint_sky["sky-atmosphere-sun-intensity"]), "sky-gradient-center": new ds($t.paint_sky["sky-gradient-center"]), "sky-gradient-radius": new ds($t.paint_sky["sky-gradient-radius"]), "sky-gradient": new xs($t.paint_sky["sky-gradient"]), "sky-atmosphere-halo-color": new ds($t.paint_sky["sky-atmosphere-halo-color"]), "sky-atmosphere-color": new ds($t.paint_sky["sky-atmosphere-color"]), "sky-opacity": new ds($t.paint_sky["sky-opacity"]) }) };
  43511. function up(t2, e2, r2) {
  43512. const n2 = [0, 0, 1], i3 = ml([]);
  43513. return function(t3, e3, r3) {
  43514. r3 *= 0.5;
  43515. var n3 = e3[0], i4 = e3[1], s2 = e3[2], a2 = e3[3], o2 = Math.sin(r3), l2 = Math.cos(r3);
  43516. t3[0] = n3 * l2 - s2 * o2, t3[1] = i4 * l2 + a2 * o2, t3[2] = s2 * l2 + n3 * o2, t3[3] = a2 * l2 - i4 * o2;
  43517. }(i3, i3, r2 ? -u(t2) + Math.PI : u(t2)), gl(i3, i3, -u(e2)), ul(n2, n2, i3), sl(n2, n2);
  43518. }
  43519. const cp = { circle: class extends Ga {
  43520. constructor(t2) {
  43521. super(t2, Lo);
  43522. }
  43523. createBucket(t2) {
  43524. return new vo(t2);
  43525. }
  43526. queryRadius(t2) {
  43527. const e2 = t2;
  43528. return Co("circle-radius", this, e2) + Co("circle-stroke-width", this, e2) + Do(this.paint.get("circle-translate"));
  43529. }
  43530. queryIntersectsFeature(t2, e2, r2, n2, i3, s2, a2, o2) {
  43531. const l2 = Vo(this.paint.get("circle-translate"), this.paint.get("circle-translate-anchor"), s2.angle, t2.pixelToTileUnitsFactor), u2 = this.paint.get("circle-radius").evaluate(e2, r2) + this.paint.get("circle-stroke-width").evaluate(e2, r2);
  43532. return bl(t2, n2, s2, a2, o2, "map" === this.paint.get("circle-pitch-alignment"), "map" === this.paint.get("circle-pitch-scale"), l2, u2);
  43533. }
  43534. getProgramIds() {
  43535. return ["circle"];
  43536. }
  43537. getProgramConfiguration(t2) {
  43538. return new La(this, t2);
  43539. }
  43540. }, heatmap: class extends Ga {
  43541. createBucket(t2) {
  43542. return new Sl(t2);
  43543. }
  43544. constructor(t2) {
  43545. super(t2, El), this._updateColorRamp();
  43546. }
  43547. _handleSpecialPaintPropertyUpdate(t2) {
  43548. "heatmap-color" === t2 && this._updateColorRamp();
  43549. }
  43550. _updateColorRamp() {
  43551. this.colorRamp = Cl({ expression: this._transitionablePaint._values["heatmap-color"].value.expression, evaluationKey: "heatmapDensity", image: this.colorRamp }), this.colorRampTexture = null;
  43552. }
  43553. resize() {
  43554. this.heatmapFbo && (this.heatmapFbo.destroy(), this.heatmapFbo = null);
  43555. }
  43556. queryRadius(t2) {
  43557. return Co("heatmap-radius", this, t2);
  43558. }
  43559. queryIntersectsFeature(t2, e2, r2, n2, s2, a2, o2, l2) {
  43560. const u2 = this.paint.get("heatmap-radius").evaluate(e2, r2);
  43561. return bl(t2, n2, a2, o2, l2, true, true, new i2(0, 0), u2);
  43562. }
  43563. hasOffscreenPass() {
  43564. return 0 !== this.paint.get("heatmap-opacity") && "none" !== this.visibility;
  43565. }
  43566. getProgramIds() {
  43567. return ["heatmap", "heatmapTexture"];
  43568. }
  43569. getProgramConfiguration(t2) {
  43570. return new La(this, t2);
  43571. }
  43572. }, hillshade: class extends Ga {
  43573. constructor(t2) {
  43574. super(t2, Dl);
  43575. }
  43576. hasOffscreenPass() {
  43577. return 0 !== this.paint.get("hillshade-exaggeration") && "none" !== this.visibility;
  43578. }
  43579. getProgramIds() {
  43580. return ["hillshade", "hillshadePrepare"];
  43581. }
  43582. }, fill: class extends Ga {
  43583. constructor(t2) {
  43584. super(t2, bu);
  43585. }
  43586. getProgramIds() {
  43587. const t2 = this.paint.get("fill-pattern"), e2 = t2 && t2.constantOr(1), r2 = [e2 ? "fillPattern" : "fill"];
  43588. return this.paint.get("fill-antialias") && r2.push(e2 && !this.getPaintProperty("fill-outline-color") ? "fillOutlinePattern" : "fillOutline"), r2;
  43589. }
  43590. getProgramConfiguration(t2) {
  43591. return new La(this, t2);
  43592. }
  43593. recalculate(t2, e2) {
  43594. super.recalculate(t2, e2);
  43595. const r2 = this.paint._values["fill-outline-color"];
  43596. "constant" === r2.value.kind && void 0 === r2.value.value && (this.paint._values["fill-outline-color"] = this.paint._values["fill-color"]);
  43597. }
  43598. createBucket(t2) {
  43599. return new xu(t2);
  43600. }
  43601. queryRadius() {
  43602. return Do(this.paint.get("fill-translate"));
  43603. }
  43604. queryIntersectsFeature(t2, e2, r2, n2, i3, s2) {
  43605. return !t2.queryGeometry.isAboveHorizon && wo(Po(t2.tilespaceGeometry, this.paint.get("fill-translate"), this.paint.get("fill-translate-anchor"), s2.angle, t2.pixelToTileUnitsFactor), n2);
  43606. }
  43607. isTileClipped() {
  43608. return true;
  43609. }
  43610. }, "fill-extrusion": class extends Ga {
  43611. constructor(t2) {
  43612. super(t2, Ou);
  43613. }
  43614. createBucket(t2) {
  43615. return new $u(t2);
  43616. }
  43617. queryRadius() {
  43618. return Do(this.paint.get("fill-extrusion-translate"));
  43619. }
  43620. is3D() {
  43621. return true;
  43622. }
  43623. getProgramIds() {
  43624. return [this.paint.get("fill-extrusion-pattern").constantOr(1) ? "fillExtrusionPattern" : "fillExtrusion"];
  43625. }
  43626. getProgramConfiguration(t2) {
  43627. return new La(this, t2);
  43628. }
  43629. queryIntersectsFeature(t2, e2, r2, n2, s2, a2, o2, l2, u2) {
  43630. const c2 = Vo(this.paint.get("fill-extrusion-translate"), this.paint.get("fill-extrusion-translate-anchor"), a2.angle, t2.pixelToTileUnitsFactor), h2 = this.paint.get("fill-extrusion-height").evaluate(e2, r2), p2 = this.paint.get("fill-extrusion-base").evaluate(e2, r2), f2 = [0, 0], d2 = l2 && a2.elevation, y2 = a2.elevation ? a2.elevation.exaggeration() : 1, m2 = t2.tile.getBucket(this);
  43631. if (d2 && m2 instanceof $u) {
  43632. const t3 = m2.centroidVertexArray, e3 = u2 + 1;
  43633. if (e3 < t3.length) {
  43634. const r3 = t3.get(e3);
  43635. f2[0] = r3.a_centroid_pos0, f2[1] = r3.a_centroid_pos1;
  43636. }
  43637. }
  43638. if (0 === f2[0] && 1 === f2[1])
  43639. return false;
  43640. const g2 = function(t3, e3, r3, n3, s3, a3, o3, l3, u3) {
  43641. return a3 ? function(t4, e4, r4, n4, i3, s4, a4, o4, l4) {
  43642. const u4 = [], c3 = [], h3 = [0, 0, 0, 1];
  43643. for (const p3 of t4) {
  43644. const t5 = [], f3 = [];
  43645. for (const u5 of p3) {
  43646. const c4 = u5.x + n4.x, p4 = u5.y + n4.y, d3 = Zu(c4, p4, e4, r4, s4, a4, o4, l4);
  43647. h3[0] = c4, h3[1] = p4, h3[2] = d3.base, h3[3] = 1, dl(h3, h3, i3), h3[3] = Math.max(h3[3], 1e-5);
  43648. const y3 = Gu([h3[0] / h3[3], h3[1] / h3[3], h3[2] / h3[3]]);
  43649. h3[0] = c4, h3[1] = p4, h3[2] = d3.top, h3[3] = 1, dl(h3, h3, i3), h3[3] = Math.max(h3[3], 1e-5);
  43650. const m3 = Gu([h3[0] / h3[3], h3[1] / h3[3], h3[2] / h3[3]]);
  43651. t5.push(y3), f3.push(m3);
  43652. }
  43653. u4.push(t5), c3.push(f3);
  43654. }
  43655. return [u4, c3];
  43656. }(t3, e3, r3, n3, s3, a3, o3, l3, u3) : function(t4, e4, r4, n4, s4) {
  43657. const a4 = [], o4 = [], l4 = s4[8] * e4, u4 = s4[9] * e4, c3 = s4[10] * e4, h3 = s4[11] * e4, p3 = s4[8] * r4, f3 = s4[9] * r4, d3 = s4[10] * r4, y3 = s4[11] * r4;
  43658. for (const e5 of t4) {
  43659. const t5 = [], r5 = [];
  43660. for (const a5 of e5) {
  43661. const e6 = a5.x + n4.x, o5 = a5.y + n4.y, m3 = s4[0] * e6 + s4[4] * o5 + s4[12], g3 = s4[1] * e6 + s4[5] * o5 + s4[13], x3 = s4[2] * e6 + s4[6] * o5 + s4[14], v2 = s4[3] * e6 + s4[7] * o5 + s4[15], b2 = m3 + l4, _2 = g3 + u4, w2 = x3 + c3, A2 = Math.max(v2 + h3, 1e-5), k2 = m3 + p3, S2 = g3 + f3, I2 = x3 + d3, M2 = Math.max(v2 + y3, 1e-5), T2 = new i2(b2 / A2, _2 / A2);
  43662. T2.z = w2 / A2, t5.push(T2);
  43663. const z2 = new i2(k2 / M2, S2 / M2);
  43664. z2.z = I2 / M2, r5.push(z2);
  43665. }
  43666. a4.push(t5), o4.push(r5);
  43667. }
  43668. return [a4, o4];
  43669. }(t3, e3, r3, n3, s3);
  43670. }(n2, p2, h2, c2, o2, d2 ? l2 : null, f2, y2, a2.center.lat), x2 = t2.queryGeometry;
  43671. return function(t3, e3, r3) {
  43672. let n3 = 1 / 0;
  43673. wo(r3, e3) && (n3 = Nu(r3, e3[0]));
  43674. for (let i3 = 0; i3 < e3.length; i3++) {
  43675. const s3 = e3[i3], a3 = t3[i3];
  43676. for (let t4 = 0; t4 < s3.length - 1; t4++) {
  43677. const e4 = s3[t4], i4 = [e4, s3[t4 + 1], a3[t4 + 1], a3[t4], e4];
  43678. bo(r3, i4) && (n3 = Math.min(n3, Nu(r3, i4)));
  43679. }
  43680. }
  43681. return n3 !== 1 / 0 && n3;
  43682. }(g2[0], g2[1], x2.isPointQuery() ? x2.screenBounds : x2.screenGeometry);
  43683. }
  43684. }, line: class extends Ga {
  43685. constructor(t2) {
  43686. super(t2, ec), this.gradientVersion = 0;
  43687. }
  43688. _handleSpecialPaintPropertyUpdate(t2) {
  43689. if ("line-gradient" === t2) {
  43690. const t3 = this._transitionablePaint._values["line-gradient"].value.expression;
  43691. this.stepInterpolant = t3._styleExpression && t3._styleExpression.expression instanceof er, this.gradientVersion = (this.gradientVersion + 1) % Number.MAX_SAFE_INTEGER;
  43692. }
  43693. }
  43694. gradientExpression() {
  43695. return this._transitionablePaint._values["line-gradient"].value.expression;
  43696. }
  43697. recalculate(t2, e2) {
  43698. super.recalculate(t2, e2), this.paint._values["line-floorwidth"] = rc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value, t2);
  43699. }
  43700. createBucket(t2) {
  43701. return new Qu(t2);
  43702. }
  43703. getProgramIds() {
  43704. return [this.paint.get("line-pattern").constantOr(1) ? "linePattern" : "line"];
  43705. }
  43706. getProgramConfiguration(t2) {
  43707. return new La(this, t2);
  43708. }
  43709. queryRadius(t2) {
  43710. const e2 = t2, r2 = nc(Co("line-width", this, e2), Co("line-gap-width", this, e2)), n2 = Co("line-offset", this, e2);
  43711. return r2 / 2 + Math.abs(n2) + Do(this.paint.get("line-translate"));
  43712. }
  43713. queryIntersectsFeature(t2, e2, r2, n2, s2, a2) {
  43714. if (t2.queryGeometry.isAboveHorizon)
  43715. return false;
  43716. const o2 = Po(t2.tilespaceGeometry, this.paint.get("line-translate"), this.paint.get("line-translate-anchor"), a2.angle, t2.pixelToTileUnitsFactor), l2 = t2.pixelToTileUnitsFactor / 2 * nc(this.paint.get("line-width").evaluate(e2, r2), this.paint.get("line-gap-width").evaluate(e2, r2)), u2 = this.paint.get("line-offset").evaluate(e2, r2);
  43717. return u2 && (n2 = function(t3, e3) {
  43718. const r3 = [], n3 = new i2(0, 0);
  43719. for (let i3 = 0; i3 < t3.length; i3++) {
  43720. const s3 = t3[i3], a3 = [];
  43721. for (let t4 = 0; t4 < s3.length; t4++) {
  43722. const r4 = s3[t4 - 1], i4 = s3[t4], o3 = s3[t4 + 1], l3 = 0 === t4 ? n3 : i4.sub(r4)._unit()._perp(), u3 = t4 === s3.length - 1 ? n3 : o3.sub(i4)._unit()._perp(), c2 = l3._add(u3)._unit();
  43723. c2._mult(1 / (c2.x * u3.x + c2.y * u3.y)), a3.push(c2._mult(e3)._add(i4));
  43724. }
  43725. r3.push(a3);
  43726. }
  43727. return r3;
  43728. }(n2, u2 * t2.pixelToTileUnitsFactor)), function(t3, e3, r3) {
  43729. for (let n3 = 0; n3 < e3.length; n3++) {
  43730. const i3 = e3[n3];
  43731. if (t3.length >= 3) {
  43732. for (let e4 = 0; e4 < i3.length; e4++)
  43733. if (zo(t3, i3[e4]))
  43734. return true;
  43735. }
  43736. if (Ao(t3, i3, r3))
  43737. return true;
  43738. }
  43739. return false;
  43740. }(o2, n2, l2);
  43741. }
  43742. isTileClipped() {
  43743. return true;
  43744. }
  43745. }, symbol: ip, background: class extends Ga {
  43746. constructor(t2) {
  43747. super(t2, sp);
  43748. }
  43749. getProgramIds() {
  43750. return [this.paint.get("background-pattern") ? "backgroundPattern" : "background"];
  43751. }
  43752. }, raster: class extends Ga {
  43753. constructor(t2) {
  43754. super(t2, ap);
  43755. }
  43756. getProgramIds() {
  43757. return ["raster"];
  43758. }
  43759. }, sky: class extends Ga {
  43760. constructor(t2) {
  43761. super(t2, lp), this._updateColorRamp();
  43762. }
  43763. _handleSpecialPaintPropertyUpdate(t2) {
  43764. "sky-gradient" === t2 ? this._updateColorRamp() : "sky-atmosphere-sun" !== t2 && "sky-atmosphere-halo-color" !== t2 && "sky-atmosphere-color" !== t2 && "sky-atmosphere-sun-intensity" !== t2 || (this._skyboxInvalidated = true);
  43765. }
  43766. _updateColorRamp() {
  43767. this.colorRamp = Cl({ expression: this._transitionablePaint._values["sky-gradient"].value.expression, evaluationKey: "skyRadialProgress" }), this.colorRampTexture && (this.colorRampTexture.destroy(), this.colorRampTexture = null);
  43768. }
  43769. needsSkyboxCapture(t2) {
  43770. if (this._skyboxInvalidated || !this.skyboxTexture || !this.skyboxGeometry)
  43771. return true;
  43772. if (!this.paint.get("sky-atmosphere-sun")) {
  43773. const e2 = t2.style.light.properties.get("position");
  43774. return this._lightPosition.azimuthal !== e2.azimuthal || this._lightPosition.polar !== e2.polar;
  43775. }
  43776. return false;
  43777. }
  43778. getCenter(t2, e2) {
  43779. if ("atmosphere" === this.paint.get("sky-type")) {
  43780. const r3 = this.paint.get("sky-atmosphere-sun"), n2 = !r3, i3 = t2.style.light, s2 = i3.properties.get("position");
  43781. return n2 && "viewport" === i3.properties.get("anchor") && C("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."), n2 ? up(s2.azimuthal, 90 - s2.polar, e2) : up(r3[0], 90 - r3[1], e2);
  43782. }
  43783. const r2 = this.paint.get("sky-gradient-center");
  43784. return up(r2[0], 90 - r2[1], e2);
  43785. }
  43786. is3D() {
  43787. return false;
  43788. }
  43789. isSky() {
  43790. return true;
  43791. }
  43792. markSkyboxValid(t2) {
  43793. this._skyboxInvalidated = false, this._lightPosition = t2.style.light.properties.get("position");
  43794. }
  43795. hasOffscreenPass() {
  43796. return true;
  43797. }
  43798. getProgramIds() {
  43799. const t2 = this.paint.get("sky-type");
  43800. return "atmosphere" === t2 ? ["skyboxCapture", "skybox"] : "gradient" === t2 ? ["skyboxGradient"] : null;
  43801. }
  43802. } };
  43803. class hp {
  43804. constructor(t2, e2, r2, n2) {
  43805. this.context = t2, this.format = r2, this.texture = t2.gl.createTexture(), this.update(e2, n2);
  43806. }
  43807. update(t2, e2, r2) {
  43808. const { width: n2, height: i3 } = t2, { context: s2 } = this, { gl: o2 } = s2, { HTMLImageElement: l2, HTMLCanvasElement: u2, HTMLVideoElement: c2, ImageData: h2, ImageBitmap: p2 } = a;
  43809. if (o2.bindTexture(o2.TEXTURE_2D, this.texture), s2.pixelStoreUnpackFlipY.set(false), s2.pixelStoreUnpack.set(1), s2.pixelStoreUnpackPremultiplyAlpha.set(this.format === o2.RGBA && (!e2 || false !== e2.premultiply)), r2 || this.size && this.size[0] === n2 && this.size[1] === i3) {
  43810. const { x: e3, y: s3 } = r2 || { x: 0, y: 0 };
  43811. t2 instanceof l2 || t2 instanceof u2 || t2 instanceof c2 || t2 instanceof h2 || p2 && t2 instanceof p2 ? o2.texSubImage2D(o2.TEXTURE_2D, 0, e3, s3, o2.RGBA, o2.UNSIGNED_BYTE, t2) : o2.texSubImage2D(o2.TEXTURE_2D, 0, e3, s3, n2, i3, o2.RGBA, o2.UNSIGNED_BYTE, t2.data);
  43812. } else
  43813. this.size = [n2, i3], t2 instanceof l2 || t2 instanceof u2 || t2 instanceof c2 || t2 instanceof h2 || p2 && t2 instanceof p2 ? o2.texImage2D(o2.TEXTURE_2D, 0, this.format, this.format, o2.UNSIGNED_BYTE, t2) : o2.texImage2D(o2.TEXTURE_2D, 0, this.format, n2, i3, 0, this.format, o2.UNSIGNED_BYTE, t2.data);
  43814. this.useMipmap = Boolean(e2 && e2.useMipmap && this.isSizePowerOfTwo()), this.useMipmap && o2.generateMipmap(o2.TEXTURE_2D);
  43815. }
  43816. bind(t2, e2) {
  43817. const { context: r2 } = this, { gl: n2 } = r2;
  43818. n2.bindTexture(n2.TEXTURE_2D, this.texture), t2 !== this.filter && (n2.texParameteri(n2.TEXTURE_2D, n2.TEXTURE_MAG_FILTER, t2), n2.texParameteri(n2.TEXTURE_2D, n2.TEXTURE_MIN_FILTER, this.useMipmap ? t2 === n2.NEAREST ? n2.NEAREST_MIPMAP_NEAREST : n2.LINEAR_MIPMAP_NEAREST : t2), this.filter = t2), e2 !== this.wrap && (n2.texParameteri(n2.TEXTURE_2D, n2.TEXTURE_WRAP_S, e2), n2.texParameteri(n2.TEXTURE_2D, n2.TEXTURE_WRAP_T, e2), this.wrap = e2);
  43819. }
  43820. isSizePowerOfTwo() {
  43821. return this.size[0] === this.size[1] && Math.log(this.size[0]) / Math.LN2 % 1 == 0;
  43822. }
  43823. destroy() {
  43824. const { gl: t2 } = this.context;
  43825. t2.deleteTexture(this.texture), this.texture = null;
  43826. }
  43827. }
  43828. class pp {
  43829. constructor(t2, e2) {
  43830. this.width = t2, this.height = e2, this.nextRow = 0, this.image = new zl({ width: t2, height: e2 }), this.positions = {}, this.uploaded = false;
  43831. }
  43832. getDash(t2, e2) {
  43833. const r2 = this.getKey(t2, e2);
  43834. return this.positions[r2];
  43835. }
  43836. trim() {
  43837. const t2 = this.width, e2 = this.height = k(this.nextRow);
  43838. this.image.resize({ width: t2, height: e2 });
  43839. }
  43840. getKey(t2, e2) {
  43841. return t2.join(",") + e2;
  43842. }
  43843. getDashRanges(t2, e2, r2) {
  43844. const n2 = [];
  43845. let i3 = t2.length % 2 == 1 ? -t2[t2.length - 1] * r2 : 0, s2 = t2[0] * r2, a2 = true;
  43846. n2.push({ left: i3, right: s2, isDash: a2, zeroLength: 0 === t2[0] });
  43847. let o2 = t2[0];
  43848. for (let e3 = 1; e3 < t2.length; e3++) {
  43849. a2 = !a2;
  43850. const l2 = t2[e3];
  43851. i3 = o2 * r2, o2 += l2, s2 = o2 * r2, n2.push({ left: i3, right: s2, isDash: a2, zeroLength: 0 === l2 });
  43852. }
  43853. return n2;
  43854. }
  43855. addRoundDash(t2, e2, r2) {
  43856. const n2 = e2 / 2;
  43857. for (let e3 = -r2; e3 <= r2; e3++) {
  43858. const i3 = this.width * (this.nextRow + r2 + e3);
  43859. let s2 = 0, a2 = t2[s2];
  43860. for (let o2 = 0; o2 < this.width; o2++) {
  43861. o2 / a2.right > 1 && (a2 = t2[++s2]);
  43862. const l2 = Math.abs(o2 - a2.left), u2 = Math.abs(o2 - a2.right), c2 = Math.min(l2, u2);
  43863. let h2;
  43864. const p2 = e3 / r2 * (n2 + 1);
  43865. if (a2.isDash) {
  43866. const t3 = n2 - Math.abs(p2);
  43867. h2 = Math.sqrt(c2 * c2 + t3 * t3);
  43868. } else
  43869. h2 = n2 - Math.sqrt(c2 * c2 + p2 * p2);
  43870. this.image.data[i3 + o2] = Math.max(0, Math.min(255, h2 + 128));
  43871. }
  43872. }
  43873. }
  43874. addRegularDash(t2, e2) {
  43875. for (let e3 = t2.length - 1; e3 >= 0; --e3) {
  43876. const r3 = t2[e3], n3 = t2[e3 + 1];
  43877. r3.zeroLength ? t2.splice(e3, 1) : n3 && n3.isDash === r3.isDash && (n3.left = r3.left, t2.splice(e3, 1));
  43878. }
  43879. const r2 = t2[0], n2 = t2[t2.length - 1];
  43880. r2.isDash === n2.isDash && (r2.left = n2.left - this.width, n2.right = r2.right + this.width);
  43881. const i3 = this.width * this.nextRow;
  43882. let s2 = 0, a2 = t2[s2];
  43883. for (let r3 = 0; r3 < this.width; r3++) {
  43884. r3 / a2.right > 1 && (a2 = t2[++s2]);
  43885. const n3 = Math.abs(r3 - a2.left), o2 = Math.abs(r3 - a2.right), l2 = Math.min(n3, o2);
  43886. this.image.data[i3 + r3] = Math.max(0, Math.min(255, (a2.isDash ? l2 : -l2) + e2 + 128));
  43887. }
  43888. }
  43889. addDash(t2, e2) {
  43890. const r2 = this.getKey(t2, e2);
  43891. if (this.positions[r2])
  43892. return this.positions[r2];
  43893. const n2 = "round" === e2, i3 = n2 ? 7 : 0, s2 = 2 * i3 + 1;
  43894. if (this.nextRow + s2 > this.height)
  43895. return C("LineAtlas out of space"), null;
  43896. 0 === t2.length && t2.push(1);
  43897. let a2 = 0;
  43898. for (let e3 = 0; e3 < t2.length; e3++)
  43899. t2[e3] < 0 && (C("Negative value is found in line dasharray, replacing values with 0"), t2[e3] = 0), a2 += t2[e3];
  43900. if (0 !== a2) {
  43901. const r3 = this.width / a2, s3 = this.getDashRanges(t2, this.width, r3);
  43902. n2 ? this.addRoundDash(s3, r3, i3) : this.addRegularDash(s3, "square" === e2 ? 0.5 * r3 : 0);
  43903. }
  43904. const o2 = this.nextRow + i3;
  43905. this.nextRow += s2;
  43906. const l2 = { tl: [o2, i3], br: [a2, 0] };
  43907. return this.positions[r2] = l2, l2;
  43908. }
  43909. }
  43910. ai(pp, "LineAtlas");
  43911. class fp {
  43912. constructor(t2) {
  43913. this._callback = t2, this._triggered = false, "undefined" != typeof MessageChannel && (this._channel = new MessageChannel(), this._channel.port2.onmessage = () => {
  43914. this._triggered = false, this._callback();
  43915. });
  43916. }
  43917. trigger() {
  43918. this._triggered || (this._triggered = true, this._channel ? this._channel.port1.postMessage(true) : setTimeout(() => {
  43919. this._triggered = false, this._callback();
  43920. }, 0));
  43921. }
  43922. remove() {
  43923. this._channel = void 0, this._callback = () => {
  43924. };
  43925. }
  43926. }
  43927. const dp = a.performance;
  43928. function yp(t2) {
  43929. const e2 = t2 ? t2.url.toString() : void 0;
  43930. return dp.getEntriesByName(e2);
  43931. }
  43932. class mp {
  43933. constructor() {
  43934. this.tasks = {}, this.taskQueue = [], I(["process"], this), this.invoker = new fp(this.process), this.nextId = 0;
  43935. }
  43936. add(t2, e2) {
  43937. const r2 = this.nextId++, n2 = function({ type: t3, isSymbolTile: e3, zoom: r3 }) {
  43938. return r3 = r3 || 0, "message" === t3 ? 0 : "maybePrepare" !== t3 || e3 ? "parseTile" !== t3 || e3 ? "parseTile" === t3 && e3 ? 300 - r3 : "maybePrepare" === t3 && e3 ? 400 - r3 : 500 : 200 - r3 : 100 - r3;
  43939. }(e2);
  43940. if (0 === n2) {
  43941. V();
  43942. try {
  43943. t2();
  43944. } finally {
  43945. }
  43946. return { cancel: () => {
  43947. } };
  43948. }
  43949. return this.tasks[r2] = { fn: t2, metadata: e2, priority: n2, id: r2 }, this.taskQueue.push(r2), this.invoker.trigger(), { cancel: () => {
  43950. delete this.tasks[r2];
  43951. } };
  43952. }
  43953. process() {
  43954. V();
  43955. try {
  43956. if (this.taskQueue = this.taskQueue.filter((t3) => !!this.tasks[t3]), !this.taskQueue.length)
  43957. return;
  43958. const t2 = this.pick();
  43959. if (null === t2)
  43960. return;
  43961. const e2 = this.tasks[t2];
  43962. if (delete this.tasks[t2], this.taskQueue.length && this.invoker.trigger(), !e2)
  43963. return;
  43964. e2.fn();
  43965. } finally {
  43966. }
  43967. }
  43968. pick() {
  43969. let t2 = null, e2 = 1 / 0;
  43970. for (let r3 = 0; r3 < this.taskQueue.length; r3++) {
  43971. const n2 = this.tasks[this.taskQueue[r3]];
  43972. n2.priority < e2 && (e2 = n2.priority, t2 = r3);
  43973. }
  43974. if (null === t2)
  43975. return null;
  43976. const r2 = this.taskQueue[t2];
  43977. return this.taskQueue.splice(t2, 1), r2;
  43978. }
  43979. remove() {
  43980. this.invoker.remove();
  43981. }
  43982. }
  43983. const gp = ks([{ type: "Float32", name: "a_globe_pos", components: 3 }, { type: "Float32", name: "a_merc_pos", components: 2 }, { type: "Float32", name: "a_uv", components: 2 }]), xp = ks([{ type: "Float32", name: "a_pos", components: 3 }, { type: "Float32", name: "a_uv", components: 2 }]), { members: vp } = gp, bp = ks([{ name: "a_pos_3", components: 3, type: "Int16" }]);
  43984. var _p = ks([{ name: "a_pos", type: "Int16", components: 2 }]);
  43985. const wp = Ya / Math.PI / 2, Ap = -wp, kp = wp, Sp = [new vl([Ap, Ap, Ap], [kp, kp, kp]), new vl([Ap, Ap, Ap], [0, 0, kp]), new vl([0, Ap, Ap], [kp, 0, kp]), new vl([Ap, 0, Ap], [0, kp, kp]), new vl([0, 0, Ap], [kp, kp, kp])];
  43986. class Ip {
  43987. constructor(t2, e2, r2) {
  43988. this.a = hl([], t2, r2), this.b = hl([], e2, r2), this.center = r2;
  43989. const n2 = sl([], this.a), i3 = sl([], this.b);
  43990. this.angle = Math.acos(al(n2, i3));
  43991. }
  43992. }
  43993. function Mp(t2, e2) {
  43994. if (0 === t2.angle)
  43995. return null;
  43996. let r2;
  43997. return r2 = 0 === t2.a[e2] ? 1 / t2.angle * 0.5 * Math.PI : 1 / t2.angle * Math.atan(t2.b[e2] / t2.a[e2] / Math.sin(t2.angle) - 1 / Math.tan(t2.angle)), r2 < 0 || r2 > 1 ? null : function(t3, e3, r3, n2) {
  43998. const i3 = Math.sin(r3);
  43999. return t3 * (Math.sin((1 - n2) * r3) / i3) + e3 * (Math.sin(n2 * r3) / i3);
  44000. }(t2.a[e2], t2.b[e2], t2.angle, y(r2, 0, 1)) + t2.center[e2];
  44001. }
  44002. function Tp(t2) {
  44003. if (t2.z <= 1)
  44004. return Sp[t2.z + 2 * t2.y + t2.x];
  44005. const [e2, r2] = Bp(t2), n2 = [Cp(e2[0], e2[1]), Cp(e2[0], r2[1]), Cp(r2[0], e2[1]), Cp(r2[0], r2[1])], i3 = [kp, kp, kp], s2 = [Ap, Ap, Ap];
  44006. for (const t3 of n2)
  44007. i3[0] = Math.min(i3[0], t3[0]), i3[1] = Math.min(i3[1], t3[1]), i3[2] = Math.min(i3[2], t3[2]), s2[0] = Math.max(s2[0], t3[0]), s2[1] = Math.max(s2[1], t3[1]), s2[2] = Math.max(s2[2], t3[2]);
  44008. return new vl(i3, s2);
  44009. }
  44010. function zp(t2, e2, r2) {
  44011. const n2 = e2 / t2.worldSize, i3 = (t3, e3) => {
  44012. nl(t3, t3, n2), nl(e3, e3, n2);
  44013. }, s2 = Number.MAX_VALUE, a2 = [-s2, -s2, -s2], o2 = [s2, s2, s2], l2 = Lp(t2);
  44014. if (r2.z <= 1) {
  44015. const t3 = Tp(r2).getCorners();
  44016. for (let e3 = 0; e3 < t3.length; e3++)
  44017. ll(t3[e3], t3[e3], l2), el(o2, o2, t3[e3]), rl(a2, a2, t3[e3]);
  44018. return i3(o2, a2), new vl(o2, a2);
  44019. }
  44020. const [c2, h2] = Bp(r2), p2 = new Ha();
  44021. p2.setSouthWest([c2[1], h2[0]]), p2.setNorthEast([h2[1], c2[0]]);
  44022. const f2 = [Cp(p2.getSouth(), p2.getWest()), Cp(p2.getSouth(), p2.getEast()), Cp(p2.getNorth(), p2.getEast()), Cp(p2.getNorth(), p2.getWest())];
  44023. for (let t3 = 0; t3 < f2.length; t3++)
  44024. ll(f2[t3], f2[t3], l2), el(o2, o2, f2[t3]), rl(a2, a2, f2[t3]);
  44025. if (p2.contains(t2.center))
  44026. return a2[2] = 0, i3(o2, a2), new vl(o2, a2);
  44027. const d2 = [l2[12], l2[13], l2[14]], m2 = t2.center.lng, g2 = y(t2.center.lat, -85.051129, oo), x2 = [eo(m2), ro(g2)], v2 = p2.getCenter().lng, b2 = y(p2.getCenter().lat, -85.051129, oo), _2 = [eo(v2), ro(b2)];
  44028. let w2 = new Array(3), A2 = 0;
  44029. const k2 = x2[0] - _2[0], S2 = x2[1] - _2[1];
  44030. if (Math.abs(k2) > Math.abs(S2))
  44031. A2 = k2 >= 0 ? 1 : 3, w2 = d2;
  44032. else {
  44033. A2 = S2 >= 0 ? 0 : 2;
  44034. const t3 = [l2[4], l2[5], l2[6]];
  44035. let e3;
  44036. e3 = S2 >= 0 ? -Math.sin(u(p2.getSouth())) * wp : -Math.sin(u(p2.getNorth())) * wp, w2 = il(w2, d2, t3, e3);
  44037. }
  44038. const I2 = f2[A2], M2 = f2[(A2 + 1) % 4], T2 = new Ip(I2, M2, w2), z2 = [Mp(T2, 0) || I2[0], Mp(T2, 1) || I2[1], Mp(T2, 2) || I2[2]];
  44039. return o2[2] = Math.min(I2[2], M2[2]), el(o2, o2, z2), rl(a2, a2, z2), i3(o2, a2), new vl(o2, a2);
  44040. }
  44041. function Bp(t2) {
  44042. const e2 = 1 << t2.z, r2 = t2.x / e2, n2 = (t2.x + 1) / e2, i3 = (t2.y + 1) / e2;
  44043. return [[so(t2.y / e2), io(r2)], [so(i3), io(n2)]];
  44044. }
  44045. function Ep(t2, e2, r2, n2 = wp) {
  44046. return r2 = u(r2), [t2 * Math.sin(r2) * n2, -e2 * n2, t2 * Math.cos(r2) * n2];
  44047. }
  44048. function Cp(t2, e2, r2) {
  44049. return Ep(Math.cos(u(t2)), Math.sin(u(t2)), e2, r2);
  44050. }
  44051. function Dp(t2, e2, r2) {
  44052. const n2 = Math.pow(2, r2.z), i3 = (t2 / Ya + r2.x) / n2;
  44053. return Cp(so((e2 / Ya + r2.y) / n2), io(i3));
  44054. }
  44055. function Pp(t2) {
  44056. return 16383 / Math.max(...hl([], t2.max, t2.min));
  44057. }
  44058. function Vp(t2) {
  44059. const e2 = jo(new Float64Array(16)), r2 = Pp(t2);
  44060. var n2, i3;
  44061. return No(e2, e2, [r2, r2, r2]), qo(e2, e2, ((n2 = [])[0] = -(i3 = t2.min)[0], n2[1] = -i3[1], n2[2] = -i3[2], n2)), e2;
  44062. }
  44063. function Fp(t2, e2, r2, n2, i3) {
  44064. const s2 = function(t3) {
  44065. const e3 = Ya / (2 * Math.PI);
  44066. return t3 / (2 * Math.PI) / e3;
  44067. }(r2), a2 = [t2, e2, -r2 / (2 * Math.PI)], o2 = jo(new Float64Array(16));
  44068. return qo(o2, o2, a2), No(o2, o2, [s2, s2, s2]), Go(o2, o2, u(-i3)), Zo(o2, o2, u(-n2)), o2;
  44069. }
  44070. function Lp(t2) {
  44071. const { x: e2, y: r2 } = t2.point, { lng: n2, lat: i3 } = t2._center;
  44072. return Fp(e2, r2, t2.worldSize, n2, i3);
  44073. }
  44074. const Rp = u(85), Up = Math.cos(Rp), $p = Math.sin(Rp);
  44075. function jp(t2, e2, r2) {
  44076. var n2 = 2 * Math.PI * 6378137 / 256 / Math.pow(2, r2);
  44077. return [t2 * n2 - 2 * Math.PI * 6378137 / 2, e2 * n2 - 2 * Math.PI * 6378137 / 2];
  44078. }
  44079. class Op {
  44080. constructor(t2, e2, r2) {
  44081. this.z = t2, this.x = e2, this.y = r2, this.key = Gp(0, t2, t2, e2, r2);
  44082. }
  44083. equals(t2) {
  44084. return this.z === t2.z && this.x === t2.x && this.y === t2.y;
  44085. }
  44086. url(t2, e2) {
  44087. const r2 = function(t3, e3, r3) {
  44088. var n3 = jp(256 * t3, 256 * (e3 = Math.pow(2, r3) - e3 - 1), r3), i3 = jp(256 * (t3 + 1), 256 * (e3 + 1), r3);
  44089. return n3[0] + "," + n3[1] + "," + i3[0] + "," + i3[1];
  44090. }(this.x, this.y, this.z), n2 = function(t3, e3, r3) {
  44091. let n3, i3 = "";
  44092. for (let s2 = t3; s2 > 0; s2--)
  44093. n3 = 1 << s2 - 1, i3 += (e3 & n3 ? 1 : 0) + (r3 & n3 ? 2 : 0);
  44094. return i3;
  44095. }(this.z, this.x, this.y);
  44096. return t2[(this.x + this.y) % t2.length].replace("{prefix}", (this.x % 16).toString(16) + (this.y % 16).toString(16)).replace("{z}", String(this.z)).replace("{x}", String(this.x)).replace("{y}", String("tms" === e2 ? Math.pow(2, this.z) - this.y - 1 : this.y)).replace("{quadkey}", n2).replace("{bbox-epsg-3857}", r2);
  44097. }
  44098. toString() {
  44099. return `${this.z}/${this.x}/${this.y}`;
  44100. }
  44101. }
  44102. class qp {
  44103. constructor(t2, e2) {
  44104. this.wrap = t2, this.canonical = e2, this.key = Gp(t2, e2.z, e2.z, e2.x, e2.y);
  44105. }
  44106. }
  44107. class Np {
  44108. constructor(t2, e2, r2, n2, i3) {
  44109. this.overscaledZ = t2, this.wrap = e2, this.canonical = new Op(r2, +n2, +i3), this.key = 0 === e2 && t2 === r2 ? this.canonical.key : Gp(e2, t2, r2, n2, i3);
  44110. }
  44111. equals(t2) {
  44112. return this.overscaledZ === t2.overscaledZ && this.wrap === t2.wrap && this.canonical.equals(t2.canonical);
  44113. }
  44114. scaledTo(t2) {
  44115. const e2 = this.canonical.z - t2;
  44116. return t2 > this.canonical.z ? new Np(t2, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y) : new Np(t2, this.wrap, t2, this.canonical.x >> e2, this.canonical.y >> e2);
  44117. }
  44118. calculateScaledKey(t2, e2 = true) {
  44119. if (this.overscaledZ === t2 && e2)
  44120. return this.key;
  44121. if (t2 > this.canonical.z)
  44122. return Gp(this.wrap * +e2, t2, this.canonical.z, this.canonical.x, this.canonical.y);
  44123. {
  44124. const r2 = this.canonical.z - t2;
  44125. return Gp(this.wrap * +e2, t2, t2, this.canonical.x >> r2, this.canonical.y >> r2);
  44126. }
  44127. }
  44128. isChildOf(t2) {
  44129. if (t2.wrap !== this.wrap)
  44130. return false;
  44131. const e2 = this.canonical.z - t2.canonical.z;
  44132. return 0 === t2.overscaledZ || t2.overscaledZ < this.overscaledZ && t2.canonical.x === this.canonical.x >> e2 && t2.canonical.y === this.canonical.y >> e2;
  44133. }
  44134. children(t2) {
  44135. if (this.overscaledZ >= t2)
  44136. return [new Np(this.overscaledZ + 1, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y)];
  44137. const e2 = this.canonical.z + 1, r2 = 2 * this.canonical.x, n2 = 2 * this.canonical.y;
  44138. return [new Np(e2, this.wrap, e2, r2, n2), new Np(e2, this.wrap, e2, r2 + 1, n2), new Np(e2, this.wrap, e2, r2, n2 + 1), new Np(e2, this.wrap, e2, r2 + 1, n2 + 1)];
  44139. }
  44140. isLessThan(t2) {
  44141. return this.wrap < t2.wrap || !(this.wrap > t2.wrap) && (this.overscaledZ < t2.overscaledZ || !(this.overscaledZ > t2.overscaledZ) && (this.canonical.x < t2.canonical.x || !(this.canonical.x > t2.canonical.x) && this.canonical.y < t2.canonical.y));
  44142. }
  44143. wrapped() {
  44144. return new Np(this.overscaledZ, 0, this.canonical.z, this.canonical.x, this.canonical.y);
  44145. }
  44146. unwrapTo(t2) {
  44147. return new Np(this.overscaledZ, t2, this.canonical.z, this.canonical.x, this.canonical.y);
  44148. }
  44149. overscaleFactor() {
  44150. return Math.pow(2, this.overscaledZ - this.canonical.z);
  44151. }
  44152. toUnwrapped() {
  44153. return new qp(this.wrap, this.canonical);
  44154. }
  44155. toString() {
  44156. return `${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`;
  44157. }
  44158. }
  44159. function Gp(t2, e2, r2, n2, i3) {
  44160. const s2 = 1 << Math.min(r2, 22);
  44161. let a2 = s2 * (i3 % s2) + n2 % s2;
  44162. return t2 && r2 < 22 && (a2 += s2 * s2 * ((t2 < 0 ? -2 * t2 - 1 : 2 * t2) % (1 << 2 * (22 - r2)))), 16 * (32 * a2 + r2) + (e2 - r2);
  44163. }
  44164. function Zp(t2, e2) {
  44165. if (!e2.isReprojectedInTileSpace)
  44166. return { scale: 1 << t2.z, x: t2.x, y: t2.y, x2: t2.x + 1, y2: t2.y + 1, projection: e2 };
  44167. const r2 = Math.pow(2, -t2.z), n2 = t2.x * r2, i3 = (t2.x + 1) * r2, s2 = t2.y * r2, a2 = (t2.y + 1) * r2, o2 = io(n2), l2 = io(i3), u2 = so(s2), c2 = so(a2), h2 = e2.project(o2, u2), p2 = e2.project(l2, u2), f2 = e2.project(l2, c2), d2 = e2.project(o2, c2);
  44168. let y2 = Math.min(h2.x, p2.x, f2.x, d2.x), m2 = Math.min(h2.y, p2.y, f2.y, d2.y), g2 = Math.max(h2.x, p2.x, f2.x, d2.x), x2 = Math.max(h2.y, p2.y, f2.y, d2.y);
  44169. const v2 = r2 / 16;
  44170. function b2(t3, r3, n3, i4, s3, a3) {
  44171. const o3 = (n3 + s3) / 2, l3 = (i4 + a3) / 2, u3 = e2.project(io(o3), so(l3)), c3 = Math.max(0, y2 - u3.x, m2 - u3.y, u3.x - g2, u3.y - x2);
  44172. y2 = Math.min(y2, u3.x), g2 = Math.max(g2, u3.x), m2 = Math.min(m2, u3.y), x2 = Math.max(x2, u3.y), c3 > v2 && (b2(t3, u3, n3, i4, o3, l3), b2(u3, r3, o3, l3, s3, a3));
  44173. }
  44174. b2(h2, p2, n2, s2, i3, s2), b2(p2, f2, i3, s2, i3, a2), b2(f2, d2, i3, a2, n2, a2), b2(d2, h2, n2, a2, n2, s2), y2 -= v2, m2 -= v2, g2 += v2, x2 += v2;
  44175. const _2 = 1 / Math.max(g2 - y2, x2 - m2);
  44176. return { scale: _2, x: y2 * _2, y: m2 * _2, x2: g2 * _2, y2: x2 * _2, projection: e2 };
  44177. }
  44178. ai(Op, "CanonicalTileID"), ai(Np, "OverscaledTileID", { omit: ["projMatrix"] });
  44179. class Xp {
  44180. constructor(t2) {
  44181. this._stringToNumber = {}, this._numberToString = [];
  44182. for (let e2 = 0; e2 < t2.length; e2++) {
  44183. const r2 = t2[e2];
  44184. this._stringToNumber[r2] = e2, this._numberToString[e2] = r2;
  44185. }
  44186. }
  44187. encode(t2) {
  44188. return this._stringToNumber[t2];
  44189. }
  44190. decode(t2) {
  44191. return this._numberToString[t2];
  44192. }
  44193. }
  44194. const Kp = ["tile", "layer", "source", "sourceLayer", "state"];
  44195. class Yp {
  44196. constructor(t2, e2, r2, n2, i3) {
  44197. this.type = "Feature", this._vectorTileFeature = t2, this._z = e2, this._x = r2, this._y = n2, this.properties = t2.properties, this.id = i3;
  44198. }
  44199. get geometry() {
  44200. return void 0 === this._geometry && (this._geometry = this._vectorTileFeature.toGeoJSON(this._x, this._y, this._z).geometry), this._geometry;
  44201. }
  44202. set geometry(t2) {
  44203. this._geometry = t2;
  44204. }
  44205. toJSON() {
  44206. const t2 = { type: "Feature", geometry: this.geometry, properties: this.properties };
  44207. void 0 !== this.id && (t2.id = this.id);
  44208. for (const e2 of Kp)
  44209. void 0 !== this[e2] && (t2[e2] = this[e2]);
  44210. return t2;
  44211. }
  44212. }
  44213. const Hp = 32, Wp = 33, Jp = new Uint16Array(8184);
  44214. for (let t2 = 0; t2 < 2046; t2++) {
  44215. let e2 = t2 + 2, r2 = 0, n2 = 0, i3 = 0, s2 = 0, a2 = 0, o2 = 0;
  44216. for (1 & e2 ? i3 = s2 = a2 = Hp : r2 = n2 = o2 = Hp; (e2 >>= 1) > 1; ) {
  44217. const t3 = r2 + i3 >> 1, l3 = n2 + s2 >> 1;
  44218. 1 & e2 ? (i3 = r2, s2 = n2, r2 = a2, n2 = o2) : (r2 = i3, n2 = s2, i3 = a2, s2 = o2), a2 = t3, o2 = l3;
  44219. }
  44220. const l2 = 4 * t2;
  44221. Jp[l2 + 0] = r2, Jp[l2 + 1] = n2, Jp[l2 + 2] = i3, Jp[l2 + 3] = s2;
  44222. }
  44223. const Qp = new Uint16Array(2178), tf = new Uint8Array(1089), ef = new Uint16Array(1089);
  44224. function rf(t2) {
  44225. return 0 === t2 ? -0.03125 : 32 === t2 ? 0.03125 : 0;
  44226. }
  44227. var nf = ks([{ name: "a_pos", type: "Int16", components: 2 }, { name: "a_texture_pos", type: "Int16", components: 2 }]);
  44228. const sf = { type: 2, extent: Ya, loadGeometry: () => [[new i2(0, 0), new i2(8193, 0), new i2(8193, 8193), new i2(0, 8193), new i2(0, 0)]] };
  44229. class af {
  44230. constructor(t2, e2, r2, n2, i3) {
  44231. this.tileID = t2, this.uid = w(), this.uses = 0, this.tileSize = e2, this.tileZoom = r2, this.buckets = {}, this.expirationTime = null, this.queryPadding = 0, this.hasSymbolBuckets = false, this.hasRTLText = false, this.dependencies = {}, this.isRaster = i3, this.expiredRequestCount = 0, this.state = "loading", n2 && n2.transform && (this.projection = n2.transform.projection);
  44232. }
  44233. registerFadeDuration(t2) {
  44234. const e2 = t2 + this.timeAdded;
  44235. e2 < N.now() || this.fadeEndTime && e2 < this.fadeEndTime || (this.fadeEndTime = e2);
  44236. }
  44237. wasRequested() {
  44238. return "errored" === this.state || "loaded" === this.state || "reloading" === this.state;
  44239. }
  44240. get tileTransform() {
  44241. return this._tileTransform || (this._tileTransform = Zp(this.tileID.canonical, this.projection)), this._tileTransform;
  44242. }
  44243. loadVectorData(t2, e2, r2) {
  44244. if (this.unloadVectorData(), this.state = "loaded", t2) {
  44245. t2.featureIndex && (this.latestFeatureIndex = t2.featureIndex, t2.rawTileData ? (this.latestRawTileData = t2.rawTileData, this.latestFeatureIndex.rawTileData = t2.rawTileData) : this.latestRawTileData && (this.latestFeatureIndex.rawTileData = this.latestRawTileData)), this.collisionBoxArray = t2.collisionBoxArray, this.buckets = function(t3, e3) {
  44246. const r3 = {};
  44247. if (!e3)
  44248. return r3;
  44249. for (const n2 of t3) {
  44250. const t4 = n2.layerIds.map((t5) => e3.getLayer(t5)).filter(Boolean);
  44251. if (0 !== t4.length) {
  44252. n2.layers = t4, n2.stateDependentLayerIds && (n2.stateDependentLayers = n2.stateDependentLayerIds.map((e4) => t4.filter((t5) => t5.id === e4)[0]));
  44253. for (const e4 of t4)
  44254. r3[e4.id] = n2;
  44255. }
  44256. }
  44257. return r3;
  44258. }(t2.buckets, e2.style), this.hasSymbolBuckets = false;
  44259. for (const t3 in this.buckets) {
  44260. const e3 = this.buckets[t3];
  44261. if (e3 instanceof tp) {
  44262. if (this.hasSymbolBuckets = true, !r2)
  44263. break;
  44264. e3.justReloaded = true;
  44265. }
  44266. }
  44267. if (this.hasRTLText = false, this.hasSymbolBuckets)
  44268. for (const t3 in this.buckets) {
  44269. const e3 = this.buckets[t3];
  44270. if (e3 instanceof tp && e3.hasRTLText) {
  44271. this.hasRTLText = true, is.isLoading() || is.isLoaded() || "deferred" !== rs() || ns();
  44272. break;
  44273. }
  44274. }
  44275. this.queryPadding = 0;
  44276. for (const t3 in this.buckets) {
  44277. const r3 = this.buckets[t3];
  44278. this.queryPadding = Math.max(this.queryPadding, e2.style.getLayer(t3).queryRadius(r3));
  44279. }
  44280. t2.imageAtlas && (this.imageAtlas = t2.imageAtlas), t2.glyphAtlasImage && (this.glyphAtlasImage = t2.glyphAtlasImage), t2.lineAtlas && (this.lineAtlas = t2.lineAtlas);
  44281. } else
  44282. this.collisionBoxArray = new ea();
  44283. }
  44284. unloadVectorData() {
  44285. if (this.hasData()) {
  44286. for (const t2 in this.buckets)
  44287. this.buckets[t2].destroy();
  44288. this.buckets = {}, this.imageAtlas && (this.imageAtlas = null), this.lineAtlas && (this.lineAtlas = null), this.imageAtlasTexture && this.imageAtlasTexture.destroy(), this.glyphAtlasTexture && this.glyphAtlasTexture.destroy(), this.lineAtlasTexture && this.lineAtlasTexture.destroy(), this._tileBoundsBuffer && (this._tileBoundsBuffer.destroy(), this._tileBoundsIndexBuffer.destroy(), this._tileBoundsSegments.destroy(), this._tileBoundsBuffer = null), this._tileDebugBuffer && (this._tileDebugBuffer.destroy(), this._tileDebugIndexBuffer.destroy(), this._tileDebugSegments.destroy(), this._tileDebugBuffer = null), this._globeTileDebugBorderBuffer && (this._globeTileDebugBorderBuffer.destroy(), this._globeTileDebugBorderBuffer = null), this._tileDebugTextBuffer && (this._tileDebugTextBuffer.destroy(), this._tileDebugTextSegments.destroy(), this._tileDebugTextIndexBuffer.destroy(), this._tileDebugTextBuffer = null), this._globeTileDebugTextBuffer && (this._globeTileDebugTextBuffer.destroy(), this._globeTileDebugTextBuffer = null), this.latestFeatureIndex = null, this.state = "unloaded";
  44289. }
  44290. }
  44291. getBucket(t2) {
  44292. return this.buckets[t2.id];
  44293. }
  44294. upload(t2) {
  44295. for (const e3 in this.buckets) {
  44296. const r2 = this.buckets[e3];
  44297. r2.uploadPending() && r2.upload(t2);
  44298. }
  44299. const e2 = t2.gl;
  44300. this.imageAtlas && !this.imageAtlas.uploaded && (this.imageAtlasTexture = new hp(t2, this.imageAtlas.image, e2.RGBA), this.imageAtlas.uploaded = true), this.glyphAtlasImage && (this.glyphAtlasTexture = new hp(t2, this.glyphAtlasImage, e2.ALPHA), this.glyphAtlasImage = null), this.lineAtlas && !this.lineAtlas.uploaded && (this.lineAtlasTexture = new hp(t2, this.lineAtlas.image, e2.ALPHA), this.lineAtlas.uploaded = true);
  44301. }
  44302. prepare(t2) {
  44303. this.imageAtlas && this.imageAtlas.patchUpdatedImages(t2, this.imageAtlasTexture);
  44304. }
  44305. queryRenderedFeatures(t2, e2, r2, n2, i3, s2, a2, o2) {
  44306. return this.latestFeatureIndex && this.latestFeatureIndex.rawTileData ? this.latestFeatureIndex.query({ tileResult: n2, pixelPosMatrix: a2, transform: s2, params: i3, tileTransform: this.tileTransform }, t2, e2, r2) : {};
  44307. }
  44308. querySourceFeatures(t2, e2) {
  44309. const r2 = this.latestFeatureIndex;
  44310. if (!r2 || !r2.rawTileData)
  44311. return;
  44312. const n2 = r2.loadVTLayers(), i3 = e2 ? e2.sourceLayer : "", s2 = n2._geojsonTileLayer || n2[i3];
  44313. if (!s2)
  44314. return;
  44315. const a2 = Sn(e2 && e2.filter), { z: o2, x: l2, y: u2 } = this.tileID.canonical, c2 = { z: o2, x: l2, y: u2 };
  44316. for (let e3 = 0; e3 < s2.length; e3++) {
  44317. const n3 = s2.feature(e3);
  44318. if (a2.needGeometry) {
  44319. const t3 = mo(n3, true);
  44320. if (!a2.filter(new ss(this.tileID.overscaledZ), t3, this.tileID.canonical))
  44321. continue;
  44322. } else if (!a2.filter(new ss(this.tileID.overscaledZ), n3))
  44323. continue;
  44324. const h2 = r2.getId(n3, i3), p2 = new Yp(n3, o2, l2, u2, h2);
  44325. p2.tile = c2, t2.push(p2);
  44326. }
  44327. }
  44328. hasData() {
  44329. return "loaded" === this.state || "reloading" === this.state || "expired" === this.state;
  44330. }
  44331. patternsLoaded() {
  44332. return !!this.imageAtlas && !!Object.keys(this.imageAtlas.patternPositions).length;
  44333. }
  44334. setExpiryData(t2) {
  44335. const e2 = this.expirationTime;
  44336. if (t2.cacheControl) {
  44337. const e3 = F(t2.cacheControl);
  44338. e3["max-age"] && (this.expirationTime = Date.now() + 1e3 * e3["max-age"]);
  44339. } else
  44340. t2.expires && (this.expirationTime = new Date(t2.expires).getTime());
  44341. if (this.expirationTime) {
  44342. const t3 = Date.now();
  44343. let r2 = false;
  44344. if (this.expirationTime > t3)
  44345. r2 = false;
  44346. else if (e2)
  44347. if (this.expirationTime < e2)
  44348. r2 = true;
  44349. else {
  44350. const n2 = this.expirationTime - e2;
  44351. n2 ? this.expirationTime = t3 + Math.max(n2, 3e4) : r2 = true;
  44352. }
  44353. else
  44354. r2 = true;
  44355. r2 ? (this.expiredRequestCount++, this.state = "expired") : this.expiredRequestCount = 0;
  44356. }
  44357. }
  44358. getExpiryTimeout() {
  44359. if (this.expirationTime)
  44360. return this.expiredRequestCount ? 1e3 * (1 << Math.min(this.expiredRequestCount - 1, 31)) : Math.min(this.expirationTime - (/* @__PURE__ */ new Date()).getTime(), Math.pow(2, 31) - 1);
  44361. }
  44362. setFeatureState(t2, e2) {
  44363. if (!this.latestFeatureIndex || !this.latestFeatureIndex.rawTileData || 0 === Object.keys(t2).length || !e2)
  44364. return;
  44365. const r2 = this.latestFeatureIndex.loadVTLayers(), n2 = e2.style.listImages();
  44366. for (const i3 in this.buckets) {
  44367. if (!e2.style.hasLayer(i3))
  44368. continue;
  44369. const s2 = this.buckets[i3], a2 = s2.layers[0].sourceLayer || "_geojsonTileLayer", o2 = r2[a2], l2 = t2[a2];
  44370. if (!o2 || !l2 || 0 === Object.keys(l2).length)
  44371. continue;
  44372. if (s2.update(l2, o2, n2, this.imageAtlas && this.imageAtlas.patternPositions || {}), s2 instanceof Qu || s2 instanceof xu) {
  44373. const t3 = e2.style._getSourceCache(s2.layers[0].source);
  44374. e2._terrain && e2._terrain.enabled && t3 && s2.programConfigurations.needsUpload && e2._terrain._clearRenderCacheForTile(t3.id, this.tileID);
  44375. }
  44376. const u2 = e2 && e2.style && e2.style.getLayer(i3);
  44377. u2 && (this.queryPadding = Math.max(this.queryPadding, u2.queryRadius(s2)));
  44378. }
  44379. }
  44380. holdingForFade() {
  44381. return void 0 !== this.symbolFadeHoldUntil;
  44382. }
  44383. symbolFadeFinished() {
  44384. return !this.symbolFadeHoldUntil || this.symbolFadeHoldUntil < N.now();
  44385. }
  44386. clearFadeHold() {
  44387. this.symbolFadeHoldUntil = void 0;
  44388. }
  44389. setHoldDuration(t2) {
  44390. this.symbolFadeHoldUntil = N.now() + t2;
  44391. }
  44392. setTexture(t2, e2) {
  44393. const r2 = e2.context, n2 = r2.gl;
  44394. this.texture = e2.getTileTexture(t2.width), this.texture ? this.texture.update(t2, { useMipmap: true }) : (this.texture = new hp(r2, t2, n2.RGBA, { useMipmap: true }), this.texture.bind(n2.LINEAR, n2.CLAMP_TO_EDGE), r2.extTextureFilterAnisotropic && n2.texParameterf(n2.TEXTURE_2D, r2.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT, r2.extTextureFilterAnisotropicMax));
  44395. }
  44396. setDependencies(t2, e2) {
  44397. const r2 = {};
  44398. for (const t3 of e2)
  44399. r2[t3] = true;
  44400. this.dependencies[t2] = r2;
  44401. }
  44402. hasDependency(t2, e2) {
  44403. for (const r2 of t2) {
  44404. const t3 = this.dependencies[r2];
  44405. if (t3) {
  44406. for (const r3 of e2)
  44407. if (t3[r3])
  44408. return true;
  44409. }
  44410. }
  44411. return false;
  44412. }
  44413. clearQueryDebugViz() {
  44414. }
  44415. _makeDebugTileBoundsBuffers(t2, e2) {
  44416. if (!e2 || "mercator" === e2.name || this._tileDebugBuffer)
  44417. return;
  44418. const r2 = yo(sf, this.tileID.canonical, this.tileTransform)[0], n2 = new Is(), i3 = new Ys();
  44419. for (let t3 = 0; t3 < r2.length; t3++) {
  44420. const { x: e3, y: s2 } = r2[t3];
  44421. n2.emplaceBack(e3, s2), i3.emplaceBack(t3);
  44422. }
  44423. i3.emplaceBack(0), this._tileDebugIndexBuffer = t2.createIndexBuffer(i3), this._tileDebugBuffer = t2.createVertexBuffer(n2, _p.members), this._tileDebugSegments = Ka.simpleSegment(0, 0, n2.length, i3.length);
  44424. }
  44425. _makeTileBoundsBuffers(t2, e2) {
  44426. if (this._tileBoundsBuffer || !e2 || "mercator" === e2.name)
  44427. return;
  44428. const r2 = yo(sf, this.tileID.canonical, this.tileTransform)[0];
  44429. let n2, i3;
  44430. if (this.isRaster) {
  44431. const t3 = function(t4, e3) {
  44432. const r3 = Zp(t4, e3), n3 = Math.pow(2, t4.z);
  44433. for (let i5 = 0; i5 < Wp; i5++)
  44434. for (let s3 = 0; s3 < Wp; s3++) {
  44435. const a3 = io((t4.x + (s3 + rf(s3)) / Hp) / n3), o3 = so((t4.y + (i5 + rf(i5)) / Hp) / n3), l3 = e3.project(a3, o3), u2 = i5 * Wp + s3;
  44436. Qp[2 * u2 + 0] = Math.round((l3.x * r3.scale - r3.x) * Ya), Qp[2 * u2 + 1] = Math.round((l3.y * r3.scale - r3.y) * Ya);
  44437. }
  44438. tf.fill(0), ef.fill(0);
  44439. for (let t5 = 2045; t5 >= 0; t5--) {
  44440. const e4 = 4 * t5, r4 = Jp[e4 + 0], n4 = Jp[e4 + 1], i5 = Jp[e4 + 2], s3 = Jp[e4 + 3], a3 = r4 + i5 >> 1, o3 = n4 + s3 >> 1, l3 = a3 + o3 - n4, u2 = o3 + r4 - a3, c2 = n4 * Wp + r4, h2 = s3 * Wp + i5, p2 = o3 * Wp + a3, f2 = Math.hypot((Qp[2 * c2 + 0] + Qp[2 * h2 + 0]) / 2 - Qp[2 * p2 + 0], (Qp[2 * c2 + 1] + Qp[2 * h2 + 1]) / 2 - Qp[2 * p2 + 1]) >= 16;
  44441. if (tf[p2] = tf[p2] || (f2 ? 1 : 0), t5 < 1022) {
  44442. const t6 = (n4 + u2 >> 1) * Wp + (r4 + l3 >> 1), e5 = (s3 + u2 >> 1) * Wp + (i5 + l3 >> 1);
  44443. tf[p2] = tf[p2] || tf[t6] || tf[e5];
  44444. }
  44445. }
  44446. const i4 = new Ts(), s2 = new js();
  44447. let a2 = 0;
  44448. function o2(t5, e4) {
  44449. const r4 = e4 * Wp + t5;
  44450. return 0 === ef[r4] && (i4.emplaceBack(Qp[2 * r4 + 0], Qp[2 * r4 + 1], t5 * Ya / Hp, e4 * Ya / Hp), ef[r4] = ++a2), ef[r4] - 1;
  44451. }
  44452. function l2(t5, e4, r4, n4, i5, a3) {
  44453. const u2 = t5 + r4 >> 1, c2 = e4 + n4 >> 1;
  44454. if (Math.abs(t5 - i5) + Math.abs(e4 - a3) > 1 && tf[c2 * Wp + u2])
  44455. l2(i5, a3, t5, e4, u2, c2), l2(r4, n4, i5, a3, u2, c2);
  44456. else {
  44457. const l3 = o2(t5, e4), u3 = o2(r4, n4), c3 = o2(i5, a3);
  44458. s2.emplaceBack(l3, u3, c3);
  44459. }
  44460. }
  44461. return l2(0, 0, Hp, Hp, Hp, 0), l2(Hp, Hp, 0, 0, 0, Hp), { vertices: i4, indices: s2 };
  44462. }(this.tileID.canonical, e2);
  44463. n2 = t3.vertices, i3 = t3.indices;
  44464. } else {
  44465. n2 = new Ts(), i3 = new js();
  44466. for (const { x: t4, y: e3 } of r2)
  44467. n2.emplaceBack(t4, e3, 0, 0);
  44468. const t3 = Fl(n2.int16, void 0, 4);
  44469. for (let e3 = 0; e3 < t3.length; e3 += 3)
  44470. i3.emplaceBack(t3[e3], t3[e3 + 1], t3[e3 + 2]);
  44471. }
  44472. this._tileBoundsBuffer = t2.createVertexBuffer(n2, nf.members), this._tileBoundsIndexBuffer = t2.createIndexBuffer(i3), this._tileBoundsSegments = Ka.simpleSegment(0, 0, n2.length, i3.length);
  44473. }
  44474. _makeGlobeTileDebugBuffers(t2, e2) {
  44475. if (this._globeTileDebugBorderBuffer || this._globeTileDebugTextBuffer || !e2 || "globe" !== e2.name)
  44476. return;
  44477. const r2 = this.tileID.canonical, n2 = Vp(Tp(r2));
  44478. this._makeGlobeTileDebugBorderBuffer(t2, r2, n2), this._makeGlobeTileDebugTextBuffer(t2, r2, n2);
  44479. }
  44480. _makeGlobeTileDebugBorderBuffer(t2, e2, r2) {
  44481. const n2 = new Is(), i3 = new Ys(), s2 = new Ms(), a2 = (t3, a3, o3, l2, u2) => {
  44482. const c2 = (o3 - t3) / (u2 - 1), h2 = (l2 - a3) / (u2 - 1), p2 = n2.length;
  44483. for (let o4 = 0; o4 < u2; o4++) {
  44484. const l3 = t3 + o4 * c2, u3 = a3 + o4 * h2;
  44485. n2.emplaceBack(l3, u3);
  44486. const f2 = Dp(l3, u3, e2), d2 = ll(f2, f2, r2);
  44487. s2.emplaceBack(d2[0], d2[1], d2[2]), i3.emplaceBack(p2 + o4);
  44488. }
  44489. }, o2 = Ya;
  44490. a2(0, 0, o2, 0, 16), a2(o2, 0, o2, o2, 16), a2(o2, o2, 0, o2, 16), a2(0, o2, 0, 0, 16), this._tileDebugIndexBuffer = t2.createIndexBuffer(i3), this._tileDebugBuffer = t2.createVertexBuffer(n2, _p.members), this._globeTileDebugBorderBuffer = t2.createVertexBuffer(s2, bp.members), this._tileDebugSegments = Ka.simpleSegment(0, 0, n2.length, i3.length);
  44491. }
  44492. _makeGlobeTileDebugTextBuffer(t2, e2, r2) {
  44493. const n2 = new Is(), i3 = new js(), s2 = new Ms(), a2 = 25;
  44494. i3.reserve(32), n2.reserve(a2), s2.reserve(a2);
  44495. const o2 = (t3, e3) => a2 * t3 + e3;
  44496. for (let t3 = 0; t3 < a2; t3++) {
  44497. const i4 = 2048 * t3;
  44498. for (let t4 = 0; t4 < a2; t4++) {
  44499. const a3 = 2048 * t4;
  44500. n2.emplaceBack(a3, i4);
  44501. const o3 = Dp(a3, i4, e2), l2 = ll(o3, o3, r2);
  44502. s2.emplaceBack(l2[0], l2[1], l2[2]);
  44503. }
  44504. }
  44505. for (let t3 = 0; t3 < 4; t3++)
  44506. for (let e3 = 0; e3 < 4; e3++) {
  44507. const r3 = o2(t3, e3), n3 = o2(t3, e3 + 1), s3 = o2(t3 + 1, e3), a3 = o2(t3 + 1, e3 + 1);
  44508. i3.emplaceBack(r3, n3, s3), i3.emplaceBack(s3, n3, a3);
  44509. }
  44510. this._tileDebugTextIndexBuffer = t2.createIndexBuffer(i3), this._tileDebugTextBuffer = t2.createVertexBuffer(n2, _p.members), this._globeTileDebugTextBuffer = t2.createVertexBuffer(s2, bp.members), this._tileDebugTextSegments = Ka.simpleSegment(0, 0, a2, 32);
  44511. }
  44512. }
  44513. class of {
  44514. constructor() {
  44515. this.state = {}, this.stateChanges = {}, this.deletedStates = {};
  44516. }
  44517. updateState(t2, e2, r2) {
  44518. const n2 = String(e2);
  44519. if (this.stateChanges[t2] = this.stateChanges[t2] || {}, this.stateChanges[t2][n2] = this.stateChanges[t2][n2] || {}, b(this.stateChanges[t2][n2], r2), null === this.deletedStates[t2]) {
  44520. this.deletedStates[t2] = {};
  44521. for (const e3 in this.state[t2])
  44522. e3 !== n2 && (this.deletedStates[t2][e3] = null);
  44523. } else if (this.deletedStates[t2] && null === this.deletedStates[t2][n2]) {
  44524. this.deletedStates[t2][n2] = {};
  44525. for (const e3 in this.state[t2][n2])
  44526. r2[e3] || (this.deletedStates[t2][n2][e3] = null);
  44527. } else
  44528. for (const e3 in r2)
  44529. this.deletedStates[t2] && this.deletedStates[t2][n2] && null === this.deletedStates[t2][n2][e3] && delete this.deletedStates[t2][n2][e3];
  44530. }
  44531. removeFeatureState(t2, e2, r2) {
  44532. if (null === this.deletedStates[t2])
  44533. return;
  44534. const n2 = String(e2);
  44535. if (this.deletedStates[t2] = this.deletedStates[t2] || {}, r2 && void 0 !== e2)
  44536. null !== this.deletedStates[t2][n2] && (this.deletedStates[t2][n2] = this.deletedStates[t2][n2] || {}, this.deletedStates[t2][n2][r2] = null);
  44537. else if (void 0 !== e2)
  44538. if (this.stateChanges[t2] && this.stateChanges[t2][n2])
  44539. for (r2 in this.deletedStates[t2][n2] = {}, this.stateChanges[t2][n2])
  44540. this.deletedStates[t2][n2][r2] = null;
  44541. else
  44542. this.deletedStates[t2][n2] = null;
  44543. else
  44544. this.deletedStates[t2] = null;
  44545. }
  44546. getState(t2, e2) {
  44547. const r2 = String(e2), n2 = b({}, (this.state[t2] || {})[r2], (this.stateChanges[t2] || {})[r2]);
  44548. if (null === this.deletedStates[t2])
  44549. return {};
  44550. if (this.deletedStates[t2]) {
  44551. const r3 = this.deletedStates[t2][e2];
  44552. if (null === r3)
  44553. return {};
  44554. for (const t3 in r3)
  44555. delete n2[t3];
  44556. }
  44557. return n2;
  44558. }
  44559. initializeTileState(t2, e2) {
  44560. t2.setFeatureState(this.state, e2);
  44561. }
  44562. coalesceChanges(t2, e2) {
  44563. const r2 = {};
  44564. for (const t3 in this.stateChanges) {
  44565. this.state[t3] = this.state[t3] || {};
  44566. const e3 = {};
  44567. for (const r3 in this.stateChanges[t3])
  44568. this.state[t3][r3] || (this.state[t3][r3] = {}), b(this.state[t3][r3], this.stateChanges[t3][r3]), e3[r3] = this.state[t3][r3];
  44569. r2[t3] = e3;
  44570. }
  44571. for (const t3 in this.deletedStates) {
  44572. this.state[t3] = this.state[t3] || {};
  44573. const e3 = {};
  44574. if (null === this.deletedStates[t3])
  44575. for (const r3 in this.state[t3])
  44576. e3[r3] = {}, this.state[t3][r3] = {};
  44577. else
  44578. for (const r3 in this.deletedStates[t3]) {
  44579. if (null === this.deletedStates[t3][r3])
  44580. this.state[t3][r3] = {};
  44581. else
  44582. for (const e4 of Object.keys(this.deletedStates[t3][r3]))
  44583. delete this.state[t3][r3][e4];
  44584. e3[r3] = this.state[t3][r3];
  44585. }
  44586. r2[t3] = r2[t3] || {}, b(r2[t3], e3);
  44587. }
  44588. if (this.stateChanges = {}, this.deletedStates = {}, 0 !== Object.keys(r2).length)
  44589. for (const n2 in t2)
  44590. t2[n2].setFeatureState(r2, e2);
  44591. }
  44592. }
  44593. class lf {
  44594. constructor(t2) {
  44595. this.size = t2, this.minimums = [], this.maximums = [], this.leaves = [];
  44596. }
  44597. getElevation(t2, e2) {
  44598. const r2 = this.toIdx(t2, e2);
  44599. return { min: this.minimums[r2], max: this.maximums[r2] };
  44600. }
  44601. isLeaf(t2, e2) {
  44602. return this.leaves[this.toIdx(t2, e2)];
  44603. }
  44604. toIdx(t2, e2) {
  44605. return e2 * this.size + t2;
  44606. }
  44607. }
  44608. function uf(t2, e2, r2, n2) {
  44609. let i3 = 0, s2 = Number.MAX_VALUE;
  44610. for (let a2 = 0; a2 < 3; a2++)
  44611. if (Math.abs(n2[a2]) < 1e-15) {
  44612. if (r2[a2] < t2[a2] || r2[a2] > e2[a2])
  44613. return null;
  44614. } else {
  44615. const o2 = 1 / n2[a2];
  44616. let l2 = (t2[a2] - r2[a2]) * o2, u2 = (e2[a2] - r2[a2]) * o2;
  44617. if (l2 > u2) {
  44618. const t3 = l2;
  44619. l2 = u2, u2 = t3;
  44620. }
  44621. if (l2 > i3 && (i3 = l2), u2 < s2 && (s2 = u2), i3 > s2)
  44622. return null;
  44623. }
  44624. return i3;
  44625. }
  44626. function cf(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2) {
  44627. const h2 = n2 - t2, p2 = i3 - e2, f2 = s2 - r2, d2 = a2 - t2, y2 = o2 - e2, m2 = l2 - r2, g2 = c2[1] * m2 - c2[2] * y2, x2 = c2[2] * d2 - c2[0] * m2, v2 = c2[0] * y2 - c2[1] * d2, b2 = h2 * g2 + p2 * x2 + f2 * v2;
  44628. if (Math.abs(b2) < 1e-15)
  44629. return null;
  44630. const _2 = 1 / b2, w2 = u2[0] - t2, A2 = u2[1] - e2, k2 = u2[2] - r2, S2 = (w2 * g2 + A2 * x2 + k2 * v2) * _2;
  44631. if (S2 < 0 || S2 > 1)
  44632. return null;
  44633. const I2 = A2 * f2 - k2 * p2, M2 = k2 * h2 - w2 * f2, T2 = w2 * p2 - A2 * h2, z2 = (c2[0] * I2 + c2[1] * M2 + c2[2] * T2) * _2;
  44634. return z2 < 0 || S2 + z2 > 1 ? null : (d2 * I2 + y2 * M2 + m2 * T2) * _2;
  44635. }
  44636. function hf(t2, e2, r2) {
  44637. return (t2 - e2) / (r2 - e2);
  44638. }
  44639. function pf(t2, e2, r2, n2, i3, s2, a2, o2, l2) {
  44640. const u2 = 1 << r2, c2 = s2 - n2, h2 = a2 - i3, p2 = (t2 + 1) / u2 * c2 + n2, f2 = (e2 + 0) / u2 * h2 + i3, d2 = (e2 + 1) / u2 * h2 + i3;
  44641. o2[0] = (t2 + 0) / u2 * c2 + n2, o2[1] = f2, l2[0] = p2, l2[1] = d2;
  44642. }
  44643. class ff {
  44644. constructor(t2) {
  44645. if (this.maximums = [], this.minimums = [], this.leaves = [], this.childOffsets = [], this.nodeCount = 0, this.dem = t2, this._siblingOffset = [[0, 0], [1, 0], [0, 1], [1, 1]], !this.dem)
  44646. return;
  44647. const e2 = function(t3) {
  44648. const e3 = Math.ceil(Math.log2(t3.dim / 8)), r3 = [];
  44649. let n3 = Math.ceil(Math.pow(2, e3));
  44650. const i3 = 1 / n3, s2 = (t4, e4, r4, n4, i4) => {
  44651. const s3 = n4 ? 1 : 0, a3 = (t4 + 1) * r4 - s3, o3 = e4 * r4, l2 = (e4 + 1) * r4 - s3;
  44652. i4[0] = t4 * r4, i4[1] = o3, i4[2] = a3, i4[3] = l2;
  44653. };
  44654. let a2 = new lf(n3);
  44655. const o2 = [];
  44656. for (let e4 = 0; e4 < n3 * n3; e4++) {
  44657. s2(e4 % n3, Math.floor(e4 / n3), i3, false, o2);
  44658. const r4 = yf(o2[0], o2[1], t3), l2 = yf(o2[2], o2[1], t3), u2 = yf(o2[2], o2[3], t3), c2 = yf(o2[0], o2[3], t3);
  44659. a2.minimums.push(Math.min(r4, l2, u2, c2)), a2.maximums.push(Math.max(r4, l2, u2, c2)), a2.leaves.push(1);
  44660. }
  44661. for (r3.push(a2), n3 /= 2; n3 >= 1; n3 /= 2) {
  44662. const t4 = r3[r3.length - 1];
  44663. a2 = new lf(n3);
  44664. for (let e4 = 0; e4 < n3 * n3; e4++) {
  44665. s2(e4 % n3, Math.floor(e4 / n3), 2, true, o2);
  44666. const r4 = t4.getElevation(o2[0], o2[1]), i4 = t4.getElevation(o2[2], o2[1]), l2 = t4.getElevation(o2[2], o2[3]), u2 = t4.getElevation(o2[0], o2[3]), c2 = t4.isLeaf(o2[0], o2[1]), h2 = t4.isLeaf(o2[2], o2[1]), p2 = t4.isLeaf(o2[2], o2[3]), f2 = t4.isLeaf(o2[0], o2[3]), d2 = Math.min(r4.min, i4.min, l2.min, u2.min), y2 = Math.max(r4.max, i4.max, l2.max, u2.max), m2 = c2 && h2 && p2 && f2;
  44667. a2.maximums.push(y2), a2.minimums.push(d2), a2.leaves.push(y2 - d2 <= 5 && m2 ? 1 : 0);
  44668. }
  44669. r3.push(a2);
  44670. }
  44671. return r3;
  44672. }(this.dem), r2 = e2.length - 1, n2 = e2[r2];
  44673. this._addNode(n2.minimums[0], n2.maximums[0], n2.leaves[0]), this._construct(e2, 0, 0, r2, 0);
  44674. }
  44675. raycastRoot(t2, e2, r2, n2, i3, s2, a2 = 1) {
  44676. return uf([t2, e2, -100], [r2, n2, this.maximums[0] * a2], i3, s2);
  44677. }
  44678. raycast(t2, e2, r2, n2, i3, s2, a2 = 1) {
  44679. if (!this.nodeCount)
  44680. return null;
  44681. const o2 = this.raycastRoot(t2, e2, r2, n2, i3, s2, a2);
  44682. if (null == o2)
  44683. return null;
  44684. const l2 = [], u2 = [], c2 = [], h2 = [], p2 = [{ idx: 0, t: o2, nodex: 0, nodey: 0, depth: 0 }];
  44685. for (; p2.length > 0; ) {
  44686. const { idx: o3, t: f2, nodex: d2, nodey: y2, depth: m2 } = p2.pop();
  44687. if (this.leaves[o3]) {
  44688. pf(d2, y2, m2, t2, e2, r2, n2, c2, h2);
  44689. const o4 = 1 << m2, l3 = (d2 + 0) / o4, u3 = (d2 + 1) / o4, p3 = (y2 + 0) / o4, g3 = (y2 + 1) / o4, x2 = yf(l3, p3, this.dem) * a2, v2 = yf(u3, p3, this.dem) * a2, b2 = yf(u3, g3, this.dem) * a2, _2 = yf(l3, g3, this.dem) * a2, w2 = cf(c2[0], c2[1], x2, h2[0], c2[1], v2, h2[0], h2[1], b2, i3, s2), A2 = cf(h2[0], h2[1], b2, c2[0], h2[1], _2, c2[0], c2[1], x2, i3, s2), k2 = Math.min(null !== w2 ? w2 : Number.MAX_VALUE, null !== A2 ? A2 : Number.MAX_VALUE);
  44690. if (k2 !== Number.MAX_VALUE)
  44691. return k2;
  44692. {
  44693. const t3 = il([], i3, s2, f2);
  44694. if (df(x2, v2, _2, b2, hf(t3[0], c2[0], h2[0]), hf(t3[1], c2[1], h2[1])) >= t3[2])
  44695. return f2;
  44696. }
  44697. continue;
  44698. }
  44699. let g2 = 0;
  44700. for (let p3 = 0; p3 < this._siblingOffset.length; p3++) {
  44701. pf((d2 << 1) + this._siblingOffset[p3][0], (y2 << 1) + this._siblingOffset[p3][1], m2 + 1, t2, e2, r2, n2, c2, h2), c2[2] = -100, h2[2] = this.maximums[this.childOffsets[o3] + p3] * a2;
  44702. const f3 = uf(c2, h2, i3, s2);
  44703. if (null != f3) {
  44704. const t3 = f3;
  44705. l2[p3] = t3;
  44706. let e3 = false;
  44707. for (let r3 = 0; r3 < g2 && !e3; r3++)
  44708. t3 >= l2[u2[r3]] && (u2.splice(r3, 0, p3), e3 = true);
  44709. e3 || (u2[g2] = p3), g2++;
  44710. }
  44711. }
  44712. for (let t3 = 0; t3 < g2; t3++) {
  44713. const e3 = u2[t3];
  44714. p2.push({ idx: this.childOffsets[o3] + e3, t: l2[e3], nodex: (d2 << 1) + this._siblingOffset[e3][0], nodey: (y2 << 1) + this._siblingOffset[e3][1], depth: m2 + 1 });
  44715. }
  44716. }
  44717. return null;
  44718. }
  44719. _addNode(t2, e2, r2) {
  44720. return this.minimums.push(t2), this.maximums.push(e2), this.leaves.push(r2), this.childOffsets.push(0), this.nodeCount++;
  44721. }
  44722. _construct(t2, e2, r2, n2, i3) {
  44723. if (1 === t2[n2].isLeaf(e2, r2))
  44724. return;
  44725. this.childOffsets[i3] || (this.childOffsets[i3] = this.nodeCount);
  44726. const s2 = n2 - 1, a2 = t2[s2];
  44727. let o2 = 0, l2 = 0;
  44728. for (let t3 = 0; t3 < this._siblingOffset.length; t3++) {
  44729. const n3 = 2 * e2 + this._siblingOffset[t3][0], i4 = 2 * r2 + this._siblingOffset[t3][1], s3 = a2.getElevation(n3, i4), u2 = a2.isLeaf(n3, i4), c2 = this._addNode(s3.min, s3.max, u2);
  44730. u2 && (o2 |= 1 << t3), l2 || (l2 = c2);
  44731. }
  44732. for (let n3 = 0; n3 < this._siblingOffset.length; n3++)
  44733. o2 & 1 << n3 || this._construct(t2, 2 * e2 + this._siblingOffset[n3][0], 2 * r2 + this._siblingOffset[n3][1], s2, l2 + n3);
  44734. }
  44735. }
  44736. function df(t2, e2, r2, n2, i3, s2) {
  44737. return rr(rr(t2, r2, s2), rr(e2, n2, s2), i3);
  44738. }
  44739. function yf(t2, e2, r2) {
  44740. const n2 = r2.dim, i3 = y(t2 * n2 - 0.5, 0, n2 - 1), s2 = y(e2 * n2 - 0.5, 0, n2 - 1), a2 = Math.floor(i3), o2 = Math.floor(s2), l2 = Math.min(a2 + 1, n2 - 1), u2 = Math.min(o2 + 1, n2 - 1);
  44741. return df(r2.get(a2, o2), r2.get(l2, o2), r2.get(a2, u2), r2.get(l2, u2), i3 - a2, s2 - o2);
  44742. }
  44743. const mf = { mapbox: [6553.6, 25.6, 0.1, 1e4], terrarium: [256, 1, 1 / 256, 32768] };
  44744. class gf {
  44745. get tree() {
  44746. return this._tree || this._buildQuadTree(), this._tree;
  44747. }
  44748. constructor(t2, e2, r2, n2 = false, i3 = false) {
  44749. if (this.uid = t2, e2.height !== e2.width)
  44750. throw new RangeError("DEM tiles must be square");
  44751. if (r2 && "mapbox" !== r2 && "terrarium" !== r2)
  44752. return C(`"${r2}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);
  44753. this.stride = e2.height;
  44754. const s2 = this.dim = e2.height - 2, a2 = new Uint32Array(e2.data.buffer);
  44755. if (this.pixels = new Uint8Array(e2.data.buffer), this.encoding = r2 || "mapbox", this.borderReady = n2, !n2) {
  44756. for (let t3 = 0; t3 < s2; t3++)
  44757. a2[this._idx(-1, t3)] = a2[this._idx(0, t3)], a2[this._idx(s2, t3)] = a2[this._idx(s2 - 1, t3)], a2[this._idx(t3, -1)] = a2[this._idx(t3, 0)], a2[this._idx(t3, s2)] = a2[this._idx(t3, s2 - 1)];
  44758. a2[this._idx(-1, -1)] = a2[this._idx(0, 0)], a2[this._idx(s2, -1)] = a2[this._idx(s2 - 1, 0)], a2[this._idx(-1, s2)] = a2[this._idx(0, s2 - 1)], a2[this._idx(s2, s2)] = a2[this._idx(s2 - 1, s2 - 1)], i3 && this._buildQuadTree();
  44759. }
  44760. }
  44761. _buildQuadTree() {
  44762. this._tree = new ff(this);
  44763. }
  44764. get(t2, e2, r2 = false) {
  44765. r2 && (t2 = y(t2, -1, this.dim), e2 = y(e2, -1, this.dim));
  44766. const n2 = 4 * this._idx(t2, e2);
  44767. return ("terrarium" === this.encoding ? this._unpackTerrarium : this._unpackMapbox)(this.pixels[n2], this.pixels[n2 + 1], this.pixels[n2 + 2]);
  44768. }
  44769. static getUnpackVector(t2) {
  44770. return mf[t2];
  44771. }
  44772. get unpackVector() {
  44773. return mf[this.encoding];
  44774. }
  44775. _idx(t2, e2) {
  44776. if (t2 < -1 || t2 >= this.dim + 1 || e2 < -1 || e2 >= this.dim + 1)
  44777. throw new RangeError("out of range source coordinates for DEM data");
  44778. return (e2 + 1) * this.stride + (t2 + 1);
  44779. }
  44780. _unpackMapbox(t2, e2, r2) {
  44781. return (256 * t2 * 256 + 256 * e2 + r2) / 10 - 1e4;
  44782. }
  44783. _unpackTerrarium(t2, e2, r2) {
  44784. return 256 * t2 + e2 + r2 / 256 - 32768;
  44785. }
  44786. static pack(t2, e2) {
  44787. const r2 = [0, 0, 0, 0], n2 = gf.getUnpackVector(e2);
  44788. let i3 = Math.floor((t2 + n2[3]) / n2[2]);
  44789. return r2[2] = i3 % 256, i3 = Math.floor(i3 / 256), r2[1] = i3 % 256, i3 = Math.floor(i3 / 256), r2[0] = i3, r2;
  44790. }
  44791. getPixels() {
  44792. return new Bl({ width: this.stride, height: this.stride }, this.pixels);
  44793. }
  44794. backfillBorder(t2, e2, r2) {
  44795. if (this.dim !== t2.dim)
  44796. throw new Error("dem dimension mismatch");
  44797. let n2 = e2 * this.dim, i3 = e2 * this.dim + this.dim, s2 = r2 * this.dim, a2 = r2 * this.dim + this.dim;
  44798. switch (e2) {
  44799. case -1:
  44800. n2 = i3 - 1;
  44801. break;
  44802. case 1:
  44803. i3 = n2 + 1;
  44804. }
  44805. switch (r2) {
  44806. case -1:
  44807. s2 = a2 - 1;
  44808. break;
  44809. case 1:
  44810. a2 = s2 + 1;
  44811. }
  44812. const o2 = -e2 * this.dim, l2 = -r2 * this.dim;
  44813. for (let e3 = s2; e3 < a2; e3++)
  44814. for (let r3 = n2; r3 < i3; r3++) {
  44815. const n3 = 4 * this._idx(r3, e3), i4 = 4 * this._idx(r3 + o2, e3 + l2);
  44816. this.pixels[n3 + 0] = t2.pixels[i4 + 0], this.pixels[n3 + 1] = t2.pixels[i4 + 1], this.pixels[n3 + 2] = t2.pixels[i4 + 2], this.pixels[n3 + 3] = t2.pixels[i4 + 3];
  44817. }
  44818. }
  44819. onDeserialize() {
  44820. this._tree && (this._tree.dem = this);
  44821. }
  44822. }
  44823. ai(gf, "DEMData"), ai(ff, "DemMinMaxQuadTree", { omit: ["dem"] });
  44824. class xf {
  44825. constructor(t2, e2) {
  44826. this.max = t2, this.onRemove = e2, this.reset();
  44827. }
  44828. reset() {
  44829. for (const t2 in this.data)
  44830. for (const e2 of this.data[t2])
  44831. e2.timeout && clearTimeout(e2.timeout), this.onRemove(e2.value);
  44832. return this.data = {}, this.order = [], this;
  44833. }
  44834. add(t2, e2, r2) {
  44835. const n2 = t2.wrapped().key;
  44836. void 0 === this.data[n2] && (this.data[n2] = []);
  44837. const i3 = { value: e2, timeout: void 0 };
  44838. if (void 0 !== r2 && (i3.timeout = setTimeout(() => {
  44839. this.remove(t2, i3);
  44840. }, r2)), this.data[n2].push(i3), this.order.push(n2), this.order.length > this.max) {
  44841. const t3 = this._getAndRemoveByKey(this.order[0]);
  44842. t3 && this.onRemove(t3);
  44843. }
  44844. return this;
  44845. }
  44846. has(t2) {
  44847. return t2.wrapped().key in this.data;
  44848. }
  44849. getAndRemove(t2) {
  44850. return this.has(t2) ? this._getAndRemoveByKey(t2.wrapped().key) : null;
  44851. }
  44852. _getAndRemoveByKey(t2) {
  44853. const e2 = this.data[t2].shift();
  44854. return e2.timeout && clearTimeout(e2.timeout), 0 === this.data[t2].length && delete this.data[t2], this.order.splice(this.order.indexOf(t2), 1), e2.value;
  44855. }
  44856. getByKey(t2) {
  44857. const e2 = this.data[t2];
  44858. return e2 ? e2[0].value : null;
  44859. }
  44860. get(t2) {
  44861. return this.has(t2) ? this.data[t2.wrapped().key][0].value : null;
  44862. }
  44863. remove(t2, e2) {
  44864. if (!this.has(t2))
  44865. return this;
  44866. const r2 = t2.wrapped().key, n2 = void 0 === e2 ? 0 : this.data[r2].indexOf(e2), i3 = this.data[r2][n2];
  44867. return this.data[r2].splice(n2, 1), i3.timeout && clearTimeout(i3.timeout), 0 === this.data[r2].length && delete this.data[r2], this.onRemove(i3.value), this.order.splice(this.order.indexOf(r2), 1), this;
  44868. }
  44869. setMaxSize(t2) {
  44870. for (this.max = t2; this.order.length > this.max; ) {
  44871. const t3 = this._getAndRemoveByKey(this.order[0]);
  44872. t3 && this.onRemove(t3);
  44873. }
  44874. return this;
  44875. }
  44876. filter(t2) {
  44877. const e2 = [];
  44878. for (const r2 in this.data)
  44879. for (const n2 of this.data[r2])
  44880. t2(n2.value) || e2.push(n2);
  44881. for (const t3 of e2)
  44882. this.remove(t3.value.tileID, t3);
  44883. }
  44884. }
  44885. class vf {
  44886. constructor(t2, e2, r2) {
  44887. this.func = t2, this.mask = e2, this.range = r2;
  44888. }
  44889. }
  44890. vf.ReadOnly = false, vf.ReadWrite = true, vf.disabled = new vf(519, vf.ReadOnly, [0, 1]);
  44891. const bf = 7680;
  44892. class _f {
  44893. constructor(t2, e2, r2, n2, i3, s2) {
  44894. this.test = t2, this.ref = e2, this.mask = r2, this.fail = n2, this.depthFail = i3, this.pass = s2;
  44895. }
  44896. }
  44897. _f.disabled = new _f({ func: 519, mask: 0 }, 0, 0, bf, bf, bf);
  44898. class wf {
  44899. constructor(t2, e2, r2) {
  44900. this.blendFunction = t2, this.blendColor = e2, this.mask = r2;
  44901. }
  44902. }
  44903. wf.Replace = [1, 0], wf.disabled = new wf(wf.Replace, ce.transparent, [false, false, false, false]), wf.unblended = new wf(wf.Replace, ce.transparent, [true, true, true, true]), wf.alphaBlended = new wf([1, 771], ce.transparent, [true, true, true, true]);
  44904. const Af = 1029, kf = 2305;
  44905. class Sf {
  44906. constructor(t2, e2, r2) {
  44907. this.enable = t2, this.mode = e2, this.frontFace = r2;
  44908. }
  44909. }
  44910. Sf.disabled = new Sf(false, Af, kf), Sf.backCCW = new Sf(true, Af, kf), Sf.backCW = new Sf(true, Af, 2304), Sf.frontCW = new Sf(true, 1028, 2304), Sf.frontCCW = new Sf(true, 1028, kf);
  44911. class If extends Ut {
  44912. constructor(t2, e2, r2) {
  44913. super(), this.id = t2, this._onlySymbols = r2, e2.on("data", (t3) => {
  44914. "source" === t3.dataType && "metadata" === t3.sourceDataType && (this._sourceLoaded = true), this._sourceLoaded && !this._paused && "source" === t3.dataType && "content" === t3.sourceDataType && (this.reload(), this.transform && this.update(this.transform));
  44915. }), e2.on("error", () => {
  44916. this._sourceErrored = true;
  44917. }), this._source = e2, this._tiles = {}, this._cache = new xf(0, this._unloadTile.bind(this)), this._timers = {}, this._cacheTimers = {}, this._minTileCacheSize = e2.minTileCacheSize, this._maxTileCacheSize = e2.maxTileCacheSize, this._loadedParentTiles = {}, this._coveredTiles = {}, this._state = new of(), this._isRaster = "raster" === this._source.type || "raster-dem" === this._source.type || "custom" === this._source.type && "raster" === this._source._dataType;
  44918. }
  44919. onAdd(t2) {
  44920. this.map = t2, this._minTileCacheSize = void 0 === this._minTileCacheSize && t2 ? t2._minTileCacheSize : this._minTileCacheSize, this._maxTileCacheSize = void 0 === this._maxTileCacheSize && t2 ? t2._maxTileCacheSize : this._maxTileCacheSize;
  44921. }
  44922. loaded() {
  44923. if (this._sourceErrored)
  44924. return true;
  44925. if (!this._sourceLoaded)
  44926. return false;
  44927. if (!this._source.loaded())
  44928. return false;
  44929. for (const t2 in this._tiles) {
  44930. const e2 = this._tiles[t2];
  44931. if ("loaded" !== e2.state && "errored" !== e2.state)
  44932. return false;
  44933. }
  44934. return true;
  44935. }
  44936. getSource() {
  44937. return this._source;
  44938. }
  44939. pause() {
  44940. this._paused = true;
  44941. }
  44942. resume() {
  44943. if (!this._paused)
  44944. return;
  44945. const t2 = this._shouldReloadOnResume;
  44946. this._paused = false, this._shouldReloadOnResume = false, t2 && this.reload(), this.transform && this.update(this.transform);
  44947. }
  44948. _loadTile(t2, e2) {
  44949. return t2.isSymbolTile = this._onlySymbols, this._source.loadTile(t2, e2);
  44950. }
  44951. _unloadTile(t2) {
  44952. if (this._source.unloadTile)
  44953. return this._source.unloadTile(t2, () => {
  44954. });
  44955. }
  44956. _abortTile(t2) {
  44957. if (this._source.abortTile)
  44958. return this._source.abortTile(t2, () => {
  44959. });
  44960. }
  44961. serialize() {
  44962. return this._source.serialize();
  44963. }
  44964. prepare(t2) {
  44965. if (this._source.prepare && this._source.prepare(), this._state.coalesceChanges(this._tiles, this.map ? this.map.painter : null), this._source.prepareTile)
  44966. for (const e2 in this._tiles) {
  44967. const r2 = this._tiles[e2];
  44968. this._source.prepareTile(r2) && this.map.painter.terrain && this.map.painter.terrain._clearRenderCacheForTile(this.id, r2.tileID), r2.upload(t2), r2.prepare(this.map.style.imageManager);
  44969. }
  44970. else
  44971. for (const e2 in this._tiles) {
  44972. const r2 = this._tiles[e2];
  44973. r2.upload(t2), r2.prepare(this.map.style.imageManager);
  44974. }
  44975. }
  44976. getIds() {
  44977. return v(this._tiles).map((t2) => t2.tileID).sort(Mf).map((t2) => t2.key);
  44978. }
  44979. getRenderableIds(t2) {
  44980. const e2 = [];
  44981. for (const r2 in this._tiles)
  44982. this._isIdRenderable(+r2, t2) && e2.push(this._tiles[r2]);
  44983. return t2 ? e2.sort((t3, e3) => {
  44984. const r2 = t3.tileID, n2 = e3.tileID, s2 = new i2(r2.canonical.x, r2.canonical.y)._rotate(this.transform.angle), a2 = new i2(n2.canonical.x, n2.canonical.y)._rotate(this.transform.angle);
  44985. return r2.overscaledZ - n2.overscaledZ || a2.y - s2.y || a2.x - s2.x;
  44986. }).map((t3) => t3.tileID.key) : e2.map((t3) => t3.tileID).sort(Mf).map((t3) => t3.key);
  44987. }
  44988. hasRenderableParent(t2) {
  44989. const e2 = this.findLoadedParent(t2, 0);
  44990. return !!e2 && this._isIdRenderable(e2.tileID.key);
  44991. }
  44992. _isIdRenderable(t2, e2) {
  44993. return this._tiles[t2] && this._tiles[t2].hasData() && !this._coveredTiles[t2] && (e2 || !this._tiles[t2].holdingForFade());
  44994. }
  44995. reload() {
  44996. if (this._paused)
  44997. this._shouldReloadOnResume = true;
  44998. else {
  44999. this._cache.reset();
  45000. for (const t2 in this._tiles)
  45001. "errored" !== this._tiles[t2].state && this._reloadTile(+t2, "reloading");
  45002. }
  45003. }
  45004. _reloadTile(t2, e2) {
  45005. const r2 = this._tiles[t2];
  45006. r2 && ("loading" !== r2.state && (r2.state = e2), this._loadTile(r2, this._tileLoaded.bind(this, r2, t2, e2)));
  45007. }
  45008. _tileLoaded(t2, e2, r2, n2) {
  45009. if (n2)
  45010. if (t2.state = "errored", 404 !== n2.status)
  45011. this._source.fire(new Rt(n2, { tile: t2 }));
  45012. else if ("raster-dem" === this._source.type && this.usedForTerrain && this.map.painter.terrain) {
  45013. const t3 = this.map.painter.terrain;
  45014. this.update(this.transform, t3.getScaledDemTileSize(), true), t3.resetTileLookupCache(this.id);
  45015. } else
  45016. this.update(this.transform);
  45017. else
  45018. t2.timeAdded = N.now(), "expired" === r2 && (t2.refreshedUponExpiration = true), this._setTileReloadTimer(e2, t2), "raster-dem" === this._source.type && t2.dem && this._backfillDEM(t2), this._state.initializeTileState(t2, this.map ? this.map.painter : null), this._source.fire(new Lt("data", { dataType: "source", tile: t2, coord: t2.tileID, sourceCacheId: this.id }));
  45019. }
  45020. _backfillDEM(t2) {
  45021. const e2 = this.getRenderableIds();
  45022. for (let n2 = 0; n2 < e2.length; n2++) {
  45023. const i3 = e2[n2];
  45024. if (t2.neighboringTiles && t2.neighboringTiles[i3]) {
  45025. const e3 = this.getTileByID(i3);
  45026. r2(t2, e3), r2(e3, t2);
  45027. }
  45028. }
  45029. function r2(t3, e3) {
  45030. if (!t3.dem || t3.dem.borderReady)
  45031. return;
  45032. t3.needsHillshadePrepare = true, t3.needsDEMTextureUpload = true;
  45033. let r3 = e3.tileID.canonical.x - t3.tileID.canonical.x;
  45034. const n2 = e3.tileID.canonical.y - t3.tileID.canonical.y, i3 = Math.pow(2, t3.tileID.canonical.z), s2 = e3.tileID.key;
  45035. 0 === r3 && 0 === n2 || Math.abs(n2) > 1 || (Math.abs(r3) > 1 && (1 === Math.abs(r3 + i3) ? r3 += i3 : 1 === Math.abs(r3 - i3) && (r3 -= i3)), e3.dem && t3.dem && (t3.dem.backfillBorder(e3.dem, r3, n2), t3.neighboringTiles && t3.neighboringTiles[s2] && (t3.neighboringTiles[s2].backfilled = true)));
  45036. }
  45037. }
  45038. getTile(t2) {
  45039. return this.getTileByID(t2.key);
  45040. }
  45041. getTileByID(t2) {
  45042. return this._tiles[t2];
  45043. }
  45044. _retainLoadedChildren(t2, e2, r2, n2) {
  45045. for (const i3 in this._tiles) {
  45046. let s2 = this._tiles[i3];
  45047. if (n2[i3] || !s2.hasData() || s2.tileID.overscaledZ <= e2 || s2.tileID.overscaledZ > r2)
  45048. continue;
  45049. let a2 = s2.tileID;
  45050. for (; s2 && s2.tileID.overscaledZ > e2 + 1; ) {
  45051. const t3 = s2.tileID.scaledTo(s2.tileID.overscaledZ - 1);
  45052. s2 = this._tiles[t3.key], s2 && s2.hasData() && (a2 = t3);
  45053. }
  45054. let o2 = a2;
  45055. for (; o2.overscaledZ > e2; )
  45056. if (o2 = o2.scaledTo(o2.overscaledZ - 1), t2[o2.key]) {
  45057. n2[a2.key] = a2;
  45058. break;
  45059. }
  45060. }
  45061. }
  45062. findLoadedParent(t2, e2) {
  45063. if (t2.key in this._loadedParentTiles) {
  45064. const r2 = this._loadedParentTiles[t2.key];
  45065. return r2 && r2.tileID.overscaledZ >= e2 ? r2 : null;
  45066. }
  45067. for (let r2 = t2.overscaledZ - 1; r2 >= e2; r2--) {
  45068. const e3 = t2.scaledTo(r2), n2 = this._getLoadedTile(e3);
  45069. if (n2)
  45070. return n2;
  45071. }
  45072. }
  45073. _getLoadedTile(t2) {
  45074. const e2 = this._tiles[t2.key];
  45075. return e2 && e2.hasData() ? e2 : this._cache.getByKey(this._source.reparseOverscaled ? t2.wrapped().key : t2.canonical.key);
  45076. }
  45077. updateCacheSize(t2, e2) {
  45078. e2 = e2 || this._source.tileSize;
  45079. const r2 = Math.ceil(t2.width / e2) + 1, n2 = Math.ceil(t2.height / e2) + 1, i3 = Math.floor(r2 * n2 * 5), s2 = "number" == typeof this._minTileCacheSize ? Math.max(this._minTileCacheSize, i3) : i3, a2 = "number" == typeof this._maxTileCacheSize ? Math.min(this._maxTileCacheSize, s2) : s2;
  45080. this._cache.setMaxSize(a2);
  45081. }
  45082. handleWrapJump(t2) {
  45083. const e2 = Math.round((t2 - (void 0 === this._prevLng ? t2 : this._prevLng)) / 360);
  45084. if (this._prevLng = t2, e2) {
  45085. const t3 = {};
  45086. for (const r2 in this._tiles) {
  45087. const n2 = this._tiles[r2];
  45088. n2.tileID = n2.tileID.unwrapTo(n2.tileID.wrap + e2), t3[n2.tileID.key] = n2;
  45089. }
  45090. this._tiles = t3;
  45091. for (const t4 in this._timers)
  45092. clearTimeout(this._timers[t4]), delete this._timers[t4];
  45093. for (const t4 in this._tiles)
  45094. this._setTileReloadTimer(+t4, this._tiles[t4]);
  45095. }
  45096. }
  45097. update(t2, e2, r2) {
  45098. if (this.transform = t2, !this._sourceLoaded || this._paused || this.transform.freezeTileCoverage)
  45099. return;
  45100. if (this.usedForTerrain && !r2)
  45101. return;
  45102. let n2;
  45103. this.updateCacheSize(t2, e2), "globe" !== this.transform.projection.name && this.handleWrapJump(this.transform.center.lng), this._coveredTiles = {}, this.used || this.usedForTerrain ? this._source.tileID ? n2 = t2.getVisibleUnwrappedCoordinates(this._source.tileID).map((t3) => new Np(t3.canonical.z, t3.wrap, t3.canonical.z, t3.canonical.x, t3.canonical.y)) : (n2 = t2.coveringTiles({ tileSize: e2 || this._source.tileSize, minzoom: this._source.minzoom, maxzoom: this._source.maxzoom, roundZoom: this._source.roundZoom && !r2, reparseOverscaled: this._source.reparseOverscaled, isTerrainDEM: this.usedForTerrain }), this._source.hasTile && (n2 = n2.filter((t3) => this._source.hasTile(t3)))) : n2 = [];
  45104. const i3 = this._updateRetainedTiles(n2);
  45105. if (Tf(this._source.type) && 0 !== n2.length) {
  45106. const t3 = {}, e3 = {}, r3 = Object.keys(i3);
  45107. for (const n3 of r3) {
  45108. const r4 = i3[n3], s4 = this._tiles[n3];
  45109. if (!s4 || s4.fadeEndTime && s4.fadeEndTime <= N.now())
  45110. continue;
  45111. const a2 = this.findLoadedParent(r4, Math.max(r4.overscaledZ - If.maxOverzooming, this._source.minzoom));
  45112. a2 && (this._addTile(a2.tileID), t3[a2.tileID.key] = a2.tileID), e3[n3] = r4;
  45113. }
  45114. const s3 = n2[n2.length - 1].overscaledZ;
  45115. for (const t4 in this._tiles) {
  45116. const r4 = this._tiles[t4];
  45117. if (i3[t4] || !r4.hasData())
  45118. continue;
  45119. let n3 = r4.tileID;
  45120. for (; n3.overscaledZ > s3; ) {
  45121. n3 = n3.scaledTo(n3.overscaledZ - 1);
  45122. const s4 = this._tiles[n3.key];
  45123. if (s4 && s4.hasData() && e3[n3.key]) {
  45124. i3[t4] = r4.tileID;
  45125. break;
  45126. }
  45127. }
  45128. }
  45129. for (const e4 in t3)
  45130. i3[e4] || (this._coveredTiles[e4] = true, i3[e4] = t3[e4]);
  45131. }
  45132. for (const t3 in i3)
  45133. this._tiles[t3].clearFadeHold();
  45134. const s2 = function(t3, e3) {
  45135. const r3 = [];
  45136. for (const n3 in t3)
  45137. n3 in e3 || r3.push(n3);
  45138. return r3;
  45139. }(this._tiles, i3);
  45140. for (const t3 of s2) {
  45141. const e3 = this._tiles[t3];
  45142. e3.hasSymbolBuckets && !e3.holdingForFade() ? e3.setHoldDuration(this.map._fadeDuration) : e3.hasSymbolBuckets && !e3.symbolFadeFinished() || this._removeTile(+t3);
  45143. }
  45144. this._updateLoadedParentTileCache(), this._onlySymbols && this._source.afterUpdate && this._source.afterUpdate();
  45145. }
  45146. releaseSymbolFadeTiles() {
  45147. for (const t2 in this._tiles)
  45148. this._tiles[t2].holdingForFade() && this._removeTile(+t2);
  45149. }
  45150. _updateRetainedTiles(t2) {
  45151. const e2 = {};
  45152. if (0 === t2.length)
  45153. return e2;
  45154. const r2 = {}, n2 = t2.reduce((t3, e3) => Math.min(t3, e3.overscaledZ), 1 / 0), i3 = t2[0].overscaledZ, s2 = Math.max(i3 - If.maxOverzooming, this._source.minzoom), a2 = Math.max(i3 + If.maxUnderzooming, this._source.minzoom), o2 = {};
  45155. for (const r3 of t2) {
  45156. const t3 = this._addTile(r3);
  45157. e2[r3.key] = r3, t3.hasData() || n2 < this._source.maxzoom && (o2[r3.key] = r3);
  45158. }
  45159. this._retainLoadedChildren(o2, n2, a2, e2);
  45160. for (const n3 of t2) {
  45161. let t3 = this._tiles[n3.key];
  45162. if (t3.hasData())
  45163. continue;
  45164. if (n3.canonical.z >= this._source.maxzoom) {
  45165. const t4 = n3.children(this._source.maxzoom)[0], r3 = this.getTile(t4);
  45166. if (r3 && r3.hasData()) {
  45167. e2[t4.key] = t4;
  45168. continue;
  45169. }
  45170. } else {
  45171. const t4 = n3.children(this._source.maxzoom);
  45172. if (e2[t4[0].key] && e2[t4[1].key] && e2[t4[2].key] && e2[t4[3].key])
  45173. continue;
  45174. }
  45175. let i4 = t3.wasRequested();
  45176. for (let a3 = n3.overscaledZ - 1; a3 >= s2; --a3) {
  45177. const s3 = n3.scaledTo(a3);
  45178. if (r2[s3.key])
  45179. break;
  45180. if (r2[s3.key] = true, t3 = this.getTile(s3), !t3 && i4 && (t3 = this._addTile(s3)), t3 && (e2[s3.key] = s3, i4 = t3.wasRequested(), t3.hasData()))
  45181. break;
  45182. }
  45183. }
  45184. return e2;
  45185. }
  45186. _updateLoadedParentTileCache() {
  45187. this._loadedParentTiles = {};
  45188. for (const t2 in this._tiles) {
  45189. const e2 = [];
  45190. let r2, n2 = this._tiles[t2].tileID;
  45191. for (; n2.overscaledZ > 0; ) {
  45192. if (n2.key in this._loadedParentTiles) {
  45193. r2 = this._loadedParentTiles[n2.key];
  45194. break;
  45195. }
  45196. e2.push(n2.key);
  45197. const t3 = n2.scaledTo(n2.overscaledZ - 1);
  45198. if (r2 = this._getLoadedTile(t3), r2)
  45199. break;
  45200. n2 = t3;
  45201. }
  45202. for (const t3 of e2)
  45203. this._loadedParentTiles[t3] = r2;
  45204. }
  45205. }
  45206. _addTile(t2) {
  45207. let e2 = this._tiles[t2.key];
  45208. if (e2)
  45209. return this._source.prepareTile && this._source.prepareTile(e2), e2;
  45210. e2 = this._cache.getAndRemove(t2), e2 && (this._setTileReloadTimer(t2.key, e2), e2.tileID = t2, this._state.initializeTileState(e2, this.map ? this.map.painter : null), this._cacheTimers[t2.key] && (clearTimeout(this._cacheTimers[t2.key]), delete this._cacheTimers[t2.key], this._setTileReloadTimer(t2.key, e2)));
  45211. const r2 = Boolean(e2);
  45212. if (!r2) {
  45213. const r3 = this.map ? this.map.painter : null;
  45214. e2 = new af(t2, this._source.tileSize * t2.overscaleFactor(), this.transform.tileZoom, r3, this._isRaster), this._source.prepareTile && this._source.prepareTile(e2) || this._loadTile(e2, this._tileLoaded.bind(this, e2, t2.key, e2.state));
  45215. }
  45216. return e2 ? (e2.uses++, this._tiles[t2.key] = e2, r2 || this._source.fire(new Lt("dataloading", { tile: e2, coord: e2.tileID, dataType: "source" })), e2) : null;
  45217. }
  45218. _setTileReloadTimer(t2, e2) {
  45219. t2 in this._timers && (clearTimeout(this._timers[t2]), delete this._timers[t2]);
  45220. const r2 = e2.getExpiryTimeout();
  45221. r2 && (this._timers[t2] = setTimeout(() => {
  45222. this._reloadTile(t2, "expired"), delete this._timers[t2];
  45223. }, r2));
  45224. }
  45225. _removeTile(t2) {
  45226. const e2 = this._tiles[t2];
  45227. e2 && (e2.uses--, delete this._tiles[t2], this._timers[t2] && (clearTimeout(this._timers[t2]), delete this._timers[t2]), e2.uses > 0 || (e2.hasData() && "reloading" !== e2.state ? this._cache.add(e2.tileID, e2, e2.getExpiryTimeout()) : (e2.aborted = true, this._abortTile(e2), this._unloadTile(e2))));
  45228. }
  45229. clearTiles() {
  45230. this._shouldReloadOnResume = false, this._paused = false;
  45231. for (const t2 in this._tiles)
  45232. this._removeTile(+t2);
  45233. this._source._clear && this._source._clear(), this._cache.reset(), this.map && this.usedForTerrain && this.map.painter.terrain && this.map.painter.terrain.resetTileLookupCache(this.id);
  45234. }
  45235. tilesIn(t2, e2, r2) {
  45236. const n2 = [], i3 = this.transform;
  45237. if (!i3)
  45238. return n2;
  45239. for (const s2 in this._tiles) {
  45240. const a2 = this._tiles[s2];
  45241. if (r2 && a2.clearQueryDebugViz(), a2.holdingForFade())
  45242. continue;
  45243. const o2 = t2.containsTile(a2, i3, e2);
  45244. o2 && n2.push(o2);
  45245. }
  45246. return n2;
  45247. }
  45248. getVisibleCoordinates(t2) {
  45249. const e2 = this.getRenderableIds(t2).map((t3) => this._tiles[t3].tileID);
  45250. for (const t3 of e2)
  45251. t3.projMatrix = this.transform.calculateProjMatrix(t3.toUnwrapped());
  45252. return e2;
  45253. }
  45254. hasTransition() {
  45255. if (this._source.hasTransition())
  45256. return true;
  45257. if (Tf(this._source.type))
  45258. for (const t2 in this._tiles) {
  45259. const e2 = this._tiles[t2];
  45260. if (void 0 !== e2.fadeEndTime && e2.fadeEndTime >= N.now())
  45261. return true;
  45262. }
  45263. return false;
  45264. }
  45265. setFeatureState(t2, e2, r2) {
  45266. this._state.updateState(t2 = t2 || "_geojsonTileLayer", e2, r2);
  45267. }
  45268. removeFeatureState(t2, e2, r2) {
  45269. this._state.removeFeatureState(t2 = t2 || "_geojsonTileLayer", e2, r2);
  45270. }
  45271. getFeatureState(t2, e2) {
  45272. return this._state.getState(t2 = t2 || "_geojsonTileLayer", e2);
  45273. }
  45274. setDependencies(t2, e2, r2) {
  45275. const n2 = this._tiles[t2];
  45276. n2 && n2.setDependencies(e2, r2);
  45277. }
  45278. reloadTilesForDependencies(t2, e2) {
  45279. for (const r2 in this._tiles)
  45280. this._tiles[r2].hasDependency(t2, e2) && this._reloadTile(+r2, "reloading");
  45281. this._cache.filter((r2) => !r2.hasDependency(t2, e2));
  45282. }
  45283. _preloadTiles(t2, e2) {
  45284. const r2 = /* @__PURE__ */ new Map(), n2 = Array.isArray(t2) ? t2 : [t2], i3 = this.map.painter.terrain, s2 = this.usedForTerrain && i3 ? i3.getScaledDemTileSize() : this._source.tileSize;
  45285. for (const t3 of n2) {
  45286. const e3 = t3.coveringTiles({ tileSize: s2, minzoom: this._source.minzoom, maxzoom: this._source.maxzoom, roundZoom: this._source.roundZoom && !this.usedForTerrain, reparseOverscaled: this._source.reparseOverscaled, isTerrainDEM: this.usedForTerrain });
  45287. for (const t4 of e3)
  45288. r2.set(t4.key, t4);
  45289. this.usedForTerrain && t3.updateElevation(false);
  45290. }
  45291. x(Array.from(r2.values()), (t3, e3) => {
  45292. const r3 = new af(t3, this._source.tileSize * t3.overscaleFactor(), this.transform.tileZoom, this.map.painter, this._isRaster);
  45293. this._loadTile(r3, (t4) => {
  45294. "raster-dem" === this._source.type && r3.dem && this._backfillDEM(r3), e3(t4, r3);
  45295. });
  45296. }, e2);
  45297. }
  45298. }
  45299. function Mf(t2, e2) {
  45300. const r2 = Math.abs(2 * t2.wrap) - +(t2.wrap < 0), n2 = Math.abs(2 * e2.wrap) - +(e2.wrap < 0);
  45301. return t2.overscaledZ - e2.overscaledZ || n2 - r2 || e2.canonical.y - t2.canonical.y || e2.canonical.x - t2.canonical.x;
  45302. }
  45303. function Tf(t2) {
  45304. return "raster" === t2 || "image" === t2 || "video" === t2;
  45305. }
  45306. If.maxOverzooming = 10, If.maxUnderzooming = 3;
  45307. class zf {
  45308. constructor(t2, e2, r2) {
  45309. this._demTile = t2, this._dem = this._demTile.dem, this._scale = e2, this._offset = r2;
  45310. }
  45311. static create(t2, e2, r2) {
  45312. const n2 = r2 || t2.findDEMTileFor(e2);
  45313. if (!n2 || !n2.dem)
  45314. return;
  45315. const i3 = n2.dem, s2 = n2.tileID, a2 = 1 << e2.canonical.z - s2.canonical.z;
  45316. return new zf(n2, n2.tileSize / Ya / a2, [(e2.canonical.x / a2 - s2.canonical.x) * i3.dim, (e2.canonical.y / a2 - s2.canonical.y) * i3.dim]);
  45317. }
  45318. tileCoordToPixel(t2, e2) {
  45319. const r2 = e2 * this._scale + this._offset[1], n2 = Math.floor(t2 * this._scale + this._offset[0]), s2 = Math.floor(r2);
  45320. return new i2(n2, s2);
  45321. }
  45322. getElevationAt(t2, e2, r2, n2) {
  45323. const i3 = t2 * this._scale + this._offset[0], s2 = e2 * this._scale + this._offset[1], a2 = Math.floor(i3), o2 = Math.floor(s2), l2 = this._dem;
  45324. return n2 = !!n2, r2 ? rr(rr(l2.get(a2, o2, n2), l2.get(a2, o2 + 1, n2), s2 - o2), rr(l2.get(a2 + 1, o2, n2), l2.get(a2 + 1, o2 + 1, n2), s2 - o2), i3 - a2) : l2.get(a2, o2, n2);
  45325. }
  45326. getElevationAtPixel(t2, e2, r2) {
  45327. return this._dem.get(t2, e2, !!r2);
  45328. }
  45329. getMeterToDEM(t2) {
  45330. return (1 << this._demTile.tileID.canonical.z) * no(1, t2) * this._dem.stride;
  45331. }
  45332. }
  45333. class Bf {
  45334. constructor(t2, e2) {
  45335. this.tileID = t2, this.x = t2.canonical.x, this.y = t2.canonical.y, this.z = t2.canonical.z, this.grid = new ni(Ya, 16, 0), this.featureIndexArray = new ua(), this.promoteId = e2;
  45336. }
  45337. insert(t2, e2, r2, n2, i3, s2 = 0) {
  45338. const a2 = this.featureIndexArray.length;
  45339. this.featureIndexArray.emplaceBack(r2, n2, i3, s2);
  45340. const o2 = this.grid;
  45341. for (let t3 = 0; t3 < e2.length; t3++) {
  45342. const r3 = e2[t3], n3 = [1 / 0, 1 / 0, -1 / 0, -1 / 0];
  45343. for (let t4 = 0; t4 < r3.length; t4++) {
  45344. const e3 = r3[t4];
  45345. n3[0] = Math.min(n3[0], e3.x), n3[1] = Math.min(n3[1], e3.y), n3[2] = Math.max(n3[2], e3.x), n3[3] = Math.max(n3[3], e3.y);
  45346. }
  45347. n3[0] < Ya && n3[1] < Ya && n3[2] >= 0 && n3[3] >= 0 && o2.insert(a2, n3[0], n3[1], n3[2], n3[3]);
  45348. }
  45349. }
  45350. loadVTLayers() {
  45351. if (!this.vtLayers) {
  45352. this.vtLayers = new Du.VectorTile(new wc(this.rawTileData)).layers, this.sourceLayerCoder = new Xp(this.vtLayers ? Object.keys(this.vtLayers).sort() : ["_geojsonTileLayer"]), this.vtFeatures = {};
  45353. for (const t2 in this.vtLayers)
  45354. this.vtFeatures[t2] = [];
  45355. }
  45356. return this.vtLayers;
  45357. }
  45358. query(t2, e2, r2, n2) {
  45359. this.loadVTLayers();
  45360. const i3 = t2.params || {}, s2 = Sn(i3.filter), a2 = t2.tileResult, o2 = t2.transform, l2 = a2.bufferedTilespaceBounds, u2 = this.grid.query(l2.min.x, l2.min.y, l2.max.x, l2.max.y, (t3, e3, r3, n3) => Bo(a2.bufferedTilespaceGeometry, t3, e3, r3, n3));
  45361. u2.sort(Cf);
  45362. let c2 = null;
  45363. o2.elevation && u2.length > 0 && (c2 = zf.create(o2.elevation, this.tileID));
  45364. const h2 = {};
  45365. let p2;
  45366. for (let o3 = 0; o3 < u2.length; o3++) {
  45367. const l3 = u2[o3];
  45368. if (l3 === p2)
  45369. continue;
  45370. p2 = l3;
  45371. const f2 = this.featureIndexArray.get(l3);
  45372. let d2 = null;
  45373. this.loadMatchingFeature(h2, f2, s2, i3.layers, i3.availableImages, e2, r2, n2, (e3, r3, n3, i4 = 0) => (d2 || (d2 = yo(e3, this.tileID.canonical, t2.tileTransform)), r3.queryIntersectsFeature(a2, e3, n3, d2, this.z, t2.transform, t2.pixelPosMatrix, c2, i4)));
  45374. }
  45375. return h2;
  45376. }
  45377. loadMatchingFeature(t2, e2, r2, n2, i3, s2, a2, o2, l2) {
  45378. const { featureIndex: u2, bucketIndex: c2, sourceLayerIndex: h2, layoutVertexArrayOffset: p2 } = e2, f2 = this.bucketLayerIDs[c2];
  45379. if (n2 && !function(t3, e3) {
  45380. for (let r3 = 0; r3 < t3.length; r3++)
  45381. if (e3.indexOf(t3[r3]) >= 0)
  45382. return true;
  45383. return false;
  45384. }(n2, f2))
  45385. return;
  45386. const d2 = this.sourceLayerCoder.decode(h2), y2 = this.vtLayers[d2].feature(u2);
  45387. if (r2.needGeometry) {
  45388. const t3 = mo(y2, true);
  45389. if (!r2.filter(new ss(this.tileID.overscaledZ), t3, this.tileID.canonical))
  45390. return;
  45391. } else if (!r2.filter(new ss(this.tileID.overscaledZ), y2))
  45392. return;
  45393. const m2 = this.getId(y2, d2);
  45394. for (let e3 = 0; e3 < f2.length; e3++) {
  45395. const r3 = f2[e3];
  45396. if (n2 && n2.indexOf(r3) < 0)
  45397. continue;
  45398. const c3 = s2[r3];
  45399. if (!c3)
  45400. continue;
  45401. let h3 = {};
  45402. void 0 !== m2 && o2 && (h3 = o2.getState(c3.sourceLayer || "_geojsonTileLayer", m2));
  45403. const d3 = b({}, a2[r3]);
  45404. d3.paint = Ef(d3.paint, c3.paint, y2, h3, i3), d3.layout = Ef(d3.layout, c3.layout, y2, h3, i3);
  45405. const g2 = !l2 || l2(y2, c3, h3, p2);
  45406. if (!g2)
  45407. continue;
  45408. const x2 = new Yp(y2, this.z, this.x, this.y, m2);
  45409. x2.layer = d3;
  45410. let v2 = t2[r3];
  45411. void 0 === v2 && (v2 = t2[r3] = []), v2.push({ featureIndex: u2, feature: x2, intersectionZ: g2 });
  45412. }
  45413. }
  45414. lookupSymbolFeatures(t2, e2, r2, n2, i3, s2, a2, o2) {
  45415. const l2 = {};
  45416. this.loadVTLayers();
  45417. const u2 = Sn(i3);
  45418. for (const i4 of t2)
  45419. this.loadMatchingFeature(l2, { bucketIndex: r2, sourceLayerIndex: n2, featureIndex: i4, layoutVertexArrayOffset: 0 }, u2, s2, a2, o2, e2);
  45420. return l2;
  45421. }
  45422. loadFeature(t2) {
  45423. const { featureIndex: e2, sourceLayerIndex: r2 } = t2;
  45424. this.loadVTLayers();
  45425. const n2 = this.sourceLayerCoder.decode(r2), i3 = this.vtFeatures[n2];
  45426. if (i3[e2])
  45427. return i3[e2];
  45428. const s2 = this.vtLayers[n2].feature(e2);
  45429. return i3[e2] = s2, s2;
  45430. }
  45431. hasLayer(t2) {
  45432. for (const e2 of this.bucketLayerIDs)
  45433. for (const r2 of e2)
  45434. if (t2 === r2)
  45435. return true;
  45436. return false;
  45437. }
  45438. getId(t2, e2) {
  45439. let r2 = t2.id;
  45440. return this.promoteId && (r2 = t2.properties["string" == typeof this.promoteId ? this.promoteId : this.promoteId[e2]], "boolean" == typeof r2 && (r2 = Number(r2))), r2;
  45441. }
  45442. }
  45443. function Ef(t2, e2, r2, n2, i3) {
  45444. return T(t2, (t3, s2) => {
  45445. const a2 = e2 instanceof fs ? e2.get(s2) : null;
  45446. return a2 && a2.evaluate ? a2.evaluate(r2, n2, i3) : a2;
  45447. });
  45448. }
  45449. function Cf(t2, e2) {
  45450. return e2 - t2;
  45451. }
  45452. ai(Bf, "FeatureIndex", { omit: ["rawTileData", "sourceLayerCoder"] });
  45453. class Df {
  45454. constructor(t2) {
  45455. const e2 = {}, r2 = [];
  45456. for (const n3 in t2) {
  45457. const i4 = t2[n3], s3 = e2[n3] = {};
  45458. for (const t3 in i4.glyphs) {
  45459. const e3 = i4.glyphs[+t3];
  45460. if (!e3 || 0 === e3.bitmap.width || 0 === e3.bitmap.height)
  45461. continue;
  45462. const n4 = e3.metrics.localGlyph ? 2 : 1, a2 = { x: 0, y: 0, w: e3.bitmap.width + 2 * n4, h: e3.bitmap.height + 2 * n4 };
  45463. r2.push(a2), s3[t3] = a2;
  45464. }
  45465. }
  45466. const { w: n2, h: i3 } = Gc(r2), s2 = new zl({ width: n2 || 1, height: i3 || 1 });
  45467. for (const r3 in t2) {
  45468. const n3 = t2[r3];
  45469. for (const t3 in n3.glyphs) {
  45470. const i4 = n3.glyphs[+t3];
  45471. if (!i4 || 0 === i4.bitmap.width || 0 === i4.bitmap.height)
  45472. continue;
  45473. const a2 = e2[r3][t3], o2 = i4.metrics.localGlyph ? 2 : 1;
  45474. zl.copy(i4.bitmap, s2, { x: 0, y: 0 }, { x: a2.x + o2, y: a2.y + o2 }, i4.bitmap);
  45475. }
  45476. }
  45477. this.image = s2, this.positions = e2;
  45478. }
  45479. }
  45480. ai(Df, "GlyphAtlas");
  45481. class Pf {
  45482. constructor(t2) {
  45483. this.tileID = new Np(t2.tileID.overscaledZ, t2.tileID.wrap, t2.tileID.canonical.z, t2.tileID.canonical.x, t2.tileID.canonical.y), this.tileZoom = t2.tileZoom, this.uid = t2.uid, this.zoom = t2.zoom, this.canonical = t2.tileID.canonical, this.pixelRatio = t2.pixelRatio, this.tileSize = t2.tileSize, this.source = t2.source, this.overscaling = this.tileID.overscaleFactor(), this.showCollisionBoxes = t2.showCollisionBoxes, this.collectResourceTiming = !!t2.collectResourceTiming, this.returnDependencies = !!t2.returnDependencies, this.promoteId = t2.promoteId, this.enableTerrain = !!t2.enableTerrain, this.isSymbolTile = t2.isSymbolTile, this.tileTransform = Zp(t2.tileID.canonical, t2.projection), this.projection = t2.projection;
  45484. }
  45485. parse(t2, e2, r2, n2, i3) {
  45486. this.status = "parsing", this.data = t2, this.collisionBoxArray = new ea();
  45487. const s2 = new Xp(Object.keys(t2.layers).sort()), a2 = new Bf(this.tileID, this.promoteId);
  45488. a2.bucketLayerIDs = [];
  45489. const o2 = {}, l2 = new pp(256, 256), u2 = { featureIndex: a2, iconDependencies: {}, patternDependencies: {}, glyphDependencies: {}, lineAtlas: l2, availableImages: r2 }, c2 = e2.familiesBySource[this.source];
  45490. for (const e3 in c2) {
  45491. const n3 = t2.layers[e3];
  45492. if (!n3)
  45493. continue;
  45494. let i4 = false, l3 = false;
  45495. for (const t3 of c2[e3])
  45496. "symbol" === t3[0].type ? i4 = true : l3 = true;
  45497. if (true === this.isSymbolTile && !i4)
  45498. continue;
  45499. if (false === this.isSymbolTile && !l3)
  45500. continue;
  45501. 1 === n3.version && C(`Vector tile source "${this.source}" layer "${e3}" does not use vector tile spec v2 and therefore may have some rendering errors.`);
  45502. const h3 = s2.encode(e3), p3 = [];
  45503. for (let t3 = 0; t3 < n3.length; t3++) {
  45504. const r3 = n3.feature(t3), i5 = a2.getId(r3, e3);
  45505. p3.push({ feature: r3, id: i5, index: t3, sourceLayerIndex: h3 });
  45506. }
  45507. for (const t3 of c2[e3]) {
  45508. const e4 = t3[0];
  45509. void 0 !== this.isSymbolTile && "symbol" === e4.type !== this.isSymbolTile || e4.minzoom && this.zoom < Math.floor(e4.minzoom) || e4.maxzoom && this.zoom >= e4.maxzoom || "none" !== e4.visibility && (Vf(t3, this.zoom, r2), (o2[e4.id] = e4.createBucket({ index: a2.bucketLayerIDs.length, layers: t3, zoom: this.zoom, canonical: this.canonical, pixelRatio: this.pixelRatio, overscaling: this.overscaling, collisionBoxArray: this.collisionBoxArray, sourceLayerIndex: h3, sourceID: this.source, enableTerrain: this.enableTerrain, projection: this.projection.name, availableImages: r2 })).populate(p3, u2, this.tileID.canonical, this.tileTransform), a2.bucketLayerIDs.push(t3.map((t4) => t4.id)));
  45510. }
  45511. }
  45512. let h2, p2, f2, d2;
  45513. l2.trim();
  45514. const y2 = { type: "maybePrepare", isSymbolTile: this.isSymbolTile, zoom: this.zoom }, m2 = T(u2.glyphDependencies, (t3) => Object.keys(t3).map(Number));
  45515. Object.keys(m2).length ? n2.send("getGlyphs", { uid: this.uid, stacks: m2 }, (t3, e3) => {
  45516. h2 || (h2 = t3, p2 = e3, b2.call(this));
  45517. }, void 0, false, y2) : p2 = {};
  45518. const g2 = Object.keys(u2.iconDependencies);
  45519. g2.length ? n2.send("getImages", { icons: g2, source: this.source, tileID: this.tileID, type: "icons" }, (t3, e3) => {
  45520. h2 || (h2 = t3, f2 = e3, b2.call(this));
  45521. }, void 0, false, y2) : f2 = {};
  45522. const x2 = Object.keys(u2.patternDependencies);
  45523. function b2() {
  45524. if (h2)
  45525. return i3(h2);
  45526. if (p2 && f2 && d2) {
  45527. const t3 = new Df(p2), e3 = new Xc(f2, d2);
  45528. for (const n3 in o2) {
  45529. const i4 = o2[n3];
  45530. i4 instanceof tp ? (Vf(i4.layers, this.zoom, r2), Rh(i4, p2, t3.positions, f2, e3.iconPositions, this.showCollisionBoxes, r2, this.tileID.canonical, this.tileZoom, this.projection)) : i4.hasPattern && (i4 instanceof Qu || i4 instanceof xu || i4 instanceof $u) && (Vf(i4.layers, this.zoom, r2), i4.addFeatures(u2, this.tileID.canonical, e3.patternPositions, r2, this.tileTransform));
  45531. }
  45532. this.status = "done", i3(null, { buckets: v(o2).filter((t4) => !t4.isEmpty()), featureIndex: a2, collisionBoxArray: this.collisionBoxArray, glyphAtlasImage: t3.image, lineAtlas: l2, imageAtlas: e3, glyphMap: this.returnDependencies ? p2 : null, iconMap: this.returnDependencies ? f2 : null, glyphPositions: this.returnDependencies ? t3.positions : null });
  45533. }
  45534. }
  45535. x2.length ? n2.send("getImages", { icons: x2, source: this.source, tileID: this.tileID, type: "patterns" }, (t3, e3) => {
  45536. h2 || (h2 = t3, d2 = e3, b2.call(this));
  45537. }, void 0, false, y2) : d2 = {}, b2.call(this);
  45538. }
  45539. }
  45540. function Vf(t2, e2, r2) {
  45541. const n2 = new ss(e2);
  45542. for (const e3 of t2)
  45543. e3.recalculate(n2, r2);
  45544. }
  45545. class Ff {
  45546. constructor(t2) {
  45547. this.entries = {}, this.scheduler = t2;
  45548. }
  45549. request(t2, e2, r2, n2) {
  45550. const i3 = this.entries[t2] = this.entries[t2] || { callbacks: [] };
  45551. if (i3.result) {
  45552. const [t3, r3] = i3.result;
  45553. return this.scheduler ? this.scheduler.add(() => {
  45554. n2(t3, r3);
  45555. }, e2) : n2(t3, r3), () => {
  45556. };
  45557. }
  45558. return i3.callbacks.push(n2), i3.cancel || (i3.cancel = r2((r3, n3) => {
  45559. i3.result = [r3, n3];
  45560. for (const t3 of i3.callbacks)
  45561. this.scheduler ? this.scheduler.add(() => {
  45562. t3(r3, n3);
  45563. }, e2) : t3(r3, n3);
  45564. setTimeout(() => delete this.entries[t2], 3e3);
  45565. })), () => {
  45566. i3.result || (i3.callbacks = i3.callbacks.filter((t3) => t3 !== n2), i3.callbacks.length || (i3.cancel(), delete this.entries[t2]));
  45567. };
  45568. }
  45569. }
  45570. function Lf(t2, e2, r2) {
  45571. const n2 = JSON.stringify(t2.request);
  45572. return t2.data && (this.deduped.entries[n2] = { result: [null, t2.data] }), this.deduped.request(n2, { type: "parseTile", isSymbolTile: t2.isSymbolTile, zoom: t2.tileZoom }, (e3) => {
  45573. const n3 = Mt(t2.request, (t3, n4, i3, s2) => {
  45574. t3 ? e3(t3) : n4 && e3(null, { vectorTile: r2 ? void 0 : new Du.VectorTile(new wc(n4)), rawData: n4, cacheControl: i3, expires: s2 });
  45575. });
  45576. return () => {
  45577. n3.cancel(), e3();
  45578. };
  45579. }, e2);
  45580. }
  45581. const Rf = jo(new Float32Array(16));
  45582. class Uf {
  45583. constructor(t2) {
  45584. this.name = t2.name, this.wrap = false, this.requiresDraping = false, this.supportsWorldCopies = false, this.supportsTerrain = false, this.supportsFog = false, this.supportsFreeCamera = false, this.zAxisUnit = "meters", this.isReprojectedInTileSpace = true, this.unsupportedLayers = ["custom"], this.center = [0, 0], this.range = [3.5, 7];
  45585. }
  45586. project(t2, e2) {
  45587. return { x: 0, y: 0, z: 0 };
  45588. }
  45589. unproject(t2, e2) {
  45590. return new Ja(0, 0);
  45591. }
  45592. projectTilePoint(t2, e2, r2) {
  45593. return { x: t2, y: e2, z: 0 };
  45594. }
  45595. locationPoint(t2, e2) {
  45596. return t2._coordinatePoint(t2.locationCoordinate(e2), false);
  45597. }
  45598. pixelsPerMeter(t2, e2) {
  45599. return no(1, t2) * e2;
  45600. }
  45601. farthestPixelDistance(t2) {
  45602. return function(t3, e2) {
  45603. const r2 = t3.fovAboveCenter, n2 = t3.elevation ? t3.elevation.getMinElevationBelowMSL() * e2 : 0, i3 = (t3._camera.position[2] * t3.worldSize - n2) / Math.cos(t3._pitch), s2 = Math.sin(r2) * i3 / Math.sin(Math.max(Math.PI / 2 - t3._pitch - r2, 0.01)), a2 = Math.sin(t3._pitch) * s2 + i3;
  45604. return Math.min(1.01 * a2, i3 * (1 / t3._horizonShift));
  45605. }(t2, t2.pixelsPerMeter);
  45606. }
  45607. pointCoordinate(t2, e2, r2, n2) {
  45608. const s2 = t2.horizonLineFromTop(false), a2 = new i2(e2, Math.max(s2, r2));
  45609. return t2.rayIntersectionCoordinate(t2.pointRayIntersection(a2, n2));
  45610. }
  45611. createInversionMatrix(t2, e2) {
  45612. return Rf;
  45613. }
  45614. createTileMatrix(t2, e2, r2) {
  45615. let n2, i3, s2;
  45616. const a2 = r2.canonical, o2 = jo(new Float64Array(16));
  45617. if (this.isReprojectedInTileSpace) {
  45618. const l2 = Zp(a2, this);
  45619. n2 = 1, i3 = l2.x + r2.wrap * l2.scale, s2 = l2.y, No(o2, o2, [n2 / l2.scale, n2 / l2.scale, t2.pixelsPerMeter / e2]);
  45620. } else
  45621. n2 = e2 / t2.zoomScale(a2.z), i3 = (a2.x + Math.pow(2, a2.z) * r2.wrap) * n2, s2 = a2.y * n2;
  45622. return qo(o2, o2, [i3, s2, 0]), No(o2, o2, [n2 / Ya, n2 / Ya, 1]), o2;
  45623. }
  45624. upVector(t2, e2, r2) {
  45625. return [0, 0, 1];
  45626. }
  45627. upVectorScale(t2, e2, r2) {
  45628. return { metersToTile: 1, metersToLabelSpace: 1 };
  45629. }
  45630. }
  45631. class $f extends Uf {
  45632. constructor(t2) {
  45633. super(t2), this.wrap = true, this.supportsWorldCopies = true, this.supportsTerrain = true, this.supportsFog = true, this.supportsFreeCamera = true, this.isReprojectedInTileSpace = false, this.unsupportedLayers = [], this.range = null;
  45634. }
  45635. project(t2, e2) {
  45636. return { x: eo(t2), y: ro(e2), z: 0 };
  45637. }
  45638. unproject(t2, e2) {
  45639. const r2 = io(t2), n2 = so(e2);
  45640. return new Ja(r2, n2);
  45641. }
  45642. }
  45643. class jf extends Uf {
  45644. constructor(t2) {
  45645. super(t2), this.range = [4, 7], this.center = t2.center || [-96, 37.5];
  45646. const [e2, r2] = this.parallels = t2.parallels || [29.5, 45.5], n2 = Math.sin(u(e2));
  45647. this.n = (n2 + Math.sin(u(r2))) / 2, this.c = 1 + n2 * (2 * this.n - n2), this.r0 = Math.sqrt(this.c) / this.n;
  45648. }
  45649. project(t2, e2) {
  45650. const { n: r2, c: n2, r0: i3 } = this, s2 = u(t2 - this.center[0]), a2 = u(e2), o2 = Math.sqrt(n2 - 2 * r2 * Math.sin(a2)) / r2;
  45651. return { x: o2 * Math.sin(s2 * r2), y: o2 * Math.cos(s2 * r2) - i3, z: 0 };
  45652. }
  45653. unproject(t2, e2) {
  45654. const { n: r2, c: n2, r0: i3 } = this, s2 = i3 + e2;
  45655. let a2 = Math.atan2(t2, Math.abs(s2)) * Math.sign(s2);
  45656. s2 * r2 < 0 && (a2 -= Math.PI * Math.sign(t2) * Math.sign(s2));
  45657. const o2 = u(this.center[0]) * r2;
  45658. a2 = g(a2, -Math.PI - o2, Math.PI - o2);
  45659. const l2 = c(a2 / r2) + this.center[0], h2 = Math.asin(y((n2 - (t2 * t2 + s2 * s2) * r2 * r2) / (2 * r2), -1, 1)), p2 = y(c(h2), -85.051129, oo);
  45660. return new Ja(l2, p2);
  45661. }
  45662. }
  45663. const Of = 1.340264, qf = -0.081106, Nf = 893e-6, Gf = 3796e-6, Zf = Math.sqrt(3) / 2;
  45664. class Xf extends Uf {
  45665. project(t2, e2) {
  45666. e2 = e2 / 180 * Math.PI, t2 = t2 / 180 * Math.PI;
  45667. const r2 = Math.asin(Zf * Math.sin(e2)), n2 = r2 * r2, i3 = n2 * n2 * n2;
  45668. return { x: 0.5 * (t2 * Math.cos(r2) / (Zf * (Of + 3 * qf * n2 + i3 * (7 * Nf + 9 * Gf * n2))) / Math.PI + 0.5), y: 1 - 0.5 * (r2 * (Of + qf * n2 + i3 * (Nf + Gf * n2)) / Math.PI + 1), z: 0 };
  45669. }
  45670. unproject(t2, e2) {
  45671. t2 = (2 * t2 - 0.5) * Math.PI;
  45672. let r2 = e2 = (2 * (1 - e2) - 1) * Math.PI, n2 = r2 * r2, i3 = n2 * n2 * n2;
  45673. for (let t3, s3, a3, o3 = 0; o3 < 12 && (s3 = r2 * (Of + qf * n2 + i3 * (Nf + Gf * n2)) - e2, a3 = Of + 3 * qf * n2 + i3 * (7 * Nf + 9 * Gf * n2), t3 = s3 / a3, r2 = y(r2 - t3, -Math.PI / 3, Math.PI / 3), n2 = r2 * r2, i3 = n2 * n2 * n2, !(Math.abs(t3) < 1e-12)); ++o3)
  45674. ;
  45675. const s2 = Zf * t2 * (Of + 3 * qf * n2 + i3 * (7 * Nf + 9 * Gf * n2)) / Math.cos(r2), a2 = Math.asin(Math.sin(r2) / Zf), o2 = y(180 * s2 / Math.PI, -180, 180), l2 = y(180 * a2 / Math.PI, -85.051129, oo);
  45676. return new Ja(o2, l2);
  45677. }
  45678. }
  45679. class Kf extends Uf {
  45680. constructor(t2) {
  45681. super(t2), this.wrap = true, this.supportsWorldCopies = true;
  45682. }
  45683. project(t2, e2) {
  45684. return { x: 0.5 + t2 / 360, y: 0.5 - e2 / 360, z: 0 };
  45685. }
  45686. unproject(t2, e2) {
  45687. const r2 = 360 * (t2 - 0.5), n2 = y(360 * (0.5 - e2), -85.051129, oo);
  45688. return new Ja(r2, n2);
  45689. }
  45690. }
  45691. const Yf = Math.PI / 2;
  45692. function Hf(t2) {
  45693. return Math.tan((Yf + t2) / 2);
  45694. }
  45695. class Wf extends Uf {
  45696. constructor(t2) {
  45697. super(t2), this.center = t2.center || [0, 30];
  45698. const [e2, r2] = this.parallels = t2.parallels || [30, 30], n2 = u(e2), i3 = u(r2), s2 = Math.cos(n2);
  45699. this.n = n2 === i3 ? Math.sin(n2) : Math.log(s2 / Math.cos(i3)) / Math.log(Hf(i3) / Hf(n2)), this.f = s2 * Math.pow(Hf(n2), this.n) / this.n;
  45700. }
  45701. project(t2, e2) {
  45702. e2 = u(e2), t2 = u(t2 - this.center[0]);
  45703. const r2 = 1e-6, { n: n2, f: i3 } = this;
  45704. i3 > 0 ? e2 < -Yf + r2 && (e2 = -Yf + r2) : e2 > Yf - r2 && (e2 = Yf - r2);
  45705. const s2 = i3 / Math.pow(Hf(e2), n2), a2 = s2 * Math.sin(n2 * t2), o2 = i3 - s2 * Math.cos(n2 * t2);
  45706. return { x: 0.5 * (a2 / Math.PI + 0.5), y: 1 - 0.5 * (o2 / Math.PI + 0.5), z: 0 };
  45707. }
  45708. unproject(t2, e2) {
  45709. t2 = (2 * t2 - 0.5) * Math.PI, e2 = (2 * (1 - e2) - 0.5) * Math.PI;
  45710. const { n: r2, f: n2 } = this, i3 = n2 - e2, s2 = Math.sign(i3), a2 = Math.sign(r2) * Math.sqrt(t2 * t2 + i3 * i3);
  45711. let o2 = Math.atan2(t2, Math.abs(i3)) * s2;
  45712. i3 * r2 < 0 && (o2 -= Math.PI * Math.sign(t2) * s2);
  45713. const l2 = y(c(o2 / r2) + this.center[0], -180, 180), u2 = y(c(2 * Math.atan(Math.pow(n2 / a2, 1 / r2)) - Yf), -85.051129, oo);
  45714. return new Ja(l2, u2);
  45715. }
  45716. }
  45717. const Jf = u(oo);
  45718. class Qf extends Uf {
  45719. project(t2, e2) {
  45720. const r2 = (e2 = u(e2)) * e2, n2 = r2 * r2;
  45721. return { x: 0.5 * ((t2 = u(t2)) * (0.8707 - 0.131979 * r2 + n2 * (n2 * (3971e-6 * r2 - 1529e-6 * n2) - 0.013791)) / Math.PI + 0.5), y: 1 - 0.5 * (e2 * (1.007226 + r2 * (0.015085 + n2 * (0.028874 * r2 - 0.044475 - 5916e-6 * n2))) / Math.PI + 1), z: 0 };
  45722. }
  45723. unproject(t2, e2) {
  45724. t2 = (2 * t2 - 0.5) * Math.PI;
  45725. let r2 = e2 = (2 * (1 - e2) - 1) * Math.PI, n2 = 25, i3 = 0, s2 = r2 * r2;
  45726. do {
  45727. s2 = r2 * r2;
  45728. const t3 = s2 * s2;
  45729. i3 = (r2 * (1.007226 + s2 * (0.015085 + t3 * (0.028874 * s2 - 0.044475 - 5916e-6 * t3))) - e2) / (1.007226 + s2 * (0.045255 + t3 * (0.259866 * s2 - 0.311325 - 5916e-6 * 11 * t3))), r2 = y(r2 - i3, -Jf, Jf);
  45730. } while (Math.abs(i3) > 1e-6 && --n2 > 0);
  45731. s2 = r2 * r2;
  45732. const a2 = y(c(t2 / (0.8707 + s2 * (s2 * (s2 * s2 * s2 * (3971e-6 - 1529e-6 * s2) - 0.013791) - 0.131979))), -180, 180), o2 = c(r2);
  45733. return new Ja(a2, o2);
  45734. }
  45735. }
  45736. const td = u(oo);
  45737. class ed extends Uf {
  45738. project(t2, e2) {
  45739. e2 = u(e2), t2 = u(t2);
  45740. const r2 = Math.cos(e2), n2 = 2 / Math.PI, i3 = Math.acos(r2 * Math.cos(t2 / 2)), s2 = Math.sin(i3) / i3, a2 = 0.5 * (t2 * n2 + 2 * r2 * Math.sin(t2 / 2) / s2) || 0, o2 = 0.5 * (e2 + Math.sin(e2) / s2) || 0;
  45741. return { x: 0.5 * (a2 / Math.PI + 0.5), y: 1 - 0.5 * (o2 / Math.PI + 1), z: 0 };
  45742. }
  45743. unproject(t2, e2) {
  45744. let r2 = t2 = (2 * t2 - 0.5) * Math.PI, n2 = e2 = (2 * (1 - e2) - 1) * Math.PI, i3 = 25;
  45745. const s2 = 1e-6;
  45746. let a2 = 0, o2 = 0;
  45747. do {
  45748. const i4 = Math.cos(n2), s3 = Math.sin(n2), l2 = 2 * s3 * i4, u2 = s3 * s3, c2 = i4 * i4, h2 = Math.cos(r2 / 2), p2 = Math.sin(r2 / 2), f2 = 2 * h2 * p2, d2 = p2 * p2, m2 = 1 - c2 * h2 * h2, g2 = m2 ? 1 / m2 : 0, x2 = m2 ? Math.acos(i4 * h2) * Math.sqrt(1 / m2) : 0, v2 = 0.5 * (2 * x2 * i4 * p2 + 2 * r2 / Math.PI) - t2, b2 = 0.5 * (x2 * s3 + n2) - e2, _2 = 0.5 * g2 * (c2 * d2 + x2 * i4 * h2 * u2) + 1 / Math.PI, w2 = g2 * (f2 * l2 / 4 - x2 * s3 * p2), A2 = 0.125 * g2 * (l2 * p2 - x2 * s3 * c2 * f2), k2 = 0.5 * g2 * (u2 * h2 + x2 * d2 * i4) + 0.5, S2 = w2 * A2 - k2 * _2;
  45749. a2 = (b2 * w2 - v2 * k2) / S2, o2 = (v2 * A2 - b2 * _2) / S2, r2 = y(r2 - a2, -Math.PI, Math.PI), n2 = y(n2 - o2, -td, td);
  45750. } while ((Math.abs(a2) > s2 || Math.abs(o2) > s2) && --i3 > 0);
  45751. return new Ja(c(r2), c(n2));
  45752. }
  45753. }
  45754. class rd extends Uf {
  45755. constructor(t2) {
  45756. super(t2), this.center = t2.center || [0, 0], this.parallels = t2.parallels || [0, 0], this.cosPhi = Math.max(0.01, Math.cos(u(this.parallels[0]))), this.scale = 1 / (2 * Math.max(Math.PI * this.cosPhi, 1 / this.cosPhi)), this.wrap = true, this.supportsWorldCopies = true;
  45757. }
  45758. project(t2, e2) {
  45759. const { scale: r2, cosPhi: n2 } = this;
  45760. return { x: u(t2) * n2 * r2 + 0.5, y: -Math.sin(u(e2)) / n2 * r2 + 0.5, z: 0 };
  45761. }
  45762. unproject(t2, e2) {
  45763. const { scale: r2, cosPhi: n2 } = this, i3 = -(e2 - 0.5) / r2, s2 = y(c((t2 - 0.5) / r2) / n2, -180, 180), a2 = Math.asin(y(i3 * n2, -1, 1)), o2 = y(c(a2), -85.051129, oo);
  45764. return new Ja(s2, o2);
  45765. }
  45766. }
  45767. t.ARRAY_TYPE = Uo, t.AUTH_ERR_MSG = tt, t.Aabb = vl, t.Actor = class {
  45768. constructor(t2, e2, r2) {
  45769. this.target = t2, this.parent = e2, this.mapId = r2, this.callbacks = {}, this.cancelCallbacks = {}, I(["receive"], this), this.target.addEventListener("message", this.receive, false), this.globalScope = V() ? t2 : a, this.scheduler = new mp();
  45770. }
  45771. send(t2, e2, r2, n2, i3 = false, s2) {
  45772. const a2 = Math.round(1e18 * Math.random()).toString(36).substring(0, 10);
  45773. r2 && (r2.metadata = s2, this.callbacks[a2] = r2);
  45774. const o2 = O(this.globalScope) ? void 0 : [];
  45775. return this.target.postMessage({ id: a2, type: t2, hasCallback: !!r2, targetMapId: n2, mustQueue: i3, sourceMapId: this.mapId, data: ui(e2, o2) }, o2), { cancel: () => {
  45776. r2 && delete this.callbacks[a2], this.target.postMessage({ id: a2, type: "<cancel>", targetMapId: n2, sourceMapId: this.mapId });
  45777. } };
  45778. }
  45779. receive(t2) {
  45780. const e2 = t2.data, r2 = e2.id;
  45781. if (r2 && (!e2.targetMapId || this.mapId === e2.targetMapId))
  45782. if ("<cancel>" === e2.type) {
  45783. const t3 = this.cancelCallbacks[r2];
  45784. delete this.cancelCallbacks[r2], t3 && t3.cancel();
  45785. } else if (e2.mustQueue || V()) {
  45786. const t3 = this.callbacks[r2];
  45787. this.cancelCallbacks[r2] = this.scheduler.add(() => this.processTask(r2, e2), t3 && t3.metadata || { type: "message" });
  45788. } else
  45789. this.processTask(r2, e2);
  45790. }
  45791. processTask(t2, e2) {
  45792. if ("<response>" === e2.type) {
  45793. const r2 = this.callbacks[t2];
  45794. delete this.callbacks[t2], r2 && (e2.error ? r2(ci(e2.error)) : r2(null, ci(e2.data)));
  45795. } else {
  45796. const r2 = O(this.globalScope) ? void 0 : [], n2 = e2.hasCallback ? (e3, n3) => {
  45797. delete this.cancelCallbacks[t2], this.target.postMessage({ id: t2, type: "<response>", sourceMapId: this.mapId, error: e3 ? ui(e3) : null, data: ui(n3, r2) }, r2);
  45798. } : (t3) => {
  45799. }, i3 = ci(e2.data);
  45800. if (this.parent[e2.type])
  45801. this.parent[e2.type](e2.sourceMapId, i3, n2);
  45802. else if (this.parent.getWorkerSource) {
  45803. const t3 = e2.type.split(".");
  45804. this.parent.getWorkerSource(e2.sourceMapId, t3[0], i3.source)[t3[1]](i3, n2);
  45805. } else
  45806. n2(new Error(`Could not find function ${e2.type}`));
  45807. }
  45808. }
  45809. remove() {
  45810. this.scheduler.remove(), this.target.removeEventListener("message", this.receive, false);
  45811. }
  45812. }, t.CanonicalTileID = Op, t.Color = ce, t.ColorMode = wf, t.CullFaceMode = Sf, t.DEMData = gf, t.DataConstantProperty = ds, t.DedupedRequest = Ff, t.DepthMode = vf, t.EXTENT = Ya, t.Elevation = class {
  45813. isDataAvailableAtPoint(t2) {
  45814. const e2 = this._source();
  45815. if (!e2 || t2.y < 0 || t2.y > 1)
  45816. return false;
  45817. const r2 = e2.getSource().maxzoom, n2 = 1 << r2, i3 = Math.floor(t2.x), s2 = Math.floor((t2.x - i3) * n2), a2 = Math.floor(t2.y * n2), o2 = this.findDEMTileFor(new Np(r2, i3, r2, s2, a2));
  45818. return !(!o2 || !o2.dem);
  45819. }
  45820. getAtPointOrZero(t2, e2 = 0) {
  45821. return this.getAtPoint(t2, e2) || 0;
  45822. }
  45823. getAtPoint(t2, e2, r2 = true) {
  45824. null == e2 && (e2 = null);
  45825. const n2 = this._source();
  45826. if (!n2)
  45827. return e2;
  45828. if (t2.y < 0 || t2.y > 1)
  45829. return e2;
  45830. const i3 = n2.getSource().maxzoom, s2 = 1 << i3, a2 = Math.floor(t2.x), o2 = t2.x - a2, l2 = new Np(i3, a2, i3, Math.floor(o2 * s2), Math.floor(t2.y * s2)), u2 = this.findDEMTileFor(l2);
  45831. if (!u2 || !u2.dem)
  45832. return e2;
  45833. const c2 = u2.dem, h2 = 1 << u2.tileID.canonical.z, p2 = (o2 * h2 - u2.tileID.canonical.x) * c2.dim, f2 = (t2.y * h2 - u2.tileID.canonical.y) * c2.dim, d2 = Math.floor(p2), y2 = Math.floor(f2);
  45834. return (r2 ? this.exaggeration() : 1) * rr(rr(c2.get(d2, y2), c2.get(d2, y2 + 1), f2 - y2), rr(c2.get(d2 + 1, y2), c2.get(d2 + 1, y2 + 1), f2 - y2), p2 - d2);
  45835. }
  45836. getAtTileOffset(t2, e2, r2) {
  45837. const n2 = 1 << t2.canonical.z;
  45838. return this.getAtPointOrZero(new lo(t2.wrap + (t2.canonical.x + e2 / Ya) / n2, (t2.canonical.y + r2 / Ya) / n2));
  45839. }
  45840. getAtTileOffsetFunc(t2, e2, r2, n2) {
  45841. return (i3) => {
  45842. const s2 = this.getAtTileOffset(t2, i3.x, i3.y), a2 = n2.upVector(t2.canonical, i3.x, i3.y);
  45843. return nl(a2, a2, s2 * n2.upVectorScale(t2.canonical, e2, r2).metersToTile), a2;
  45844. };
  45845. }
  45846. getForTilePoints(t2, e2, r2, n2) {
  45847. const i3 = zf.create(this, t2, n2);
  45848. return !!i3 && (e2.forEach((t3) => {
  45849. t3[2] = this.exaggeration() * i3.getElevationAt(t3[0], t3[1], r2);
  45850. }), true);
  45851. }
  45852. getMinMaxForTile(t2) {
  45853. const e2 = this.findDEMTileFor(t2);
  45854. if (!e2 || !e2.dem)
  45855. return null;
  45856. const r2 = e2.dem.tree, n2 = e2.tileID, i3 = 1 << t2.canonical.z - n2.canonical.z;
  45857. let s2 = t2.canonical.x / i3 - n2.canonical.x, a2 = t2.canonical.y / i3 - n2.canonical.y, o2 = 0;
  45858. for (let e3 = 0; e3 < t2.canonical.z - n2.canonical.z && !r2.leaves[o2]; e3++) {
  45859. s2 *= 2, a2 *= 2;
  45860. const t3 = 2 * Math.floor(a2) + Math.floor(s2);
  45861. o2 = r2.childOffsets[o2] + t3, s2 %= 1, a2 %= 1;
  45862. }
  45863. return { min: this.exaggeration() * r2.minimums[o2], max: this.exaggeration() * r2.maximums[o2] };
  45864. }
  45865. getMinElevationBelowMSL() {
  45866. throw new Error("Pure virtual method called.");
  45867. }
  45868. raycast(t2, e2, r2) {
  45869. throw new Error("Pure virtual method called.");
  45870. }
  45871. pointCoordinate(t2) {
  45872. throw new Error("Pure virtual method called.");
  45873. }
  45874. _source() {
  45875. throw new Error("Pure virtual method called.");
  45876. }
  45877. exaggeration() {
  45878. throw new Error("Pure virtual method called.");
  45879. }
  45880. findDEMTileFor(t2) {
  45881. throw new Error("Pure virtual method called.");
  45882. }
  45883. get visibleDemTiles() {
  45884. throw new Error("Getter must be implemented in subclass.");
  45885. }
  45886. }, t.ErrorEvent = Rt, t.EvaluationParameters = ss, t.Event = Lt, t.Evented = Ut, t.FillExtrusionBucket = $u, t.Frustum = xl, t.GLOBE_RADIUS = wp, t.GlobeSharedBuffers = class {
  45887. constructor(t2) {
  45888. this._createGrid(t2), this._createPoles(t2), this._createAtmosphere(t2);
  45889. }
  45890. destroy() {
  45891. this._poleIndexBuffer.destroy(), this._gridBuffer.destroy(), this._gridIndexBuffer.destroy(), this._poleNorthVertexBuffer.destroy(), this._poleSouthVertexBuffer.destroy();
  45892. for (const t2 of this._poleSegments)
  45893. t2.destroy();
  45894. this._gridSegments.destroy(), this.atmosphereVertexBuffer.destroy(), this.atmosphereIndexBuffer.destroy(), this.atmosphereSegments.destroy(), this._wireframeIndexBuffer && (this._wireframeIndexBuffer.destroy(), this._wireframeSegments.destroy());
  45895. }
  45896. _createGrid(t2) {
  45897. const e2 = new Is(), r2 = new js(), n2 = 65;
  45898. for (let t3 = 0; t3 < n2; t3++)
  45899. for (let r3 = 0; r3 < n2; r3++)
  45900. e2.emplaceBack(r3, t3);
  45901. for (let t3 = 0; t3 < 64; t3++)
  45902. for (let e3 = 0; e3 < 64; e3++) {
  45903. const i3 = t3 * n2 + e3;
  45904. r2.emplaceBack(i3 + 1, i3, i3 + n2), r2.emplaceBack(i3 + n2, i3 + n2 + 1, i3 + 1);
  45905. }
  45906. this._gridBuffer = t2.createVertexBuffer(e2, _p.members), this._gridIndexBuffer = t2.createIndexBuffer(r2, true), this._gridSegments = Ka.simpleSegment(0, 0, 4225, 8192);
  45907. }
  45908. _createPoles(t2) {
  45909. const e2 = new js();
  45910. for (let t3 = 0; t3 <= 64; t3++)
  45911. e2.emplaceBack(0, t3 + 1, t3 + 2);
  45912. this._poleIndexBuffer = t2.createIndexBuffer(e2, true);
  45913. const r2 = new Gs(), n2 = new Gs();
  45914. this._poleSegments = [];
  45915. for (let t3 = 0, e3 = 0; t3 < 5; t3++) {
  45916. const i3 = 1 << t3, s2 = 512 * i3 / Math.PI / 2, a2 = 360 / i3;
  45917. r2.emplaceBack(0, -s2, 0, 0, 0, 0.5, 0), n2.emplaceBack(0, -s2, 0, 0, 0, 0.5, 1);
  45918. for (let t4 = 0; t4 <= 64; t4++) {
  45919. const e4 = t4 / 64, i4 = rr(0, a2, e4), [o2, l2, u2] = Ep(Up, $p, i4, s2);
  45920. r2.emplaceBack(o2, l2, u2, 0, 0, e4, 0), n2.emplaceBack(o2, l2, u2, 0, 0, e4, 1);
  45921. }
  45922. this._poleSegments.push(Ka.simpleSegment(e3, 0, 66, 64)), e3 += 66;
  45923. }
  45924. this._poleNorthVertexBuffer = t2.createVertexBuffer(r2, vp, false), this._poleSouthVertexBuffer = t2.createVertexBuffer(n2, vp, false);
  45925. }
  45926. _createAtmosphere(t2) {
  45927. const e2 = new Zs();
  45928. e2.emplaceBack(-1, 1, 1, 0, 0), e2.emplaceBack(1, 1, 1, 1, 0), e2.emplaceBack(1, -1, 1, 1, 1), e2.emplaceBack(-1, -1, 1, 0, 1);
  45929. const r2 = new js();
  45930. r2.emplaceBack(0, 1, 2), r2.emplaceBack(2, 3, 0), this.atmosphereVertexBuffer = t2.createVertexBuffer(e2, xp.members), this.atmosphereIndexBuffer = t2.createIndexBuffer(r2), this.atmosphereSegments = Ka.simpleSegment(0, 0, 4, 2);
  45931. }
  45932. getGridBuffers() {
  45933. return [this._gridBuffer, this._gridIndexBuffer, this._gridSegments];
  45934. }
  45935. getPoleBuffers(t2) {
  45936. return [this._poleNorthVertexBuffer, this._poleSouthVertexBuffer, this._poleIndexBuffer, this._poleSegments[t2]];
  45937. }
  45938. getWirefameBuffers(t2) {
  45939. if (!this._wireframeSegments) {
  45940. const e2 = new Ks(), r2 = 64, n2 = r2 + 1;
  45941. for (let t3 = 0; t3 < r2; t3++)
  45942. for (let i3 = 0; i3 < r2; i3++) {
  45943. const r3 = t3 * n2 + i3;
  45944. e2.emplaceBack(r3, r3 + 1), e2.emplaceBack(r3, r3 + n2), e2.emplaceBack(r3, r3 + n2 + 1);
  45945. }
  45946. this._wireframeIndexBuffer = t2.createIndexBuffer(e2), this._wireframeSegments = Ka.simpleSegment(0, 0, r2 * r2, e2.length);
  45947. }
  45948. return [this._gridBuffer, this._wireframeIndexBuffer, this._wireframeSegments];
  45949. }
  45950. }, t.GlyphManager = Ah, t.ImagePosition = Zc, t.LineAtlas = pp, t.LngLat = Ja, t.LngLatBounds = Ha, t.LocalGlyphMode = wh, t.MAX_MERCATOR_LATITUDE = oo, t.MercatorCoordinate = lo, t.ONE_EM = cc, t.OverscaledTileID = Np, t.Properties = vs, t.RGBAImage = Bl, t.Ray = class {
  45951. constructor(t2, e2) {
  45952. this.pos = t2, this.dir = e2;
  45953. }
  45954. intersectsPlane(t2, e2, r2) {
  45955. const n2 = al(e2, this.dir);
  45956. if (Math.abs(n2) < 1e-6)
  45957. return false;
  45958. const i3 = ((t2[0] - this.pos[0]) * e2[0] + (t2[1] - this.pos[1]) * e2[1] + (t2[2] - this.pos[2]) * e2[2]) / n2;
  45959. return r2[0] = this.pos[0] + this.dir[0] * i3, r2[1] = this.pos[1] + this.dir[1] * i3, r2[2] = this.pos[2] + this.dir[2] * i3, true;
  45960. }
  45961. closestPointOnSphere(t2, e2, r2) {
  45962. if (function(t3, e3) {
  45963. var r3 = t3[0], n3 = t3[1], i4 = t3[2], s3 = e3[0], a3 = e3[1], o3 = e3[2];
  45964. return Math.abs(r3 - s3) <= Ro * Math.max(1, Math.abs(r3), Math.abs(s3)) && Math.abs(n3 - a3) <= Ro * Math.max(1, Math.abs(n3), Math.abs(a3)) && Math.abs(i4 - o3) <= Ro * Math.max(1, Math.abs(i4), Math.abs(o3));
  45965. }(this.pos, t2) || 0 === e2)
  45966. return r2[0] = r2[1] = r2[2] = 0, false;
  45967. const [n2, i3, s2] = this.dir, a2 = this.pos[0] - t2[0], o2 = this.pos[1] - t2[1], l2 = this.pos[2] - t2[2], u2 = n2 * n2 + i3 * i3 + s2 * s2, c2 = 2 * (a2 * n2 + o2 * i3 + l2 * s2), h2 = c2 * c2 - 4 * u2 * (a2 * a2 + o2 * o2 + l2 * l2 - e2 * e2);
  45968. if (h2 < 0) {
  45969. const t3 = Math.max(-c2 / 2, 0), u3 = a2 + n2 * t3, h3 = o2 + i3 * t3, p2 = l2 + s2 * t3, f2 = Math.hypot(u3, h3, p2);
  45970. return r2[0] = u3 * e2 / f2, r2[1] = h3 * e2 / f2, r2[2] = p2 * e2 / f2, false;
  45971. }
  45972. {
  45973. const t3 = (-c2 - Math.sqrt(h2)) / (2 * u2);
  45974. if (t3 < 0) {
  45975. const t4 = Math.hypot(a2, o2, l2);
  45976. return r2[0] = a2 * e2 / t4, r2[1] = o2 * e2 / t4, r2[2] = l2 * e2 / t4, false;
  45977. }
  45978. return r2[0] = a2 + n2 * t3, r2[1] = o2 + i3 * t3, r2[2] = l2 + s2 * t3, true;
  45979. }
  45980. }
  45981. }, t.RequestManager = class {
  45982. constructor(t2, e2, r2) {
  45983. this._transformRequestFn = t2, this._customAccessToken = e2, this._silenceAuthErrors = !!r2, this._createSkuToken();
  45984. }
  45985. _createSkuToken() {
  45986. const t2 = function() {
  45987. let t3 = "";
  45988. for (let e2 = 0; e2 < 10; e2++)
  45989. t3 += "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62 * Math.random())];
  45990. return { token: ["1", Q, t3].join(""), tokenExpiresAt: Date.now() + 432e5 };
  45991. }();
  45992. this._skuToken = t2.token, this._skuTokenExpiresAt = t2.tokenExpiresAt;
  45993. }
  45994. _isSkuTokenExpired() {
  45995. return Date.now() > this._skuTokenExpiresAt;
  45996. }
  45997. transformRequest(t2, e2) {
  45998. return this._transformRequestFn && this._transformRequestFn(t2, e2) || { url: t2 };
  45999. }
  46000. normalizeStyleURL(t2, e2) {
  46001. if (!et(t2))
  46002. return t2;
  46003. const r2 = it(t2);
  46004. return r2.path = `/styles/v1${r2.path}`, this._makeAPIURL(r2, this._customAccessToken || e2);
  46005. }
  46006. normalizeGlyphsURL(t2, e2) {
  46007. if (!et(t2))
  46008. return t2;
  46009. const r2 = it(t2);
  46010. return r2.path = `/fonts/v1${r2.path}`, this._makeAPIURL(r2, this._customAccessToken || e2);
  46011. }
  46012. normalizeSourceURL(t2, e2) {
  46013. if (!et(t2))
  46014. return t2;
  46015. const r2 = it(t2);
  46016. return r2.path = `/v4/${r2.authority}.json`, r2.params.push("secure"), this._makeAPIURL(r2, this._customAccessToken || e2);
  46017. }
  46018. normalizeSpriteURL(t2, e2, r2, n2) {
  46019. const i3 = it(t2);
  46020. return et(t2) ? (i3.path = `/styles/v1${i3.path}/sprite${e2}${r2}`, this._makeAPIURL(i3, this._customAccessToken || n2)) : (i3.path += `${e2}${r2}`, st(i3));
  46021. }
  46022. normalizeTileURL(t2, e2, r2) {
  46023. if (this._isSkuTokenExpired() && this._createSkuToken(), t2 && !et(t2))
  46024. return t2;
  46025. const n2 = it(t2);
  46026. n2.path = n2.path.replace(/(\.(png|jpg)\d*)(?=$)/, `${e2 || r2 && "raster" !== n2.authority && 512 === r2 ? "@2x" : ""}${X.supported ? ".webp" : "$1"}`), "raster" === n2.authority ? n2.path = `/${Z.RASTER_URL_PREFIX}${n2.path}` : (n2.path = n2.path.replace(/^.+\/v4\//, "/"), n2.path = `/${Z.TILE_URL_VERSION}${n2.path}`);
  46027. const i3 = this._customAccessToken || function(t3) {
  46028. for (const e3 of t3) {
  46029. const t4 = e3.match(/^access_token=(.*)$/);
  46030. if (t4)
  46031. return t4[1];
  46032. }
  46033. return null;
  46034. }(n2.params) || Z.ACCESS_TOKEN;
  46035. return Z.REQUIRE_ACCESS_TOKEN && i3 && this._skuToken && n2.params.push(`sku=${this._skuToken}`), this._makeAPIURL(n2, i3);
  46036. }
  46037. canonicalizeTileURL(t2, e2) {
  46038. const r2 = it(t2);
  46039. if (!r2.path.match(/^(\/v4\/|\/raster\/v1\/)/) || !r2.path.match(/\.[\w]+$/))
  46040. return t2;
  46041. let n2 = "mapbox://";
  46042. r2.path.match(/^\/raster\/v1\//) ? n2 += `raster/${r2.path.replace(`/${Z.RASTER_URL_PREFIX}/`, "")}` : n2 += `tiles/${r2.path.replace(`/${Z.TILE_URL_VERSION}/`, "")}`;
  46043. let i3 = r2.params;
  46044. return e2 && (i3 = i3.filter((t3) => !t3.match(/^access_token=/))), i3.length && (n2 += `?${i3.join("&")}`), n2;
  46045. }
  46046. canonicalizeTileset(t2, e2) {
  46047. const r2 = !!e2 && et(e2), n2 = [];
  46048. for (const e3 of t2.tiles || [])
  46049. rt(e3) ? n2.push(this.canonicalizeTileURL(e3, r2)) : n2.push(e3);
  46050. return n2;
  46051. }
  46052. _makeAPIURL(t2, e2) {
  46053. const r2 = "See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes", n2 = it(Z.API_URL);
  46054. if (t2.protocol = n2.protocol, t2.authority = n2.authority, "http" === t2.protocol) {
  46055. const e3 = t2.params.indexOf("secure");
  46056. e3 >= 0 && t2.params.splice(e3, 1);
  46057. }
  46058. if ("/" !== n2.path && (t2.path = `${n2.path}${t2.path}`), !Z.REQUIRE_ACCESS_TOKEN)
  46059. return st(t2);
  46060. if (e2 = e2 || Z.ACCESS_TOKEN, !this._silenceAuthErrors) {
  46061. if (!e2)
  46062. throw new Error(`An API access token is required to use Mapbox GL. ${r2}`);
  46063. if ("s" === e2[0])
  46064. throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${r2}`);
  46065. }
  46066. return t2.params = t2.params.filter((t3) => -1 === t3.indexOf("access_token")), t2.params.push(`access_token=${e2 || ""}`), st(t2);
  46067. }
  46068. }, t.ResourceType = At, t.SegmentVector = Ka, t.SourceCache = If, t.StencilMode = _f, t.StructArrayLayout1ui2 = Ys, t.StructArrayLayout2f1f2i16 = Us, t.StructArrayLayout2i4 = Is, t.StructArrayLayout2ui4 = Ks, t.StructArrayLayout3f12 = Vs, t.StructArrayLayout3ui6 = js, t.StructArrayLayout4i8 = Ts, t.Texture = hp, t.Tile = af, t.Transitionable = ls, t.Uniform1f = Sa, t.Uniform1i = class extends ka {
  46069. constructor(t2, e2) {
  46070. super(t2, e2), this.current = 0;
  46071. }
  46072. set(t2) {
  46073. this.current !== t2 && (this.current = t2, this.gl.uniform1i(this.location, t2));
  46074. }
  46075. }, t.Uniform2f = class extends ka {
  46076. constructor(t2, e2) {
  46077. super(t2, e2), this.current = [0, 0];
  46078. }
  46079. set(t2) {
  46080. t2[0] === this.current[0] && t2[1] === this.current[1] || (this.current = t2, this.gl.uniform2f(this.location, t2[0], t2[1]));
  46081. }
  46082. }, t.Uniform3f = class extends ka {
  46083. constructor(t2, e2) {
  46084. super(t2, e2), this.current = [0, 0, 0];
  46085. }
  46086. set(t2) {
  46087. t2[0] === this.current[0] && t2[1] === this.current[1] && t2[2] === this.current[2] || (this.current = t2, this.gl.uniform3f(this.location, t2[0], t2[1], t2[2]));
  46088. }
  46089. }, t.Uniform4f = Ia, t.UniformColor = Ma, t.UniformMatrix2f = class extends ka {
  46090. constructor(t2, e2) {
  46091. super(t2, e2), this.current = Ba;
  46092. }
  46093. set(t2) {
  46094. for (let e2 = 0; e2 < 4; e2++)
  46095. if (t2[e2] !== this.current[e2]) {
  46096. this.current = t2, this.gl.uniformMatrix2fv(this.location, false, t2);
  46097. break;
  46098. }
  46099. }
  46100. }, t.UniformMatrix3f = class extends ka {
  46101. constructor(t2, e2) {
  46102. super(t2, e2), this.current = za;
  46103. }
  46104. set(t2) {
  46105. for (let e2 = 0; e2 < 9; e2++)
  46106. if (t2[e2] !== this.current[e2]) {
  46107. this.current = t2, this.gl.uniformMatrix3fv(this.location, false, t2);
  46108. break;
  46109. }
  46110. }
  46111. }, t.UniformMatrix4f = class extends ka {
  46112. constructor(t2, e2) {
  46113. super(t2, e2), this.current = Ta;
  46114. }
  46115. set(t2) {
  46116. if (t2[12] !== this.current[12] || t2[0] !== this.current[0])
  46117. return this.current = t2, void this.gl.uniformMatrix4fv(this.location, false, t2);
  46118. for (let e2 = 1; e2 < 16; e2++)
  46119. if (t2[e2] !== this.current[e2]) {
  46120. this.current = t2, this.gl.uniformMatrix4fv(this.location, false, t2);
  46121. break;
  46122. }
  46123. }
  46124. }, t.UnwrappedTileID = qp, t.ValidationError = mn, t.VectorTileWorkerSource = class extends Ut {
  46125. constructor(t2, e2, r2, n2, i3) {
  46126. super(), this.actor = t2, this.layerIndex = e2, this.availableImages = r2, this.loadVectorData = i3 || Lf, this.loading = {}, this.loaded = {}, this.deduped = new Ff(t2.scheduler), this.isSpriteLoaded = n2, this.scheduler = t2.scheduler;
  46127. }
  46128. loadTile(t2, e2) {
  46129. const r2 = t2.uid, n2 = t2 && t2.request, i3 = n2 && n2.collectResourceTiming, s2 = this.loading[r2] = new Pf(t2);
  46130. s2.abort = this.loadVectorData(t2, (a2, o2) => {
  46131. const l2 = !this.loading[r2];
  46132. if (delete this.loading[r2], l2 || a2 || !o2)
  46133. return s2.status = "done", l2 || (this.loaded[r2] = s2), e2(a2);
  46134. const u2 = o2.rawData, c2 = {};
  46135. o2.expires && (c2.expires = o2.expires), o2.cacheControl && (c2.cacheControl = o2.cacheControl), s2.vectorTile = o2.vectorTile || new Du.VectorTile(new wc(u2));
  46136. const h2 = () => {
  46137. s2.parse(s2.vectorTile, this.layerIndex, this.availableImages, this.actor, (t3, r3) => {
  46138. if (t3 || !r3)
  46139. return e2(t3);
  46140. const s3 = {};
  46141. if (i3) {
  46142. const t4 = yp(n2);
  46143. t4.length > 0 && (s3.resourceTiming = JSON.parse(JSON.stringify(t4)));
  46144. }
  46145. e2(null, b({ rawTileData: u2.slice(0) }, r3, c2, s3));
  46146. });
  46147. };
  46148. this.isSpriteLoaded ? h2() : this.once("isSpriteLoaded", () => {
  46149. this.scheduler ? this.scheduler.add(h2, { type: "parseTile", isSymbolTile: t2.isSymbolTile, zoom: t2.tileZoom }) : h2();
  46150. }), this.loaded = this.loaded || {}, this.loaded[r2] = s2;
  46151. });
  46152. }
  46153. reloadTile(t2, e2) {
  46154. const r2 = this.loaded, n2 = t2.uid, i3 = this;
  46155. if (r2 && r2[n2]) {
  46156. const s2 = r2[n2];
  46157. s2.showCollisionBoxes = t2.showCollisionBoxes, s2.enableTerrain = !!t2.enableTerrain, s2.projection = t2.projection, s2.tileTransform = Zp(t2.tileID.canonical, t2.projection);
  46158. const a2 = (t3, r3) => {
  46159. const n3 = s2.reloadCallback;
  46160. n3 && (delete s2.reloadCallback, s2.parse(s2.vectorTile, i3.layerIndex, this.availableImages, i3.actor, n3)), e2(t3, r3);
  46161. };
  46162. "parsing" === s2.status ? s2.reloadCallback = a2 : "done" === s2.status && (s2.vectorTile ? s2.parse(s2.vectorTile, this.layerIndex, this.availableImages, this.actor, a2) : a2());
  46163. }
  46164. }
  46165. abortTile(t2, e2) {
  46166. const r2 = t2.uid, n2 = this.loading[r2];
  46167. n2 && (n2.abort && n2.abort(), delete this.loading[r2]), e2();
  46168. }
  46169. removeTile(t2, e2) {
  46170. const r2 = this.loaded, n2 = t2.uid;
  46171. r2 && r2[n2] && delete r2[n2], e2();
  46172. }
  46173. }, t.WritingMode = Kc, t.ZoomHistory = hi, t.add = Jo, t.addDynamicAttributes = Hh, t.adjoint = function(t2, e2) {
  46174. var r2 = e2[0], n2 = e2[1], i3 = e2[2], s2 = e2[3], a2 = e2[4], o2 = e2[5], l2 = e2[6], u2 = e2[7], c2 = e2[8];
  46175. return t2[0] = a2 * c2 - o2 * u2, t2[1] = i3 * u2 - n2 * c2, t2[2] = n2 * o2 - i3 * a2, t2[3] = o2 * l2 - s2 * c2, t2[4] = r2 * c2 - i3 * l2, t2[5] = i3 * s2 - r2 * o2, t2[6] = s2 * u2 - a2 * l2, t2[7] = n2 * l2 - r2 * u2, t2[8] = r2 * a2 - n2 * s2, t2;
  46176. }, t.asyncAll = x, t.bezier = f, t.bindAll = I, t.boundsAttributes = nf, t.bufferConvexPolygon = function(t2, e2) {
  46177. const r2 = [];
  46178. for (let n2 = 0; n2 < t2.length; n2++) {
  46179. const i3 = g(n2 - 1, -1, t2.length - 1), s2 = g(n2 + 1, -1, t2.length - 1), a2 = t2[n2], o2 = t2[s2], l2 = t2[i3].sub(a2).unit(), u2 = o2.sub(a2).unit(), c2 = u2.angleWithSep(l2.x, l2.y), h2 = l2.add(u2).unit().mult(-1 * e2 / Math.sin(c2 / 2));
  46180. r2.push(a2.add(h2));
  46181. }
  46182. return r2;
  46183. }, t.cacheEntryPossiblyAdded = function(t2) {
  46184. wt++, wt > vt && (t2.getActor().send("enforceCacheSizeLimit", xt), wt = 0);
  46185. }, t.calculateGlobeLabelMatrix = function(t2, e2) {
  46186. const { lng: r2, lat: n2 } = t2._center, i3 = Fp(0, 0, t2.worldSize / t2._projectionScaler, r2, n2);
  46187. return Oo(i3, i3, function(t3) {
  46188. const e3 = jo(new Float64Array(16)), r3 = 1 / Pp(t3);
  46189. return qo(e3, e3, t3.min), No(e3, e3, [r3, r3, r3]), e3;
  46190. }(Tp(e2)));
  46191. }, t.calculateGlobeMatrix = Lp, t.calculateGlobeMercatorMatrix = function(t2) {
  46192. const e2 = t2.worldSize, r2 = t2.point, n2 = no(1, t2.center.lat) * e2, i3 = t2.pixelsPerMeter, s2 = e2 / (n2 / t2.pixelsPerMeter), a2 = jo(new Float64Array(16));
  46193. return qo(a2, a2, [r2.x, r2.y, 0]), No(a2, a2, [s2, s2, i3]), Float32Array.from(a2);
  46194. }, t.circumferenceAtLatitude = to, t.clamp = y, t.clearTileCache = function(t2) {
  46195. const e2 = a.caches.delete(yt);
  46196. t2 && e2.catch(t2).then(() => t2());
  46197. }, t.clipLine = xh, t.clone = function(t2) {
  46198. var e2 = new Uo(16);
  46199. return e2[0] = t2[0], e2[1] = t2[1], e2[2] = t2[2], e2[3] = t2[3], e2[4] = t2[4], e2[5] = t2[5], e2[6] = t2[6], e2[7] = t2[7], e2[8] = t2[8], e2[9] = t2[9], e2[10] = t2[10], e2[11] = t2[11], e2[12] = t2[12], e2[13] = t2[13], e2[14] = t2[14], e2[15] = t2[15], e2;
  46200. }, t.clone$1 = B, t.collisionCircleLayout = uc, t.config = Z, t.conjugate = function(t2, e2) {
  46201. return t2[0] = -e2[0], t2[1] = -e2[1], t2[2] = -e2[2], t2[3] = e2[3], t2;
  46202. }, t.create = function() {
  46203. var t2 = new Uo(16);
  46204. return Uo != Float32Array && (t2[1] = 0, t2[2] = 0, t2[3] = 0, t2[4] = 0, t2[6] = 0, t2[7] = 0, t2[8] = 0, t2[9] = 0, t2[11] = 0, t2[12] = 0, t2[13] = 0, t2[14] = 0), t2[0] = 1, t2[5] = 1, t2[10] = 1, t2[15] = 1, t2;
  46205. }, t.create$1 = $o, t.createExpression = cn, t.createLayout = ks, t.createStyleLayer = function(t2) {
  46206. return "custom" === t2.type ? new op(t2) : new cp[t2.type](t2);
  46207. }, t.cross = ol, t.degToRad = u, t.div = function(t2, e2, r2) {
  46208. return t2[0] = e2[0] / r2[0], t2[1] = e2[1] / r2[1], t2[2] = e2[2] / r2[2], t2;
  46209. }, t.dot = al, t.earthRadius = Wa, t.ease = d, t.easeCubicInOut = p, t.emitValidationErrors = ri, t.endsWith = M, t.enforceCacheSizeLimit = function(t2) {
  46210. bt(), mt && mt.then((e2) => {
  46211. e2.keys().then((r2) => {
  46212. for (let n2 = 0; n2 < r2.length - t2; n2++)
  46213. e2.delete(r2[n2]);
  46214. });
  46215. });
  46216. }, t.evaluateSizeForFeature = fc, t.evaluateSizeForZoom = dc, t.evaluateVariableOffset = Lh, t.evented = es, t.exactEquals = function(t2, e2) {
  46217. return t2[0] === e2[0] && t2[1] === e2[1] && t2[2] === e2[2] && t2[3] === e2[3];
  46218. }, t.exactEquals$1 = function(t2, e2) {
  46219. return t2[0] === e2[0] && t2[1] === e2[1] && t2[2] === e2[2];
  46220. }, t.exported = N, t.exported$1 = X, t.extend = b, t.extend$1 = jt, t.filterObject = z, t.fromMat4 = function(t2, e2) {
  46221. return t2[0] = e2[0], t2[1] = e2[1], t2[2] = e2[2], t2[3] = e2[4], t2[4] = e2[5], t2[5] = e2[6], t2[6] = e2[8], t2[7] = e2[9], t2[8] = e2[10], t2;
  46222. }, t.fromQuat = function(t2, e2) {
  46223. var r2 = e2[0], n2 = e2[1], i3 = e2[2], s2 = e2[3], a2 = r2 + r2, o2 = n2 + n2, l2 = i3 + i3, u2 = r2 * a2, c2 = n2 * a2, h2 = n2 * o2, p2 = i3 * a2, f2 = i3 * o2, d2 = i3 * l2, y2 = s2 * a2, m2 = s2 * o2, g2 = s2 * l2;
  46224. return t2[0] = 1 - h2 - d2, t2[1] = c2 + g2, t2[2] = p2 - m2, t2[3] = 0, t2[4] = c2 - g2, t2[5] = 1 - u2 - d2, t2[6] = f2 + y2, t2[7] = 0, t2[8] = p2 + m2, t2[9] = f2 - y2, t2[10] = 1 - u2 - h2, t2[11] = 0, t2[12] = 0, t2[13] = 0, t2[14] = 0, t2[15] = 1, t2;
  46225. }, t.fromRotation = function(t2, e2) {
  46226. var r2 = Math.sin(e2), n2 = Math.cos(e2);
  46227. return t2[0] = n2, t2[1] = r2, t2[2] = 0, t2[3] = -r2, t2[4] = n2, t2[5] = 0, t2[6] = 0, t2[7] = 0, t2[8] = 1, t2;
  46228. }, t.fromScaling = function(t2, e2) {
  46229. return t2[0] = e2[0], t2[1] = 0, t2[2] = 0, t2[3] = 0, t2[4] = 0, t2[5] = e2[1], t2[6] = 0, t2[7] = 0, t2[8] = 0, t2[9] = 0, t2[10] = e2[2], t2[11] = 0, t2[12] = 0, t2[13] = 0, t2[14] = 0, t2[15] = 1, t2;
  46230. }, t.furthestTileCorner = function(t2) {
  46231. const e2 = Math.round((t2 + 45 + 360) % 360 / 90) % 4;
  46232. return h[e2];
  46233. }, t.getAABBPointSquareDist = function(t2, e2, r2) {
  46234. let n2 = 0;
  46235. for (let i3 = 0; i3 < 2; ++i3) {
  46236. const s2 = r2 ? r2[i3] : 0;
  46237. t2[i3] > s2 && (n2 += (t2[i3] - s2) * (t2[i3] - s2)), e2[i3] < s2 && (n2 += (s2 - e2[i3]) * (s2 - e2[i3]));
  46238. }
  46239. return n2;
  46240. }, t.getAnchorAlignment = ah, t.getAnchorJustification = Uh, t.getBounds = function(t2) {
  46241. let e2 = 1 / 0, r2 = 1 / 0, n2 = -1 / 0, s2 = -1 / 0;
  46242. for (const i3 of t2)
  46243. e2 = Math.min(e2, i3.x), r2 = Math.min(r2, i3.y), n2 = Math.max(n2, i3.x), s2 = Math.max(s2, i3.y);
  46244. return { min: new i2(e2, r2), max: new i2(n2, s2) };
  46245. }, t.getColumn = function(t2, e2) {
  46246. return [t2[4 * e2], t2[4 * e2 + 1], t2[4 * e2 + 2], t2[4 * e2 + 3]];
  46247. }, t.getGridMatrix = function(t2, e2) {
  46248. const [r2, n2] = e2, i3 = 0.015625;
  46249. return [0, (n2[1] - r2[1]) * i3, 1 << t2.z, (n2[0] - r2[0]) * i3, 0, t2.y, r2[0], r2[1], i3];
  46250. }, t.getImage = Pt, t.getJSON = function(t2, e2) {
  46251. return It(b(t2, { type: "json" }), e2);
  46252. }, t.getMapSessionAPI = ft, t.getPerformanceMeasurement = yp, t.getProjection = function(t2) {
  46253. const e2 = t2.parallels, r2 = !!e2 && Math.abs(e2[0] + e2[1]) < 0.01;
  46254. switch (t2.name) {
  46255. case "mercator":
  46256. return new $f(t2);
  46257. case "equirectangular":
  46258. return new Kf(t2);
  46259. case "naturalEarth":
  46260. return new Qf(t2);
  46261. case "equalEarth":
  46262. return new Xf(t2);
  46263. case "winkelTripel":
  46264. return new ed(t2);
  46265. case "albers":
  46266. return r2 ? new rd(t2) : new jf(t2);
  46267. case "lambertConformalConic":
  46268. return r2 ? new rd(t2) : new Wf(t2);
  46269. }
  46270. throw new Error(`Invalid projection name: ${t2.name}`);
  46271. }, t.getRTLTextPluginStatus = rs, t.getReferrer = St, t.getTilePoint = function(t2, { x: e2, y: r2 }, n2 = 0) {
  46272. return new i2(((e2 - n2) * t2.scale - t2.x) * Ya, (r2 * t2.scale - t2.y) * Ya);
  46273. }, t.getTileVec3 = function(t2, e2, r2 = 0) {
  46274. return Wo(((e2.x - r2) * t2.scale - t2.x) * Ya, (e2.y * t2.scale - t2.y) * Ya, ao(e2.z, e2.y));
  46275. }, t.getVideo = function(t2, e2) {
  46276. const r2 = a.document.createElement("video");
  46277. r2.muted = true, r2.onloadstart = function() {
  46278. e2(null, r2);
  46279. };
  46280. for (let e3 = 0; e3 < t2.length; e3++) {
  46281. const n2 = a.document.createElement("source");
  46282. Bt(t2[e3]) || (r2.crossOrigin = "Anonymous"), n2.src = t2[e3], r2.appendChild(n2);
  46283. }
  46284. return { cancel: () => {
  46285. } };
  46286. }, t.globeECEFOrigin = function(t2, e2) {
  46287. const r2 = [0, 0, 0];
  46288. return ll(r2, r2, Vp(Tp(e2.canonical))), ll(r2, r2, t2), r2;
  46289. }, t.globePixelsToTileUnits = function(t2, e2) {
  46290. return Ya / (512 * Math.pow(2, t2)) * Pp(Tp(e2));
  46291. }, t.globePoleMatrixForTile = function(t2, e2, r2) {
  46292. const n2 = jo(new Float64Array(16)), i3 = 1 << t2, s2 = 360 * (e2 / i3 - 0.5), a2 = r2.point, o2 = r2.worldSize / (r2.tileSize * i3);
  46293. return qo(n2, n2, [a2.x, a2.y, -r2.worldSize / Math.PI / 2]), No(n2, n2, [o2, o2, o2]), Go(n2, n2, u(-r2._center.lat)), Zo(n2, n2, u(-r2._center.lng + s2)), Float32Array.from(n2);
  46294. }, t.globeTileLatLngCorners = Bp, t.globeToMercatorTransition = function(t2) {
  46295. return m(5, 6, t2);
  46296. }, t.identity = jo, t.identity$1 = ml, t.invert = function(t2, e2) {
  46297. var r2 = e2[0], n2 = e2[1], i3 = e2[2], s2 = e2[3], a2 = e2[4], o2 = e2[5], l2 = e2[6], u2 = e2[7], c2 = e2[8], h2 = e2[9], p2 = e2[10], f2 = e2[11], d2 = e2[12], y2 = e2[13], m2 = e2[14], g2 = e2[15], x2 = r2 * o2 - n2 * a2, v2 = r2 * l2 - i3 * a2, b2 = r2 * u2 - s2 * a2, _2 = n2 * l2 - i3 * o2, w2 = n2 * u2 - s2 * o2, A2 = i3 * u2 - s2 * l2, k2 = c2 * y2 - h2 * d2, S2 = c2 * m2 - p2 * d2, I2 = c2 * g2 - f2 * d2, M2 = h2 * m2 - p2 * y2, T2 = h2 * g2 - f2 * y2, z2 = p2 * g2 - f2 * m2, B2 = x2 * z2 - v2 * T2 + b2 * M2 + _2 * I2 - w2 * S2 + A2 * k2;
  46298. return B2 ? (t2[0] = (o2 * z2 - l2 * T2 + u2 * M2) * (B2 = 1 / B2), t2[1] = (i3 * T2 - n2 * z2 - s2 * M2) * B2, t2[2] = (y2 * A2 - m2 * w2 + g2 * _2) * B2, t2[3] = (p2 * w2 - h2 * A2 - f2 * _2) * B2, t2[4] = (l2 * I2 - a2 * z2 - u2 * S2) * B2, t2[5] = (r2 * z2 - i3 * I2 + s2 * S2) * B2, t2[6] = (m2 * b2 - d2 * A2 - g2 * v2) * B2, t2[7] = (c2 * A2 - p2 * b2 + f2 * v2) * B2, t2[8] = (a2 * T2 - o2 * I2 + u2 * k2) * B2, t2[9] = (n2 * I2 - r2 * T2 - s2 * k2) * B2, t2[10] = (d2 * w2 - y2 * b2 + g2 * x2) * B2, t2[11] = (h2 * b2 - c2 * w2 - f2 * x2) * B2, t2[12] = (o2 * S2 - a2 * M2 - l2 * k2) * B2, t2[13] = (r2 * M2 - n2 * S2 + i3 * k2) * B2, t2[14] = (y2 * v2 - d2 * _2 - m2 * x2) * B2, t2[15] = (c2 * _2 - h2 * v2 + p2 * x2) * B2, t2) : null;
  46299. }, t.isMapAuthenticated = function(t2) {
  46300. return dt.has(t2);
  46301. }, t.isMapboxURL = et, t.isSafariWithAntialiasingBug = function(t2) {
  46302. const e2 = t2.navigator ? t2.navigator.userAgent : null;
  46303. return !!O(t2) && e2 && (e2.match("Version/15.4") || e2.match("Version/15.5") || e2.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/));
  46304. }, t.latFromMercatorY = so, t.len = fl, t.length = Ho, t.length$1 = function(t2) {
  46305. return Math.hypot(t2[0], t2[1], t2[2], t2[3]);
  46306. }, t.loadVectorTile = Lf, t.makeRequest = It, t.mercatorXfromLng = eo, t.mercatorYfromLat = ro, t.mercatorZfromAltitude = no, t.mul = Xo, t.mul$1 = pl, t.multiply = function(t2, e2, r2) {
  46307. var n2 = e2[0], i3 = e2[1], s2 = e2[2], a2 = e2[3], o2 = e2[4], l2 = e2[5], u2 = e2[6], c2 = e2[7], h2 = e2[8], p2 = r2[0], f2 = r2[1], d2 = r2[2], y2 = r2[3], m2 = r2[4], g2 = r2[5], x2 = r2[6], v2 = r2[7], b2 = r2[8];
  46308. return t2[0] = p2 * n2 + f2 * a2 + d2 * u2, t2[1] = p2 * i3 + f2 * o2 + d2 * c2, t2[2] = p2 * s2 + f2 * l2 + d2 * h2, t2[3] = y2 * n2 + m2 * a2 + g2 * u2, t2[4] = y2 * i3 + m2 * o2 + g2 * c2, t2[5] = y2 * s2 + m2 * l2 + g2 * h2, t2[6] = x2 * n2 + v2 * a2 + b2 * u2, t2[7] = x2 * i3 + v2 * o2 + b2 * c2, t2[8] = x2 * s2 + v2 * l2 + b2 * h2, t2;
  46309. }, t.multiply$1 = Oo, t.multiply$2 = tl, t.nextPowerOfTwo = k, t.normalize = sl, t.normalize$1 = function(t2, e2) {
  46310. var r2 = e2[0], n2 = e2[1], i3 = e2[2], s2 = e2[3], a2 = r2 * r2 + n2 * n2 + i3 * i3 + s2 * s2;
  46311. return a2 > 0 && (a2 = 1 / Math.sqrt(a2)), t2[0] = r2 * a2, t2[1] = n2 * a2, t2[2] = i3 * a2, t2[3] = s2 * a2, t2;
  46312. }, t.number = rr, t.ortho = function(t2, e2, r2, n2, i3, s2, a2) {
  46313. var o2 = 1 / (e2 - r2), l2 = 1 / (n2 - i3), u2 = 1 / (s2 - a2);
  46314. return t2[0] = -2 * o2, t2[1] = 0, t2[2] = 0, t2[3] = 0, t2[4] = 0, t2[5] = -2 * l2, t2[6] = 0, t2[7] = 0, t2[8] = 0, t2[9] = 0, t2[10] = 2 * u2, t2[11] = 0, t2[12] = (e2 + r2) * o2, t2[13] = (i3 + n2) * l2, t2[14] = (a2 + s2) * u2, t2[15] = 1, t2;
  46315. }, t.pbf = wc, t.perspective = function(t2, e2, r2, n2, i3) {
  46316. var s2, a2 = 1 / Math.tan(e2 / 2);
  46317. return t2[0] = a2 / r2, t2[1] = 0, t2[2] = 0, t2[3] = 0, t2[4] = 0, t2[5] = a2, t2[6] = 0, t2[7] = 0, t2[8] = 0, t2[9] = 0, t2[11] = -1, t2[12] = 0, t2[13] = 0, t2[15] = 0, null != i3 && i3 !== 1 / 0 ? (t2[10] = (i3 + n2) * (s2 = 1 / (n2 - i3)), t2[14] = 2 * i3 * n2 * s2) : (t2[10] = -1, t2[14] = -2 * n2), t2;
  46318. }, t.pick = function(t2, e2) {
  46319. const r2 = {};
  46320. for (let n2 = 0; n2 < e2.length; n2++) {
  46321. const i3 = e2[n2];
  46322. i3 in t2 && (r2[i3] = t2[i3]);
  46323. }
  46324. return r2;
  46325. }, t.plugin = is, t.pointGeometry = i2, t.polygonIntersectsBox = Bo, t.polygonIntersectsPolygon = bo, t.polygonizeBounds = function(t2, e2, r2 = 0, n2 = true) {
  46326. const s2 = new i2(r2, r2), a2 = t2.sub(s2), o2 = e2.add(s2), l2 = [a2, new i2(o2.x, a2.y), o2, new i2(a2.x, o2.y)];
  46327. return n2 && l2.push(a2), l2;
  46328. }, t.posAttributes = _p, t.postMapLoadEvent = ht, t.postTurnstileEvent = ut, t.potpack = Gc, t.prevPowerOfTwo = function(t2) {
  46329. return t2 <= 1 ? 1 : Math.pow(2, Math.floor(Math.log(t2) / Math.LN2));
  46330. }, t.radToDeg = c, t.refProperties = ["type", "source", "source-layer", "minzoom", "maxzoom", "filter", "layout"], t.registerForPluginStateChange = function(t2) {
  46331. return t2({ pluginStatus: Wi, pluginURL: Ji }), es.on("pluginStateChange", t2), t2;
  46332. }, t.removeAuthState = function(t2) {
  46333. dt.delete(t2);
  46334. }, t.renderColorRamp = Cl, t.rotateX = Go, t.rotateX$1 = gl, t.rotateY = Zo, t.rotateZ = function(t2, e2, r2) {
  46335. var n2 = Math.sin(r2), i3 = Math.cos(r2), s2 = e2[0], a2 = e2[1], o2 = e2[2], l2 = e2[3], u2 = e2[4], c2 = e2[5], h2 = e2[6], p2 = e2[7];
  46336. return e2 !== t2 && (t2[8] = e2[8], t2[9] = e2[9], t2[10] = e2[10], t2[11] = e2[11], t2[12] = e2[12], t2[13] = e2[13], t2[14] = e2[14], t2[15] = e2[15]), t2[0] = s2 * i3 + u2 * n2, t2[1] = a2 * i3 + c2 * n2, t2[2] = o2 * i3 + h2 * n2, t2[3] = l2 * i3 + p2 * n2, t2[4] = u2 * i3 - s2 * n2, t2[5] = c2 * i3 - a2 * n2, t2[6] = h2 * i3 - o2 * n2, t2[7] = p2 * i3 - l2 * n2, t2;
  46337. }, t.rotateZ$1 = function(t2, e2, r2) {
  46338. r2 *= 0.5;
  46339. var n2 = e2[0], i3 = e2[1], s2 = e2[2], a2 = e2[3], o2 = Math.sin(r2), l2 = Math.cos(r2);
  46340. return t2[0] = n2 * l2 + i3 * o2, t2[1] = i3 * l2 - n2 * o2, t2[2] = s2 * l2 + a2 * o2, t2[3] = a2 * l2 - s2 * o2, t2;
  46341. }, t.scale = No, t.scale$1 = function(t2, e2, r2) {
  46342. return t2[0] = e2[0] * r2, t2[1] = e2[1] * r2, t2[2] = e2[2] * r2, t2[3] = e2[3] * r2, t2;
  46343. }, t.scale$2 = nl, t.scaleAndAdd = il, t.setCacheLimits = function(t2, e2) {
  46344. xt = t2, vt = e2;
  46345. }, t.setColumn = function(t2, e2, r2) {
  46346. t2[4 * e2 + 0] = r2[0], t2[4 * e2 + 1] = r2[1], t2[4 * e2 + 2] = r2[2], t2[4 * e2 + 3] = r2[3];
  46347. }, t.setRTLTextPlugin = function(t2, e2, r2 = false) {
  46348. if (Wi === Xi || Wi === Ki || Wi === Yi)
  46349. throw new Error("setRTLTextPlugin cannot be called multiple times.");
  46350. Ji = N.resolveURL(t2), Wi = Xi, Hi = e2, ts(), r2 || ns();
  46351. }, t.smoothstep = m, t.spec = $t, t.storeAuthState = function(t2, e2) {
  46352. e2 ? dt.add(t2) : dt.delete(t2);
  46353. }, t.sub = hl, t.subtract = Qo, t.symbolSize = yc, t.tileAABB = function(t2, e2, r2, n2, i3, s2, a2, o2, l2) {
  46354. if ("globe" === l2.name)
  46355. return zp(t2, e2, new Op(r2, n2, i3));
  46356. const u2 = Zp({ z: r2, x: n2, y: i3 }, l2);
  46357. return new vl([(s2 + u2.x / u2.scale) * e2, e2 * (u2.y / u2.scale), a2], [(s2 + u2.x2 / u2.scale) * e2, e2 * (u2.y2 / u2.scale), o2]);
  46358. }, t.tileTransform = Zp, t.transformMat3 = function(t2, e2, r2) {
  46359. var n2 = e2[0], i3 = e2[1], s2 = e2[2];
  46360. return t2[0] = n2 * r2[0] + i3 * r2[3] + s2 * r2[6], t2[1] = n2 * r2[1] + i3 * r2[4] + s2 * r2[7], t2[2] = n2 * r2[2] + i3 * r2[5] + s2 * r2[8], t2;
  46361. }, t.transformMat4 = ll, t.transformMat4$1 = dl, t.transformQuat = ul, t.translate = qo, t.transpose = function(t2, e2) {
  46362. if (t2 === e2) {
  46363. var r2 = e2[1], n2 = e2[2], i3 = e2[5];
  46364. t2[1] = e2[3], t2[2] = e2[6], t2[3] = r2, t2[5] = e2[7], t2[6] = n2, t2[7] = i3;
  46365. } else
  46366. t2[0] = e2[0], t2[1] = e2[3], t2[2] = e2[6], t2[3] = e2[1], t2[4] = e2[4], t2[5] = e2[7], t2[6] = e2[2], t2[7] = e2[5], t2[8] = e2[8];
  46367. return t2;
  46368. }, t.triggerPluginCompletionEvent = Qi, t.uniqueId = w, t.validateCustomStyleLayer = function(t2) {
  46369. const e2 = [], r2 = t2.id;
  46370. return void 0 === r2 && e2.push({ message: `layers.${r2}: missing required property "id"` }), void 0 === t2.render && e2.push({ message: `layers.${r2}: missing required method "render"` }), t2.renderingMode && "2d" !== t2.renderingMode && "3d" !== t2.renderingMode && e2.push({ message: `layers.${r2}: property "renderingMode" must be either "2d" or "3d"` }), e2;
  46371. }, t.validateFilter = (t2) => ei(Ln(t2)), t.validateFog = (t2) => ei(Kn(t2)), t.validateLayer = (t2) => ei(On(t2)), t.validateLight = (t2) => ei(Zn(t2)), t.validateSource = (t2) => ei(Gn(t2)), t.validateStyle = Jn, t.validateTerrain = (t2) => ei(Xn(t2)), t.values = v, t.vectorTile = Du, t.version = e, t.warnOnce = C, t.window = a, t.wrap = g;
  46372. });
  46373. define(["./shared"], function(e) {
  46374. function t(e2) {
  46375. if ("number" == typeof e2 || "boolean" == typeof e2 || "string" == typeof e2 || null == e2)
  46376. return JSON.stringify(e2);
  46377. if (Array.isArray(e2)) {
  46378. let r3 = "[";
  46379. for (const o2 of e2)
  46380. r3 += `${t(o2)},`;
  46381. return `${r3}]`;
  46382. }
  46383. let r2 = "{";
  46384. for (const o2 of Object.keys(e2).sort())
  46385. r2 += `${o2}:${t(e2[o2])},`;
  46386. return `${r2}}`;
  46387. }
  46388. function r(r2) {
  46389. let o2 = "";
  46390. for (const n2 of e.refProperties)
  46391. o2 += `/${t(r2[n2])}`;
  46392. return o2;
  46393. }
  46394. class o {
  46395. constructor(e2) {
  46396. this.keyCache = {}, e2 && this.replace(e2);
  46397. }
  46398. replace(e2) {
  46399. this._layerConfigs = {}, this._layers = {}, this.update(e2, []);
  46400. }
  46401. update(t2, o2) {
  46402. for (const r2 of t2)
  46403. this._layerConfigs[r2.id] = r2, (this._layers[r2.id] = e.createStyleLayer(r2)).compileFilter(), this.keyCache[r2.id] && delete this.keyCache[r2.id];
  46404. for (const e2 of o2)
  46405. delete this.keyCache[e2], delete this._layerConfigs[e2], delete this._layers[e2];
  46406. this.familiesBySource = {};
  46407. const n2 = function(e2, t3) {
  46408. const o3 = {};
  46409. for (let n4 = 0; n4 < e2.length; n4++) {
  46410. const i3 = t3 && t3[e2[n4].id] || r(e2[n4]);
  46411. t3 && (t3[e2[n4].id] = i3);
  46412. let s2 = o3[i3];
  46413. s2 || (s2 = o3[i3] = []), s2.push(e2[n4]);
  46414. }
  46415. const n3 = [];
  46416. for (const e3 in o3)
  46417. n3.push(o3[e3]);
  46418. return n3;
  46419. }(e.values(this._layerConfigs), this.keyCache);
  46420. for (const e2 of n2) {
  46421. const t3 = e2.map((e3) => this._layers[e3.id]), r2 = t3[0];
  46422. if ("none" === r2.visibility)
  46423. continue;
  46424. const o3 = r2.source || "";
  46425. let n3 = this.familiesBySource[o3];
  46426. n3 || (n3 = this.familiesBySource[o3] = {});
  46427. const i3 = r2.sourceLayer || "_geojsonTileLayer";
  46428. let s2 = n3[i3];
  46429. s2 || (s2 = n3[i3] = []), s2.push(t3);
  46430. }
  46431. }
  46432. }
  46433. class n {
  46434. loadTile(t2, r2) {
  46435. const { uid: o2, encoding: n2, rawImageData: i3, padding: s2, buildQuadTree: a2 } = t2, l2 = e.window.ImageBitmap && i3 instanceof e.window.ImageBitmap ? this.getImageData(i3, s2) : i3;
  46436. r2(null, new e.DEMData(o2, l2, n2, s2 < 1, a2));
  46437. }
  46438. getImageData(e2, t2) {
  46439. this.offscreenCanvas && this.offscreenCanvasContext || (this.offscreenCanvas = new OffscreenCanvas(e2.width, e2.height), this.offscreenCanvasContext = this.offscreenCanvas.getContext("2d")), this.offscreenCanvas.width = e2.width, this.offscreenCanvas.height = e2.height, this.offscreenCanvasContext.drawImage(e2, 0, 0, e2.width, e2.height);
  46440. const r2 = this.offscreenCanvasContext.getImageData(-t2, -t2, e2.width + 2 * t2, e2.height + 2 * t2);
  46441. return this.offscreenCanvasContext.clearRect(0, 0, this.offscreenCanvas.width, this.offscreenCanvas.height), r2;
  46442. }
  46443. }
  46444. var i2 = function e2(t2, r2) {
  46445. var o2, n2 = t2 && t2.type;
  46446. if ("FeatureCollection" === n2)
  46447. for (o2 = 0; o2 < t2.features.length; o2++)
  46448. e2(t2.features[o2], r2);
  46449. else if ("GeometryCollection" === n2)
  46450. for (o2 = 0; o2 < t2.geometries.length; o2++)
  46451. e2(t2.geometries[o2], r2);
  46452. else if ("Feature" === n2)
  46453. e2(t2.geometry, r2);
  46454. else if ("Polygon" === n2)
  46455. s(t2.coordinates, r2);
  46456. else if ("MultiPolygon" === n2)
  46457. for (o2 = 0; o2 < t2.coordinates.length; o2++)
  46458. s(t2.coordinates[o2], r2);
  46459. return t2;
  46460. };
  46461. function s(e2, t2) {
  46462. if (0 !== e2.length) {
  46463. a(e2[0], t2);
  46464. for (var r2 = 1; r2 < e2.length; r2++)
  46465. a(e2[r2], !t2);
  46466. }
  46467. }
  46468. function a(e2, t2) {
  46469. for (var r2 = 0, o2 = 0, n2 = 0, i3 = e2.length, s2 = i3 - 1; n2 < i3; s2 = n2++) {
  46470. var a2 = (e2[n2][0] - e2[s2][0]) * (e2[s2][1] + e2[n2][1]), l2 = r2 + a2;
  46471. o2 += Math.abs(r2) >= Math.abs(a2) ? r2 - l2 + a2 : a2 - l2 + r2, r2 = l2;
  46472. }
  46473. r2 + o2 >= 0 != !!t2 && e2.reverse();
  46474. }
  46475. const l = e.vectorTile.VectorTileFeature.prototype.toGeoJSON;
  46476. class u {
  46477. constructor(t2) {
  46478. this._feature = t2, this.extent = e.EXTENT, this.type = t2.type, this.properties = t2.tags, "id" in t2 && !isNaN(t2.id) && (this.id = parseInt(t2.id, 10));
  46479. }
  46480. loadGeometry() {
  46481. if (1 === this._feature.type) {
  46482. const t2 = [];
  46483. for (const r2 of this._feature.geometry)
  46484. t2.push([new e.pointGeometry(r2[0], r2[1])]);
  46485. return t2;
  46486. }
  46487. {
  46488. const t2 = [];
  46489. for (const r2 of this._feature.geometry) {
  46490. const o2 = [];
  46491. for (const t3 of r2)
  46492. o2.push(new e.pointGeometry(t3[0], t3[1]));
  46493. t2.push(o2);
  46494. }
  46495. return t2;
  46496. }
  46497. }
  46498. toGeoJSON(e2, t2, r2) {
  46499. return l.call(this, e2, t2, r2);
  46500. }
  46501. }
  46502. class h {
  46503. constructor(t2) {
  46504. this.layers = { _geojsonTileLayer: this }, this.name = "_geojsonTileLayer", this.extent = e.EXTENT, this.length = t2.length, this._features = t2;
  46505. }
  46506. feature(e2) {
  46507. return new u(this._features[e2]);
  46508. }
  46509. }
  46510. var c = e.vectorTile.VectorTileFeature, f = p;
  46511. function p(e2, t2) {
  46512. this.options = t2 || {}, this.features = e2, this.length = e2.length;
  46513. }
  46514. function g(e2, t2) {
  46515. this.id = "number" == typeof e2.id ? e2.id : void 0, this.type = e2.type, this.rawGeometry = 1 === e2.type ? [e2.geometry] : e2.geometry, this.properties = e2.tags, this.extent = t2 || 4096;
  46516. }
  46517. p.prototype.feature = function(e2) {
  46518. return new g(this.features[e2], this.options.extent);
  46519. }, g.prototype.loadGeometry = function() {
  46520. var t2 = this.rawGeometry;
  46521. this.geometry = [];
  46522. for (var r2 = 0; r2 < t2.length; r2++) {
  46523. for (var o2 = t2[r2], n2 = [], i3 = 0; i3 < o2.length; i3++)
  46524. n2.push(new e.pointGeometry(o2[i3][0], o2[i3][1]));
  46525. this.geometry.push(n2);
  46526. }
  46527. return this.geometry;
  46528. }, g.prototype.bbox = function() {
  46529. this.geometry || this.loadGeometry();
  46530. for (var e2 = this.geometry, t2 = 1 / 0, r2 = -1 / 0, o2 = 1 / 0, n2 = -1 / 0, i3 = 0; i3 < e2.length; i3++)
  46531. for (var s2 = e2[i3], a2 = 0; a2 < s2.length; a2++) {
  46532. var l2 = s2[a2];
  46533. t2 = Math.min(t2, l2.x), r2 = Math.max(r2, l2.x), o2 = Math.min(o2, l2.y), n2 = Math.max(n2, l2.y);
  46534. }
  46535. return [t2, o2, r2, n2];
  46536. }, g.prototype.toGeoJSON = c.prototype.toGeoJSON;
  46537. var d = y, m = f;
  46538. function y(t2) {
  46539. var r2 = new e.pbf();
  46540. return function(e2, t3) {
  46541. for (var r3 in e2.layers)
  46542. t3.writeMessage(3, v, e2.layers[r3]);
  46543. }(t2, r2), r2.finish();
  46544. }
  46545. function v(e2, t2) {
  46546. var r2;
  46547. t2.writeVarintField(15, e2.version || 1), t2.writeStringField(1, e2.name || ""), t2.writeVarintField(5, e2.extent || 4096);
  46548. var o2 = { keys: [], values: [], keycache: {}, valuecache: {} };
  46549. for (r2 = 0; r2 < e2.length; r2++)
  46550. o2.feature = e2.feature(r2), t2.writeMessage(2, x, o2);
  46551. var n2 = o2.keys;
  46552. for (r2 = 0; r2 < n2.length; r2++)
  46553. t2.writeStringField(3, n2[r2]);
  46554. var i3 = o2.values;
  46555. for (r2 = 0; r2 < i3.length; r2++)
  46556. t2.writeMessage(4, b, i3[r2]);
  46557. }
  46558. function x(e2, t2) {
  46559. var r2 = e2.feature;
  46560. void 0 !== r2.id && t2.writeVarintField(1, r2.id), t2.writeMessage(2, w, e2), t2.writeVarintField(3, r2.type), t2.writeMessage(4, P, r2);
  46561. }
  46562. function w(e2, t2) {
  46563. var r2 = e2.feature, o2 = e2.keys, n2 = e2.values, i3 = e2.keycache, s2 = e2.valuecache;
  46564. for (var a2 in r2.properties) {
  46565. var l2 = r2.properties[a2], u2 = i3[a2];
  46566. if (null !== l2) {
  46567. void 0 === u2 && (o2.push(a2), i3[a2] = u2 = o2.length - 1), t2.writeVarint(u2);
  46568. var h2 = typeof l2;
  46569. "string" !== h2 && "boolean" !== h2 && "number" !== h2 && (l2 = JSON.stringify(l2));
  46570. var c2 = h2 + ":" + l2, f2 = s2[c2];
  46571. void 0 === f2 && (n2.push(l2), s2[c2] = f2 = n2.length - 1), t2.writeVarint(f2);
  46572. }
  46573. }
  46574. }
  46575. function S(e2, t2) {
  46576. return (t2 << 3) + (7 & e2);
  46577. }
  46578. function M(e2) {
  46579. return e2 << 1 ^ e2 >> 31;
  46580. }
  46581. function P(e2, t2) {
  46582. for (var r2 = e2.loadGeometry(), o2 = e2.type, n2 = 0, i3 = 0, s2 = r2.length, a2 = 0; a2 < s2; a2++) {
  46583. var l2 = r2[a2], u2 = 1;
  46584. 1 === o2 && (u2 = l2.length), t2.writeVarint(S(1, u2));
  46585. for (var h2 = 3 === o2 ? l2.length - 1 : l2.length, c2 = 0; c2 < h2; c2++) {
  46586. 1 === c2 && 1 !== o2 && t2.writeVarint(S(2, h2 - 1));
  46587. var f2 = l2[c2].x - n2, p2 = l2[c2].y - i3;
  46588. t2.writeVarint(M(f2)), t2.writeVarint(M(p2)), n2 += f2, i3 += p2;
  46589. }
  46590. 3 === o2 && t2.writeVarint(S(7, 1));
  46591. }
  46592. }
  46593. function b(e2, t2) {
  46594. var r2 = typeof e2;
  46595. "string" === r2 ? t2.writeStringField(1, e2) : "boolean" === r2 ? t2.writeBooleanField(7, e2) : "number" === r2 && (e2 % 1 != 0 ? t2.writeDoubleField(3, e2) : e2 < 0 ? t2.writeSVarintField(6, e2) : t2.writeVarintField(5, e2));
  46596. }
  46597. function T(e2, t2, r2, o2, n2, i3) {
  46598. if (n2 - o2 <= r2)
  46599. return;
  46600. const s2 = o2 + n2 >> 1;
  46601. k(e2, t2, s2, o2, n2, i3 % 2), T(e2, t2, r2, o2, s2 - 1, i3 + 1), T(e2, t2, r2, s2 + 1, n2, i3 + 1);
  46602. }
  46603. function k(e2, t2, r2, o2, n2, i3) {
  46604. for (; n2 > o2; ) {
  46605. if (n2 - o2 > 600) {
  46606. const s3 = n2 - o2 + 1, a3 = r2 - o2 + 1, l3 = Math.log(s3), u2 = 0.5 * Math.exp(2 * l3 / 3), h2 = 0.5 * Math.sqrt(l3 * u2 * (s3 - u2) / s3) * (a3 - s3 / 2 < 0 ? -1 : 1);
  46607. k(e2, t2, r2, Math.max(o2, Math.floor(r2 - a3 * u2 / s3 + h2)), Math.min(n2, Math.floor(r2 + (s3 - a3) * u2 / s3 + h2)), i3);
  46608. }
  46609. const s2 = t2[2 * r2 + i3];
  46610. let a2 = o2, l2 = n2;
  46611. for (I(e2, t2, o2, r2), t2[2 * n2 + i3] > s2 && I(e2, t2, o2, n2); a2 < l2; ) {
  46612. for (I(e2, t2, a2, l2), a2++, l2--; t2[2 * a2 + i3] < s2; )
  46613. a2++;
  46614. for (; t2[2 * l2 + i3] > s2; )
  46615. l2--;
  46616. }
  46617. t2[2 * o2 + i3] === s2 ? I(e2, t2, o2, l2) : (l2++, I(e2, t2, l2, n2)), l2 <= r2 && (o2 = l2 + 1), r2 <= l2 && (n2 = l2 - 1);
  46618. }
  46619. }
  46620. function I(e2, t2, r2, o2) {
  46621. _(e2, r2, o2), _(t2, 2 * r2, 2 * o2), _(t2, 2 * r2 + 1, 2 * o2 + 1);
  46622. }
  46623. function _(e2, t2, r2) {
  46624. const o2 = e2[t2];
  46625. e2[t2] = e2[r2], e2[r2] = o2;
  46626. }
  46627. function L(e2, t2, r2, o2) {
  46628. const n2 = e2 - r2, i3 = t2 - o2;
  46629. return n2 * n2 + i3 * i3;
  46630. }
  46631. d.fromVectorTileJs = y, d.fromGeojsonVt = function(e2, t2) {
  46632. t2 = t2 || {};
  46633. var r2 = {};
  46634. for (var o2 in e2)
  46635. r2[o2] = new f(e2[o2].features, t2), r2[o2].name = o2, r2[o2].version = t2.version, r2[o2].extent = t2.extent;
  46636. return y({ layers: r2 });
  46637. }, d.GeoJSONWrapper = m;
  46638. const C = (e2) => e2[0], O = (e2) => e2[1];
  46639. class z {
  46640. constructor(e2, t2 = C, r2 = O, o2 = 64, n2 = Float64Array) {
  46641. this.nodeSize = o2, this.points = e2;
  46642. const i3 = e2.length < 65536 ? Uint16Array : Uint32Array, s2 = this.ids = new i3(e2.length), a2 = this.coords = new n2(2 * e2.length);
  46643. for (let o3 = 0; o3 < e2.length; o3++)
  46644. s2[o3] = o3, a2[2 * o3] = t2(e2[o3]), a2[2 * o3 + 1] = r2(e2[o3]);
  46645. T(s2, a2, o2, 0, s2.length - 1, 0);
  46646. }
  46647. range(e2, t2, r2, o2) {
  46648. return function(e3, t3, r3, o3, n2, i3, s2) {
  46649. const a2 = [0, e3.length - 1, 0], l2 = [];
  46650. let u2, h2;
  46651. for (; a2.length; ) {
  46652. const c2 = a2.pop(), f2 = a2.pop(), p2 = a2.pop();
  46653. if (f2 - p2 <= s2) {
  46654. for (let s3 = p2; s3 <= f2; s3++)
  46655. u2 = t3[2 * s3], h2 = t3[2 * s3 + 1], u2 >= r3 && u2 <= n2 && h2 >= o3 && h2 <= i3 && l2.push(e3[s3]);
  46656. continue;
  46657. }
  46658. const g2 = Math.floor((p2 + f2) / 2);
  46659. u2 = t3[2 * g2], h2 = t3[2 * g2 + 1], u2 >= r3 && u2 <= n2 && h2 >= o3 && h2 <= i3 && l2.push(e3[g2]);
  46660. const d2 = (c2 + 1) % 2;
  46661. (0 === c2 ? r3 <= u2 : o3 <= h2) && (a2.push(p2), a2.push(g2 - 1), a2.push(d2)), (0 === c2 ? n2 >= u2 : i3 >= h2) && (a2.push(g2 + 1), a2.push(f2), a2.push(d2));
  46662. }
  46663. return l2;
  46664. }(this.ids, this.coords, e2, t2, r2, o2, this.nodeSize);
  46665. }
  46666. within(e2, t2, r2) {
  46667. return function(e3, t3, r3, o2, n2, i3) {
  46668. const s2 = [0, e3.length - 1, 0], a2 = [], l2 = n2 * n2;
  46669. for (; s2.length; ) {
  46670. const u2 = s2.pop(), h2 = s2.pop(), c2 = s2.pop();
  46671. if (h2 - c2 <= i3) {
  46672. for (let n3 = c2; n3 <= h2; n3++)
  46673. L(t3[2 * n3], t3[2 * n3 + 1], r3, o2) <= l2 && a2.push(e3[n3]);
  46674. continue;
  46675. }
  46676. const f2 = Math.floor((c2 + h2) / 2), p2 = t3[2 * f2], g2 = t3[2 * f2 + 1];
  46677. L(p2, g2, r3, o2) <= l2 && a2.push(e3[f2]);
  46678. const d2 = (u2 + 1) % 2;
  46679. (0 === u2 ? r3 - n2 <= p2 : o2 - n2 <= g2) && (s2.push(c2), s2.push(f2 - 1), s2.push(d2)), (0 === u2 ? r3 + n2 >= p2 : o2 + n2 >= g2) && (s2.push(f2 + 1), s2.push(h2), s2.push(d2));
  46680. }
  46681. return a2;
  46682. }(this.ids, this.coords, e2, t2, r2, this.nodeSize);
  46683. }
  46684. }
  46685. const E = { minZoom: 0, maxZoom: 16, minPoints: 2, radius: 40, extent: 512, nodeSize: 64, log: false, generateId: false, reduce: null, map: (e2) => e2 }, F = Math.fround || (N = new Float32Array(1), (e2) => (N[0] = +e2, N[0]));
  46686. var N;
  46687. class j {
  46688. constructor(e2) {
  46689. this.options = A(Object.create(E), e2), this.trees = new Array(this.options.maxZoom + 1);
  46690. }
  46691. load(e2) {
  46692. const { log: t2, minZoom: r2, maxZoom: o2, nodeSize: n2 } = this.options;
  46693. t2 && console.time("total time");
  46694. const i3 = `prepare ${e2.length} points`;
  46695. t2 && console.time(i3), this.points = e2;
  46696. let s2 = [];
  46697. for (let t3 = 0; t3 < e2.length; t3++)
  46698. e2[t3].geometry && s2.push(G(e2[t3], t3));
  46699. this.trees[o2 + 1] = new z(s2, D, $, n2, Float32Array), t2 && console.timeEnd(i3);
  46700. for (let e3 = o2; e3 >= r2; e3--) {
  46701. const r3 = +Date.now();
  46702. s2 = this._cluster(s2, e3), this.trees[e3] = new z(s2, D, $, n2, Float32Array), t2 && console.log("z%d: %d clusters in %dms", e3, s2.length, +Date.now() - r3);
  46703. }
  46704. return t2 && console.timeEnd("total time"), this;
  46705. }
  46706. getClusters(e2, t2) {
  46707. let r2 = ((e2[0] + 180) % 360 + 360) % 360 - 180;
  46708. const o2 = Math.max(-90, Math.min(90, e2[1]));
  46709. let n2 = 180 === e2[2] ? 180 : ((e2[2] + 180) % 360 + 360) % 360 - 180;
  46710. const i3 = Math.max(-90, Math.min(90, e2[3]));
  46711. if (e2[2] - e2[0] >= 360)
  46712. r2 = -180, n2 = 180;
  46713. else if (r2 > n2) {
  46714. const e3 = this.getClusters([r2, o2, 180, i3], t2), s3 = this.getClusters([-180, o2, n2, i3], t2);
  46715. return e3.concat(s3);
  46716. }
  46717. const s2 = this.trees[this._limitZoom(t2)], a2 = s2.range(Y(r2), X(i3), Y(n2), X(o2)), l2 = [];
  46718. for (const e3 of a2) {
  46719. const t3 = s2.points[e3];
  46720. l2.push(t3.numPoints ? J(t3) : this.points[t3.index]);
  46721. }
  46722. return l2;
  46723. }
  46724. getChildren(e2) {
  46725. const t2 = this._getOriginId(e2), r2 = this._getOriginZoom(e2), o2 = "No cluster with the specified id.", n2 = this.trees[r2];
  46726. if (!n2)
  46727. throw new Error(o2);
  46728. const i3 = n2.points[t2];
  46729. if (!i3)
  46730. throw new Error(o2);
  46731. const s2 = this.options.radius / (this.options.extent * Math.pow(2, r2 - 1)), a2 = n2.within(i3.x, i3.y, s2), l2 = [];
  46732. for (const t3 of a2) {
  46733. const r3 = n2.points[t3];
  46734. r3.parentId === e2 && l2.push(r3.numPoints ? J(r3) : this.points[r3.index]);
  46735. }
  46736. if (0 === l2.length)
  46737. throw new Error(o2);
  46738. return l2;
  46739. }
  46740. getLeaves(e2, t2, r2) {
  46741. const o2 = [];
  46742. return this._appendLeaves(o2, e2, t2 = t2 || 10, r2 = r2 || 0, 0), o2;
  46743. }
  46744. getTile(e2, t2, r2) {
  46745. const o2 = this.trees[this._limitZoom(e2)], n2 = Math.pow(2, e2), { extent: i3, radius: s2 } = this.options, a2 = s2 / i3, l2 = (r2 - a2) / n2, u2 = (r2 + 1 + a2) / n2, h2 = { features: [] };
  46746. return this._addTileFeatures(o2.range((t2 - a2) / n2, l2, (t2 + 1 + a2) / n2, u2), o2.points, t2, r2, n2, h2), 0 === t2 && this._addTileFeatures(o2.range(1 - a2 / n2, l2, 1, u2), o2.points, n2, r2, n2, h2), t2 === n2 - 1 && this._addTileFeatures(o2.range(0, l2, a2 / n2, u2), o2.points, -1, r2, n2, h2), h2.features.length ? h2 : null;
  46747. }
  46748. getClusterExpansionZoom(e2) {
  46749. let t2 = this._getOriginZoom(e2) - 1;
  46750. for (; t2 <= this.options.maxZoom; ) {
  46751. const r2 = this.getChildren(e2);
  46752. if (t2++, 1 !== r2.length)
  46753. break;
  46754. e2 = r2[0].properties.cluster_id;
  46755. }
  46756. return t2;
  46757. }
  46758. _appendLeaves(e2, t2, r2, o2, n2) {
  46759. const i3 = this.getChildren(t2);
  46760. for (const t3 of i3) {
  46761. const i4 = t3.properties;
  46762. if (i4 && i4.cluster ? n2 + i4.point_count <= o2 ? n2 += i4.point_count : n2 = this._appendLeaves(e2, i4.cluster_id, r2, o2, n2) : n2 < o2 ? n2++ : e2.push(t3), e2.length === r2)
  46763. break;
  46764. }
  46765. return n2;
  46766. }
  46767. _addTileFeatures(e2, t2, r2, o2, n2, i3) {
  46768. for (const s2 of e2) {
  46769. const e3 = t2[s2], a2 = e3.numPoints;
  46770. let l2, u2, h2;
  46771. if (a2)
  46772. l2 = W(e3), u2 = e3.x, h2 = e3.y;
  46773. else {
  46774. const t3 = this.points[e3.index];
  46775. l2 = t3.properties, u2 = Y(t3.geometry.coordinates[0]), h2 = X(t3.geometry.coordinates[1]);
  46776. }
  46777. const c2 = { type: 1, geometry: [[Math.round(this.options.extent * (u2 * n2 - r2)), Math.round(this.options.extent * (h2 * n2 - o2))]], tags: l2 };
  46778. let f2;
  46779. a2 ? f2 = e3.id : this.options.generateId ? f2 = e3.index : this.points[e3.index].id && (f2 = this.points[e3.index].id), void 0 !== f2 && (c2.id = f2), i3.features.push(c2);
  46780. }
  46781. }
  46782. _limitZoom(e2) {
  46783. return Math.max(this.options.minZoom, Math.min(+e2, this.options.maxZoom + 1));
  46784. }
  46785. _cluster(e2, t2) {
  46786. const r2 = [], { radius: o2, extent: n2, reduce: i3, minPoints: s2 } = this.options, a2 = o2 / (n2 * Math.pow(2, t2));
  46787. for (let o3 = 0; o3 < e2.length; o3++) {
  46788. const n3 = e2[o3];
  46789. if (n3.zoom <= t2)
  46790. continue;
  46791. n3.zoom = t2;
  46792. const l2 = this.trees[t2 + 1], u2 = l2.within(n3.x, n3.y, a2), h2 = n3.numPoints || 1;
  46793. let c2 = h2;
  46794. for (const e3 of u2) {
  46795. const r3 = l2.points[e3];
  46796. r3.zoom > t2 && (c2 += r3.numPoints || 1);
  46797. }
  46798. if (c2 > h2 && c2 >= s2) {
  46799. let e3 = n3.x * h2, s3 = n3.y * h2, a3 = i3 && h2 > 1 ? this._map(n3, true) : null;
  46800. const f2 = (o3 << 5) + (t2 + 1) + this.points.length;
  46801. for (const r3 of u2) {
  46802. const o4 = l2.points[r3];
  46803. if (o4.zoom <= t2)
  46804. continue;
  46805. o4.zoom = t2;
  46806. const u3 = o4.numPoints || 1;
  46807. e3 += o4.x * u3, s3 += o4.y * u3, o4.parentId = f2, i3 && (a3 || (a3 = this._map(n3, true)), i3(a3, this._map(o4)));
  46808. }
  46809. n3.parentId = f2, r2.push(Z(e3 / c2, s3 / c2, f2, c2, a3));
  46810. } else if (r2.push(n3), c2 > 1)
  46811. for (const e3 of u2) {
  46812. const o4 = l2.points[e3];
  46813. o4.zoom <= t2 || (o4.zoom = t2, r2.push(o4));
  46814. }
  46815. }
  46816. return r2;
  46817. }
  46818. _getOriginId(e2) {
  46819. return e2 - this.points.length >> 5;
  46820. }
  46821. _getOriginZoom(e2) {
  46822. return (e2 - this.points.length) % 32;
  46823. }
  46824. _map(e2, t2) {
  46825. if (e2.numPoints)
  46826. return t2 ? A({}, e2.properties) : e2.properties;
  46827. const r2 = this.points[e2.index].properties, o2 = this.options.map(r2);
  46828. return t2 && o2 === r2 ? A({}, o2) : o2;
  46829. }
  46830. }
  46831. function Z(e2, t2, r2, o2, n2) {
  46832. return { x: F(e2), y: F(t2), zoom: 1 / 0, id: r2, parentId: -1, numPoints: o2, properties: n2 };
  46833. }
  46834. function G(e2, t2) {
  46835. const [r2, o2] = e2.geometry.coordinates;
  46836. return { x: F(Y(r2)), y: F(X(o2)), zoom: 1 / 0, index: t2, parentId: -1 };
  46837. }
  46838. function J(e2) {
  46839. return { type: "Feature", id: e2.id, properties: W(e2), geometry: { type: "Point", coordinates: [(t2 = e2.x, 360 * (t2 - 0.5)), V(e2.y)] } };
  46840. var t2;
  46841. }
  46842. function W(e2) {
  46843. const t2 = e2.numPoints, r2 = t2 >= 1e4 ? `${Math.round(t2 / 1e3)}k` : t2 >= 1e3 ? Math.round(t2 / 100) / 10 + "k" : t2;
  46844. return A(A({}, e2.properties), { cluster: true, cluster_id: e2.id, point_count: t2, point_count_abbreviated: r2 });
  46845. }
  46846. function Y(e2) {
  46847. return e2 / 360 + 0.5;
  46848. }
  46849. function X(e2) {
  46850. const t2 = Math.sin(e2 * Math.PI / 180), r2 = 0.5 - 0.25 * Math.log((1 + t2) / (1 - t2)) / Math.PI;
  46851. return r2 < 0 ? 0 : r2 > 1 ? 1 : r2;
  46852. }
  46853. function V(e2) {
  46854. const t2 = (180 - 360 * e2) * Math.PI / 180;
  46855. return 360 * Math.atan(Math.exp(t2)) / Math.PI - 90;
  46856. }
  46857. function A(e2, t2) {
  46858. for (const r2 in t2)
  46859. e2[r2] = t2[r2];
  46860. return e2;
  46861. }
  46862. function D(e2) {
  46863. return e2.x;
  46864. }
  46865. function $(e2) {
  46866. return e2.y;
  46867. }
  46868. function B(e2, t2, r2, o2) {
  46869. for (var n2, i3 = o2, s2 = r2 - t2 >> 1, a2 = r2 - t2, l2 = e2[t2], u2 = e2[t2 + 1], h2 = e2[r2], c2 = e2[r2 + 1], f2 = t2 + 3; f2 < r2; f2 += 3) {
  46870. var p2 = R(e2[f2], e2[f2 + 1], l2, u2, h2, c2);
  46871. if (p2 > i3)
  46872. n2 = f2, i3 = p2;
  46873. else if (p2 === i3) {
  46874. var g2 = Math.abs(f2 - s2);
  46875. g2 < a2 && (n2 = f2, a2 = g2);
  46876. }
  46877. }
  46878. i3 > o2 && (n2 - t2 > 3 && B(e2, t2, n2, o2), e2[n2 + 2] = i3, r2 - n2 > 3 && B(e2, n2, r2, o2));
  46879. }
  46880. function R(e2, t2, r2, o2, n2, i3) {
  46881. var s2 = n2 - r2, a2 = i3 - o2;
  46882. if (0 !== s2 || 0 !== a2) {
  46883. var l2 = ((e2 - r2) * s2 + (t2 - o2) * a2) / (s2 * s2 + a2 * a2);
  46884. l2 > 1 ? (r2 = n2, o2 = i3) : l2 > 0 && (r2 += s2 * l2, o2 += a2 * l2);
  46885. }
  46886. return (s2 = e2 - r2) * s2 + (a2 = t2 - o2) * a2;
  46887. }
  46888. function q(e2, t2, r2, o2) {
  46889. var n2 = { id: void 0 === e2 ? null : e2, type: t2, geometry: r2, tags: o2, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
  46890. return function(e3) {
  46891. var t3 = e3.geometry, r3 = e3.type;
  46892. if ("Point" === r3 || "MultiPoint" === r3 || "LineString" === r3)
  46893. U(e3, t3);
  46894. else if ("Polygon" === r3 || "MultiLineString" === r3)
  46895. for (var o3 = 0; o3 < t3.length; o3++)
  46896. U(e3, t3[o3]);
  46897. else if ("MultiPolygon" === r3)
  46898. for (o3 = 0; o3 < t3.length; o3++)
  46899. for (var n3 = 0; n3 < t3[o3].length; n3++)
  46900. U(e3, t3[o3][n3]);
  46901. }(n2), n2;
  46902. }
  46903. function U(e2, t2) {
  46904. for (var r2 = 0; r2 < t2.length; r2 += 3)
  46905. e2.minX = Math.min(e2.minX, t2[r2]), e2.minY = Math.min(e2.minY, t2[r2 + 1]), e2.maxX = Math.max(e2.maxX, t2[r2]), e2.maxY = Math.max(e2.maxY, t2[r2 + 1]);
  46906. }
  46907. function Q(e2, t2, r2, o2) {
  46908. if (t2.geometry) {
  46909. var n2 = t2.geometry.coordinates, i3 = t2.geometry.type, s2 = Math.pow(r2.tolerance / ((1 << r2.maxZoom) * r2.extent), 2), a2 = [], l2 = t2.id;
  46910. if (r2.promoteId ? l2 = t2.properties[r2.promoteId] : r2.generateId && (l2 = o2 || 0), "Point" === i3)
  46911. H(n2, a2);
  46912. else if ("MultiPoint" === i3)
  46913. for (var u2 = 0; u2 < n2.length; u2++)
  46914. H(n2[u2], a2);
  46915. else if ("LineString" === i3)
  46916. K(n2, a2, s2, false);
  46917. else if ("MultiLineString" === i3) {
  46918. if (r2.lineMetrics) {
  46919. for (u2 = 0; u2 < n2.length; u2++)
  46920. K(n2[u2], a2 = [], s2, false), e2.push(q(l2, "LineString", a2, t2.properties));
  46921. return;
  46922. }
  46923. ee(n2, a2, s2, false);
  46924. } else if ("Polygon" === i3)
  46925. ee(n2, a2, s2, true);
  46926. else {
  46927. if ("MultiPolygon" !== i3) {
  46928. if ("GeometryCollection" === i3) {
  46929. for (u2 = 0; u2 < t2.geometry.geometries.length; u2++)
  46930. Q(e2, { id: l2, geometry: t2.geometry.geometries[u2], properties: t2.properties }, r2, o2);
  46931. return;
  46932. }
  46933. throw new Error("Input data is not a valid GeoJSON object.");
  46934. }
  46935. for (u2 = 0; u2 < n2.length; u2++) {
  46936. var h2 = [];
  46937. ee(n2[u2], h2, s2, true), a2.push(h2);
  46938. }
  46939. }
  46940. e2.push(q(l2, i3, a2, t2.properties));
  46941. }
  46942. }
  46943. function H(e2, t2) {
  46944. t2.push(te(e2[0])), t2.push(re(e2[1])), t2.push(0);
  46945. }
  46946. function K(e2, t2, r2, o2) {
  46947. for (var n2, i3, s2 = 0, a2 = 0; a2 < e2.length; a2++) {
  46948. var l2 = te(e2[a2][0]), u2 = re(e2[a2][1]);
  46949. t2.push(l2), t2.push(u2), t2.push(0), a2 > 0 && (s2 += o2 ? (n2 * u2 - l2 * i3) / 2 : Math.sqrt(Math.pow(l2 - n2, 2) + Math.pow(u2 - i3, 2))), n2 = l2, i3 = u2;
  46950. }
  46951. var h2 = t2.length - 3;
  46952. t2[2] = 1, B(t2, 0, h2, r2), t2[h2 + 2] = 1, t2.size = Math.abs(s2), t2.start = 0, t2.end = t2.size;
  46953. }
  46954. function ee(e2, t2, r2, o2) {
  46955. for (var n2 = 0; n2 < e2.length; n2++) {
  46956. var i3 = [];
  46957. K(e2[n2], i3, r2, o2), t2.push(i3);
  46958. }
  46959. }
  46960. function te(e2) {
  46961. return e2 / 360 + 0.5;
  46962. }
  46963. function re(e2) {
  46964. var t2 = Math.sin(e2 * Math.PI / 180), r2 = 0.5 - 0.25 * Math.log((1 + t2) / (1 - t2)) / Math.PI;
  46965. return r2 < 0 ? 0 : r2 > 1 ? 1 : r2;
  46966. }
  46967. function oe(e2, t2, r2, o2, n2, i3, s2, a2) {
  46968. if (o2 /= t2, i3 >= (r2 /= t2) && s2 < o2)
  46969. return e2;
  46970. if (s2 < r2 || i3 >= o2)
  46971. return null;
  46972. for (var l2 = [], u2 = 0; u2 < e2.length; u2++) {
  46973. var h2 = e2[u2], c2 = h2.geometry, f2 = h2.type, p2 = 0 === n2 ? h2.minX : h2.minY, g2 = 0 === n2 ? h2.maxX : h2.maxY;
  46974. if (p2 >= r2 && g2 < o2)
  46975. l2.push(h2);
  46976. else if (!(g2 < r2 || p2 >= o2)) {
  46977. var d2 = [];
  46978. if ("Point" === f2 || "MultiPoint" === f2)
  46979. ne(c2, d2, r2, o2, n2);
  46980. else if ("LineString" === f2)
  46981. ie(c2, d2, r2, o2, n2, false, a2.lineMetrics);
  46982. else if ("MultiLineString" === f2)
  46983. ae(c2, d2, r2, o2, n2, false);
  46984. else if ("Polygon" === f2)
  46985. ae(c2, d2, r2, o2, n2, true);
  46986. else if ("MultiPolygon" === f2)
  46987. for (var m2 = 0; m2 < c2.length; m2++) {
  46988. var y2 = [];
  46989. ae(c2[m2], y2, r2, o2, n2, true), y2.length && d2.push(y2);
  46990. }
  46991. if (d2.length) {
  46992. if (a2.lineMetrics && "LineString" === f2) {
  46993. for (m2 = 0; m2 < d2.length; m2++)
  46994. l2.push(q(h2.id, f2, d2[m2], h2.tags));
  46995. continue;
  46996. }
  46997. "LineString" !== f2 && "MultiLineString" !== f2 || (1 === d2.length ? (f2 = "LineString", d2 = d2[0]) : f2 = "MultiLineString"), "Point" !== f2 && "MultiPoint" !== f2 || (f2 = 3 === d2.length ? "Point" : "MultiPoint"), l2.push(q(h2.id, f2, d2, h2.tags));
  46998. }
  46999. }
  47000. }
  47001. return l2.length ? l2 : null;
  47002. }
  47003. function ne(e2, t2, r2, o2, n2) {
  47004. for (var i3 = 0; i3 < e2.length; i3 += 3) {
  47005. var s2 = e2[i3 + n2];
  47006. s2 >= r2 && s2 <= o2 && (t2.push(e2[i3]), t2.push(e2[i3 + 1]), t2.push(e2[i3 + 2]));
  47007. }
  47008. }
  47009. function ie(e2, t2, r2, o2, n2, i3, s2) {
  47010. for (var a2, l2, u2 = se(e2), h2 = 0 === n2 ? ue : he, c2 = e2.start, f2 = 0; f2 < e2.length - 3; f2 += 3) {
  47011. var p2 = e2[f2], g2 = e2[f2 + 1], d2 = e2[f2 + 2], m2 = e2[f2 + 3], y2 = e2[f2 + 4], v2 = 0 === n2 ? p2 : g2, x2 = 0 === n2 ? m2 : y2, w2 = false;
  47012. s2 && (a2 = Math.sqrt(Math.pow(p2 - m2, 2) + Math.pow(g2 - y2, 2))), v2 < r2 ? x2 > r2 && (l2 = h2(u2, p2, g2, m2, y2, r2), s2 && (u2.start = c2 + a2 * l2)) : v2 > o2 ? x2 < o2 && (l2 = h2(u2, p2, g2, m2, y2, o2), s2 && (u2.start = c2 + a2 * l2)) : le(u2, p2, g2, d2), x2 < r2 && v2 >= r2 && (l2 = h2(u2, p2, g2, m2, y2, r2), w2 = true), x2 > o2 && v2 <= o2 && (l2 = h2(u2, p2, g2, m2, y2, o2), w2 = true), !i3 && w2 && (s2 && (u2.end = c2 + a2 * l2), t2.push(u2), u2 = se(e2)), s2 && (c2 += a2);
  47013. }
  47014. var S2 = e2.length - 3;
  47015. p2 = e2[S2], g2 = e2[S2 + 1], d2 = e2[S2 + 2], (v2 = 0 === n2 ? p2 : g2) >= r2 && v2 <= o2 && le(u2, p2, g2, d2), S2 = u2.length - 3, i3 && S2 >= 3 && (u2[S2] !== u2[0] || u2[S2 + 1] !== u2[1]) && le(u2, u2[0], u2[1], u2[2]), u2.length && t2.push(u2);
  47016. }
  47017. function se(e2) {
  47018. var t2 = [];
  47019. return t2.size = e2.size, t2.start = e2.start, t2.end = e2.end, t2;
  47020. }
  47021. function ae(e2, t2, r2, o2, n2, i3) {
  47022. for (var s2 = 0; s2 < e2.length; s2++)
  47023. ie(e2[s2], t2, r2, o2, n2, i3, false);
  47024. }
  47025. function le(e2, t2, r2, o2) {
  47026. e2.push(t2), e2.push(r2), e2.push(o2);
  47027. }
  47028. function ue(e2, t2, r2, o2, n2, i3) {
  47029. var s2 = (i3 - t2) / (o2 - t2);
  47030. return e2.push(i3), e2.push(r2 + (n2 - r2) * s2), e2.push(1), s2;
  47031. }
  47032. function he(e2, t2, r2, o2, n2, i3) {
  47033. var s2 = (i3 - r2) / (n2 - r2);
  47034. return e2.push(t2 + (o2 - t2) * s2), e2.push(i3), e2.push(1), s2;
  47035. }
  47036. function ce(e2, t2) {
  47037. for (var r2 = [], o2 = 0; o2 < e2.length; o2++) {
  47038. var n2, i3 = e2[o2], s2 = i3.type;
  47039. if ("Point" === s2 || "MultiPoint" === s2 || "LineString" === s2)
  47040. n2 = fe(i3.geometry, t2);
  47041. else if ("MultiLineString" === s2 || "Polygon" === s2) {
  47042. n2 = [];
  47043. for (var a2 = 0; a2 < i3.geometry.length; a2++)
  47044. n2.push(fe(i3.geometry[a2], t2));
  47045. } else if ("MultiPolygon" === s2)
  47046. for (n2 = [], a2 = 0; a2 < i3.geometry.length; a2++) {
  47047. for (var l2 = [], u2 = 0; u2 < i3.geometry[a2].length; u2++)
  47048. l2.push(fe(i3.geometry[a2][u2], t2));
  47049. n2.push(l2);
  47050. }
  47051. r2.push(q(i3.id, s2, n2, i3.tags));
  47052. }
  47053. return r2;
  47054. }
  47055. function fe(e2, t2) {
  47056. var r2 = [];
  47057. r2.size = e2.size, void 0 !== e2.start && (r2.start = e2.start, r2.end = e2.end);
  47058. for (var o2 = 0; o2 < e2.length; o2 += 3)
  47059. r2.push(e2[o2] + t2, e2[o2 + 1], e2[o2 + 2]);
  47060. return r2;
  47061. }
  47062. function pe(e2, t2) {
  47063. if (e2.transformed)
  47064. return e2;
  47065. var r2, o2, n2, i3 = 1 << e2.z, s2 = e2.x, a2 = e2.y;
  47066. for (r2 = 0; r2 < e2.features.length; r2++) {
  47067. var l2 = e2.features[r2], u2 = l2.geometry, h2 = l2.type;
  47068. if (l2.geometry = [], 1 === h2)
  47069. for (o2 = 0; o2 < u2.length; o2 += 2)
  47070. l2.geometry.push(ge(u2[o2], u2[o2 + 1], t2, i3, s2, a2));
  47071. else
  47072. for (o2 = 0; o2 < u2.length; o2++) {
  47073. var c2 = [];
  47074. for (n2 = 0; n2 < u2[o2].length; n2 += 2)
  47075. c2.push(ge(u2[o2][n2], u2[o2][n2 + 1], t2, i3, s2, a2));
  47076. l2.geometry.push(c2);
  47077. }
  47078. }
  47079. return e2.transformed = true, e2;
  47080. }
  47081. function ge(e2, t2, r2, o2, n2, i3) {
  47082. return [Math.round(r2 * (e2 * o2 - n2)), Math.round(r2 * (t2 * o2 - i3))];
  47083. }
  47084. function de(e2, t2, r2, o2, n2) {
  47085. for (var i3 = t2 === n2.maxZoom ? 0 : n2.tolerance / ((1 << t2) * n2.extent), s2 = { features: [], numPoints: 0, numSimplified: 0, numFeatures: 0, source: null, x: r2, y: o2, z: t2, transformed: false, minX: 2, minY: 1, maxX: -1, maxY: 0 }, a2 = 0; a2 < e2.length; a2++) {
  47086. s2.numFeatures++, me(s2, e2[a2], i3, n2);
  47087. var l2 = e2[a2].minX, u2 = e2[a2].minY, h2 = e2[a2].maxX, c2 = e2[a2].maxY;
  47088. l2 < s2.minX && (s2.minX = l2), u2 < s2.minY && (s2.minY = u2), h2 > s2.maxX && (s2.maxX = h2), c2 > s2.maxY && (s2.maxY = c2);
  47089. }
  47090. return s2;
  47091. }
  47092. function me(e2, t2, r2, o2) {
  47093. var n2 = t2.geometry, i3 = t2.type, s2 = [];
  47094. if ("Point" === i3 || "MultiPoint" === i3)
  47095. for (var a2 = 0; a2 < n2.length; a2 += 3)
  47096. s2.push(n2[a2]), s2.push(n2[a2 + 1]), e2.numPoints++, e2.numSimplified++;
  47097. else if ("LineString" === i3)
  47098. ye(s2, n2, e2, r2, false, false);
  47099. else if ("MultiLineString" === i3 || "Polygon" === i3)
  47100. for (a2 = 0; a2 < n2.length; a2++)
  47101. ye(s2, n2[a2], e2, r2, "Polygon" === i3, 0 === a2);
  47102. else if ("MultiPolygon" === i3)
  47103. for (var l2 = 0; l2 < n2.length; l2++) {
  47104. var u2 = n2[l2];
  47105. for (a2 = 0; a2 < u2.length; a2++)
  47106. ye(s2, u2[a2], e2, r2, true, 0 === a2);
  47107. }
  47108. if (s2.length) {
  47109. var h2 = t2.tags || null;
  47110. if ("LineString" === i3 && o2.lineMetrics) {
  47111. for (var c2 in h2 = {}, t2.tags)
  47112. h2[c2] = t2.tags[c2];
  47113. h2.mapbox_clip_start = n2.start / n2.size, h2.mapbox_clip_end = n2.end / n2.size;
  47114. }
  47115. var f2 = { geometry: s2, type: "Polygon" === i3 || "MultiPolygon" === i3 ? 3 : "LineString" === i3 || "MultiLineString" === i3 ? 2 : 1, tags: h2 };
  47116. null !== t2.id && (f2.id = t2.id), e2.features.push(f2);
  47117. }
  47118. }
  47119. function ye(e2, t2, r2, o2, n2, i3) {
  47120. var s2 = o2 * o2;
  47121. if (o2 > 0 && t2.size < (n2 ? s2 : o2))
  47122. r2.numPoints += t2.length / 3;
  47123. else {
  47124. for (var a2 = [], l2 = 0; l2 < t2.length; l2 += 3)
  47125. (0 === o2 || t2[l2 + 2] > s2) && (r2.numSimplified++, a2.push(t2[l2]), a2.push(t2[l2 + 1])), r2.numPoints++;
  47126. n2 && function(e3, t3) {
  47127. for (var r3 = 0, o3 = 0, n3 = e3.length, i4 = n3 - 2; o3 < n3; i4 = o3, o3 += 2)
  47128. r3 += (e3[o3] - e3[i4]) * (e3[o3 + 1] + e3[i4 + 1]);
  47129. if (r3 > 0 === t3)
  47130. for (o3 = 0, n3 = e3.length; o3 < n3 / 2; o3 += 2) {
  47131. var s3 = e3[o3], a3 = e3[o3 + 1];
  47132. e3[o3] = e3[n3 - 2 - o3], e3[o3 + 1] = e3[n3 - 1 - o3], e3[n3 - 2 - o3] = s3, e3[n3 - 1 - o3] = a3;
  47133. }
  47134. }(a2, i3), e2.push(a2);
  47135. }
  47136. }
  47137. function ve(e2, t2) {
  47138. var r2 = (t2 = this.options = function(e3, t3) {
  47139. for (var r3 in t3)
  47140. e3[r3] = t3[r3];
  47141. return e3;
  47142. }(Object.create(this.options), t2)).debug;
  47143. if (r2 && console.time("preprocess data"), t2.maxZoom < 0 || t2.maxZoom > 24)
  47144. throw new Error("maxZoom should be in the 0-24 range");
  47145. if (t2.promoteId && t2.generateId)
  47146. throw new Error("promoteId and generateId cannot be used together.");
  47147. var o2 = function(e3, t3) {
  47148. var r3 = [];
  47149. if ("FeatureCollection" === e3.type)
  47150. for (var o3 = 0; o3 < e3.features.length; o3++)
  47151. Q(r3, e3.features[o3], t3, o3);
  47152. else
  47153. Q(r3, "Feature" === e3.type ? e3 : { geometry: e3 }, t3);
  47154. return r3;
  47155. }(e2, t2);
  47156. this.tiles = {}, this.tileCoords = [], r2 && (console.timeEnd("preprocess data"), console.log("index: maxZoom: %d, maxPoints: %d", t2.indexMaxZoom, t2.indexMaxPoints), console.time("generate tiles"), this.stats = {}, this.total = 0), (o2 = function(e3, t3) {
  47157. var r3 = t3.buffer / t3.extent, o3 = e3, n2 = oe(e3, 1, -1 - r3, r3, 0, -1, 2, t3), i3 = oe(e3, 1, 1 - r3, 2 + r3, 0, -1, 2, t3);
  47158. return (n2 || i3) && (o3 = oe(e3, 1, -r3, 1 + r3, 0, -1, 2, t3) || [], n2 && (o3 = ce(n2, 1).concat(o3)), i3 && (o3 = o3.concat(ce(i3, -1)))), o3;
  47159. }(o2, t2)).length && this.splitTile(o2, 0, 0, 0), r2 && (o2.length && console.log("features: %d, points: %d", this.tiles[0].numFeatures, this.tiles[0].numPoints), console.timeEnd("generate tiles"), console.log("tiles generated:", this.total, JSON.stringify(this.stats)));
  47160. }
  47161. function xe(e2, t2, r2) {
  47162. return 32 * ((1 << e2) * r2 + t2) + e2;
  47163. }
  47164. function we(e2, t2) {
  47165. const r2 = e2.tileID.canonical;
  47166. if (!this._geoJSONIndex)
  47167. return t2(null, null);
  47168. const o2 = this._geoJSONIndex.getTile(r2.z, r2.x, r2.y);
  47169. if (!o2)
  47170. return t2(null, null);
  47171. const n2 = new h(o2.features);
  47172. let i3 = d(n2);
  47173. 0 === i3.byteOffset && i3.byteLength === i3.buffer.byteLength || (i3 = new Uint8Array(i3)), t2(null, { vectorTile: n2, rawData: i3.buffer });
  47174. }
  47175. ve.prototype.options = { maxZoom: 14, indexMaxZoom: 5, indexMaxPoints: 1e5, tolerance: 3, extent: 4096, buffer: 64, lineMetrics: false, promoteId: null, generateId: false, debug: 0 }, ve.prototype.splitTile = function(e2, t2, r2, o2, n2, i3, s2) {
  47176. for (var a2 = [e2, t2, r2, o2], l2 = this.options, u2 = l2.debug; a2.length; ) {
  47177. o2 = a2.pop(), r2 = a2.pop(), t2 = a2.pop(), e2 = a2.pop();
  47178. var h2 = 1 << t2, c2 = xe(t2, r2, o2), f2 = this.tiles[c2];
  47179. if (!f2 && (u2 > 1 && console.time("creation"), f2 = this.tiles[c2] = de(e2, t2, r2, o2, l2), this.tileCoords.push({ z: t2, x: r2, y: o2 }), u2)) {
  47180. u2 > 1 && (console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)", t2, r2, o2, f2.numFeatures, f2.numPoints, f2.numSimplified), console.timeEnd("creation"));
  47181. var p2 = "z" + t2;
  47182. this.stats[p2] = (this.stats[p2] || 0) + 1, this.total++;
  47183. }
  47184. if (f2.source = e2, n2) {
  47185. if (t2 === l2.maxZoom || t2 === n2)
  47186. continue;
  47187. var g2 = 1 << n2 - t2;
  47188. if (r2 !== Math.floor(i3 / g2) || o2 !== Math.floor(s2 / g2))
  47189. continue;
  47190. } else if (t2 === l2.indexMaxZoom || f2.numPoints <= l2.indexMaxPoints)
  47191. continue;
  47192. if (f2.source = null, 0 !== e2.length) {
  47193. u2 > 1 && console.time("clipping");
  47194. var d2, m2, y2, v2, x2, w2, S2 = 0.5 * l2.buffer / l2.extent, M2 = 0.5 - S2, P2 = 0.5 + S2, b2 = 1 + S2;
  47195. d2 = m2 = y2 = v2 = null, x2 = oe(e2, h2, r2 - S2, r2 + P2, 0, f2.minX, f2.maxX, l2), w2 = oe(e2, h2, r2 + M2, r2 + b2, 0, f2.minX, f2.maxX, l2), e2 = null, x2 && (d2 = oe(x2, h2, o2 - S2, o2 + P2, 1, f2.minY, f2.maxY, l2), m2 = oe(x2, h2, o2 + M2, o2 + b2, 1, f2.minY, f2.maxY, l2), x2 = null), w2 && (y2 = oe(w2, h2, o2 - S2, o2 + P2, 1, f2.minY, f2.maxY, l2), v2 = oe(w2, h2, o2 + M2, o2 + b2, 1, f2.minY, f2.maxY, l2), w2 = null), u2 > 1 && console.timeEnd("clipping"), a2.push(d2 || [], t2 + 1, 2 * r2, 2 * o2), a2.push(m2 || [], t2 + 1, 2 * r2, 2 * o2 + 1), a2.push(y2 || [], t2 + 1, 2 * r2 + 1, 2 * o2), a2.push(v2 || [], t2 + 1, 2 * r2 + 1, 2 * o2 + 1);
  47196. }
  47197. }
  47198. }, ve.prototype.getTile = function(e2, t2, r2) {
  47199. var o2 = this.options, n2 = o2.extent, i3 = o2.debug;
  47200. if (e2 < 0 || e2 > 24)
  47201. return null;
  47202. var s2 = 1 << e2, a2 = xe(e2, t2 = (t2 % s2 + s2) % s2, r2);
  47203. if (this.tiles[a2])
  47204. return pe(this.tiles[a2], n2);
  47205. i3 > 1 && console.log("drilling down to z%d-%d-%d", e2, t2, r2);
  47206. for (var l2, u2 = e2, h2 = t2, c2 = r2; !l2 && u2 > 0; )
  47207. u2--, h2 = Math.floor(h2 / 2), c2 = Math.floor(c2 / 2), l2 = this.tiles[xe(u2, h2, c2)];
  47208. return l2 && l2.source ? (i3 > 1 && console.log("found parent tile z%d-%d-%d", u2, h2, c2), i3 > 1 && console.time("drilling down"), this.splitTile(l2.source, u2, h2, c2, e2, t2, r2), i3 > 1 && console.timeEnd("drilling down"), this.tiles[a2] ? pe(this.tiles[a2], n2) : null) : null;
  47209. };
  47210. class Se extends e.VectorTileWorkerSource {
  47211. constructor(e2, t2, r2, o2, n2) {
  47212. super(e2, t2, r2, o2, we), n2 && (this.loadGeoJSON = n2);
  47213. }
  47214. loadData(t2, r2) {
  47215. const o2 = t2 && t2.request, n2 = o2 && o2.collectResourceTiming;
  47216. this.loadGeoJSON(t2, (s2, a2) => {
  47217. if (s2 || !a2)
  47218. return r2(s2);
  47219. if ("object" != typeof a2)
  47220. return r2(new Error(`Input data given to '${t2.source}' is not a valid GeoJSON object.`));
  47221. {
  47222. i2(a2, true);
  47223. try {
  47224. if (t2.filter) {
  47225. const r3 = e.createExpression(t2.filter, { type: "boolean", "property-type": "data-driven", overridable: false, transition: false });
  47226. if ("error" === r3.result)
  47227. throw new Error(r3.value.map((e2) => `${e2.key}: ${e2.message}`).join(", "));
  47228. const o3 = a2.features.filter((e2) => r3.value.evaluate({ zoom: 0 }, e2));
  47229. a2 = { type: "FeatureCollection", features: o3 };
  47230. }
  47231. this._geoJSONIndex = t2.cluster ? new j(function({ superclusterOptions: t3, clusterProperties: r3 }) {
  47232. if (!r3 || !t3)
  47233. return t3;
  47234. const o3 = {}, n3 = {}, i3 = { accumulated: null, zoom: 0 }, s3 = { properties: null }, a3 = Object.keys(r3);
  47235. for (const t4 of a3) {
  47236. const [i4, s4] = r3[t4], a4 = e.createExpression(s4), l3 = e.createExpression("string" == typeof i4 ? [i4, ["accumulated"], ["get", t4]] : i4);
  47237. o3[t4] = a4.value, n3[t4] = l3.value;
  47238. }
  47239. return t3.map = (e2) => {
  47240. s3.properties = e2;
  47241. const t4 = {};
  47242. for (const e3 of a3)
  47243. t4[e3] = o3[e3].evaluate(i3, s3);
  47244. return t4;
  47245. }, t3.reduce = (e2, t4) => {
  47246. s3.properties = t4;
  47247. for (const t5 of a3)
  47248. i3.accumulated = e2[t5], e2[t5] = n3[t5].evaluate(i3, s3);
  47249. }, t3;
  47250. }(t2)).load(a2.features) : function(e2, t3) {
  47251. return new ve(e2, t3);
  47252. }(a2, t2.geojsonVtOptions);
  47253. } catch (s3) {
  47254. return r2(s3);
  47255. }
  47256. this.loaded = {};
  47257. const l2 = {};
  47258. if (n2) {
  47259. const r3 = e.getPerformanceMeasurement(o2);
  47260. r3 && (l2.resourceTiming = {}, l2.resourceTiming[t2.source] = JSON.parse(JSON.stringify(r3)));
  47261. }
  47262. r2(null, l2);
  47263. }
  47264. });
  47265. }
  47266. reloadTile(e2, t2) {
  47267. const r2 = this.loaded;
  47268. return r2 && r2[e2.uid] ? super.reloadTile(e2, t2) : this.loadTile(e2, t2);
  47269. }
  47270. loadGeoJSON(t2, r2) {
  47271. if (t2.request)
  47272. e.getJSON(t2.request, r2);
  47273. else {
  47274. if ("string" != typeof t2.data)
  47275. return r2(new Error(`Input data given to '${t2.source}' is not a valid GeoJSON object.`));
  47276. try {
  47277. return r2(null, JSON.parse(t2.data));
  47278. } catch (e2) {
  47279. return r2(new Error(`Input data given to '${t2.source}' is not a valid GeoJSON object.`));
  47280. }
  47281. }
  47282. }
  47283. getClusterExpansionZoom(e2, t2) {
  47284. try {
  47285. t2(null, this._geoJSONIndex.getClusterExpansionZoom(e2.clusterId));
  47286. } catch (e3) {
  47287. t2(e3);
  47288. }
  47289. }
  47290. getClusterChildren(e2, t2) {
  47291. try {
  47292. t2(null, this._geoJSONIndex.getChildren(e2.clusterId));
  47293. } catch (e3) {
  47294. t2(e3);
  47295. }
  47296. }
  47297. getClusterLeaves(e2, t2) {
  47298. try {
  47299. t2(null, this._geoJSONIndex.getLeaves(e2.clusterId, e2.limit, e2.offset));
  47300. } catch (e3) {
  47301. t2(e3);
  47302. }
  47303. }
  47304. }
  47305. class Me {
  47306. constructor(t2) {
  47307. this.self = t2, this.actor = new e.Actor(t2, this), this.layerIndexes = {}, this.availableImages = {}, this.isSpriteLoaded = {}, this.projections = {}, this.defaultProjection = e.getProjection({ name: "mercator" }), this.workerSourceTypes = { vector: e.VectorTileWorkerSource, geojson: Se }, this.workerSources = {}, this.demWorkerSources = {}, this.self.registerWorkerSource = (e2, t3) => {
  47308. if (this.workerSourceTypes[e2])
  47309. throw new Error(`Worker source with name "${e2}" already registered.`);
  47310. this.workerSourceTypes[e2] = t3;
  47311. }, this.self.registerRTLTextPlugin = (t3) => {
  47312. if (e.plugin.isParsed())
  47313. throw new Error("RTL text plugin already registered.");
  47314. e.plugin.applyArabicShaping = t3.applyArabicShaping, e.plugin.processBidirectionalText = t3.processBidirectionalText, e.plugin.processStyledBidirectionalText = t3.processStyledBidirectionalText;
  47315. };
  47316. }
  47317. clearCaches(e2, t2, r2) {
  47318. delete this.layerIndexes[e2], delete this.availableImages[e2], delete this.workerSources[e2], delete this.demWorkerSources[e2], r2();
  47319. }
  47320. checkIfReady(e2, t2, r2) {
  47321. r2();
  47322. }
  47323. setReferrer(e2, t2) {
  47324. this.referrer = t2;
  47325. }
  47326. spriteLoaded(t2, r2) {
  47327. this.isSpriteLoaded[t2] = r2;
  47328. for (const o2 in this.workerSources[t2]) {
  47329. const n2 = this.workerSources[t2][o2];
  47330. for (const t3 in n2)
  47331. n2[t3] instanceof e.VectorTileWorkerSource && (n2[t3].isSpriteLoaded = r2, n2[t3].fire(new e.Event("isSpriteLoaded")));
  47332. }
  47333. }
  47334. setImages(e2, t2, r2) {
  47335. this.availableImages[e2] = t2;
  47336. for (const r3 in this.workerSources[e2]) {
  47337. const o2 = this.workerSources[e2][r3];
  47338. for (const e3 in o2)
  47339. o2[e3].availableImages = t2;
  47340. }
  47341. r2();
  47342. }
  47343. enableTerrain(e2, t2, r2) {
  47344. this.terrain = t2, r2();
  47345. }
  47346. setProjection(t2, r2) {
  47347. this.projections[t2] = e.getProjection(r2);
  47348. }
  47349. setLayers(e2, t2, r2) {
  47350. this.getLayerIndex(e2).replace(t2), r2();
  47351. }
  47352. updateLayers(e2, t2, r2) {
  47353. this.getLayerIndex(e2).update(t2.layers, t2.removedIds), r2();
  47354. }
  47355. loadTile(t2, r2, o2) {
  47356. const n2 = this.enableTerrain ? e.extend({ enableTerrain: this.terrain }, r2) : r2;
  47357. n2.projection = this.projections[t2] || this.defaultProjection, this.getWorkerSource(t2, r2.type, r2.source).loadTile(n2, o2);
  47358. }
  47359. loadDEMTile(t2, r2, o2) {
  47360. const n2 = this.enableTerrain ? e.extend({ buildQuadTree: this.terrain }, r2) : r2;
  47361. this.getDEMWorkerSource(t2, r2.source).loadTile(n2, o2);
  47362. }
  47363. reloadTile(t2, r2, o2) {
  47364. const n2 = this.enableTerrain ? e.extend({ enableTerrain: this.terrain }, r2) : r2;
  47365. n2.projection = this.projections[t2] || this.defaultProjection, this.getWorkerSource(t2, r2.type, r2.source).reloadTile(n2, o2);
  47366. }
  47367. abortTile(e2, t2, r2) {
  47368. this.getWorkerSource(e2, t2.type, t2.source).abortTile(t2, r2);
  47369. }
  47370. removeTile(e2, t2, r2) {
  47371. this.getWorkerSource(e2, t2.type, t2.source).removeTile(t2, r2);
  47372. }
  47373. removeSource(e2, t2, r2) {
  47374. if (!this.workerSources[e2] || !this.workerSources[e2][t2.type] || !this.workerSources[e2][t2.type][t2.source])
  47375. return;
  47376. const o2 = this.workerSources[e2][t2.type][t2.source];
  47377. delete this.workerSources[e2][t2.type][t2.source], void 0 !== o2.removeSource ? o2.removeSource(t2, r2) : r2();
  47378. }
  47379. loadWorkerSource(e2, t2, r2) {
  47380. try {
  47381. this.self.importScripts(t2.url), r2();
  47382. } catch (e3) {
  47383. r2(e3.toString());
  47384. }
  47385. }
  47386. syncRTLPluginState(t2, r2, o2) {
  47387. try {
  47388. e.plugin.setState(r2);
  47389. const t3 = e.plugin.getPluginURL();
  47390. if (e.plugin.isLoaded() && !e.plugin.isParsed() && null != t3) {
  47391. this.self.importScripts(t3);
  47392. const r3 = e.plugin.isParsed();
  47393. o2(r3 ? void 0 : new Error(`RTL Text Plugin failed to import scripts from ${t3}`), r3);
  47394. }
  47395. } catch (e2) {
  47396. o2(e2.toString());
  47397. }
  47398. }
  47399. getAvailableImages(e2) {
  47400. let t2 = this.availableImages[e2];
  47401. return t2 || (t2 = []), t2;
  47402. }
  47403. getLayerIndex(e2) {
  47404. let t2 = this.layerIndexes[e2];
  47405. return t2 || (t2 = this.layerIndexes[e2] = new o()), t2;
  47406. }
  47407. getWorkerSource(e2, t2, r2) {
  47408. return this.workerSources[e2] || (this.workerSources[e2] = {}), this.workerSources[e2][t2] || (this.workerSources[e2][t2] = {}), this.workerSources[e2][t2][r2] || (this.workerSources[e2][t2][r2] = new this.workerSourceTypes[t2]({ send: (t3, r3, o2, n2, i3, s2) => {
  47409. this.actor.send(t3, r3, o2, e2, i3, s2);
  47410. }, scheduler: this.actor.scheduler }, this.getLayerIndex(e2), this.getAvailableImages(e2), this.isSpriteLoaded[e2])), this.workerSources[e2][t2][r2];
  47411. }
  47412. getDEMWorkerSource(e2, t2) {
  47413. return this.demWorkerSources[e2] || (this.demWorkerSources[e2] = {}), this.demWorkerSources[e2][t2] || (this.demWorkerSources[e2][t2] = new n()), this.demWorkerSources[e2][t2];
  47414. }
  47415. enforceCacheSizeLimit(t2, r2) {
  47416. e.enforceCacheSizeLimit(r2);
  47417. }
  47418. getWorkerPerformanceMetrics(e2, t2, r2) {
  47419. r2(void 0, void 0);
  47420. }
  47421. }
  47422. return "undefined" != typeof WorkerGlobalScope && "undefined" != typeof self && self instanceof WorkerGlobalScope && (self.worker = new Me(self)), Me;
  47423. });
  47424. define(["./shared"], function(e) {
  47425. var t = i2;
  47426. function i2(e2) {
  47427. return !function(e3) {
  47428. return "undefined" == typeof window || "undefined" == typeof document ? "not a browser" : Array.prototype && Array.prototype.every && Array.prototype.filter && Array.prototype.forEach && Array.prototype.indexOf && Array.prototype.lastIndexOf && Array.prototype.map && Array.prototype.some && Array.prototype.reduce && Array.prototype.reduceRight && Array.isArray ? Function.prototype && Function.prototype.bind ? Object.keys && Object.create && Object.getPrototypeOf && Object.getOwnPropertyNames && Object.isSealed && Object.isFrozen && Object.isExtensible && Object.getOwnPropertyDescriptor && Object.defineProperty && Object.defineProperties && Object.seal && Object.freeze && Object.preventExtensions ? "JSON" in window && "parse" in JSON && "stringify" in JSON ? function() {
  47429. if (!("Worker" in window && "Blob" in window && "URL" in window))
  47430. return false;
  47431. var e4, t3, i3 = new Blob([""], { type: "text/javascript" }), o2 = URL.createObjectURL(i3);
  47432. try {
  47433. t3 = new Worker(o2), e4 = true;
  47434. } catch (t4) {
  47435. e4 = false;
  47436. }
  47437. return t3 && t3.terminate(), URL.revokeObjectURL(o2), e4;
  47438. }() ? "Uint8ClampedArray" in window ? ArrayBuffer.isView ? function() {
  47439. var e4 = document.createElement("canvas");
  47440. e4.width = e4.height = 1;
  47441. var t3 = e4.getContext("2d");
  47442. if (!t3)
  47443. return false;
  47444. var i3 = t3.getImageData(0, 0, 1, 1);
  47445. return i3 && i3.width === e4.width;
  47446. }() ? (void 0 === o[t2 = e3 && e3.failIfMajorPerformanceCaveat] && (o[t2] = function(e4) {
  47447. var t3, o2 = function(e5) {
  47448. var t4 = document.createElement("canvas"), o3 = Object.create(i2.webGLContextAttributes);
  47449. return o3.failIfMajorPerformanceCaveat = e5, t4.getContext("webgl", o3) || t4.getContext("experimental-webgl", o3);
  47450. }(e4);
  47451. if (!o2)
  47452. return false;
  47453. try {
  47454. t3 = o2.createShader(o2.VERTEX_SHADER);
  47455. } catch (e5) {
  47456. return false;
  47457. }
  47458. return !(!t3 || o2.isContextLost()) && (o2.shaderSource(t3, "void main() {}"), o2.compileShader(t3), true === o2.getShaderParameter(t3, o2.COMPILE_STATUS));
  47459. }(t2)), o[t2] ? document.documentMode ? "insufficient ECMAScript 6 support" : void 0 : "insufficient WebGL support") : "insufficient Canvas/getImageData support" : "insufficient ArrayBuffer support" : "insufficient Uint8ClampedArray support" : "insufficient worker support" : "insufficient JSON support" : "insufficient Object support" : "insufficient Function support" : "insufficent Array support";
  47460. var t2;
  47461. }(e2);
  47462. }
  47463. var o = {};
  47464. function r(e2, t2) {
  47465. if (Array.isArray(e2)) {
  47466. if (!Array.isArray(t2) || e2.length !== t2.length)
  47467. return false;
  47468. for (let i3 = 0; i3 < e2.length; i3++)
  47469. if (!r(e2[i3], t2[i3]))
  47470. return false;
  47471. return true;
  47472. }
  47473. if ("object" == typeof e2 && null !== e2 && null !== t2) {
  47474. if ("object" != typeof t2)
  47475. return false;
  47476. if (Object.keys(e2).length !== Object.keys(t2).length)
  47477. return false;
  47478. for (const i3 in e2)
  47479. if (!r(e2[i3], t2[i3]))
  47480. return false;
  47481. return true;
  47482. }
  47483. return e2 === t2;
  47484. }
  47485. function n(t2, i3, o2) {
  47486. const r2 = e.window.document.createElement(t2);
  47487. return void 0 !== i3 && (r2.className = i3), o2 && o2.appendChild(r2), r2;
  47488. }
  47489. function a(t2, i3, o2) {
  47490. const r2 = e.window.document.createElementNS("http://www.w3.org/2000/svg", t2);
  47491. for (const e2 of Object.keys(i3))
  47492. r2.setAttributeNS(null, e2, i3[e2]);
  47493. return o2 && o2.appendChild(r2), r2;
  47494. }
  47495. i2.webGLContextAttributes = { antialias: false, alpha: true, stencil: true, depth: true };
  47496. const s = e.window.document && e.window.document.documentElement.style, l = s && void 0 !== s.userSelect ? "userSelect" : "WebkitUserSelect";
  47497. let c;
  47498. function h() {
  47499. s && l && (c = s[l], s[l] = "none");
  47500. }
  47501. function _() {
  47502. s && l && (s[l] = c);
  47503. }
  47504. function u(t2) {
  47505. t2.preventDefault(), t2.stopPropagation(), e.window.removeEventListener("click", u, true);
  47506. }
  47507. function d() {
  47508. e.window.addEventListener("click", u, true), e.window.setTimeout(() => {
  47509. e.window.removeEventListener("click", u, true);
  47510. }, 0);
  47511. }
  47512. function p(e2, t2) {
  47513. const i3 = e2.getBoundingClientRect();
  47514. return g(e2, i3, t2);
  47515. }
  47516. function m(e2, t2) {
  47517. const i3 = e2.getBoundingClientRect(), o2 = [];
  47518. for (let r2 = 0; r2 < t2.length; r2++)
  47519. o2.push(g(e2, i3, t2[r2]));
  47520. return o2;
  47521. }
  47522. function f(t2) {
  47523. return void 0 !== e.window.InstallTrigger && 2 === t2.button && t2.ctrlKey && e.window.navigator.platform.toUpperCase().indexOf("MAC") >= 0 ? 0 : t2.button;
  47524. }
  47525. function g(t2, i3, o2) {
  47526. const r2 = t2.offsetWidth === i3.width ? 1 : t2.offsetWidth / i3.width;
  47527. return new e.pointGeometry((o2.clientX - i3.left) * r2, (o2.clientY - i3.top) * r2);
  47528. }
  47529. function v(e2, t2) {
  47530. var i3 = t2[0], o2 = t2[1], r2 = t2[2], n2 = t2[3], a2 = i3 * n2 - r2 * o2;
  47531. return a2 ? (e2[0] = n2 * (a2 = 1 / a2), e2[1] = -o2 * a2, e2[2] = -r2 * a2, e2[3] = i3 * a2, e2) : null;
  47532. }
  47533. function x(e2) {
  47534. const { userImage: t2 } = e2;
  47535. return !!(t2 && t2.render && t2.render()) && (e2.data.replace(new Uint8Array(t2.data.buffer)), true);
  47536. }
  47537. class y extends e.Evented {
  47538. constructor() {
  47539. super(), this.images = {}, this.updatedImages = {}, this.callbackDispatchedThisFrame = {}, this.loaded = false, this.requestors = [], this.patterns = {}, this.atlasImage = new e.RGBAImage({ width: 1, height: 1 }), this.dirty = true;
  47540. }
  47541. isLoaded() {
  47542. return this.loaded;
  47543. }
  47544. setLoaded(e2) {
  47545. if (this.loaded !== e2 && (this.loaded = e2, e2)) {
  47546. for (const { ids: e3, callback: t2 } of this.requestors)
  47547. this._notify(e3, t2);
  47548. this.requestors = [];
  47549. }
  47550. }
  47551. hasImage(e2) {
  47552. return !!this.getImage(e2);
  47553. }
  47554. getImage(e2) {
  47555. return this.images[e2];
  47556. }
  47557. addImage(e2, t2) {
  47558. this._validate(e2, t2) && (this.images[e2] = t2);
  47559. }
  47560. _validate(t2, i3) {
  47561. let o2 = true;
  47562. return this._validateStretch(i3.stretchX, i3.data && i3.data.width) || (this.fire(new e.ErrorEvent(new Error(`Image "${t2}" has invalid "stretchX" value`))), o2 = false), this._validateStretch(i3.stretchY, i3.data && i3.data.height) || (this.fire(new e.ErrorEvent(new Error(`Image "${t2}" has invalid "stretchY" value`))), o2 = false), this._validateContent(i3.content, i3) || (this.fire(new e.ErrorEvent(new Error(`Image "${t2}" has invalid "content" value`))), o2 = false), o2;
  47563. }
  47564. _validateStretch(e2, t2) {
  47565. if (!e2)
  47566. return true;
  47567. let i3 = 0;
  47568. for (const o2 of e2) {
  47569. if (o2[0] < i3 || o2[1] < o2[0] || t2 < o2[1])
  47570. return false;
  47571. i3 = o2[1];
  47572. }
  47573. return true;
  47574. }
  47575. _validateContent(e2, t2) {
  47576. return !(e2 && (4 !== e2.length || e2[0] < 0 || t2.data.width < e2[0] || e2[1] < 0 || t2.data.height < e2[1] || e2[2] < 0 || t2.data.width < e2[2] || e2[3] < 0 || t2.data.height < e2[3] || e2[2] < e2[0] || e2[3] < e2[1]));
  47577. }
  47578. updateImage(e2, t2) {
  47579. t2.version = this.images[e2].version + 1, this.images[e2] = t2, this.updatedImages[e2] = true;
  47580. }
  47581. removeImage(e2) {
  47582. const t2 = this.images[e2];
  47583. delete this.images[e2], delete this.patterns[e2], t2.userImage && t2.userImage.onRemove && t2.userImage.onRemove();
  47584. }
  47585. listImages() {
  47586. return Object.keys(this.images);
  47587. }
  47588. getImages(e2, t2) {
  47589. let i3 = true;
  47590. if (!this.isLoaded())
  47591. for (const t3 of e2)
  47592. this.images[t3] || (i3 = false);
  47593. this.isLoaded() || i3 ? this._notify(e2, t2) : this.requestors.push({ ids: e2, callback: t2 });
  47594. }
  47595. _notify(t2, i3) {
  47596. const o2 = {};
  47597. for (const i4 of t2) {
  47598. this.images[i4] || this.fire(new e.Event("styleimagemissing", { id: i4 }));
  47599. const t3 = this.images[i4];
  47600. t3 ? o2[i4] = { data: t3.data.clone(), pixelRatio: t3.pixelRatio, sdf: t3.sdf, version: t3.version, stretchX: t3.stretchX, stretchY: t3.stretchY, content: t3.content, hasRenderCallback: Boolean(t3.userImage && t3.userImage.render) } : e.warnOnce(`Image "${i4}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);
  47601. }
  47602. i3(null, o2);
  47603. }
  47604. getPixelSize() {
  47605. const { width: e2, height: t2 } = this.atlasImage;
  47606. return { width: e2, height: t2 };
  47607. }
  47608. getPattern(t2) {
  47609. const i3 = this.patterns[t2], o2 = this.getImage(t2);
  47610. if (!o2)
  47611. return null;
  47612. if (i3 && i3.position.version === o2.version)
  47613. return i3.position;
  47614. if (i3)
  47615. i3.position.version = o2.version;
  47616. else {
  47617. const i4 = { w: o2.data.width + 2, h: o2.data.height + 2, x: 0, y: 0 }, r2 = new e.ImagePosition(i4, o2);
  47618. this.patterns[t2] = { bin: i4, position: r2 };
  47619. }
  47620. return this._updatePatternAtlas(), this.patterns[t2].position;
  47621. }
  47622. bind(t2) {
  47623. const i3 = t2.gl;
  47624. this.atlasTexture ? this.dirty && (this.atlasTexture.update(this.atlasImage), this.dirty = false) : this.atlasTexture = new e.Texture(t2, this.atlasImage, i3.RGBA), this.atlasTexture.bind(i3.LINEAR, i3.CLAMP_TO_EDGE);
  47625. }
  47626. _updatePatternAtlas() {
  47627. const t2 = [];
  47628. for (const e2 in this.patterns)
  47629. t2.push(this.patterns[e2].bin);
  47630. const { w: i3, h: o2 } = e.potpack(t2), r2 = this.atlasImage;
  47631. r2.resize({ width: i3 || 1, height: o2 || 1 });
  47632. for (const t3 in this.patterns) {
  47633. const { bin: i4 } = this.patterns[t3], o3 = i4.x + 1, n2 = i4.y + 1, a2 = this.images[t3].data, s2 = a2.width, l2 = a2.height;
  47634. e.RGBAImage.copy(a2, r2, { x: 0, y: 0 }, { x: o3, y: n2 }, { width: s2, height: l2 }), e.RGBAImage.copy(a2, r2, { x: 0, y: l2 - 1 }, { x: o3, y: n2 - 1 }, { width: s2, height: 1 }), e.RGBAImage.copy(a2, r2, { x: 0, y: 0 }, { x: o3, y: n2 + l2 }, { width: s2, height: 1 }), e.RGBAImage.copy(a2, r2, { x: s2 - 1, y: 0 }, { x: o3 - 1, y: n2 }, { width: 1, height: l2 }), e.RGBAImage.copy(a2, r2, { x: 0, y: 0 }, { x: o3 + s2, y: n2 }, { width: 1, height: l2 });
  47635. }
  47636. this.dirty = true;
  47637. }
  47638. beginFrame() {
  47639. this.callbackDispatchedThisFrame = {};
  47640. }
  47641. dispatchRenderCallbacks(e2) {
  47642. for (const t2 of e2) {
  47643. if (this.callbackDispatchedThisFrame[t2])
  47644. continue;
  47645. this.callbackDispatchedThisFrame[t2] = true;
  47646. const e3 = this.images[t2];
  47647. x(e3) && this.updateImage(t2, e3);
  47648. }
  47649. }
  47650. }
  47651. const b = new e.Properties({ anchor: new e.DataConstantProperty(e.spec.light.anchor), position: new class {
  47652. constructor() {
  47653. this.specification = e.spec.light.position;
  47654. }
  47655. possiblyEvaluate(t2, i3) {
  47656. return function([t3, i4, o2]) {
  47657. const r2 = e.degToRad(i4 + 90), n2 = e.degToRad(o2);
  47658. return { x: t3 * Math.cos(r2) * Math.sin(n2), y: t3 * Math.sin(r2) * Math.sin(n2), z: t3 * Math.cos(n2), azimuthal: i4, polar: o2 };
  47659. }(t2.expression.evaluate(i3));
  47660. }
  47661. interpolate(t2, i3, o2) {
  47662. return { x: e.number(t2.x, i3.x, o2), y: e.number(t2.y, i3.y, o2), z: e.number(t2.z, i3.z, o2), azimuthal: e.number(t2.azimuthal, i3.azimuthal, o2), polar: e.number(t2.polar, i3.polar, o2) };
  47663. }
  47664. }(), color: new e.DataConstantProperty(e.spec.light.color), intensity: new e.DataConstantProperty(e.spec.light.intensity) }), w = "-transition";
  47665. class T extends e.Evented {
  47666. constructor(t2) {
  47667. super(), this._transitionable = new e.Transitionable(b), this.setLight(t2), this._transitioning = this._transitionable.untransitioned();
  47668. }
  47669. getLight() {
  47670. return this._transitionable.serialize();
  47671. }
  47672. setLight(t2, i3 = {}) {
  47673. if (!this._validate(e.validateLight, t2, i3))
  47674. for (const i4 in t2) {
  47675. const o2 = t2[i4];
  47676. e.endsWith(i4, w) ? this._transitionable.setTransition(i4.slice(0, -w.length), o2) : this._transitionable.setValue(i4, o2);
  47677. }
  47678. }
  47679. updateTransitions(e2) {
  47680. this._transitioning = this._transitionable.transitioned(e2, this._transitioning);
  47681. }
  47682. hasTransition() {
  47683. return this._transitioning.hasTransition();
  47684. }
  47685. recalculate(e2) {
  47686. this.properties = this._transitioning.possiblyEvaluate(e2);
  47687. }
  47688. _validate(t2, i3, o2) {
  47689. return (!o2 || false !== o2.validate) && e.emitValidationErrors(this, t2.call(e.validateStyle, e.extend({ value: i3, style: { glyphs: true, sprite: true }, styleSpec: e.spec })));
  47690. }
  47691. }
  47692. const E = new e.Properties({ source: new e.DataConstantProperty(e.spec.terrain.source), exaggeration: new e.DataConstantProperty(e.spec.terrain.exaggeration) }), C = "-transition";
  47693. class I extends e.Evented {
  47694. constructor(t2, i3) {
  47695. super(), this._transitionable = new e.Transitionable(E), this.set(t2), this._transitioning = this._transitionable.untransitioned(), this.drapeRenderMode = i3;
  47696. }
  47697. get() {
  47698. return this._transitionable.serialize();
  47699. }
  47700. set(t2) {
  47701. for (const i3 in t2) {
  47702. const o2 = t2[i3];
  47703. e.endsWith(i3, C) ? this._transitionable.setTransition(i3.slice(0, -C.length), o2) : this._transitionable.setValue(i3, o2);
  47704. }
  47705. }
  47706. updateTransitions(e2) {
  47707. this._transitioning = this._transitionable.transitioned(e2, this._transitioning);
  47708. }
  47709. hasTransition() {
  47710. return this._transitioning.hasTransition();
  47711. }
  47712. recalculate(e2) {
  47713. this.properties = this._transitioning.possiblyEvaluate(e2);
  47714. }
  47715. }
  47716. function M(t2, i3, o2, r2) {
  47717. const n2 = e.smoothstep(45, 65, o2), [a2, s2] = S(t2, r2), l2 = e.length(i3);
  47718. let c2 = 1 - Math.min(1, Math.exp((l2 - a2) / (s2 - a2) * -6));
  47719. return c2 *= c2 * c2, c2 = Math.min(1, 1.00747 * c2), c2 * n2 * t2.alpha;
  47720. }
  47721. function S(e2, t2) {
  47722. const i3 = 0.5 / Math.tan(0.5 * t2);
  47723. return [e2.range[0] + i3, e2.range[1] + i3];
  47724. }
  47725. const z = new e.Properties({ range: new e.DataConstantProperty(e.spec.fog.range), color: new e.DataConstantProperty(e.spec.fog.color), "horizon-blend": new e.DataConstantProperty(e.spec.fog["horizon-blend"]) }), D = "-transition";
  47726. class P extends e.Evented {
  47727. constructor(t2, i3) {
  47728. super(), this._transitionable = new e.Transitionable(z), this.set(t2), this._transitioning = this._transitionable.untransitioned(), this._transform = i3;
  47729. }
  47730. get state() {
  47731. return { range: this.properties.get("range"), horizonBlend: this.properties.get("horizon-blend"), alpha: this.properties.get("color").a };
  47732. }
  47733. get() {
  47734. return this._transitionable.serialize();
  47735. }
  47736. set(t2, i3 = {}) {
  47737. if (!this._validate(e.validateFog, t2, i3))
  47738. for (const i4 in t2) {
  47739. const o2 = t2[i4];
  47740. e.endsWith(i4, D) ? this._transitionable.setTransition(i4.slice(0, -D.length), o2) : this._transitionable.setValue(i4, o2);
  47741. }
  47742. }
  47743. getOpacity(t2) {
  47744. if (!this._transform.projection.supportsFog)
  47745. return 0;
  47746. const i3 = this.properties && this.properties.get("color") || 1;
  47747. return e.smoothstep(45, 65, t2) * i3.a;
  47748. }
  47749. getOpacityAtLatLng(t2, i3) {
  47750. return this._transform.projection.supportsFog ? function(t3, i4, o2) {
  47751. const r2 = e.MercatorCoordinate.fromLngLat(i4), n2 = o2.elevation ? o2.elevation.getAtPointOrZero(r2) : 0, a2 = [r2.x, r2.y, n2];
  47752. return e.transformMat4(a2, a2, o2.mercatorFogMatrix), M(t3, a2, o2.pitch, o2._fov);
  47753. }(this.state, t2, i3) : 0;
  47754. }
  47755. getFovAdjustedRange(e2) {
  47756. return this._transform.projection.supportsFog ? S(this.state, e2) : [0, 1];
  47757. }
  47758. updateTransitions(e2) {
  47759. this._transitioning = this._transitionable.transitioned(e2, this._transitioning);
  47760. }
  47761. hasTransition() {
  47762. return this._transitioning.hasTransition();
  47763. }
  47764. recalculate(e2) {
  47765. this.properties = this._transitioning.possiblyEvaluate(e2);
  47766. }
  47767. _validate(t2, i3, o2) {
  47768. return (!o2 || false !== o2.validate) && e.emitValidationErrors(this, t2.call(e.validateStyle, e.extend({ value: i3, style: { glyphs: true, sprite: true }, styleSpec: e.spec })));
  47769. }
  47770. }
  47771. class A {
  47772. constructor(t2, i3) {
  47773. this.workerPool = t2, this.actors = [], this.currentActor = 0, this.id = e.uniqueId();
  47774. const o2 = this.workerPool.acquire(this.id);
  47775. for (let e2 = 0; e2 < o2.length; e2++) {
  47776. const t3 = new A.Actor(o2[e2], i3, this.id);
  47777. t3.name = `Worker ${e2}`, this.actors.push(t3);
  47778. }
  47779. this.ready = false, this.broadcast("checkIfReady", null, () => {
  47780. this.ready = true;
  47781. });
  47782. }
  47783. broadcast(t2, i3, o2) {
  47784. e.asyncAll(this.actors, (e2, o3) => {
  47785. e2.send(t2, i3, o3);
  47786. }, o2 = o2 || function() {
  47787. });
  47788. }
  47789. getActor() {
  47790. return this.currentActor = (this.currentActor + 1) % this.actors.length, this.actors[this.currentActor];
  47791. }
  47792. remove() {
  47793. this.actors.forEach((e2) => {
  47794. e2.remove();
  47795. }), this.actors = [], this.workerPool.release(this.id);
  47796. }
  47797. }
  47798. function L(t2, i3, o2) {
  47799. return i3 * (e.EXTENT / (t2.tileSize * Math.pow(2, o2 - t2.tileID.overscaledZ)));
  47800. }
  47801. A.Actor = e.Actor;
  47802. class R {
  47803. constructor(e2, t2, i3, o2) {
  47804. this.screenBounds = e2, this.cameraPoint = t2, this._screenRaycastCache = {}, this._cameraRaycastCache = {}, this.isAboveHorizon = i3, this.screenGeometry = this.bufferedScreenGeometry(0), this.screenGeometryMercator = this.screenGeometry.map((e3) => o2.pointCoordinate3D(e3)), this.cameraGeometry = this.bufferedCameraGeometry(0);
  47805. }
  47806. static createFromScreenPoints(t2, i3) {
  47807. let o2, r2;
  47808. if (t2 instanceof e.pointGeometry || "number" == typeof t2[0]) {
  47809. const n2 = e.pointGeometry.convert(t2);
  47810. o2 = [e.pointGeometry.convert(t2)], r2 = i3.isPointAboveHorizon(n2);
  47811. } else {
  47812. const n2 = e.pointGeometry.convert(t2[0]), a2 = e.pointGeometry.convert(t2[1]);
  47813. o2 = [n2, a2], r2 = e.polygonizeBounds(n2, a2).every((e2) => i3.isPointAboveHorizon(e2));
  47814. }
  47815. return new R(o2, i3.getCameraPoint(), r2, i3);
  47816. }
  47817. isPointQuery() {
  47818. return 1 === this.screenBounds.length;
  47819. }
  47820. bufferedScreenGeometry(t2) {
  47821. return e.polygonizeBounds(this.screenBounds[0], 1 === this.screenBounds.length ? this.screenBounds[0] : this.screenBounds[1], t2);
  47822. }
  47823. bufferedCameraGeometry(t2) {
  47824. const i3 = this.screenBounds[0], o2 = 1 === this.screenBounds.length ? this.screenBounds[0].add(new e.pointGeometry(1, 1)) : this.screenBounds[1], r2 = e.polygonizeBounds(i3, o2, 0, false);
  47825. return this.cameraPoint.y > o2.y && (this.cameraPoint.x > i3.x && this.cameraPoint.x < o2.x ? r2.splice(3, 0, this.cameraPoint) : this.cameraPoint.x >= o2.x ? r2[2] = this.cameraPoint : this.cameraPoint.x <= i3.x && (r2[3] = this.cameraPoint)), e.bufferConvexPolygon(r2, t2);
  47826. }
  47827. containsTile(t2, i3, o2) {
  47828. const r2 = t2.queryPadding + 1, n2 = t2.tileID.wrap, a2 = o2 ? this._bufferedCameraMercator(r2, i3).map((i4) => e.getTilePoint(t2.tileTransform, i4, n2)) : this._bufferedScreenMercator(r2, i3).map((i4) => e.getTilePoint(t2.tileTransform, i4, n2)), s2 = this.screenGeometryMercator.map((i4) => e.getTileVec3(t2.tileTransform, i4, n2)), l2 = s2.map((t3) => new e.pointGeometry(t3[0], t3[1])), c2 = i3.getFreeCameraOptions().position || new e.MercatorCoordinate(0, 0, 0), h2 = e.getTileVec3(t2.tileTransform, c2, n2), _2 = s2.map((t3) => {
  47829. const i4 = e.sub(t3, t3, h2);
  47830. return e.normalize(i4, i4), new e.Ray(h2, i4);
  47831. }), u2 = L(t2, 1, i3.zoom);
  47832. if (e.polygonIntersectsBox(a2, 0, 0, e.EXTENT, e.EXTENT))
  47833. return { queryGeometry: this, tilespaceGeometry: l2, tilespaceRays: _2, bufferedTilespaceGeometry: a2, bufferedTilespaceBounds: (d2 = e.getBounds(a2), d2.min.x = e.clamp(d2.min.x, 0, e.EXTENT), d2.min.y = e.clamp(d2.min.y, 0, e.EXTENT), d2.max.x = e.clamp(d2.max.x, 0, e.EXTENT), d2.max.y = e.clamp(d2.max.y, 0, e.EXTENT), d2), tile: t2, tileID: t2.tileID, pixelToTileUnitsFactor: u2 };
  47834. var d2;
  47835. }
  47836. _bufferedScreenMercator(e2, t2) {
  47837. const i3 = k(e2);
  47838. if (this._screenRaycastCache[i3])
  47839. return this._screenRaycastCache[i3];
  47840. {
  47841. const o2 = this.bufferedScreenGeometry(e2).map((e3) => t2.pointCoordinate3D(e3));
  47842. return this._screenRaycastCache[i3] = o2, o2;
  47843. }
  47844. }
  47845. _bufferedCameraMercator(e2, t2) {
  47846. const i3 = k(e2);
  47847. if (this._cameraRaycastCache[i3])
  47848. return this._cameraRaycastCache[i3];
  47849. {
  47850. const o2 = this.bufferedCameraGeometry(e2).map((e3) => t2.pointCoordinate3D(e3));
  47851. return this._cameraRaycastCache[i3] = o2, o2;
  47852. }
  47853. }
  47854. }
  47855. function k(e2) {
  47856. return 100 * e2 | 0;
  47857. }
  47858. function O(t2, i3, o2) {
  47859. const r2 = function(r3, n2) {
  47860. if (r3)
  47861. return o2(r3);
  47862. if (n2) {
  47863. const r4 = e.pick(e.extend(n2, t2), ["tiles", "minzoom", "maxzoom", "attribution", "mapbox_logo", "bounds", "scheme", "tileSize", "encoding"]);
  47864. n2.vector_layers && (r4.vectorLayers = n2.vector_layers, r4.vectorLayerIds = r4.vectorLayers.map((e2) => e2.id)), r4.tiles = i3.canonicalizeTileset(r4, t2.url), o2(null, r4);
  47865. }
  47866. };
  47867. return t2.url ? e.getJSON(i3.transformRequest(i3.normalizeSourceURL(t2.url), e.ResourceType.Source), r2) : e.exported.frame(() => r2(null, t2));
  47868. }
  47869. class B {
  47870. constructor(t2, i3, o2) {
  47871. this.bounds = e.LngLatBounds.convert(this.validateBounds(t2)), this.minzoom = i3 || 0, this.maxzoom = o2 || 24;
  47872. }
  47873. validateBounds(e2) {
  47874. return Array.isArray(e2) && 4 === e2.length ? [Math.max(-180, e2[0]), Math.max(-90, e2[1]), Math.min(180, e2[2]), Math.min(90, e2[3])] : [-180, -90, 180, 90];
  47875. }
  47876. contains(t2) {
  47877. const i3 = Math.pow(2, t2.z), o2 = Math.floor(e.mercatorXfromLng(this.bounds.getWest()) * i3), r2 = Math.floor(e.mercatorYfromLat(this.bounds.getNorth()) * i3), n2 = Math.ceil(e.mercatorXfromLng(this.bounds.getEast()) * i3), a2 = Math.ceil(e.mercatorYfromLat(this.bounds.getSouth()) * i3);
  47878. return t2.x >= o2 && t2.x < n2 && t2.y >= r2 && t2.y < a2;
  47879. }
  47880. }
  47881. class F {
  47882. constructor(e2, t2, i3) {
  47883. this.context = e2;
  47884. const o2 = e2.gl;
  47885. this.buffer = o2.createBuffer(), this.dynamicDraw = Boolean(i3), this.context.unbindVAO(), e2.bindElementBuffer.set(this.buffer), o2.bufferData(o2.ELEMENT_ARRAY_BUFFER, t2.arrayBuffer, this.dynamicDraw ? o2.DYNAMIC_DRAW : o2.STATIC_DRAW), this.dynamicDraw || t2.destroy();
  47886. }
  47887. bind() {
  47888. this.context.bindElementBuffer.set(this.buffer);
  47889. }
  47890. updateData(e2) {
  47891. const t2 = this.context.gl;
  47892. this.context.unbindVAO(), this.bind(), t2.bufferSubData(t2.ELEMENT_ARRAY_BUFFER, 0, e2.arrayBuffer);
  47893. }
  47894. destroy() {
  47895. this.buffer && (this.context.gl.deleteBuffer(this.buffer), delete this.buffer);
  47896. }
  47897. }
  47898. const U = { Int8: "BYTE", Uint8: "UNSIGNED_BYTE", Int16: "SHORT", Uint16: "UNSIGNED_SHORT", Int32: "INT", Uint32: "UNSIGNED_INT", Float32: "FLOAT" };
  47899. class N {
  47900. constructor(e2, t2, i3, o2) {
  47901. this.length = t2.length, this.attributes = i3, this.itemSize = t2.bytesPerElement, this.dynamicDraw = o2, this.context = e2;
  47902. const r2 = e2.gl;
  47903. this.buffer = r2.createBuffer(), e2.bindVertexBuffer.set(this.buffer), r2.bufferData(r2.ARRAY_BUFFER, t2.arrayBuffer, this.dynamicDraw ? r2.DYNAMIC_DRAW : r2.STATIC_DRAW), this.dynamicDraw || t2.destroy();
  47904. }
  47905. bind() {
  47906. this.context.bindVertexBuffer.set(this.buffer);
  47907. }
  47908. updateData(e2) {
  47909. const t2 = this.context.gl;
  47910. this.bind(), t2.bufferSubData(t2.ARRAY_BUFFER, 0, e2.arrayBuffer);
  47911. }
  47912. enableAttributes(e2, t2) {
  47913. for (let i3 = 0; i3 < this.attributes.length; i3++) {
  47914. const o2 = t2.attributes[this.attributes[i3].name];
  47915. void 0 !== o2 && e2.enableVertexAttribArray(o2);
  47916. }
  47917. }
  47918. setVertexAttribPointers(e2, t2, i3) {
  47919. for (let o2 = 0; o2 < this.attributes.length; o2++) {
  47920. const r2 = this.attributes[o2], n2 = t2.attributes[r2.name];
  47921. void 0 !== n2 && e2.vertexAttribPointer(n2, r2.components, e2[U[r2.type]], false, this.itemSize, r2.offset + this.itemSize * (i3 || 0));
  47922. }
  47923. }
  47924. destroy() {
  47925. this.buffer && (this.context.gl.deleteBuffer(this.buffer), delete this.buffer);
  47926. }
  47927. }
  47928. class G {
  47929. constructor(e2) {
  47930. this.gl = e2.gl, this.default = this.getDefault(), this.current = this.default, this.dirty = false;
  47931. }
  47932. get() {
  47933. return this.current;
  47934. }
  47935. set(e2) {
  47936. }
  47937. getDefault() {
  47938. return this.default;
  47939. }
  47940. setDefault() {
  47941. this.set(this.default);
  47942. }
  47943. }
  47944. class j extends G {
  47945. getDefault() {
  47946. return e.Color.transparent;
  47947. }
  47948. set(e2) {
  47949. const t2 = this.current;
  47950. (e2.r !== t2.r || e2.g !== t2.g || e2.b !== t2.b || e2.a !== t2.a || this.dirty) && (this.gl.clearColor(e2.r, e2.g, e2.b, e2.a), this.current = e2, this.dirty = false);
  47951. }
  47952. }
  47953. class Z extends G {
  47954. getDefault() {
  47955. return 1;
  47956. }
  47957. set(e2) {
  47958. (e2 !== this.current || this.dirty) && (this.gl.clearDepth(e2), this.current = e2, this.dirty = false);
  47959. }
  47960. }
  47961. class V extends G {
  47962. getDefault() {
  47963. return 0;
  47964. }
  47965. set(e2) {
  47966. (e2 !== this.current || this.dirty) && (this.gl.clearStencil(e2), this.current = e2, this.dirty = false);
  47967. }
  47968. }
  47969. class W extends G {
  47970. getDefault() {
  47971. return [true, true, true, true];
  47972. }
  47973. set(e2) {
  47974. const t2 = this.current;
  47975. (e2[0] !== t2[0] || e2[1] !== t2[1] || e2[2] !== t2[2] || e2[3] !== t2[3] || this.dirty) && (this.gl.colorMask(e2[0], e2[1], e2[2], e2[3]), this.current = e2, this.dirty = false);
  47976. }
  47977. }
  47978. class q extends G {
  47979. getDefault() {
  47980. return true;
  47981. }
  47982. set(e2) {
  47983. (e2 !== this.current || this.dirty) && (this.gl.depthMask(e2), this.current = e2, this.dirty = false);
  47984. }
  47985. }
  47986. class X extends G {
  47987. getDefault() {
  47988. return 255;
  47989. }
  47990. set(e2) {
  47991. (e2 !== this.current || this.dirty) && (this.gl.stencilMask(e2), this.current = e2, this.dirty = false);
  47992. }
  47993. }
  47994. class $ extends G {
  47995. getDefault() {
  47996. return { func: this.gl.ALWAYS, ref: 0, mask: 255 };
  47997. }
  47998. set(e2) {
  47999. const t2 = this.current;
  48000. (e2.func !== t2.func || e2.ref !== t2.ref || e2.mask !== t2.mask || this.dirty) && (this.gl.stencilFunc(e2.func, e2.ref, e2.mask), this.current = e2, this.dirty = false);
  48001. }
  48002. }
  48003. class H extends G {
  48004. getDefault() {
  48005. const e2 = this.gl;
  48006. return [e2.KEEP, e2.KEEP, e2.KEEP];
  48007. }
  48008. set(e2) {
  48009. const t2 = this.current;
  48010. (e2[0] !== t2[0] || e2[1] !== t2[1] || e2[2] !== t2[2] || this.dirty) && (this.gl.stencilOp(e2[0], e2[1], e2[2]), this.current = e2, this.dirty = false);
  48011. }
  48012. }
  48013. class K extends G {
  48014. getDefault() {
  48015. return false;
  48016. }
  48017. set(e2) {
  48018. if (e2 === this.current && !this.dirty)
  48019. return;
  48020. const t2 = this.gl;
  48021. e2 ? t2.enable(t2.STENCIL_TEST) : t2.disable(t2.STENCIL_TEST), this.current = e2, this.dirty = false;
  48022. }
  48023. }
  48024. class Y extends G {
  48025. getDefault() {
  48026. return [0, 1];
  48027. }
  48028. set(e2) {
  48029. const t2 = this.current;
  48030. (e2[0] !== t2[0] || e2[1] !== t2[1] || this.dirty) && (this.gl.depthRange(e2[0], e2[1]), this.current = e2, this.dirty = false);
  48031. }
  48032. }
  48033. class J extends G {
  48034. getDefault() {
  48035. return false;
  48036. }
  48037. set(e2) {
  48038. if (e2 === this.current && !this.dirty)
  48039. return;
  48040. const t2 = this.gl;
  48041. e2 ? t2.enable(t2.DEPTH_TEST) : t2.disable(t2.DEPTH_TEST), this.current = e2, this.dirty = false;
  48042. }
  48043. }
  48044. class Q extends G {
  48045. getDefault() {
  48046. return this.gl.LESS;
  48047. }
  48048. set(e2) {
  48049. (e2 !== this.current || this.dirty) && (this.gl.depthFunc(e2), this.current = e2, this.dirty = false);
  48050. }
  48051. }
  48052. class ee extends G {
  48053. getDefault() {
  48054. return false;
  48055. }
  48056. set(e2) {
  48057. if (e2 === this.current && !this.dirty)
  48058. return;
  48059. const t2 = this.gl;
  48060. e2 ? t2.enable(t2.BLEND) : t2.disable(t2.BLEND), this.current = e2, this.dirty = false;
  48061. }
  48062. }
  48063. class te extends G {
  48064. getDefault() {
  48065. const e2 = this.gl;
  48066. return [e2.ONE, e2.ZERO];
  48067. }
  48068. set(e2) {
  48069. const t2 = this.current;
  48070. (e2[0] !== t2[0] || e2[1] !== t2[1] || this.dirty) && (this.gl.blendFunc(e2[0], e2[1]), this.current = e2, this.dirty = false);
  48071. }
  48072. }
  48073. class ie extends G {
  48074. getDefault() {
  48075. return e.Color.transparent;
  48076. }
  48077. set(e2) {
  48078. const t2 = this.current;
  48079. (e2.r !== t2.r || e2.g !== t2.g || e2.b !== t2.b || e2.a !== t2.a || this.dirty) && (this.gl.blendColor(e2.r, e2.g, e2.b, e2.a), this.current = e2, this.dirty = false);
  48080. }
  48081. }
  48082. class oe extends G {
  48083. getDefault() {
  48084. return this.gl.FUNC_ADD;
  48085. }
  48086. set(e2) {
  48087. (e2 !== this.current || this.dirty) && (this.gl.blendEquation(e2), this.current = e2, this.dirty = false);
  48088. }
  48089. }
  48090. class re extends G {
  48091. getDefault() {
  48092. return false;
  48093. }
  48094. set(e2) {
  48095. if (e2 === this.current && !this.dirty)
  48096. return;
  48097. const t2 = this.gl;
  48098. e2 ? t2.enable(t2.CULL_FACE) : t2.disable(t2.CULL_FACE), this.current = e2, this.dirty = false;
  48099. }
  48100. }
  48101. class ne extends G {
  48102. getDefault() {
  48103. return this.gl.BACK;
  48104. }
  48105. set(e2) {
  48106. (e2 !== this.current || this.dirty) && (this.gl.cullFace(e2), this.current = e2, this.dirty = false);
  48107. }
  48108. }
  48109. class ae extends G {
  48110. getDefault() {
  48111. return this.gl.CCW;
  48112. }
  48113. set(e2) {
  48114. (e2 !== this.current || this.dirty) && (this.gl.frontFace(e2), this.current = e2, this.dirty = false);
  48115. }
  48116. }
  48117. class se extends G {
  48118. getDefault() {
  48119. return null;
  48120. }
  48121. set(e2) {
  48122. (e2 !== this.current || this.dirty) && (this.gl.useProgram(e2), this.current = e2, this.dirty = false);
  48123. }
  48124. }
  48125. class le extends G {
  48126. getDefault() {
  48127. return this.gl.TEXTURE0;
  48128. }
  48129. set(e2) {
  48130. (e2 !== this.current || this.dirty) && (this.gl.activeTexture(e2), this.current = e2, this.dirty = false);
  48131. }
  48132. }
  48133. class ce extends G {
  48134. getDefault() {
  48135. const e2 = this.gl;
  48136. return [0, 0, e2.drawingBufferWidth, e2.drawingBufferHeight];
  48137. }
  48138. set(e2) {
  48139. const t2 = this.current;
  48140. (e2[0] !== t2[0] || e2[1] !== t2[1] || e2[2] !== t2[2] || e2[3] !== t2[3] || this.dirty) && (this.gl.viewport(e2[0], e2[1], e2[2], e2[3]), this.current = e2, this.dirty = false);
  48141. }
  48142. }
  48143. class he extends G {
  48144. getDefault() {
  48145. return null;
  48146. }
  48147. set(e2) {
  48148. if (e2 === this.current && !this.dirty)
  48149. return;
  48150. const t2 = this.gl;
  48151. t2.bindFramebuffer(t2.FRAMEBUFFER, e2), this.current = e2, this.dirty = false;
  48152. }
  48153. }
  48154. class _e extends G {
  48155. getDefault() {
  48156. return null;
  48157. }
  48158. set(e2) {
  48159. if (e2 === this.current && !this.dirty)
  48160. return;
  48161. const t2 = this.gl;
  48162. t2.bindRenderbuffer(t2.RENDERBUFFER, e2), this.current = e2, this.dirty = false;
  48163. }
  48164. }
  48165. class ue extends G {
  48166. getDefault() {
  48167. return null;
  48168. }
  48169. set(e2) {
  48170. if (e2 === this.current && !this.dirty)
  48171. return;
  48172. const t2 = this.gl;
  48173. t2.bindTexture(t2.TEXTURE_2D, e2), this.current = e2, this.dirty = false;
  48174. }
  48175. }
  48176. class de extends G {
  48177. getDefault() {
  48178. return null;
  48179. }
  48180. set(e2) {
  48181. if (e2 === this.current && !this.dirty)
  48182. return;
  48183. const t2 = this.gl;
  48184. t2.bindBuffer(t2.ARRAY_BUFFER, e2), this.current = e2, this.dirty = false;
  48185. }
  48186. }
  48187. class pe extends G {
  48188. getDefault() {
  48189. return null;
  48190. }
  48191. set(e2) {
  48192. const t2 = this.gl;
  48193. t2.bindBuffer(t2.ELEMENT_ARRAY_BUFFER, e2), this.current = e2, this.dirty = false;
  48194. }
  48195. }
  48196. class me extends G {
  48197. constructor(e2) {
  48198. super(e2), this.vao = e2.extVertexArrayObject;
  48199. }
  48200. getDefault() {
  48201. return null;
  48202. }
  48203. set(e2) {
  48204. this.vao && (e2 !== this.current || this.dirty) && (this.vao.bindVertexArrayOES(e2), this.current = e2, this.dirty = false);
  48205. }
  48206. }
  48207. class fe extends G {
  48208. getDefault() {
  48209. return 4;
  48210. }
  48211. set(e2) {
  48212. if (e2 === this.current && !this.dirty)
  48213. return;
  48214. const t2 = this.gl;
  48215. t2.pixelStorei(t2.UNPACK_ALIGNMENT, e2), this.current = e2, this.dirty = false;
  48216. }
  48217. }
  48218. class ge extends G {
  48219. getDefault() {
  48220. return false;
  48221. }
  48222. set(e2) {
  48223. if (e2 === this.current && !this.dirty)
  48224. return;
  48225. const t2 = this.gl;
  48226. t2.pixelStorei(t2.UNPACK_PREMULTIPLY_ALPHA_WEBGL, e2), this.current = e2, this.dirty = false;
  48227. }
  48228. }
  48229. class ve extends G {
  48230. getDefault() {
  48231. return false;
  48232. }
  48233. set(e2) {
  48234. if (e2 === this.current && !this.dirty)
  48235. return;
  48236. const t2 = this.gl;
  48237. t2.pixelStorei(t2.UNPACK_FLIP_Y_WEBGL, e2), this.current = e2, this.dirty = false;
  48238. }
  48239. }
  48240. class xe extends G {
  48241. constructor(e2, t2) {
  48242. super(e2), this.context = e2, this.parent = t2;
  48243. }
  48244. getDefault() {
  48245. return null;
  48246. }
  48247. }
  48248. class ye extends xe {
  48249. setDirty() {
  48250. this.dirty = true;
  48251. }
  48252. set(e2) {
  48253. if (e2 === this.current && !this.dirty)
  48254. return;
  48255. this.context.bindFramebuffer.set(this.parent);
  48256. const t2 = this.gl;
  48257. t2.framebufferTexture2D(t2.FRAMEBUFFER, t2.COLOR_ATTACHMENT0, t2.TEXTURE_2D, e2, 0), this.current = e2, this.dirty = false;
  48258. }
  48259. }
  48260. class be extends xe {
  48261. attachment() {
  48262. return this.gl.DEPTH_ATTACHMENT;
  48263. }
  48264. set(e2) {
  48265. if (e2 === this.current && !this.dirty)
  48266. return;
  48267. this.context.bindFramebuffer.set(this.parent);
  48268. const t2 = this.gl;
  48269. t2.framebufferRenderbuffer(t2.FRAMEBUFFER, this.attachment(), t2.RENDERBUFFER, e2), this.current = e2, this.dirty = false;
  48270. }
  48271. }
  48272. class we extends be {
  48273. attachment() {
  48274. return this.gl.DEPTH_STENCIL_ATTACHMENT;
  48275. }
  48276. }
  48277. class Te {
  48278. constructor(e2, t2, i3, o2) {
  48279. this.context = e2, this.width = t2, this.height = i3;
  48280. const r2 = this.framebuffer = e2.gl.createFramebuffer();
  48281. this.colorAttachment = new ye(e2, r2), o2 && (this.depthAttachment = new be(e2, r2));
  48282. }
  48283. destroy() {
  48284. const e2 = this.context.gl, t2 = this.colorAttachment.get();
  48285. if (t2 && e2.deleteTexture(t2), this.depthAttachment) {
  48286. const t3 = this.depthAttachment.get();
  48287. t3 && e2.deleteRenderbuffer(t3);
  48288. }
  48289. e2.deleteFramebuffer(this.framebuffer);
  48290. }
  48291. }
  48292. class Ee {
  48293. constructor(e2) {
  48294. this.gl = e2, this.extVertexArrayObject = this.gl.getExtension("OES_vertex_array_object"), this.clearColor = new j(this), this.clearDepth = new Z(this), this.clearStencil = new V(this), this.colorMask = new W(this), this.depthMask = new q(this), this.stencilMask = new X(this), this.stencilFunc = new $(this), this.stencilOp = new H(this), this.stencilTest = new K(this), this.depthRange = new Y(this), this.depthTest = new J(this), this.depthFunc = new Q(this), this.blend = new ee(this), this.blendFunc = new te(this), this.blendColor = new ie(this), this.blendEquation = new oe(this), this.cullFace = new re(this), this.cullFaceSide = new ne(this), this.frontFace = new ae(this), this.program = new se(this), this.activeTexture = new le(this), this.viewport = new ce(this), this.bindFramebuffer = new he(this), this.bindRenderbuffer = new _e(this), this.bindTexture = new ue(this), this.bindVertexBuffer = new de(this), this.bindElementBuffer = new pe(this), this.bindVertexArrayOES = this.extVertexArrayObject && new me(this), this.pixelStoreUnpack = new fe(this), this.pixelStoreUnpackPremultiplyAlpha = new ge(this), this.pixelStoreUnpackFlipY = new ve(this), this.extTextureFilterAnisotropic = e2.getExtension("EXT_texture_filter_anisotropic") || e2.getExtension("MOZ_EXT_texture_filter_anisotropic") || e2.getExtension("WEBKIT_EXT_texture_filter_anisotropic"), this.extTextureFilterAnisotropic && (this.extTextureFilterAnisotropicMax = e2.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)), this.extTextureFilterAnisotropicForceOff = false, this.extTextureHalfFloat = e2.getExtension("OES_texture_half_float"), this.extTextureHalfFloat && (e2.getExtension("OES_texture_half_float_linear"), this.extRenderToTextureHalfFloat = e2.getExtension("EXT_color_buffer_half_float")), this.extTimerQuery = e2.getExtension("EXT_disjoint_timer_query"), this.maxTextureSize = e2.getParameter(e2.MAX_TEXTURE_SIZE);
  48295. }
  48296. setDefault() {
  48297. this.unbindVAO(), this.clearColor.setDefault(), this.clearDepth.setDefault(), this.clearStencil.setDefault(), this.colorMask.setDefault(), this.depthMask.setDefault(), this.stencilMask.setDefault(), this.stencilFunc.setDefault(), this.stencilOp.setDefault(), this.stencilTest.setDefault(), this.depthRange.setDefault(), this.depthTest.setDefault(), this.depthFunc.setDefault(), this.blend.setDefault(), this.blendFunc.setDefault(), this.blendColor.setDefault(), this.blendEquation.setDefault(), this.cullFace.setDefault(), this.cullFaceSide.setDefault(), this.frontFace.setDefault(), this.program.setDefault(), this.activeTexture.setDefault(), this.bindFramebuffer.setDefault(), this.pixelStoreUnpack.setDefault(), this.pixelStoreUnpackPremultiplyAlpha.setDefault(), this.pixelStoreUnpackFlipY.setDefault();
  48298. }
  48299. setDirty() {
  48300. this.clearColor.dirty = true, this.clearDepth.dirty = true, this.clearStencil.dirty = true, this.colorMask.dirty = true, this.depthMask.dirty = true, this.stencilMask.dirty = true, this.stencilFunc.dirty = true, this.stencilOp.dirty = true, this.stencilTest.dirty = true, this.depthRange.dirty = true, this.depthTest.dirty = true, this.depthFunc.dirty = true, this.blend.dirty = true, this.blendFunc.dirty = true, this.blendColor.dirty = true, this.blendEquation.dirty = true, this.cullFace.dirty = true, this.cullFaceSide.dirty = true, this.frontFace.dirty = true, this.program.dirty = true, this.activeTexture.dirty = true, this.viewport.dirty = true, this.bindFramebuffer.dirty = true, this.bindRenderbuffer.dirty = true, this.bindTexture.dirty = true, this.bindVertexBuffer.dirty = true, this.bindElementBuffer.dirty = true, this.extVertexArrayObject && (this.bindVertexArrayOES.dirty = true), this.pixelStoreUnpack.dirty = true, this.pixelStoreUnpackPremultiplyAlpha.dirty = true, this.pixelStoreUnpackFlipY.dirty = true;
  48301. }
  48302. createIndexBuffer(e2, t2) {
  48303. return new F(this, e2, t2);
  48304. }
  48305. createVertexBuffer(e2, t2, i3) {
  48306. return new N(this, e2, t2, i3);
  48307. }
  48308. createRenderbuffer(e2, t2, i3) {
  48309. const o2 = this.gl, r2 = o2.createRenderbuffer();
  48310. return this.bindRenderbuffer.set(r2), o2.renderbufferStorage(o2.RENDERBUFFER, e2, t2, i3), this.bindRenderbuffer.set(null), r2;
  48311. }
  48312. createFramebuffer(e2, t2, i3) {
  48313. return new Te(this, e2, t2, i3);
  48314. }
  48315. clear({ color: e2, depth: t2, stencil: i3 }) {
  48316. const o2 = this.gl;
  48317. let r2 = 0;
  48318. e2 && (r2 |= o2.COLOR_BUFFER_BIT, this.clearColor.set(e2), this.colorMask.set([true, true, true, true])), void 0 !== t2 && (r2 |= o2.DEPTH_BUFFER_BIT, this.depthRange.set([0, 1]), this.clearDepth.set(t2), this.depthMask.set(true)), void 0 !== i3 && (r2 |= o2.STENCIL_BUFFER_BIT, this.clearStencil.set(i3), this.stencilMask.set(255)), o2.clear(r2);
  48319. }
  48320. setCullFace(e2) {
  48321. false === e2.enable ? this.cullFace.set(false) : (this.cullFace.set(true), this.cullFaceSide.set(e2.mode), this.frontFace.set(e2.frontFace));
  48322. }
  48323. setDepthMode(e2) {
  48324. e2.func !== this.gl.ALWAYS || e2.mask ? (this.depthTest.set(true), this.depthFunc.set(e2.func), this.depthMask.set(e2.mask), this.depthRange.set(e2.range)) : this.depthTest.set(false);
  48325. }
  48326. setStencilMode(e2) {
  48327. e2.test.func !== this.gl.ALWAYS || e2.mask ? (this.stencilTest.set(true), this.stencilMask.set(e2.mask), this.stencilOp.set([e2.fail, e2.depthFail, e2.pass]), this.stencilFunc.set({ func: e2.test.func, ref: e2.ref, mask: e2.test.mask })) : this.stencilTest.set(false);
  48328. }
  48329. setColorMode(t2) {
  48330. r(t2.blendFunction, e.ColorMode.Replace) ? this.blend.set(false) : (this.blend.set(true), this.blendFunc.set(t2.blendFunction), this.blendColor.set(t2.blendColor)), this.colorMask.set(t2.mask);
  48331. }
  48332. unbindVAO() {
  48333. this.extVertexArrayObject && this.bindVertexArrayOES.set(null);
  48334. }
  48335. }
  48336. class Ce extends e.Evented {
  48337. constructor(t2, i3, o2, r2) {
  48338. super(), this.id = t2, this.dispatcher = o2, this.setEventedParent(r2), this.type = "raster", this.minzoom = 0, this.maxzoom = 22, this.roundZoom = true, this.scheme = "xyz", this.tileSize = 512, this._loaded = false, this._options = e.extend({ type: "raster" }, i3), e.extend(this, e.pick(i3, ["url", "scheme", "tileSize"]));
  48339. }
  48340. load() {
  48341. this._loaded = false, this.fire(new e.Event("dataloading", { dataType: "source" })), this._tileJSONRequest = O(this._options, this.map._requestManager, (t2, i3) => {
  48342. this._tileJSONRequest = null, this._loaded = true, t2 ? this.fire(new e.ErrorEvent(t2)) : i3 && (e.extend(this, i3), i3.bounds && (this.tileBounds = new B(i3.bounds, this.minzoom, this.maxzoom)), e.postTurnstileEvent(i3.tiles), this.fire(new e.Event("data", { dataType: "source", sourceDataType: "metadata" })), this.fire(new e.Event("data", { dataType: "source", sourceDataType: "content" })));
  48343. });
  48344. }
  48345. loaded() {
  48346. return this._loaded;
  48347. }
  48348. onAdd(e2) {
  48349. this.map = e2, this.load();
  48350. }
  48351. onRemove() {
  48352. this._tileJSONRequest && (this._tileJSONRequest.cancel(), this._tileJSONRequest = null);
  48353. }
  48354. serialize() {
  48355. return e.extend({}, this._options);
  48356. }
  48357. hasTile(e2) {
  48358. return !this.tileBounds || this.tileBounds.contains(e2.canonical);
  48359. }
  48360. loadTile(t2, i3) {
  48361. const o2 = e.exported.devicePixelRatio >= 2, r2 = this.map._requestManager.normalizeTileURL(t2.tileID.canonical.url(this.tiles, this.scheme), o2, this.tileSize);
  48362. t2.request = e.getImage(this.map._requestManager.transformRequest(r2, e.ResourceType.Tile), (o3, r3, n2, a2) => (delete t2.request, t2.aborted ? (t2.state = "unloaded", i3(null)) : o3 ? (t2.state = "errored", i3(o3)) : r3 ? (this.map._refreshExpiredTiles && t2.setExpiryData({ cacheControl: n2, expires: a2 }), t2.setTexture(r3, this.map.painter), t2.state = "loaded", e.cacheEntryPossiblyAdded(this.dispatcher), void i3(null)) : i3(null)));
  48363. }
  48364. static loadTileData(e2, t2, i3) {
  48365. e2.setTexture(t2, i3);
  48366. }
  48367. static unloadTileData(e2, t2) {
  48368. e2.texture && t2.saveTileTexture(e2.texture);
  48369. }
  48370. abortTile(e2, t2) {
  48371. e2.request && (e2.request.cancel(), delete e2.request), t2();
  48372. }
  48373. unloadTile(e2, t2) {
  48374. e2.texture && this.map.painter.saveTileTexture(e2.texture), t2();
  48375. }
  48376. hasTransition() {
  48377. return false;
  48378. }
  48379. }
  48380. let Ie;
  48381. function Me(t2, i3, o2, r2, n2, a2, s2, l2) {
  48382. const c2 = [t2, o2, n2, i3, r2, a2, 1, 1, 1], h2 = [s2, l2, 1], _2 = e.adjoint([], c2), [u2, d2, p2] = e.transformMat3(h2, h2, e.transpose(_2, _2));
  48383. return e.multiply(c2, [u2, 0, 0, 0, d2, 0, 0, 0, p2], c2);
  48384. }
  48385. class Se extends e.Evented {
  48386. constructor(e2, t2, i3, o2) {
  48387. super(), this.id = e2, this.dispatcher = i3, this.coordinates = t2.coordinates, this.type = "image", this.minzoom = 0, this.maxzoom = 22, this.tileSize = 512, this.tiles = {}, this._loaded = false, this.setEventedParent(o2), this.options = t2;
  48388. }
  48389. load(t2) {
  48390. this._loaded = false, this.fire(new e.Event("dataloading", { dataType: "source" })), this.url = this.options.url, e.getImage(this.map._requestManager.transformRequest(this.url, e.ResourceType.Image), (i3, o2) => {
  48391. if (this._loaded = true, i3)
  48392. this.fire(new e.ErrorEvent(i3));
  48393. else if (o2) {
  48394. const { HTMLImageElement: i4 } = e.window;
  48395. this.image = o2 instanceof i4 ? e.exported.getImageData(o2) : o2, this.width = this.image.width, this.height = this.image.height, t2 && (this.coordinates = t2), this._finishLoading();
  48396. }
  48397. });
  48398. }
  48399. loaded() {
  48400. return this._loaded;
  48401. }
  48402. updateImage(e2) {
  48403. return this.image && e2.url ? (this.options.url = e2.url, this.load(e2.coordinates), this) : this;
  48404. }
  48405. _finishLoading() {
  48406. this.map && (this.setCoordinates(this.coordinates), this.fire(new e.Event("data", { dataType: "source", sourceDataType: "metadata" })));
  48407. }
  48408. onAdd(e2) {
  48409. this.map = e2, this.load();
  48410. }
  48411. onRemove() {
  48412. this.texture && this.texture.destroy();
  48413. }
  48414. setCoordinates(t2) {
  48415. this.coordinates = t2, this._boundsArray = void 0;
  48416. const i3 = t2.map(e.MercatorCoordinate.fromLngLat);
  48417. return this.tileID = function(t3) {
  48418. let i4 = 1 / 0, o2 = 1 / 0, r2 = -1 / 0, n2 = -1 / 0;
  48419. for (const e2 of t3)
  48420. i4 = Math.min(i4, e2.x), o2 = Math.min(o2, e2.y), r2 = Math.max(r2, e2.x), n2 = Math.max(n2, e2.y);
  48421. const a2 = Math.max(r2 - i4, n2 - o2), s2 = Math.max(0, Math.floor(-Math.log(a2) / Math.LN2)), l2 = Math.pow(2, s2);
  48422. return new e.CanonicalTileID(s2, Math.floor((i4 + r2) / 2 * l2), Math.floor((o2 + n2) / 2 * l2));
  48423. }(i3), this.minzoom = this.maxzoom = this.tileID.z, this.fire(new e.Event("data", { dataType: "source", sourceDataType: "content" })), this;
  48424. }
  48425. _clear() {
  48426. this._boundsArray = void 0;
  48427. }
  48428. _prepareData(t2) {
  48429. for (const e2 in this.tiles) {
  48430. const t3 = this.tiles[e2];
  48431. "loaded" !== t3.state && (t3.state = "loaded", t3.texture = this.texture);
  48432. }
  48433. if (this._boundsArray)
  48434. return;
  48435. const i3 = e.tileTransform(this.tileID, this.map.transform.projection), [o2, r2, n2, a2] = this.coordinates.map((t3) => {
  48436. const o3 = i3.projection.project(t3[0], t3[1]);
  48437. return e.getTilePoint(i3, o3)._round();
  48438. });
  48439. this.perspectiveTransform = function(t3, i4, o3, r3, n3, a3, s3, l2, c2, h2) {
  48440. const _2 = Me(0, 0, t3, 0, 0, i4, t3, i4), u2 = Me(o3, r3, n3, a3, s3, l2, c2, h2);
  48441. return e.multiply(u2, e.adjoint(_2, _2), u2), [u2[6] / u2[8] * t3 / e.EXTENT, u2[7] / u2[8] * i4 / e.EXTENT];
  48442. }(this.width, this.height, o2.x, o2.y, r2.x, r2.y, a2.x, a2.y, n2.x, n2.y);
  48443. const s2 = this._boundsArray = new e.StructArrayLayout4i8();
  48444. s2.emplaceBack(o2.x, o2.y, 0, 0), s2.emplaceBack(r2.x, r2.y, e.EXTENT, 0), s2.emplaceBack(a2.x, a2.y, 0, e.EXTENT), s2.emplaceBack(n2.x, n2.y, e.EXTENT, e.EXTENT), this.boundsBuffer && this.boundsBuffer.destroy(), this.boundsBuffer = t2.createVertexBuffer(s2, e.boundsAttributes.members), this.boundsSegments = e.SegmentVector.simpleSegment(0, 0, 4, 2);
  48445. }
  48446. prepare() {
  48447. if (0 === Object.keys(this.tiles).length || !this.image)
  48448. return;
  48449. const t2 = this.map.painter.context, i3 = t2.gl;
  48450. this.texture ? this.texture.update(this.image) : (this.texture = new e.Texture(t2, this.image, i3.RGBA), this.texture.bind(i3.LINEAR, i3.CLAMP_TO_EDGE)), this._prepareData(t2);
  48451. }
  48452. loadTile(e2, t2) {
  48453. this.tileID && this.tileID.equals(e2.tileID.canonical) ? (this.tiles[String(e2.tileID.wrap)] = e2, e2.buckets = {}, t2(null)) : (e2.state = "errored", t2(null));
  48454. }
  48455. serialize() {
  48456. return { type: "image", url: this.options.url, coordinates: this.coordinates };
  48457. }
  48458. hasTransition() {
  48459. return false;
  48460. }
  48461. }
  48462. const ze = { vector: class extends e.Evented {
  48463. constructor(t2, i3, o2, r2) {
  48464. if (super(), this.id = t2, this.dispatcher = o2, this.type = "vector", this.minzoom = 0, this.maxzoom = 22, this.scheme = "xyz", this.tileSize = 512, this.reparseOverscaled = true, this.isTileClipped = true, this._loaded = false, e.extend(this, e.pick(i3, ["url", "scheme", "tileSize", "promoteId"])), this._options = e.extend({ type: "vector" }, i3), this._collectResourceTiming = i3.collectResourceTiming, 512 !== this.tileSize)
  48465. throw new Error("vector tile sources must have a tileSize of 512");
  48466. this.setEventedParent(r2), this._tileWorkers = {}, this._deduped = new e.DedupedRequest();
  48467. }
  48468. load() {
  48469. this._loaded = false, this.fire(new e.Event("dataloading", { dataType: "source" })), this._tileJSONRequest = O(this._options, this.map._requestManager, (t2, i3) => {
  48470. this._tileJSONRequest = null, this._loaded = true, t2 ? this.fire(new e.ErrorEvent(t2)) : i3 && (e.extend(this, i3), i3.bounds && (this.tileBounds = new B(i3.bounds, this.minzoom, this.maxzoom)), e.postTurnstileEvent(i3.tiles, this.map._requestManager._customAccessToken), this.fire(new e.Event("data", { dataType: "source", sourceDataType: "metadata" })), this.fire(new e.Event("data", { dataType: "source", sourceDataType: "content" })));
  48471. });
  48472. }
  48473. loaded() {
  48474. return this._loaded;
  48475. }
  48476. hasTile(e2) {
  48477. return !this.tileBounds || this.tileBounds.contains(e2.canonical);
  48478. }
  48479. onAdd(e2) {
  48480. this.map = e2, this.load();
  48481. }
  48482. setSourceProperty(e2) {
  48483. this._tileJSONRequest && this._tileJSONRequest.cancel(), e2();
  48484. const t2 = this.map.style._getSourceCaches(this.id);
  48485. for (const e3 of t2)
  48486. e3.clearTiles();
  48487. this.load();
  48488. }
  48489. setTiles(e2) {
  48490. return this.setSourceProperty(() => {
  48491. this._options.tiles = e2;
  48492. }), this;
  48493. }
  48494. setUrl(e2) {
  48495. return this.setSourceProperty(() => {
  48496. this.url = e2, this._options.url = e2;
  48497. }), this;
  48498. }
  48499. onRemove() {
  48500. this._tileJSONRequest && (this._tileJSONRequest.cancel(), this._tileJSONRequest = null);
  48501. }
  48502. serialize() {
  48503. return e.extend({}, this._options);
  48504. }
  48505. loadTile(t2, i3) {
  48506. const o2 = this.map._requestManager.normalizeTileURL(t2.tileID.canonical.url(this.tiles, this.scheme)), r2 = { request: this.map._requestManager.transformRequest(o2, e.ResourceType.Tile), data: void 0, uid: t2.uid, tileID: t2.tileID, tileZoom: t2.tileZoom, zoom: t2.tileID.overscaledZ, tileSize: this.tileSize * t2.tileID.overscaleFactor(), type: this.type, source: this.id, pixelRatio: e.exported.devicePixelRatio, showCollisionBoxes: this.map.showCollisionBoxes, promoteId: this.promoteId, isSymbolTile: t2.isSymbolTile };
  48507. if (r2.request.collectResourceTiming = this._collectResourceTiming, t2.actor && "expired" !== t2.state)
  48508. "loading" === t2.state ? t2.reloadCallback = i3 : t2.request = t2.actor.send("reloadTile", r2, n2.bind(this));
  48509. else if (t2.actor = this._tileWorkers[o2] = this._tileWorkers[o2] || this.dispatcher.getActor(), this.dispatcher.ready)
  48510. t2.request = t2.actor.send("loadTile", r2, n2.bind(this), void 0, true);
  48511. else {
  48512. const i4 = e.loadVectorTile.call({ deduped: this._deduped }, r2, (e2, i5) => {
  48513. e2 || !i5 ? n2.call(this, e2) : (r2.data = { cacheControl: i5.cacheControl, expires: i5.expires, rawData: i5.rawData.slice(0) }, t2.actor && t2.actor.send("loadTile", r2, n2.bind(this), void 0, true));
  48514. }, true);
  48515. t2.request = { cancel: i4 };
  48516. }
  48517. function n2(o3, r3) {
  48518. return delete t2.request, t2.aborted ? i3(null) : o3 && 404 !== o3.status ? i3(o3) : (r3 && r3.resourceTiming && (t2.resourceTiming = r3.resourceTiming), this.map._refreshExpiredTiles && r3 && t2.setExpiryData(r3), t2.loadVectorData(r3, this.map.painter), e.cacheEntryPossiblyAdded(this.dispatcher), i3(null), void (t2.reloadCallback && (this.loadTile(t2, t2.reloadCallback), t2.reloadCallback = null)));
  48519. }
  48520. }
  48521. abortTile(e2) {
  48522. e2.request && (e2.request.cancel(), delete e2.request), e2.actor && e2.actor.send("abortTile", { uid: e2.uid, type: this.type, source: this.id });
  48523. }
  48524. unloadTile(e2) {
  48525. e2.unloadVectorData(), e2.actor && e2.actor.send("removeTile", { uid: e2.uid, type: this.type, source: this.id });
  48526. }
  48527. hasTransition() {
  48528. return false;
  48529. }
  48530. afterUpdate() {
  48531. this._tileWorkers = {};
  48532. }
  48533. }, raster: Ce, "raster-dem": class extends Ce {
  48534. constructor(t2, i3, o2, r2) {
  48535. super(t2, i3, o2, r2), this.type = "raster-dem", this.maxzoom = 22, this._options = e.extend({ type: "raster-dem" }, i3), this.encoding = i3.encoding || "mapbox";
  48536. }
  48537. loadTile(t2, i3) {
  48538. const o2 = this.map._requestManager.normalizeTileURL(t2.tileID.canonical.url(this.tiles, this.scheme), false, this.tileSize);
  48539. function r2(e2, o3) {
  48540. e2 && (t2.state = "errored", i3(e2)), o3 && (t2.dem = o3, t2.dem.onDeserialize(), t2.needsHillshadePrepare = true, t2.needsDEMTextureUpload = true, t2.state = "loaded", i3(null));
  48541. }
  48542. t2.request = e.getImage(this.map._requestManager.transformRequest(o2, e.ResourceType.Tile), function(o3, n2, a2, s2) {
  48543. if (delete t2.request, t2.aborted)
  48544. t2.state = "unloaded", i3(null);
  48545. else if (o3)
  48546. t2.state = "errored", i3(o3);
  48547. else if (n2) {
  48548. this.map._refreshExpiredTiles && t2.setExpiryData({ cacheControl: a2, expires: s2 });
  48549. const i4 = e.window.ImageBitmap && n2 instanceof e.window.ImageBitmap && (null == Ie && (Ie = e.window.OffscreenCanvas && new e.window.OffscreenCanvas(1, 1).getContext("2d") && "function" == typeof e.window.createImageBitmap), Ie), o4 = 1 - (n2.width - e.prevPowerOfTwo(n2.width)) / 2;
  48550. o4 < 1 || t2.neighboringTiles || (t2.neighboringTiles = this._getNeighboringTiles(t2.tileID));
  48551. const l2 = i4 ? n2 : e.exported.getImageData(n2, o4), c2 = { uid: t2.uid, coord: t2.tileID, source: this.id, rawImageData: l2, encoding: this.encoding, padding: o4 };
  48552. t2.actor && "expired" !== t2.state || (t2.actor = this.dispatcher.getActor(), t2.actor.send("loadDEMTile", c2, r2.bind(this), void 0, true));
  48553. }
  48554. }.bind(this));
  48555. }
  48556. _getNeighboringTiles(t2) {
  48557. const i3 = t2.canonical, o2 = Math.pow(2, i3.z), r2 = (i3.x - 1 + o2) % o2, n2 = 0 === i3.x ? t2.wrap - 1 : t2.wrap, a2 = (i3.x + 1 + o2) % o2, s2 = i3.x + 1 === o2 ? t2.wrap + 1 : t2.wrap, l2 = {};
  48558. return l2[new e.OverscaledTileID(t2.overscaledZ, n2, i3.z, r2, i3.y).key] = { backfilled: false }, l2[new e.OverscaledTileID(t2.overscaledZ, s2, i3.z, a2, i3.y).key] = { backfilled: false }, i3.y > 0 && (l2[new e.OverscaledTileID(t2.overscaledZ, n2, i3.z, r2, i3.y - 1).key] = { backfilled: false }, l2[new e.OverscaledTileID(t2.overscaledZ, t2.wrap, i3.z, i3.x, i3.y - 1).key] = { backfilled: false }, l2[new e.OverscaledTileID(t2.overscaledZ, s2, i3.z, a2, i3.y - 1).key] = { backfilled: false }), i3.y + 1 < o2 && (l2[new e.OverscaledTileID(t2.overscaledZ, n2, i3.z, r2, i3.y + 1).key] = { backfilled: false }, l2[new e.OverscaledTileID(t2.overscaledZ, t2.wrap, i3.z, i3.x, i3.y + 1).key] = { backfilled: false }, l2[new e.OverscaledTileID(t2.overscaledZ, s2, i3.z, a2, i3.y + 1).key] = { backfilled: false }), l2;
  48559. }
  48560. unloadTile(e2) {
  48561. e2.demTexture && this.map.painter.saveTileTexture(e2.demTexture), e2.fbo && (e2.fbo.destroy(), delete e2.fbo), e2.dem && delete e2.dem, delete e2.neighboringTiles, e2.state = "unloaded";
  48562. }
  48563. }, geojson: class extends e.Evented {
  48564. constructor(t2, i3, o2, r2) {
  48565. super(), this.id = t2, this.type = "geojson", this.minzoom = 0, this.maxzoom = 18, this.tileSize = 512, this.isTileClipped = true, this.reparseOverscaled = true, this._loaded = false, this.actor = o2.getActor(), this.setEventedParent(r2), this._data = i3.data, this._options = e.extend({}, i3), this._collectResourceTiming = i3.collectResourceTiming, void 0 !== i3.maxzoom && (this.maxzoom = i3.maxzoom), i3.type && (this.type = i3.type), i3.attribution && (this.attribution = i3.attribution), this.promoteId = i3.promoteId;
  48566. const n2 = e.EXTENT / this.tileSize;
  48567. this.workerOptions = e.extend({ source: this.id, cluster: i3.cluster || false, geojsonVtOptions: { buffer: (void 0 !== i3.buffer ? i3.buffer : 128) * n2, tolerance: (void 0 !== i3.tolerance ? i3.tolerance : 0.375) * n2, extent: e.EXTENT, maxZoom: this.maxzoom, lineMetrics: i3.lineMetrics || false, generateId: i3.generateId || false }, superclusterOptions: { maxZoom: void 0 !== i3.clusterMaxZoom ? i3.clusterMaxZoom : this.maxzoom - 1, minPoints: Math.max(2, i3.clusterMinPoints || 2), extent: e.EXTENT, radius: (void 0 !== i3.clusterRadius ? i3.clusterRadius : 50) * n2, log: false, generateId: i3.generateId || false }, clusterProperties: i3.clusterProperties, filter: i3.filter }, i3.workerOptions);
  48568. }
  48569. onAdd(e2) {
  48570. this.map = e2, this.setData(this._data);
  48571. }
  48572. setData(e2) {
  48573. return this._data = e2, this._updateWorkerData(), this;
  48574. }
  48575. getClusterExpansionZoom(e2, t2) {
  48576. return this.actor.send("geojson.getClusterExpansionZoom", { clusterId: e2, source: this.id }, t2), this;
  48577. }
  48578. getClusterChildren(e2, t2) {
  48579. return this.actor.send("geojson.getClusterChildren", { clusterId: e2, source: this.id }, t2), this;
  48580. }
  48581. getClusterLeaves(e2, t2, i3, o2) {
  48582. return this.actor.send("geojson.getClusterLeaves", { source: this.id, clusterId: e2, limit: t2, offset: i3 }, o2), this;
  48583. }
  48584. _updateWorkerData() {
  48585. if (this._pendingLoad)
  48586. return void (this._coalesce = true);
  48587. this.fire(new e.Event("dataloading", { dataType: "source" })), this._loaded = false;
  48588. const t2 = e.extend({}, this.workerOptions), i3 = this._data;
  48589. "string" == typeof i3 ? (t2.request = this.map._requestManager.transformRequest(e.exported.resolveURL(i3), e.ResourceType.Source), t2.request.collectResourceTiming = this._collectResourceTiming) : t2.data = JSON.stringify(i3), this._pendingLoad = this.actor.send(`${this.type}.loadData`, t2, (t3, i4) => {
  48590. if (this._loaded = true, this._pendingLoad = null, t3)
  48591. this.fire(new e.ErrorEvent(t3));
  48592. else {
  48593. const t4 = { dataType: "source", sourceDataType: this._metadataFired ? "content" : "metadata" };
  48594. this._collectResourceTiming && i4 && i4.resourceTiming && i4.resourceTiming[this.id] && (t4.resourceTiming = i4.resourceTiming[this.id]), this.fire(new e.Event("data", t4)), this._metadataFired = true;
  48595. }
  48596. this._coalesce && (this._updateWorkerData(), this._coalesce = false);
  48597. });
  48598. }
  48599. loaded() {
  48600. return this._loaded;
  48601. }
  48602. loadTile(t2, i3) {
  48603. const o2 = t2.actor ? "reloadTile" : "loadTile";
  48604. t2.actor = this.actor, t2.request = this.actor.send(o2, { type: this.type, uid: t2.uid, tileID: t2.tileID, tileZoom: t2.tileZoom, zoom: t2.tileID.overscaledZ, maxZoom: this.maxzoom, tileSize: this.tileSize, source: this.id, pixelRatio: e.exported.devicePixelRatio, showCollisionBoxes: this.map.showCollisionBoxes, promoteId: this.promoteId }, (e2, r2) => (delete t2.request, t2.unloadVectorData(), t2.aborted ? i3(null) : e2 ? i3(e2) : (t2.loadVectorData(r2, this.map.painter, "reloadTile" === o2), i3(null))), void 0, "loadTile" === o2);
  48605. }
  48606. abortTile(e2) {
  48607. e2.request && (e2.request.cancel(), delete e2.request), e2.aborted = true;
  48608. }
  48609. unloadTile(e2) {
  48610. e2.unloadVectorData(), this.actor.send("removeTile", { uid: e2.uid, type: this.type, source: this.id });
  48611. }
  48612. onRemove() {
  48613. this._pendingLoad && this._pendingLoad.cancel();
  48614. }
  48615. serialize() {
  48616. return e.extend({}, this._options, { type: this.type, data: this._data });
  48617. }
  48618. hasTransition() {
  48619. return false;
  48620. }
  48621. }, video: class extends Se {
  48622. constructor(e2, t2, i3, o2) {
  48623. super(e2, t2, i3, o2), this.roundZoom = true, this.type = "video", this.options = t2;
  48624. }
  48625. load() {
  48626. this._loaded = false;
  48627. const t2 = this.options;
  48628. this.urls = [];
  48629. for (const i3 of t2.urls)
  48630. this.urls.push(this.map._requestManager.transformRequest(i3, e.ResourceType.Source).url);
  48631. e.getVideo(this.urls, (t3, i3) => {
  48632. this._loaded = true, t3 ? this.fire(new e.ErrorEvent(t3)) : i3 && (this.video = i3, this.video.loop = true, this.video.setAttribute("playsinline", ""), this.video.addEventListener("playing", () => {
  48633. this.map.triggerRepaint();
  48634. }), this.map && this.video.play(), this._finishLoading());
  48635. });
  48636. }
  48637. pause() {
  48638. this.video && this.video.pause();
  48639. }
  48640. play() {
  48641. this.video && this.video.play();
  48642. }
  48643. seek(t2) {
  48644. if (this.video) {
  48645. const i3 = this.video.seekable;
  48646. t2 < i3.start(0) || t2 > i3.end(0) ? this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${this.id}`, null, `Playback for this video can be set only between the ${i3.start(0)} and ${i3.end(0)}-second mark.`))) : this.video.currentTime = t2;
  48647. }
  48648. }
  48649. getVideo() {
  48650. return this.video;
  48651. }
  48652. onAdd(e2) {
  48653. this.map || (this.map = e2, this.load(), this.video && (this.video.play(), this.setCoordinates(this.coordinates)));
  48654. }
  48655. prepare() {
  48656. if (0 === Object.keys(this.tiles).length || this.video.readyState < 2)
  48657. return;
  48658. const t2 = this.map.painter.context, i3 = t2.gl;
  48659. this.texture ? this.video.paused || (this.texture.bind(i3.LINEAR, i3.CLAMP_TO_EDGE), i3.texSubImage2D(i3.TEXTURE_2D, 0, 0, 0, i3.RGBA, i3.UNSIGNED_BYTE, this.video)) : (this.texture = new e.Texture(t2, this.video, i3.RGBA), this.texture.bind(i3.LINEAR, i3.CLAMP_TO_EDGE), this.width = this.video.videoWidth, this.height = this.video.videoHeight), this._prepareData(t2);
  48660. }
  48661. serialize() {
  48662. return { type: "video", urls: this.urls, coordinates: this.coordinates };
  48663. }
  48664. hasTransition() {
  48665. return this.video && !this.video.paused;
  48666. }
  48667. }, image: Se, canvas: class extends Se {
  48668. constructor(t2, i3, o2, r2) {
  48669. super(t2, i3, o2, r2), i3.coordinates ? Array.isArray(i3.coordinates) && 4 === i3.coordinates.length && !i3.coordinates.some((e2) => !Array.isArray(e2) || 2 !== e2.length || e2.some((e3) => "number" != typeof e3)) || this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t2}`, null, '"coordinates" property must be an array of 4 longitude/latitude array pairs'))) : this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t2}`, null, 'missing required property "coordinates"'))), i3.animate && "boolean" != typeof i3.animate && this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t2}`, null, 'optional "animate" property must be a boolean value'))), i3.canvas ? "string" == typeof i3.canvas || i3.canvas instanceof e.window.HTMLCanvasElement || this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t2}`, null, '"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))) : this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t2}`, null, 'missing required property "canvas"'))), this.options = i3, this.animate = void 0 === i3.animate || i3.animate;
  48670. }
  48671. load() {
  48672. this._loaded = true, this.canvas || (this.canvas = this.options.canvas instanceof e.window.HTMLCanvasElement ? this.options.canvas : e.window.document.getElementById(this.options.canvas)), this.width = this.canvas.width, this.height = this.canvas.height, this._hasInvalidDimensions() ? this.fire(new e.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))) : (this.play = function() {
  48673. this._playing = true, this.map.triggerRepaint();
  48674. }, this.pause = function() {
  48675. this._playing && (this.prepare(), this._playing = false);
  48676. }, this._finishLoading());
  48677. }
  48678. getCanvas() {
  48679. return this.canvas;
  48680. }
  48681. onAdd(e2) {
  48682. this.map = e2, this.load(), this.canvas && this.animate && this.play();
  48683. }
  48684. onRemove() {
  48685. this.pause();
  48686. }
  48687. prepare() {
  48688. let t2 = false;
  48689. if (this.canvas.width !== this.width && (this.width = this.canvas.width, t2 = true), this.canvas.height !== this.height && (this.height = this.canvas.height, t2 = true), this._hasInvalidDimensions())
  48690. return;
  48691. if (0 === Object.keys(this.tiles).length)
  48692. return;
  48693. const i3 = this.map.painter.context;
  48694. this.texture ? (t2 || this._playing) && this.texture.update(this.canvas, { premultiply: true }) : this.texture = new e.Texture(i3, this.canvas, i3.gl.RGBA, { premultiply: true }), this._prepareData(i3);
  48695. }
  48696. serialize() {
  48697. return { type: "canvas", coordinates: this.coordinates };
  48698. }
  48699. hasTransition() {
  48700. return this._playing;
  48701. }
  48702. _hasInvalidDimensions() {
  48703. for (const e2 of [this.canvas.width, this.canvas.height])
  48704. if (isNaN(e2) || e2 <= 0)
  48705. return true;
  48706. return false;
  48707. }
  48708. }, custom: class extends e.Evented {
  48709. constructor(t2, i3, o2, r2) {
  48710. super(), this.id = t2, this.type = "custom", this._dataType = "raster", this._dispatcher = o2, this._implementation = i3, this.setEventedParent(r2), this.scheme = "xyz", this.minzoom = 0, this.maxzoom = 22, this.tileSize = 512, this._loaded = false, this.roundZoom = true, this._implementation || this.fire(new e.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))), this._implementation.loadTile || this.fire(new e.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))), this._implementation.bounds && (this.tileBounds = new B(this._implementation.bounds, this.minzoom, this.maxzoom)), i3.update = this._update.bind(this), i3.coveringTiles = this._coveringTiles.bind(this), e.extend(this, e.pick(i3, ["dataType", "scheme", "minzoom", "maxzoom", "tileSize", "attribution", "minTileCacheSize", "maxTileCacheSize"]));
  48711. }
  48712. serialize() {
  48713. return e.pick(this, ["type", "scheme", "minzoom", "maxzoom", "tileSize", "attribution"]);
  48714. }
  48715. load() {
  48716. this._loaded = true, this.fire(new e.Event("data", { dataType: "source", sourceDataType: "metadata" })), this.fire(new e.Event("data", { dataType: "source", sourceDataType: "content" }));
  48717. }
  48718. loaded() {
  48719. return this._loaded;
  48720. }
  48721. onAdd(t2) {
  48722. this._map = t2, this._loaded = false, this.fire(new e.Event("dataloading", { dataType: "source" })), this._implementation.onAdd && this._implementation.onAdd(t2), this.load();
  48723. }
  48724. onRemove(e2) {
  48725. this._implementation.onRemove && this._implementation.onRemove(e2);
  48726. }
  48727. hasTile(e2) {
  48728. if (this._implementation.hasTile) {
  48729. const { x: t2, y: i3, z: o2 } = e2.canonical;
  48730. return this._implementation.hasTile({ x: t2, y: i3, z: o2 });
  48731. }
  48732. return !this.tileBounds || this.tileBounds.contains(e2.canonical);
  48733. }
  48734. loadTile(t2, i3) {
  48735. const { x: o2, y: r2, z: n2 } = t2.tileID.canonical, a2 = new e.window.AbortController(), s2 = this._implementation.loadTile({ x: o2, y: r2, z: n2 }, { signal: a2.signal });
  48736. if (!s2)
  48737. return this.loadTileData(t2, { width: this.tileSize, height: this.tileSize, data: null }), t2.state = "loaded", i3(null);
  48738. s2.cancel = () => a2.abort(), t2.request = s2.then(function(o3) {
  48739. return delete t2.request, t2.aborted ? (t2.state = "unloaded", i3(null)) : o3 ? function(t3) {
  48740. return t3 instanceof e.window.ImageData || t3 instanceof e.window.ImageBitmap || t3 instanceof e.window.HTMLCanvasElement;
  48741. }(o3) ? (this.loadTileData(t2, o3), t2.state = "loaded", void i3(null)) : (t2.state = "errored", i3(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`))) : (this.loadTileData(t2, { width: this.tileSize, height: this.tileSize, data: null }), t2.state = "loaded", i3(null));
  48742. }.bind(this)).catch((e2) => {
  48743. 20 !== e2.code && (t2.state = "errored", i3(e2));
  48744. });
  48745. }
  48746. loadTileData(e2, t2) {
  48747. Ce.loadTileData(e2, t2, this._map.painter);
  48748. }
  48749. unloadTileData(e2) {
  48750. Ce.unloadTileData(e2, this._map.painter);
  48751. }
  48752. prepareTile(e2) {
  48753. if (!this._implementation.prepareTile)
  48754. return null;
  48755. const { x: t2, y: i3, z: o2 } = e2.tileID.canonical, r2 = this._implementation.prepareTile({ x: t2, y: i3, z: o2 });
  48756. return r2 ? (this.loadTileData(e2, r2), e2.state = "loaded", r2) : null;
  48757. }
  48758. unloadTile(e2, t2) {
  48759. if (this.unloadTileData(e2), this._implementation.unloadTile) {
  48760. const { x: t3, y: i3, z: o2 } = e2.tileID.canonical;
  48761. this._implementation.unloadTile({ x: t3, y: i3, z: o2 });
  48762. }
  48763. t2();
  48764. }
  48765. abortTile(e2, t2) {
  48766. e2.request && e2.request.cancel && (e2.request.cancel(), delete e2.request), t2();
  48767. }
  48768. hasTransition() {
  48769. return false;
  48770. }
  48771. _coveringTiles() {
  48772. return this._map.transform.coveringTiles({ tileSize: this.tileSize, minzoom: this.minzoom, maxzoom: this.maxzoom, roundZoom: this.roundZoom }).map((e2) => ({ x: e2.canonical.x, y: e2.canonical.y, z: e2.canonical.z }));
  48773. }
  48774. _update() {
  48775. this.fire(new e.Event("data", { dataType: "source", sourceDataType: "content" }));
  48776. }
  48777. } }, De = function(t2, i3, o2, r2) {
  48778. const n2 = new ze[i3.type](t2, i3, o2, r2);
  48779. if (n2.id !== t2)
  48780. throw new Error(`Expected Source id to be ${t2} instead of ${n2.id}`);
  48781. return e.bindAll(["load", "abort", "unload", "serialize", "prepare"], n2), n2;
  48782. };
  48783. function Pe(t2, i3) {
  48784. const o2 = e.identity([]);
  48785. return e.scale(o2, o2, [0.5 * t2.width, 0.5 * -t2.height, 1]), e.translate(o2, o2, [1, -1, 0]), e.multiply$1(o2, o2, t2.calculateProjMatrix(i3.toUnwrapped())), Float32Array.from(o2);
  48786. }
  48787. function Ae(e2, t2, i3, o2, r2, n2, a2, s2 = false) {
  48788. const l2 = e2.tilesIn(o2, a2, s2);
  48789. l2.sort(Re);
  48790. const c2 = [];
  48791. for (const o3 of l2)
  48792. c2.push({ wrappedTileID: o3.tile.tileID.wrapped().key, queryResults: o3.tile.queryRenderedFeatures(t2, i3, e2._state, o3, r2, n2, Pe(e2.transform, o3.tile.tileID), s2) });
  48793. const h2 = function(e3) {
  48794. const t3 = {}, i4 = {};
  48795. for (const o3 of e3) {
  48796. const e4 = o3.queryResults, r3 = o3.wrappedTileID, n3 = i4[r3] = i4[r3] || {};
  48797. for (const i5 in e4) {
  48798. const o4 = e4[i5], r4 = n3[i5] = n3[i5] || {}, a3 = t3[i5] = t3[i5] || [];
  48799. for (const e5 of o4)
  48800. r4[e5.featureIndex] || (r4[e5.featureIndex] = true, a3.push(e5));
  48801. }
  48802. }
  48803. return t3;
  48804. }(c2);
  48805. for (const t3 in h2)
  48806. h2[t3].forEach((t4) => {
  48807. const i4 = t4.feature, o3 = i4.layer;
  48808. o3 && "background" !== o3.type && "sky" !== o3.type && (i4.source = o3.source, o3["source-layer"] && (i4.sourceLayer = o3["source-layer"]), i4.state = void 0 !== i4.id ? e2.getFeatureState(o3["source-layer"], i4.id) : {});
  48809. });
  48810. return h2;
  48811. }
  48812. function Le(e2, t2) {
  48813. const i3 = e2.getRenderableIds().map((t3) => e2.getTileByID(t3)), o2 = [], r2 = {};
  48814. for (let e3 = 0; e3 < i3.length; e3++) {
  48815. const n2 = i3[e3], a2 = n2.tileID.canonical.key;
  48816. r2[a2] || (r2[a2] = true, n2.querySourceFeatures(o2, t2));
  48817. }
  48818. return o2;
  48819. }
  48820. function Re(e2, t2) {
  48821. const i3 = e2.tileID, o2 = t2.tileID;
  48822. return i3.overscaledZ - o2.overscaledZ || i3.canonical.y - o2.canonical.y || i3.wrap - o2.wrap || i3.canonical.x - o2.canonical.x;
  48823. }
  48824. function ke() {
  48825. return null != ln.workerClass ? new ln.workerClass() : new e.window.Worker(ln.workerUrl);
  48826. }
  48827. const Oe = "mapboxgl_preloaded_worker_pool";
  48828. class Be {
  48829. constructor() {
  48830. this.active = {};
  48831. }
  48832. acquire(e2) {
  48833. if (!this.workers)
  48834. for (this.workers = []; this.workers.length < Be.workerCount; )
  48835. this.workers.push(new ke());
  48836. return this.active[e2] = true, this.workers.slice();
  48837. }
  48838. release(e2) {
  48839. delete this.active[e2], 0 === this.numActive() && (this.workers.forEach((e3) => {
  48840. e3.terminate();
  48841. }), this.workers = null);
  48842. }
  48843. isPreloaded() {
  48844. return !!this.active[Oe];
  48845. }
  48846. numActive() {
  48847. return Object.keys(this.active).length;
  48848. }
  48849. }
  48850. let Fe;
  48851. function Ue() {
  48852. return Fe || (Fe = new Be()), Fe;
  48853. }
  48854. function Ne(t2, i3) {
  48855. const o2 = {};
  48856. for (const e2 in t2)
  48857. "ref" !== e2 && (o2[e2] = t2[e2]);
  48858. return e.refProperties.forEach((e2) => {
  48859. e2 in i3 && (o2[e2] = i3[e2]);
  48860. }), o2;
  48861. }
  48862. function Ge(e2) {
  48863. e2 = e2.slice();
  48864. const t2 = /* @__PURE__ */ Object.create(null);
  48865. for (let i3 = 0; i3 < e2.length; i3++)
  48866. t2[e2[i3].id] = e2[i3];
  48867. for (let i3 = 0; i3 < e2.length; i3++)
  48868. "ref" in e2[i3] && (e2[i3] = Ne(e2[i3], t2[e2[i3].ref]));
  48869. return e2;
  48870. }
  48871. Be.workerCount = 2;
  48872. const je = { setStyle: "setStyle", addLayer: "addLayer", removeLayer: "removeLayer", setPaintProperty: "setPaintProperty", setLayoutProperty: "setLayoutProperty", setFilter: "setFilter", addSource: "addSource", removeSource: "removeSource", setGeoJSONSourceData: "setGeoJSONSourceData", setLayerZoomRange: "setLayerZoomRange", setLayerProperty: "setLayerProperty", setCenter: "setCenter", setZoom: "setZoom", setBearing: "setBearing", setPitch: "setPitch", setSprite: "setSprite", setGlyphs: "setGlyphs", setTransition: "setTransition", setLight: "setLight", setTerrain: "setTerrain", setFog: "setFog", setProjection: "setProjection" };
  48873. function Ze(e2, t2, i3) {
  48874. i3.push({ command: je.addSource, args: [e2, t2[e2]] });
  48875. }
  48876. function Ve(e2, t2, i3) {
  48877. t2.push({ command: je.removeSource, args: [e2] }), i3[e2] = true;
  48878. }
  48879. function We(e2, t2, i3, o2) {
  48880. Ve(e2, i3, o2), Ze(e2, t2, i3);
  48881. }
  48882. function qe(e2, t2, i3) {
  48883. let o2;
  48884. for (o2 in e2[i3])
  48885. if (e2[i3].hasOwnProperty(o2) && "data" !== o2 && !r(e2[i3][o2], t2[i3][o2]))
  48886. return false;
  48887. for (o2 in t2[i3])
  48888. if (t2[i3].hasOwnProperty(o2) && "data" !== o2 && !r(e2[i3][o2], t2[i3][o2]))
  48889. return false;
  48890. return true;
  48891. }
  48892. function Xe(e2, t2, i3, o2, n2, a2) {
  48893. let s2;
  48894. for (s2 in t2 = t2 || {}, e2 = e2 || {})
  48895. e2.hasOwnProperty(s2) && (r(e2[s2], t2[s2]) || i3.push({ command: a2, args: [o2, s2, t2[s2], n2] }));
  48896. for (s2 in t2)
  48897. t2.hasOwnProperty(s2) && !e2.hasOwnProperty(s2) && (r(e2[s2], t2[s2]) || i3.push({ command: a2, args: [o2, s2, t2[s2], n2] }));
  48898. }
  48899. function $e(e2) {
  48900. return e2.id;
  48901. }
  48902. function He(e2, t2) {
  48903. return e2[t2.id] = t2, e2;
  48904. }
  48905. class Ke {
  48906. constructor(e2, t2) {
  48907. this.reset(e2, t2);
  48908. }
  48909. reset(e2, t2) {
  48910. this.points = e2 || [], this._distances = [0];
  48911. for (let e3 = 1; e3 < this.points.length; e3++)
  48912. this._distances[e3] = this._distances[e3 - 1] + this.points[e3].dist(this.points[e3 - 1]);
  48913. this.length = this._distances[this._distances.length - 1], this.padding = Math.min(t2 || 0, 0.5 * this.length), this.paddedLength = this.length - 2 * this.padding;
  48914. }
  48915. lerp(t2) {
  48916. if (1 === this.points.length)
  48917. return this.points[0];
  48918. t2 = e.clamp(t2, 0, 1);
  48919. let i3 = 1, o2 = this._distances[i3];
  48920. const r2 = t2 * this.paddedLength + this.padding;
  48921. for (; o2 < r2 && i3 < this._distances.length; )
  48922. o2 = this._distances[++i3];
  48923. const n2 = i3 - 1, a2 = this._distances[n2], s2 = o2 - a2, l2 = s2 > 0 ? (r2 - a2) / s2 : 0;
  48924. return this.points[n2].mult(1 - l2).add(this.points[i3].mult(l2));
  48925. }
  48926. }
  48927. class Ye {
  48928. constructor(e2, t2, i3) {
  48929. const o2 = this.boxCells = [], r2 = this.circleCells = [];
  48930. this.xCellCount = Math.ceil(e2 / i3), this.yCellCount = Math.ceil(t2 / i3);
  48931. for (let e3 = 0; e3 < this.xCellCount * this.yCellCount; e3++)
  48932. o2.push([]), r2.push([]);
  48933. this.circleKeys = [], this.boxKeys = [], this.bboxes = [], this.circles = [], this.width = e2, this.height = t2, this.xScale = this.xCellCount / e2, this.yScale = this.yCellCount / t2, this.boxUid = 0, this.circleUid = 0;
  48934. }
  48935. keysLength() {
  48936. return this.boxKeys.length + this.circleKeys.length;
  48937. }
  48938. insert(e2, t2, i3, o2, r2) {
  48939. this._forEachCell(t2, i3, o2, r2, this._insertBoxCell, this.boxUid++), this.boxKeys.push(e2), this.bboxes.push(t2), this.bboxes.push(i3), this.bboxes.push(o2), this.bboxes.push(r2);
  48940. }
  48941. insertCircle(e2, t2, i3, o2) {
  48942. this._forEachCell(t2 - o2, i3 - o2, t2 + o2, i3 + o2, this._insertCircleCell, this.circleUid++), this.circleKeys.push(e2), this.circles.push(t2), this.circles.push(i3), this.circles.push(o2);
  48943. }
  48944. _insertBoxCell(e2, t2, i3, o2, r2, n2) {
  48945. this.boxCells[r2].push(n2);
  48946. }
  48947. _insertCircleCell(e2, t2, i3, o2, r2, n2) {
  48948. this.circleCells[r2].push(n2);
  48949. }
  48950. _query(e2, t2, i3, o2, r2, n2) {
  48951. if (i3 < 0 || e2 > this.width || o2 < 0 || t2 > this.height)
  48952. return !r2 && [];
  48953. const a2 = [];
  48954. if (e2 <= 0 && t2 <= 0 && this.width <= i3 && this.height <= o2) {
  48955. if (r2)
  48956. return true;
  48957. for (let e3 = 0; e3 < this.boxKeys.length; e3++)
  48958. a2.push({ key: this.boxKeys[e3], x1: this.bboxes[4 * e3], y1: this.bboxes[4 * e3 + 1], x2: this.bboxes[4 * e3 + 2], y2: this.bboxes[4 * e3 + 3] });
  48959. for (let e3 = 0; e3 < this.circleKeys.length; e3++) {
  48960. const t3 = this.circles[3 * e3], i4 = this.circles[3 * e3 + 1], o3 = this.circles[3 * e3 + 2];
  48961. a2.push({ key: this.circleKeys[e3], x1: t3 - o3, y1: i4 - o3, x2: t3 + o3, y2: i4 + o3 });
  48962. }
  48963. return n2 ? a2.filter(n2) : a2;
  48964. }
  48965. return this._forEachCell(e2, t2, i3, o2, this._queryCell, a2, { hitTest: r2, seenUids: { box: {}, circle: {} } }, n2), r2 ? a2.length > 0 : a2;
  48966. }
  48967. _queryCircle(e2, t2, i3, o2, r2) {
  48968. const n2 = e2 - i3, a2 = e2 + i3, s2 = t2 - i3, l2 = t2 + i3;
  48969. if (a2 < 0 || n2 > this.width || l2 < 0 || s2 > this.height)
  48970. return !o2 && [];
  48971. const c2 = [];
  48972. return this._forEachCell(n2, s2, a2, l2, this._queryCellCircle, c2, { hitTest: o2, circle: { x: e2, y: t2, radius: i3 }, seenUids: { box: {}, circle: {} } }, r2), o2 ? c2.length > 0 : c2;
  48973. }
  48974. query(e2, t2, i3, o2, r2) {
  48975. return this._query(e2, t2, i3, o2, false, r2);
  48976. }
  48977. hitTest(e2, t2, i3, o2, r2) {
  48978. return this._query(e2, t2, i3, o2, true, r2);
  48979. }
  48980. hitTestCircle(e2, t2, i3, o2) {
  48981. return this._queryCircle(e2, t2, i3, true, o2);
  48982. }
  48983. _queryCell(e2, t2, i3, o2, r2, n2, a2, s2) {
  48984. const l2 = a2.seenUids, c2 = this.boxCells[r2];
  48985. if (null !== c2) {
  48986. const r3 = this.bboxes;
  48987. for (const h3 of c2)
  48988. if (!l2.box[h3]) {
  48989. l2.box[h3] = true;
  48990. const c3 = 4 * h3;
  48991. if (e2 <= r3[c3 + 2] && t2 <= r3[c3 + 3] && i3 >= r3[c3 + 0] && o2 >= r3[c3 + 1] && (!s2 || s2(this.boxKeys[h3]))) {
  48992. if (a2.hitTest)
  48993. return n2.push(true), true;
  48994. n2.push({ key: this.boxKeys[h3], x1: r3[c3], y1: r3[c3 + 1], x2: r3[c3 + 2], y2: r3[c3 + 3] });
  48995. }
  48996. }
  48997. }
  48998. const h2 = this.circleCells[r2];
  48999. if (null !== h2) {
  49000. const r3 = this.circles;
  49001. for (const c3 of h2)
  49002. if (!l2.circle[c3]) {
  49003. l2.circle[c3] = true;
  49004. const h3 = 3 * c3;
  49005. if (this._circleAndRectCollide(r3[h3], r3[h3 + 1], r3[h3 + 2], e2, t2, i3, o2) && (!s2 || s2(this.circleKeys[c3]))) {
  49006. if (a2.hitTest)
  49007. return n2.push(true), true;
  49008. {
  49009. const e3 = r3[h3], t3 = r3[h3 + 1], i4 = r3[h3 + 2];
  49010. n2.push({ key: this.circleKeys[c3], x1: e3 - i4, y1: t3 - i4, x2: e3 + i4, y2: t3 + i4 });
  49011. }
  49012. }
  49013. }
  49014. }
  49015. }
  49016. _queryCellCircle(e2, t2, i3, o2, r2, n2, a2, s2) {
  49017. const l2 = a2.circle, c2 = a2.seenUids, h2 = this.boxCells[r2];
  49018. if (null !== h2) {
  49019. const e3 = this.bboxes;
  49020. for (const t3 of h2)
  49021. if (!c2.box[t3]) {
  49022. c2.box[t3] = true;
  49023. const i4 = 4 * t3;
  49024. if (this._circleAndRectCollide(l2.x, l2.y, l2.radius, e3[i4 + 0], e3[i4 + 1], e3[i4 + 2], e3[i4 + 3]) && (!s2 || s2(this.boxKeys[t3])))
  49025. return n2.push(true), true;
  49026. }
  49027. }
  49028. const _2 = this.circleCells[r2];
  49029. if (null !== _2) {
  49030. const e3 = this.circles;
  49031. for (const t3 of _2)
  49032. if (!c2.circle[t3]) {
  49033. c2.circle[t3] = true;
  49034. const i4 = 3 * t3;
  49035. if (this._circlesCollide(e3[i4], e3[i4 + 1], e3[i4 + 2], l2.x, l2.y, l2.radius) && (!s2 || s2(this.circleKeys[t3])))
  49036. return n2.push(true), true;
  49037. }
  49038. }
  49039. }
  49040. _forEachCell(e2, t2, i3, o2, r2, n2, a2, s2) {
  49041. const l2 = this._convertToXCellCoord(e2), c2 = this._convertToYCellCoord(t2), h2 = this._convertToXCellCoord(i3), _2 = this._convertToYCellCoord(o2);
  49042. for (let u2 = l2; u2 <= h2; u2++)
  49043. for (let l3 = c2; l3 <= _2; l3++)
  49044. if (r2.call(this, e2, t2, i3, o2, this.xCellCount * l3 + u2, n2, a2, s2))
  49045. return;
  49046. }
  49047. _convertToXCellCoord(e2) {
  49048. return Math.max(0, Math.min(this.xCellCount - 1, Math.floor(e2 * this.xScale)));
  49049. }
  49050. _convertToYCellCoord(e2) {
  49051. return Math.max(0, Math.min(this.yCellCount - 1, Math.floor(e2 * this.yScale)));
  49052. }
  49053. _circlesCollide(e2, t2, i3, o2, r2, n2) {
  49054. const a2 = o2 - e2, s2 = r2 - t2, l2 = i3 + n2;
  49055. return l2 * l2 > a2 * a2 + s2 * s2;
  49056. }
  49057. _circleAndRectCollide(e2, t2, i3, o2, r2, n2, a2) {
  49058. const s2 = (n2 - o2) / 2, l2 = Math.abs(e2 - (o2 + s2));
  49059. if (l2 > s2 + i3)
  49060. return false;
  49061. const c2 = (a2 - r2) / 2, h2 = Math.abs(t2 - (r2 + c2));
  49062. if (h2 > c2 + i3)
  49063. return false;
  49064. if (l2 <= s2 || h2 <= c2)
  49065. return true;
  49066. const _2 = l2 - s2, u2 = h2 - c2;
  49067. return _2 * _2 + u2 * u2 <= i3 * i3;
  49068. }
  49069. }
  49070. const Je = Math.tan(85 * Math.PI / 180);
  49071. function Qe(t2, i3, o2, r2, n2, a2) {
  49072. const s2 = e.create();
  49073. if (o2) {
  49074. if ("globe" === n2.projection.name)
  49075. e.multiply$1(s2, s2, e.calculateGlobeLabelMatrix(n2, i3));
  49076. else {
  49077. const e2 = v([], a2);
  49078. s2[0] = e2[0], s2[1] = e2[1], s2[4] = e2[2], s2[5] = e2[3];
  49079. }
  49080. r2 || e.rotateZ(s2, s2, n2.angle);
  49081. } else
  49082. e.multiply$1(s2, n2.labelPlaneMatrix, t2);
  49083. return s2;
  49084. }
  49085. function et(t2, i3, o2, r2, n2, a2) {
  49086. if (o2) {
  49087. if ("globe" === n2.projection.name) {
  49088. const s2 = Qe(t2, i3, o2, r2, n2, a2);
  49089. return e.invert(s2, s2), e.multiply$1(s2, t2, s2), s2;
  49090. }
  49091. {
  49092. const i4 = e.clone(t2), o3 = e.identity([]);
  49093. return o3[0] = a2[0], o3[1] = a2[1], o3[4] = a2[2], o3[5] = a2[3], e.multiply$1(i4, i4, o3), r2 || e.rotateZ(i4, i4, -n2.angle), i4;
  49094. }
  49095. }
  49096. return n2.glCoordMatrix;
  49097. }
  49098. function tt(t2, i3, o2 = 0) {
  49099. const r2 = [t2.x, t2.y, o2, 1];
  49100. o2 ? e.transformMat4$1(r2, r2, i3) : pt(r2, r2, i3);
  49101. const n2 = r2[3];
  49102. return { point: new e.pointGeometry(r2[0] / n2, r2[1] / n2), signedDistanceFromCamera: n2 };
  49103. }
  49104. function it(t2, i3) {
  49105. const o2 = [t2[0], t2[1], t2[2], 1];
  49106. e.transformMat4$1(o2, o2, i3);
  49107. const r2 = o2[3];
  49108. return { point: new e.pointGeometry(o2[0] / r2, o2[1] / r2), signedDistanceFromCamera: r2 };
  49109. }
  49110. function ot(e2, t2) {
  49111. return Math.min(0.5 + e2 / t2 * 0.5, 1.5);
  49112. }
  49113. function rt(e2, t2) {
  49114. const i3 = e2[0] / e2[3], o2 = e2[1] / e2[3];
  49115. return i3 >= -t2[0] && i3 <= t2[0] && o2 >= -t2[1] && o2 <= t2[1];
  49116. }
  49117. function nt(t2, i3, o2, r2, n2, a2, s2, l2, c2, h2) {
  49118. const _2 = o2.transform, u2 = r2 ? t2.textSizeData : t2.iconSizeData, d2 = e.evaluateSizeForZoom(u2, o2.transform.zoom), p2 = [256 / o2.width * 2 + 1, 256 / o2.height * 2 + 1], m2 = r2 ? t2.text.dynamicLayoutVertexArray : t2.icon.dynamicLayoutVertexArray;
  49119. m2.clear();
  49120. const f2 = t2.lineVertexArray, g2 = r2 ? t2.text.placedSymbolArray : t2.icon.placedSymbolArray, v2 = o2.transform.width / o2.transform.height;
  49121. let x2 = false;
  49122. for (let r3 = 0; r3 < g2.length; r3++) {
  49123. const y2 = g2.get(r3);
  49124. if (y2.writingMode !== e.WritingMode.vertical || x2 || 0 !== r3 && g2.get(r3 - 1).writingMode === e.WritingMode.horizontal || (x2 = true), (y2.hidden || y2.writingMode === e.WritingMode.vertical) && !x2) {
  49125. dt(y2.numGlyphs, m2);
  49126. continue;
  49127. }
  49128. x2 = false;
  49129. const b2 = new e.pointGeometry(y2.tileAnchorX, y2.tileAnchorY), w2 = c2 ? c2(b2) : [0, 0, 0], T2 = _2.projection.projectTilePoint(b2.x, b2.y, h2.canonical), E2 = [T2.x + w2[0], T2.y + w2[1], T2.z + w2[2]], C2 = [...E2, 1];
  49130. if (e.transformMat4$1(C2, C2, i3), !rt(C2, p2)) {
  49131. dt(y2.numGlyphs, m2);
  49132. continue;
  49133. }
  49134. const I2 = ot(o2.transform.cameraToCenterDistance, C2[3]), M2 = e.evaluateSizeForFeature(u2, d2, y2), S2 = s2 ? M2 / I2 : M2 * I2, z2 = tt(new e.pointGeometry(E2[0], E2[1]), n2, E2[2]);
  49135. if (z2.signedDistanceFromCamera <= 0) {
  49136. dt(y2.numGlyphs, m2);
  49137. continue;
  49138. }
  49139. let D2 = {};
  49140. const P2 = s2 ? null : c2, A2 = lt(y2, S2, false, l2, i3, n2, a2, t2.glyphOffsetArray, f2, m2, z2.point, b2, D2, v2, P2, _2.projection, h2);
  49141. x2 = A2.useVertical, P2 && A2.needsFlipping && (D2 = {}), (A2.notEnoughRoom || x2 || A2.needsFlipping && lt(y2, S2, true, l2, i3, n2, a2, t2.glyphOffsetArray, f2, m2, z2.point, b2, D2, v2, P2, _2.projection, h2).notEnoughRoom) && dt(y2.numGlyphs, m2);
  49142. }
  49143. r2 ? t2.text.dynamicLayoutVertexBuffer.updateData(m2) : t2.icon.dynamicLayoutVertexBuffer.updateData(m2);
  49144. }
  49145. function at(e2, t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2, d2, p2) {
  49146. const m2 = s2.glyphStartIndex + s2.numGlyphs, f2 = s2.lineStartIndex, g2 = s2.lineStartIndex + s2.lineLength, v2 = t2.getoffsetX(s2.glyphStartIndex), x2 = t2.getoffsetX(m2 - 1), y2 = _t(e2 * v2, i3, o2, r2, n2, a2, s2.segment, f2, g2, l2, c2, h2, _2, u2, true, d2, p2);
  49147. if (!y2)
  49148. return null;
  49149. const b2 = _t(e2 * x2, i3, o2, r2, n2, a2, s2.segment, f2, g2, l2, c2, h2, _2, u2, true, d2, p2);
  49150. return b2 ? { first: y2, last: b2 } : null;
  49151. }
  49152. function st(t2, i3, o2, r2) {
  49153. return t2.writingMode === e.WritingMode.horizontal && Math.abs(o2.y - i3.y) > Math.abs(o2.x - i3.x) * r2 ? { useVertical: true } : t2.writingMode === e.WritingMode.vertical ? i3.y < o2.y ? { needsFlipping: true } : null : 0 !== t2.flipState && function(e2, t3, i4) {
  49154. const o3 = (t3.x - e2.x) * i4;
  49155. return 0 === o3 || Math.abs((t3.y - e2.y) / o3) > Je;
  49156. }(i3, o2, r2) ? 1 === t2.flipState ? { needsFlipping: true } : null : i3.x > o2.x ? { needsFlipping: true } : null;
  49157. }
  49158. function lt(t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2, d2, p2, m2, f2, g2) {
  49159. const v2 = i3 / 24, x2 = t2.lineOffsetX * v2, y2 = t2.lineOffsetY * v2;
  49160. let b2;
  49161. if (t2.numGlyphs > 1) {
  49162. const e2 = t2.glyphStartIndex + t2.numGlyphs, i4 = t2.lineStartIndex, n3 = t2.lineStartIndex + t2.lineLength, h3 = at(v2, l2, x2, y2, o2, _2, u2, t2, c2, a2, d2, m2, false, f2, g2);
  49163. if (!h3)
  49164. return { notEnoughRoom: true };
  49165. const w2 = tt(h3.first.point, s2).point, T2 = tt(h3.last.point, s2).point;
  49166. if (r2 && !o2) {
  49167. const e3 = st(t2, w2, T2, p2);
  49168. if (t2.flipState = e3 && e3.needsFlipping ? 1 : 2, e3)
  49169. return e3;
  49170. }
  49171. b2 = [h3.first];
  49172. for (let r3 = t2.glyphStartIndex + 1; r3 < e2 - 1; r3++)
  49173. b2.push(_t(v2 * l2.getoffsetX(r3), x2, y2, o2, _2, u2, t2.segment, i4, n3, c2, a2, d2, m2, false, false, f2, g2));
  49174. b2.push(h3.last);
  49175. } else {
  49176. if (r2 && !o2) {
  49177. const i5 = tt(u2, n2).point, o3 = t2.lineStartIndex + t2.segment + 1, r3 = new e.pointGeometry(c2.getx(o3), c2.gety(o3)), a3 = tt(r3, n2), s3 = st(t2, i5, a3.signedDistanceFromCamera > 0 ? a3.point : ht(u2, r3, i5, 1, n2, void 0, f2, g2.canonical), p2);
  49178. if (t2.flipState = s3 && s3.needsFlipping ? 1 : 2, s3)
  49179. return s3;
  49180. }
  49181. const i4 = _t(v2 * l2.getoffsetX(t2.glyphStartIndex), x2, y2, o2, _2, u2, t2.segment, t2.lineStartIndex, t2.lineStartIndex + t2.lineLength, c2, a2, d2, m2, false, false, f2, g2);
  49182. if (!i4)
  49183. return { notEnoughRoom: true };
  49184. b2 = [i4];
  49185. }
  49186. for (const t3 of b2)
  49187. e.addDynamicAttributes(h2, t3.point, t3.angle);
  49188. return {};
  49189. }
  49190. function ct(t2, i3, o2, r2, n2) {
  49191. const a2 = r2.projectTilePoint(t2.x, t2.y, i3);
  49192. if (!n2)
  49193. return tt(a2, o2, a2.z);
  49194. const s2 = n2(t2);
  49195. return tt(new e.pointGeometry(a2.x + s2[0], a2.y + s2[1]), o2, a2.z + s2[2]);
  49196. }
  49197. function ht(e2, t2, i3, o2, r2, n2, a2, s2) {
  49198. const l2 = ct(e2.add(e2.sub(t2)._unit()), s2, r2, a2, n2).point, c2 = i3.sub(l2);
  49199. return i3.add(c2._mult(o2 / c2.mag()));
  49200. }
  49201. function _t(t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2, d2, p2, m2, f2, g2) {
  49202. const v2 = r2 ? t2 - i3 : t2 + i3;
  49203. let x2 = v2 > 0 ? 1 : -1, y2 = 0;
  49204. r2 && (x2 *= -1, y2 = Math.PI), x2 < 0 && (y2 += Math.PI);
  49205. let b2 = x2 > 0 ? l2 + s2 : l2 + s2 + 1, w2 = n2, T2 = n2, E2 = 0, C2 = 0;
  49206. const I2 = Math.abs(v2), M2 = [], S2 = [];
  49207. let z2 = a2;
  49208. const D2 = () => {
  49209. const t3 = b2 - x2;
  49210. return 0 === E2 ? a2 : new e.pointGeometry(h2.getx(t3), h2.gety(t3));
  49211. }, P2 = () => ht(D2(), z2, T2, I2 - E2 + 1, _2, d2, f2, g2.canonical);
  49212. for (; E2 + C2 <= I2; ) {
  49213. if (b2 += x2, b2 < l2 || b2 >= c2)
  49214. return null;
  49215. if (T2 = w2, M2.push(w2), p2 && S2.push(z2 || D2()), w2 = u2[b2], void 0 === w2) {
  49216. z2 = new e.pointGeometry(h2.getx(b2), h2.gety(b2));
  49217. const t3 = ct(z2, g2.canonical, _2, f2, d2);
  49218. w2 = t3.signedDistanceFromCamera > 0 ? u2[b2] = t3.point : P2();
  49219. } else
  49220. z2 = null;
  49221. E2 += C2, C2 = T2.dist(w2);
  49222. }
  49223. m2 && d2 && (z2 = z2 || new e.pointGeometry(h2.getx(b2), h2.gety(b2)), u2[b2] = w2 = void 0 === u2[b2] ? w2 : P2(), C2 = T2.dist(w2));
  49224. const A2 = (I2 - E2) / C2, L2 = w2.sub(T2), R2 = L2.mult(A2)._add(T2);
  49225. o2 && R2._add(L2._unit()._perp()._mult(o2 * x2));
  49226. const k2 = y2 + Math.atan2(w2.y - T2.y, w2.x - T2.x);
  49227. return M2.push(R2), p2 && (z2 = z2 || new e.pointGeometry(h2.getx(b2), h2.gety(b2)), S2.push(function(t3, i4, o3) {
  49228. const r3 = 1 - o3;
  49229. return new e.pointGeometry(t3.x * r3 + i4.x * o3, t3.y * r3 + i4.y * o3);
  49230. }(S2.length > 0 ? S2[S2.length - 1] : z2, z2, A2))), { point: R2, angle: k2, path: M2, tilePath: S2 };
  49231. }
  49232. const ut = new Float32Array([-1 / 0, -1 / 0, 0, -1 / 0, -1 / 0, 0, -1 / 0, -1 / 0, 0, -1 / 0, -1 / 0, 0]);
  49233. function dt(e2, t2) {
  49234. for (let i3 = 0; i3 < e2; i3++) {
  49235. const e3 = t2.length;
  49236. t2.resize(e3 + 4), t2.float32.set(ut, 3 * e3);
  49237. }
  49238. }
  49239. function pt(e2, t2, i3) {
  49240. const o2 = t2[0], r2 = t2[1];
  49241. return e2[0] = i3[0] * o2 + i3[4] * r2 + i3[12], e2[1] = i3[1] * o2 + i3[5] * r2 + i3[13], e2[3] = i3[3] * o2 + i3[7] * r2 + i3[15], e2;
  49242. }
  49243. const mt = 100;
  49244. class ft {
  49245. constructor(e2, t2, i3 = new Ye(e2.width + 200, e2.height + 200, 25), o2 = new Ye(e2.width + 200, e2.height + 200, 25)) {
  49246. this.transform = e2, this.grid = i3, this.ignoredGrid = o2, this.pitchfactor = Math.cos(e2._pitch) * e2.cameraToCenterDistance, this.screenRightBoundary = e2.width + mt, this.screenBottomBoundary = e2.height + mt, this.gridRightBoundary = e2.width + 200, this.gridBottomBoundary = e2.height + 200, this.fogState = t2;
  49247. }
  49248. placeCollisionBox(e2, t2, i3, o2, r2, n2, a2) {
  49249. let s2 = t2.projectedAnchorX, l2 = t2.projectedAnchorY, c2 = t2.projectedAnchorZ;
  49250. const h2 = t2.elevation, _2 = t2.tileID;
  49251. if (h2 && _2) {
  49252. const e3 = this.transform.projection.upVector(_2.canonical, t2.tileAnchorX, t2.tileAnchorY), i4 = this.transform.projection.upVectorScale(_2.canonical, this.transform.center.lat, this.transform.worldSize).metersToTile;
  49253. s2 += e3[0] * h2 * i4, l2 += e3[1] * h2 * i4, c2 += e3[2] * h2 * i4;
  49254. }
  49255. const u2 = this.projectAndGetPerspectiveRatio(n2, [s2, l2, c2], t2.tileID, "globe" === this.transform.projection.name || !!h2 || this.transform.pitch > 0), d2 = r2 * u2.perspectiveRatio, p2 = (t2.x1 * e2 + i3.x - t2.padding) * d2 + u2.point.x, m2 = (t2.y1 * e2 + i3.y - t2.padding) * d2 + u2.point.y, f2 = (t2.x2 * e2 + i3.x + t2.padding) * d2 + u2.point.x, g2 = (t2.y2 * e2 + i3.y + t2.padding) * d2 + u2.point.y, v2 = u2.perspectiveRatio <= 0.55 || u2.occluded;
  49256. return !this.isInsideGrid(p2, m2, f2, g2) || !o2 && this.grid.hitTest(p2, m2, f2, g2, a2) || v2 ? { box: [], offscreen: false, occluded: u2.occluded } : { box: [p2, m2, f2, g2], offscreen: this.isOffscreen(p2, m2, f2, g2), occluded: false };
  49257. }
  49258. placeCollisionCircles(t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2, d2, p2) {
  49259. const m2 = [], f2 = this.transform.elevation, g2 = f2 ? f2.getAtTileOffsetFunc(p2, this.transform.center.lat, this.transform.worldSize, this.transform.projection) : (e2) => [0, 0, 0], v2 = new e.pointGeometry(i3.tileAnchorX, i3.tileAnchorY), x2 = this.transform.projection.projectTilePoint(i3.tileAnchorX, i3.tileAnchorY, p2.canonical), y2 = g2(v2), b2 = [x2.x + y2[0], x2.y + y2[1], x2.z + y2[2]], w2 = this.projectAndGetPerspectiveRatio(a2, [b2[0], b2[1], b2[2]], p2, "globe" === this.transform.projection.name || !!f2 || this.transform.pitch > 0), { perspectiveRatio: T2 } = w2, E2 = (h2 ? n2 / T2 : n2 * T2) / e.ONE_EM, C2 = tt(new e.pointGeometry(b2[0], b2[1]), s2, b2[2]).point, I2 = w2.signedDistanceFromCamera > 0 ? at(E2, r2, i3.lineOffsetX * E2, i3.lineOffsetY * E2, false, C2, v2, i3, o2, s2, {}, f2 && !h2 ? g2 : null, h2 && !!f2, this.transform.projection, p2) : null;
  49260. let M2 = false, S2 = false, z2 = true;
  49261. if (I2 && !w2.occluded) {
  49262. const i4 = 0.5 * u2 * T2 + d2, o3 = new e.pointGeometry(-100, -100), r3 = new e.pointGeometry(this.screenRightBoundary, this.screenBottomBoundary), n3 = new Ke(), a3 = I2.first, s3 = I2.last;
  49263. let h3 = [];
  49264. for (let e2 = a3.path.length - 1; e2 >= 1; e2--)
  49265. h3.push(a3.path[e2]);
  49266. for (let e2 = 1; e2 < s3.path.length; e2++)
  49267. h3.push(s3.path[e2]);
  49268. const p3 = 2.5 * i4;
  49269. if (l2) {
  49270. const e2 = h3.map(f2 ? (e3, t3) => {
  49271. const i5 = g2(t3 < a3.path.length - 1 ? a3.tilePath[a3.path.length - 1 - t3] : s3.tilePath[t3 - a3.path.length + 2]);
  49272. return tt(e3, l2, i5[2]);
  49273. } : (e3) => tt(e3, l2));
  49274. h3 = e2.some((e3) => e3.signedDistanceFromCamera <= 0) ? [] : e2.map((e3) => e3.point);
  49275. }
  49276. let v3 = [];
  49277. if (h3.length > 0) {
  49278. const t3 = h3[0].clone(), i5 = h3[0].clone();
  49279. for (let e2 = 1; e2 < h3.length; e2++)
  49280. t3.x = Math.min(t3.x, h3[e2].x), t3.y = Math.min(t3.y, h3[e2].y), i5.x = Math.max(i5.x, h3[e2].x), i5.y = Math.max(i5.y, h3[e2].y);
  49281. v3 = t3.x >= o3.x && i5.x <= r3.x && t3.y >= o3.y && i5.y <= r3.y ? [h3] : i5.x < o3.x || t3.x > r3.x || i5.y < o3.y || t3.y > r3.y ? [] : e.clipLine([h3], o3.x, o3.y, r3.x, r3.y);
  49282. }
  49283. for (const e2 of v3) {
  49284. n3.reset(e2, 0.25 * i4);
  49285. let o4 = 0;
  49286. o4 = n3.length <= 0.5 * i4 ? 1 : Math.ceil(n3.paddedLength / p3) + 1;
  49287. for (let e3 = 0; e3 < o4; e3++) {
  49288. const r4 = e3 / Math.max(o4 - 1, 1), a4 = n3.lerp(r4), s4 = a4.x + mt, l3 = a4.y + mt;
  49289. m2.push(s4, l3, i4, 0);
  49290. const h4 = s4 - i4, u3 = l3 - i4, d3 = s4 + i4, p4 = l3 + i4;
  49291. if (z2 = z2 && this.isOffscreen(h4, u3, d3, p4), S2 = S2 || this.isInsideGrid(h4, u3, d3, p4), !t2 && this.grid.hitTestCircle(s4, l3, i4, _2) && (M2 = true, !c2))
  49292. return { circles: [], offscreen: false, collisionDetected: M2, occluded: false };
  49293. }
  49294. }
  49295. }
  49296. return { circles: !c2 && M2 || !S2 ? [] : m2, offscreen: z2, collisionDetected: M2, occluded: w2.occluded };
  49297. }
  49298. queryRenderedSymbols(t2) {
  49299. if (0 === t2.length || 0 === this.grid.keysLength() && 0 === this.ignoredGrid.keysLength())
  49300. return {};
  49301. const i3 = [];
  49302. let o2 = 1 / 0, r2 = 1 / 0, n2 = -1 / 0, a2 = -1 / 0;
  49303. for (const s3 of t2) {
  49304. const t3 = new e.pointGeometry(s3.x + mt, s3.y + mt);
  49305. o2 = Math.min(o2, t3.x), r2 = Math.min(r2, t3.y), n2 = Math.max(n2, t3.x), a2 = Math.max(a2, t3.y), i3.push(t3);
  49306. }
  49307. const s2 = this.grid.query(o2, r2, n2, a2).concat(this.ignoredGrid.query(o2, r2, n2, a2)), l2 = {}, c2 = {};
  49308. for (const t3 of s2) {
  49309. const o3 = t3.key;
  49310. if (void 0 === l2[o3.bucketInstanceId] && (l2[o3.bucketInstanceId] = {}), l2[o3.bucketInstanceId][o3.featureIndex])
  49311. continue;
  49312. const r3 = [new e.pointGeometry(t3.x1, t3.y1), new e.pointGeometry(t3.x2, t3.y1), new e.pointGeometry(t3.x2, t3.y2), new e.pointGeometry(t3.x1, t3.y2)];
  49313. e.polygonIntersectsPolygon(i3, r3) && (l2[o3.bucketInstanceId][o3.featureIndex] = true, void 0 === c2[o3.bucketInstanceId] && (c2[o3.bucketInstanceId] = []), c2[o3.bucketInstanceId].push(o3.featureIndex));
  49314. }
  49315. return c2;
  49316. }
  49317. insertCollisionBox(e2, t2, i3, o2, r2) {
  49318. (t2 ? this.ignoredGrid : this.grid).insert({ bucketInstanceId: i3, featureIndex: o2, collisionGroupID: r2 }, e2[0], e2[1], e2[2], e2[3]);
  49319. }
  49320. insertCollisionCircles(e2, t2, i3, o2, r2) {
  49321. const n2 = t2 ? this.ignoredGrid : this.grid, a2 = { bucketInstanceId: i3, featureIndex: o2, collisionGroupID: r2 };
  49322. for (let t3 = 0; t3 < e2.length; t3 += 4)
  49323. n2.insertCircle(a2, e2[t3], e2[t3 + 1], e2[t3 + 2]);
  49324. }
  49325. projectAndGetPerspectiveRatio(t2, i3, o2, r2) {
  49326. const n2 = [i3[0], i3[1], i3[2], 1];
  49327. let a2 = false;
  49328. return i3[2] || this.transform.pitch > 0 ? (e.transformMat4$1(n2, n2, t2), this.fogState && o2 && (a2 = function(t3, i4, o3, r3, n3, a3) {
  49329. const s2 = a3.calculateFogTileMatrix(n3), l2 = [i4, o3, r3];
  49330. return e.transformMat4(l2, l2, s2), M(t3, l2, a3.pitch, a3._fov);
  49331. }(this.fogState, i3[0], i3[1], i3[2], o2.toUnwrapped(), this.transform) > 0.9)) : pt(n2, n2, t2), { point: new e.pointGeometry((n2[0] / n2[3] + 1) / 2 * this.transform.width + mt, (-n2[1] / n2[3] + 1) / 2 * this.transform.height + mt), perspectiveRatio: Math.min(0.5 + this.transform.cameraToCenterDistance / n2[3] * 0.5, 1.5), signedDistanceFromCamera: n2[3], occluded: r2 && n2[2] > n2[3] || a2 };
  49332. }
  49333. isOffscreen(e2, t2, i3, o2) {
  49334. return i3 < mt || e2 >= this.screenRightBoundary || o2 < mt || t2 > this.screenBottomBoundary;
  49335. }
  49336. isInsideGrid(e2, t2, i3, o2) {
  49337. return i3 >= 0 && e2 < this.gridRightBoundary && o2 >= 0 && t2 < this.gridBottomBoundary;
  49338. }
  49339. getViewportMatrix() {
  49340. const t2 = e.identity([]);
  49341. return e.translate(t2, t2, [-100, -100, 0]), t2;
  49342. }
  49343. }
  49344. class gt {
  49345. constructor(e2, t2, i3, o2) {
  49346. this.opacity = e2 ? Math.max(0, Math.min(1, e2.opacity + (e2.placed ? t2 : -t2))) : o2 && i3 ? 1 : 0, this.placed = i3;
  49347. }
  49348. isHidden() {
  49349. return 0 === this.opacity && !this.placed;
  49350. }
  49351. }
  49352. class vt {
  49353. constructor(e2, t2, i3, o2, r2, n2 = false) {
  49354. this.text = new gt(e2 ? e2.text : null, t2, i3, r2), this.icon = new gt(e2 ? e2.icon : null, t2, o2, r2), this.clipped = n2;
  49355. }
  49356. isHidden() {
  49357. return this.text.isHidden() && this.icon.isHidden();
  49358. }
  49359. }
  49360. class xt {
  49361. constructor(e2, t2, i3, o2 = false) {
  49362. this.text = e2, this.icon = t2, this.skipFade = i3, this.clipped = o2;
  49363. }
  49364. }
  49365. class yt {
  49366. constructor() {
  49367. this.invProjMatrix = e.create(), this.viewportMatrix = e.create(), this.circles = [];
  49368. }
  49369. }
  49370. class bt {
  49371. constructor(e2, t2, i3, o2, r2) {
  49372. this.bucketInstanceId = e2, this.featureIndex = t2, this.sourceLayerIndex = i3, this.bucketIndex = o2, this.tileID = r2;
  49373. }
  49374. }
  49375. class wt {
  49376. constructor(e2) {
  49377. this.crossSourceCollisions = e2, this.maxGroupID = 0, this.collisionGroups = {};
  49378. }
  49379. get(e2) {
  49380. if (this.crossSourceCollisions)
  49381. return { ID: 0, predicate: null };
  49382. if (!this.collisionGroups[e2]) {
  49383. const t2 = ++this.maxGroupID;
  49384. this.collisionGroups[e2] = { ID: t2, predicate: (e3) => e3.collisionGroupID === t2 };
  49385. }
  49386. return this.collisionGroups[e2];
  49387. }
  49388. }
  49389. function Tt(t2, i3, o2, r2, n2) {
  49390. const { horizontalAlign: a2, verticalAlign: s2 } = e.getAnchorAlignment(t2), l2 = -(a2 - 0.5) * i3, c2 = -(s2 - 0.5) * o2, h2 = e.evaluateVariableOffset(t2, r2);
  49391. return new e.pointGeometry(l2 + h2[0] * n2, c2 + h2[1] * n2);
  49392. }
  49393. function Et(t2, i3, o2, r2, n2) {
  49394. const a2 = new e.pointGeometry(t2, i3);
  49395. return o2 && a2._rotate(r2 ? n2 : -n2), a2;
  49396. }
  49397. class Ct {
  49398. constructor(e2, t2, i3, o2, r2) {
  49399. this.transform = e2.clone(), this.collisionIndex = new ft(this.transform, r2), this.placements = {}, this.opacities = {}, this.variableOffsets = {}, this.stale = false, this.commitTime = 0, this.fadeDuration = t2, this.retainedQueryData = {}, this.collisionGroups = new wt(i3), this.collisionCircleArrays = {}, this.prevPlacement = o2, o2 && (o2.prevPlacement = void 0), this.placedOrientations = {};
  49400. }
  49401. getBucketParts(t2, i3, o2, r2) {
  49402. const n2 = o2.getBucket(i3), a2 = o2.latestFeatureIndex;
  49403. if (!n2 || !a2 || i3.id !== n2.layerIds[0])
  49404. return;
  49405. const s2 = n2.layers[0].layout, l2 = o2.collisionBoxArray, c2 = Math.pow(2, this.transform.zoom - o2.tileID.overscaledZ), h2 = o2.tileSize / e.EXTENT, _2 = o2.tileID.toUnwrapped(), u2 = this.transform.calculateProjMatrix(_2), d2 = "map" === s2.get("text-pitch-alignment"), p2 = "map" === s2.get("text-rotation-alignment");
  49406. i3.compileFilter();
  49407. const m2 = i3.dynamicFilter(), f2 = i3.dynamicFilterNeedsFeature(), g2 = this.transform.calculatePixelsToTileUnitsMatrix(o2), v2 = Qe(u2, o2.tileID.canonical, d2, p2, this.transform, g2);
  49408. let x2 = null;
  49409. if (d2) {
  49410. const t3 = et(u2, o2.tileID.canonical, d2, p2, this.transform, g2);
  49411. x2 = e.multiply$1([], this.transform.labelPlaneMatrix, t3);
  49412. }
  49413. let y2 = null;
  49414. m2 && o2.latestFeatureIndex && (y2 = { unwrappedTileID: _2, dynamicFilter: m2, dynamicFilterNeedsFeature: f2, featureIndex: o2.latestFeatureIndex }), this.retainedQueryData[n2.bucketInstanceId] = new bt(n2.bucketInstanceId, a2, n2.sourceLayerIndex, n2.index, o2.tileID);
  49415. const b2 = { bucket: n2, layout: s2, posMatrix: u2, textLabelPlaneMatrix: v2, labelToScreenMatrix: x2, clippingData: y2, scale: c2, textPixelRatio: h2, holdingForFade: o2.holdingForFade(), collisionBoxArray: l2, partiallyEvaluatedTextSize: e.evaluateSizeForZoom(n2.textSizeData, this.transform.zoom), partiallyEvaluatedIconSize: e.evaluateSizeForZoom(n2.iconSizeData, this.transform.zoom), collisionGroup: this.collisionGroups.get(n2.sourceID) };
  49416. if (r2)
  49417. for (const e2 of n2.sortKeyRanges) {
  49418. const { sortKey: i4, symbolInstanceStart: o3, symbolInstanceEnd: r3 } = e2;
  49419. t2.push({ sortKey: i4, symbolInstanceStart: o3, symbolInstanceEnd: r3, parameters: b2 });
  49420. }
  49421. else
  49422. t2.push({ symbolInstanceStart: 0, symbolInstanceEnd: n2.symbolInstances.length, parameters: b2 });
  49423. }
  49424. attemptAnchorPlacement(e2, t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2, d2, p2, m2, f2, g2) {
  49425. const v2 = [_2.textOffset0, _2.textOffset1], x2 = Tt(e2, i3, o2, v2, r2), y2 = this.collisionIndex.placeCollisionBox(r2, t2, Et(x2.x, x2.y, n2, a2, this.transform.angle), h2, s2, l2, c2.predicate);
  49426. if ((!m2 || 0 !== this.collisionIndex.placeCollisionBox(d2.getSymbolInstanceIconSize(g2, this.transform.zoom, u2), m2, Et(x2.x, x2.y, n2, a2, this.transform.angle), h2, s2, l2, c2.predicate).box.length) && y2.box.length > 0) {
  49427. let t3;
  49428. return this.prevPlacement && this.prevPlacement.variableOffsets[_2.crossTileID] && this.prevPlacement.placements[_2.crossTileID] && this.prevPlacement.placements[_2.crossTileID].text && (t3 = this.prevPlacement.variableOffsets[_2.crossTileID].anchor), this.variableOffsets[_2.crossTileID] = { textOffset: v2, width: i3, height: o2, anchor: e2, textScale: r2, prevAnchor: t3 }, this.markUsedJustification(d2, e2, _2, p2), d2.allowVerticalPlacement && (this.markUsedOrientation(d2, p2, _2), this.placedOrientations[_2.crossTileID] = p2), { shift: x2, placedGlyphBoxes: y2 };
  49429. }
  49430. }
  49431. placeLayerBucketPart(t2, i3, o2, r2) {
  49432. const { bucket: n2, layout: a2, posMatrix: s2, textLabelPlaneMatrix: l2, labelToScreenMatrix: c2, clippingData: h2, textPixelRatio: _2, holdingForFade: u2, collisionBoxArray: d2, partiallyEvaluatedTextSize: p2, partiallyEvaluatedIconSize: m2, collisionGroup: f2 } = t2.parameters, g2 = a2.get("text-optional"), v2 = a2.get("icon-optional"), x2 = a2.get("text-allow-overlap"), y2 = a2.get("icon-allow-overlap"), b2 = "map" === a2.get("text-rotation-alignment"), w2 = "map" === a2.get("text-pitch-alignment"), T2 = "none" !== a2.get("icon-text-fit"), E2 = "viewport-y" === a2.get("symbol-z-order");
  49433. let C2 = x2 && (y2 || !n2.hasIconData() || v2), I2 = y2 && (x2 || !n2.hasTextData() || g2);
  49434. !n2.collisionArrays && d2 && n2.deserializeCollisionBoxes(d2), o2 && r2 && n2.updateCollisionDebugBuffers(this.transform.zoom, d2);
  49435. const M2 = (t3, r3, d3) => {
  49436. if (h2) {
  49437. const o3 = { zoom: this.transform.zoom, pitch: this.transform.pitch };
  49438. let r4 = null;
  49439. if (h2.dynamicFilterNeedsFeature) {
  49440. const e2 = this.retainedQueryData[n2.bucketInstanceId];
  49441. r4 = h2.featureIndex.loadFeature({ featureIndex: t3.featureIndex, bucketIndex: e2.bucketIndex, sourceLayerIndex: e2.sourceLayerIndex, layoutVertexArrayOffset: 0 });
  49442. }
  49443. if (!(0, h2.dynamicFilter)(o3, r4, this.retainedQueryData[n2.bucketInstanceId].tileID.canonical, new e.pointGeometry(t3.tileAnchorX, t3.tileAnchorY), this.transform.calculateDistanceTileData(h2.unwrappedTileID)))
  49444. return this.placements[t3.crossTileID] = new xt(false, false, false, true), void (i3[t3.crossTileID] = true);
  49445. }
  49446. if (i3[t3.crossTileID])
  49447. return;
  49448. if (u2)
  49449. return void (this.placements[t3.crossTileID] = new xt(false, false, false));
  49450. let E3 = false, M3 = false, S2 = true, z2 = false, D2 = false, P2 = null, A2 = { box: null, offscreen: null, occluded: null }, L2 = { box: null, offscreen: null, occluded: null }, R2 = null, k2 = null, O2 = null, B2 = 0, F2 = 0, U2 = 0;
  49451. d3.textFeatureIndex ? B2 = d3.textFeatureIndex : t3.useRuntimeCollisionCircles && (B2 = t3.featureIndex), d3.verticalTextFeatureIndex && (F2 = d3.verticalTextFeatureIndex);
  49452. const N2 = (e2) => {
  49453. e2.tileID = this.retainedQueryData[n2.bucketInstanceId].tileID, (this.transform.elevation || e2.elevation) && (e2.elevation = this.transform.elevation ? this.transform.elevation.getAtTileOffset(this.retainedQueryData[n2.bucketInstanceId].tileID, e2.tileAnchorX, e2.tileAnchorY) : 0);
  49454. }, G2 = d3.textBox;
  49455. if (G2) {
  49456. N2(G2);
  49457. const i4 = (i5) => {
  49458. let o4 = e.WritingMode.horizontal;
  49459. if (n2.allowVerticalPlacement && !i5 && this.prevPlacement) {
  49460. const e2 = this.prevPlacement.placedOrientations[t3.crossTileID];
  49461. e2 && (this.placedOrientations[t3.crossTileID] = e2, o4 = e2, this.markUsedOrientation(n2, o4, t3));
  49462. }
  49463. return o4;
  49464. }, o3 = (i5, o4) => {
  49465. if (n2.allowVerticalPlacement && t3.numVerticalGlyphVertices > 0 && d3.verticalTextBox) {
  49466. for (const t4 of n2.writingModes)
  49467. if (t4 === e.WritingMode.vertical ? (A2 = o4(), L2 = A2) : A2 = i5(), A2 && A2.box && A2.box.length)
  49468. break;
  49469. } else
  49470. A2 = i5();
  49471. };
  49472. if (a2.get("text-variable-anchor")) {
  49473. let l3 = a2.get("text-variable-anchor");
  49474. if (this.prevPlacement && this.prevPlacement.variableOffsets[t3.crossTileID]) {
  49475. const e2 = this.prevPlacement.variableOffsets[t3.crossTileID];
  49476. l3.indexOf(e2.anchor) > 0 && (l3 = l3.filter((t4) => t4 !== e2.anchor), l3.unshift(e2.anchor));
  49477. }
  49478. const c3 = (e2, i5, o4) => {
  49479. const a3 = n2.getSymbolInstanceTextSize(p2, t3, this.transform.zoom, r3), c4 = (e2.x2 - e2.x1) * a3 + 2 * e2.padding, h4 = (e2.y2 - e2.y1) * a3 + 2 * e2.padding, u3 = T2 && !y2 ? i5 : null;
  49480. u3 && N2(u3);
  49481. let d4 = { box: [], offscreen: false, occluded: false };
  49482. const g3 = x2 ? 2 * l3.length : l3.length;
  49483. for (let i6 = 0; i6 < g3; ++i6) {
  49484. const g4 = this.attemptAnchorPlacement(l3[i6 % l3.length], e2, c4, h4, a3, b2, w2, _2, s2, f2, i6 >= l3.length, t3, r3, n2, o4, u3, p2, m2);
  49485. if (g4 && (d4 = g4.placedGlyphBoxes, d4 && d4.box && d4.box.length)) {
  49486. E3 = true, P2 = g4.shift;
  49487. break;
  49488. }
  49489. }
  49490. return d4;
  49491. };
  49492. o3(() => c3(G2, d3.iconBox, e.WritingMode.horizontal), () => {
  49493. const i5 = d3.verticalTextBox;
  49494. return i5 && N2(i5), n2.allowVerticalPlacement && !(A2 && A2.box && A2.box.length) && t3.numVerticalGlyphVertices > 0 && i5 ? c3(i5, d3.verticalIconBox, e.WritingMode.vertical) : { box: null, offscreen: null, occluded: null };
  49495. }), A2 && (E3 = A2.box, S2 = A2.offscreen, z2 = A2.occluded);
  49496. const h3 = i4(A2 && A2.box);
  49497. if (!E3 && this.prevPlacement) {
  49498. const e2 = this.prevPlacement.variableOffsets[t3.crossTileID];
  49499. e2 && (this.variableOffsets[t3.crossTileID] = e2, this.markUsedJustification(n2, e2.anchor, t3, h3));
  49500. }
  49501. } else {
  49502. const a3 = (i5, o4) => {
  49503. const a4 = n2.getSymbolInstanceTextSize(p2, t3, this.transform.zoom, r3), l3 = this.collisionIndex.placeCollisionBox(a4, i5, new e.pointGeometry(0, 0), x2, _2, s2, f2.predicate);
  49504. return l3 && l3.box && l3.box.length && (this.markUsedOrientation(n2, o4, t3), this.placedOrientations[t3.crossTileID] = o4), l3;
  49505. };
  49506. o3(() => a3(G2, e.WritingMode.horizontal), () => {
  49507. const i5 = d3.verticalTextBox;
  49508. return n2.allowVerticalPlacement && t3.numVerticalGlyphVertices > 0 && i5 ? (N2(i5), a3(i5, e.WritingMode.vertical)) : { box: null, offscreen: null, occluded: null };
  49509. }), i4(A2 && A2.box && A2.box.length);
  49510. }
  49511. }
  49512. if (R2 = A2, E3 = R2 && R2.box && R2.box.length > 0, S2 = R2 && R2.offscreen, z2 = R2 && R2.occluded, t3.useRuntimeCollisionCircles) {
  49513. const i4 = n2.text.placedSymbolArray.get(t3.centerJustifiedTextSymbolIndex >= 0 ? t3.centerJustifiedTextSymbolIndex : t3.verticalPlacedTextSymbolIndex), r4 = e.evaluateSizeForFeature(n2.textSizeData, p2, i4), h3 = a2.get("text-padding");
  49514. k2 = this.collisionIndex.placeCollisionCircles(x2, i4, n2.lineVertexArray, n2.glyphOffsetArray, r4, s2, l2, c2, o2, w2, f2.predicate, t3.collisionCircleDiameter * r4 / e.ONE_EM, h3, this.retainedQueryData[n2.bucketInstanceId].tileID), E3 = x2 || k2.circles.length > 0 && !k2.collisionDetected, S2 = S2 && k2.offscreen, z2 = k2.occluded;
  49515. }
  49516. if (d3.iconFeatureIndex && (U2 = d3.iconFeatureIndex), d3.iconBox) {
  49517. const t4 = (t5) => {
  49518. N2(t5);
  49519. const i4 = T2 && P2 ? Et(P2.x, P2.y, b2, w2, this.transform.angle) : new e.pointGeometry(0, 0), o3 = n2.getSymbolInstanceIconSize(m2, this.transform.zoom, r3);
  49520. return this.collisionIndex.placeCollisionBox(o3, t5, i4, y2, _2, s2, f2.predicate);
  49521. };
  49522. L2 && L2.box && L2.box.length && d3.verticalIconBox ? (O2 = t4(d3.verticalIconBox), M3 = O2.box.length > 0) : (O2 = t4(d3.iconBox), M3 = O2.box.length > 0), S2 = S2 && O2.offscreen, D2 = O2.occluded;
  49523. }
  49524. const j2 = g2 || 0 === t3.numHorizontalGlyphVertices && 0 === t3.numVerticalGlyphVertices, Z2 = v2 || 0 === t3.numIconVertices;
  49525. if (j2 || Z2 ? Z2 ? j2 || (M3 = M3 && E3) : E3 = M3 && E3 : M3 = E3 = M3 && E3, E3 && R2 && R2.box && this.collisionIndex.insertCollisionBox(R2.box, a2.get("text-ignore-placement"), n2.bucketInstanceId, L2 && L2.box && F2 ? F2 : B2, f2.ID), M3 && O2 && this.collisionIndex.insertCollisionBox(O2.box, a2.get("icon-ignore-placement"), n2.bucketInstanceId, U2, f2.ID), k2 && (E3 && this.collisionIndex.insertCollisionCircles(k2.circles, a2.get("text-ignore-placement"), n2.bucketInstanceId, B2, f2.ID), o2)) {
  49526. const e2 = n2.bucketInstanceId;
  49527. let t4 = this.collisionCircleArrays[e2];
  49528. void 0 === t4 && (t4 = this.collisionCircleArrays[e2] = new yt());
  49529. for (let e3 = 0; e3 < k2.circles.length; e3 += 4)
  49530. t4.circles.push(k2.circles[e3 + 0]), t4.circles.push(k2.circles[e3 + 1]), t4.circles.push(k2.circles[e3 + 2]), t4.circles.push(k2.collisionDetected ? 1 : 0);
  49531. }
  49532. const V2 = "globe" !== this.transform.projection.name;
  49533. C2 = C2 && (V2 || !z2), I2 = I2 && (V2 || !D2), this.placements[t3.crossTileID] = new xt(E3 || C2, M3 || I2, S2 || n2.justReloaded), i3[t3.crossTileID] = true;
  49534. };
  49535. if (E2) {
  49536. const e2 = n2.getSortedSymbolIndexes(this.transform.angle);
  49537. for (let t3 = e2.length - 1; t3 >= 0; --t3) {
  49538. const i4 = e2[t3];
  49539. M2(n2.symbolInstances.get(i4), i4, n2.collisionArrays[i4]);
  49540. }
  49541. } else
  49542. for (let e2 = t2.symbolInstanceStart; e2 < t2.symbolInstanceEnd; e2++)
  49543. M2(n2.symbolInstances.get(e2), e2, n2.collisionArrays[e2]);
  49544. if (o2 && n2.bucketInstanceId in this.collisionCircleArrays) {
  49545. const t3 = this.collisionCircleArrays[n2.bucketInstanceId];
  49546. e.invert(t3.invProjMatrix, s2), t3.viewportMatrix = this.collisionIndex.getViewportMatrix();
  49547. }
  49548. n2.justReloaded = false;
  49549. }
  49550. markUsedJustification(t2, i3, o2, r2) {
  49551. let n2;
  49552. n2 = r2 === e.WritingMode.vertical ? o2.verticalPlacedTextSymbolIndex : { left: o2.leftJustifiedTextSymbolIndex, center: o2.centerJustifiedTextSymbolIndex, right: o2.rightJustifiedTextSymbolIndex }[e.getAnchorJustification(i3)];
  49553. const a2 = [o2.leftJustifiedTextSymbolIndex, o2.centerJustifiedTextSymbolIndex, o2.rightJustifiedTextSymbolIndex, o2.verticalPlacedTextSymbolIndex];
  49554. for (const e2 of a2)
  49555. e2 >= 0 && (t2.text.placedSymbolArray.get(e2).crossTileID = n2 >= 0 && e2 !== n2 ? 0 : o2.crossTileID);
  49556. }
  49557. markUsedOrientation(t2, i3, o2) {
  49558. const r2 = i3 === e.WritingMode.horizontal || i3 === e.WritingMode.horizontalOnly ? i3 : 0, n2 = i3 === e.WritingMode.vertical ? i3 : 0, a2 = [o2.leftJustifiedTextSymbolIndex, o2.centerJustifiedTextSymbolIndex, o2.rightJustifiedTextSymbolIndex];
  49559. for (const e2 of a2)
  49560. t2.text.placedSymbolArray.get(e2).placedOrientation = r2;
  49561. o2.verticalPlacedTextSymbolIndex && (t2.text.placedSymbolArray.get(o2.verticalPlacedTextSymbolIndex).placedOrientation = n2);
  49562. }
  49563. commit(e2) {
  49564. this.commitTime = e2, this.zoomAtLastRecencyCheck = this.transform.zoom;
  49565. const t2 = this.prevPlacement;
  49566. let i3 = false;
  49567. this.prevZoomAdjustment = t2 ? t2.zoomAdjustment(this.transform.zoom) : 0;
  49568. const o2 = t2 ? t2.symbolFadeChange(e2) : 1, r2 = t2 ? t2.opacities : {}, n2 = t2 ? t2.variableOffsets : {}, a2 = t2 ? t2.placedOrientations : {};
  49569. for (const e3 in this.placements) {
  49570. const t3 = this.placements[e3], n3 = r2[e3];
  49571. n3 ? (this.opacities[e3] = new vt(n3, o2, t3.text, t3.icon, null, t3.clipped), i3 = i3 || t3.text !== n3.text.placed || t3.icon !== n3.icon.placed) : (this.opacities[e3] = new vt(null, o2, t3.text, t3.icon, t3.skipFade, t3.clipped), i3 = i3 || t3.text || t3.icon);
  49572. }
  49573. for (const e3 in r2) {
  49574. const t3 = r2[e3];
  49575. if (!this.opacities[e3]) {
  49576. const r3 = new vt(t3, o2, false, false);
  49577. r3.isHidden() || (this.opacities[e3] = r3, i3 = i3 || t3.text.placed || t3.icon.placed);
  49578. }
  49579. }
  49580. for (const e3 in n2)
  49581. this.variableOffsets[e3] || !this.opacities[e3] || this.opacities[e3].isHidden() || (this.variableOffsets[e3] = n2[e3]);
  49582. for (const e3 in a2)
  49583. this.placedOrientations[e3] || !this.opacities[e3] || this.opacities[e3].isHidden() || (this.placedOrientations[e3] = a2[e3]);
  49584. i3 ? this.lastPlacementChangeTime = e2 : "number" != typeof this.lastPlacementChangeTime && (this.lastPlacementChangeTime = t2 ? t2.lastPlacementChangeTime : e2);
  49585. }
  49586. updateLayerOpacities(e2, t2) {
  49587. const i3 = {};
  49588. for (const o2 of t2) {
  49589. const t3 = o2.getBucket(e2);
  49590. t3 && o2.latestFeatureIndex && e2.id === t3.layerIds[0] && this.updateBucketOpacities(t3, i3, o2.collisionBoxArray);
  49591. }
  49592. }
  49593. updateBucketOpacities(t2, i3, o2) {
  49594. t2.hasTextData() && t2.text.opacityVertexArray.clear(), t2.hasIconData() && t2.icon.opacityVertexArray.clear(), t2.hasIconCollisionBoxData() && t2.iconCollisionBox.collisionVertexArray.clear(), t2.hasTextCollisionBoxData() && t2.textCollisionBox.collisionVertexArray.clear();
  49595. const r2 = t2.layers[0].layout, n2 = !!t2.layers[0].dynamicFilter(), a2 = new vt(null, 0, false, false, true), s2 = r2.get("text-allow-overlap"), l2 = r2.get("icon-allow-overlap"), c2 = r2.get("text-variable-anchor"), h2 = "map" === r2.get("text-rotation-alignment"), _2 = "map" === r2.get("text-pitch-alignment"), u2 = "none" !== r2.get("icon-text-fit"), d2 = new vt(null, 0, s2 && (l2 || !t2.hasIconData() || r2.get("icon-optional")), l2 && (s2 || !t2.hasTextData() || r2.get("text-optional")), true);
  49596. !t2.collisionArrays && o2 && (t2.hasIconCollisionBoxData() || t2.hasTextCollisionBoxData()) && t2.deserializeCollisionBoxes(o2);
  49597. const p2 = (e2, t3, i4) => {
  49598. for (let o3 = 0; o3 < t3 / 4; o3++)
  49599. e2.opacityVertexArray.emplaceBack(i4);
  49600. };
  49601. let m2 = 0;
  49602. for (let o3 = 0; o3 < t2.symbolInstances.length; o3++) {
  49603. const r3 = t2.symbolInstances.get(o3), { numHorizontalGlyphVertices: s3, numVerticalGlyphVertices: l3, crossTileID: f2 } = r3;
  49604. let g2 = this.opacities[f2];
  49605. i3[f2] ? g2 = a2 : g2 || (g2 = d2, this.opacities[f2] = g2), i3[f2] = true;
  49606. const v2 = s3 > 0 || l3 > 0, x2 = r3.numIconVertices > 0, y2 = this.placedOrientations[r3.crossTileID], b2 = y2 === e.WritingMode.vertical, w2 = y2 === e.WritingMode.horizontal || y2 === e.WritingMode.horizontalOnly;
  49607. if (!v2 && !x2 || g2.isHidden() || m2++, v2) {
  49608. const e2 = Rt(g2.text);
  49609. p2(t2.text, s3, b2 ? kt : e2), p2(t2.text, l3, w2 ? kt : e2);
  49610. const i4 = g2.text.isHidden();
  49611. [r3.rightJustifiedTextSymbolIndex, r3.centerJustifiedTextSymbolIndex, r3.leftJustifiedTextSymbolIndex].forEach((e3) => {
  49612. e3 >= 0 && (t2.text.placedSymbolArray.get(e3).hidden = i4 || b2 ? 1 : 0);
  49613. }), r3.verticalPlacedTextSymbolIndex >= 0 && (t2.text.placedSymbolArray.get(r3.verticalPlacedTextSymbolIndex).hidden = i4 || w2 ? 1 : 0);
  49614. const o4 = this.variableOffsets[r3.crossTileID];
  49615. o4 && this.markUsedJustification(t2, o4.anchor, r3, y2);
  49616. const n3 = this.placedOrientations[r3.crossTileID];
  49617. n3 && (this.markUsedJustification(t2, "left", r3, n3), this.markUsedOrientation(t2, n3, r3));
  49618. }
  49619. if (x2) {
  49620. const e2 = Rt(g2.icon);
  49621. r3.placedIconSymbolIndex >= 0 && (p2(t2.icon, r3.numIconVertices, b2 ? kt : e2), t2.icon.placedSymbolArray.get(r3.placedIconSymbolIndex).hidden = g2.icon.isHidden()), r3.verticalPlacedIconSymbolIndex >= 0 && (p2(t2.icon, r3.numVerticalIconVertices, w2 ? kt : e2), t2.icon.placedSymbolArray.get(r3.verticalPlacedIconSymbolIndex).hidden = g2.icon.isHidden());
  49622. }
  49623. if (t2.hasIconCollisionBoxData() || t2.hasTextCollisionBoxData()) {
  49624. const i4 = t2.collisionArrays[o3];
  49625. if (i4) {
  49626. let o4 = new e.pointGeometry(0, 0), r4 = true;
  49627. if (i4.textBox || i4.verticalTextBox) {
  49628. if (c2) {
  49629. const e2 = this.variableOffsets[f2];
  49630. e2 ? (o4 = Tt(e2.anchor, e2.width, e2.height, e2.textOffset, e2.textScale), h2 && o4._rotate(_2 ? this.transform.angle : -this.transform.angle)) : r4 = false;
  49631. }
  49632. n2 && (r4 = !g2.clipped), i4.textBox && It(t2.textCollisionBox.collisionVertexArray, g2.text.placed, !r4 || b2, o4.x, o4.y), i4.verticalTextBox && It(t2.textCollisionBox.collisionVertexArray, g2.text.placed, !r4 || w2, o4.x, o4.y);
  49633. }
  49634. const a3 = r4 && Boolean(!w2 && i4.verticalIconBox);
  49635. i4.iconBox && It(t2.iconCollisionBox.collisionVertexArray, g2.icon.placed, a3, u2 ? o4.x : 0, u2 ? o4.y : 0), i4.verticalIconBox && It(t2.iconCollisionBox.collisionVertexArray, g2.icon.placed, !a3, u2 ? o4.x : 0, u2 ? o4.y : 0);
  49636. }
  49637. }
  49638. }
  49639. if (t2.fullyClipped = 0 === m2, t2.sortFeatures(this.transform.angle), this.retainedQueryData[t2.bucketInstanceId] && (this.retainedQueryData[t2.bucketInstanceId].featureSortOrder = t2.featureSortOrder), t2.hasTextData() && t2.text.opacityVertexBuffer && t2.text.opacityVertexBuffer.updateData(t2.text.opacityVertexArray), t2.hasIconData() && t2.icon.opacityVertexBuffer && t2.icon.opacityVertexBuffer.updateData(t2.icon.opacityVertexArray), t2.hasIconCollisionBoxData() && t2.iconCollisionBox.collisionVertexBuffer && t2.iconCollisionBox.collisionVertexBuffer.updateData(t2.iconCollisionBox.collisionVertexArray), t2.hasTextCollisionBoxData() && t2.textCollisionBox.collisionVertexBuffer && t2.textCollisionBox.collisionVertexBuffer.updateData(t2.textCollisionBox.collisionVertexArray), t2.bucketInstanceId in this.collisionCircleArrays) {
  49640. const e2 = this.collisionCircleArrays[t2.bucketInstanceId];
  49641. t2.placementInvProjMatrix = e2.invProjMatrix, t2.placementViewportMatrix = e2.viewportMatrix, t2.collisionCircleArray = e2.circles, delete this.collisionCircleArrays[t2.bucketInstanceId];
  49642. }
  49643. }
  49644. symbolFadeChange(e2) {
  49645. return 0 === this.fadeDuration ? 1 : (e2 - this.commitTime) / this.fadeDuration + this.prevZoomAdjustment;
  49646. }
  49647. zoomAdjustment(e2) {
  49648. return Math.max(0, (this.transform.zoom - e2) / 1.5);
  49649. }
  49650. hasTransitions(e2) {
  49651. return this.stale || e2 - this.lastPlacementChangeTime < this.fadeDuration;
  49652. }
  49653. stillRecent(e2, t2) {
  49654. const i3 = this.zoomAtLastRecencyCheck === t2 ? 1 - this.zoomAdjustment(t2) : 1;
  49655. return this.zoomAtLastRecencyCheck = t2, this.commitTime + this.fadeDuration * i3 > e2;
  49656. }
  49657. setStale() {
  49658. this.stale = true;
  49659. }
  49660. }
  49661. function It(e2, t2, i3, o2, r2) {
  49662. e2.emplaceBack(t2 ? 1 : 0, i3 ? 1 : 0, o2 || 0, r2 || 0), e2.emplaceBack(t2 ? 1 : 0, i3 ? 1 : 0, o2 || 0, r2 || 0), e2.emplaceBack(t2 ? 1 : 0, i3 ? 1 : 0, o2 || 0, r2 || 0), e2.emplaceBack(t2 ? 1 : 0, i3 ? 1 : 0, o2 || 0, r2 || 0);
  49663. }
  49664. const Mt = Math.pow(2, 25), St = Math.pow(2, 24), zt = Math.pow(2, 17), Dt = Math.pow(2, 16), Pt = Math.pow(2, 9), At = Math.pow(2, 8), Lt = Math.pow(2, 1);
  49665. function Rt(e2) {
  49666. if (0 === e2.opacity && !e2.placed)
  49667. return 0;
  49668. if (1 === e2.opacity && e2.placed)
  49669. return 4294967295;
  49670. const t2 = e2.placed ? 1 : 0, i3 = Math.floor(127 * e2.opacity);
  49671. return i3 * Mt + t2 * St + i3 * zt + t2 * Dt + i3 * Pt + t2 * At + i3 * Lt + t2;
  49672. }
  49673. const kt = 0;
  49674. class Ot {
  49675. constructor(e2) {
  49676. this._sortAcrossTiles = "viewport-y" !== e2.layout.get("symbol-z-order") && void 0 !== e2.layout.get("symbol-sort-key").constantOr(1), this._currentTileIndex = 0, this._currentPartIndex = 0, this._seenCrossTileIDs = {}, this._bucketParts = [];
  49677. }
  49678. continuePlacement(e2, t2, i3, o2, r2) {
  49679. const n2 = this._bucketParts;
  49680. for (; this._currentTileIndex < e2.length; )
  49681. if (t2.getBucketParts(n2, o2, e2[this._currentTileIndex], this._sortAcrossTiles), this._currentTileIndex++, r2())
  49682. return true;
  49683. for (this._sortAcrossTiles && (this._sortAcrossTiles = false, n2.sort((e3, t3) => e3.sortKey - t3.sortKey)); this._currentPartIndex < n2.length; ) {
  49684. const e3 = n2[this._currentPartIndex];
  49685. if (t2.placeLayerBucketPart(e3, this._seenCrossTileIDs, i3, 0 === e3.symbolInstanceStart), this._currentPartIndex++, r2())
  49686. return true;
  49687. }
  49688. return false;
  49689. }
  49690. }
  49691. class Bt {
  49692. constructor(e2, t2, i3, o2, r2, n2, a2, s2) {
  49693. this.placement = new Ct(e2, r2, n2, a2, s2), this._currentPlacementIndex = t2.length - 1, this._forceFullPlacement = i3, this._showCollisionBoxes = o2, this._done = false;
  49694. }
  49695. isDone() {
  49696. return this._done;
  49697. }
  49698. continuePlacement(t2, i3, o2) {
  49699. const r2 = e.exported.now(), n2 = () => {
  49700. const t3 = e.exported.now() - r2;
  49701. return !this._forceFullPlacement && t3 > 2;
  49702. };
  49703. for (; this._currentPlacementIndex >= 0; ) {
  49704. const e2 = i3[t2[this._currentPlacementIndex]], r3 = this.placement.collisionIndex.transform.zoom;
  49705. if ("symbol" === e2.type && (!e2.minzoom || e2.minzoom <= r3) && (!e2.maxzoom || e2.maxzoom > r3)) {
  49706. if (this._inProgressLayer || (this._inProgressLayer = new Ot(e2)), this._inProgressLayer.continuePlacement(o2[e2.source], this.placement, this._showCollisionBoxes, e2, n2))
  49707. return;
  49708. delete this._inProgressLayer;
  49709. }
  49710. this._currentPlacementIndex--;
  49711. }
  49712. this._done = true;
  49713. }
  49714. commit(e2) {
  49715. return this.placement.commit(e2), this.placement;
  49716. }
  49717. }
  49718. const Ft = 512 / e.EXTENT / 2;
  49719. class Ut {
  49720. constructor(e2, t2, i3) {
  49721. this.tileID = e2, this.indexedSymbolInstances = {}, this.bucketInstanceId = i3;
  49722. for (let i4 = 0; i4 < t2.length; i4++) {
  49723. const o2 = t2.get(i4), r2 = o2.key;
  49724. this.indexedSymbolInstances[r2] || (this.indexedSymbolInstances[r2] = []), this.indexedSymbolInstances[r2].push({ crossTileID: o2.crossTileID, coord: this.getScaledCoordinates(o2, e2) });
  49725. }
  49726. }
  49727. getScaledCoordinates(t2, i3) {
  49728. const o2 = Ft / Math.pow(2, i3.canonical.z - this.tileID.canonical.z);
  49729. return { x: Math.floor((i3.canonical.x * e.EXTENT + t2.tileAnchorX) * o2), y: Math.floor((i3.canonical.y * e.EXTENT + t2.tileAnchorY) * o2) };
  49730. }
  49731. findMatches(e2, t2, i3) {
  49732. const o2 = this.tileID.canonical.z < t2.canonical.z ? 1 : Math.pow(2, this.tileID.canonical.z - t2.canonical.z);
  49733. for (let r2 = 0; r2 < e2.length; r2++) {
  49734. const n2 = e2.get(r2);
  49735. if (n2.crossTileID)
  49736. continue;
  49737. const a2 = this.indexedSymbolInstances[n2.key];
  49738. if (!a2)
  49739. continue;
  49740. const s2 = this.getScaledCoordinates(n2, t2);
  49741. for (const e3 of a2)
  49742. if (Math.abs(e3.coord.x - s2.x) <= o2 && Math.abs(e3.coord.y - s2.y) <= o2 && !i3[e3.crossTileID]) {
  49743. i3[e3.crossTileID] = true, n2.crossTileID = e3.crossTileID;
  49744. break;
  49745. }
  49746. }
  49747. }
  49748. }
  49749. class Nt {
  49750. constructor() {
  49751. this.maxCrossTileID = 0;
  49752. }
  49753. generate() {
  49754. return ++this.maxCrossTileID;
  49755. }
  49756. }
  49757. class Gt {
  49758. constructor() {
  49759. this.indexes = {}, this.usedCrossTileIDs = {}, this.lng = 0;
  49760. }
  49761. handleWrapJump(e2) {
  49762. const t2 = Math.round((e2 - this.lng) / 360);
  49763. if (0 !== t2)
  49764. for (const e3 in this.indexes) {
  49765. const i3 = this.indexes[e3], o2 = {};
  49766. for (const e4 in i3) {
  49767. const r2 = i3[e4];
  49768. r2.tileID = r2.tileID.unwrapTo(r2.tileID.wrap + t2), o2[r2.tileID.key] = r2;
  49769. }
  49770. this.indexes[e3] = o2;
  49771. }
  49772. this.lng = e2;
  49773. }
  49774. addBucket(e2, t2, i3) {
  49775. if (this.indexes[e2.overscaledZ] && this.indexes[e2.overscaledZ][e2.key]) {
  49776. if (this.indexes[e2.overscaledZ][e2.key].bucketInstanceId === t2.bucketInstanceId)
  49777. return false;
  49778. this.removeBucketCrossTileIDs(e2.overscaledZ, this.indexes[e2.overscaledZ][e2.key]);
  49779. }
  49780. for (let e3 = 0; e3 < t2.symbolInstances.length; e3++)
  49781. t2.symbolInstances.get(e3).crossTileID = 0;
  49782. this.usedCrossTileIDs[e2.overscaledZ] || (this.usedCrossTileIDs[e2.overscaledZ] = {});
  49783. const o2 = this.usedCrossTileIDs[e2.overscaledZ];
  49784. for (const i4 in this.indexes) {
  49785. const r2 = this.indexes[i4];
  49786. if (Number(i4) > e2.overscaledZ)
  49787. for (const i5 in r2) {
  49788. const n2 = r2[i5];
  49789. n2.tileID.isChildOf(e2) && n2.findMatches(t2.symbolInstances, e2, o2);
  49790. }
  49791. else {
  49792. const n2 = r2[e2.scaledTo(Number(i4)).key];
  49793. n2 && n2.findMatches(t2.symbolInstances, e2, o2);
  49794. }
  49795. }
  49796. for (let e3 = 0; e3 < t2.symbolInstances.length; e3++) {
  49797. const r2 = t2.symbolInstances.get(e3);
  49798. r2.crossTileID || (r2.crossTileID = i3.generate(), o2[r2.crossTileID] = true);
  49799. }
  49800. return void 0 === this.indexes[e2.overscaledZ] && (this.indexes[e2.overscaledZ] = {}), this.indexes[e2.overscaledZ][e2.key] = new Ut(e2, t2.symbolInstances, t2.bucketInstanceId), true;
  49801. }
  49802. removeBucketCrossTileIDs(e2, t2) {
  49803. for (const i3 in t2.indexedSymbolInstances)
  49804. for (const o2 of t2.indexedSymbolInstances[i3])
  49805. delete this.usedCrossTileIDs[e2][o2.crossTileID];
  49806. }
  49807. removeStaleBuckets(e2) {
  49808. let t2 = false;
  49809. for (const i3 in this.indexes) {
  49810. const o2 = this.indexes[i3];
  49811. for (const r2 in o2)
  49812. e2[o2[r2].bucketInstanceId] || (this.removeBucketCrossTileIDs(i3, o2[r2]), delete o2[r2], t2 = true);
  49813. }
  49814. return t2;
  49815. }
  49816. }
  49817. class jt {
  49818. constructor() {
  49819. this.layerIndexes = {}, this.crossTileIDs = new Nt(), this.maxBucketInstanceId = 0, this.bucketsInCurrentPlacement = {};
  49820. }
  49821. addLayer(e2, t2, i3, o2) {
  49822. let r2 = this.layerIndexes[e2.id];
  49823. void 0 === r2 && (r2 = this.layerIndexes[e2.id] = new Gt());
  49824. let n2 = false;
  49825. const a2 = {};
  49826. "globe" !== o2.name && r2.handleWrapJump(i3);
  49827. for (const i4 of t2) {
  49828. const t3 = i4.getBucket(e2);
  49829. t3 && e2.id === t3.layerIds[0] && (t3.bucketInstanceId || (t3.bucketInstanceId = ++this.maxBucketInstanceId), r2.addBucket(i4.tileID, t3, this.crossTileIDs) && (n2 = true), a2[t3.bucketInstanceId] = true);
  49830. }
  49831. return r2.removeStaleBuckets(a2) && (n2 = true), n2;
  49832. }
  49833. pruneUnusedLayers(e2) {
  49834. const t2 = {};
  49835. e2.forEach((e3) => {
  49836. t2[e3] = true;
  49837. });
  49838. for (const e3 in this.layerIndexes)
  49839. t2[e3] || delete this.layerIndexes[e3];
  49840. }
  49841. }
  49842. const Zt = (t2, i3) => e.emitValidationErrors(t2, i3 && i3.filter((e2) => "source.canvas" !== e2.identifier)), Vt = e.pick(je, ["addLayer", "removeLayer", "setPaintProperty", "setLayoutProperty", "setFilter", "addSource", "removeSource", "setLayerZoomRange", "setLight", "setTransition", "setGeoJSONSourceData", "setTerrain", "setFog", "setProjection"]), Wt = e.pick(je, ["setCenter", "setZoom", "setBearing", "setPitch"]), qt = { version: 8, layers: [], sources: {} }, Xt = { fill: true, line: true, background: true, hillshade: true, raster: true };
  49843. class $t extends e.Evented {
  49844. constructor(t2, i3 = {}) {
  49845. super(), this.map = t2, this.dispatcher = new A(Ue(), this), this.imageManager = new y(), this.imageManager.setEventedParent(this), this.glyphManager = new e.GlyphManager(t2._requestManager, i3.localFontFamily ? e.LocalGlyphMode.all : i3.localIdeographFontFamily ? e.LocalGlyphMode.ideographs : e.LocalGlyphMode.none, i3.localFontFamily || i3.localIdeographFontFamily), this.lineAtlas = new e.LineAtlas(256, 512), this.crossTileSymbolIndex = new jt(), this._layers = {}, this._num3DLayers = 0, this._numSymbolLayers = 0, this._numCircleLayers = 0, this._serializedLayers = {}, this._sourceCaches = {}, this._otherSourceCaches = {}, this._symbolSourceCaches = {}, this.zoomHistory = new e.ZoomHistory(), this._loaded = false, this._availableImages = [], this._order = [], this._drapedFirstOrder = [], this._markersNeedUpdate = false, this._resetUpdates(), this.dispatcher.broadcast("setReferrer", e.getReferrer());
  49846. const o2 = this;
  49847. this._rtlTextPluginCallback = $t.registerForPluginStateChange((t3) => {
  49848. o2.dispatcher.broadcast("syncRTLPluginState", { pluginStatus: t3.pluginStatus, pluginURL: t3.pluginURL }, (t4, i4) => {
  49849. if (e.triggerPluginCompletionEvent(t4), i4 && i4.every((e2) => e2))
  49850. for (const e2 in o2._sourceCaches) {
  49851. const t5 = o2._sourceCaches[e2], i5 = t5.getSource().type;
  49852. "vector" !== i5 && "geojson" !== i5 || t5.reload();
  49853. }
  49854. });
  49855. }), this.on("data", (e2) => {
  49856. if ("source" !== e2.dataType || "metadata" !== e2.sourceDataType)
  49857. return;
  49858. const t3 = this.getSource(e2.sourceId);
  49859. if (t3 && t3.vectorLayerIds)
  49860. for (const e3 in this._layers) {
  49861. const i4 = this._layers[e3];
  49862. i4.source === t3.id && this._validateLayer(i4);
  49863. }
  49864. });
  49865. }
  49866. loadURL(t2, i3 = {}) {
  49867. this.fire(new e.Event("dataloading", { dataType: "style" }));
  49868. const o2 = "boolean" == typeof i3.validate ? i3.validate : !e.isMapboxURL(t2);
  49869. t2 = this.map._requestManager.normalizeStyleURL(t2, i3.accessToken);
  49870. const r2 = this.map._requestManager.transformRequest(t2, e.ResourceType.Style);
  49871. this._request = e.getJSON(r2, (t3, i4) => {
  49872. this._request = null, t3 ? this.fire(new e.ErrorEvent(t3)) : i4 && this._load(i4, o2);
  49873. });
  49874. }
  49875. loadJSON(t2, i3 = {}) {
  49876. this.fire(new e.Event("dataloading", { dataType: "style" })), this._request = e.exported.frame(() => {
  49877. this._request = null, this._load(t2, false !== i3.validate);
  49878. });
  49879. }
  49880. loadEmpty() {
  49881. this.fire(new e.Event("dataloading", { dataType: "style" })), this._load(qt, false);
  49882. }
  49883. _updateLayerCount(e2, t2) {
  49884. const i3 = t2 ? 1 : -1;
  49885. e2.is3D() && (this._num3DLayers += i3), "circle" === e2.type && (this._numCircleLayers += i3), "symbol" === e2.type && (this._numSymbolLayers += i3);
  49886. }
  49887. _load(t2, i3) {
  49888. if (i3 && Zt(this, e.validateStyle(t2)))
  49889. return;
  49890. this._loaded = true, this.stylesheet = t2, this._updateMapProjection();
  49891. for (const e2 in t2.sources)
  49892. this.addSource(e2, t2.sources[e2], { validate: false });
  49893. this._changed = false, t2.sprite ? this._loadSprite(t2.sprite) : (this.imageManager.setLoaded(true), this.dispatcher.broadcast("spriteLoaded", true)), this.glyphManager.setURL(t2.glyphs);
  49894. const o2 = Ge(this.stylesheet.layers);
  49895. this._order = o2.map((e2) => e2.id), this._layers = {}, this._serializedLayers = {};
  49896. for (let t3 of o2)
  49897. t3 = e.createStyleLayer(t3), t3.setEventedParent(this, { layer: { id: t3.id } }), this._layers[t3.id] = t3, this._serializedLayers[t3.id] = t3.serialize(), this._updateLayerCount(t3, true);
  49898. this.dispatcher.broadcast("setLayers", this._serializeLayers(this._order)), this.light = new T(this.stylesheet.light), this.stylesheet.terrain && !this.terrainSetForDrapingOnly() && this._createTerrain(this.stylesheet.terrain, 1), this.stylesheet.fog && this._createFog(this.stylesheet.fog), this._updateDrapeFirstLayers(), this.fire(new e.Event("data", { dataType: "style" })), this.fire(new e.Event("style.load"));
  49899. }
  49900. terrainSetForDrapingOnly() {
  49901. return !!this.terrain && 0 === this.terrain.drapeRenderMode;
  49902. }
  49903. setProjection(e2) {
  49904. e2 ? this.stylesheet.projection = e2 : delete this.stylesheet.projection, this.map._explicitProjection || this.map._updateProjection();
  49905. }
  49906. _updateMapProjection() {
  49907. this.map._explicitProjection ? this.applyProjectionUpdate() : this.map._updateProjection();
  49908. }
  49909. applyProjectionUpdate() {
  49910. this._loaded && (this.dispatcher.broadcast("setProjection", this.map.transform.projectionOptions), this.map.transform.projection.requiresDraping ? this.getTerrain() || this.stylesheet.terrain || this.setTerrainForDraping() : this.terrainSetForDrapingOnly() && this.setTerrain(null));
  49911. }
  49912. _loadSprite(t2) {
  49913. this._spriteRequest = function(t3, i3, o2) {
  49914. let r2, n2, a2;
  49915. const s2 = e.exported.devicePixelRatio > 1 ? "@2x" : "";
  49916. let l2 = e.getJSON(i3.transformRequest(i3.normalizeSpriteURL(t3, s2, ".json"), e.ResourceType.SpriteJSON), (e2, t4) => {
  49917. l2 = null, a2 || (a2 = e2, r2 = t4, h2());
  49918. }), c2 = e.getImage(i3.transformRequest(i3.normalizeSpriteURL(t3, s2, ".png"), e.ResourceType.SpriteImage), (e2, t4) => {
  49919. c2 = null, a2 || (a2 = e2, n2 = t4, h2());
  49920. });
  49921. function h2() {
  49922. if (a2)
  49923. o2(a2);
  49924. else if (r2 && n2) {
  49925. const t4 = e.exported.getImageData(n2), i4 = {};
  49926. for (const o3 in r2) {
  49927. const { width: n3, height: a3, x: s3, y: l3, sdf: c3, pixelRatio: h3, stretchX: _2, stretchY: u2, content: d2 } = r2[o3], p2 = new e.RGBAImage({ width: n3, height: a3 });
  49928. e.RGBAImage.copy(t4, p2, { x: s3, y: l3 }, { x: 0, y: 0 }, { width: n3, height: a3 }), i4[o3] = { data: p2, pixelRatio: h3, sdf: c3, stretchX: _2, stretchY: u2, content: d2 };
  49929. }
  49930. o2(null, i4);
  49931. }
  49932. }
  49933. return { cancel() {
  49934. l2 && (l2.cancel(), l2 = null), c2 && (c2.cancel(), c2 = null);
  49935. } };
  49936. }(t2, this.map._requestManager, (t3, i3) => {
  49937. if (this._spriteRequest = null, t3)
  49938. this.fire(new e.ErrorEvent(t3));
  49939. else if (i3)
  49940. for (const e2 in i3)
  49941. this.imageManager.addImage(e2, i3[e2]);
  49942. this.imageManager.setLoaded(true), this._availableImages = this.imageManager.listImages(), this.dispatcher.broadcast("setImages", this._availableImages), this.dispatcher.broadcast("spriteLoaded", true), this.fire(new e.Event("data", { dataType: "style" }));
  49943. });
  49944. }
  49945. _validateLayer(t2) {
  49946. const i3 = this.getSource(t2.source);
  49947. if (!i3)
  49948. return;
  49949. const o2 = t2.sourceLayer;
  49950. o2 && ("geojson" === i3.type || i3.vectorLayerIds && -1 === i3.vectorLayerIds.indexOf(o2)) && this.fire(new e.ErrorEvent(new Error(`Source layer "${o2}" does not exist on source "${i3.id}" as specified by style layer "${t2.id}"`)));
  49951. }
  49952. loaded() {
  49953. if (!this._loaded)
  49954. return false;
  49955. if (Object.keys(this._updatedSources).length)
  49956. return false;
  49957. for (const e2 in this._sourceCaches)
  49958. if (!this._sourceCaches[e2].loaded())
  49959. return false;
  49960. return !!this.imageManager.isLoaded();
  49961. }
  49962. _serializeLayers(e2) {
  49963. const t2 = [];
  49964. for (const i3 of e2) {
  49965. const e3 = this._layers[i3];
  49966. "custom" !== e3.type && t2.push(e3.serialize());
  49967. }
  49968. return t2;
  49969. }
  49970. hasTransitions() {
  49971. if (this.light && this.light.hasTransition())
  49972. return true;
  49973. if (this.fog && this.fog.hasTransition())
  49974. return true;
  49975. for (const e2 in this._sourceCaches)
  49976. if (this._sourceCaches[e2].hasTransition())
  49977. return true;
  49978. for (const e2 in this._layers)
  49979. if (this._layers[e2].hasTransition())
  49980. return true;
  49981. return false;
  49982. }
  49983. get order() {
  49984. return this.map._optimizeForTerrain && this.terrain ? this._drapedFirstOrder : this._order;
  49985. }
  49986. isLayerDraped(e2) {
  49987. return !!this.terrain && Xt[e2.type];
  49988. }
  49989. _checkLoaded() {
  49990. if (!this._loaded)
  49991. throw new Error("Style is not done loading");
  49992. }
  49993. update(t2) {
  49994. if (!this._loaded)
  49995. return;
  49996. const i3 = this._changed;
  49997. if (this._changed) {
  49998. const e2 = Object.keys(this._updatedLayers), i4 = Object.keys(this._removedLayers);
  49999. (e2.length || i4.length) && this._updateWorkerLayers(e2, i4);
  50000. for (const e3 in this._updatedSources) {
  50001. const t3 = this._updatedSources[e3];
  50002. "reload" === t3 ? this._reloadSource(e3) : "clear" === t3 && this._clearSource(e3);
  50003. }
  50004. this._updateTilesForChangedImages();
  50005. for (const e3 in this._updatedPaintProps)
  50006. this._layers[e3].updateTransitions(t2);
  50007. this.light.updateTransitions(t2), this.fog && this.fog.updateTransitions(t2), this._resetUpdates();
  50008. }
  50009. const o2 = {};
  50010. for (const e2 in this._sourceCaches) {
  50011. const t3 = this._sourceCaches[e2];
  50012. o2[e2] = t3.used, t3.used = false;
  50013. }
  50014. for (const e2 of this._order) {
  50015. const i4 = this._layers[e2];
  50016. if (i4.recalculate(t2, this._availableImages), !i4.isHidden(t2.zoom)) {
  50017. const e3 = this._getLayerSourceCache(i4);
  50018. e3 && (e3.used = true);
  50019. }
  50020. const o3 = this.map.painter;
  50021. if (o3) {
  50022. const e3 = i4.getProgramIds();
  50023. if (!e3)
  50024. continue;
  50025. const r2 = i4.getProgramConfiguration(t2.zoom);
  50026. for (const t3 of e3)
  50027. o3.useProgram(t3, r2);
  50028. }
  50029. }
  50030. for (const t3 in o2) {
  50031. const i4 = this._sourceCaches[t3];
  50032. o2[t3] !== i4.used && i4.getSource().fire(new e.Event("data", { sourceDataType: "visibility", dataType: "source", sourceId: i4.getSource().id }));
  50033. }
  50034. this.light.recalculate(t2), this.terrain && this.terrain.recalculate(t2), this.fog && this.fog.recalculate(t2), this.z = t2.zoom, this._markersNeedUpdate && (this._updateMarkersOpacity(), this._markersNeedUpdate = false), i3 && this.fire(new e.Event("data", { dataType: "style" }));
  50035. }
  50036. _updateTilesForChangedImages() {
  50037. const e2 = Object.keys(this._changedImages);
  50038. if (e2.length) {
  50039. for (const t2 in this._sourceCaches)
  50040. this._sourceCaches[t2].reloadTilesForDependencies(["icons", "patterns"], e2);
  50041. this._changedImages = {};
  50042. }
  50043. }
  50044. _updateWorkerLayers(e2, t2) {
  50045. this.dispatcher.broadcast("updateLayers", { layers: this._serializeLayers(e2), removedIds: t2 });
  50046. }
  50047. _resetUpdates() {
  50048. this._changed = false, this._updatedLayers = {}, this._removedLayers = {}, this._updatedSources = {}, this._updatedPaintProps = {}, this._changedImages = {};
  50049. }
  50050. setState(t2) {
  50051. if (this._checkLoaded(), Zt(this, e.validateStyle(t2)))
  50052. return false;
  50053. (t2 = e.clone$1(t2)).layers = Ge(t2.layers);
  50054. const i3 = function(e2, t3) {
  50055. if (!e2)
  50056. return [{ command: je.setStyle, args: [t3] }];
  50057. let i4 = [];
  50058. try {
  50059. if (!r(e2.version, t3.version))
  50060. return [{ command: je.setStyle, args: [t3] }];
  50061. r(e2.center, t3.center) || i4.push({ command: je.setCenter, args: [t3.center] }), r(e2.zoom, t3.zoom) || i4.push({ command: je.setZoom, args: [t3.zoom] }), r(e2.bearing, t3.bearing) || i4.push({ command: je.setBearing, args: [t3.bearing] }), r(e2.pitch, t3.pitch) || i4.push({ command: je.setPitch, args: [t3.pitch] }), r(e2.sprite, t3.sprite) || i4.push({ command: je.setSprite, args: [t3.sprite] }), r(e2.glyphs, t3.glyphs) || i4.push({ command: je.setGlyphs, args: [t3.glyphs] }), r(e2.transition, t3.transition) || i4.push({ command: je.setTransition, args: [t3.transition] }), r(e2.light, t3.light) || i4.push({ command: je.setLight, args: [t3.light] }), r(e2.fog, t3.fog) || i4.push({ command: je.setFog, args: [t3.fog] }), r(e2.projection, t3.projection) || i4.push({ command: je.setProjection, args: [t3.projection] });
  50062. const o3 = {}, n2 = [];
  50063. !function(e3, t4, i5, o4) {
  50064. let n3;
  50065. for (n3 in t4 = t4 || {}, e3 = e3 || {})
  50066. e3.hasOwnProperty(n3) && (t4.hasOwnProperty(n3) || Ve(n3, i5, o4));
  50067. for (n3 in t4)
  50068. t4.hasOwnProperty(n3) && (e3.hasOwnProperty(n3) ? r(e3[n3], t4[n3]) || ("geojson" === e3[n3].type && "geojson" === t4[n3].type && qe(e3, t4, n3) ? i5.push({ command: je.setGeoJSONSourceData, args: [n3, t4[n3].data] }) : We(n3, t4, i5, o4)) : Ze(n3, t4, i5));
  50069. }(e2.sources, t3.sources, n2, o3);
  50070. const a2 = [];
  50071. e2.layers && e2.layers.forEach((e3) => {
  50072. e3.source && o3[e3.source] ? i4.push({ command: je.removeLayer, args: [e3.id] }) : a2.push(e3);
  50073. });
  50074. let s2 = e2.terrain;
  50075. s2 && o3[s2.source] && (i4.push({ command: je.setTerrain, args: [void 0] }), s2 = void 0), i4 = i4.concat(n2), r(s2, t3.terrain) || i4.push({ command: je.setTerrain, args: [t3.terrain] }), function(e3, t4, i5) {
  50076. t4 = t4 || [];
  50077. const o4 = (e3 = e3 || []).map($e), n3 = t4.map($e), a3 = e3.reduce(He, {}), s3 = t4.reduce(He, {}), l2 = o4.slice(), c2 = /* @__PURE__ */ Object.create(null);
  50078. let h2, _2, u2, d2, p2, m2, f2;
  50079. for (h2 = 0, _2 = 0; h2 < o4.length; h2++)
  50080. u2 = o4[h2], s3.hasOwnProperty(u2) ? _2++ : (i5.push({ command: je.removeLayer, args: [u2] }), l2.splice(l2.indexOf(u2, _2), 1));
  50081. for (h2 = 0, _2 = 0; h2 < n3.length; h2++)
  50082. u2 = n3[n3.length - 1 - h2], l2[l2.length - 1 - h2] !== u2 && (a3.hasOwnProperty(u2) ? (i5.push({ command: je.removeLayer, args: [u2] }), l2.splice(l2.lastIndexOf(u2, l2.length - _2), 1)) : _2++, m2 = l2[l2.length - h2], i5.push({ command: je.addLayer, args: [s3[u2], m2] }), l2.splice(l2.length - h2, 0, u2), c2[u2] = true);
  50083. for (h2 = 0; h2 < n3.length; h2++)
  50084. if (u2 = n3[h2], d2 = a3[u2], p2 = s3[u2], !c2[u2] && !r(d2, p2))
  50085. if (r(d2.source, p2.source) && r(d2["source-layer"], p2["source-layer"]) && r(d2.type, p2.type)) {
  50086. for (f2 in Xe(d2.layout, p2.layout, i5, u2, null, je.setLayoutProperty), Xe(d2.paint, p2.paint, i5, u2, null, je.setPaintProperty), r(d2.filter, p2.filter) || i5.push({ command: je.setFilter, args: [u2, p2.filter] }), r(d2.minzoom, p2.minzoom) && r(d2.maxzoom, p2.maxzoom) || i5.push({ command: je.setLayerZoomRange, args: [u2, p2.minzoom, p2.maxzoom] }), d2)
  50087. d2.hasOwnProperty(f2) && "layout" !== f2 && "paint" !== f2 && "filter" !== f2 && "metadata" !== f2 && "minzoom" !== f2 && "maxzoom" !== f2 && (0 === f2.indexOf("paint.") ? Xe(d2[f2], p2[f2], i5, u2, f2.slice(6), je.setPaintProperty) : r(d2[f2], p2[f2]) || i5.push({ command: je.setLayerProperty, args: [u2, f2, p2[f2]] }));
  50088. for (f2 in p2)
  50089. p2.hasOwnProperty(f2) && !d2.hasOwnProperty(f2) && "layout" !== f2 && "paint" !== f2 && "filter" !== f2 && "metadata" !== f2 && "minzoom" !== f2 && "maxzoom" !== f2 && (0 === f2.indexOf("paint.") ? Xe(d2[f2], p2[f2], i5, u2, f2.slice(6), je.setPaintProperty) : r(d2[f2], p2[f2]) || i5.push({ command: je.setLayerProperty, args: [u2, f2, p2[f2]] }));
  50090. } else
  50091. i5.push({ command: je.removeLayer, args: [u2] }), m2 = l2[l2.lastIndexOf(u2) + 1], i5.push({ command: je.addLayer, args: [p2, m2] });
  50092. }(a2, t3.layers, i4);
  50093. } catch (e3) {
  50094. console.warn("Unable to compute style diff:", e3), i4 = [{ command: je.setStyle, args: [t3] }];
  50095. }
  50096. return i4;
  50097. }(this.serialize(), t2).filter((e2) => !(e2.command in Wt));
  50098. if (0 === i3.length)
  50099. return false;
  50100. const o2 = i3.filter((e2) => !(e2.command in Vt));
  50101. if (o2.length > 0)
  50102. throw new Error(`Unimplemented: ${o2.map((e2) => e2.command).join(", ")}.`);
  50103. return i3.forEach((e2) => {
  50104. "setTransition" !== e2.command && this[e2.command].apply(this, e2.args);
  50105. }), this.stylesheet = t2, this._updateMapProjection(), true;
  50106. }
  50107. addImage(t2, i3) {
  50108. return this.getImage(t2) ? this.fire(new e.ErrorEvent(new Error("An image with this name already exists."))) : (this.imageManager.addImage(t2, i3), this._afterImageUpdated(t2), this);
  50109. }
  50110. updateImage(e2, t2) {
  50111. this.imageManager.updateImage(e2, t2);
  50112. }
  50113. getImage(e2) {
  50114. return this.imageManager.getImage(e2);
  50115. }
  50116. removeImage(t2) {
  50117. return this.getImage(t2) ? (this.imageManager.removeImage(t2), this._afterImageUpdated(t2), this) : this.fire(new e.ErrorEvent(new Error("No image with this name exists.")));
  50118. }
  50119. _afterImageUpdated(t2) {
  50120. this._availableImages = this.imageManager.listImages(), this._changedImages[t2] = true, this._changed = true, this.dispatcher.broadcast("setImages", this._availableImages), this.fire(new e.Event("data", { dataType: "style" }));
  50121. }
  50122. listImages() {
  50123. return this._checkLoaded(), this._availableImages.slice();
  50124. }
  50125. addSource(t2, i3, o2 = {}) {
  50126. if (this._checkLoaded(), void 0 !== this.getSource(t2))
  50127. throw new Error("There is already a source with this ID");
  50128. if (!i3.type)
  50129. throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i3).join(", ")}.`);
  50130. if (["vector", "raster", "geojson", "video", "image"].indexOf(i3.type) >= 0 && this._validate(e.validateSource, `sources.${t2}`, i3, null, o2))
  50131. return;
  50132. this.map && this.map._collectResourceTiming && (i3.collectResourceTiming = true);
  50133. const r2 = De(t2, i3, this.dispatcher, this);
  50134. r2.setEventedParent(this, () => ({ isSourceLoaded: this._isSourceCacheLoaded(t2), source: r2.serialize(), sourceId: t2 }));
  50135. const n2 = (i4) => {
  50136. const o3 = (i4 ? "symbol:" : "other:") + t2, n3 = this._sourceCaches[o3] = new e.SourceCache(o3, r2, i4);
  50137. (i4 ? this._symbolSourceCaches : this._otherSourceCaches)[t2] = n3, n3.style = this, n3.onAdd(this.map);
  50138. };
  50139. n2(false), "vector" !== i3.type && "geojson" !== i3.type || n2(true), r2.onAdd && r2.onAdd(this.map), this._changed = true;
  50140. }
  50141. removeSource(t2) {
  50142. this._checkLoaded();
  50143. const i3 = this.getSource(t2);
  50144. if (!i3)
  50145. throw new Error("There is no source with this ID");
  50146. for (const i4 in this._layers)
  50147. if (this._layers[i4].source === t2)
  50148. return this.fire(new e.ErrorEvent(new Error(`Source "${t2}" cannot be removed while layer "${i4}" is using it.`)));
  50149. if (this.terrain && this.terrain.get().source === t2)
  50150. return this.fire(new e.ErrorEvent(new Error(`Source "${t2}" cannot be removed while terrain is using it.`)));
  50151. const o2 = this._getSourceCaches(t2);
  50152. for (const t3 of o2)
  50153. delete this._sourceCaches[t3.id], delete this._updatedSources[t3.id], t3.fire(new e.Event("data", { sourceDataType: "metadata", dataType: "source", sourceId: t3.getSource().id })), t3.setEventedParent(null), t3.clearTiles();
  50154. return delete this._otherSourceCaches[t2], delete this._symbolSourceCaches[t2], i3.setEventedParent(null), i3.onRemove && i3.onRemove(this.map), this._changed = true, this;
  50155. }
  50156. setGeoJSONSourceData(e2, t2) {
  50157. this._checkLoaded(), this.getSource(e2).setData(t2), this._changed = true;
  50158. }
  50159. getSource(e2) {
  50160. const t2 = this._getSourceCache(e2);
  50161. return t2 && t2.getSource();
  50162. }
  50163. addLayer(t2, i3, o2 = {}) {
  50164. this._checkLoaded();
  50165. const r2 = t2.id;
  50166. if (this.getLayer(r2))
  50167. return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${r2}" already exists on this map`)));
  50168. let n2;
  50169. if ("custom" === t2.type) {
  50170. if (Zt(this, e.validateCustomStyleLayer(t2)))
  50171. return;
  50172. n2 = e.createStyleLayer(t2);
  50173. } else {
  50174. if ("object" == typeof t2.source && (this.addSource(r2, t2.source), t2 = e.clone$1(t2), t2 = e.extend(t2, { source: r2 })), this._validate(e.validateLayer, `layers.${r2}`, t2, { arrayIndex: -1 }, o2))
  50175. return;
  50176. n2 = e.createStyleLayer(t2), this._validateLayer(n2), n2.setEventedParent(this, { layer: { id: r2 } }), this._serializedLayers[n2.id] = n2.serialize(), this._updateLayerCount(n2, true);
  50177. }
  50178. const a2 = i3 ? this._order.indexOf(i3) : this._order.length;
  50179. if (i3 && -1 === a2)
  50180. return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${i3}" does not exist on this map.`)));
  50181. this._order.splice(a2, 0, r2), this._layerOrderChanged = true, this._layers[r2] = n2;
  50182. const s2 = this._getLayerSourceCache(n2);
  50183. if (this._removedLayers[r2] && n2.source && s2 && "custom" !== n2.type) {
  50184. const e2 = this._removedLayers[r2];
  50185. delete this._removedLayers[r2], e2.type !== n2.type ? this._updatedSources[n2.source] = "clear" : (this._updatedSources[n2.source] = "reload", s2.pause());
  50186. }
  50187. this._updateLayer(n2), n2.onAdd && n2.onAdd(this.map), this._updateDrapeFirstLayers();
  50188. }
  50189. moveLayer(t2, i3) {
  50190. if (this._checkLoaded(), this._changed = true, !this._layers[t2])
  50191. return void this.fire(new e.ErrorEvent(new Error(`The layer '${t2}' does not exist in the map's style and cannot be moved.`)));
  50192. if (t2 === i3)
  50193. return;
  50194. const o2 = this._order.indexOf(t2);
  50195. this._order.splice(o2, 1);
  50196. const r2 = i3 ? this._order.indexOf(i3) : this._order.length;
  50197. i3 && -1 === r2 ? this.fire(new e.ErrorEvent(new Error(`Layer with id "${i3}" does not exist on this map.`))) : (this._order.splice(r2, 0, t2), this._layerOrderChanged = true, this._updateDrapeFirstLayers());
  50198. }
  50199. removeLayer(t2) {
  50200. this._checkLoaded();
  50201. const i3 = this._layers[t2];
  50202. if (!i3)
  50203. return void this.fire(new e.ErrorEvent(new Error(`The layer '${t2}' does not exist in the map's style and cannot be removed.`)));
  50204. i3.setEventedParent(null), this._updateLayerCount(i3, false);
  50205. const o2 = this._order.indexOf(t2);
  50206. this._order.splice(o2, 1), this._layerOrderChanged = true, this._changed = true, this._removedLayers[t2] = i3, delete this._layers[t2], delete this._serializedLayers[t2], delete this._updatedLayers[t2], delete this._updatedPaintProps[t2], i3.onRemove && i3.onRemove(this.map), this._updateDrapeFirstLayers();
  50207. }
  50208. getLayer(e2) {
  50209. return this._layers[e2];
  50210. }
  50211. hasLayer(e2) {
  50212. return e2 in this._layers;
  50213. }
  50214. hasLayerType(e2) {
  50215. for (const t2 in this._layers)
  50216. if (this._layers[t2].type === e2)
  50217. return true;
  50218. return false;
  50219. }
  50220. setLayerZoomRange(t2, i3, o2) {
  50221. this._checkLoaded();
  50222. const r2 = this.getLayer(t2);
  50223. r2 ? r2.minzoom === i3 && r2.maxzoom === o2 || (null != i3 && (r2.minzoom = i3), null != o2 && (r2.maxzoom = o2), this._updateLayer(r2)) : this.fire(new e.ErrorEvent(new Error(`The layer '${t2}' does not exist in the map's style and cannot have zoom extent.`)));
  50224. }
  50225. setFilter(t2, i3, o2 = {}) {
  50226. this._checkLoaded();
  50227. const n2 = this.getLayer(t2);
  50228. if (n2) {
  50229. if (!r(n2.filter, i3))
  50230. return null == i3 ? (n2.filter = void 0, void this._updateLayer(n2)) : void (this._validate(e.validateFilter, `layers.${n2.id}.filter`, i3, { layerType: n2.type }, o2) || (n2.filter = e.clone$1(i3), this._updateLayer(n2)));
  50231. } else
  50232. this.fire(new e.ErrorEvent(new Error(`The layer '${t2}' does not exist in the map's style and cannot be filtered.`)));
  50233. }
  50234. getFilter(t2) {
  50235. const i3 = this.getLayer(t2);
  50236. return i3 && e.clone$1(i3.filter);
  50237. }
  50238. setLayoutProperty(t2, i3, o2, n2 = {}) {
  50239. this._checkLoaded();
  50240. const a2 = this.getLayer(t2);
  50241. a2 ? r(a2.getLayoutProperty(i3), o2) || (a2.setLayoutProperty(i3, o2, n2), this._updateLayer(a2)) : this.fire(new e.ErrorEvent(new Error(`The layer '${t2}' does not exist in the map's style and cannot be styled.`)));
  50242. }
  50243. getLayoutProperty(t2, i3) {
  50244. const o2 = this.getLayer(t2);
  50245. if (o2)
  50246. return o2.getLayoutProperty(i3);
  50247. this.fire(new e.ErrorEvent(new Error(`The layer '${t2}' does not exist in the map's style.`)));
  50248. }
  50249. setPaintProperty(t2, i3, o2, n2 = {}) {
  50250. this._checkLoaded();
  50251. const a2 = this.getLayer(t2);
  50252. a2 ? r(a2.getPaintProperty(i3), o2) || (a2.setPaintProperty(i3, o2, n2) && this._updateLayer(a2), this._changed = true, this._updatedPaintProps[t2] = true) : this.fire(new e.ErrorEvent(new Error(`The layer '${t2}' does not exist in the map's style and cannot be styled.`)));
  50253. }
  50254. getPaintProperty(e2, t2) {
  50255. const i3 = this.getLayer(e2);
  50256. return i3 && i3.getPaintProperty(t2);
  50257. }
  50258. setFeatureState(t2, i3) {
  50259. this._checkLoaded();
  50260. const o2 = t2.source, r2 = t2.sourceLayer, n2 = this.getSource(o2);
  50261. if (!n2)
  50262. return void this.fire(new e.ErrorEvent(new Error(`The source '${o2}' does not exist in the map's style.`)));
  50263. const a2 = n2.type;
  50264. if ("geojson" === a2 && r2)
  50265. return void this.fire(new e.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));
  50266. if ("vector" === a2 && !r2)
  50267. return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));
  50268. void 0 === t2.id && this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided.")));
  50269. const s2 = this._getSourceCaches(o2);
  50270. for (const e2 of s2)
  50271. e2.setFeatureState(r2, t2.id, i3);
  50272. }
  50273. removeFeatureState(t2, i3) {
  50274. this._checkLoaded();
  50275. const o2 = t2.source, r2 = this.getSource(o2);
  50276. if (!r2)
  50277. return void this.fire(new e.ErrorEvent(new Error(`The source '${o2}' does not exist in the map's style.`)));
  50278. const n2 = r2.type, a2 = "vector" === n2 ? t2.sourceLayer : void 0;
  50279. if ("vector" === n2 && !a2)
  50280. return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));
  50281. if (i3 && "string" != typeof t2.id && "number" != typeof t2.id)
  50282. return void this.fire(new e.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));
  50283. const s2 = this._getSourceCaches(o2);
  50284. for (const e2 of s2)
  50285. e2.removeFeatureState(a2, t2.id, i3);
  50286. }
  50287. getFeatureState(t2) {
  50288. this._checkLoaded();
  50289. const i3 = t2.source, o2 = t2.sourceLayer, r2 = this.getSource(i3);
  50290. if (r2) {
  50291. if ("vector" !== r2.type || o2)
  50292. return void 0 === t2.id && this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided."))), this._getSourceCaches(i3)[0].getFeatureState(o2, t2.id);
  50293. this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));
  50294. } else
  50295. this.fire(new e.ErrorEvent(new Error(`The source '${i3}' does not exist in the map's style.`)));
  50296. }
  50297. getTransition() {
  50298. return e.extend({ duration: 300, delay: 0 }, this.stylesheet && this.stylesheet.transition);
  50299. }
  50300. serialize() {
  50301. const t2 = {};
  50302. for (const e2 in this._sourceCaches) {
  50303. const i3 = this._sourceCaches[e2].getSource();
  50304. t2[i3.id] || (t2[i3.id] = i3.serialize());
  50305. }
  50306. return e.filterObject({ version: this.stylesheet.version, name: this.stylesheet.name, metadata: this.stylesheet.metadata, light: this.stylesheet.light, terrain: this.stylesheet.terrain, fog: this.stylesheet.fog, center: this.stylesheet.center, zoom: this.stylesheet.zoom, bearing: this.stylesheet.bearing, pitch: this.stylesheet.pitch, sprite: this.stylesheet.sprite, glyphs: this.stylesheet.glyphs, transition: this.stylesheet.transition, projection: this.stylesheet.projection, sources: t2, layers: this._serializeLayers(this._order) }, (e2) => void 0 !== e2);
  50307. }
  50308. _updateLayer(e2) {
  50309. this._updatedLayers[e2.id] = true;
  50310. const t2 = this._getLayerSourceCache(e2);
  50311. e2.source && !this._updatedSources[e2.source] && t2 && "raster" !== t2.getSource().type && (this._updatedSources[e2.source] = "reload", t2.pause()), this._changed = true, e2.invalidateCompiledFilter();
  50312. }
  50313. _flattenAndSortRenderedFeatures(e2) {
  50314. const t2 = (e3) => "fill-extrusion" === this._layers[e3].type, i3 = {}, o2 = [];
  50315. for (let r3 = this._order.length - 1; r3 >= 0; r3--) {
  50316. const n2 = this._order[r3];
  50317. if (t2(n2)) {
  50318. i3[n2] = r3;
  50319. for (const t3 of e2) {
  50320. const e3 = t3[n2];
  50321. if (e3)
  50322. for (const t4 of e3)
  50323. o2.push(t4);
  50324. }
  50325. }
  50326. }
  50327. o2.sort((e3, t3) => t3.intersectionZ - e3.intersectionZ);
  50328. const r2 = [];
  50329. for (let n2 = this._order.length - 1; n2 >= 0; n2--) {
  50330. const a2 = this._order[n2];
  50331. if (t2(a2))
  50332. for (let e3 = o2.length - 1; e3 >= 0; e3--) {
  50333. const t3 = o2[e3].feature;
  50334. if (i3[t3.layer.id] < n2)
  50335. break;
  50336. r2.push(t3), o2.pop();
  50337. }
  50338. else
  50339. for (const t3 of e2) {
  50340. const e3 = t3[a2];
  50341. if (e3)
  50342. for (const t4 of e3)
  50343. r2.push(t4.feature);
  50344. }
  50345. }
  50346. return r2;
  50347. }
  50348. queryRenderedFeatures(t2, i3, o2) {
  50349. i3 && i3.filter && this._validate(e.validateFilter, "queryRenderedFeatures.filter", i3.filter, null, i3);
  50350. const r2 = {};
  50351. if (i3 && i3.layers) {
  50352. if (!Array.isArray(i3.layers))
  50353. return this.fire(new e.ErrorEvent(new Error("parameters.layers must be an Array."))), [];
  50354. for (const t3 of i3.layers) {
  50355. const i4 = this._layers[t3];
  50356. if (!i4)
  50357. return this.fire(new e.ErrorEvent(new Error(`The layer '${t3}' does not exist in the map's style and cannot be queried for features.`))), [];
  50358. r2[i4.source] = true;
  50359. }
  50360. }
  50361. const n2 = [];
  50362. i3.availableImages = this._availableImages;
  50363. const a2 = i3 && i3.layers ? i3.layers.some((e2) => {
  50364. const t3 = this.getLayer(e2);
  50365. return t3 && t3.is3D();
  50366. }) : this.has3DLayers(), s2 = R.createFromScreenPoints(t2, o2);
  50367. for (const e2 in this._sourceCaches) {
  50368. const t3 = this._sourceCaches[e2].getSource().id;
  50369. i3.layers && !r2[t3] || n2.push(Ae(this._sourceCaches[e2], this._layers, this._serializedLayers, s2, i3, o2, a2, !!this.map._showQueryGeometry));
  50370. }
  50371. return this.placement && n2.push(function(e2, t3, i4, o3, r3, n3, a3) {
  50372. const s3 = {}, l2 = n3.queryRenderedSymbols(o3), c2 = [];
  50373. for (const e3 of Object.keys(l2).map(Number))
  50374. c2.push(a3[e3]);
  50375. c2.sort(Re);
  50376. for (const i5 of c2) {
  50377. const o4 = i5.featureIndex.lookupSymbolFeatures(l2[i5.bucketInstanceId], t3, i5.bucketIndex, i5.sourceLayerIndex, r3.filter, r3.layers, r3.availableImages, e2);
  50378. for (const e3 in o4) {
  50379. const t4 = s3[e3] = s3[e3] || [], r4 = o4[e3];
  50380. r4.sort((e4, t5) => {
  50381. const o5 = i5.featureSortOrder;
  50382. if (o5) {
  50383. const i6 = o5.indexOf(e4.featureIndex);
  50384. return o5.indexOf(t5.featureIndex) - i6;
  50385. }
  50386. return t5.featureIndex - e4.featureIndex;
  50387. });
  50388. for (const e4 of r4)
  50389. t4.push(e4);
  50390. }
  50391. }
  50392. for (const t4 in s3)
  50393. s3[t4].forEach((o4) => {
  50394. const r4 = o4.feature, n4 = i4(e2[t4]).getFeatureState(r4.layer["source-layer"], r4.id);
  50395. r4.source = r4.layer.source, r4.layer["source-layer"] && (r4.sourceLayer = r4.layer["source-layer"]), r4.state = n4;
  50396. });
  50397. return s3;
  50398. }(this._layers, this._serializedLayers, this._getLayerSourceCache.bind(this), s2.screenGeometry, i3, this.placement.collisionIndex, this.placement.retainedQueryData)), this._flattenAndSortRenderedFeatures(n2);
  50399. }
  50400. querySourceFeatures(t2, i3) {
  50401. i3 && i3.filter && this._validate(e.validateFilter, "querySourceFeatures.filter", i3.filter, null, i3);
  50402. const o2 = this._getSourceCaches(t2);
  50403. let r2 = [];
  50404. for (const e2 of o2)
  50405. r2 = r2.concat(Le(e2, i3));
  50406. return r2;
  50407. }
  50408. addSourceType(e2, t2, i3) {
  50409. return $t.getSourceType(e2) ? i3(new Error(`A source type called "${e2}" already exists.`)) : ($t.setSourceType(e2, t2), t2.workerSourceURL ? void this.dispatcher.broadcast("loadWorkerSource", { name: e2, url: t2.workerSourceURL }, i3) : i3(null, null));
  50410. }
  50411. getLight() {
  50412. return this.light.getLight();
  50413. }
  50414. setLight(t2, i3 = {}) {
  50415. this._checkLoaded();
  50416. const o2 = this.light.getLight();
  50417. let n2 = false;
  50418. for (const e2 in t2)
  50419. if (!r(t2[e2], o2[e2])) {
  50420. n2 = true;
  50421. break;
  50422. }
  50423. if (!n2)
  50424. return;
  50425. const a2 = { now: e.exported.now(), transition: e.extend({ duration: 300, delay: 0 }, this.stylesheet.transition) };
  50426. this.light.setLight(t2, i3), this.light.updateTransitions(a2);
  50427. }
  50428. getTerrain() {
  50429. return this.terrain && 1 === this.terrain.drapeRenderMode ? this.terrain.get() : null;
  50430. }
  50431. setTerrainForDraping() {
  50432. this.setTerrain({ source: "", exaggeration: 0 }, 0);
  50433. }
  50434. setTerrain(t2, i3 = 1) {
  50435. if (this._checkLoaded(), !t2)
  50436. return delete this.terrain, delete this.stylesheet.terrain, this.dispatcher.broadcast("enableTerrain", false), this._force3DLayerUpdate(), void (this._markersNeedUpdate = true);
  50437. if (1 === i3) {
  50438. if ("object" == typeof t2.source) {
  50439. const i4 = "terrain-dem-src";
  50440. this.addSource(i4, t2.source), t2 = e.clone$1(t2), t2 = e.extend(t2, { source: i4 });
  50441. }
  50442. if (this._validate(e.validateTerrain, "terrain", t2))
  50443. return;
  50444. }
  50445. if (!this.terrain || this.terrain && i3 !== this.terrain.drapeRenderMode)
  50446. this._createTerrain(t2, i3);
  50447. else {
  50448. const i4 = this.terrain, o2 = i4.get();
  50449. for (const n2 in t2)
  50450. if (!r(t2[n2], o2[n2])) {
  50451. i4.set(t2), this.stylesheet.terrain = t2;
  50452. const o3 = { now: e.exported.now(), transition: e.extend({ duration: 0 }, this.stylesheet.transition) };
  50453. i4.updateTransitions(o3);
  50454. break;
  50455. }
  50456. }
  50457. this._updateDrapeFirstLayers(), this._markersNeedUpdate = true;
  50458. }
  50459. _createFog(t2) {
  50460. const i3 = this.fog = new P(t2, this.map.transform);
  50461. this.stylesheet.fog = t2;
  50462. const o2 = { now: e.exported.now(), transition: e.extend({ duration: 0 }, this.stylesheet.transition) };
  50463. i3.updateTransitions(o2);
  50464. }
  50465. _updateMarkersOpacity() {
  50466. 0 !== this.map._markers.length && this.map._requestDomTask(() => {
  50467. for (const e2 of this.map._markers)
  50468. e2._evaluateOpacity();
  50469. });
  50470. }
  50471. getFog() {
  50472. return this.fog ? this.fog.get() : null;
  50473. }
  50474. setFog(t2) {
  50475. if (this._checkLoaded(), !t2)
  50476. return delete this.fog, delete this.stylesheet.fog, void (this._markersNeedUpdate = true);
  50477. if (this.fog) {
  50478. const i3 = this.fog, o2 = i3.get();
  50479. for (const n2 in t2)
  50480. if (!r(t2[n2], o2[n2])) {
  50481. i3.set(t2), this.stylesheet.fog = t2;
  50482. const o3 = { now: e.exported.now(), transition: e.extend({ duration: 0 }, this.stylesheet.transition) };
  50483. i3.updateTransitions(o3);
  50484. break;
  50485. }
  50486. } else
  50487. this._createFog(t2);
  50488. this._markersNeedUpdate = true;
  50489. }
  50490. _updateDrapeFirstLayers() {
  50491. if (!this.map._optimizeForTerrain || !this.terrain)
  50492. return;
  50493. const e2 = this._order.filter((e3) => this.isLayerDraped(this._layers[e3])), t2 = this._order.filter((e3) => !this.isLayerDraped(this._layers[e3]));
  50494. this._drapedFirstOrder = [], this._drapedFirstOrder.push(...e2), this._drapedFirstOrder.push(...t2);
  50495. }
  50496. _createTerrain(t2, i3) {
  50497. const o2 = this.terrain = new I(t2, i3);
  50498. this.stylesheet.terrain = t2, this.dispatcher.broadcast("enableTerrain", !this.terrainSetForDrapingOnly()), this._force3DLayerUpdate();
  50499. const r2 = { now: e.exported.now(), transition: e.extend({ duration: 0 }, this.stylesheet.transition) };
  50500. o2.updateTransitions(r2);
  50501. }
  50502. _force3DLayerUpdate() {
  50503. for (const e2 in this._layers) {
  50504. const t2 = this._layers[e2];
  50505. "fill-extrusion" === t2.type && this._updateLayer(t2);
  50506. }
  50507. }
  50508. _forceSymbolLayerUpdate() {
  50509. for (const e2 in this._layers) {
  50510. const t2 = this._layers[e2];
  50511. "symbol" === t2.type && this._updateLayer(t2);
  50512. }
  50513. }
  50514. _validate(t2, i3, o2, r2, n2 = {}) {
  50515. return (!n2 || false !== n2.validate) && Zt(this, t2.call(e.validateStyle, e.extend({ key: i3, style: this.serialize(), value: o2, styleSpec: e.spec }, r2)));
  50516. }
  50517. _remove() {
  50518. this._request && (this._request.cancel(), this._request = null), this._spriteRequest && (this._spriteRequest.cancel(), this._spriteRequest = null), e.evented.off("pluginStateChange", this._rtlTextPluginCallback);
  50519. for (const e2 in this._layers)
  50520. this._layers[e2].setEventedParent(null);
  50521. for (const e2 in this._sourceCaches)
  50522. this._sourceCaches[e2].clearTiles(), this._sourceCaches[e2].setEventedParent(null);
  50523. this.imageManager.setEventedParent(null), this.setEventedParent(null), this.dispatcher.remove();
  50524. }
  50525. _clearSource(e2) {
  50526. const t2 = this._getSourceCaches(e2);
  50527. for (const e3 of t2)
  50528. e3.clearTiles();
  50529. }
  50530. _reloadSource(e2) {
  50531. const t2 = this._getSourceCaches(e2);
  50532. for (const e3 of t2)
  50533. e3.resume(), e3.reload();
  50534. }
  50535. _updateSources(e2) {
  50536. for (const t2 in this._sourceCaches)
  50537. this._sourceCaches[t2].update(e2);
  50538. }
  50539. _generateCollisionBoxes() {
  50540. for (const e2 in this._sourceCaches) {
  50541. const t2 = this._sourceCaches[e2];
  50542. t2.resume(), t2.reload();
  50543. }
  50544. }
  50545. _updatePlacement(t2, i3, o2, r2, n2 = false) {
  50546. let a2 = false, s2 = false;
  50547. const l2 = {};
  50548. for (const e2 of this._order) {
  50549. const i4 = this._layers[e2];
  50550. if ("symbol" !== i4.type)
  50551. continue;
  50552. if (!l2[i4.source]) {
  50553. const e3 = this._getLayerSourceCache(i4);
  50554. if (!e3)
  50555. continue;
  50556. l2[i4.source] = e3.getRenderableIds(true).map((t3) => e3.getTileByID(t3)).sort((e4, t3) => t3.tileID.overscaledZ - e4.tileID.overscaledZ || (e4.tileID.isLessThan(t3.tileID) ? -1 : 1));
  50557. }
  50558. const o3 = this.crossTileSymbolIndex.addLayer(i4, l2[i4.source], t2.center.lng, t2.projection);
  50559. a2 = a2 || o3;
  50560. }
  50561. if (this.crossTileSymbolIndex.pruneUnusedLayers(this._order), n2 = n2 || this._layerOrderChanged || 0 === o2, this._layerOrderChanged && this.fire(new e.Event("neworder")), (n2 || !this.pauseablePlacement || this.pauseablePlacement.isDone() && !this.placement.stillRecent(e.exported.now(), t2.zoom)) && (this.pauseablePlacement = new Bt(t2, this._order, n2, i3, o2, r2, this.placement, this.fog && t2.projection.supportsFog ? this.fog.state : null), this._layerOrderChanged = false), this.pauseablePlacement.isDone() ? this.placement.setStale() : (this.pauseablePlacement.continuePlacement(this._order, this._layers, l2), this.pauseablePlacement.isDone() && (this.placement = this.pauseablePlacement.commit(e.exported.now()), s2 = true), a2 && this.pauseablePlacement.placement.setStale()), s2 || a2)
  50562. for (const e2 of this._order) {
  50563. const t3 = this._layers[e2];
  50564. "symbol" === t3.type && this.placement.updateLayerOpacities(t3, l2[t3.source]);
  50565. }
  50566. return !this.pauseablePlacement.isDone() || this.placement.hasTransitions(e.exported.now());
  50567. }
  50568. _releaseSymbolFadeTiles() {
  50569. for (const e2 in this._sourceCaches)
  50570. this._sourceCaches[e2].releaseSymbolFadeTiles();
  50571. }
  50572. getImages(e2, t2, i3) {
  50573. this.imageManager.getImages(t2.icons, i3), this._updateTilesForChangedImages();
  50574. const o2 = (e3) => {
  50575. e3 && e3.setDependencies(t2.tileID.key, t2.type, t2.icons);
  50576. };
  50577. o2(this._otherSourceCaches[t2.source]), o2(this._symbolSourceCaches[t2.source]);
  50578. }
  50579. getGlyphs(e2, t2, i3) {
  50580. this.glyphManager.getGlyphs(t2.stacks, i3);
  50581. }
  50582. getResource(t2, i3, o2) {
  50583. return e.makeRequest(i3, o2);
  50584. }
  50585. _getSourceCache(e2) {
  50586. return this._otherSourceCaches[e2];
  50587. }
  50588. _getLayerSourceCache(e2) {
  50589. return "symbol" === e2.type ? this._symbolSourceCaches[e2.source] : this._otherSourceCaches[e2.source];
  50590. }
  50591. _getSourceCaches(e2) {
  50592. const t2 = [];
  50593. return this._otherSourceCaches[e2] && t2.push(this._otherSourceCaches[e2]), this._symbolSourceCaches[e2] && t2.push(this._symbolSourceCaches[e2]), t2;
  50594. }
  50595. _isSourceCacheLoaded(t2) {
  50596. const i3 = this._getSourceCaches(t2);
  50597. return 0 === i3.length ? (this.fire(new e.ErrorEvent(new Error(`There is no source with ID '${t2}'`))), false) : i3.every((e2) => e2.loaded());
  50598. }
  50599. has3DLayers() {
  50600. return this._num3DLayers > 0;
  50601. }
  50602. hasSymbolLayers() {
  50603. return this._numSymbolLayers > 0;
  50604. }
  50605. hasCircleLayers() {
  50606. return this._numCircleLayers > 0;
  50607. }
  50608. _clearWorkerCaches() {
  50609. this.dispatcher.broadcast("clearCaches");
  50610. }
  50611. destroy() {
  50612. this._clearWorkerCaches(), this.terrainSetForDrapingOnly() && (delete this.terrain, delete this.stylesheet.terrain);
  50613. }
  50614. }
  50615. $t.getSourceType = function(e2) {
  50616. return ze[e2];
  50617. }, $t.setSourceType = function(e2, t2) {
  50618. ze[e2] = t2;
  50619. }, $t.registerForPluginStateChange = e.registerForPluginStateChange;
  50620. var Ht = "\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#define HALF_PI PI/2.0\n#define QUARTER_PI PI/4.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}\n#endif", Kt = "attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}";
  50621. let Yt = {}, Jt = {};
  50622. Yt = ii("", "\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;\n#endif\nuniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nfloat unpack_depth(vec4 rgba_depth)\n{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;\n#else\nvec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);\n#endif\nreturn vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;vec4 bounds=vec4(d,vec2(1.0)-d);h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif", true), Jt = ii("#ifdef FOG\nuniform float u_fog_temporal_offset;float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif", "#ifdef FOG\nuniform mat4 u_fog_matrix;vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif", true);
  50623. const Qt = ii("\nhighp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef TERRAIN\nhighp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#endif", "\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered."), ei = Ht;
  50624. var ti = { background: ii("uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"), backgroundPattern: ii("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_mix);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"), circle: ii("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 scaled_extrude=extrude*a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=scaled_extrude.x*surface_vectors[0]+scaled_extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);vec4 world_center=vec4(pos,1);\n#else \nmat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\n#if defined(SCALE_WITH_MAP) && defined(PROJECTION_GLOBE_VIEW)\nview_scale*=a_scale;\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nvec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}"), clippingMask: ii("void main() {gl_FragColor=vec4(1.0);}", "attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"), heatmap: ii("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\ngl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nextrude*=a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\nvec3 pos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"), heatmapTexture: ii("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}", "attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"), collisionBox: ii("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}", "attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"), collisionCircle: ii("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}", "attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"), debug: ii("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}", "attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;\n#endif\nvarying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}"), fill: ii("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"), fillOutline: ii("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"), fillOutlinePattern: ii("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"), fillPattern: ii("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"), fillExtrusion: ii("varying vec4 v_color;void main() {vec4 color=v_color;\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);\n#else\nvec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(pos.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"), fillExtrusionPattern: ii("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);\n#else\nvec3 p=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"), hillshadePrepare: ii("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nreturn texture2D(u_image,coord).a/4.0;\n#else\nvec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;\n#endif\n}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"), hillshade: ii("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"), line: ii("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\n#ifdef RENDER_LINE_GRADIENT\nvec4 out_color=texture2D(u_gradient_image,v_uv);\n#else\nvec4 out_color=color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#ifdef RENDER_LINE_GRADIENT\nattribute vec3 a_packed;\n#else\nattribute float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];float a_linesofar=a_packed[2];highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);\n#endif\n#ifdef RENDER_LINE_DASH\nfloat tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"), linePattern: ii("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"), raster: ii("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"), symbolIcon: ii("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchor_z=a_z_tile_anchor.x;vec2 tile_anchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchor_z)+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(a_pos,anchor_z)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point=u_matrix*vec4(a_pos+vec2(1,0),anchor_z,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition);\n#else\nvec3 proj_pos=vec3(a_projected_pos.xy,anchor_z);\n#endif\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}"), symbolSDF: ii("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchor_z=a_z_tile_anchor.x;vec2 tile_anchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchor_z)+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(a_pos,anchor_z)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point=u_matrix*vec4(a_pos+vec2(1,0),anchor_z,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition);\n#else\nvec3 proj_pos=vec3(a_projected_pos.xy,anchor_z);\n#endif\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}"), symbolTextAndIcon: ii("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchor_z=a_z_tile_anchor.x;vec2 tile_anchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchor_z)+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(a_pos,anchor_z)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),anchor_z,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition);\n#else\nvec3 proj_pos=vec3(a_projected_pos.xy,anchor_z);\n#endif\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}"), terrainRaster: ii("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nconst float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n}"), terrainDepth: ii("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}", "uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"), skybox: ii("\nvarying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", Kt), skyboxGradient: ii("varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", Kt), skyboxCapture: ii("\nvarying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;\n#ifdef GL_ES\nprecision highp float;\n#endif\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}", "attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"), globeRaster: ii("uniform sampler2D u_image0;varying vec2 v_pos0;void main() {gl_FragColor=texture2D(u_image0,v_pos0);\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}", "uniform mat4 u_proj_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;\n#ifdef GLOBE_POLES\nattribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;\n#else\nattribute vec2 a_pos;\n#endif\nvarying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 merc_pos=a_merc_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idy=u_grid_matrix[1][2];float S=u_grid_matrix[2][2];vec3 latLng=u_grid_matrix*vec3(a_pos,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=a_pos[0]*S;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;uv=uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nvec4 globe=u_globe_matrix*vec4(globe_pos+up_vector.xyz*height,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);}"), globeAtmosphere: ii("uniform float u_opacity;uniform highp float u_fadeout_range;uniform vec3 u_start_color;uniform vec3 u_end_color;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;varying highp vec3 v_ray_dir;void main() {highp vec3 dir=normalize(v_ray_dir);highp vec3 closest_point=abs(dot(u_globe_pos,dir))*dir;float norm_dist_from_center=length(closest_point-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 1.0)\ndiscard;float t=clamp(1.0-sqrt(norm_dist_from_center-1.0)/u_fadeout_range,0.0,1.0);vec3 color=mix(u_start_color,u_end_color,1.0-t);gl_FragColor=vec4(color*t*u_opacity,u_opacity);}", "attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;varying highp vec3 v_ray_dir;void main() {v_ray_dir=mix(mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);gl_Position=vec4(a_pos,1.0);}") };
  50625. function ii(e2, t2, i3) {
  50626. const o2 = /#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g, r2 = /uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g, n2 = t2.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g), a2 = e2.match(r2), s2 = t2.match(r2), l2 = Ht.match(r2);
  50627. let c2 = s2 ? s2.concat(a2) : a2;
  50628. i3 || (Yt.staticUniforms && (c2 = Yt.staticUniforms.concat(c2)), Jt.staticUniforms && (c2 = Jt.staticUniforms.concat(c2))), c2 && (c2 = c2.concat(l2));
  50629. const h2 = {};
  50630. return { fragmentSource: e2 = e2.replace(o2, (e3, t3, i4, o3, r3) => (h2[r3] = true, "define" === t3 ? `
  50631. #ifndef HAS_UNIFORM_u_${r3}
  50632. varying ${i4} ${o3} ${r3};
  50633. #else
  50634. uniform ${i4} ${o3} u_${r3};
  50635. #endif
  50636. ` : `
  50637. #ifdef HAS_UNIFORM_u_${r3}
  50638. ${i4} ${o3} ${r3} = u_${r3};
  50639. #endif
  50640. `)), vertexSource: t2 = t2.replace(o2, (e3, t3, i4, o3, r3) => {
  50641. const n3 = "float" === o3 ? "vec2" : "vec4", a3 = r3.match(/color/) ? "color" : n3;
  50642. return h2[r3] ? "define" === t3 ? `
  50643. #ifndef HAS_UNIFORM_u_${r3}
  50644. uniform lowp float u_${r3}_t;
  50645. attribute ${i4} ${n3} a_${r3};
  50646. varying ${i4} ${o3} ${r3};
  50647. #else
  50648. uniform ${i4} ${o3} u_${r3};
  50649. #endif
  50650. ` : "vec4" === a3 ? `
  50651. #ifndef HAS_UNIFORM_u_${r3}
  50652. ${r3} = a_${r3};
  50653. #else
  50654. ${i4} ${o3} ${r3} = u_${r3};
  50655. #endif
  50656. ` : `
  50657. #ifndef HAS_UNIFORM_u_${r3}
  50658. ${r3} = unpack_mix_${a3}(a_${r3}, u_${r3}_t);
  50659. #else
  50660. ${i4} ${o3} ${r3} = u_${r3};
  50661. #endif
  50662. ` : "define" === t3 ? `
  50663. #ifndef HAS_UNIFORM_u_${r3}
  50664. uniform lowp float u_${r3}_t;
  50665. attribute ${i4} ${n3} a_${r3};
  50666. #else
  50667. uniform ${i4} ${o3} u_${r3};
  50668. #endif
  50669. ` : "vec4" === a3 ? `
  50670. #ifndef HAS_UNIFORM_u_${r3}
  50671. ${i4} ${o3} ${r3} = a_${r3};
  50672. #else
  50673. ${i4} ${o3} ${r3} = u_${r3};
  50674. #endif
  50675. ` : `
  50676. #ifndef HAS_UNIFORM_u_${r3}
  50677. ${i4} ${o3} ${r3} = unpack_mix_${a3}(a_${r3}, u_${r3}_t);
  50678. #else
  50679. ${i4} ${o3} ${r3} = u_${r3};
  50680. #endif
  50681. `;
  50682. }), staticAttributes: n2, staticUniforms: c2 };
  50683. }
  50684. class oi {
  50685. constructor() {
  50686. this.boundProgram = null, this.boundLayoutVertexBuffer = null, this.boundPaintVertexBuffers = [], this.boundIndexBuffer = null, this.boundVertexOffset = null, this.boundDynamicVertexBuffer = null, this.vao = null;
  50687. }
  50688. bind(e2, t2, i3, o2, r2, n2, a2, s2) {
  50689. this.context = e2;
  50690. let l2 = this.boundPaintVertexBuffers.length !== o2.length;
  50691. for (let e3 = 0; !l2 && e3 < o2.length; e3++)
  50692. this.boundPaintVertexBuffers[e3] !== o2[e3] && (l2 = true);
  50693. e2.extVertexArrayObject && this.vao && this.boundProgram === t2 && this.boundLayoutVertexBuffer === i3 && !l2 && this.boundIndexBuffer === r2 && this.boundVertexOffset === n2 && this.boundDynamicVertexBuffer === a2 && this.boundDynamicVertexBuffer2 === s2 ? (e2.bindVertexArrayOES.set(this.vao), a2 && a2.bind(), r2 && r2.dynamicDraw && r2.bind(), s2 && s2.bind()) : this.freshBind(t2, i3, o2, r2, n2, a2, s2);
  50694. }
  50695. freshBind(e2, t2, i3, o2, r2, n2, a2) {
  50696. let s2;
  50697. const l2 = e2.numAttributes, c2 = this.context, h2 = c2.gl;
  50698. if (c2.extVertexArrayObject)
  50699. this.vao && this.destroy(), this.vao = c2.extVertexArrayObject.createVertexArrayOES(), c2.bindVertexArrayOES.set(this.vao), s2 = 0, this.boundProgram = e2, this.boundLayoutVertexBuffer = t2, this.boundPaintVertexBuffers = i3, this.boundIndexBuffer = o2, this.boundVertexOffset = r2, this.boundDynamicVertexBuffer = n2, this.boundDynamicVertexBuffer2 = a2;
  50700. else {
  50701. s2 = c2.currentNumAttributes || 0;
  50702. for (let e3 = l2; e3 < s2; e3++)
  50703. h2.disableVertexAttribArray(e3);
  50704. }
  50705. t2.enableAttributes(h2, e2);
  50706. for (const t3 of i3)
  50707. t3.enableAttributes(h2, e2);
  50708. n2 && n2.enableAttributes(h2, e2), a2 && a2.enableAttributes(h2, e2), t2.bind(), t2.setVertexAttribPointers(h2, e2, r2);
  50709. for (const t3 of i3)
  50710. t3.bind(), t3.setVertexAttribPointers(h2, e2, r2);
  50711. n2 && (n2.bind(), n2.setVertexAttribPointers(h2, e2, r2)), o2 && o2.bind(), a2 && (a2.bind(), a2.setVertexAttribPointers(h2, e2, r2)), c2.currentNumAttributes = l2;
  50712. }
  50713. destroy() {
  50714. this.vao && (this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao), this.vao = null);
  50715. }
  50716. }
  50717. function ri(t2, i3) {
  50718. const o2 = Math.pow(2, i3.canonical.z), r2 = i3.canonical.y;
  50719. return [new e.MercatorCoordinate(0, r2 / o2).toLngLat().lat, new e.MercatorCoordinate(0, (r2 + 1) / o2).toLngLat().lat];
  50720. }
  50721. function ni(t2, i3, o2, r2, n2, a2, s2) {
  50722. const l2 = t2.context, c2 = l2.gl, h2 = o2.fbo;
  50723. if (!h2)
  50724. return;
  50725. t2.prepareDrawTile();
  50726. const _2 = t2.useProgram("hillshade");
  50727. l2.activeTexture.set(c2.TEXTURE0), c2.bindTexture(c2.TEXTURE_2D, h2.colorAttachment.get());
  50728. const u2 = ((e2, t3, i4, o3) => {
  50729. const r3 = i4.paint.get("hillshade-shadow-color"), n3 = i4.paint.get("hillshade-highlight-color"), a3 = i4.paint.get("hillshade-accent-color");
  50730. let s3 = i4.paint.get("hillshade-illumination-direction") * (Math.PI / 180);
  50731. "viewport" === i4.paint.get("hillshade-illumination-anchor") && (s3 -= e2.transform.angle);
  50732. const l3 = !e2.options.moving;
  50733. return { u_matrix: o3 || e2.transform.calculateProjMatrix(t3.tileID.toUnwrapped(), l3), u_image: 0, u_latrange: ri(0, t3.tileID), u_light: [i4.paint.get("hillshade-exaggeration"), s3], u_shadow: r3, u_highlight: n3, u_accent: a3 };
  50734. })(t2, o2, r2, t2.terrain ? i3.projMatrix : null);
  50735. t2.prepareDrawProgram(l2, _2, i3.toUnwrapped());
  50736. const { tileBoundsBuffer: d2, tileBoundsIndexBuffer: p2, tileBoundsSegments: m2 } = t2.getTileBoundsBuffers(o2);
  50737. _2.draw(l2, c2.TRIANGLES, n2, a2, s2, e.CullFaceMode.disabled, u2, r2.id, d2, p2, m2);
  50738. }
  50739. function ai(t2, i3, o2) {
  50740. if (!i3.needsDEMTextureUpload)
  50741. return;
  50742. const r2 = t2.context, n2 = r2.gl;
  50743. r2.pixelStoreUnpackPremultiplyAlpha.set(false), i3.demTexture = i3.demTexture || t2.getTileTexture(o2.stride);
  50744. const a2 = o2.getPixels();
  50745. i3.demTexture ? i3.demTexture.update(a2, { premultiply: false }) : i3.demTexture = new e.Texture(r2, a2, n2.RGBA, { premultiply: false }), i3.needsDEMTextureUpload = false;
  50746. }
  50747. function si(t2, i3, o2, r2, n2, a2) {
  50748. const s2 = t2.context, l2 = s2.gl;
  50749. if (!i3.dem)
  50750. return;
  50751. const c2 = i3.dem;
  50752. if (s2.activeTexture.set(l2.TEXTURE1), ai(t2, i3, c2), !i3.demTexture)
  50753. return;
  50754. i3.demTexture.bind(l2.NEAREST, l2.CLAMP_TO_EDGE);
  50755. const h2 = c2.dim;
  50756. s2.activeTexture.set(l2.TEXTURE0);
  50757. let _2 = i3.fbo;
  50758. if (!_2) {
  50759. const t3 = new e.Texture(s2, { width: h2, height: h2, data: null }, l2.RGBA);
  50760. t3.bind(l2.LINEAR, l2.CLAMP_TO_EDGE), _2 = i3.fbo = s2.createFramebuffer(h2, h2, true), _2.colorAttachment.set(t3.texture);
  50761. }
  50762. s2.bindFramebuffer.set(_2.framebuffer), s2.viewport.set([0, 0, h2, h2]);
  50763. const { tileBoundsBuffer: u2, tileBoundsIndexBuffer: d2, tileBoundsSegments: p2 } = t2.getMercatorTileBoundsBuffers();
  50764. t2.useProgram("hillshadePrepare").draw(s2, l2.TRIANGLES, r2, n2, a2, e.CullFaceMode.disabled, ((t3, i4) => {
  50765. const o3 = i4.stride, r3 = e.create();
  50766. return e.ortho(r3, 0, e.EXTENT, -e.EXTENT, 0, 0, 1), e.translate(r3, r3, [0, -e.EXTENT, 0]), { u_matrix: r3, u_image: 1, u_dimension: [o3, o3], u_zoom: t3.overscaledZ, u_unpack: i4.unpackVector };
  50767. })(i3.tileID, c2), o2.id, u2, d2, p2), i3.needsHillshadePrepare = false;
  50768. }
  50769. const li = (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_image0: new e.Uniform1i(t2, i3.u_image0), u_skirt_height: new e.Uniform1f(t2, i3.u_skirt_height) }), ci = (e2, t2) => ({ u_matrix: e2, u_image0: 0, u_skirt_height: t2 }), hi = (e2, t2, i3, o2, r2, n2) => ({ u_proj_matrix: Float32Array.from(e2), u_globe_matrix: t2, u_merc_matrix: i3, u_zoom_transition: o2, u_merc_center: r2, u_image0: 0, u_grid_matrix: n2 ? Float32Array.from(n2) : new Float32Array(9) });
  50770. function _i(e2, t2) {
  50771. return null != e2 && null != t2 && !(!e2.hasData() || !t2.hasData()) && null != e2.demTexture && null != t2.demTexture && e2.tileID.key !== t2.tileID.key;
  50772. }
  50773. const ui = new class {
  50774. constructor() {
  50775. this.operations = {};
  50776. }
  50777. newMorphing(e2, t2, i3, o2, r2) {
  50778. if (e2 in this.operations) {
  50779. const t3 = this.operations[e2];
  50780. t3.to.tileID.key !== i3.tileID.key && (t3.queued = i3);
  50781. } else
  50782. this.operations[e2] = { startTime: o2, phase: 0, duration: r2, from: t2, to: i3, queued: null };
  50783. }
  50784. getMorphValuesForProxy(e2) {
  50785. if (!(e2 in this.operations))
  50786. return null;
  50787. const t2 = this.operations[e2];
  50788. return { from: t2.from, to: t2.to, phase: t2.phase };
  50789. }
  50790. update(e2) {
  50791. for (const t2 in this.operations) {
  50792. const i3 = this.operations[t2];
  50793. for (i3.phase = (e2 - i3.startTime) / i3.duration; i3.phase >= 1 || !this._validOp(i3); )
  50794. if (!this._nextOp(i3, e2)) {
  50795. delete this.operations[t2];
  50796. break;
  50797. }
  50798. }
  50799. }
  50800. _nextOp(e2, t2) {
  50801. return !!e2.queued && (e2.from = e2.to, e2.to = e2.queued, e2.queued = null, e2.phase = 0, e2.startTime = t2, true);
  50802. }
  50803. _validOp(e2) {
  50804. return e2.from.hasData() && e2.to.hasData();
  50805. }
  50806. }(), di = { 0: null, 1: "TERRAIN_VERTEX_MORPHING", 2: "TERRAIN_WIREFRAME" };
  50807. function pi(e2, t2) {
  50808. const i3 = 1 << e2.z;
  50809. return !t2 && (0 === e2.x || e2.x === i3 - 1) || 0 === e2.y || e2.y === i3 - 1;
  50810. }
  50811. const mi = (e2) => ({ u_matrix: e2 });
  50812. function fi(t2, i3, o2, r2, n2) {
  50813. if (n2 > 0) {
  50814. const a2 = e.exported.now(), s2 = (a2 - t2.timeAdded) / n2, l2 = i3 ? (a2 - i3.timeAdded) / n2 : -1, c2 = o2.getSource(), h2 = r2.coveringZoomLevel({ tileSize: c2.tileSize, roundZoom: c2.roundZoom }), _2 = !i3 || Math.abs(i3.tileID.overscaledZ - h2) > Math.abs(t2.tileID.overscaledZ - h2), u2 = _2 && t2.refreshedUponExpiration ? 1 : e.clamp(_2 ? s2 : 1 - l2, 0, 1);
  50815. return t2.refreshedUponExpiration && s2 >= 1 && (t2.refreshedUponExpiration = false), i3 ? { opacity: 1, mix: 1 - u2 } : { opacity: u2, mix: 0 };
  50816. }
  50817. return { opacity: 1, mix: 0 };
  50818. }
  50819. const gi = 2 * e.mercatorZfromAltitude(1, 0) * e.GLOBE_RADIUS * Math.PI;
  50820. class vi extends e.SourceCache {
  50821. constructor(e2) {
  50822. const t2 = { type: "raster-dem", maxzoom: e2.transform.maxZoom }, i3 = new A(Ue(), null), o2 = De("mock-dem", t2, i3, e2.style);
  50823. super("mock-dem", o2, false), o2.setEventedParent(this), this._sourceLoaded = true;
  50824. }
  50825. _loadTile(e2, t2) {
  50826. e2.state = "loaded", t2(null);
  50827. }
  50828. }
  50829. class xi extends e.SourceCache {
  50830. constructor(e2) {
  50831. const t2 = De("proxy", { type: "geojson", maxzoom: e2.transform.maxZoom }, new A(Ue(), null), e2.style);
  50832. super("proxy", t2, false), t2.setEventedParent(this), this.map = this.getSource().map = e2, this.used = this._sourceLoaded = true, this.renderCache = [], this.renderCachePool = [], this.proxyCachedFBO = {};
  50833. }
  50834. update(t2, i3, o2) {
  50835. if (t2.freezeTileCoverage)
  50836. return;
  50837. this.transform = t2;
  50838. const r2 = t2.coveringTiles({ tileSize: this._source.tileSize, minzoom: this._source.minzoom, maxzoom: this._source.maxzoom, roundZoom: this._source.roundZoom, reparseOverscaled: this._source.reparseOverscaled }).reduce((i4, o3) => {
  50839. if (i4[o3.key] = "", !this._tiles[o3.key]) {
  50840. const i5 = new e.Tile(o3, this._source.tileSize * o3.overscaleFactor(), t2.tileZoom);
  50841. i5.state = "loaded", this._tiles[o3.key] = i5;
  50842. }
  50843. return i4;
  50844. }, {});
  50845. for (const e2 in this._tiles)
  50846. e2 in r2 || (this.freeFBO(e2), this._tiles[e2].unloadVectorData(), delete this._tiles[e2]);
  50847. }
  50848. freeFBO(e2) {
  50849. const t2 = this.proxyCachedFBO[e2];
  50850. if (void 0 !== t2) {
  50851. const i3 = Object.values(t2);
  50852. this.renderCachePool.push(...i3), delete this.proxyCachedFBO[e2];
  50853. }
  50854. }
  50855. deallocRenderCache() {
  50856. this.renderCache.forEach((e2) => e2.fb.destroy()), this.renderCache = [], this.renderCachePool = [], this.proxyCachedFBO = {};
  50857. }
  50858. }
  50859. class yi extends e.OverscaledTileID {
  50860. constructor(e2, t2, i3) {
  50861. super(e2.overscaledZ, e2.wrap, e2.canonical.z, e2.canonical.x, e2.canonical.y), this.proxyTileKey = t2, this.projMatrix = i3;
  50862. }
  50863. }
  50864. class bi extends e.Elevation {
  50865. constructor(t2, i3) {
  50866. super(), this.painter = t2, this.terrainTileForTile = {}, this.prevTerrainTileForTile = {};
  50867. const [o2, r2, n2] = function(t3) {
  50868. const i4 = new e.StructArrayLayout4i8(), o3 = new e.StructArrayLayout3ui6(), r3 = 131;
  50869. i4.reserve(17161), o3.reserve(33800);
  50870. const n3 = e.EXTENT / 128, a3 = e.EXTENT + n3 / 2, s3 = a3 + n3;
  50871. for (let t4 = -n3; t4 < s3; t4 += n3)
  50872. for (let o4 = -n3; o4 < s3; o4 += n3) {
  50873. const r4 = o4 < 0 || o4 > a3 || t4 < 0 || t4 > a3 ? 24575 : 0, n4 = e.clamp(Math.round(o4), 0, e.EXTENT), s4 = e.clamp(Math.round(t4), 0, e.EXTENT);
  50874. i4.emplaceBack(n4 + r4, s4, n4, s4);
  50875. }
  50876. const l2 = (e2, t4) => {
  50877. const i5 = t4 * r3 + e2;
  50878. o3.emplaceBack(i5 + 1, i5, i5 + r3), o3.emplaceBack(i5 + r3, i5 + r3 + 1, i5 + 1);
  50879. };
  50880. for (let e2 = 1; e2 < 129; e2++)
  50881. for (let t4 = 1; t4 < 129; t4++)
  50882. l2(t4, e2);
  50883. return [0, 129].forEach((e2) => {
  50884. for (let t4 = 0; t4 < 130; t4++)
  50885. l2(t4, e2), l2(e2, t4);
  50886. }), [i4, o3, 32768];
  50887. }(), a2 = t2.context;
  50888. this.gridBuffer = a2.createVertexBuffer(o2, e.boundsAttributes.members), this.gridIndexBuffer = a2.createIndexBuffer(r2), this.gridSegments = e.SegmentVector.simpleSegment(0, 0, o2.length, r2.length), this.gridNoSkirtSegments = e.SegmentVector.simpleSegment(0, 0, o2.length, n2), this.proxyCoords = [], this.proxiedCoords = {}, this._visibleDemTiles = [], this._drapedRenderBatches = [], this._sourceTilesOverlap = {}, this.proxySourceCache = new xi(i3.map), this.orthoMatrix = e.create(), e.ortho(this.orthoMatrix, 0, e.EXTENT, 0, e.EXTENT, 0, 1);
  50889. const s2 = a2.gl;
  50890. this._overlapStencilMode = new e.StencilMode({ func: s2.GEQUAL, mask: 255 }, 0, 255, s2.KEEP, s2.KEEP, s2.REPLACE), this._previousZoom = t2.transform.zoom, this.pool = [], this._findCoveringTileCache = {}, this._tilesDirty = {}, this.style = i3, this._useVertexMorphing = true, this._exaggeration = 1, this._mockSourceCache = new vi(i3.map);
  50891. }
  50892. set style(e2) {
  50893. e2.on("data", this._onStyleDataEvent.bind(this)), e2.on("neworder", this._checkRenderCacheEfficiency.bind(this)), this._style = e2, this._checkRenderCacheEfficiency();
  50894. }
  50895. update(t2, i3, o2) {
  50896. if (t2 && t2.terrain) {
  50897. this._style !== t2 && (this.style = t2), this.enabled = true;
  50898. const r2 = t2.terrain.properties;
  50899. this.sourceCache = 0 === t2.terrain.drapeRenderMode ? this._mockSourceCache : t2._getSourceCache(r2.get("source")), this._exaggeration = r2.get("exaggeration");
  50900. const n2 = () => {
  50901. this.sourceCache.used && e.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.
  50902. This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);
  50903. const t3 = this.getScaledDemTileSize();
  50904. this.sourceCache.update(i3, t3, true), this.resetTileLookupCache(this.sourceCache.id);
  50905. };
  50906. this.sourceCache.usedForTerrain || (this.resetTileLookupCache(this.sourceCache.id), this.sourceCache.usedForTerrain = true, n2(), this._initializing = true), n2(), i3.updateElevation(!o2), this.resetTileLookupCache(this.proxySourceCache.id), this.proxySourceCache.update(i3), this._emptyDEMTextureDirty = true;
  50907. } else
  50908. this._disable();
  50909. }
  50910. resetTileLookupCache(e2) {
  50911. this._findCoveringTileCache[e2] = {};
  50912. }
  50913. getScaledDemTileSize() {
  50914. return this.sourceCache.getSource().tileSize / 128 * this.proxySourceCache.getSource().tileSize;
  50915. }
  50916. _checkRenderCacheEfficiency() {
  50917. const t2 = this.renderCacheEfficiency(this._style);
  50918. this._style.map._optimizeForTerrain || 100 !== t2.efficiency && e.warnOnce(`Terrain render cache efficiency is not optimal (${t2.efficiency}%) and performance
  50919. may be affected negatively, consider placing all background, fill and line layers before layer
  50920. with id '${t2.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`);
  50921. }
  50922. _onStyleDataEvent(e2) {
  50923. e2.coord && "source" === e2.dataType ? this._clearRenderCacheForTile(e2.sourceCacheId, e2.coord) : "style" === e2.dataType && (this._invalidateRenderCache = true);
  50924. }
  50925. _disable() {
  50926. if (this.enabled && (this.enabled = false, this._sharedDepthStencil = void 0, this.proxySourceCache.deallocRenderCache(), this._style))
  50927. for (const e2 in this._style._sourceCaches)
  50928. this._style._sourceCaches[e2].usedForTerrain = false;
  50929. }
  50930. destroy() {
  50931. this._disable(), this._emptyDEMTexture && this._emptyDEMTexture.destroy(), this._emptyDepthBufferTexture && this._emptyDepthBufferTexture.destroy(), this.pool.forEach((e2) => e2.fb.destroy()), this.pool = [], this._depthFBO && (this._depthFBO.destroy(), this._depthFBO = void 0, this._depthTexture = void 0);
  50932. }
  50933. _source() {
  50934. return this.enabled ? this.sourceCache : null;
  50935. }
  50936. exaggeration() {
  50937. return this._exaggeration;
  50938. }
  50939. get visibleDemTiles() {
  50940. return this._visibleDemTiles;
  50941. }
  50942. get drapeBufferSize() {
  50943. const e2 = 2 * this.proxySourceCache.getSource().tileSize;
  50944. return [e2, e2];
  50945. }
  50946. set useVertexMorphing(e2) {
  50947. this._useVertexMorphing = e2;
  50948. }
  50949. updateTileBinding(t2) {
  50950. if (!this.enabled)
  50951. return;
  50952. this.prevTerrainTileForTile = this.terrainTileForTile;
  50953. const i3 = this.proxySourceCache, o2 = this.painter.transform;
  50954. this._initializing && (this._initializing = 0 === o2._centerAltitude && -1 === this.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(o2.center), -1), this._emptyDEMTextureDirty = !this._initializing);
  50955. const r2 = this.proxyCoords = i3.getIds().map((e2) => {
  50956. const t3 = i3.getTileByID(e2).tileID;
  50957. return t3.projMatrix = o2.calculateProjMatrix(t3.toUnwrapped()), t3;
  50958. });
  50959. !function(t3, i4) {
  50960. const o3 = i4.transform.pointCoordinate(i4.transform.getCameraPoint()), r3 = new e.pointGeometry(o3.x, o3.y);
  50961. t3.sort((t4, i5) => {
  50962. if (i5.overscaledZ - t4.overscaledZ)
  50963. return i5.overscaledZ - t4.overscaledZ;
  50964. const o4 = new e.pointGeometry(t4.canonical.x + (1 << t4.canonical.z) * t4.wrap, t4.canonical.y), n3 = new e.pointGeometry(i5.canonical.x + (1 << i5.canonical.z) * i5.wrap, i5.canonical.y), a3 = r3.mult(1 << t4.canonical.z);
  50965. return a3.x -= 0.5, a3.y -= 0.5, a3.distSqr(o4) - a3.distSqr(n3);
  50966. });
  50967. }(r2, this.painter), this._previousZoom = o2.zoom;
  50968. const n2 = this.proxyToSource || {};
  50969. this.proxyToSource = {}, r2.forEach((e2) => {
  50970. this.proxyToSource[e2.key] = {};
  50971. }), this.terrainTileForTile = {};
  50972. const a2 = this._style._sourceCaches;
  50973. for (const e2 in a2) {
  50974. const i4 = a2[e2];
  50975. if (!i4.used)
  50976. continue;
  50977. if (i4 !== this.sourceCache && this.resetTileLookupCache(i4.id), this._setupProxiedCoordsForOrtho(i4, t2[e2], n2), i4.usedForTerrain)
  50978. continue;
  50979. const o3 = t2[e2];
  50980. i4.getSource().reparseOverscaled && this._assignTerrainTiles(o3);
  50981. }
  50982. this.proxiedCoords[i3.id] = r2.map((e2) => new yi(e2, e2.key, this.orthoMatrix)), this._assignTerrainTiles(r2), this._prepareDEMTextures(), this._setupDrapedRenderBatches(), this._initFBOPool(), this._setupRenderCache(n2), this.renderingToTexture = false, this._updateTimestamp = e.exported.now();
  50983. const s2 = {};
  50984. this._visibleDemTiles = [];
  50985. for (const e2 of this.proxyCoords) {
  50986. const t3 = this.terrainTileForTile[e2.key];
  50987. if (!t3)
  50988. continue;
  50989. const i4 = t3.tileID.key;
  50990. i4 in s2 || (this._visibleDemTiles.push(t3), s2[i4] = i4);
  50991. }
  50992. }
  50993. _assignTerrainTiles(e2) {
  50994. this._initializing || e2.forEach((e3) => {
  50995. if (this.terrainTileForTile[e3.key])
  50996. return;
  50997. const t2 = this._findTileCoveringTileID(e3, this.sourceCache);
  50998. t2 && (this.terrainTileForTile[e3.key] = t2);
  50999. });
  51000. }
  51001. _prepareDEMTextures() {
  51002. const e2 = this.painter.context, t2 = e2.gl;
  51003. for (const i3 in this.terrainTileForTile) {
  51004. const o2 = this.terrainTileForTile[i3], r2 = o2.dem;
  51005. !r2 || o2.demTexture && !o2.needsDEMTextureUpload || (e2.activeTexture.set(t2.TEXTURE1), ai(this.painter, o2, r2));
  51006. }
  51007. }
  51008. _prepareDemTileUniforms(e2, t2, i3, o2) {
  51009. if (!t2 || null == t2.demTexture)
  51010. return false;
  51011. const r2 = e2.tileID.canonical, n2 = Math.pow(2, t2.tileID.canonical.z - r2.z), a2 = o2 || "";
  51012. return i3[`u_dem_tl${a2}`] = [r2.x * n2 % 1, r2.y * n2 % 1], i3[`u_dem_scale${a2}`] = n2, true;
  51013. }
  51014. get emptyDEMTexture() {
  51015. return !this._emptyDEMTextureDirty && this._emptyDEMTexture ? this._emptyDEMTexture : this._updateEmptyDEMTexture();
  51016. }
  51017. get emptyDepthBufferTexture() {
  51018. const t2 = this.painter.context, i3 = t2.gl;
  51019. if (!this._emptyDepthBufferTexture) {
  51020. const o2 = new e.RGBAImage({ width: 1, height: 1 }, Uint8Array.of(255, 255, 255, 255));
  51021. this._emptyDepthBufferTexture = new e.Texture(t2, o2, i3.RGBA, { premultiply: false });
  51022. }
  51023. return this._emptyDepthBufferTexture;
  51024. }
  51025. _getLoadedAreaMinimum() {
  51026. let e2 = 0;
  51027. const t2 = this._visibleDemTiles.reduce((t3, i3) => {
  51028. if (!i3.dem)
  51029. return t3;
  51030. const o2 = i3.dem.tree.minimums[0];
  51031. return o2 > 0 && e2++, t3 + o2;
  51032. }, 0);
  51033. return e2 ? t2 / e2 : 0;
  51034. }
  51035. _updateEmptyDEMTexture() {
  51036. const t2 = this.painter.context, i3 = t2.gl;
  51037. t2.activeTexture.set(i3.TEXTURE2);
  51038. const o2 = this._getLoadedAreaMinimum(), r2 = new e.RGBAImage({ width: 1, height: 1 }, new Uint8Array(e.DEMData.pack(o2, this.sourceCache.getSource().encoding)));
  51039. this._emptyDEMTextureDirty = false;
  51040. let n2 = this._emptyDEMTexture;
  51041. return n2 ? n2.update(r2, { premultiply: false }) : n2 = this._emptyDEMTexture = new e.Texture(t2, r2, i3.RGBA, { premultiply: false }), n2;
  51042. }
  51043. setupElevationDraw(t2, i3, o2) {
  51044. const r2 = this.painter.context, n2 = r2.gl, a2 = (s2 = this.sourceCache.getSource().encoding, { u_dem: 2, u_dem_prev: 4, u_dem_unpack: e.DEMData.getUnpackVector(s2), u_dem_tl: [0, 0], u_dem_tl_prev: [0, 0], u_dem_scale: 0, u_dem_scale_prev: 0, u_dem_size: 0, u_dem_lerp: 1, u_depth: 3, u_depth_size_inv: [0, 0], u_exaggeration: 0, u_tile_tl_up: [0, 0, 1], u_tile_tr_up: [0, 0, 1], u_tile_br_up: [0, 0, 1], u_tile_bl_up: [0, 0, 1], u_tile_up_scale: 1 });
  51045. var s2;
  51046. a2.u_dem_size = this.sourceCache.getSource().tileSize, a2.u_exaggeration = this.exaggeration();
  51047. const l2 = this.painter.transform, c2 = l2.projection, h2 = t2.tileID.canonical;
  51048. a2.u_tile_tl_up = c2.upVector(h2, 0, 0), a2.u_tile_tr_up = c2.upVector(h2, e.EXTENT, 0), a2.u_tile_br_up = c2.upVector(h2, e.EXTENT, e.EXTENT), a2.u_tile_bl_up = c2.upVector(h2, 0, e.EXTENT), a2.u_tile_up_scale = o2 && o2.useDenormalizedUpVectorScale ? gi : c2.upVectorScale(h2, l2.center.lat, l2.worldSize).metersToTile;
  51049. let _2 = null, u2 = null, d2 = 1;
  51050. if (o2 && o2.morphing && this._useVertexMorphing) {
  51051. const e2 = o2.morphing.srcDemTile, i4 = o2.morphing.dstDemTile;
  51052. d2 = o2.morphing.phase, e2 && i4 && (this._prepareDemTileUniforms(t2, e2, a2, "_prev") && (u2 = e2), this._prepareDemTileUniforms(t2, i4, a2) && (_2 = i4));
  51053. }
  51054. if (u2 && _2 ? (r2.activeTexture.set(n2.TEXTURE2), _2.demTexture.bind(n2.NEAREST, n2.CLAMP_TO_EDGE, n2.NEAREST), r2.activeTexture.set(n2.TEXTURE4), u2.demTexture.bind(n2.NEAREST, n2.CLAMP_TO_EDGE, n2.NEAREST), a2.u_dem_lerp = d2) : (_2 = this.terrainTileForTile[t2.tileID.key], r2.activeTexture.set(n2.TEXTURE2), (this._prepareDemTileUniforms(t2, _2, a2) ? _2.demTexture : this.emptyDEMTexture).bind(n2.NEAREST, n2.CLAMP_TO_EDGE)), r2.activeTexture.set(n2.TEXTURE3), o2 && o2.useDepthForOcclusion ? (this._depthTexture && this._depthTexture.bind(n2.NEAREST, n2.CLAMP_TO_EDGE), this._depthFBO && (a2.u_depth_size_inv = [1 / this._depthFBO.width, 1 / this._depthFBO.height])) : (this.emptyDepthBufferTexture.bind(n2.NEAREST, n2.CLAMP_TO_EDGE), a2.u_depth_size_inv = [1, 1]), o2 && o2.useMeterToDem && _2) {
  51055. const t3 = (1 << _2.tileID.canonical.z) * e.mercatorZfromAltitude(1, this.painter.transform.center.lat) * this.sourceCache.getSource().tileSize;
  51056. a2.u_meter_to_dem = t3;
  51057. }
  51058. o2 && o2.labelPlaneMatrixInv && (a2.u_label_plane_matrix_inv = o2.labelPlaneMatrixInv), i3.setTerrainUniformValues(r2, a2);
  51059. }
  51060. renderToBackBuffer(t2) {
  51061. const i3 = this.painter, o2 = this.painter.context;
  51062. 0 !== t2.length && (o2.bindFramebuffer.set(null), o2.viewport.set([0, 0, i3.width, i3.height]), this.renderingToTexture = false, function(t3, i4, o3, r2, n2) {
  51063. if ("globe" === t3.transform.projection.name)
  51064. !function(t4, i5, o4, r3, n3) {
  51065. const a2 = t4.context, s2 = a2.gl;
  51066. let l2, c2;
  51067. const h2 = t4.options.showTerrainWireframe ? 2 : 0, _2 = (e2, i6) => {
  51068. if (c2 === e2)
  51069. return;
  51070. const o5 = [di[e2], "PROJECTION_GLOBE_VIEW"];
  51071. i6 && o5.push(di[h2]), l2 = t4.useProgram("globeRaster", null, o5), c2 = e2;
  51072. }, u2 = t4.colorModeForRenderPass(), d2 = new e.DepthMode(s2.LEQUAL, e.DepthMode.ReadWrite, t4.depthRangeFor3D);
  51073. ui.update(n3);
  51074. const p2 = t4.transform, m2 = e.calculateGlobeMercatorMatrix(p2), f2 = [e.mercatorXfromLng(p2.center.lng), e.mercatorYfromLat(p2.center.lat)], g2 = t4.globeSharedBuffers;
  51075. if ((h2 ? [false, true] : [false]).forEach((h3) => {
  51076. c2 = -1;
  51077. const v2 = h3 ? s2.LINES : s2.TRIANGLES;
  51078. for (const c3 of r3) {
  51079. const r4 = o4.getTile(c3), x2 = e.StencilMode.disabled, y2 = i5.prevTerrainTileForTile[c3.key], b2 = i5.terrainTileForTile[c3.key];
  51080. _i(y2, b2) && ui.newMorphing(c3.key, y2, b2, n3, 250), a2.activeTexture.set(s2.TEXTURE0), r4.texture.bind(s2.LINEAR, s2.CLAMP_TO_EDGE);
  51081. const w2 = ui.getMorphValuesForProxy(c3.key), T2 = w2 ? 1 : 0, E2 = { useDenormalizedUpVectorScale: true };
  51082. w2 && e.extend$1(E2, { morphing: { srcDemTile: w2.from, dstDemTile: w2.to, phase: e.easeCubicInOut(w2.phase) } });
  51083. const C2 = Float32Array.from(p2.globeMatrix), I2 = e.globeTileLatLngCorners(c3.canonical), M2 = e.getGridMatrix(c3.canonical, I2), S2 = hi(p2.projMatrix, C2, m2, e.globeToMercatorTransition(p2.zoom), f2, M2);
  51084. if (_2(T2, h3), i5.setupElevationDraw(r4, l2, E2), t4.prepareDrawProgram(a2, l2, c3.toUnwrapped()), g2) {
  51085. const [i6, o5, r5] = h3 ? g2.getWirefameBuffers(t4.context) : g2.getGridBuffers();
  51086. l2.draw(a2, v2, d2, x2, u2, e.CullFaceMode.backCCW, S2, "globe_raster", i6, o5, r5);
  51087. }
  51088. }
  51089. }), g2) {
  51090. l2 = t4.useProgram("globeRaster", null, ["GLOBE_POLES", "PROJECTION_GLOBE_VIEW"]);
  51091. for (const n4 of r3) {
  51092. const { x: r4, y: c3, z: h3 } = n4.canonical, _3 = 0 === c3, m3 = c3 === (1 << h3) - 1, [v2, x2, y2, b2] = g2.getPoleBuffers(h3);
  51093. if (b2 && (_3 || m3)) {
  51094. const c4 = o4.getTile(n4);
  51095. a2.activeTexture.set(s2.TEXTURE0), c4.texture.bind(s2.LINEAR, s2.CLAMP_TO_EDGE);
  51096. let g3 = e.globePoleMatrixForTile(h3, r4, p2);
  51097. const w2 = (t5, i6) => t5.draw(a2, s2.TRIANGLES, d2, e.StencilMode.disabled, u2, e.CullFaceMode.disabled, hi(p2.projMatrix, g3, g3, 0, f2), "globe_pole_raster", i6, y2, b2);
  51098. i5.setupElevationDraw(c4, l2, {}), t4.prepareDrawProgram(a2, l2, n4.toUnwrapped()), _3 && w2(l2, v2), m3 && (g3 = e.scale(e.create(), g3, [1, -1, 1]), w2(l2, x2));
  51099. }
  51100. }
  51101. }
  51102. }(t3, i4, o3, r2, n2);
  51103. else {
  51104. const a2 = t3.context, s2 = a2.gl;
  51105. let l2, c2;
  51106. const h2 = t3.options.showTerrainWireframe ? 2 : 0, _2 = (e2, i5) => {
  51107. if (c2 === e2)
  51108. return;
  51109. const o4 = [di[e2]];
  51110. i5 && o4.push(di[h2]), l2 = t3.useProgram("terrainRaster", null, o4), c2 = e2;
  51111. }, u2 = t3.colorModeForRenderPass(), d2 = new e.DepthMode(s2.LEQUAL, e.DepthMode.ReadWrite, t3.depthRangeFor3D);
  51112. ui.update(n2);
  51113. const p2 = t3.transform, m2 = 6 * Math.pow(1.5, 22 - p2.zoom) * i4.exaggeration();
  51114. (h2 ? [false, true] : [false]).forEach((h3) => {
  51115. c2 = -1;
  51116. const f2 = h3 ? s2.LINES : s2.TRIANGLES, [g2, v2] = h3 ? i4.getWirefameBuffer() : [i4.gridIndexBuffer, i4.gridSegments];
  51117. for (const c3 of r2) {
  51118. const r3 = o3.getTile(c3), x2 = e.StencilMode.disabled, y2 = i4.prevTerrainTileForTile[c3.key], b2 = i4.terrainTileForTile[c3.key];
  51119. _i(y2, b2) && ui.newMorphing(c3.key, y2, b2, n2, 250), a2.activeTexture.set(s2.TEXTURE0), r3.texture.bind(s2.LINEAR, s2.CLAMP_TO_EDGE, s2.LINEAR_MIPMAP_NEAREST);
  51120. const w2 = ui.getMorphValuesForProxy(c3.key), T2 = w2 ? 1 : 0;
  51121. let E2;
  51122. w2 && (E2 = { morphing: { srcDemTile: w2.from, dstDemTile: w2.to, phase: e.easeCubicInOut(w2.phase) } });
  51123. const C2 = ci(c3.projMatrix, pi(c3.canonical, p2.renderWorldCopies) ? m2 / 10 : m2);
  51124. _2(T2, h3), i4.setupElevationDraw(r3, l2, E2), t3.prepareDrawProgram(a2, l2, c3.toUnwrapped()), l2.draw(a2, f2, d2, x2, u2, e.CullFaceMode.backCCW, C2, "terrain_raster", i4.gridBuffer, g2, v2);
  51125. }
  51126. });
  51127. }
  51128. }(i3, this, this.proxySourceCache, t2, this._updateTimestamp), this.renderingToTexture = true, t2.splice(0, t2.length));
  51129. }
  51130. renderBatch(t2) {
  51131. if (0 === this._drapedRenderBatches.length)
  51132. return t2 + 1;
  51133. this.renderingToTexture = true;
  51134. const i3 = this.painter, o2 = this.painter.context, r2 = this.proxySourceCache, n2 = this.proxiedCoords[r2.id], a2 = this._drapedRenderBatches.shift(), s2 = [], l2 = i3.style.order;
  51135. let c2 = 0;
  51136. for (const h2 of n2) {
  51137. const n3 = r2.getTileByID(h2.proxyTileKey), _2 = r2.proxyCachedFBO[h2.key] ? r2.proxyCachedFBO[h2.key][t2] : void 0, u2 = void 0 !== _2 ? r2.renderCache[_2] : this.pool[c2++], d2 = void 0 !== _2;
  51138. if (n3.texture = u2.tex, d2 && !u2.dirty) {
  51139. s2.push(n3.tileID);
  51140. continue;
  51141. }
  51142. let p2;
  51143. o2.bindFramebuffer.set(u2.fb.framebuffer), this.renderedToTile = false, u2.dirty && (o2.clear({ color: e.Color.transparent, stencil: 0 }), u2.dirty = false);
  51144. for (let e2 = a2.start; e2 <= a2.end; ++e2) {
  51145. const t3 = i3.style._layers[l2[e2]];
  51146. if (t3.isHidden(i3.transform.zoom))
  51147. continue;
  51148. const r3 = i3.style._getLayerSourceCache(t3), n4 = r3 ? this.proxyToSource[h2.key][r3.id] : [h2];
  51149. if (!n4)
  51150. continue;
  51151. const a3 = n4;
  51152. o2.viewport.set([0, 0, u2.fb.width, u2.fb.height]), p2 !== (r3 ? r3.id : null) && (this._setupStencil(u2, n4, t3, r3), p2 = r3 ? r3.id : null), i3.renderLayer(i3, r3, t3, a3);
  51153. }
  51154. this.renderedToTile ? (u2.dirty = true, s2.push(n3.tileID)) : d2 || --c2, 5 === c2 && (c2 = 0, this.renderToBackBuffer(s2));
  51155. }
  51156. return this.renderToBackBuffer(s2), this.renderingToTexture = false, o2.bindFramebuffer.set(null), o2.viewport.set([0, 0, i3.width, i3.height]), a2.end + 1;
  51157. }
  51158. postRender() {
  51159. }
  51160. renderCacheEfficiency(e2) {
  51161. const t2 = e2.order.length;
  51162. if (0 === t2)
  51163. return { efficiency: 100 };
  51164. let i3, o2 = 0, r2 = 0, n2 = false;
  51165. for (let a2 = 0; a2 < t2; ++a2) {
  51166. const t3 = e2._layers[e2.order[a2]];
  51167. this._style.isLayerDraped(t3) ? (n2 && ++o2, ++r2) : n2 || (n2 = true, i3 = t3.id);
  51168. }
  51169. return 0 === r2 ? { efficiency: 100 } : { efficiency: 100 * (1 - o2 / r2), firstUndrapedLayer: i3 };
  51170. }
  51171. getMinElevationBelowMSL() {
  51172. let e2 = 0;
  51173. return this._visibleDemTiles.filter((e3) => e3.dem).forEach((t2) => {
  51174. e2 = Math.min(e2, t2.dem.tree.minimums[0]);
  51175. }), 0 === e2 ? e2 : (e2 - 30) * this._exaggeration;
  51176. }
  51177. raycast(e2, t2, i3) {
  51178. if (!this._visibleDemTiles)
  51179. return null;
  51180. const o2 = this._visibleDemTiles.filter((e3) => e3.dem).map((o3) => {
  51181. const r2 = o3.tileID, n2 = Math.pow(2, r2.overscaledZ), { x: a2, y: s2 } = r2.canonical, l2 = a2 / n2, c2 = (a2 + 1) / n2, h2 = s2 / n2, _2 = (s2 + 1) / n2;
  51182. return { minx: l2, miny: h2, maxx: c2, maxy: _2, t: o3.dem.tree.raycastRoot(l2, h2, c2, _2, e2, t2, i3), tile: o3 };
  51183. });
  51184. o2.sort((e3, t3) => (null !== e3.t ? e3.t : Number.MAX_VALUE) - (null !== t3.t ? t3.t : Number.MAX_VALUE));
  51185. for (const r2 of o2) {
  51186. if (null == r2.t)
  51187. return null;
  51188. const o3 = r2.tile.dem.tree.raycast(r2.minx, r2.miny, r2.maxx, r2.maxy, e2, t2, i3);
  51189. if (null != o3)
  51190. return o3;
  51191. }
  51192. return null;
  51193. }
  51194. _createFBO() {
  51195. const t2 = this.painter.context, i3 = t2.gl, o2 = this.drapeBufferSize;
  51196. t2.activeTexture.set(i3.TEXTURE0);
  51197. const r2 = new e.Texture(t2, { width: o2[0], height: o2[1], data: null }, i3.RGBA);
  51198. r2.bind(i3.LINEAR, i3.CLAMP_TO_EDGE);
  51199. const n2 = t2.createFramebuffer(o2[0], o2[1], false);
  51200. return n2.colorAttachment.set(r2.texture), n2.depthAttachment = new we(t2, n2.framebuffer), void 0 === this._sharedDepthStencil ? (this._sharedDepthStencil = t2.createRenderbuffer(t2.gl.DEPTH_STENCIL, o2[0], o2[1]), this._stencilRef = 0, n2.depthAttachment.set(this._sharedDepthStencil), t2.clear({ stencil: 0 })) : n2.depthAttachment.set(this._sharedDepthStencil), t2.extTextureFilterAnisotropic && !t2.extTextureFilterAnisotropicForceOff && i3.texParameterf(i3.TEXTURE_2D, t2.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT, t2.extTextureFilterAnisotropicMax), { fb: n2, tex: r2, dirty: false };
  51201. }
  51202. _initFBOPool() {
  51203. for (; this.pool.length < Math.min(5, this.proxyCoords.length); )
  51204. this.pool.push(this._createFBO());
  51205. }
  51206. _shouldDisableRenderCache() {
  51207. if (this._style.light && this._style.light.hasTransition())
  51208. return true;
  51209. for (const e2 in this._style._sourceCaches)
  51210. if (this._style._sourceCaches[e2].hasTransition())
  51211. return true;
  51212. return this._style.order.some((e2) => {
  51213. const t2 = this._style._layers[e2], i3 = t2.isHidden(this.painter.transform.zoom), o2 = t2.getCrossfadeParameters(), r2 = !!o2 && 1 !== o2.t, n2 = t2.hasTransition();
  51214. return "custom" !== t2.type && !i3 && (r2 || n2);
  51215. });
  51216. }
  51217. _clearRasterFadeFromRenderCache() {
  51218. let e2 = false;
  51219. for (const t2 in this._style._sourceCaches)
  51220. if (this._style._sourceCaches[t2]._source instanceof Ce) {
  51221. e2 = true;
  51222. break;
  51223. }
  51224. if (e2)
  51225. for (let e3 = 0; e3 < this._style.order.length; ++e3) {
  51226. const t2 = this._style._layers[this._style.order[e3]], i3 = t2.isHidden(this.painter.transform.zoom), o2 = this._style._getLayerSourceCache(t2);
  51227. if ("raster" !== t2.type || i3 || !o2)
  51228. continue;
  51229. const r2 = t2.paint.get("raster-fade-duration");
  51230. for (const e4 of this.proxyCoords) {
  51231. const t3 = this.proxyToSource[e4.key][o2.id];
  51232. if (t3)
  51233. for (const e5 of t3) {
  51234. const t4 = fi(o2.getTile(e5), o2.findLoadedParent(e5, 0), o2, this.painter.transform, r2);
  51235. (1 !== t4.opacity || 0 !== t4.mix) && this._clearRenderCacheForTile(o2.id, e5);
  51236. }
  51237. }
  51238. }
  51239. }
  51240. _setupDrapedRenderBatches() {
  51241. const e2 = this._style.order, t2 = e2.length;
  51242. if (0 === t2)
  51243. return;
  51244. const i3 = [];
  51245. let o2, r2 = 0, n2 = this._style._layers[e2[r2]];
  51246. for (; !this._style.isLayerDraped(n2) && n2.isHidden(this.painter.transform.zoom) && ++r2 < t2; )
  51247. n2 = this._style._layers[e2[r2]];
  51248. for (; r2 < t2; ++r2) {
  51249. const t3 = this._style._layers[e2[r2]];
  51250. t3.isHidden(this.painter.transform.zoom) || (this._style.isLayerDraped(t3) ? void 0 === o2 && (o2 = r2) : void 0 !== o2 && (i3.push({ start: o2, end: r2 - 1 }), o2 = void 0));
  51251. }
  51252. void 0 !== o2 && i3.push({ start: o2, end: r2 - 1 }), this._drapedRenderBatches = i3;
  51253. }
  51254. _setupRenderCache(e2) {
  51255. const t2 = this.proxySourceCache;
  51256. if (this._shouldDisableRenderCache() || this._invalidateRenderCache) {
  51257. if (this._invalidateRenderCache = false, t2.renderCache.length > t2.renderCachePool.length) {
  51258. const e3 = Object.values(t2.proxyCachedFBO);
  51259. t2.proxyCachedFBO = {};
  51260. for (let i4 = 0; i4 < e3.length; ++i4) {
  51261. const o3 = Object.values(e3[i4]);
  51262. t2.renderCachePool.push(...o3);
  51263. }
  51264. }
  51265. return;
  51266. }
  51267. this._clearRasterFadeFromRenderCache();
  51268. const i3 = this.proxyCoords, o2 = this._tilesDirty;
  51269. for (let r3 = i3.length - 1; r3 >= 0; r3--) {
  51270. const n2 = i3[r3];
  51271. if (t2.getTileByID(n2.key), void 0 !== t2.proxyCachedFBO[n2.key]) {
  51272. const i4 = e2[n2.key], r4 = this.proxyToSource[n2.key];
  51273. let a2 = 0;
  51274. for (const e3 in r4) {
  51275. const t3 = r4[e3], n3 = i4[e3];
  51276. if (!n3 || n3.length !== t3.length || t3.some((t4, i5) => t4 !== n3[i5] || o2[e3] && o2[e3].hasOwnProperty(t4.key))) {
  51277. a2 = -1;
  51278. break;
  51279. }
  51280. ++a2;
  51281. }
  51282. for (const e3 in t2.proxyCachedFBO[n2.key])
  51283. t2.renderCache[t2.proxyCachedFBO[n2.key][e3]].dirty = a2 < 0 || a2 !== Object.values(i4).length;
  51284. }
  51285. }
  51286. const r2 = [...this._drapedRenderBatches];
  51287. r2.sort((e3, t3) => t3.end - t3.start - (e3.end - e3.start));
  51288. for (const e3 of r2)
  51289. for (const o3 of i3) {
  51290. if (t2.proxyCachedFBO[o3.key])
  51291. continue;
  51292. let i4 = t2.renderCachePool.pop();
  51293. void 0 === i4 && t2.renderCache.length < 50 && (i4 = t2.renderCache.length, t2.renderCache.push(this._createFBO())), void 0 !== i4 && (t2.proxyCachedFBO[o3.key] = {}, t2.proxyCachedFBO[o3.key][e3.start] = i4, t2.renderCache[i4].dirty = true);
  51294. }
  51295. this._tilesDirty = {};
  51296. }
  51297. _setupStencil(e2, t2, i3, o2) {
  51298. if (!o2 || !this._sourceTilesOverlap[o2.id])
  51299. return void (this._overlapStencilType && (this._overlapStencilType = false));
  51300. const r2 = this.painter.context, n2 = r2.gl;
  51301. if (t2.length <= 1)
  51302. return void (this._overlapStencilType = false);
  51303. let a2;
  51304. if (i3.isTileClipped())
  51305. a2 = t2.length, this._overlapStencilMode.test = { func: n2.EQUAL, mask: 255 }, this._overlapStencilType = "Clip";
  51306. else {
  51307. if (!(t2[0].overscaledZ > t2[t2.length - 1].overscaledZ))
  51308. return void (this._overlapStencilType = false);
  51309. a2 = 1, this._overlapStencilMode.test = { func: n2.GREATER, mask: 255 }, this._overlapStencilType = "Mask";
  51310. }
  51311. this._stencilRef + a2 > 255 && (r2.clear({ stencil: 0 }), this._stencilRef = 0), this._stencilRef += a2, this._overlapStencilMode.ref = this._stencilRef, i3.isTileClipped() && this._renderTileClippingMasks(t2, this._overlapStencilMode.ref);
  51312. }
  51313. clipOrMaskOverlapStencilType() {
  51314. return "Clip" === this._overlapStencilType || "Mask" === this._overlapStencilType;
  51315. }
  51316. stencilModeForRTTOverlap(t2) {
  51317. return this.renderingToTexture && this._overlapStencilType ? ("Clip" === this._overlapStencilType && (this._overlapStencilMode.ref = this.painter._tileClippingMaskIDs.get(t2.key) || 0), this._overlapStencilMode) : e.StencilMode.disabled;
  51318. }
  51319. _renderTileClippingMasks(t2, i3) {
  51320. const o2 = this.painter, r2 = this.painter.context, n2 = r2.gl;
  51321. o2._tileClippingMaskIDs.clear(), r2.setColorMode(e.ColorMode.disabled), r2.setDepthMode(e.DepthMode.disabled);
  51322. const a2 = o2.useProgram("clippingMask");
  51323. for (const s2 of t2) {
  51324. const t3 = --i3;
  51325. o2._tileClippingMaskIDs.set(s2.key, t3), a2.draw(r2, n2.TRIANGLES, e.DepthMode.disabled, new e.StencilMode({ func: n2.ALWAYS, mask: 0 }, t3, 255, n2.KEEP, n2.KEEP, n2.REPLACE), e.ColorMode.disabled, e.CullFaceMode.disabled, mi(s2.projMatrix), "$clipping", o2.tileExtentBuffer, o2.quadTriangleIndexBuffer, o2.tileExtentSegments);
  51326. }
  51327. }
  51328. pointCoordinate(t2) {
  51329. const i3 = this.painter.transform;
  51330. if (t2.x < 0 || t2.x > i3.width || t2.y < 0 || t2.y > i3.height)
  51331. return null;
  51332. const o2 = [t2.x, t2.y, 1, 1];
  51333. e.transformMat4$1(o2, o2, i3.pixelMatrixInverse), e.scale$1(o2, o2, 1 / o2[3]), o2[0] /= i3.worldSize, o2[1] /= i3.worldSize;
  51334. const r2 = i3._camera.position, n2 = e.mercatorZfromAltitude(1, i3.center.lat), a2 = [r2[0], r2[1], r2[2] / n2, 0], s2 = e.subtract([], o2.slice(0, 3), a2);
  51335. e.normalize(s2, s2);
  51336. const l2 = this.raycast(a2, s2, this._exaggeration);
  51337. return null !== l2 && l2 ? (e.scaleAndAdd(a2, a2, s2, l2), a2[3] = a2[2], a2[2] *= n2, a2) : null;
  51338. }
  51339. drawDepth() {
  51340. const t2 = this.painter, i3 = t2.context, o2 = this.proxySourceCache, r2 = Math.ceil(t2.width), n2 = Math.ceil(t2.height);
  51341. if (!this._depthFBO || this._depthFBO.width === r2 && this._depthFBO.height === n2 || (this._depthFBO.destroy(), this._depthFBO = void 0, this._depthTexture = void 0), !this._depthFBO) {
  51342. const t3 = i3.gl, o3 = i3.createFramebuffer(r2, n2, true);
  51343. i3.activeTexture.set(t3.TEXTURE0);
  51344. const a2 = new e.Texture(i3, { width: r2, height: n2, data: null }, t3.RGBA);
  51345. a2.bind(t3.NEAREST, t3.CLAMP_TO_EDGE), o3.colorAttachment.set(a2.texture);
  51346. const s2 = i3.createRenderbuffer(i3.gl.DEPTH_COMPONENT16, r2, n2);
  51347. o3.depthAttachment.set(s2), this._depthFBO = o3, this._depthTexture = a2;
  51348. }
  51349. i3.bindFramebuffer.set(this._depthFBO.framebuffer), i3.viewport.set([0, 0, r2, n2]), function(t3, i4, o3, r3) {
  51350. if ("globe" === t3.transform.projection.name)
  51351. return;
  51352. const n3 = t3.context, a2 = n3.gl;
  51353. n3.clear({ depth: 1 });
  51354. const s2 = t3.useProgram("terrainDepth"), l2 = new e.DepthMode(a2.LESS, e.DepthMode.ReadWrite, t3.depthRangeFor3D);
  51355. for (const t4 of r3) {
  51356. const r4 = o3.getTile(t4), c2 = ci(t4.projMatrix, 0);
  51357. i4.setupElevationDraw(r4, s2), s2.draw(n3, a2.TRIANGLES, l2, e.StencilMode.disabled, e.ColorMode.unblended, e.CullFaceMode.backCCW, c2, "terrain_depth", i4.gridBuffer, i4.gridIndexBuffer, i4.gridNoSkirtSegments);
  51358. }
  51359. }(t2, this, o2, this.proxyCoords);
  51360. }
  51361. _setupProxiedCoordsForOrtho(e2, t2, i3) {
  51362. if (e2.getSource() instanceof Se)
  51363. return this._setupProxiedCoordsForImageSource(e2, t2, i3);
  51364. this._findCoveringTileCache[e2.id] = this._findCoveringTileCache[e2.id] || {};
  51365. const o2 = this.proxiedCoords[e2.id] = [], r2 = this.proxyCoords;
  51366. for (let t3 = 0; t3 < r2.length; t3++) {
  51367. const n3 = r2[t3], a2 = this._findTileCoveringTileID(n3, e2);
  51368. if (a2) {
  51369. const t4 = this._createProxiedId(n3, a2, i3[n3.key] && i3[n3.key][e2.id]);
  51370. o2.push(t4), this.proxyToSource[n3.key][e2.id] = [t4];
  51371. }
  51372. }
  51373. let n2 = false;
  51374. for (let r3 = 0; r3 < t2.length; r3++) {
  51375. const a2 = e2.getTile(t2[r3]);
  51376. if (!a2 || !a2.hasData())
  51377. continue;
  51378. const s2 = this._findTileCoveringTileID(a2.tileID, this.proxySourceCache);
  51379. if (s2 && s2.tileID.canonical.z !== a2.tileID.canonical.z) {
  51380. const t3 = this.proxyToSource[s2.tileID.key][e2.id], r4 = this._createProxiedId(s2.tileID, a2, i3[s2.tileID.key] && i3[s2.tileID.key][e2.id]);
  51381. t3 ? t3.splice(t3.length - 1, 0, r4) : this.proxyToSource[s2.tileID.key][e2.id] = [r4], o2.push(r4), n2 = true;
  51382. }
  51383. }
  51384. this._sourceTilesOverlap[e2.id] = n2;
  51385. }
  51386. _setupProxiedCoordsForImageSource(t2, i3, o2) {
  51387. if (!t2.getSource().loaded())
  51388. return;
  51389. const r2 = this.proxiedCoords[t2.id] = [], n2 = this.proxyCoords, a2 = t2.getSource(), s2 = new e.pointGeometry(a2.tileID.x, a2.tileID.y)._div(1 << a2.tileID.z), l2 = a2.coordinates.map(e.MercatorCoordinate.fromLngLat).reduce((e2, t3) => (e2.min.x = Math.min(e2.min.x, t3.x - s2.x), e2.min.y = Math.min(e2.min.y, t3.y - s2.y), e2.max.x = Math.max(e2.max.x, t3.x - s2.x), e2.max.y = Math.max(e2.max.y, t3.y - s2.y), e2), { min: new e.pointGeometry(Number.MAX_VALUE, Number.MAX_VALUE), max: new e.pointGeometry(-Number.MAX_VALUE, -Number.MAX_VALUE) }), c2 = (t3, i4) => {
  51390. const o3 = t3.wrap + t3.canonical.x / (1 << t3.canonical.z), r3 = t3.canonical.y / (1 << t3.canonical.z), n3 = e.EXTENT / (1 << t3.canonical.z), a3 = i4.wrap + i4.canonical.x / (1 << i4.canonical.z), s3 = i4.canonical.y / (1 << i4.canonical.z);
  51391. return o3 + n3 < a3 + l2.min.x || o3 > a3 + l2.max.x || r3 + n3 < s3 + l2.min.y || r3 > s3 + l2.max.y;
  51392. };
  51393. for (let e2 = 0; e2 < n2.length; e2++) {
  51394. const a3 = n2[e2];
  51395. for (let e3 = 0; e3 < i3.length; e3++) {
  51396. const n3 = t2.getTile(i3[e3]);
  51397. if (!n3 || !n3.hasData())
  51398. continue;
  51399. if (c2(a3, n3.tileID))
  51400. continue;
  51401. const s3 = this._createProxiedId(a3, n3, o2[a3.key] && o2[a3.key][t2.id]), l3 = this.proxyToSource[a3.key][t2.id];
  51402. l3 ? l3.push(s3) : this.proxyToSource[a3.key][t2.id] = [s3], r2.push(s3);
  51403. }
  51404. }
  51405. }
  51406. _createProxiedId(t2, i3, o2) {
  51407. let r2 = this.orthoMatrix;
  51408. if (o2) {
  51409. const e2 = o2.find((e3) => e3.key === i3.tileID.key);
  51410. if (e2)
  51411. return e2;
  51412. }
  51413. if (i3.tileID.key !== t2.key) {
  51414. const o3 = t2.canonical.z - i3.tileID.canonical.z;
  51415. let n2, a2, s2;
  51416. r2 = e.create();
  51417. const l2 = i3.tileID.wrap - t2.wrap << t2.overscaledZ;
  51418. o3 > 0 ? (n2 = e.EXTENT >> o3, a2 = n2 * ((i3.tileID.canonical.x << o3) - t2.canonical.x + l2), s2 = n2 * ((i3.tileID.canonical.y << o3) - t2.canonical.y)) : (n2 = e.EXTENT << -o3, a2 = e.EXTENT * (i3.tileID.canonical.x - (t2.canonical.x + l2 << -o3)), s2 = e.EXTENT * (i3.tileID.canonical.y - (t2.canonical.y << -o3))), e.ortho(r2, 0, n2, 0, n2, 0, 1), e.translate(r2, r2, [a2, s2, 0]);
  51419. }
  51420. return new yi(i3.tileID, t2.key, r2);
  51421. }
  51422. _findTileCoveringTileID(t2, i3) {
  51423. let o2 = i3.getTile(t2);
  51424. if (o2 && o2.hasData())
  51425. return o2;
  51426. const r2 = this._findCoveringTileCache[i3.id], n2 = r2[t2.key];
  51427. if (o2 = n2 ? i3.getTileByID(n2) : null, o2 && o2.hasData() || null === n2)
  51428. return o2;
  51429. let a2 = o2 ? o2.tileID : t2, s2 = a2.overscaledZ;
  51430. const l2 = i3.getSource().minzoom, c2 = [];
  51431. if (!n2) {
  51432. const r3 = i3.getSource().maxzoom;
  51433. if (t2.canonical.z >= r3) {
  51434. const o3 = t2.canonical.z - r3;
  51435. i3.getSource().reparseOverscaled ? (s2 = Math.max(t2.canonical.z + 2, i3.transform.tileZoom), a2 = new e.OverscaledTileID(s2, t2.wrap, r3, t2.canonical.x >> o3, t2.canonical.y >> o3)) : 0 !== o3 && (s2 = r3, a2 = new e.OverscaledTileID(s2, t2.wrap, r3, t2.canonical.x >> o3, t2.canonical.y >> o3));
  51436. }
  51437. a2.key !== t2.key && (c2.push(a2.key), o2 = i3.getTile(a2));
  51438. }
  51439. const h2 = (e2) => {
  51440. c2.forEach((t3) => {
  51441. r2[t3] = e2;
  51442. }), c2.length = 0;
  51443. };
  51444. for (s2 -= 1; s2 >= l2 && (!o2 || !o2.hasData()); s2--) {
  51445. o2 && h2(o2.tileID.key);
  51446. const e2 = a2.calculateScaledKey(s2);
  51447. if (o2 = i3.getTileByID(e2), o2 && o2.hasData())
  51448. break;
  51449. const t3 = r2[e2];
  51450. if (null === t3)
  51451. break;
  51452. void 0 === t3 ? c2.push(e2) : o2 = i3.getTileByID(t3);
  51453. }
  51454. return h2(o2 ? o2.tileID.key : null), o2 && o2.hasData() ? o2 : null;
  51455. }
  51456. findDEMTileFor(e2) {
  51457. return this.enabled ? this._findTileCoveringTileID(e2, this.sourceCache) : null;
  51458. }
  51459. prepareDrawTile() {
  51460. this.renderedToTile = true;
  51461. }
  51462. _clearRenderCacheForTile(e2, t2) {
  51463. let i3 = this._tilesDirty[e2];
  51464. i3 || (i3 = this._tilesDirty[e2] = {}), i3[t2.key] = true;
  51465. }
  51466. getWirefameBuffer() {
  51467. if (!this.wireframeSegments) {
  51468. const t2 = function(t3) {
  51469. let i3 = 0;
  51470. const o2 = new e.StructArrayLayout2ui4(), r2 = 131;
  51471. for (let e2 = 1; e2 < 129; e2++) {
  51472. for (let t4 = 1; t4 < 129; t4++)
  51473. i3 = e2 * r2 + t4, o2.emplaceBack(i3, i3 + 1), o2.emplaceBack(i3, i3 + r2), o2.emplaceBack(i3 + 1, i3 + r2), 128 === e2 && o2.emplaceBack(i3 + r2, i3 + r2 + 1);
  51474. o2.emplaceBack(i3 + 1, i3 + 1 + r2);
  51475. }
  51476. return o2;
  51477. }();
  51478. this.wireframeIndexBuffer = this.painter.context.createIndexBuffer(t2), this.wireframeSegments = e.SegmentVector.simpleSegment(0, 0, this.gridBuffer.length, t2.length);
  51479. }
  51480. return [this.wireframeIndexBuffer, this.wireframeSegments];
  51481. }
  51482. }
  51483. function wi(e2) {
  51484. const t2 = [];
  51485. for (let i3 = 0; i3 < e2.length; i3++) {
  51486. if (null === e2[i3])
  51487. continue;
  51488. const o2 = e2[i3].split(" ");
  51489. t2.push(o2.pop());
  51490. }
  51491. return t2;
  51492. }
  51493. class Ti {
  51494. static cacheKey(e2, t2, i3) {
  51495. let o2 = `${e2}${i3 ? i3.cacheKey : ""}`;
  51496. for (const e3 of t2)
  51497. o2 += `/${e3}`;
  51498. return o2;
  51499. }
  51500. constructor(t2, i3, o2, r2, n2, a2) {
  51501. const s2 = t2.gl;
  51502. this.program = s2.createProgram();
  51503. const l2 = wi(o2.staticAttributes), c2 = r2 ? r2.getBinderAttributes() : [], h2 = l2.concat(c2), _2 = o2.staticUniforms ? wi(o2.staticUniforms) : [], u2 = r2 ? r2.getBinderUniforms() : [], d2 = _2.concat(u2), p2 = [];
  51504. for (const e2 of d2)
  51505. p2.indexOf(e2) < 0 && p2.push(e2);
  51506. let m2 = r2 ? r2.defines() : [];
  51507. m2 = m2.concat(a2.map((e2) => `#define ${e2}`));
  51508. const f2 = m2.concat("\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif", ei, Qt.fragmentSource, Jt.fragmentSource, o2.fragmentSource).join("\n"), g2 = m2.concat("\n#ifdef GL_ES\nprecision highp float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif", ei, Qt.vertexSource, Jt.vertexSource, Yt.vertexSource, o2.vertexSource).join("\n"), v2 = s2.createShader(s2.FRAGMENT_SHADER);
  51509. if (s2.isContextLost())
  51510. return void (this.failedToCreate = true);
  51511. s2.shaderSource(v2, f2), s2.compileShader(v2), s2.attachShader(this.program, v2);
  51512. const x2 = s2.createShader(s2.VERTEX_SHADER);
  51513. if (s2.isContextLost())
  51514. return void (this.failedToCreate = true);
  51515. s2.shaderSource(x2, g2), s2.compileShader(x2), s2.attachShader(this.program, x2), this.attributes = {};
  51516. const y2 = {};
  51517. this.numAttributes = h2.length;
  51518. for (let e2 = 0; e2 < this.numAttributes; e2++)
  51519. h2[e2] && (s2.bindAttribLocation(this.program, e2, h2[e2]), this.attributes[h2[e2]] = e2);
  51520. s2.linkProgram(this.program), s2.deleteShader(x2), s2.deleteShader(v2);
  51521. for (let e2 = 0; e2 < p2.length; e2++) {
  51522. const t3 = p2[e2];
  51523. if (t3 && !y2[t3]) {
  51524. const e3 = s2.getUniformLocation(this.program, t3);
  51525. e3 && (y2[t3] = e3);
  51526. }
  51527. }
  51528. this.fixedUniforms = n2(t2, y2), this.binderUniforms = r2 ? r2.getUniforms(t2, y2) : [], -1 !== a2.indexOf("TERRAIN") && (this.terrainUniforms = ((t3, i4) => ({ u_dem: new e.Uniform1i(t3, i4.u_dem), u_dem_prev: new e.Uniform1i(t3, i4.u_dem_prev), u_dem_unpack: new e.Uniform4f(t3, i4.u_dem_unpack), u_dem_tl: new e.Uniform2f(t3, i4.u_dem_tl), u_dem_scale: new e.Uniform1f(t3, i4.u_dem_scale), u_dem_tl_prev: new e.Uniform2f(t3, i4.u_dem_tl_prev), u_dem_scale_prev: new e.Uniform1f(t3, i4.u_dem_scale_prev), u_dem_size: new e.Uniform1f(t3, i4.u_dem_size), u_dem_lerp: new e.Uniform1f(t3, i4.u_dem_lerp), u_exaggeration: new e.Uniform1f(t3, i4.u_exaggeration), u_depth: new e.Uniform1i(t3, i4.u_depth), u_depth_size_inv: new e.Uniform2f(t3, i4.u_depth_size_inv), u_meter_to_dem: new e.Uniform1f(t3, i4.u_meter_to_dem), u_label_plane_matrix_inv: new e.UniformMatrix4f(t3, i4.u_label_plane_matrix_inv), u_tile_tl_up: new e.Uniform3f(t3, i4.u_tile_tl_up), u_tile_tr_up: new e.Uniform3f(t3, i4.u_tile_tr_up), u_tile_br_up: new e.Uniform3f(t3, i4.u_tile_br_up), u_tile_bl_up: new e.Uniform3f(t3, i4.u_tile_bl_up), u_tile_up_scale: new e.Uniform1f(t3, i4.u_tile_up_scale) }))(t2, y2)), -1 !== a2.indexOf("FOG") && (this.fogUniforms = ((t3, i4) => ({ u_fog_matrix: new e.UniformMatrix4f(t3, i4.u_fog_matrix), u_fog_range: new e.Uniform2f(t3, i4.u_fog_range), u_fog_color: new e.Uniform4f(t3, i4.u_fog_color), u_fog_horizon_blend: new e.Uniform1f(t3, i4.u_fog_horizon_blend), u_fog_temporal_offset: new e.Uniform1f(t3, i4.u_fog_temporal_offset) }))(t2, y2));
  51529. }
  51530. setTerrainUniformValues(e2, t2) {
  51531. if (!this.terrainUniforms)
  51532. return;
  51533. const i3 = this.terrainUniforms;
  51534. if (!this.failedToCreate) {
  51535. e2.program.set(this.program);
  51536. for (const e3 in t2)
  51537. i3[e3].set(t2[e3]);
  51538. }
  51539. }
  51540. setFogUniformValues(e2, t2) {
  51541. if (!this.fogUniforms)
  51542. return;
  51543. const i3 = this.fogUniforms;
  51544. if (!this.failedToCreate) {
  51545. e2.program.set(this.program);
  51546. for (const e3 in t2)
  51547. i3[e3].location && i3[e3].set(t2[e3]);
  51548. }
  51549. }
  51550. draw(e2, t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2, d2, p2, m2) {
  51551. const f2 = e2.gl;
  51552. if (this.failedToCreate)
  51553. return;
  51554. e2.program.set(this.program), e2.setDepthMode(i3), e2.setStencilMode(o2), e2.setColorMode(r2), e2.setCullFace(n2);
  51555. for (const e3 of Object.keys(this.fixedUniforms))
  51556. this.fixedUniforms[e3].set(a2[e3]);
  51557. d2 && d2.setUniforms(e2, this.binderUniforms, _2, { zoom: u2 });
  51558. const g2 = { [f2.LINES]: 2, [f2.TRIANGLES]: 3, [f2.LINE_STRIP]: 1 }[t2];
  51559. for (const i4 of h2.get()) {
  51560. const o3 = i4.vaos || (i4.vaos = {});
  51561. (o3[s2] || (o3[s2] = new oi())).bind(e2, this, l2, d2 ? d2.getPaintVertexBuffers() : [], c2, i4.vertexOffset, p2, m2), f2.drawElements(t2, i4.primitiveLength * g2, f2.UNSIGNED_SHORT, i4.primitiveOffset * g2 * 2);
  51562. }
  51563. }
  51564. }
  51565. function Ei(e2, t2, i3) {
  51566. const o2 = 1 / L(i3, 1, t2.transform.tileZoom), r2 = Math.pow(2, i3.tileID.overscaledZ), n2 = i3.tileSize * Math.pow(2, t2.transform.tileZoom) / r2, a2 = n2 * (i3.tileID.canonical.x + i3.tileID.wrap * r2), s2 = n2 * i3.tileID.canonical.y;
  51567. return { u_image: 0, u_texsize: i3.imageAtlasTexture.size, u_scale: [o2, e2.fromScale, e2.toScale], u_fade: e2.t, u_pixel_coord_upper: [a2 >> 16, s2 >> 16], u_pixel_coord_lower: [65535 & a2, 65535 & s2] };
  51568. }
  51569. const Ci = e.create(), Ii = (t2, i3, o2, r2, n2, a2, s2, l2, c2) => {
  51570. const h2 = i3.style.light, _2 = h2.properties.get("position"), u2 = [_2.x, _2.y, _2.z], d2 = e.create$1();
  51571. "viewport" === h2.properties.get("anchor") && (e.fromRotation(d2, -i3.transform.angle), e.transformMat3(u2, u2, d2));
  51572. const p2 = h2.properties.get("color"), m2 = i3.transform, f2 = { u_matrix: t2, u_lightpos: u2, u_lightintensity: h2.properties.get("intensity"), u_lightcolor: [p2.r, p2.g, p2.b], u_vertical_gradient: +o2, u_opacity: r2, u_tile_id: [0, 0, 0], u_zoom_transition: 0, u_inv_rot_matrix: Ci, u_merc_center: [0, 0], u_up_dir: [0, 0, 0], u_height_lift: 0 };
  51573. return "globe" === m2.projection.name && (f2.u_tile_id = [n2.canonical.x, n2.canonical.y, 1 << n2.canonical.z], f2.u_zoom_transition = s2, f2.u_inv_rot_matrix = c2, f2.u_merc_center = l2, f2.u_up_dir = m2.projection.upVector(new e.CanonicalTileID(0, 0, 0), l2[0] * e.EXTENT, l2[1] * e.EXTENT), f2.u_height_lift = a2), f2;
  51574. }, Mi = (t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2) => {
  51575. const u2 = Ii(t2, i3, o2, r2, n2, l2, c2, h2, _2), d2 = { u_height_factor: -Math.pow(2, n2.overscaledZ) / s2.tileSize / 8 };
  51576. return e.extend(u2, Ei(a2, i3, s2), d2);
  51577. }, Si = (e2) => ({ u_matrix: e2 }), zi = (t2, i3, o2, r2) => e.extend(Si(t2), Ei(o2, i3, r2)), Di = (e2, t2) => ({ u_matrix: e2, u_world: t2 }), Pi = (t2, i3, o2, r2, n2) => e.extend(zi(t2, i3, o2, r2), { u_world: n2 }), Ai = e.create(), Li = (t2, i3, o2, r2, n2, a2) => {
  51578. const s2 = t2.transform, l2 = "globe" === s2.projection.name;
  51579. let c2;
  51580. if ("map" === a2.paint.get("circle-pitch-alignment"))
  51581. if (l2) {
  51582. const t3 = e.globePixelsToTileUnits(s2.zoom, i3.canonical);
  51583. c2 = Float32Array.from([t3, 0, 0, t3]);
  51584. } else
  51585. c2 = s2.calculatePixelsToTileUnitsMatrix(o2);
  51586. else
  51587. c2 = new Float32Array([s2.pixelsToGLUnits[0], 0, 0, s2.pixelsToGLUnits[1]]);
  51588. const h2 = { u_camera_to_center_distance: s2.cameraToCenterDistance, u_matrix: t2.translatePosMatrix(i3.projMatrix, o2, a2.paint.get("circle-translate"), a2.paint.get("circle-translate-anchor")), u_device_pixel_ratio: e.exported.devicePixelRatio, u_extrude_scale: c2, u_inv_rot_matrix: Ai, u_merc_center: [0, 0], u_tile_id: [0, 0, 0], u_zoom_transition: 0, u_up_dir: [0, 0, 0] };
  51589. return l2 && (h2.u_inv_rot_matrix = r2, h2.u_merc_center = n2, h2.u_tile_id = [i3.canonical.x, i3.canonical.y, 1 << i3.canonical.z], h2.u_zoom_transition = e.globeToMercatorTransition(s2.zoom), h2.u_up_dir = s2.projection.upVector(i3.canonical, n2[0], n2[1])), h2;
  51590. }, Ri = (e2) => {
  51591. const t2 = [];
  51592. return "map" === e2.paint.get("circle-pitch-alignment") && t2.push("PITCH_WITH_MAP"), "map" === e2.paint.get("circle-pitch-scale") && t2.push("SCALE_WITH_MAP"), t2;
  51593. }, ki = (t2, i3, o2) => {
  51594. const r2 = e.EXTENT / o2.tileSize;
  51595. return { u_matrix: t2, u_camera_to_center_distance: i3.cameraToCenterDistance, u_extrude_scale: [i3.pixelsToGLUnits[0] / r2, i3.pixelsToGLUnits[1] / r2] };
  51596. }, Oi = (e2, t2, i3 = 1) => ({ u_matrix: e2, u_color: t2, u_overlay: 0, u_overlay_scale: i3 }), Bi = e.create(), Fi = (t2, i3, o2, r2, n2, a2, s2) => {
  51597. const l2 = t2.transform, c2 = "globe" === l2.projection.name, h2 = c2 ? e.globePixelsToTileUnits(l2.zoom, i3.canonical) : L(o2, 1, a2), _2 = { u_matrix: i3.projMatrix, u_extrude_scale: h2, u_intensity: s2, u_inv_rot_matrix: Bi, u_merc_center: [0, 0], u_tile_id: [0, 0, 0], u_zoom_transition: 0, u_up_dir: [0, 0, 0] };
  51598. return c2 && (_2.u_inv_rot_matrix = r2, _2.u_merc_center = n2, _2.u_tile_id = [i3.canonical.x, i3.canonical.y, 1 << i3.canonical.z], _2.u_zoom_transition = e.globeToMercatorTransition(l2.zoom), _2.u_up_dir = l2.projection.upVector(i3.canonical, n2[0], n2[1])), _2;
  51599. }, Ui = (e2, t2, i3, o2, r2, n2, a2) => {
  51600. const s2 = e2.transform, l2 = s2.calculatePixelsToTileUnitsMatrix(t2), c2 = { u_matrix: ji(e2, t2, i3, r2), u_pixels_to_tile_units: l2, u_device_pixel_ratio: a2, u_units_to_pixels: [1 / s2.pixelsToGLUnits[0], 1 / s2.pixelsToGLUnits[1]], u_dash_image: 0, u_gradient_image: 1, u_image_height: n2, u_texsize: [0, 0], u_scale: [0, 0, 0], u_mix: 0, u_alpha_discard_threshold: 0 };
  51601. if (Zi(i3)) {
  51602. const i4 = Gi(t2, e2.transform);
  51603. c2.u_texsize = t2.lineAtlasTexture.size, c2.u_scale = [i4, o2.fromScale, o2.toScale], c2.u_mix = o2.t;
  51604. }
  51605. return c2;
  51606. }, Ni = (e2, t2, i3, o2, r2, n2) => {
  51607. const a2 = e2.transform, s2 = Gi(t2, a2);
  51608. return { u_matrix: ji(e2, t2, i3, r2), u_texsize: t2.imageAtlasTexture.size, u_pixels_to_tile_units: a2.calculatePixelsToTileUnitsMatrix(t2), u_device_pixel_ratio: n2, u_image: 0, u_scale: [s2, o2.fromScale, o2.toScale], u_fade: o2.t, u_units_to_pixels: [1 / a2.pixelsToGLUnits[0], 1 / a2.pixelsToGLUnits[1]], u_alpha_discard_threshold: 0 };
  51609. };
  51610. function Gi(e2, t2) {
  51611. return 1 / L(e2, 1, t2.tileZoom);
  51612. }
  51613. function ji(e2, t2, i3, o2) {
  51614. return e2.translatePosMatrix(o2 || t2.tileID.projMatrix, t2, i3.paint.get("line-translate"), i3.paint.get("line-translate-anchor"));
  51615. }
  51616. function Zi(e2) {
  51617. const t2 = e2.paint.get("line-dasharray").value;
  51618. return t2.value || "constant" !== t2.kind;
  51619. }
  51620. const Vi = (e2, t2, i3, o2, r2, n2) => {
  51621. return { u_matrix: e2, u_tl_parent: t2, u_scale_parent: i3, u_fade_t: o2.mix, u_opacity: o2.opacity * r2.paint.get("raster-opacity"), u_image0: 0, u_image1: 1, u_brightness_low: r2.paint.get("raster-brightness-min"), u_brightness_high: r2.paint.get("raster-brightness-max"), u_saturation_factor: (s2 = r2.paint.get("raster-saturation"), s2 > 0 ? 1 - 1 / (1.001 - s2) : -s2), u_contrast_factor: (a2 = r2.paint.get("raster-contrast"), a2 > 0 ? 1 / (1 - a2) : 1 + a2), u_spin_weights: Wi(r2.paint.get("raster-hue-rotate")), u_perspective_transform: n2 };
  51622. var a2, s2;
  51623. };
  51624. function Wi(e2) {
  51625. e2 *= Math.PI / 180;
  51626. const t2 = Math.sin(e2), i3 = Math.cos(e2);
  51627. return [(2 * i3 + 1) / 3, (-Math.sqrt(3) * t2 - i3 + 1) / 3, (Math.sqrt(3) * t2 - i3 + 1) / 3];
  51628. }
  51629. const qi = e.create(), Xi = (t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2, d2, p2) => {
  51630. const m2 = n2.transform, f2 = { u_is_size_zoom_constant: +("constant" === t2 || "source" === t2), u_is_size_feature_constant: +("constant" === t2 || "camera" === t2), u_size_t: i3 ? i3.uSizeT : 0, u_size: i3 ? i3.uSize : 0, u_camera_to_center_distance: m2.cameraToCenterDistance, u_rotate_symbol: +o2, u_aspect_ratio: m2.width / m2.height, u_fade_change: n2.options.fadeDuration ? n2.symbolFadeChange : 1, u_matrix: a2, u_label_plane_matrix: s2, u_coord_matrix: l2, u_is_text: +c2, u_pitch_with_map: +r2, u_texsize: h2, u_texture: 0, u_tile_id: [0, 0, 0], u_zoom_transition: 0, u_inv_rot_matrix: qi, u_merc_center: [0, 0], u_camera_forward: [0, 0, 0], u_ecef_origin: [0, 0, 0], u_tile_matrix: qi };
  51631. return "globe" === m2.projection.name && (f2.u_tile_id = [_2.canonical.x, _2.canonical.y, 1 << _2.canonical.z], f2.u_zoom_transition = u2, f2.u_inv_rot_matrix = p2, f2.u_merc_center = d2, f2.u_camera_forward = m2._camera.forward(), f2.u_ecef_origin = e.globeECEFOrigin(m2.globeMatrix, _2.toUnwrapped()), f2.u_tile_matrix = Float32Array.from(m2.globeMatrix)), f2;
  51632. }, $i = (t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2, d2, p2, m2) => {
  51633. const { cameraToCenterDistance: f2, _pitch: g2 } = n2.transform;
  51634. return e.extend(Xi(t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, u2, d2, p2, m2), { u_gamma_scale: r2 ? f2 * Math.cos(n2.terrain ? 0 : g2) : 1, u_device_pixel_ratio: e.exported.devicePixelRatio, u_is_halo: +_2 });
  51635. }, Hi = (t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2, d2, p2) => e.extend($i(t2, i3, o2, r2, n2, a2, s2, l2, true, c2, true, _2, u2, d2, p2), { u_texsize_icon: h2, u_texture_icon: 1 }), Ki = (e2, t2, i3) => ({ u_matrix: e2, u_opacity: t2, u_color: i3 }), Yi = (t2, i3, o2, r2, n2, a2) => e.extend(function(e2, t3, i4, o3) {
  51636. const r3 = i4.imageManager.getPattern(e2.from.toString()), n3 = i4.imageManager.getPattern(e2.to.toString()), { width: a3, height: s2 } = i4.imageManager.getPixelSize(), l2 = Math.pow(2, o3.tileID.overscaledZ), c2 = o3.tileSize * Math.pow(2, i4.transform.tileZoom) / l2, h2 = c2 * (o3.tileID.canonical.x + o3.tileID.wrap * l2), _2 = c2 * o3.tileID.canonical.y;
  51637. return { u_image: 0, u_pattern_tl_a: r3.tl, u_pattern_br_a: r3.br, u_pattern_tl_b: n3.tl, u_pattern_br_b: n3.br, u_texsize: [a3, s2], u_mix: t3.t, u_pattern_size_a: r3.displaySize, u_pattern_size_b: n3.displaySize, u_scale_a: t3.fromScale, u_scale_b: t3.toScale, u_tile_units_to_pixels: 1 / L(o3, 1, i4.transform.tileZoom), u_pixel_coord_upper: [h2 >> 16, _2 >> 16], u_pixel_coord_lower: [65535 & h2, 65535 & _2] };
  51638. }(r2, a2, o2, n2), { u_matrix: t2, u_opacity: i3 }), Ji = { fillExtrusion: (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_lightpos: new e.Uniform3f(t2, i3.u_lightpos), u_lightintensity: new e.Uniform1f(t2, i3.u_lightintensity), u_lightcolor: new e.Uniform3f(t2, i3.u_lightcolor), u_vertical_gradient: new e.Uniform1f(t2, i3.u_vertical_gradient), u_opacity: new e.Uniform1f(t2, i3.u_opacity), u_tile_id: new e.Uniform3f(t2, i3.u_tile_id), u_zoom_transition: new e.Uniform1f(t2, i3.u_zoom_transition), u_inv_rot_matrix: new e.UniformMatrix4f(t2, i3.u_inv_rot_matrix), u_merc_center: new e.Uniform2f(t2, i3.u_merc_center), u_up_dir: new e.Uniform3f(t2, i3.u_up_dir), u_height_lift: new e.Uniform1f(t2, i3.u_height_lift) }), fillExtrusionPattern: (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_lightpos: new e.Uniform3f(t2, i3.u_lightpos), u_lightintensity: new e.Uniform1f(t2, i3.u_lightintensity), u_lightcolor: new e.Uniform3f(t2, i3.u_lightcolor), u_vertical_gradient: new e.Uniform1f(t2, i3.u_vertical_gradient), u_height_factor: new e.Uniform1f(t2, i3.u_height_factor), u_tile_id: new e.Uniform3f(t2, i3.u_tile_id), u_zoom_transition: new e.Uniform1f(t2, i3.u_zoom_transition), u_inv_rot_matrix: new e.UniformMatrix4f(t2, i3.u_inv_rot_matrix), u_merc_center: new e.Uniform2f(t2, i3.u_merc_center), u_up_dir: new e.Uniform3f(t2, i3.u_up_dir), u_height_lift: new e.Uniform1f(t2, i3.u_height_lift), u_image: new e.Uniform1i(t2, i3.u_image), u_texsize: new e.Uniform2f(t2, i3.u_texsize), u_pixel_coord_upper: new e.Uniform2f(t2, i3.u_pixel_coord_upper), u_pixel_coord_lower: new e.Uniform2f(t2, i3.u_pixel_coord_lower), u_scale: new e.Uniform3f(t2, i3.u_scale), u_fade: new e.Uniform1f(t2, i3.u_fade), u_opacity: new e.Uniform1f(t2, i3.u_opacity) }), fill: (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix) }), fillPattern: (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_image: new e.Uniform1i(t2, i3.u_image), u_texsize: new e.Uniform2f(t2, i3.u_texsize), u_pixel_coord_upper: new e.Uniform2f(t2, i3.u_pixel_coord_upper), u_pixel_coord_lower: new e.Uniform2f(t2, i3.u_pixel_coord_lower), u_scale: new e.Uniform3f(t2, i3.u_scale), u_fade: new e.Uniform1f(t2, i3.u_fade) }), fillOutline: (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_world: new e.Uniform2f(t2, i3.u_world) }), fillOutlinePattern: (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_world: new e.Uniform2f(t2, i3.u_world), u_image: new e.Uniform1i(t2, i3.u_image), u_texsize: new e.Uniform2f(t2, i3.u_texsize), u_pixel_coord_upper: new e.Uniform2f(t2, i3.u_pixel_coord_upper), u_pixel_coord_lower: new e.Uniform2f(t2, i3.u_pixel_coord_lower), u_scale: new e.Uniform3f(t2, i3.u_scale), u_fade: new e.Uniform1f(t2, i3.u_fade) }), circle: (t2, i3) => ({ u_camera_to_center_distance: new e.Uniform1f(t2, i3.u_camera_to_center_distance), u_extrude_scale: new e.UniformMatrix2f(t2, i3.u_extrude_scale), u_device_pixel_ratio: new e.Uniform1f(t2, i3.u_device_pixel_ratio), u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_inv_rot_matrix: new e.UniformMatrix4f(t2, i3.u_inv_rot_matrix), u_merc_center: new e.Uniform2f(t2, i3.u_merc_center), u_tile_id: new e.Uniform3f(t2, i3.u_tile_id), u_zoom_transition: new e.Uniform1f(t2, i3.u_zoom_transition), u_up_dir: new e.Uniform3f(t2, i3.u_up_dir) }), collisionBox: (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_camera_to_center_distance: new e.Uniform1f(t2, i3.u_camera_to_center_distance), u_extrude_scale: new e.Uniform2f(t2, i3.u_extrude_scale) }), collisionCircle: (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_inv_matrix: new e.UniformMatrix4f(t2, i3.u_inv_matrix), u_camera_to_center_distance: new e.Uniform1f(t2, i3.u_camera_to_center_distance), u_viewport_size: new e.Uniform2f(t2, i3.u_viewport_size) }), debug: (t2, i3) => ({ u_color: new e.UniformColor(t2, i3.u_color), u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_overlay: new e.Uniform1i(t2, i3.u_overlay), u_overlay_scale: new e.Uniform1f(t2, i3.u_overlay_scale) }), clippingMask: (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix) }), heatmap: (t2, i3) => ({ u_extrude_scale: new e.Uniform1f(t2, i3.u_extrude_scale), u_intensity: new e.Uniform1f(t2, i3.u_intensity), u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_inv_rot_matrix: new e.UniformMatrix4f(t2, i3.u_inv_rot_matrix), u_merc_center: new e.Uniform2f(t2, i3.u_merc_center), u_tile_id: new e.Uniform3f(t2, i3.u_tile_id), u_zoom_transition: new e.Uniform1f(t2, i3.u_zoom_transition), u_up_dir: new e.Uniform3f(t2, i3.u_up_dir) }), heatmapTexture: (t2, i3) => ({ u_image: new e.Uniform1i(t2, i3.u_image), u_color_ramp: new e.Uniform1i(t2, i3.u_color_ramp), u_opacity: new e.Uniform1f(t2, i3.u_opacity) }), hillshade: (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_image: new e.Uniform1i(t2, i3.u_image), u_latrange: new e.Uniform2f(t2, i3.u_latrange), u_light: new e.Uniform2f(t2, i3.u_light), u_shadow: new e.UniformColor(t2, i3.u_shadow), u_highlight: new e.UniformColor(t2, i3.u_highlight), u_accent: new e.UniformColor(t2, i3.u_accent) }), hillshadePrepare: (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_image: new e.Uniform1i(t2, i3.u_image), u_dimension: new e.Uniform2f(t2, i3.u_dimension), u_zoom: new e.Uniform1f(t2, i3.u_zoom), u_unpack: new e.Uniform4f(t2, i3.u_unpack) }), line: (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_pixels_to_tile_units: new e.UniformMatrix2f(t2, i3.u_pixels_to_tile_units), u_device_pixel_ratio: new e.Uniform1f(t2, i3.u_device_pixel_ratio), u_units_to_pixels: new e.Uniform2f(t2, i3.u_units_to_pixels), u_dash_image: new e.Uniform1i(t2, i3.u_dash_image), u_gradient_image: new e.Uniform1i(t2, i3.u_gradient_image), u_image_height: new e.Uniform1f(t2, i3.u_image_height), u_texsize: new e.Uniform2f(t2, i3.u_texsize), u_scale: new e.Uniform3f(t2, i3.u_scale), u_mix: new e.Uniform1f(t2, i3.u_mix), u_alpha_discard_threshold: new e.Uniform1f(t2, i3.u_alpha_discard_threshold) }), linePattern: (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_texsize: new e.Uniform2f(t2, i3.u_texsize), u_pixels_to_tile_units: new e.UniformMatrix2f(t2, i3.u_pixels_to_tile_units), u_device_pixel_ratio: new e.Uniform1f(t2, i3.u_device_pixel_ratio), u_image: new e.Uniform1i(t2, i3.u_image), u_units_to_pixels: new e.Uniform2f(t2, i3.u_units_to_pixels), u_scale: new e.Uniform3f(t2, i3.u_scale), u_fade: new e.Uniform1f(t2, i3.u_fade), u_alpha_discard_threshold: new e.Uniform1f(t2, i3.u_alpha_discard_threshold) }), raster: (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_tl_parent: new e.Uniform2f(t2, i3.u_tl_parent), u_scale_parent: new e.Uniform1f(t2, i3.u_scale_parent), u_fade_t: new e.Uniform1f(t2, i3.u_fade_t), u_opacity: new e.Uniform1f(t2, i3.u_opacity), u_image0: new e.Uniform1i(t2, i3.u_image0), u_image1: new e.Uniform1i(t2, i3.u_image1), u_brightness_low: new e.Uniform1f(t2, i3.u_brightness_low), u_brightness_high: new e.Uniform1f(t2, i3.u_brightness_high), u_saturation_factor: new e.Uniform1f(t2, i3.u_saturation_factor), u_contrast_factor: new e.Uniform1f(t2, i3.u_contrast_factor), u_spin_weights: new e.Uniform3f(t2, i3.u_spin_weights), u_perspective_transform: new e.Uniform2f(t2, i3.u_perspective_transform) }), symbolIcon: (t2, i3) => ({ u_is_size_zoom_constant: new e.Uniform1i(t2, i3.u_is_size_zoom_constant), u_is_size_feature_constant: new e.Uniform1i(t2, i3.u_is_size_feature_constant), u_size_t: new e.Uniform1f(t2, i3.u_size_t), u_size: new e.Uniform1f(t2, i3.u_size), u_camera_to_center_distance: new e.Uniform1f(t2, i3.u_camera_to_center_distance), u_rotate_symbol: new e.Uniform1i(t2, i3.u_rotate_symbol), u_aspect_ratio: new e.Uniform1f(t2, i3.u_aspect_ratio), u_fade_change: new e.Uniform1f(t2, i3.u_fade_change), u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_label_plane_matrix: new e.UniformMatrix4f(t2, i3.u_label_plane_matrix), u_coord_matrix: new e.UniformMatrix4f(t2, i3.u_coord_matrix), u_is_text: new e.Uniform1i(t2, i3.u_is_text), u_pitch_with_map: new e.Uniform1i(t2, i3.u_pitch_with_map), u_texsize: new e.Uniform2f(t2, i3.u_texsize), u_tile_id: new e.Uniform3f(t2, i3.u_tile_id), u_zoom_transition: new e.Uniform1f(t2, i3.u_zoom_transition), u_inv_rot_matrix: new e.UniformMatrix4f(t2, i3.u_inv_rot_matrix), u_merc_center: new e.Uniform2f(t2, i3.u_merc_center), u_camera_forward: new e.Uniform3f(t2, i3.u_camera_forward), u_tile_matrix: new e.UniformMatrix4f(t2, i3.u_tile_matrix), u_ecef_origin: new e.Uniform3f(t2, i3.u_ecef_origin), u_texture: new e.Uniform1i(t2, i3.u_texture) }), symbolSDF: (t2, i3) => ({ u_is_size_zoom_constant: new e.Uniform1i(t2, i3.u_is_size_zoom_constant), u_is_size_feature_constant: new e.Uniform1i(t2, i3.u_is_size_feature_constant), u_size_t: new e.Uniform1f(t2, i3.u_size_t), u_size: new e.Uniform1f(t2, i3.u_size), u_camera_to_center_distance: new e.Uniform1f(t2, i3.u_camera_to_center_distance), u_rotate_symbol: new e.Uniform1i(t2, i3.u_rotate_symbol), u_aspect_ratio: new e.Uniform1f(t2, i3.u_aspect_ratio), u_fade_change: new e.Uniform1f(t2, i3.u_fade_change), u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_label_plane_matrix: new e.UniformMatrix4f(t2, i3.u_label_plane_matrix), u_coord_matrix: new e.UniformMatrix4f(t2, i3.u_coord_matrix), u_is_text: new e.Uniform1i(t2, i3.u_is_text), u_pitch_with_map: new e.Uniform1i(t2, i3.u_pitch_with_map), u_texsize: new e.Uniform2f(t2, i3.u_texsize), u_texture: new e.Uniform1i(t2, i3.u_texture), u_gamma_scale: new e.Uniform1f(t2, i3.u_gamma_scale), u_device_pixel_ratio: new e.Uniform1f(t2, i3.u_device_pixel_ratio), u_tile_id: new e.Uniform3f(t2, i3.u_tile_id), u_zoom_transition: new e.Uniform1f(t2, i3.u_zoom_transition), u_inv_rot_matrix: new e.UniformMatrix4f(t2, i3.u_inv_rot_matrix), u_merc_center: new e.Uniform2f(t2, i3.u_merc_center), u_camera_forward: new e.Uniform3f(t2, i3.u_camera_forward), u_tile_matrix: new e.UniformMatrix4f(t2, i3.u_tile_matrix), u_ecef_origin: new e.Uniform3f(t2, i3.u_ecef_origin), u_is_halo: new e.Uniform1i(t2, i3.u_is_halo) }), symbolTextAndIcon: (t2, i3) => ({ u_is_size_zoom_constant: new e.Uniform1i(t2, i3.u_is_size_zoom_constant), u_is_size_feature_constant: new e.Uniform1i(t2, i3.u_is_size_feature_constant), u_size_t: new e.Uniform1f(t2, i3.u_size_t), u_size: new e.Uniform1f(t2, i3.u_size), u_camera_to_center_distance: new e.Uniform1f(t2, i3.u_camera_to_center_distance), u_rotate_symbol: new e.Uniform1i(t2, i3.u_rotate_symbol), u_aspect_ratio: new e.Uniform1f(t2, i3.u_aspect_ratio), u_fade_change: new e.Uniform1f(t2, i3.u_fade_change), u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_label_plane_matrix: new e.UniformMatrix4f(t2, i3.u_label_plane_matrix), u_coord_matrix: new e.UniformMatrix4f(t2, i3.u_coord_matrix), u_is_text: new e.Uniform1i(t2, i3.u_is_text), u_pitch_with_map: new e.Uniform1i(t2, i3.u_pitch_with_map), u_texsize: new e.Uniform2f(t2, i3.u_texsize), u_texsize_icon: new e.Uniform2f(t2, i3.u_texsize_icon), u_texture: new e.Uniform1i(t2, i3.u_texture), u_texture_icon: new e.Uniform1i(t2, i3.u_texture_icon), u_gamma_scale: new e.Uniform1f(t2, i3.u_gamma_scale), u_device_pixel_ratio: new e.Uniform1f(t2, i3.u_device_pixel_ratio), u_is_halo: new e.Uniform1i(t2, i3.u_is_halo) }), background: (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_opacity: new e.Uniform1f(t2, i3.u_opacity), u_color: new e.UniformColor(t2, i3.u_color) }), backgroundPattern: (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_opacity: new e.Uniform1f(t2, i3.u_opacity), u_image: new e.Uniform1i(t2, i3.u_image), u_pattern_tl_a: new e.Uniform2f(t2, i3.u_pattern_tl_a), u_pattern_br_a: new e.Uniform2f(t2, i3.u_pattern_br_a), u_pattern_tl_b: new e.Uniform2f(t2, i3.u_pattern_tl_b), u_pattern_br_b: new e.Uniform2f(t2, i3.u_pattern_br_b), u_texsize: new e.Uniform2f(t2, i3.u_texsize), u_mix: new e.Uniform1f(t2, i3.u_mix), u_pattern_size_a: new e.Uniform2f(t2, i3.u_pattern_size_a), u_pattern_size_b: new e.Uniform2f(t2, i3.u_pattern_size_b), u_scale_a: new e.Uniform1f(t2, i3.u_scale_a), u_scale_b: new e.Uniform1f(t2, i3.u_scale_b), u_pixel_coord_upper: new e.Uniform2f(t2, i3.u_pixel_coord_upper), u_pixel_coord_lower: new e.Uniform2f(t2, i3.u_pixel_coord_lower), u_tile_units_to_pixels: new e.Uniform1f(t2, i3.u_tile_units_to_pixels) }), terrainRaster: li, terrainDepth: li, skybox: (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_sun_direction: new e.Uniform3f(t2, i3.u_sun_direction), u_cubemap: new e.Uniform1i(t2, i3.u_cubemap), u_opacity: new e.Uniform1f(t2, i3.u_opacity), u_temporal_offset: new e.Uniform1f(t2, i3.u_temporal_offset) }), skyboxGradient: (t2, i3) => ({ u_matrix: new e.UniformMatrix4f(t2, i3.u_matrix), u_color_ramp: new e.Uniform1i(t2, i3.u_color_ramp), u_center_direction: new e.Uniform3f(t2, i3.u_center_direction), u_radius: new e.Uniform1f(t2, i3.u_radius), u_opacity: new e.Uniform1f(t2, i3.u_opacity), u_temporal_offset: new e.Uniform1f(t2, i3.u_temporal_offset) }), skyboxCapture: (t2, i3) => ({ u_matrix_3f: new e.UniformMatrix3f(t2, i3.u_matrix_3f), u_sun_direction: new e.Uniform3f(t2, i3.u_sun_direction), u_sun_intensity: new e.Uniform1f(t2, i3.u_sun_intensity), u_color_tint_r: new e.Uniform4f(t2, i3.u_color_tint_r), u_color_tint_m: new e.Uniform4f(t2, i3.u_color_tint_m), u_luminance: new e.Uniform1f(t2, i3.u_luminance) }), globeRaster: (t2, i3) => ({ u_proj_matrix: new e.UniformMatrix4f(t2, i3.u_proj_matrix), u_globe_matrix: new e.UniformMatrix4f(t2, i3.u_globe_matrix), u_merc_matrix: new e.UniformMatrix4f(t2, i3.u_merc_matrix), u_zoom_transition: new e.Uniform1f(t2, i3.u_zoom_transition), u_merc_center: new e.Uniform2f(t2, i3.u_merc_center), u_image0: new e.Uniform1i(t2, i3.u_image0), u_grid_matrix: new e.UniformMatrix3f(t2, i3.u_grid_matrix) }), globeAtmosphere: (t2, i3) => ({ u_frustum_tl: new e.Uniform3f(t2, i3.u_frustum_tl), u_frustum_tr: new e.Uniform3f(t2, i3.u_frustum_tr), u_frustum_br: new e.Uniform3f(t2, i3.u_frustum_br), u_frustum_bl: new e.Uniform3f(t2, i3.u_frustum_bl), u_globe_pos: new e.Uniform3f(t2, i3.u_globe_pos), u_globe_radius: new e.Uniform1f(t2, i3.u_globe_radius), u_opacity: new e.Uniform1f(t2, i3.u_opacity), u_fadeout_range: new e.Uniform1f(t2, i3.u_fadeout_range), u_start_color: new e.Uniform3f(t2, i3.u_start_color), u_end_color: new e.Uniform3f(t2, i3.u_end_color) }) };
  51639. let Qi;
  51640. function eo(t2, i3, o2, r2, n2, a2, s2) {
  51641. const l2 = t2.context, c2 = l2.gl, h2 = t2.useProgram("collisionBox"), _2 = [];
  51642. let u2 = 0, d2 = 0;
  51643. for (let p3 = 0; p3 < r2.length; p3++) {
  51644. const m3 = r2[p3], f3 = i3.getTile(m3), g3 = f3.getBucket(o2);
  51645. if (!g3)
  51646. continue;
  51647. let v3 = m3.projMatrix;
  51648. 0 === n2[0] && 0 === n2[1] || (v3 = t2.translatePosMatrix(m3.projMatrix, f3, n2, a2));
  51649. const x3 = s2 ? g3.textCollisionBox : g3.iconCollisionBox, y2 = g3.collisionCircleArray;
  51650. if (y2.length > 0) {
  51651. const i4 = e.create(), o3 = v3;
  51652. e.mul(i4, g3.placementInvProjMatrix, t2.transform.glCoordMatrix), e.mul(i4, i4, g3.placementViewportMatrix), _2.push({ circleArray: y2, circleOffset: d2, transform: o3, invTransform: i4 }), u2 += y2.length / 4, d2 = u2;
  51653. }
  51654. x3 && (t2.terrain && t2.terrain.setupElevationDraw(f3, h2), h2.draw(l2, c2.LINES, e.DepthMode.disabled, e.StencilMode.disabled, t2.colorModeForRenderPass(), e.CullFaceMode.disabled, ki(v3, t2.transform, f3), o2.id, x3.layoutVertexBuffer, x3.indexBuffer, x3.segments, null, t2.transform.zoom, null, x3.collisionVertexBuffer, x3.collisionVertexBufferExt));
  51655. }
  51656. if (!s2 || !_2.length)
  51657. return;
  51658. const p2 = t2.useProgram("collisionCircle"), m2 = new e.StructArrayLayout2f1f2i16();
  51659. m2.resize(4 * u2), m2._trim();
  51660. let f2 = 0;
  51661. for (const e2 of _2)
  51662. for (let t3 = 0; t3 < e2.circleArray.length / 4; t3++) {
  51663. const i4 = 4 * t3, o3 = e2.circleArray[i4 + 0], r3 = e2.circleArray[i4 + 1], n3 = e2.circleArray[i4 + 2], a3 = e2.circleArray[i4 + 3];
  51664. m2.emplace(f2++, o3, r3, n3, a3, 0), m2.emplace(f2++, o3, r3, n3, a3, 1), m2.emplace(f2++, o3, r3, n3, a3, 2), m2.emplace(f2++, o3, r3, n3, a3, 3);
  51665. }
  51666. (!Qi || Qi.length < 2 * u2) && (Qi = function(t3) {
  51667. const i4 = 2 * t3, o3 = new e.StructArrayLayout3ui6();
  51668. o3.resize(i4), o3._trim();
  51669. for (let e2 = 0; e2 < i4; e2++) {
  51670. const t4 = 6 * e2;
  51671. o3.uint16[t4 + 0] = 4 * e2 + 0, o3.uint16[t4 + 1] = 4 * e2 + 1, o3.uint16[t4 + 2] = 4 * e2 + 2, o3.uint16[t4 + 3] = 4 * e2 + 2, o3.uint16[t4 + 4] = 4 * e2 + 3, o3.uint16[t4 + 5] = 4 * e2 + 0;
  51672. }
  51673. return o3;
  51674. }(u2));
  51675. const g2 = l2.createIndexBuffer(Qi, true), v2 = l2.createVertexBuffer(m2, e.collisionCircleLayout.members, true);
  51676. for (const i4 of _2) {
  51677. const r3 = { u_matrix: i4.transform, u_inv_matrix: i4.invTransform, u_camera_to_center_distance: (x2 = t2.transform).cameraToCenterDistance, u_viewport_size: [x2.width, x2.height] };
  51678. p2.draw(l2, c2.TRIANGLES, e.DepthMode.disabled, e.StencilMode.disabled, t2.colorModeForRenderPass(), e.CullFaceMode.disabled, r3, o2.id, v2, g2, e.SegmentVector.simpleSegment(0, 2 * i4.circleOffset, i4.circleArray.length, i4.circleArray.length / 2), null, t2.transform.zoom, null, null, null);
  51679. }
  51680. var x2;
  51681. v2.destroy(), g2.destroy();
  51682. }
  51683. const to = e.create();
  51684. function io(t2, i3, o2, r2, n2, a2) {
  51685. const { horizontalAlign: s2, verticalAlign: l2 } = e.getAnchorAlignment(t2), c2 = -(s2 - 0.5) * i3, h2 = -(l2 - 0.5) * o2, _2 = e.evaluateVariableOffset(t2, r2);
  51686. return new e.pointGeometry((c2 / n2 + _2[0]) * a2, (h2 / n2 + _2[1]) * a2);
  51687. }
  51688. function oo(t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2) {
  51689. const d2 = t2.text.placedSymbolArray, p2 = t2.text.dynamicLayoutVertexArray, m2 = t2.icon.dynamicLayoutVertexArray, f2 = {}, g2 = l2.projMatrix, v2 = a2.elevation, x2 = u2.upVectorScale(l2.canonical, a2.center.lat, a2.worldSize);
  51690. p2.clear();
  51691. for (let m3 = 0; m3 < d2.length; m3++) {
  51692. const y2 = d2.get(m3), b2 = t2.allowVerticalPlacement && !y2.placedOrientation, w2 = y2.hidden || !y2.crossTileID || b2 ? null : r2[y2.crossTileID];
  51693. if (w2) {
  51694. const r3 = new e.pointGeometry(y2.tileAnchorX, y2.tileAnchorY), d3 = u2.upVector(l2.canonical, r3.x, r3.y), m4 = v2 ? v2.getAtTileOffset(l2, r3.x, r3.y) : 0, b3 = it([y2.projectedAnchorX + m4 * d3[0] * x2.metersToTile, y2.projectedAnchorY + m4 * d3[1] * x2.metersToTile, y2.projectedAnchorZ + m4 * d3[2] * x2.metersToTile], o2 ? g2 : s2), T2 = ot(a2.cameraToCenterDistance, b3.signedDistanceFromCamera);
  51695. let E2 = n2.evaluateSizeForFeature(t2.textSizeData, h2, y2) * T2 / e.ONE_EM;
  51696. o2 && (E2 *= t2.tilePixelRatio / c2);
  51697. const { width: C2, height: I2, anchor: M2, textOffset: S2, textScale: z2 } = w2, D2 = io(M2, C2, I2, S2, z2, E2), P2 = o2 ? tt(r3.add(D2), s2, m4 * x2.metersToLabelSpace).point : b3.point.add(i3 ? D2.rotate(-a2.angle) : D2), A2 = t2.allowVerticalPlacement && y2.placedOrientation === e.WritingMode.vertical ? Math.PI / 2 : 0;
  51698. for (let t3 = 0; t3 < y2.numGlyphs; t3++)
  51699. e.addDynamicAttributes(p2, P2, A2);
  51700. _2 && y2.associatedIconIndex >= 0 && (f2[y2.associatedIconIndex] = { shiftedAnchor: P2, angle: A2 });
  51701. } else
  51702. dt(y2.numGlyphs, p2);
  51703. }
  51704. if (_2) {
  51705. m2.clear();
  51706. const i4 = t2.icon.placedSymbolArray;
  51707. for (let t3 = 0; t3 < i4.length; t3++) {
  51708. const o3 = i4.get(t3);
  51709. if (o3.hidden)
  51710. dt(o3.numGlyphs, m2);
  51711. else {
  51712. const i5 = f2[t3];
  51713. if (i5)
  51714. for (let t4 = 0; t4 < o3.numGlyphs; t4++)
  51715. e.addDynamicAttributes(m2, i5.shiftedAnchor, i5.angle);
  51716. else
  51717. dt(o3.numGlyphs, m2);
  51718. }
  51719. }
  51720. t2.icon.dynamicLayoutVertexBuffer.updateData(m2);
  51721. }
  51722. t2.text.dynamicLayoutVertexBuffer.updateData(p2);
  51723. }
  51724. function ro(e2, t2, i3) {
  51725. return i3.iconsInText && t2 ? "symbolTextAndIcon" : e2 ? "symbolSDF" : "symbolIcon";
  51726. }
  51727. function no(t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2) {
  51728. const d2 = t2.context, p2 = d2.gl, m2 = t2.transform, f2 = "map" === l2, g2 = "map" === c2, v2 = f2 && "point" !== o2.layout.get("symbol-placement"), x2 = f2 && !g2 && !v2, y2 = void 0 !== o2.layout.get("symbol-sort-key").constantOr(1);
  51729. let b2 = false;
  51730. const w2 = t2.depthModeForSublayer(0, e.DepthMode.ReadOnly), T2 = [e.mercatorXfromLng(m2.center.lng), e.mercatorYfromLat(m2.center.lat)], E2 = o2.layout.get("text-variable-anchor"), C2 = "globe" === m2.projection.name, I2 = C2 ? e.globeToMercatorTransition(m2.zoom) : 0, M2 = [], S2 = [];
  51731. t2.terrain && g2 && S2.push("PITCH_WITH_MAP_TERRAIN"), C2 && S2.push("PROJECTION_GLOBE_VIEW");
  51732. for (const l3 of r2) {
  51733. const r3 = i3.getTile(l3), c3 = r3.getBucket(o2);
  51734. if (!c3 || c3.projection !== m2.projection.name)
  51735. continue;
  51736. const _3 = n2 ? c3.text : c3.icon;
  51737. if (!_3 || c3.fullyClipped || !_3.segments.get().length)
  51738. continue;
  51739. const u3 = _3.programConfigurations.get(o2.id), d3 = n2 || c3.sdfIcons, w3 = n2 ? c3.textSizeData : c3.iconSizeData, C3 = g2 || 0 !== m2.pitch, z2 = e.evaluateSizeForZoom(w3, m2.zoom);
  51740. let D2, P2, A2, L2, R2 = [0, 0], k2 = null;
  51741. if (n2) {
  51742. if (P2 = r3.glyphAtlasTexture, A2 = p2.LINEAR, D2 = r3.glyphAtlasTexture.size, c3.iconsInText) {
  51743. R2 = r3.imageAtlasTexture.size, k2 = r3.imageAtlasTexture;
  51744. const e2 = "composite" === w3.kind || "camera" === w3.kind;
  51745. L2 = C3 || t2.options.rotating || t2.options.zooming || e2 ? p2.LINEAR : p2.NEAREST;
  51746. }
  51747. } else {
  51748. const e2 = 1 !== o2.layout.get("icon-size").constantOr(0) || c3.iconsNeedLinear;
  51749. P2 = r3.imageAtlasTexture, A2 = d3 || t2.options.rotating || t2.options.zooming || e2 || C3 ? p2.LINEAR : p2.NEAREST, D2 = r3.imageAtlasTexture.size;
  51750. }
  51751. const O2 = t2.transform.calculatePixelsToTileUnitsMatrix(r3), B2 = Qe(l3.projMatrix, r3.tileID.canonical, g2, f2, t2.transform, O2), F2 = t2.terrain && g2 && v2 ? e.invert(e.create(), B2) : to, U2 = et(l3.projMatrix, r3.tileID.canonical, g2, f2, t2.transform, O2), N2 = E2 && c3.hasTextData(), G2 = "none" !== o2.layout.get("icon-text-fit") && N2 && c3.hasIconData();
  51752. if (v2) {
  51753. const e2 = m2.elevation, i4 = e2 ? e2.getAtTileOffsetFunc(l3, m2.center.lat, m2.worldSize, m2.projection) : (e3) => [0, 0, 0];
  51754. nt(c3, l3.projMatrix, t2, n2, B2, U2, g2, h2, i4, l3);
  51755. }
  51756. const j2 = v2 || n2 && E2 || G2, Z2 = t2.translatePosMatrix(l3.projMatrix, r3, a2, s2), V2 = j2 ? to : B2, W2 = t2.translatePosMatrix(U2, r3, a2, s2, true), q2 = m2.projection.createInversionMatrix(m2, l3.canonical), X2 = j2 ? S2.concat(["PROJECTED_POS_ON_VIEWPORT"]) : S2, $2 = d3 && 0 !== o2.paint.get(n2 ? "text-halo-width" : "icon-halo-width").constantOr(1);
  51757. let H2;
  51758. H2 = d3 ? c3.iconsInText ? Hi(w3.kind, z2, x2, g2, t2, Z2, V2, W2, D2, R2, l3, I2, T2, q2) : $i(w3.kind, z2, x2, g2, t2, Z2, V2, W2, n2, D2, true, l3, I2, T2, q2) : Xi(w3.kind, z2, x2, g2, t2, Z2, V2, W2, n2, D2, l3, I2, T2, q2);
  51759. const K2 = { program: t2.useProgram(ro(d3, n2, c3), u3, X2), buffers: _3, uniformValues: H2, atlasTexture: P2, atlasTextureIcon: k2, atlasInterpolation: A2, atlasInterpolationIcon: L2, isSDF: d3, hasHalo: $2, tile: r3, labelPlaneMatrixInv: F2 };
  51760. if (y2 && c3.canOverlap) {
  51761. b2 = true;
  51762. const t3 = _3.segments.get();
  51763. for (const i4 of t3)
  51764. M2.push({ segments: new e.SegmentVector([i4]), sortKey: i4.sortKey, state: K2 });
  51765. } else
  51766. M2.push({ segments: _3.segments, sortKey: 0, state: K2 });
  51767. }
  51768. b2 && M2.sort((e2, t3) => e2.sortKey - t3.sortKey);
  51769. for (const e2 of M2) {
  51770. const i4 = e2.state;
  51771. if (t2.terrain && t2.terrain.setupElevationDraw(i4.tile, i4.program, { useDepthForOcclusion: !C2, labelPlaneMatrixInv: i4.labelPlaneMatrixInv }), d2.activeTexture.set(p2.TEXTURE0), i4.atlasTexture.bind(i4.atlasInterpolation, p2.CLAMP_TO_EDGE), i4.atlasTextureIcon && (d2.activeTexture.set(p2.TEXTURE1), i4.atlasTextureIcon && i4.atlasTextureIcon.bind(i4.atlasInterpolationIcon, p2.CLAMP_TO_EDGE)), i4.isSDF) {
  51772. const r3 = i4.uniformValues;
  51773. i4.hasHalo && (r3.u_is_halo = 1, ao(i4.buffers, e2.segments, o2, t2, i4.program, w2, _2, u2, r3)), r3.u_is_halo = 0;
  51774. }
  51775. ao(i4.buffers, e2.segments, o2, t2, i4.program, w2, _2, u2, i4.uniformValues);
  51776. }
  51777. }
  51778. function ao(t2, i3, o2, r2, n2, a2, s2, l2, c2) {
  51779. const h2 = r2.context;
  51780. n2.draw(h2, h2.gl.TRIANGLES, a2, s2, l2, e.CullFaceMode.disabled, c2, o2.id, t2.layoutVertexBuffer, t2.indexBuffer, i3, o2.paint, r2.transform.zoom, t2.programConfigurations.get(o2.id), t2.dynamicLayoutVertexBuffer, t2.opacityVertexBuffer);
  51781. }
  51782. function so(t2, i3, o2, r2, n2, a2, s2) {
  51783. const l2 = t2.context.gl, c2 = o2.paint.get("fill-pattern"), h2 = c2 && c2.constantOr(1), _2 = o2.getCrossfadeParameters();
  51784. let u2, d2, p2, m2, f2;
  51785. s2 ? (d2 = h2 && !o2.getPaintProperty("fill-outline-color") ? "fillOutlinePattern" : "fillOutline", u2 = l2.LINES) : (d2 = h2 ? "fillPattern" : "fill", u2 = l2.TRIANGLES);
  51786. for (const g2 of r2) {
  51787. const r3 = i3.getTile(g2);
  51788. if (h2 && !r3.patternsLoaded())
  51789. continue;
  51790. const v2 = r3.getBucket(o2);
  51791. if (!v2)
  51792. continue;
  51793. t2.prepareDrawTile();
  51794. const x2 = v2.programConfigurations.get(o2.id), y2 = t2.useProgram(d2, x2);
  51795. h2 && (t2.context.activeTexture.set(l2.TEXTURE0), r3.imageAtlasTexture.bind(l2.LINEAR, l2.CLAMP_TO_EDGE), x2.updatePaintBuffers(_2));
  51796. const b2 = c2.constantOr(null);
  51797. if (b2 && r3.imageAtlas) {
  51798. const e2 = r3.imageAtlas, t3 = e2.patternPositions[b2.to.toString()], i4 = e2.patternPositions[b2.from.toString()];
  51799. t3 && i4 && x2.setConstantPatternPositions(t3, i4);
  51800. }
  51801. const w2 = t2.translatePosMatrix(g2.projMatrix, r3, o2.paint.get("fill-translate"), o2.paint.get("fill-translate-anchor"));
  51802. if (s2) {
  51803. m2 = v2.indexBuffer2, f2 = v2.segments2;
  51804. const e2 = t2.terrain && t2.terrain.renderingToTexture ? t2.terrain.drapeBufferSize : [l2.drawingBufferWidth, l2.drawingBufferHeight];
  51805. p2 = "fillOutlinePattern" === d2 && h2 ? Pi(w2, t2, _2, r3, e2) : Di(w2, e2);
  51806. } else
  51807. m2 = v2.indexBuffer, f2 = v2.segments, p2 = h2 ? zi(w2, t2, _2, r3) : Si(w2);
  51808. t2.prepareDrawProgram(t2.context, y2, g2.toUnwrapped()), y2.draw(t2.context, u2, n2, t2.stencilModeForClipping(g2), a2, e.CullFaceMode.disabled, p2, o2.id, v2.layoutVertexBuffer, m2, f2, o2.paint, t2.transform.zoom, x2);
  51809. }
  51810. }
  51811. function lo(t2, i3, o2, r2, n2, a2, s2) {
  51812. const l2 = t2.context, c2 = l2.gl, h2 = t2.transform, _2 = o2.paint.get("fill-extrusion-pattern"), u2 = _2.constantOr(1), d2 = o2.getCrossfadeParameters(), p2 = o2.paint.get("fill-extrusion-opacity"), m2 = function(t3) {
  51813. if ("globe" !== t3.projection.name)
  51814. return 0;
  51815. const i4 = Math.PI / 32, o3 = Math.tan(i4), r3 = e.earthRadius;
  51816. return r3 * Math.sqrt(1 + 2 * o3 * o3) - r3;
  51817. }(h2), f2 = "globe" === h2.projection.name, g2 = f2 ? e.globeToMercatorTransition(h2.zoom) : 0, v2 = [e.mercatorXfromLng(h2.center.lng), e.mercatorYfromLat(h2.center.lat)], x2 = [];
  51818. f2 && x2.push("PROJECTION_GLOBE_VIEW");
  51819. for (const y2 of r2) {
  51820. const r3 = i3.getTile(y2), b2 = r3.getBucket(o2);
  51821. if (!b2 || b2.projection !== h2.projection.name)
  51822. continue;
  51823. const w2 = b2.programConfigurations.get(o2.id), T2 = t2.useProgram(u2 ? "fillExtrusionPattern" : "fillExtrusion", w2, x2);
  51824. if (t2.terrain) {
  51825. const e2 = t2.terrain;
  51826. if (t2.style.terrainSetForDrapingOnly())
  51827. e2.setupElevationDraw(r3, T2, { useMeterToDem: true });
  51828. else {
  51829. if (!b2.enableTerrain)
  51830. continue;
  51831. if (e2.setupElevationDraw(r3, T2, { useMeterToDem: true }), co(l2, i3, y2, b2, o2, e2), !b2.centroidVertexBuffer) {
  51832. const e3 = T2.attributes.a_centroid_pos;
  51833. void 0 !== e3 && c2.vertexAttrib2f(e3, 0, 0);
  51834. }
  51835. }
  51836. }
  51837. u2 && (t2.context.activeTexture.set(c2.TEXTURE0), r3.imageAtlasTexture.bind(c2.LINEAR, c2.CLAMP_TO_EDGE), w2.updatePaintBuffers(d2));
  51838. const E2 = _2.constantOr(null);
  51839. if (E2 && r3.imageAtlas) {
  51840. const e2 = r3.imageAtlas, t3 = e2.patternPositions[E2.to.toString()], i4 = e2.patternPositions[E2.from.toString()];
  51841. t3 && i4 && w2.setConstantPatternPositions(t3, i4);
  51842. }
  51843. const C2 = t2.translatePosMatrix(y2.projMatrix, r3, o2.paint.get("fill-extrusion-translate"), o2.paint.get("fill-extrusion-translate-anchor")), I2 = h2.projection.createInversionMatrix(h2, y2.canonical), M2 = o2.paint.get("fill-extrusion-vertical-gradient"), S2 = u2 ? Mi(C2, t2, M2, p2, y2, d2, r3, m2, g2, v2, I2) : Ii(C2, t2, M2, p2, y2, m2, g2, v2, I2);
  51844. t2.prepareDrawProgram(l2, T2, y2.toUnwrapped()), T2.draw(l2, l2.gl.TRIANGLES, n2, a2, s2, e.CullFaceMode.backCCW, S2, o2.id, b2.layoutVertexBuffer, b2.indexBuffer, b2.segments, o2.paint, t2.transform.zoom, w2, t2.terrain ? b2.centroidVertexBuffer : null, f2 ? b2.layoutVertexExtBuffer : null);
  51845. }
  51846. }
  51847. function co(t2, i3, o2, r2, n2, a2) {
  51848. const s2 = [(t3) => {
  51849. let i4 = t3.canonical.x - 1, o3 = t3.wrap;
  51850. return i4 < 0 && (i4 = (1 << t3.canonical.z) - 1, o3--), new e.OverscaledTileID(t3.overscaledZ, o3, t3.canonical.z, i4, t3.canonical.y);
  51851. }, (t3) => {
  51852. let i4 = t3.canonical.x + 1, o3 = t3.wrap;
  51853. return i4 === 1 << t3.canonical.z && (i4 = 0, o3++), new e.OverscaledTileID(t3.overscaledZ, o3, t3.canonical.z, i4, t3.canonical.y);
  51854. }, (t3) => new e.OverscaledTileID(t3.overscaledZ, t3.wrap, t3.canonical.z, t3.canonical.x, (0 === t3.canonical.y ? 1 << t3.canonical.z : t3.canonical.y) - 1), (t3) => new e.OverscaledTileID(t3.overscaledZ, t3.wrap, t3.canonical.z, t3.canonical.x, t3.canonical.y === (1 << t3.canonical.z) - 1 ? 0 : t3.canonical.y + 1)], l2 = (e2) => {
  51855. const t3 = i3.getSource().minzoom, o3 = (e3) => {
  51856. const t4 = i3.getTileByID(e3);
  51857. if (t4 && t4.hasData())
  51858. return t4.getBucket(n2);
  51859. }, r3 = [0, -1, 1];
  51860. for (const i4 of r3) {
  51861. if (e2.overscaledZ + i4 < t3)
  51862. continue;
  51863. const r4 = o3(e2.calculateScaledKey(e2.overscaledZ + i4));
  51864. if (r4)
  51865. return r4;
  51866. }
  51867. }, c2 = [0, 0, 0], h2 = (t3, i4) => (c2[0] = Math.min(t3.min.y, i4.min.y), c2[1] = Math.max(t3.max.y, i4.max.y), c2[2] = e.EXTENT - i4.min.x > t3.max.x ? i4.min.x - e.EXTENT : t3.max.x, c2), _2 = (t3, i4) => (c2[0] = Math.min(t3.min.x, i4.min.x), c2[1] = Math.max(t3.max.x, i4.max.x), c2[2] = e.EXTENT - i4.min.y > t3.max.y ? i4.min.y - e.EXTENT : t3.max.y, c2), u2 = [(e2, t3) => h2(e2, t3), (e2, t3) => h2(t3, e2), (e2, t3) => _2(e2, t3), (e2, t3) => _2(t3, e2)], d2 = new e.pointGeometry(0, 0);
  51868. let p2, m2, f2;
  51869. const g2 = (t3, i4, r3, n3, s3) => {
  51870. const l3 = [[n3 ? r3 : t3, n3 ? t3 : r3, 0], [n3 ? r3 : i4, n3 ? i4 : r3, 0]], c3 = s3 < 0 ? e.EXTENT + s3 : s3, h3 = [n3 ? c3 : (t3 + i4) / 2, n3 ? (t3 + i4) / 2 : c3, 0];
  51871. return 0 === r3 && s3 < 0 || 0 !== r3 && s3 > 0 ? a2.getForTilePoints(f2, [h3], true, m2) : l3.push(h3), a2.getForTilePoints(o2, l3, true, p2), Math.max(l3[0][2], l3[1][2], h3[2]) / a2.exaggeration();
  51872. };
  51873. for (let t3 = 0; t3 < 4; t3++) {
  51874. const i4 = (t3 < 2 ? 1 : 5) - t3, n3 = r2.borders[t3];
  51875. if (0 === n3.length)
  51876. continue;
  51877. const c3 = f2 = s2[t3](o2), h3 = l2(c3);
  51878. if (!(h3 && h3 instanceof e.FillExtrusionBucket && h3.enableTerrain))
  51879. continue;
  51880. if (r2.borderDoneWithNeighborZ[t3] === h3.canonical.z && h3.borderDoneWithNeighborZ[i4] === r2.canonical.z)
  51881. continue;
  51882. if (m2 = a2.findDEMTileFor(c3), !m2 || !m2.dem)
  51883. continue;
  51884. if (!p2) {
  51885. const e2 = a2.findDEMTileFor(o2);
  51886. if (!e2 || !e2.dem)
  51887. return;
  51888. p2 = e2;
  51889. }
  51890. const _3 = h3.borders[i4];
  51891. let v2 = 0;
  51892. const x2 = h3.borderDoneWithNeighborZ[i4] !== r2.canonical.z;
  51893. if (r2.canonical.z === h3.canonical.z) {
  51894. for (let o3 = 0; o3 < n3.length; o3++) {
  51895. const a3 = r2.featuresOnBorder[n3[o3]], s3 = a3.borders[t3];
  51896. let l3;
  51897. for (; v2 < _3.length && (l3 = h3.featuresOnBorder[_3[v2]], !(l3.borders[i4][1] > s3[0] + 3)); )
  51898. x2 && h3.encodeCentroid(void 0, l3, false), v2++;
  51899. if (l3 && v2 < _3.length) {
  51900. const o4 = v2;
  51901. let n4 = 0;
  51902. for (; !(l3.borders[i4][0] > s3[1] - 3) && (n4++, ++v2 !== _3.length); )
  51903. l3 = h3.featuresOnBorder[_3[v2]];
  51904. if (l3 = h3.featuresOnBorder[_3[o4]], a3.intersectsCount() > 1 || l3.intersectsCount() > 1 || 1 !== n4) {
  51905. 1 !== n4 && (v2 = o4), r2.encodeCentroid(void 0, a3, false), x2 && h3.encodeCentroid(void 0, l3, false);
  51906. continue;
  51907. }
  51908. const c4 = u2[t3](a3, l3), p3 = t3 % 2 ? e.EXTENT - 1 : 0;
  51909. d2.x = g2(c4[0], Math.min(e.EXTENT - 1, c4[1]), p3, t3 < 2, c4[2]), d2.y = 0, r2.encodeCentroid(d2, a3, false), x2 && h3.encodeCentroid(d2, l3, false);
  51910. } else
  51911. r2.encodeCentroid(void 0, a3, false);
  51912. }
  51913. r2.borderDoneWithNeighborZ[t3] = h3.canonical.z, r2.needsCentroidUpdate = true, x2 && (h3.borderDoneWithNeighborZ[i4] = r2.canonical.z, h3.needsCentroidUpdate = true);
  51914. } else {
  51915. for (const e2 of n3)
  51916. r2.encodeCentroid(void 0, r2.featuresOnBorder[e2], false);
  51917. if (x2) {
  51918. for (const e2 of _3)
  51919. h3.encodeCentroid(void 0, h3.featuresOnBorder[e2], false);
  51920. h3.borderDoneWithNeighborZ[i4] = r2.canonical.z, h3.needsCentroidUpdate = true;
  51921. }
  51922. r2.borderDoneWithNeighborZ[t3] = h3.canonical.z, r2.needsCentroidUpdate = true;
  51923. }
  51924. }
  51925. (r2.needsCentroidUpdate || !r2.centroidVertexBuffer && 0 !== r2.centroidVertexArray.length) && r2.uploadCentroid(t2);
  51926. }
  51927. const ho = new e.Color(1, 0, 0, 1), _o = new e.Color(0, 1, 0, 1), uo = new e.Color(0, 0, 1, 1), po = new e.Color(1, 0, 1, 1), mo = new e.Color(0, 1, 1, 1);
  51928. function fo(e2, t2, i3, o2) {
  51929. vo(e2, 0, t2 + i3 / 2, e2.transform.width, i3, o2);
  51930. }
  51931. function go(e2, t2, i3, o2) {
  51932. vo(e2, t2 - i3 / 2, 0, i3, e2.transform.height, o2);
  51933. }
  51934. function vo(t2, i3, o2, r2, n2, a2) {
  51935. const s2 = t2.context, l2 = s2.gl;
  51936. l2.enable(l2.SCISSOR_TEST), l2.scissor(i3 * e.exported.devicePixelRatio, o2 * e.exported.devicePixelRatio, r2 * e.exported.devicePixelRatio, n2 * e.exported.devicePixelRatio), s2.clear({ color: a2 }), l2.disable(l2.SCISSOR_TEST);
  51937. }
  51938. function xo(t2, i3, o2) {
  51939. const r2 = t2.context, n2 = r2.gl, a2 = "globe" === t2.transform.projection.name, s2 = o2.projMatrix, l2 = t2.useProgram("debug", null, a2 ? ["PROJECTION_GLOBE_VIEW"] : null), c2 = i3.getTileByID(o2.key);
  51940. t2.terrain && t2.terrain.setupElevationDraw(c2, l2);
  51941. const h2 = e.DepthMode.disabled, _2 = e.StencilMode.disabled, u2 = t2.colorModeForRenderPass(), d2 = "$debug";
  51942. r2.activeTexture.set(n2.TEXTURE0), t2.emptyTexture.bind(n2.LINEAR, n2.CLAMP_TO_EDGE), a2 ? c2._makeGlobeTileDebugBuffers(t2.context, t2.transform.projection) : c2._makeDebugTileBoundsBuffers(t2.context, t2.transform.projection);
  51943. const p2 = c2._tileDebugBuffer || t2.debugBuffer, m2 = c2._tileDebugIndexBuffer || t2.debugIndexBuffer, f2 = c2._tileDebugSegments || t2.debugSegments;
  51944. l2.draw(r2, n2.LINE_STRIP, h2, _2, u2, e.CullFaceMode.disabled, Oi(s2, e.Color.red), d2, p2, m2, f2, null, null, null, c2._globeTileDebugBorderBuffer);
  51945. const g2 = c2.latestRawTileData, v2 = Math.floor((g2 && g2.byteLength || 0) / 1024), x2 = i3.getTile(o2).tileSize, y2 = 512 / Math.min(x2, 512) * (o2.overscaledZ / t2.transform.zoom) * 0.5;
  51946. let b2 = o2.canonical.toString();
  51947. o2.overscaledZ !== o2.canonical.z && (b2 += ` => ${o2.overscaledZ}`), function(e2, t3) {
  51948. e2.initDebugOverlayCanvas();
  51949. const i4 = e2.debugOverlayCanvas, o3 = e2.context.gl, r3 = e2.debugOverlayCanvas.getContext("2d");
  51950. r3.clearRect(0, 0, i4.width, i4.height), r3.shadowColor = "white", r3.shadowBlur = 2, r3.lineWidth = 1.5, r3.strokeStyle = "white", r3.textBaseline = "top", r3.font = "bold 36px Open Sans, sans-serif", r3.fillText(t3, 5, 5), r3.strokeText(t3, 5, 5), e2.debugOverlayTexture.update(i4), e2.debugOverlayTexture.bind(o3.LINEAR, o3.CLAMP_TO_EDGE);
  51951. }(t2, `${b2} ${v2}kb`);
  51952. const w2 = c2._tileDebugTextBuffer || t2.debugBuffer, T2 = c2._tileDebugTextIndexBuffer || t2.quadTriangleIndexBuffer, E2 = c2._tileDebugTextSegments || t2.debugSegments;
  51953. l2.draw(r2, n2.TRIANGLES, h2, _2, e.ColorMode.alphaBlended, e.CullFaceMode.disabled, Oi(s2, e.Color.transparent, y2), d2, w2, T2, E2, null, null, null, c2._globeTileDebugTextBuffer);
  51954. }
  51955. const yo = e.createLayout([{ name: "a_pos_3f", components: 3, type: "Float32" }]), { members: bo } = yo;
  51956. function wo(e2, t2, i3, o2) {
  51957. e2.emplaceBack(t2, i3, o2);
  51958. }
  51959. class To {
  51960. constructor(t2) {
  51961. this.vertexArray = new e.StructArrayLayout3f12(), this.indices = new e.StructArrayLayout3ui6(), wo(this.vertexArray, -1, -1, 1), wo(this.vertexArray, 1, -1, 1), wo(this.vertexArray, -1, 1, 1), wo(this.vertexArray, 1, 1, 1), wo(this.vertexArray, -1, -1, -1), wo(this.vertexArray, 1, -1, -1), wo(this.vertexArray, -1, 1, -1), wo(this.vertexArray, 1, 1, -1), this.indices.emplaceBack(5, 1, 3), this.indices.emplaceBack(3, 7, 5), this.indices.emplaceBack(6, 2, 0), this.indices.emplaceBack(0, 4, 6), this.indices.emplaceBack(2, 6, 7), this.indices.emplaceBack(7, 3, 2), this.indices.emplaceBack(5, 4, 0), this.indices.emplaceBack(0, 1, 5), this.indices.emplaceBack(0, 2, 3), this.indices.emplaceBack(3, 1, 0), this.indices.emplaceBack(7, 6, 4), this.indices.emplaceBack(4, 5, 7), this.vertexBuffer = t2.createVertexBuffer(this.vertexArray, bo), this.indexBuffer = t2.createIndexBuffer(this.indices), this.segment = e.SegmentVector.simpleSegment(0, 0, 36, 12);
  51962. }
  51963. }
  51964. function Eo(t2, i3, o2, r2, n2, a2) {
  51965. const s2 = t2.gl, l2 = i3.paint.get("sky-atmosphere-color"), c2 = i3.paint.get("sky-atmosphere-halo-color"), h2 = i3.paint.get("sky-atmosphere-sun-intensity"), _2 = ((e2, t3, i4, o3, r3) => ({ u_matrix_3f: e2, u_sun_direction: t3, u_sun_intensity: i4, u_color_tint_r: [o3.r, o3.g, o3.b, o3.a], u_color_tint_m: [r3.r, r3.g, r3.b, r3.a], u_luminance: 5e-5 }))(e.fromMat4(e.create$1(), r2), n2, h2, l2, c2);
  51966. s2.framebufferTexture2D(s2.FRAMEBUFFER, s2.COLOR_ATTACHMENT0, s2.TEXTURE_CUBE_MAP_POSITIVE_X + a2, i3.skyboxTexture, 0), o2.draw(t2, s2.TRIANGLES, e.DepthMode.disabled, e.StencilMode.disabled, e.ColorMode.unblended, e.CullFaceMode.frontCW, _2, "skyboxCapture", i3.skyboxGeometry.vertexBuffer, i3.skyboxGeometry.indexBuffer, i3.skyboxGeometry.segment);
  51967. }
  51968. function Co(t2, i3) {
  51969. return e.transformMat4(t2, t2, i3);
  51970. }
  51971. const Io = { symbol: function(t2, i3, o2, r2, n2) {
  51972. if ("translucent" !== t2.renderPass)
  51973. return;
  51974. const a2 = e.StencilMode.disabled, s2 = t2.colorModeForRenderPass();
  51975. o2.layout.get("text-variable-anchor") && function(t3, i4, o3, r3, n3, a3, s3) {
  51976. const l2 = i4.transform, c2 = "map" === n3, h2 = "map" === a3;
  51977. for (const n4 of t3) {
  51978. const t4 = r3.getTile(n4), a4 = t4.getBucket(o3);
  51979. if (!a4 || a4.projection !== l2.projection.name || !a4.text || !a4.text.segments.get().length)
  51980. continue;
  51981. const _2 = e.evaluateSizeForZoom(a4.textSizeData, l2.zoom), u2 = i4.transform.calculatePixelsToTileUnitsMatrix(t4), d2 = Qe(n4.projMatrix, t4.tileID.canonical, h2, c2, i4.transform, u2), p2 = "none" !== o3.layout.get("icon-text-fit") && a4.hasIconData();
  51982. if (_2) {
  51983. const i5 = Math.pow(2, l2.zoom - t4.tileID.overscaledZ);
  51984. oo(a4, c2, h2, s3, e.symbolSize, l2, d2, n4, i5, _2, p2, l2.projection);
  51985. }
  51986. }
  51987. }(r2, t2, o2, i3, o2.layout.get("text-rotation-alignment"), o2.layout.get("text-pitch-alignment"), n2), 0 !== o2.paint.get("icon-opacity").constantOr(1) && no(t2, i3, o2, r2, false, o2.paint.get("icon-translate"), o2.paint.get("icon-translate-anchor"), o2.layout.get("icon-rotation-alignment"), o2.layout.get("icon-pitch-alignment"), o2.layout.get("icon-keep-upright"), a2, s2), 0 !== o2.paint.get("text-opacity").constantOr(1) && no(t2, i3, o2, r2, true, o2.paint.get("text-translate"), o2.paint.get("text-translate-anchor"), o2.layout.get("text-rotation-alignment"), o2.layout.get("text-pitch-alignment"), o2.layout.get("text-keep-upright"), a2, s2), i3.map.showCollisionBoxes && (eo(t2, i3, o2, r2, o2.paint.get("text-translate"), o2.paint.get("text-translate-anchor"), true), eo(t2, i3, o2, r2, o2.paint.get("icon-translate"), o2.paint.get("icon-translate-anchor"), false));
  51988. }, circle: function(t2, i3, o2, r2) {
  51989. if ("translucent" !== t2.renderPass)
  51990. return;
  51991. const n2 = o2.paint.get("circle-opacity"), a2 = o2.paint.get("circle-stroke-width"), s2 = o2.paint.get("circle-stroke-opacity"), l2 = void 0 !== o2.layout.get("circle-sort-key").constantOr(1);
  51992. if (0 === n2.constantOr(1) && (0 === a2.constantOr(1) || 0 === s2.constantOr(1)))
  51993. return;
  51994. const c2 = t2.context, h2 = c2.gl, _2 = t2.transform, u2 = t2.depthModeForSublayer(0, e.DepthMode.ReadOnly), d2 = e.StencilMode.disabled, p2 = t2.colorModeForRenderPass(), m2 = "globe" === _2.projection.name, f2 = [e.mercatorXfromLng(_2.center.lng), e.mercatorYfromLat(_2.center.lat)], g2 = [];
  51995. for (let n3 = 0; n3 < r2.length; n3++) {
  51996. const a3 = r2[n3], s3 = i3.getTile(a3), c3 = s3.getBucket(o2);
  51997. if (!c3)
  51998. continue;
  51999. const h3 = c3.programConfigurations.get(o2.id), u3 = Ri(o2);
  52000. m2 && u3.push("PROJECTION_GLOBE_VIEW");
  52001. const d3 = t2.useProgram("circle", h3, u3), p3 = c3.layoutVertexBuffer, v3 = c3.globeExtVertexBuffer, x2 = c3.indexBuffer, y2 = _2.projection.createInversionMatrix(_2, a3.canonical), b2 = { programConfiguration: h3, program: d3, layoutVertexBuffer: p3, globeExtVertexBuffer: v3, indexBuffer: x2, uniformValues: Li(t2, a3, s3, y2, f2, o2), tile: s3 };
  52002. if (l2) {
  52003. const t3 = c3.segments.get();
  52004. for (const i4 of t3)
  52005. g2.push({ segments: new e.SegmentVector([i4]), sortKey: i4.sortKey, state: b2 });
  52006. } else
  52007. g2.push({ segments: c3.segments, sortKey: 0, state: b2 });
  52008. }
  52009. l2 && g2.sort((e2, t3) => e2.sortKey - t3.sortKey);
  52010. const v2 = { useDepthForOcclusion: !m2 };
  52011. for (const i4 of g2) {
  52012. const { programConfiguration: r3, program: n3, layoutVertexBuffer: a3, globeExtVertexBuffer: s3, indexBuffer: l3, uniformValues: f3, tile: g3 } = i4.state, x2 = i4.segments;
  52013. t2.terrain && t2.terrain.setupElevationDraw(g3, n3, v2), t2.prepareDrawProgram(c2, n3, g3.tileID.toUnwrapped()), n3.draw(c2, h2.TRIANGLES, u2, d2, p2, e.CullFaceMode.disabled, f3, o2.id, a3, l3, x2, o2.paint, _2.zoom, r3, m2 ? s3 : null);
  52014. }
  52015. }, heatmap: function(t2, i3, o2, r2) {
  52016. if (0 !== o2.paint.get("heatmap-opacity"))
  52017. if ("offscreen" === t2.renderPass) {
  52018. const n2 = t2.context, a2 = n2.gl, s2 = e.StencilMode.disabled, l2 = new e.ColorMode([a2.ONE, a2.ONE], e.Color.transparent, [true, true, true, true]);
  52019. !function(e2, t3, i4) {
  52020. const o3 = e2.gl;
  52021. e2.activeTexture.set(o3.TEXTURE1), e2.viewport.set([0, 0, t3.width / 4, t3.height / 4]);
  52022. let r3 = i4.heatmapFbo;
  52023. if (r3)
  52024. o3.bindTexture(o3.TEXTURE_2D, r3.colorAttachment.get()), e2.bindFramebuffer.set(r3.framebuffer);
  52025. else {
  52026. const n3 = o3.createTexture();
  52027. o3.bindTexture(o3.TEXTURE_2D, n3), o3.texParameteri(o3.TEXTURE_2D, o3.TEXTURE_WRAP_S, o3.CLAMP_TO_EDGE), o3.texParameteri(o3.TEXTURE_2D, o3.TEXTURE_WRAP_T, o3.CLAMP_TO_EDGE), o3.texParameteri(o3.TEXTURE_2D, o3.TEXTURE_MIN_FILTER, o3.LINEAR), o3.texParameteri(o3.TEXTURE_2D, o3.TEXTURE_MAG_FILTER, o3.LINEAR), r3 = i4.heatmapFbo = e2.createFramebuffer(t3.width / 4, t3.height / 4, false), function(e3, t4, i5, o4) {
  52028. const r4 = e3.gl;
  52029. r4.texImage2D(r4.TEXTURE_2D, 0, r4.RGBA, t4.width / 4, t4.height / 4, 0, r4.RGBA, e3.extRenderToTextureHalfFloat ? e3.extTextureHalfFloat.HALF_FLOAT_OES : r4.UNSIGNED_BYTE, null), o4.colorAttachment.set(i5);
  52030. }(e2, t3, n3, r3);
  52031. }
  52032. }(n2, t2, o2), n2.clear({ color: e.Color.transparent });
  52033. const c2 = t2.transform, h2 = "globe" === c2.projection.name, _2 = h2 ? ["PROJECTION_GLOBE_VIEW"] : null, u2 = [e.mercatorXfromLng(c2.center.lng), e.mercatorYfromLat(c2.center.lat)];
  52034. for (let d2 = 0; d2 < r2.length; d2++) {
  52035. const p2 = r2[d2];
  52036. if (i3.hasRenderableParent(p2))
  52037. continue;
  52038. const m2 = i3.getTile(p2), f2 = m2.getBucket(o2);
  52039. if (!f2)
  52040. continue;
  52041. const g2 = f2.programConfigurations.get(o2.id), v2 = t2.useProgram("heatmap", g2, _2), { zoom: x2 } = t2.transform;
  52042. t2.terrain && t2.terrain.setupElevationDraw(m2, v2), t2.prepareDrawProgram(n2, v2, p2.toUnwrapped());
  52043. const y2 = c2.projection.createInversionMatrix(c2, p2.canonical);
  52044. v2.draw(n2, a2.TRIANGLES, e.DepthMode.disabled, s2, l2, e.CullFaceMode.disabled, Fi(t2, p2, m2, y2, u2, x2, o2.paint.get("heatmap-intensity")), o2.id, f2.layoutVertexBuffer, f2.indexBuffer, f2.segments, o2.paint, t2.transform.zoom, g2, h2 ? f2.globeExtVertexBuffer : null);
  52045. }
  52046. n2.viewport.set([0, 0, t2.width, t2.height]);
  52047. } else
  52048. "translucent" === t2.renderPass && (t2.context.setColorMode(t2.colorModeForRenderPass()), function(t3, i4) {
  52049. const o3 = t3.context, r3 = o3.gl, n2 = i4.heatmapFbo;
  52050. if (!n2)
  52051. return;
  52052. o3.activeTexture.set(r3.TEXTURE0), r3.bindTexture(r3.TEXTURE_2D, n2.colorAttachment.get()), o3.activeTexture.set(r3.TEXTURE1);
  52053. let a2 = i4.colorRampTexture;
  52054. a2 || (a2 = i4.colorRampTexture = new e.Texture(o3, i4.colorRamp, r3.RGBA)), a2.bind(r3.LINEAR, r3.CLAMP_TO_EDGE), t3.useProgram("heatmapTexture").draw(o3, r3.TRIANGLES, e.DepthMode.disabled, e.StencilMode.disabled, t3.colorModeForRenderPass(), e.CullFaceMode.disabled, ((e2, t4, i5, o4) => ({ u_image: 0, u_color_ramp: 1, u_opacity: t4.paint.get("heatmap-opacity") }))(0, i4), i4.id, t3.viewportBuffer, t3.quadTriangleIndexBuffer, t3.viewportSegments, i4.paint, t3.transform.zoom);
  52055. }(t2, o2));
  52056. }, line: function(t2, i3, o2, r2) {
  52057. if ("translucent" !== t2.renderPass)
  52058. return;
  52059. const n2 = o2.paint.get("line-opacity"), a2 = o2.paint.get("line-width");
  52060. if (0 === n2.constantOr(1) || 0 === a2.constantOr(1))
  52061. return;
  52062. const s2 = t2.depthModeForSublayer(0, e.DepthMode.ReadOnly), l2 = t2.colorModeForRenderPass(), c2 = t2.terrain && t2.terrain.renderingToTexture ? 1 : e.exported.devicePixelRatio, h2 = o2.paint.get("line-dasharray"), _2 = h2.constantOr(1), u2 = o2.layout.get("line-cap"), d2 = o2.paint.get("line-pattern"), p2 = d2.constantOr(1), m2 = o2.paint.get("line-gradient"), f2 = o2.getCrossfadeParameters(), g2 = p2 ? "linePattern" : "line", v2 = t2.context, x2 = v2.gl, y2 = ((e2) => {
  52063. const t3 = [];
  52064. Zi(e2) && t3.push("RENDER_LINE_DASH"), e2.paint.get("line-gradient") && t3.push("RENDER_LINE_GRADIENT");
  52065. const i4 = e2.paint.get("line-pattern").constantOr(1), o3 = 1 !== e2.paint.get("line-opacity").constantOr(1);
  52066. return !i4 && o3 && t3.push("RENDER_LINE_ALPHA_DISCARD"), t3;
  52067. })(o2);
  52068. let b2 = y2.includes("RENDER_LINE_ALPHA_DISCARD");
  52069. t2.terrain && t2.terrain.clipOrMaskOverlapStencilType() && (b2 = false);
  52070. for (const n3 of r2) {
  52071. const r3 = i3.getTile(n3);
  52072. if (p2 && !r3.patternsLoaded())
  52073. continue;
  52074. const a3 = r3.getBucket(o2);
  52075. if (!a3)
  52076. continue;
  52077. t2.prepareDrawTile();
  52078. const w2 = a3.programConfigurations.get(o2.id), T2 = t2.useProgram(g2, w2, y2), E2 = d2.constantOr(null);
  52079. if (E2 && r3.imageAtlas) {
  52080. const e2 = r3.imageAtlas, t3 = e2.patternPositions[E2.to.toString()], i4 = e2.patternPositions[E2.from.toString()];
  52081. t3 && i4 && w2.setConstantPatternPositions(t3, i4);
  52082. }
  52083. const C2 = h2.constantOr(null), I2 = u2.constantOr(null);
  52084. if (!p2 && C2 && I2 && r3.lineAtlas) {
  52085. const e2 = r3.lineAtlas, t3 = e2.getDash(C2.to, I2), i4 = e2.getDash(C2.from, I2);
  52086. t3 && i4 && w2.setConstantPatternPositions(t3, i4);
  52087. }
  52088. const M2 = t2.terrain ? n3.projMatrix : null, S2 = p2 ? Ni(t2, r3, o2, f2, M2, c2) : Ui(t2, r3, o2, f2, M2, a3.lineClipsArray.length, c2);
  52089. if (m2) {
  52090. const r4 = a3.gradients[o2.id];
  52091. let s3 = r4.texture;
  52092. if (o2.gradientVersion !== r4.version) {
  52093. let l3 = 256;
  52094. if (o2.stepInterpolant) {
  52095. const o3 = i3.getSource().maxzoom, r5 = n3.canonical.z === o3 ? Math.ceil(1 << t2.transform.maxZoom - n3.canonical.z) : 1;
  52096. l3 = e.clamp(e.nextPowerOfTwo(a3.maxLineLength / e.EXTENT * 1024 * r5), 256, v2.maxTextureSize);
  52097. }
  52098. r4.gradient = e.renderColorRamp({ expression: o2.gradientExpression(), evaluationKey: "lineProgress", resolution: l3, image: r4.gradient || void 0, clips: a3.lineClipsArray }), r4.texture ? r4.texture.update(r4.gradient) : r4.texture = new e.Texture(v2, r4.gradient, x2.RGBA), r4.version = o2.gradientVersion, s3 = r4.texture;
  52099. }
  52100. v2.activeTexture.set(x2.TEXTURE1), s3.bind(o2.stepInterpolant ? x2.NEAREST : x2.LINEAR, x2.CLAMP_TO_EDGE);
  52101. }
  52102. _2 && (v2.activeTexture.set(x2.TEXTURE0), r3.lineAtlasTexture.bind(x2.LINEAR, x2.REPEAT), w2.updatePaintBuffers(f2)), p2 && (v2.activeTexture.set(x2.TEXTURE0), r3.imageAtlasTexture.bind(x2.LINEAR, x2.CLAMP_TO_EDGE), w2.updatePaintBuffers(f2)), t2.prepareDrawProgram(v2, T2, n3.toUnwrapped());
  52103. const z2 = (i4) => {
  52104. T2.draw(v2, x2.TRIANGLES, s2, i4, l2, e.CullFaceMode.disabled, S2, o2.id, a3.layoutVertexBuffer, a3.indexBuffer, a3.segments, o2.paint, t2.transform.zoom, w2, a3.layoutVertexBuffer2);
  52105. };
  52106. if (b2) {
  52107. const i4 = t2.stencilModeForClipping(n3).ref;
  52108. 0 === i4 && t2.terrain && v2.clear({ stencil: 0 });
  52109. const o3 = { func: x2.EQUAL, mask: 255 };
  52110. S2.u_alpha_discard_threshold = 0.8, z2(new e.StencilMode(o3, i4, 255, x2.KEEP, x2.KEEP, x2.INVERT)), S2.u_alpha_discard_threshold = 0, z2(new e.StencilMode(o3, i4, 255, x2.KEEP, x2.KEEP, x2.KEEP));
  52111. } else
  52112. z2(t2.stencilModeForClipping(n3));
  52113. }
  52114. b2 && (t2.resetStencilClippingMasks(), t2.terrain && v2.clear({ stencil: 0 }));
  52115. }, fill: function(t2, i3, o2, r2) {
  52116. const n2 = o2.paint.get("fill-color"), a2 = o2.paint.get("fill-opacity");
  52117. if (0 === a2.constantOr(1))
  52118. return;
  52119. const s2 = t2.colorModeForRenderPass(), l2 = o2.paint.get("fill-pattern"), c2 = t2.opaquePassEnabledForLayer() && !l2.constantOr(1) && 1 === n2.constantOr(e.Color.transparent).a && 1 === a2.constantOr(0) ? "opaque" : "translucent";
  52120. if (t2.renderPass === c2) {
  52121. const n3 = t2.depthModeForSublayer(1, "opaque" === t2.renderPass ? e.DepthMode.ReadWrite : e.DepthMode.ReadOnly);
  52122. so(t2, i3, o2, r2, n3, s2, false);
  52123. }
  52124. if ("translucent" === t2.renderPass && o2.paint.get("fill-antialias")) {
  52125. const n3 = t2.depthModeForSublayer(o2.getPaintProperty("fill-outline-color") ? 2 : 0, e.DepthMode.ReadOnly);
  52126. so(t2, i3, o2, r2, n3, s2, true);
  52127. }
  52128. }, "fill-extrusion": function(t2, i3, o2, r2) {
  52129. const n2 = o2.paint.get("fill-extrusion-opacity");
  52130. if (0 !== n2 && "translucent" === t2.renderPass) {
  52131. const a2 = new e.DepthMode(t2.context.gl.LEQUAL, e.DepthMode.ReadWrite, t2.depthRangeFor3D);
  52132. if (1 !== n2 || o2.paint.get("fill-extrusion-pattern").constantOr(1))
  52133. lo(t2, i3, o2, r2, a2, e.StencilMode.disabled, e.ColorMode.disabled), lo(t2, i3, o2, r2, a2, t2.stencilModeFor3D(), t2.colorModeForRenderPass()), t2.resetStencilClippingMasks();
  52134. else {
  52135. const n3 = t2.colorModeForRenderPass();
  52136. lo(t2, i3, o2, r2, a2, e.StencilMode.disabled, n3);
  52137. }
  52138. }
  52139. }, hillshade: function(t2, i3, o2, r2) {
  52140. if ("offscreen" !== t2.renderPass && "translucent" !== t2.renderPass)
  52141. return;
  52142. const n2 = t2.context, a2 = t2.depthModeForSublayer(0, e.DepthMode.ReadOnly), s2 = t2.colorModeForRenderPass(), l2 = t2.terrain && t2.terrain.renderingToTexture, [c2, h2] = "translucent" !== t2.renderPass || l2 ? [{}, r2] : t2.stencilConfigForOverlap(r2);
  52143. for (const r3 of h2) {
  52144. const n3 = i3.getTile(r3);
  52145. if (n3.needsHillshadePrepare && "offscreen" === t2.renderPass)
  52146. si(t2, n3, o2, a2, e.StencilMode.disabled, s2);
  52147. else if ("translucent" === t2.renderPass) {
  52148. const e2 = l2 && t2.terrain ? t2.terrain.stencilModeForRTTOverlap(r3) : c2[r3.overscaledZ];
  52149. ni(t2, r3, n3, o2, a2, e2, s2);
  52150. }
  52151. }
  52152. n2.viewport.set([0, 0, t2.width, t2.height]), t2.resetStencilClippingMasks();
  52153. }, raster: function(t2, i3, o2, r2, n2, a2) {
  52154. if ("translucent" !== t2.renderPass)
  52155. return;
  52156. if (0 === o2.paint.get("raster-opacity"))
  52157. return;
  52158. if (!r2.length)
  52159. return;
  52160. const s2 = t2.context, l2 = s2.gl, c2 = i3.getSource(), h2 = t2.useProgram("raster"), _2 = t2.colorModeForRenderPass(), u2 = t2.terrain && t2.terrain.renderingToTexture, [d2, p2] = c2 instanceof Se || u2 ? [{}, r2] : t2.stencilConfigForOverlap(r2), m2 = p2[p2.length - 1].overscaledZ, f2 = !t2.options.moving;
  52161. for (const r3 of p2) {
  52162. const n3 = u2 ? e.DepthMode.disabled : t2.depthModeForSublayer(r3.overscaledZ - m2, 1 === o2.paint.get("raster-opacity") ? e.DepthMode.ReadWrite : e.DepthMode.ReadOnly, l2.LESS), p3 = r3.toUnwrapped(), g2 = i3.getTile(r3);
  52163. if (u2 && (!g2 || !g2.hasData()))
  52164. continue;
  52165. const v2 = u2 ? r3.projMatrix : t2.transform.calculateProjMatrix(p3, f2), x2 = t2.terrain && u2 ? t2.terrain.stencilModeForRTTOverlap(r3) : d2[r3.overscaledZ], y2 = a2 ? 0 : o2.paint.get("raster-fade-duration");
  52166. g2.registerFadeDuration(y2);
  52167. const b2 = i3.findLoadedParent(r3, 0), w2 = fi(g2, b2, i3, t2.transform, y2);
  52168. let T2, E2;
  52169. t2.terrain && t2.terrain.prepareDrawTile();
  52170. const C2 = "nearest" === o2.paint.get("raster-resampling") ? l2.NEAREST : l2.LINEAR;
  52171. s2.activeTexture.set(l2.TEXTURE0), g2.texture.bind(C2, l2.CLAMP_TO_EDGE), s2.activeTexture.set(l2.TEXTURE1), b2 ? (b2.texture.bind(C2, l2.CLAMP_TO_EDGE), T2 = Math.pow(2, b2.tileID.overscaledZ - g2.tileID.overscaledZ), E2 = [g2.tileID.canonical.x * T2 % 1, g2.tileID.canonical.y * T2 % 1]) : g2.texture.bind(C2, l2.CLAMP_TO_EDGE);
  52172. const I2 = Vi(v2, E2 || [0, 0], T2 || 1, w2, o2, c2 instanceof Se ? c2.perspectiveTransform : [0, 0]);
  52173. if (t2.prepareDrawProgram(s2, h2, p3), c2 instanceof Se)
  52174. c2.boundsBuffer && c2.boundsSegments && h2.draw(s2, l2.TRIANGLES, n3, e.StencilMode.disabled, _2, e.CullFaceMode.disabled, I2, o2.id, c2.boundsBuffer, t2.quadTriangleIndexBuffer, c2.boundsSegments);
  52175. else {
  52176. const { tileBoundsBuffer: i4, tileBoundsIndexBuffer: r4, tileBoundsSegments: a3 } = t2.getTileBoundsBuffers(g2);
  52177. h2.draw(s2, l2.TRIANGLES, n3, x2, _2, e.CullFaceMode.disabled, I2, o2.id, i4, r4, a3);
  52178. }
  52179. }
  52180. t2.resetStencilClippingMasks();
  52181. }, background: function(t2, i3, o2, r2) {
  52182. const n2 = o2.paint.get("background-color"), a2 = o2.paint.get("background-opacity");
  52183. if (0 === a2)
  52184. return;
  52185. const s2 = t2.context, l2 = s2.gl, c2 = t2.transform, h2 = c2.tileSize, _2 = o2.paint.get("background-pattern");
  52186. if (t2.isPatternMissing(_2))
  52187. return;
  52188. const u2 = !_2 && 1 === n2.a && 1 === a2 && t2.opaquePassEnabledForLayer() ? "opaque" : "translucent";
  52189. if (t2.renderPass !== u2)
  52190. return;
  52191. const d2 = e.StencilMode.disabled, p2 = t2.depthModeForSublayer(0, "opaque" === u2 ? e.DepthMode.ReadWrite : e.DepthMode.ReadOnly), m2 = t2.colorModeForRenderPass(), f2 = t2.useProgram(_2 ? "backgroundPattern" : "background");
  52192. let g2, v2 = r2;
  52193. v2 || (g2 = t2.getBackgroundTiles(), v2 = Object.values(g2).map((e2) => e2.tileID)), _2 && (s2.activeTexture.set(l2.TEXTURE0), t2.imageManager.bind(t2.context));
  52194. const x2 = o2.getCrossfadeParameters();
  52195. for (const u3 of v2) {
  52196. const v3 = u3.toUnwrapped(), y2 = r2 ? u3.projMatrix : t2.transform.calculateProjMatrix(v3);
  52197. t2.prepareDrawTile();
  52198. const b2 = i3 ? i3.getTile(u3) : g2 ? g2[u3.key] : new e.Tile(u3, h2, c2.zoom, t2), w2 = _2 ? Yi(y2, a2, t2, _2, { tileID: u3, tileSize: h2 }, x2) : Ki(y2, a2, n2);
  52199. t2.prepareDrawProgram(s2, f2, v3);
  52200. const { tileBoundsBuffer: T2, tileBoundsIndexBuffer: E2, tileBoundsSegments: C2 } = t2.getTileBoundsBuffers(b2);
  52201. f2.draw(s2, l2.TRIANGLES, p2, d2, m2, e.CullFaceMode.disabled, w2, o2.id, T2, E2, C2);
  52202. }
  52203. }, sky: function(t2, i3, o2) {
  52204. const r2 = t2.transform, n2 = "mercator" === r2.projection.name || "globe" === r2.projection.name ? 1 : e.smoothstep(7, 8, r2.zoom), a2 = o2.paint.get("sky-opacity") * n2;
  52205. if (0 === a2)
  52206. return;
  52207. const s2 = t2.context, l2 = o2.paint.get("sky-type"), c2 = new e.DepthMode(s2.gl.LEQUAL, e.DepthMode.ReadOnly, [0, 1]), h2 = t2.frameCounter / 1e3 % 1;
  52208. "atmosphere" === l2 ? "offscreen" === t2.renderPass ? o2.needsSkyboxCapture(t2) && (function(t3, i4, o3, r3) {
  52209. const n3 = t3.context, a3 = n3.gl;
  52210. let s3 = i4.skyboxFbo;
  52211. if (!s3) {
  52212. s3 = i4.skyboxFbo = n3.createFramebuffer(32, 32, false), i4.skyboxGeometry = new To(n3), i4.skyboxTexture = n3.gl.createTexture(), a3.bindTexture(a3.TEXTURE_CUBE_MAP, i4.skyboxTexture), a3.texParameteri(a3.TEXTURE_CUBE_MAP, a3.TEXTURE_WRAP_S, a3.CLAMP_TO_EDGE), a3.texParameteri(a3.TEXTURE_CUBE_MAP, a3.TEXTURE_WRAP_T, a3.CLAMP_TO_EDGE), a3.texParameteri(a3.TEXTURE_CUBE_MAP, a3.TEXTURE_MIN_FILTER, a3.LINEAR), a3.texParameteri(a3.TEXTURE_CUBE_MAP, a3.TEXTURE_MAG_FILTER, a3.LINEAR);
  52213. for (let e2 = 0; e2 < 6; ++e2)
  52214. a3.texImage2D(a3.TEXTURE_CUBE_MAP_POSITIVE_X + e2, 0, a3.RGBA, 32, 32, 0, a3.RGBA, a3.UNSIGNED_BYTE, null);
  52215. }
  52216. n3.bindFramebuffer.set(s3.framebuffer), n3.viewport.set([0, 0, 32, 32]);
  52217. const l3 = i4.getCenter(t3, true), c3 = t3.useProgram("skyboxCapture"), h3 = new Float64Array(16);
  52218. e.identity(h3), e.rotateY(h3, h3, 0.5 * -Math.PI), Eo(n3, i4, c3, h3, l3, 0), e.identity(h3), e.rotateY(h3, h3, 0.5 * Math.PI), Eo(n3, i4, c3, h3, l3, 1), e.identity(h3), e.rotateX(h3, h3, 0.5 * -Math.PI), Eo(n3, i4, c3, h3, l3, 2), e.identity(h3), e.rotateX(h3, h3, 0.5 * Math.PI), Eo(n3, i4, c3, h3, l3, 3), e.identity(h3), Eo(n3, i4, c3, h3, l3, 4), e.identity(h3), e.rotateY(h3, h3, Math.PI), Eo(n3, i4, c3, h3, l3, 5), n3.viewport.set([0, 0, t3.width, t3.height]);
  52219. }(t2, o2), o2.markSkyboxValid(t2)) : "sky" === t2.renderPass && function(t3, i4, o3, r3, n3) {
  52220. const a3 = t3.context, s3 = a3.gl, l3 = t3.transform, c3 = t3.useProgram("skybox");
  52221. a3.activeTexture.set(s3.TEXTURE0), s3.bindTexture(s3.TEXTURE_CUBE_MAP, i4.skyboxTexture);
  52222. const h3 = ((e2, t4, i5, o4, r4) => ({ u_matrix: e2, u_sun_direction: t4, u_cubemap: 0, u_opacity: o4, u_temporal_offset: r4 }))(l3.skyboxMatrix, i4.getCenter(t3, false), 0, r3, n3);
  52223. t3.prepareDrawProgram(a3, c3), c3.draw(a3, s3.TRIANGLES, o3, e.StencilMode.disabled, t3.colorModeForRenderPass(), e.CullFaceMode.backCW, h3, "skybox", i4.skyboxGeometry.vertexBuffer, i4.skyboxGeometry.indexBuffer, i4.skyboxGeometry.segment);
  52224. }(t2, o2, c2, a2, h2) : "gradient" === l2 && "sky" === t2.renderPass && function(t3, i4, o3, r3, n3) {
  52225. const a3 = t3.context, s3 = a3.gl, l3 = t3.transform, c3 = t3.useProgram("skyboxGradient");
  52226. i4.skyboxGeometry || (i4.skyboxGeometry = new To(a3)), a3.activeTexture.set(s3.TEXTURE0);
  52227. let h3 = i4.colorRampTexture;
  52228. h3 || (h3 = i4.colorRampTexture = new e.Texture(a3, i4.colorRamp, s3.RGBA)), h3.bind(s3.LINEAR, s3.CLAMP_TO_EDGE);
  52229. const _2 = ((t4, i5, o4, r4, n4) => ({ u_matrix: t4, u_color_ramp: 0, u_center_direction: i5, u_radius: e.degToRad(o4), u_opacity: r4, u_temporal_offset: n4 }))(l3.skyboxMatrix, i4.getCenter(t3, false), i4.paint.get("sky-gradient-radius"), r3, n3);
  52230. t3.prepareDrawProgram(a3, c3), c3.draw(a3, s3.TRIANGLES, o3, e.StencilMode.disabled, t3.colorModeForRenderPass(), e.CullFaceMode.backCW, _2, "skyboxGradient", i4.skyboxGeometry.vertexBuffer, i4.skyboxGeometry.indexBuffer, i4.skyboxGeometry.segment);
  52231. }(t2, o2, c2, a2, h2);
  52232. }, debug: function(e2, t2, i3) {
  52233. for (let o2 = 0; o2 < i3.length; o2++)
  52234. xo(e2, t2, i3[o2]);
  52235. }, custom: function(t2, i3, o2) {
  52236. const r2 = t2.context, n2 = o2.implementation;
  52237. if (t2.transform.projection.unsupportedLayers && t2.transform.projection.unsupportedLayers.includes("custom"))
  52238. e.warnOnce("Custom layers are not yet supported with non-mercator projections. Use mercator to enable custom layers.");
  52239. else if ("offscreen" === t2.renderPass) {
  52240. const e2 = n2.prerender;
  52241. e2 && (t2.setCustomLayerDefaults(), r2.setColorMode(t2.colorModeForRenderPass()), e2.call(n2, r2.gl, t2.transform.customLayerMatrix()), r2.setDirty(), t2.setBaseState());
  52242. } else if ("translucent" === t2.renderPass) {
  52243. t2.setCustomLayerDefaults(), r2.setColorMode(t2.colorModeForRenderPass()), r2.setStencilMode(e.StencilMode.disabled);
  52244. const i4 = "3d" === n2.renderingMode ? new e.DepthMode(t2.context.gl.LEQUAL, e.DepthMode.ReadWrite, t2.depthRangeFor3D) : t2.depthModeForSublayer(0, e.DepthMode.ReadOnly);
  52245. r2.setDepthMode(i4), n2.render(r2.gl, t2.transform.customLayerMatrix()), r2.setDirty(), t2.setBaseState(), r2.bindFramebuffer.set(null);
  52246. }
  52247. } };
  52248. class Mo {
  52249. constructor(t2, i3) {
  52250. this.context = new Ee(t2), this.transform = i3, this._tileTextures = {}, this.frameCopies = [], this.loadTimeStamps = [], this.setup(), this.numSublayers = e.SourceCache.maxUnderzooming + e.SourceCache.maxOverzooming + 1, this.depthEpsilon = 1 / Math.pow(2, 16), this.crossTileSymbolIndex = new jt(), this.gpuTimers = {}, this.frameCounter = 0, this._backgroundTiles = {}, this._tileClippingMaskIDs = /* @__PURE__ */ new Map(), this._skippedStencilTileIDs = /* @__PURE__ */ new Set();
  52251. }
  52252. updateTerrain(e2, t2) {
  52253. const i3 = !!e2 && !!e2.terrain && this.transform.projection.supportsTerrain;
  52254. if (!(i3 || this._terrain && this._terrain.enabled))
  52255. return;
  52256. this._terrain || (this._terrain = new bi(this, e2));
  52257. const o2 = this._terrain;
  52258. this.transform.elevation = i3 ? o2 : null, o2.update(e2, this.transform, t2);
  52259. }
  52260. _updateFog(e2) {
  52261. const t2 = e2.fog;
  52262. if (!t2 || t2.getOpacity(this.transform.pitch) < 1 || t2.properties.get("horizon-blend") < 0.03)
  52263. return void (this.transform.fogCullDistSq = null);
  52264. const [i3, o2] = t2.getFovAdjustedRange(this.transform._fov);
  52265. if (i3 > o2)
  52266. return void (this.transform.fogCullDistSq = null);
  52267. const r2 = i3 + 0.78 * (o2 - i3);
  52268. this.transform.fogCullDistSq = r2 * r2;
  52269. }
  52270. get terrain() {
  52271. return this.transform._terrainEnabled() && this._terrain && this._terrain.enabled ? this._terrain : null;
  52272. }
  52273. resize(t2, i3) {
  52274. if (this.width = t2 * e.exported.devicePixelRatio, this.height = i3 * e.exported.devicePixelRatio, this.context.viewport.set([0, 0, this.width, this.height]), this.style)
  52275. for (const e2 of this.style.order)
  52276. this.style._layers[e2].resize();
  52277. }
  52278. setup() {
  52279. const t2 = this.context, i3 = new e.StructArrayLayout2i4();
  52280. i3.emplaceBack(0, 0), i3.emplaceBack(e.EXTENT, 0), i3.emplaceBack(0, e.EXTENT), i3.emplaceBack(e.EXTENT, e.EXTENT), this.tileExtentBuffer = t2.createVertexBuffer(i3, e.posAttributes.members), this.tileExtentSegments = e.SegmentVector.simpleSegment(0, 0, 4, 2);
  52281. const o2 = new e.StructArrayLayout2i4();
  52282. o2.emplaceBack(0, 0), o2.emplaceBack(e.EXTENT, 0), o2.emplaceBack(0, e.EXTENT), o2.emplaceBack(e.EXTENT, e.EXTENT), this.debugBuffer = t2.createVertexBuffer(o2, e.posAttributes.members), this.debugSegments = e.SegmentVector.simpleSegment(0, 0, 4, 5);
  52283. const r2 = new e.StructArrayLayout2i4();
  52284. r2.emplaceBack(-1, -1), r2.emplaceBack(1, -1), r2.emplaceBack(-1, 1), r2.emplaceBack(1, 1), this.viewportBuffer = t2.createVertexBuffer(r2, e.posAttributes.members), this.viewportSegments = e.SegmentVector.simpleSegment(0, 0, 4, 2);
  52285. const n2 = new e.StructArrayLayout4i8();
  52286. n2.emplaceBack(0, 0, 0, 0), n2.emplaceBack(e.EXTENT, 0, e.EXTENT, 0), n2.emplaceBack(0, e.EXTENT, 0, e.EXTENT), n2.emplaceBack(e.EXTENT, e.EXTENT, e.EXTENT, e.EXTENT), this.mercatorBoundsBuffer = t2.createVertexBuffer(n2, e.boundsAttributes.members), this.mercatorBoundsSegments = e.SegmentVector.simpleSegment(0, 0, 4, 2);
  52287. const a2 = new e.StructArrayLayout3ui6();
  52288. a2.emplaceBack(0, 1, 2), a2.emplaceBack(2, 1, 3), this.quadTriangleIndexBuffer = t2.createIndexBuffer(a2);
  52289. const s2 = new e.StructArrayLayout1ui2();
  52290. for (const e2 of [0, 1, 3, 2, 0])
  52291. s2.emplaceBack(e2);
  52292. this.debugIndexBuffer = t2.createIndexBuffer(s2), this.emptyTexture = new e.Texture(t2, new e.RGBAImage({ width: 1, height: 1 }, Uint8Array.of(0, 0, 0, 0)), t2.gl.RGBA), this.identityMat = e.create();
  52293. const l2 = this.context.gl;
  52294. this.stencilClearMode = new e.StencilMode({ func: l2.ALWAYS, mask: 0 }, 0, 255, l2.ZERO, l2.ZERO, l2.ZERO), this.loadTimeStamps.push(e.window.performance.now());
  52295. }
  52296. getMercatorTileBoundsBuffers() {
  52297. return { tileBoundsBuffer: this.mercatorBoundsBuffer, tileBoundsIndexBuffer: this.quadTriangleIndexBuffer, tileBoundsSegments: this.mercatorBoundsSegments };
  52298. }
  52299. getTileBoundsBuffers(e2) {
  52300. return e2._makeTileBoundsBuffers(this.context, this.transform.projection), e2._tileBoundsBuffer ? { tileBoundsBuffer: e2._tileBoundsBuffer, tileBoundsIndexBuffer: e2._tileBoundsIndexBuffer, tileBoundsSegments: e2._tileBoundsSegments } : this.getMercatorTileBoundsBuffers();
  52301. }
  52302. clearStencil() {
  52303. const t2 = this.context, i3 = t2.gl;
  52304. this.nextStencilID = 1, this.currentStencilSource = void 0, this._tileClippingMaskIDs.clear(), this._skippedStencilTileIDs.clear(), this.useProgram("clippingMask").draw(t2, i3.TRIANGLES, e.DepthMode.disabled, this.stencilClearMode, e.ColorMode.disabled, e.CullFaceMode.disabled, mi(this.identityMat), "$clipping", this.viewportBuffer, this.quadTriangleIndexBuffer, this.viewportSegments);
  52305. }
  52306. resetStencilClippingMasks() {
  52307. this.terrain || (this.currentStencilSource = void 0, this._tileClippingMaskIDs.clear(), this._skippedStencilTileIDs.clear());
  52308. }
  52309. _renderTileClippingMasks(t2, i3, o2) {
  52310. if (!i3 || this.currentStencilSource === i3.id || !t2.isTileClipped() || !o2 || 0 === o2.length)
  52311. return;
  52312. const r2 = [];
  52313. let n2 = false;
  52314. if (this._tileClippingMaskIDs && !this.terrain) {
  52315. for (const e2 of o2)
  52316. if (this._tileClippingMaskIDs.has(e2.key) || (n2 = true), this._skippedStencilTileIDs.has(e2.key)) {
  52317. if (!i3.getTile(e2).getBucket(t2))
  52318. continue;
  52319. this._skippedStencilTileIDs.delete(e2.key), r2.push(e2);
  52320. }
  52321. if (!n2 && 0 === r2.length)
  52322. return;
  52323. }
  52324. const a2 = this.context, s2 = a2.gl;
  52325. a2.setColorMode(e.ColorMode.disabled), a2.setDepthMode(e.DepthMode.disabled);
  52326. const l2 = this.useProgram("clippingMask"), c2 = (t3) => {
  52327. const o3 = i3.getTile(t3), { tileBoundsBuffer: r3, tileBoundsIndexBuffer: n3, tileBoundsSegments: c3 } = this.getTileBoundsBuffers(o3);
  52328. l2.draw(a2, s2.TRIANGLES, e.DepthMode.disabled, new e.StencilMode({ func: s2.GREATER, mask: 255 }, this._tileClippingMaskIDs.get(t3.key) || 0, 255, s2.KEEP, s2.KEEP, s2.REPLACE), e.ColorMode.disabled, e.CullFaceMode.disabled, mi(t3.projMatrix), "$clipping", r3, n3, c3);
  52329. };
  52330. if (!n2 && r2.length > 0)
  52331. for (const e2 of r2)
  52332. c2(e2);
  52333. else {
  52334. (0 === this._tileClippingMaskIDs.size || this.nextStencilID + o2.length > 256) && this.clearStencil(), this._tileClippingMaskIDs.clear(), this._skippedStencilTileIDs.clear();
  52335. for (const e2 of o2)
  52336. this._tileClippingMaskIDs.set(e2.key, this.nextStencilID++), i3.getTile(e2).getBucket(t2) ? c2(e2) : this._skippedStencilTileIDs.add(e2.key);
  52337. }
  52338. 0 === this._skippedStencilTileIDs.size && (this.currentStencilSource = i3.id);
  52339. }
  52340. stencilModeFor3D() {
  52341. this.currentStencilSource = void 0, this.nextStencilID + 1 > 256 && this.clearStencil();
  52342. const t2 = this.nextStencilID++, i3 = this.context.gl;
  52343. return new e.StencilMode({ func: i3.NOTEQUAL, mask: 255 }, t2, 255, i3.KEEP, i3.KEEP, i3.REPLACE);
  52344. }
  52345. stencilModeForClipping(t2) {
  52346. if (this.terrain)
  52347. return this.terrain.stencilModeForRTTOverlap(t2);
  52348. const i3 = this.context.gl;
  52349. return new e.StencilMode({ func: i3.EQUAL, mask: 255 }, this._tileClippingMaskIDs.get(t2.key) || 0, 0, i3.KEEP, i3.KEEP, i3.REPLACE);
  52350. }
  52351. stencilConfigForOverlap(t2) {
  52352. const i3 = this.context.gl, o2 = t2.sort((e2, t3) => t3.overscaledZ - e2.overscaledZ), r2 = o2[o2.length - 1].overscaledZ, n2 = o2[0].overscaledZ - r2 + 1;
  52353. if (n2 > 1) {
  52354. this.currentStencilSource = void 0, this.nextStencilID + n2 > 256 && this.clearStencil();
  52355. const t3 = {};
  52356. for (let o3 = 0; o3 < n2; o3++)
  52357. t3[o3 + r2] = new e.StencilMode({ func: i3.GEQUAL, mask: 255 }, o3 + this.nextStencilID, 255, i3.KEEP, i3.KEEP, i3.REPLACE);
  52358. return this.nextStencilID += n2, [t3, o2];
  52359. }
  52360. return [{ [r2]: e.StencilMode.disabled }, o2];
  52361. }
  52362. colorModeForRenderPass() {
  52363. const t2 = this.context.gl;
  52364. if (this._showOverdrawInspector) {
  52365. const i3 = 1 / 8;
  52366. return new e.ColorMode([t2.CONSTANT_COLOR, t2.ONE], new e.Color(i3, i3, i3, 0), [true, true, true, true]);
  52367. }
  52368. return "opaque" === this.renderPass ? e.ColorMode.unblended : e.ColorMode.alphaBlended;
  52369. }
  52370. depthModeForSublayer(t2, i3, o2) {
  52371. if (!this.opaquePassEnabledForLayer())
  52372. return e.DepthMode.disabled;
  52373. const r2 = 1 - ((1 + this.currentLayer) * this.numSublayers + t2) * this.depthEpsilon;
  52374. return new e.DepthMode(o2 || this.context.gl.LEQUAL, i3, [r2, r2]);
  52375. }
  52376. opaquePassEnabledForLayer() {
  52377. return this.currentLayer < this.opaquePassCutoff;
  52378. }
  52379. render(t2, i3) {
  52380. this.style = t2, this.options = i3, this.lineAtlas = t2.lineAtlas, this.imageManager = t2.imageManager, this.glyphManager = t2.glyphManager, this.symbolFadeChange = t2.placement.symbolFadeChange(e.exported.now()), this.imageManager.beginFrame();
  52381. const o2 = this.style.order, r2 = this.style._sourceCaches;
  52382. for (const e2 in r2) {
  52383. const t3 = r2[e2];
  52384. t3.used && t3.prepare(this.context);
  52385. }
  52386. const n2 = {}, a2 = {}, s2 = {};
  52387. for (const e2 in r2) {
  52388. const t3 = r2[e2];
  52389. n2[e2] = t3.getVisibleCoordinates(), a2[e2] = n2[e2].slice().reverse(), s2[e2] = t3.getVisibleCoordinates(true).reverse();
  52390. }
  52391. this.opaquePassCutoff = 1 / 0;
  52392. for (let e2 = 0; e2 < o2.length; e2++)
  52393. if (this.style._layers[o2[e2]].is3D()) {
  52394. this.opaquePassCutoff = e2;
  52395. break;
  52396. }
  52397. if (this.terrain && (this.terrain.updateTileBinding(s2), this.opaquePassCutoff = 0), "globe" !== this.transform.projection.name || this.globeSharedBuffers || (this.globeSharedBuffers = new e.GlobeSharedBuffers(this.context)), !e.isMapAuthenticated(this.context.gl))
  52398. return;
  52399. this.renderPass = "offscreen";
  52400. for (const e2 of o2) {
  52401. const i4 = this.style._layers[e2], o3 = t2._getLayerSourceCache(i4);
  52402. if (!i4.hasOffscreenPass() || i4.isHidden(this.transform.zoom))
  52403. continue;
  52404. const r3 = o3 ? a2[o3.id] : void 0;
  52405. ("custom" === i4.type || i4.isSky() || r3 && r3.length) && this.renderLayer(this, o3, i4, r3);
  52406. }
  52407. this.depthRangeFor3D = [0, 1 - (t2.order.length + 2) * this.numSublayers * this.depthEpsilon], this.terrain && (this.style.hasSymbolLayers() || this.style.hasCircleLayers()) && this.terrain.drawDepth(), this.context.bindFramebuffer.set(null), this.context.viewport.set([0, 0, this.width, this.height]);
  52408. let l2 = e.Color.transparent;
  52409. if (this.style.fog && this.style.fog.getOpacity(this.transform.pitch) && (l2 = this.style.fog.properties.get("color")), this.context.clear({ color: i3.showOverdrawInspector ? e.Color.black : l2, depth: 1 }), this.clearStencil(), this._showOverdrawInspector = i3.showOverdrawInspector, this.renderPass = "opaque", !this.terrain)
  52410. for (this.currentLayer = o2.length - 1; this.currentLayer >= 0; this.currentLayer--) {
  52411. const e2 = this.style._layers[o2[this.currentLayer]], i4 = t2._getLayerSourceCache(e2);
  52412. if (e2.isSky())
  52413. continue;
  52414. const r3 = i4 ? a2[i4.id] : void 0;
  52415. this._renderTileClippingMasks(e2, i4, r3), this.renderLayer(this, i4, e2, r3);
  52416. }
  52417. if (this.renderPass = "sky", (e.globeToMercatorTransition(this.transform.zoom) > 0 || "globe" !== this.transform.projection.name) && this.transform.isHorizonVisible())
  52418. for (this.currentLayer = 0; this.currentLayer < o2.length; this.currentLayer++) {
  52419. const e2 = this.style._layers[o2[this.currentLayer]], i4 = t2._getLayerSourceCache(e2);
  52420. e2.isSky() && this.renderLayer(this, i4, e2, i4 ? a2[i4.id] : void 0);
  52421. }
  52422. for ("globe" === this.transform.projection.name && function(t3) {
  52423. const i4 = t3.context, o3 = i4.gl, r3 = t3.transform, n3 = new e.DepthMode(o3.LEQUAL, e.DepthMode.ReadOnly, [0, 1]), a3 = t3.useProgram("globeAtmosphere"), s3 = r3.centerOffset, l3 = r3._camera.getCameraToClipPerspective(r3._fov, r3.width / r3.height, r3._nearZ, r3._farZ);
  52424. l3[8] = 2 * -s3.x / r3.width, l3[9] = 2 * s3.y / r3.height;
  52425. const c2 = e.invert([], l3), h2 = e.mul([], c2, r3.projMatrix), _2 = { u_frustum_tl: Co([-1, 1, 1], c2), u_frustum_tr: Co([1, 1, 1], c2), u_frustum_br: Co([1, -1, 1], c2), u_frustum_bl: Co([-1, -1, 1], c2), u_globe_pos: Co([r3.globeMatrix[12], r3.globeMatrix[13], r3.globeMatrix[14]], h2), u_globe_radius: r3.worldSize / 2 / Math.PI - 1, u_opacity: 1 - e.globeToMercatorTransition(r3.zoom), u_fadeout_range: 2, u_start_color: [1, 1, 1], u_end_color: [0.0118, 0.7451, 0.9882] };
  52426. t3.prepareDrawProgram(i4, a3);
  52427. const u2 = t3.globeSharedBuffers;
  52428. u2 && a3.draw(i4, o3.TRIANGLES, n3, e.StencilMode.disabled, e.ColorMode.alphaBlended, e.CullFaceMode.backCW, _2, "skybox", u2.atmosphereVertexBuffer, u2.atmosphereIndexBuffer, u2.atmosphereSegments);
  52429. }(this), this.renderPass = "translucent", this.currentLayer = 0; this.currentLayer < o2.length; ) {
  52430. const e2 = this.style._layers[o2[this.currentLayer]], i4 = t2._getLayerSourceCache(e2);
  52431. if (e2.isSky()) {
  52432. ++this.currentLayer;
  52433. continue;
  52434. }
  52435. if (this.terrain && this.style.isLayerDraped(e2)) {
  52436. if (e2.isHidden(this.transform.zoom)) {
  52437. ++this.currentLayer;
  52438. continue;
  52439. }
  52440. this.currentLayer = this.terrain.renderBatch(this.currentLayer);
  52441. continue;
  52442. }
  52443. const r3 = i4 ? ("symbol" === e2.type ? s2 : a2)[i4.id] : void 0;
  52444. this._renderTileClippingMasks(e2, i4, i4 ? n2[i4.id] : void 0), this.renderLayer(this, i4, e2, r3), ++this.currentLayer;
  52445. }
  52446. if (this.terrain && this.terrain.postRender(), this.options.showTileBoundaries || this.options.showQueryGeometry) {
  52447. let i4 = null;
  52448. e.values(this.style._layers).forEach((e2) => {
  52449. const o3 = t2._getLayerSourceCache(e2);
  52450. o3 && !e2.isHidden(this.transform.zoom) && (!i4 || i4.getSource().maxzoom < o3.getSource().maxzoom) && (i4 = o3);
  52451. }), i4 && this.options.showTileBoundaries && Io.debug(this, i4, i4.getVisibleCoordinates());
  52452. }
  52453. this.options.showPadding && function(e2) {
  52454. const t3 = e2.transform.padding;
  52455. fo(e2, e2.transform.height - (t3.top || 0), 3, ho), fo(e2, t3.bottom || 0, 3, _o), go(e2, t3.left || 0, 3, uo), go(e2, e2.transform.width - (t3.right || 0), 3, po);
  52456. const i4 = e2.transform.centerPoint;
  52457. !function(e3, t4, i5, o3) {
  52458. vo(e3, t4 - 1, i5 - 10, 2, 20, o3), vo(e3, t4 - 10, i5 - 1, 20, 2, o3);
  52459. }(e2, i4.x, e2.transform.height - i4.y, mo);
  52460. }(this), this.context.setDefault(), this.frameCounter = (this.frameCounter + 1) % Number.MAX_SAFE_INTEGER, this.tileLoaded && this.options.speedIndexTiming && (this.loadTimeStamps.push(e.window.performance.now()), this.saveCanvasCopy());
  52461. }
  52462. renderLayer(e2, t2, i3, o2) {
  52463. i3.isHidden(this.transform.zoom) || ("background" === i3.type || "sky" === i3.type || "custom" === i3.type || o2 && o2.length) && (this.id = i3.id, this.gpuTimingStart(i3), e2.transform.projection.unsupportedLayers && e2.transform.projection.unsupportedLayers.includes(i3.type) || Io[i3.type](e2, t2, i3, o2, this.style.placement.variableOffsets, this.options.isInitialLoad), this.gpuTimingEnd());
  52464. }
  52465. gpuTimingStart(e2) {
  52466. if (!this.options.gpuTiming)
  52467. return;
  52468. const t2 = this.context.extTimerQuery;
  52469. let i3 = this.gpuTimers[e2.id];
  52470. i3 || (i3 = this.gpuTimers[e2.id] = { calls: 0, cpuTime: 0, query: t2.createQueryEXT() }), i3.calls++, t2.beginQueryEXT(t2.TIME_ELAPSED_EXT, i3.query);
  52471. }
  52472. gpuTimingEnd() {
  52473. if (!this.options.gpuTiming)
  52474. return;
  52475. const e2 = this.context.extTimerQuery;
  52476. e2.endQueryEXT(e2.TIME_ELAPSED_EXT);
  52477. }
  52478. collectGpuTimers() {
  52479. const e2 = this.gpuTimers;
  52480. return this.gpuTimers = {}, e2;
  52481. }
  52482. queryGpuTimers(e2) {
  52483. const t2 = {};
  52484. for (const i3 in e2) {
  52485. const o2 = e2[i3], r2 = this.context.extTimerQuery, n2 = r2.getQueryObjectEXT(o2.query, r2.QUERY_RESULT_EXT) / 1e6;
  52486. r2.deleteQueryEXT(o2.query), t2[i3] = n2;
  52487. }
  52488. return t2;
  52489. }
  52490. translatePosMatrix(t2, i3, o2, r2, n2) {
  52491. if (!o2[0] && !o2[1])
  52492. return t2;
  52493. const a2 = n2 ? "map" === r2 ? this.transform.angle : 0 : "viewport" === r2 ? -this.transform.angle : 0;
  52494. if (a2) {
  52495. const e2 = Math.sin(a2), t3 = Math.cos(a2);
  52496. o2 = [o2[0] * t3 - o2[1] * e2, o2[0] * e2 + o2[1] * t3];
  52497. }
  52498. const s2 = [n2 ? o2[0] : L(i3, o2[0], this.transform.zoom), n2 ? o2[1] : L(i3, o2[1], this.transform.zoom), 0], l2 = new Float32Array(16);
  52499. return e.translate(l2, t2, s2), l2;
  52500. }
  52501. saveTileTexture(e2) {
  52502. const t2 = this._tileTextures[e2.size[0]];
  52503. t2 ? t2.push(e2) : this._tileTextures[e2.size[0]] = [e2];
  52504. }
  52505. getTileTexture(e2) {
  52506. const t2 = this._tileTextures[e2];
  52507. return t2 && t2.length > 0 ? t2.pop() : null;
  52508. }
  52509. isPatternMissing(e2) {
  52510. if (!e2)
  52511. return false;
  52512. if (!e2.from || !e2.to)
  52513. return true;
  52514. const t2 = this.imageManager.getPattern(e2.from.toString()), i3 = this.imageManager.getPattern(e2.to.toString());
  52515. return !t2 || !i3;
  52516. }
  52517. currentGlobalDefines() {
  52518. const e2 = this.terrain && this.terrain.renderingToTexture, t2 = this.style && this.style.fog, i3 = [];
  52519. return this.terrain && !this.terrain.renderingToTexture && i3.push("TERRAIN"), t2 && !e2 && 0 !== t2.getOpacity(this.transform.pitch) && i3.push("FOG"), e2 && i3.push("RENDER_TO_TEXTURE"), this._showOverdrawInspector && i3.push("OVERDRAW_INSPECTOR"), i3;
  52520. }
  52521. useProgram(e2, t2, i3) {
  52522. this.cache = this.cache || {};
  52523. const o2 = i3 || [], r2 = this.currentGlobalDefines().concat(o2), n2 = Ti.cacheKey(e2, r2, t2);
  52524. return this.cache[n2] || (this.cache[n2] = new Ti(this.context, e2, ti[e2], t2, Ji[e2], r2)), this.cache[n2];
  52525. }
  52526. setCustomLayerDefaults() {
  52527. this.context.unbindVAO(), this.context.cullFace.setDefault(), this.context.frontFace.setDefault(), this.context.cullFaceSide.setDefault(), this.context.activeTexture.setDefault(), this.context.pixelStoreUnpack.setDefault(), this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(), this.context.pixelStoreUnpackFlipY.setDefault();
  52528. }
  52529. setBaseState() {
  52530. const e2 = this.context.gl;
  52531. this.context.cullFace.set(false), this.context.viewport.set([0, 0, this.width, this.height]), this.context.blendEquation.set(e2.FUNC_ADD);
  52532. }
  52533. initDebugOverlayCanvas() {
  52534. null == this.debugOverlayCanvas && (this.debugOverlayCanvas = e.window.document.createElement("canvas"), this.debugOverlayCanvas.width = 512, this.debugOverlayCanvas.height = 512, this.debugOverlayTexture = new e.Texture(this.context, this.debugOverlayCanvas, this.context.gl.RGBA));
  52535. }
  52536. destroy() {
  52537. this._terrain && this._terrain.destroy(), this.globeSharedBuffers && this.globeSharedBuffers.destroy(), this.emptyTexture.destroy(), this.debugOverlayTexture && this.debugOverlayTexture.destroy();
  52538. }
  52539. prepareDrawTile() {
  52540. this.terrain && this.terrain.prepareDrawTile();
  52541. }
  52542. prepareDrawProgram(e2, t2, i3) {
  52543. if (this.terrain && this.terrain.renderingToTexture)
  52544. return;
  52545. const o2 = this.style.fog;
  52546. if (o2) {
  52547. const r2 = o2.getOpacity(this.transform.pitch);
  52548. 0 !== r2 && t2.setFogUniformValues(e2, ((e3, t3, i4, o3) => {
  52549. const r3 = t3.properties.get("color"), n2 = e3.frameCounter / 1e3 % 1, a2 = [r3.r / r3.a, r3.g / r3.a, r3.b / r3.a, o3];
  52550. return { u_fog_matrix: i4 ? e3.transform.calculateFogTileMatrix(i4) : e3.identityMat, u_fog_range: t3.getFovAdjustedRange(e3.transform._fov), u_fog_color: a2, u_fog_horizon_blend: t3.properties.get("horizon-blend"), u_fog_temporal_offset: n2 };
  52551. })(this, o2, i3, r2));
  52552. }
  52553. }
  52554. setTileLoadedFlag(e2) {
  52555. this.tileLoaded = e2;
  52556. }
  52557. saveCanvasCopy() {
  52558. this.frameCopies.push(this.canvasCopy()), this.tileLoaded = false;
  52559. }
  52560. canvasCopy() {
  52561. const e2 = this.context.gl, t2 = e2.createTexture();
  52562. return e2.bindTexture(e2.TEXTURE_2D, t2), e2.copyTexImage2D(e2.TEXTURE_2D, 0, e2.RGBA, 0, 0, e2.drawingBufferWidth, e2.drawingBufferHeight, 0), t2;
  52563. }
  52564. getCanvasCopiesAndTimestamps() {
  52565. return { canvasCopies: this.frameCopies, timeStamps: this.loadTimeStamps };
  52566. }
  52567. averageElevationNeedsEasing() {
  52568. if (!this.transform._elevation)
  52569. return false;
  52570. const e2 = this.style && this.style.fog;
  52571. return !!e2 && 0 !== e2.getOpacity(this.transform.pitch);
  52572. }
  52573. getBackgroundTiles() {
  52574. const t2 = this._backgroundTiles, i3 = this._backgroundTiles = {}, o2 = this.transform.coveringTiles({ tileSize: 512 });
  52575. for (const r2 of o2)
  52576. i3[r2.key] = t2[r2.key] || new e.Tile(r2, 512, this.transform.tileZoom, this);
  52577. return i3;
  52578. }
  52579. clearBackgroundTiles() {
  52580. this._backgroundTiles = {};
  52581. }
  52582. }
  52583. class So {
  52584. constructor(e2 = 0, t2 = 0, i3 = 0, o2 = 0) {
  52585. if (isNaN(e2) || e2 < 0 || isNaN(t2) || t2 < 0 || isNaN(i3) || i3 < 0 || isNaN(o2) || o2 < 0)
  52586. throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");
  52587. this.top = e2, this.bottom = t2, this.left = i3, this.right = o2;
  52588. }
  52589. interpolate(t2, i3, o2) {
  52590. return null != i3.top && null != t2.top && (this.top = e.number(t2.top, i3.top, o2)), null != i3.bottom && null != t2.bottom && (this.bottom = e.number(t2.bottom, i3.bottom, o2)), null != i3.left && null != t2.left && (this.left = e.number(t2.left, i3.left, o2)), null != i3.right && null != t2.right && (this.right = e.number(t2.right, i3.right, o2)), this;
  52591. }
  52592. getCenter(t2, i3) {
  52593. const o2 = e.clamp((this.left + t2 - this.right) / 2, 0, t2), r2 = e.clamp((this.top + i3 - this.bottom) / 2, 0, i3);
  52594. return new e.pointGeometry(o2, r2);
  52595. }
  52596. equals(e2) {
  52597. return this.top === e2.top && this.bottom === e2.bottom && this.left === e2.left && this.right === e2.right;
  52598. }
  52599. clone() {
  52600. return new So(this.top, this.bottom, this.left, this.right);
  52601. }
  52602. toJSON() {
  52603. return { top: this.top, bottom: this.bottom, left: this.left, right: this.right };
  52604. }
  52605. }
  52606. function zo(t2, i3) {
  52607. const o2 = e.getColumn(t2, 3);
  52608. e.fromQuat(t2, i3), e.setColumn(t2, 3, o2);
  52609. }
  52610. function Do(t2, i3) {
  52611. const o2 = e.identity$1([]);
  52612. return e.rotateZ$1(o2, o2, -i3), e.rotateX$1(o2, o2, -t2), o2;
  52613. }
  52614. function Po(t2, i3) {
  52615. const o2 = [t2[0], t2[1], 0], r2 = [i3[0], i3[1], 0];
  52616. if (e.length(o2) >= 1e-15) {
  52617. const t3 = e.normalize([], o2);
  52618. e.scale$2(r2, t3, e.dot(r2, t3)), i3[0] = r2[0], i3[1] = r2[1];
  52619. }
  52620. const n2 = e.cross([], i3, t2);
  52621. if (e.len(n2) < 1e-15)
  52622. return null;
  52623. const a2 = Math.atan2(-n2[1], n2[0]);
  52624. return Do(Math.atan2(Math.sqrt(t2[0] * t2[0] + t2[1] * t2[1]), -t2[2]), a2);
  52625. }
  52626. class Ao {
  52627. constructor(e2, t2) {
  52628. this.position = e2, this.orientation = t2;
  52629. }
  52630. get position() {
  52631. return this._position;
  52632. }
  52633. set position(t2) {
  52634. if (t2) {
  52635. const i3 = t2 instanceof e.MercatorCoordinate ? t2 : new e.MercatorCoordinate(t2[0], t2[1], t2[2]);
  52636. this._renderWorldCopies && (i3.x = e.wrap(i3.x, 0, 1)), this._position = i3;
  52637. } else
  52638. this._position = null;
  52639. }
  52640. lookAtPoint(t2, i3) {
  52641. if (this.orientation = null, !this.position)
  52642. return;
  52643. const o2 = this._elevation ? this._elevation.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(t2)) : 0, r2 = this.position, n2 = e.MercatorCoordinate.fromLngLat(t2, o2), a2 = [n2.x - r2.x, n2.y - r2.y, n2.z - r2.z];
  52644. i3 || (i3 = [0, 0, 1]), i3[2] = Math.abs(i3[2]), this.orientation = Po(a2, i3);
  52645. }
  52646. setPitchBearing(t2, i3) {
  52647. this.orientation = Do(e.degToRad(t2), e.degToRad(-i3));
  52648. }
  52649. }
  52650. class Lo {
  52651. constructor(t2, i3) {
  52652. this._transform = e.identity([]), this.orientation = i3, this.position = t2;
  52653. }
  52654. get mercatorPosition() {
  52655. const t2 = this.position;
  52656. return new e.MercatorCoordinate(t2[0], t2[1], t2[2]);
  52657. }
  52658. get position() {
  52659. const t2 = e.getColumn(this._transform, 3);
  52660. return [t2[0], t2[1], t2[2]];
  52661. }
  52662. set position(t2) {
  52663. var i3;
  52664. t2 && e.setColumn(this._transform, 3, [(i3 = t2)[0], i3[1], i3[2], 1]);
  52665. }
  52666. get orientation() {
  52667. return this._orientation;
  52668. }
  52669. set orientation(t2) {
  52670. this._orientation = t2 || e.identity$1([]), t2 && zo(this._transform, this._orientation);
  52671. }
  52672. getPitchBearing() {
  52673. const e2 = this.forward(), t2 = this.right();
  52674. return { bearing: Math.atan2(-t2[1], t2[0]), pitch: Math.atan2(Math.sqrt(e2[0] * e2[0] + e2[1] * e2[1]), -e2[2]) };
  52675. }
  52676. setPitchBearing(e2, t2) {
  52677. this._orientation = Do(e2, t2), zo(this._transform, this._orientation);
  52678. }
  52679. forward() {
  52680. const t2 = e.getColumn(this._transform, 2);
  52681. return [-t2[0], -t2[1], -t2[2]];
  52682. }
  52683. up() {
  52684. const t2 = e.getColumn(this._transform, 1);
  52685. return [-t2[0], -t2[1], -t2[2]];
  52686. }
  52687. right() {
  52688. const t2 = e.getColumn(this._transform, 0);
  52689. return [t2[0], t2[1], t2[2]];
  52690. }
  52691. getCameraToWorld(t2, i3) {
  52692. const o2 = new Float64Array(16);
  52693. return e.invert(o2, this.getWorldToCamera(t2, i3)), o2;
  52694. }
  52695. getWorldToCameraPosition(t2, i3, o2) {
  52696. const r2 = this.position;
  52697. e.scale$2(r2, r2, -t2);
  52698. const n2 = new Float64Array(16);
  52699. return e.fromScaling(n2, [o2, o2, o2]), e.translate(n2, n2, r2), n2[10] *= i3, n2;
  52700. }
  52701. getWorldToCamera(t2, i3) {
  52702. const o2 = new Float64Array(16), r2 = new Float64Array(4), n2 = this.position;
  52703. return e.conjugate(r2, this._orientation), e.scale$2(n2, n2, -t2), e.fromQuat(o2, r2), e.translate(o2, o2, n2), o2[1] *= -1, o2[5] *= -1, o2[9] *= -1, o2[13] *= -1, o2[8] *= i3, o2[9] *= i3, o2[10] *= i3, o2[11] *= i3, o2;
  52704. }
  52705. getCameraToClipPerspective(t2, i3, o2, r2) {
  52706. const n2 = new Float64Array(16);
  52707. return e.perspective(n2, t2, i3, o2, r2), n2;
  52708. }
  52709. getDistanceToElevation(t2) {
  52710. const i3 = 0 === t2 ? 0 : e.mercatorZfromAltitude(t2, this.position[1]), o2 = this.forward();
  52711. return (i3 - this.position[2]) / o2[2];
  52712. }
  52713. clone() {
  52714. return new Lo([...this.position], [...this.orientation]);
  52715. }
  52716. }
  52717. function Ro(t2, i3) {
  52718. const o2 = Oo(t2), r2 = function(t3, i4, o3, r3, n3) {
  52719. const a2 = new e.LngLat(o3.lng - 180 * Bo, o3.lat), s2 = new e.LngLat(o3.lng + 180 * Bo, o3.lat), l2 = t3.project(a2.lng, a2.lat), c2 = t3.project(s2.lng, s2.lat), h2 = -Math.atan2(c2.y - l2.y, c2.x - l2.x), _2 = e.MercatorCoordinate.fromLngLat(o3);
  52720. _2.y = e.clamp(_2.y, -0.999975, 0.999975);
  52721. const u2 = _2.toLngLat(), d2 = t3.project(u2.lng, u2.lat), p2 = e.MercatorCoordinate.fromLngLat(u2);
  52722. p2.x += Bo;
  52723. const m2 = p2.toLngLat(), f2 = t3.project(m2.lng, m2.lat), g2 = Uo(f2.x - d2.x, f2.y - d2.y, h2), v2 = e.MercatorCoordinate.fromLngLat(u2);
  52724. v2.y += Bo;
  52725. const x2 = v2.toLngLat(), y2 = t3.project(x2.lng, x2.lat), b2 = Uo(y2.x - d2.x, y2.y - d2.y, h2), w2 = Math.abs(g2.x) / Math.abs(b2.y), T2 = e.identity([]);
  52726. e.rotateZ(T2, T2, -h2 * (1 - (n3 ? 0 : r3)));
  52727. const E2 = e.identity([]);
  52728. return e.scale(E2, E2, [1, 1 - (1 - w2) * r3, 1]), E2[4] = -b2.x / b2.y * r3, e.rotateZ(E2, E2, h2), e.multiply$1(E2, T2, E2), E2;
  52729. }(t2.projection, 0, t2.center, o2, i3), n2 = ko(t2);
  52730. return e.scale(r2, r2, [n2, n2, 1]), r2;
  52731. }
  52732. function ko(t2) {
  52733. const i3 = t2.projection, o2 = Oo(t2), r2 = Fo(i3, t2.center), n2 = Fo(i3, e.LngLat.convert(i3.center));
  52734. return Math.pow(2, r2 * o2 + (1 - o2) * n2);
  52735. }
  52736. function Oo(t2) {
  52737. const i3 = t2.projection.range;
  52738. if (!i3)
  52739. return 0;
  52740. const o2 = Math.max(t2.width, t2.height), r2 = Math.log(o2 / 1024) / Math.LN2;
  52741. return e.smoothstep(i3[0] + r2, i3[1] + r2, t2.zoom);
  52742. }
  52743. const Bo = 1 / 4e4;
  52744. function Fo(t2, i3) {
  52745. const o2 = e.clamp(i3.lat, -e.MAX_MERCATOR_LATITUDE, e.MAX_MERCATOR_LATITUDE), r2 = new e.LngLat(i3.lng - 180 * Bo, o2), n2 = new e.LngLat(i3.lng + 180 * Bo, o2), a2 = t2.project(r2.lng, o2), s2 = t2.project(n2.lng, o2), l2 = e.MercatorCoordinate.fromLngLat(r2), c2 = e.MercatorCoordinate.fromLngLat(n2), h2 = s2.x - a2.x, _2 = s2.y - a2.y, u2 = c2.x - l2.x, d2 = c2.y - l2.y, p2 = Math.sqrt((u2 * u2 + d2 * d2) / (h2 * h2 + _2 * _2));
  52746. return Math.log(p2) / Math.LN2;
  52747. }
  52748. function Uo(e2, t2, i3) {
  52749. const o2 = Math.cos(i3), r2 = Math.sin(i3);
  52750. return { x: e2 * o2 - t2 * r2, y: e2 * r2 + t2 * o2 };
  52751. }
  52752. class No {
  52753. constructor(t2, i3, o2, r2, n2, a2, s2) {
  52754. this.tileSize = 512, this._renderWorldCopies = void 0 === n2 || n2, this._minZoom = t2 || 0, this._maxZoom = i3 || 22, this._minPitch = null == o2 ? 0 : o2, this._maxPitch = null == r2 ? 60 : r2, this.setProjection(a2), this.setMaxBounds(s2), this.width = 0, this.height = 0, this._center = new e.LngLat(0, 0), this.zoom = 0, this.angle = 0, this._fov = 0.6435011087932844, this._pitch = 0, this._nearZ = 0, this._farZ = 0, this._unmodified = true, this._edgeInsets = new So(), this._projMatrixCache = {}, this._alignedProjMatrixCache = {}, this._fogTileMatrixCache = {}, this._distanceTileDataCache = {}, this._camera = new Lo(), this._centerAltitude = 0, this._centerAltitudeValidForExaggeration = 0, this._averageElevation = 0, this.cameraElevationReference = "ground", this._projectionScaler = 1, this._horizonShift = 0.1;
  52755. }
  52756. clone() {
  52757. const e2 = new No(this._minZoom, this._maxZoom, this._minPitch, this.maxPitch, this._renderWorldCopies, this.getProjection());
  52758. return e2._elevation = this._elevation, e2._centerAltitude = this._centerAltitude, e2._centerAltitudeValidForExaggeration = this._centerAltitudeValidForExaggeration, e2.tileSize = this.tileSize, e2.width = this.width, e2.height = this.height, e2.cameraElevationReference = this.cameraElevationReference, e2._center = this._center, e2._setZoom(this.zoom), e2._seaLevelZoom = this._seaLevelZoom, e2.angle = this.angle, e2._fov = this._fov, e2._pitch = this._pitch, e2._nearZ = this._nearZ, e2._farZ = this._farZ, e2._averageElevation = this._averageElevation, e2._unmodified = this._unmodified, e2._edgeInsets = this._edgeInsets.clone(), e2._camera = this._camera.clone(), e2._calcMatrices(), e2.freezeTileCoverage = this.freezeTileCoverage, e2;
  52759. }
  52760. get elevation() {
  52761. return this._elevation;
  52762. }
  52763. set elevation(e2) {
  52764. this._elevation !== e2 && (this._elevation = e2, this._updateCameraOnTerrain(), this._calcMatrices());
  52765. }
  52766. updateElevation(e2) {
  52767. const t2 = this._elevation && this._elevation.exaggeration() !== this._centerAltitudeValidForExaggeration;
  52768. (null == this._seaLevelZoom || t2) && this._updateCameraOnTerrain(), (e2 || t2) && this._constrainCameraAltitude(), this._calcMatrices();
  52769. }
  52770. getProjection() {
  52771. return e.pick(this.projection, ["name", "center", "parallels"]);
  52772. }
  52773. setProjection(t2) {
  52774. null == t2 && (t2 = { name: "mercator" }), this.projectionOptions = t2;
  52775. const i3 = this.projection ? this.getProjection() : void 0;
  52776. this.projection = e.getProjection(t2);
  52777. const o2 = this.getProjection();
  52778. return r(i3, o2) ? null : (this._calcMatrices(), o2);
  52779. }
  52780. get minZoom() {
  52781. return this._minZoom;
  52782. }
  52783. set minZoom(e2) {
  52784. this._minZoom !== e2 && (this._minZoom = e2, this.zoom = Math.max(this.zoom, e2));
  52785. }
  52786. get maxZoom() {
  52787. return this._maxZoom;
  52788. }
  52789. set maxZoom(e2) {
  52790. this._maxZoom !== e2 && (this._maxZoom = e2, this.zoom = Math.min(this.zoom, e2));
  52791. }
  52792. get minPitch() {
  52793. return this._minPitch;
  52794. }
  52795. set minPitch(e2) {
  52796. this._minPitch !== e2 && (this._minPitch = e2, this.pitch = Math.max(this.pitch, e2));
  52797. }
  52798. get maxPitch() {
  52799. return this._maxPitch;
  52800. }
  52801. set maxPitch(e2) {
  52802. this._maxPitch !== e2 && (this._maxPitch = e2, this.pitch = Math.min(this.pitch, e2));
  52803. }
  52804. get renderWorldCopies() {
  52805. return this._renderWorldCopies && true === this.projection.supportsWorldCopies;
  52806. }
  52807. set renderWorldCopies(e2) {
  52808. void 0 === e2 ? e2 = true : null === e2 && (e2 = false), this._renderWorldCopies = e2;
  52809. }
  52810. get worldSize() {
  52811. return this.tileSize * this.scale;
  52812. }
  52813. get cameraWorldSize() {
  52814. const e2 = Math.max(this._camera.getDistanceToElevation(this._averageElevation), Number.EPSILON);
  52815. return this._worldSizeFromZoom(this._zoomFromMercatorZ(e2));
  52816. }
  52817. get pixelsPerMeter() {
  52818. return this.projection.pixelsPerMeter(this.center.lat, this.worldSize);
  52819. }
  52820. get cameraPixelsPerMeter() {
  52821. return this.projection.pixelsPerMeter(this.center.lat, this.cameraWorldSize);
  52822. }
  52823. get centerOffset() {
  52824. return this.centerPoint._sub(this.size._div(2));
  52825. }
  52826. get size() {
  52827. return new e.pointGeometry(this.width, this.height);
  52828. }
  52829. get bearing() {
  52830. return e.wrap(this.rotation, -180, 180);
  52831. }
  52832. set bearing(e2) {
  52833. this.rotation = e2;
  52834. }
  52835. get rotation() {
  52836. return -this.angle / Math.PI * 180;
  52837. }
  52838. set rotation(t2) {
  52839. const i3 = -t2 * Math.PI / 180;
  52840. var o2;
  52841. this.angle !== i3 && (this._unmodified = false, this.angle = i3, this._calcMatrices(), this.rotationMatrix = (o2 = new e.ARRAY_TYPE(4), e.ARRAY_TYPE != Float32Array && (o2[1] = 0, o2[2] = 0), o2[0] = 1, o2[3] = 1, o2), function(e2, t3, i4) {
  52842. var o3 = t3[0], r2 = t3[1], n2 = t3[2], a2 = t3[3], s2 = Math.sin(i4), l2 = Math.cos(i4);
  52843. e2[0] = o3 * l2 + n2 * s2, e2[1] = r2 * l2 + a2 * s2, e2[2] = o3 * -s2 + n2 * l2, e2[3] = r2 * -s2 + a2 * l2;
  52844. }(this.rotationMatrix, this.rotationMatrix, this.angle));
  52845. }
  52846. get pitch() {
  52847. return this._pitch / Math.PI * 180;
  52848. }
  52849. set pitch(t2) {
  52850. const i3 = e.clamp(t2, this.minPitch, this.maxPitch) / 180 * Math.PI;
  52851. this._pitch !== i3 && (this._unmodified = false, this._pitch = i3, this._calcMatrices());
  52852. }
  52853. get fov() {
  52854. return this._fov / Math.PI * 180;
  52855. }
  52856. set fov(e2) {
  52857. e2 = Math.max(0.01, Math.min(60, e2)), this._fov !== e2 && (this._unmodified = false, this._fov = e2 / 180 * Math.PI, this._calcMatrices());
  52858. }
  52859. get averageElevation() {
  52860. return this._averageElevation;
  52861. }
  52862. set averageElevation(e2) {
  52863. this._averageElevation = e2, this._calcFogMatrices(), this._distanceTileDataCache = {};
  52864. }
  52865. get zoom() {
  52866. return this._zoom;
  52867. }
  52868. set zoom(e2) {
  52869. const t2 = Math.min(Math.max(e2, this.minZoom), this.maxZoom);
  52870. this._zoom !== t2 && (this._unmodified = false, this._setZoom(t2), this._updateSeaLevelZoom(), this._constrain(), this._calcMatrices());
  52871. }
  52872. _setZoom(e2) {
  52873. this._zoom = e2, this.scale = this.zoomScale(e2), this.tileZoom = Math.floor(e2), this.zoomFraction = e2 - this.tileZoom;
  52874. }
  52875. _updateCameraOnTerrain() {
  52876. if (!this._elevation || !this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))
  52877. return this._centerAltitude = 0, this._seaLevelZoom = null, void (this._centerAltitudeValidForExaggeration = 0);
  52878. const e2 = this._elevation;
  52879. this._centerAltitude = e2.getAtPointOrZero(this.locationCoordinate(this.center)), this._centerAltitudeValidForExaggeration = e2.exaggeration(), this._updateSeaLevelZoom();
  52880. }
  52881. _updateSeaLevelZoom() {
  52882. 0 !== this._centerAltitudeValidForExaggeration && (this._seaLevelZoom = this._zoomFromMercatorZ((this.pixelsPerMeter * this._centerAltitude + this.cameraToCenterDistance) / this.worldSize));
  52883. }
  52884. sampleAverageElevation() {
  52885. if (!this._elevation)
  52886. return 0;
  52887. const t2 = this._elevation, i3 = [[0.5, 0.2], [0.3, 0.5], [0.5, 0.5], [0.7, 0.5], [0.5, 0.8]], o2 = this.horizonLineFromTop();
  52888. let r2 = 0, n2 = 0;
  52889. for (let a2 = 0; a2 < i3.length; a2++) {
  52890. const s2 = new e.pointGeometry(i3[a2][0] * this.width, o2 + i3[a2][1] * (this.height - o2)), l2 = t2.pointCoordinate(s2);
  52891. if (!l2)
  52892. continue;
  52893. const c2 = 1 / Math.hypot(l2[0] - this._camera.position[0], l2[1] - this._camera.position[1]);
  52894. r2 += l2[3] * c2, n2 += c2;
  52895. }
  52896. return 0 === n2 ? NaN : r2 / n2;
  52897. }
  52898. get center() {
  52899. return this._center;
  52900. }
  52901. set center(e2) {
  52902. e2.lat === this._center.lat && e2.lng === this._center.lng || (this._unmodified = false, this._center = e2, this._terrainEnabled() && ("ground" === this.cameraElevationReference ? this._updateCameraOnTerrain() : this._updateZoomFromElevation()), this._constrain(), this._calcMatrices());
  52903. }
  52904. _updateZoomFromElevation() {
  52905. if (null == this._seaLevelZoom || !this._elevation)
  52906. return;
  52907. const e2 = this._seaLevelZoom, t2 = this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)), i3 = this.pixelsPerMeter / this.worldSize * t2, o2 = this._mercatorZfromZoom(e2), r2 = this._mercatorZfromZoom(this._maxZoom), n2 = Math.max(o2 - i3, r2);
  52908. this._setZoom(this._zoomFromMercatorZ(n2));
  52909. }
  52910. get padding() {
  52911. return this._edgeInsets.toJSON();
  52912. }
  52913. set padding(e2) {
  52914. this._edgeInsets.equals(e2) || (this._unmodified = false, this._edgeInsets.interpolate(this._edgeInsets, e2, 1), this._calcMatrices());
  52915. }
  52916. computeZoomRelativeTo(t2) {
  52917. const i3 = this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint, t2.toAltitude()));
  52918. let o2;
  52919. o2 = t2.z < this._camera.position[2] ? [i3.x, i3.y, i3.z] : [t2.x, t2.y, t2.z];
  52920. const r2 = e.length(e.sub([], this._camera.position, o2));
  52921. return e.clamp(this._zoomFromMercatorZ(r2), this._minZoom, this._maxZoom);
  52922. }
  52923. setFreeCameraOptions(t2) {
  52924. if (!this.height)
  52925. return;
  52926. if (!t2.position && !t2.orientation)
  52927. return;
  52928. this._updateCameraState();
  52929. let i3 = false;
  52930. if (t2.orientation && !e.exactEquals(t2.orientation, this._camera.orientation) && (i3 = this._setCameraOrientation(t2.orientation)), t2.position) {
  52931. const o2 = [t2.position.x, t2.position.y, t2.position.z];
  52932. e.exactEquals$1(o2, this._camera.position) || (this._setCameraPosition(o2), i3 = true);
  52933. }
  52934. i3 && (this._updateStateFromCamera(), this.recenterOnTerrain());
  52935. }
  52936. getFreeCameraOptions() {
  52937. this._updateCameraState();
  52938. const t2 = this._camera.position, i3 = new Ao();
  52939. return i3.position = new e.MercatorCoordinate(t2[0], t2[1], t2[2]), i3.orientation = this._camera.orientation, i3._elevation = this.elevation, i3._renderWorldCopies = this.renderWorldCopies, i3;
  52940. }
  52941. _setCameraOrientation(t2) {
  52942. if (!e.length$1(t2))
  52943. return false;
  52944. e.normalize$1(t2, t2);
  52945. const i3 = e.transformQuat([], [0, 0, -1], t2), o2 = e.transformQuat([], [0, -1, 0], t2);
  52946. if (o2[2] < 0)
  52947. return false;
  52948. const r2 = Po(i3, o2);
  52949. return !!r2 && (this._camera.orientation = r2, true);
  52950. }
  52951. _setCameraPosition(t2) {
  52952. const i3 = this.zoomScale(this.minZoom) * this.tileSize, o2 = this.zoomScale(this.maxZoom) * this.tileSize, r2 = this.cameraToCenterDistance;
  52953. t2[2] = e.clamp(t2[2], r2 / o2, r2 / i3), this._camera.position = t2;
  52954. }
  52955. get centerPoint() {
  52956. return this._edgeInsets.getCenter(this.width, this.height);
  52957. }
  52958. get fovAboveCenter() {
  52959. return this._fov * (0.5 + this.centerOffset.y / this.height);
  52960. }
  52961. isPaddingEqual(e2) {
  52962. return this._edgeInsets.equals(e2);
  52963. }
  52964. interpolatePadding(e2, t2, i3) {
  52965. this._unmodified = false, this._edgeInsets.interpolate(e2, t2, i3), this._constrain(), this._calcMatrices();
  52966. }
  52967. coveringZoomLevel(e2) {
  52968. const t2 = (e2.roundZoom ? Math.round : Math.floor)(this.zoom + this.scaleZoom(this.tileSize / e2.tileSize));
  52969. return Math.max(0, t2);
  52970. }
  52971. getVisibleUnwrappedCoordinates(t2) {
  52972. const i3 = [new e.UnwrappedTileID(0, t2)];
  52973. if (this.renderWorldCopies) {
  52974. const o2 = this.pointCoordinate(new e.pointGeometry(0, 0)), r2 = this.pointCoordinate(new e.pointGeometry(this.width, 0)), n2 = this.pointCoordinate(new e.pointGeometry(this.width, this.height)), a2 = this.pointCoordinate(new e.pointGeometry(0, this.height)), s2 = Math.floor(Math.min(o2.x, r2.x, n2.x, a2.x)), l2 = Math.floor(Math.max(o2.x, r2.x, n2.x, a2.x)), c2 = 1;
  52975. for (let o3 = s2 - c2; o3 <= l2 + c2; o3++)
  52976. 0 !== o3 && i3.push(new e.UnwrappedTileID(o3, t2));
  52977. }
  52978. return i3;
  52979. }
  52980. coveringTiles(t2) {
  52981. let i3 = this.coveringZoomLevel(t2);
  52982. const o2 = i3, r2 = this.elevation && !t2.isTerrainDEM, n2 = "mercator" === this.projection.name;
  52983. if (void 0 !== t2.minzoom && i3 < t2.minzoom)
  52984. return [];
  52985. void 0 !== t2.maxzoom && i3 > t2.maxzoom && (i3 = t2.maxzoom);
  52986. const a2 = this.locationCoordinate(this.center), s2 = this.center.lat, l2 = 1 << i3, c2 = [l2 * a2.x, l2 * a2.y, 0], h2 = "globe" === this.projection.name, _2 = !h2, u2 = e.Frustum.fromInvProjectionMatrix(this.invProjMatrix, this.worldSize, i3, _2), d2 = h2 ? this._camera.mercatorPosition : this.pointCoordinate(this.getCameraPoint()), p2 = l2 * e.mercatorZfromAltitude(1, this.center.lat), m2 = this._camera.position[2] / e.mercatorZfromAltitude(1, this.center.lat), f2 = [l2 * d2.x, l2 * d2.y, m2 * (_2 ? 1 : p2)], g2 = this.cameraToCenterDistance / t2.tileSize * (t2.roundZoom ? 1 : 0.502), v2 = this.pitch <= 60 && this._edgeInsets.top <= this._edgeInsets.bottom && !this._elevation && !this.projection.isReprojectedInTileSpace ? i3 : 0, x2 = t2.isTerrainDEM && this._elevation ? 1e4 * this._elevation.exaggeration() : this._centerAltitude, y2 = t2.isTerrainDEM ? -x2 : this._elevation ? this._elevation.getMinElevationBelowMSL() : 0, b2 = this.projection.isReprojectedInTileSpace ? ko(this) : 1, w2 = (t3) => {
  52987. const i4 = 1 / 4e4, o3 = new e.MercatorCoordinate(t3.x + i4, t3.y, t3.z), r3 = new e.MercatorCoordinate(t3.x, t3.y + i4, t3.z), n3 = t3.toLngLat(), a3 = o3.toLngLat(), s3 = r3.toLngLat(), l3 = this.locationCoordinate(n3), c3 = this.locationCoordinate(a3), h3 = this.locationCoordinate(s3), _3 = Math.hypot(c3.x - l3.x, c3.y - l3.y), u3 = Math.hypot(h3.x - l3.x, h3.y - l3.y);
  52988. return Math.sqrt(_3 * u3) * b2 / i4;
  52989. }, T2 = (t3) => {
  52990. const i4 = x2, o3 = y2;
  52991. return { aabb: e.tileAABB(this, l2, 0, 0, 0, t3, o3, i4, this.projection), zoom: 0, x: 0, y: 0, minZ: o3, maxZ: i4, wrap: t3, fullyVisible: false };
  52992. }, E2 = [];
  52993. let C2 = [];
  52994. const I2 = i3, M2 = t2.reparseOverscaled ? o2 : i3, S2 = (e2) => e2 * e2, z2 = S2((m2 - this._centerAltitude) * p2), D2 = (e2) => {
  52995. if (!this._elevation || !e2.tileID || !n2)
  52996. return;
  52997. const t3 = this._elevation.getMinMaxForTile(e2.tileID), i4 = e2.aabb;
  52998. t3 ? (i4.min[2] = t3.min, i4.max[2] = t3.max, i4.center[2] = (i4.min[2] + i4.max[2]) / 2) : (e2.shouldSplit = P2(e2), e2.shouldSplit || (i4.min[2] = i4.max[2] = i4.center[2] = this._centerAltitude));
  52999. }, P2 = (t3) => {
  53000. if (t3.zoom < v2)
  53001. return true;
  53002. if (t3.zoom === I2)
  53003. return false;
  53004. if (null != t3.shouldSplit)
  53005. return t3.shouldSplit;
  53006. const i4 = t3.aabb.distanceX(f2), n3 = t3.aabb.distanceY(f2);
  53007. let a3 = z2, l3 = 1;
  53008. if (h2) {
  53009. a3 = S2(t3.aabb.distanceZ(f2));
  53010. const i5 = Math.pow(2, t3.zoom), o3 = e.latFromMercatorY((t3.y + 1) / i5), r3 = e.latFromMercatorY(t3.y / i5), n4 = Math.min(Math.max(s2, o3), r3), c4 = e.circumferenceAtLatitude(n4) / e.circumferenceAtLatitude(s2);
  53011. l3 = Math.min(c4, 1);
  53012. } else if (r2 && (a3 = S2(t3.aabb.distanceZ(f2) * p2)), this.projection.isReprojectedInTileSpace && o2 <= 5) {
  53013. const i5 = Math.pow(2, t3.zoom), o3 = w2(new e.MercatorCoordinate((t3.x + 0.5) / i5, (t3.y + 0.5) / i5));
  53014. l3 = o3 > 0.85 ? 1 : o3;
  53015. }
  53016. const c3 = i4 * i4 + n3 * n3 + a3;
  53017. return c3 < S2((1 << I2 - t3.zoom) * g2 * l3 * ((e2, t4) => {
  53018. if (t4 * S2(0.707) < e2)
  53019. return 1;
  53020. const i5 = Math.sqrt(t4 / e2);
  53021. return i5 / (1.4144271570014144 + (Math.pow(1.1, i5 - 1.4144271570014144 + 1) - 1) / (1.1 - 1) - 1);
  53022. })(Math.max(a3, z2), c3));
  53023. };
  53024. if (this.renderWorldCopies)
  53025. for (let e2 = 1; e2 <= 3; e2++)
  53026. E2.push(T2(-e2)), E2.push(T2(e2));
  53027. for (E2.push(T2(0)); E2.length > 0; ) {
  53028. const o3 = E2.pop(), a3 = o3.x, s3 = o3.y;
  53029. let _3 = o3.fullyVisible;
  53030. if (!_3) {
  53031. const e2 = o3.aabb.intersects(u2);
  53032. if (0 === e2)
  53033. continue;
  53034. _3 = 2 === e2;
  53035. }
  53036. if (o3.zoom !== I2 && P2(o3))
  53037. for (let t3 = 0; t3 < 4; t3++) {
  53038. const i4 = (a3 << 1) + t3 % 2, c3 = (s3 << 1) + (t3 >> 1), u3 = { aabb: n2 ? o3.aabb.quadrant(t3) : e.tileAABB(this, l2, o3.zoom + 1, i4, c3, o3.wrap, o3.minZ, o3.maxZ, this.projection), zoom: o3.zoom + 1, x: i4, y: c3, wrap: o3.wrap, fullyVisible: _3, tileID: void 0, shouldSplit: void 0, minZ: o3.minZ, maxZ: o3.maxZ };
  53039. r2 && !h2 && (u3.tileID = new e.OverscaledTileID(o3.zoom + 1 === I2 ? M2 : o3.zoom + 1, o3.wrap, o3.zoom + 1, i4, c3), D2(u3)), E2.push(u3);
  53040. }
  53041. else {
  53042. const r3 = o3.zoom === I2 ? M2 : o3.zoom;
  53043. if (t2.minzoom && t2.minzoom > r3)
  53044. continue;
  53045. const n3 = c2[0] - (0.5 + a3 + (o3.wrap << o3.zoom)) * (1 << i3 - o3.zoom), l3 = c2[1] - 0.5 - s3, h3 = o3.tileID ? o3.tileID : new e.OverscaledTileID(r3, o3.wrap, o3.zoom, a3, s3);
  53046. C2.push({ tileID: h3, distanceSq: n3 * n3 + l3 * l3 });
  53047. }
  53048. }
  53049. if (this.fogCullDistSq) {
  53050. const i4 = this.fogCullDistSq, o3 = this.horizonLineFromTop();
  53051. C2 = C2.filter((r3) => {
  53052. const n3 = [0, 0, 0, 1], a3 = [e.EXTENT, e.EXTENT, 0, 1], s3 = this.calculateFogTileMatrix(r3.tileID.toUnwrapped());
  53053. e.transformMat4$1(n3, n3, s3), e.transformMat4$1(a3, a3, s3);
  53054. const l3 = e.getAABBPointSquareDist(n3, a3);
  53055. if (0 === l3)
  53056. return true;
  53057. let c3 = false;
  53058. const h3 = this._elevation;
  53059. if (h3 && l3 > i4 && 0 !== o3) {
  53060. const i5 = this.calculateProjMatrix(r3.tileID.toUnwrapped());
  53061. let n4;
  53062. t2.isTerrainDEM || (n4 = h3.getMinMaxForTile(r3.tileID)), n4 || (n4 = { min: y2, max: x2 });
  53063. const a4 = e.furthestTileCorner(this.rotation), s4 = [a4[0] * e.EXTENT, a4[1] * e.EXTENT, n4.max];
  53064. e.transformMat4(s4, s4, i5), c3 = (1 - s4[1]) * this.height * 0.5 < o3;
  53065. }
  53066. return l3 < i4 || c3;
  53067. });
  53068. }
  53069. return C2.sort((e2, t3) => e2.distanceSq - t3.distanceSq).map((e2) => e2.tileID);
  53070. }
  53071. resize(e2, t2) {
  53072. this.width = e2, this.height = t2, this.pixelsToGLUnits = [2 / e2, -2 / t2], this._constrain(), this._calcMatrices();
  53073. }
  53074. get unmodified() {
  53075. return this._unmodified;
  53076. }
  53077. zoomScale(e2) {
  53078. return Math.pow(2, e2);
  53079. }
  53080. scaleZoom(e2) {
  53081. return Math.log(e2) / Math.LN2;
  53082. }
  53083. project(t2) {
  53084. const i3 = e.clamp(t2.lat, -e.MAX_MERCATOR_LATITUDE, e.MAX_MERCATOR_LATITUDE), o2 = this.projection.project(t2.lng, i3);
  53085. return new e.pointGeometry(o2.x * this.worldSize, o2.y * this.worldSize);
  53086. }
  53087. unproject(e2) {
  53088. return this.projection.unproject(e2.x / this.worldSize, e2.y / this.worldSize);
  53089. }
  53090. get point() {
  53091. return this.project(this.center);
  53092. }
  53093. setLocationAtPoint(t2, i3) {
  53094. let o2, r2;
  53095. const n2 = this.centerPoint;
  53096. if ("globe" === this.projection.name) {
  53097. const e2 = this.worldSize;
  53098. o2 = (i3.x - n2.x) / e2, r2 = (i3.y - n2.y) / e2;
  53099. } else {
  53100. const e2 = this.pointCoordinate(i3), t3 = this.pointCoordinate(n2);
  53101. o2 = e2.x - t3.x, r2 = e2.y - t3.y;
  53102. }
  53103. const a2 = this.locationCoordinate(t2);
  53104. this.setLocation(new e.MercatorCoordinate(a2.x - o2, a2.y - r2));
  53105. }
  53106. setLocation(e2) {
  53107. this.center = this.coordinateLocation(e2), this.projection.wrap && (this.center = this.center.wrap());
  53108. }
  53109. locationPoint(e2) {
  53110. return this.projection.locationPoint(this, e2);
  53111. }
  53112. locationPoint3D(e2) {
  53113. return this._coordinatePoint(this.locationCoordinate(e2), true);
  53114. }
  53115. pointLocation(e2) {
  53116. return this.coordinateLocation(this.pointCoordinate(e2));
  53117. }
  53118. pointLocation3D(e2) {
  53119. return this.coordinateLocation(this.pointCoordinate3D(e2));
  53120. }
  53121. locationCoordinate(t2, i3) {
  53122. const o2 = i3 ? e.mercatorZfromAltitude(i3, t2.lat) : void 0, r2 = this.projection.project(t2.lng, t2.lat);
  53123. return new e.MercatorCoordinate(r2.x, r2.y, o2);
  53124. }
  53125. coordinateLocation(e2) {
  53126. return this.projection.unproject(e2.x, e2.y);
  53127. }
  53128. pointRayIntersection(t2, i3) {
  53129. const o2 = null != i3 ? i3 : this._centerAltitude, r2 = [t2.x, t2.y, 0, 1], n2 = [t2.x, t2.y, 1, 1];
  53130. e.transformMat4$1(r2, r2, this.pixelMatrixInverse), e.transformMat4$1(n2, n2, this.pixelMatrixInverse);
  53131. const a2 = n2[3];
  53132. e.scale$1(r2, r2, 1 / r2[3]), e.scale$1(n2, n2, 1 / a2);
  53133. const s2 = r2[2], l2 = n2[2];
  53134. return { p0: r2, p1: n2, t: s2 === l2 ? 0 : (o2 - s2) / (l2 - s2) };
  53135. }
  53136. screenPointToMercatorRay(t2) {
  53137. const i3 = [t2.x, t2.y, 0, 1], o2 = [t2.x, t2.y, 1, 1];
  53138. return e.transformMat4$1(i3, i3, this.pixelMatrixInverse), e.transformMat4$1(o2, o2, this.pixelMatrixInverse), e.scale$1(i3, i3, 1 / i3[3]), e.scale$1(o2, o2, 1 / o2[3]), i3[2] = e.mercatorZfromAltitude(i3[2], this._center.lat) * this.worldSize, o2[2] = e.mercatorZfromAltitude(o2[2], this._center.lat) * this.worldSize, e.scale$1(i3, i3, 1 / this.worldSize), e.scale$1(o2, o2, 1 / this.worldSize), new e.Ray([i3[0], i3[1], i3[2]], e.normalize([], e.sub([], o2, i3)));
  53139. }
  53140. rayIntersectionCoordinate(t2) {
  53141. const { p0: i3, p1: o2, t: r2 } = t2, n2 = e.mercatorZfromAltitude(i3[2], this._center.lat), a2 = e.mercatorZfromAltitude(o2[2], this._center.lat);
  53142. return new e.MercatorCoordinate(e.number(i3[0], o2[0], r2) / this.worldSize, e.number(i3[1], o2[1], r2) / this.worldSize, e.number(n2, a2, r2));
  53143. }
  53144. pointCoordinate(e2, t2 = this._centerAltitude) {
  53145. return this.projection.pointCoordinate(this, e2.x, e2.y, t2);
  53146. }
  53147. pointCoordinate3D(t2) {
  53148. if (!this.elevation)
  53149. return this.pointCoordinate(t2);
  53150. const i3 = this.elevation;
  53151. let o2 = this.elevation.pointCoordinate(t2);
  53152. if (o2)
  53153. return new e.MercatorCoordinate(o2[0], o2[1], o2[2]);
  53154. let r2 = 0, n2 = this.horizonLineFromTop();
  53155. if (t2.y > n2)
  53156. return this.pointCoordinate(t2);
  53157. const a2 = 0.02 * n2, s2 = t2.clone();
  53158. for (let t3 = 0; t3 < 10 && n2 - r2 > a2; t3++) {
  53159. s2.y = e.number(r2, n2, 0.66);
  53160. const t4 = i3.pointCoordinate(s2);
  53161. t4 ? (n2 = s2.y, o2 = t4) : r2 = s2.y;
  53162. }
  53163. return o2 ? new e.MercatorCoordinate(o2[0], o2[1], o2[2]) : this.pointCoordinate(t2);
  53164. }
  53165. isPointAboveHorizon(e2) {
  53166. if (this.elevation)
  53167. return !this.elevation.pointCoordinate(e2);
  53168. {
  53169. const t2 = this.horizonLineFromTop();
  53170. return e2.y < t2;
  53171. }
  53172. }
  53173. _coordinatePoint(t2, i3) {
  53174. const o2 = i3 && this.elevation ? this.elevation.getAtPointOrZero(t2, this._centerAltitude) : this._centerAltitude, r2 = [t2.x * this.worldSize, t2.y * this.worldSize, o2 + t2.toAltitude(), 1];
  53175. return e.transformMat4$1(r2, r2, this.pixelMatrix), r2[3] > 0 ? new e.pointGeometry(r2[0] / r2[3], r2[1] / r2[3]) : new e.pointGeometry(Number.MAX_VALUE, Number.MAX_VALUE);
  53176. }
  53177. _getBounds(t2, i3) {
  53178. const o2 = new e.pointGeometry(this._edgeInsets.left, this._edgeInsets.top), r2 = new e.pointGeometry(this.width - this._edgeInsets.right, this._edgeInsets.top), n2 = new e.pointGeometry(this.width - this._edgeInsets.right, this.height - this._edgeInsets.bottom), a2 = new e.pointGeometry(this._edgeInsets.left, this.height - this._edgeInsets.bottom);
  53179. let s2 = this.pointCoordinate(o2, t2), l2 = this.pointCoordinate(r2, t2);
  53180. const c2 = this.pointCoordinate(n2, i3), h2 = this.pointCoordinate(a2, i3), _2 = (e2, t3) => (t3.y - e2.y) / (t3.x - e2.x);
  53181. return s2.y > 1 && l2.y >= 0 ? s2 = new e.MercatorCoordinate((1 - h2.y) / _2(h2, s2) + h2.x, 1) : s2.y < 0 && l2.y <= 1 && (s2 = new e.MercatorCoordinate(-h2.y / _2(h2, s2) + h2.x, 0)), l2.y > 1 && s2.y >= 0 ? l2 = new e.MercatorCoordinate((1 - c2.y) / _2(c2, l2) + c2.x, 1) : l2.y < 0 && s2.y <= 1 && (l2 = new e.MercatorCoordinate(-c2.y / _2(c2, l2) + c2.x, 0)), new e.LngLatBounds().extend(this.coordinateLocation(s2)).extend(this.coordinateLocation(l2)).extend(this.coordinateLocation(h2)).extend(this.coordinateLocation(c2));
  53182. }
  53183. _getBounds3D() {
  53184. const e2 = this.elevation;
  53185. if (!e2.visibleDemTiles.length)
  53186. return this._getBounds(0, 0);
  53187. const t2 = e2.visibleDemTiles.reduce((e3, t3) => {
  53188. if (t3.dem) {
  53189. const i3 = t3.dem.tree;
  53190. e3.min = Math.min(e3.min, i3.minimums[0]), e3.max = Math.max(e3.max, i3.maximums[0]);
  53191. }
  53192. return e3;
  53193. }, { min: Number.MAX_VALUE, max: 0 });
  53194. return this._getBounds(t2.min * e2.exaggeration(), t2.max * e2.exaggeration());
  53195. }
  53196. getBounds() {
  53197. return this._terrainEnabled() ? this._getBounds3D() : this._getBounds(0, 0);
  53198. }
  53199. horizonLineFromTop(e2 = true) {
  53200. const t2 = this.height / 2 / Math.tan(this._fov / 2) / Math.tan(Math.max(this._pitch, 0.1)) + this.centerOffset.y, i3 = this.height / 2 - t2 * (1 - this._horizonShift);
  53201. return e2 ? Math.max(0, i3) : i3;
  53202. }
  53203. getMaxBounds() {
  53204. return this.maxBounds;
  53205. }
  53206. setMaxBounds(t2) {
  53207. this.maxBounds = t2, this.minLat = -e.MAX_MERCATOR_LATITUDE, this.maxLat = e.MAX_MERCATOR_LATITUDE, this.minLng = -180, this.maxLng = 180, t2 && (this.minLat = t2.getSouth(), this.maxLat = t2.getNorth(), this.minLng = t2.getWest(), this.maxLng = t2.getEast(), this.maxLng < this.minLng && (this.maxLng += 360)), this.worldMinX = e.mercatorXfromLng(this.minLng) * this.tileSize, this.worldMaxX = e.mercatorXfromLng(this.maxLng) * this.tileSize, this.worldMinY = e.mercatorYfromLat(this.maxLat) * this.tileSize, this.worldMaxY = e.mercatorYfromLat(this.minLat) * this.tileSize, this._constrain();
  53208. }
  53209. calculatePosMatrix(e2, t2) {
  53210. return this.projection.createTileMatrix(this, t2, e2);
  53211. }
  53212. calculateDistanceTileData(t2) {
  53213. const i3 = t2.key, o2 = this._distanceTileDataCache;
  53214. if (o2[i3])
  53215. return o2[i3];
  53216. const r2 = t2.canonical, n2 = 1 / this.height, a2 = this.cameraWorldSize / this.zoomScale(r2.z), s2 = (r2.x + Math.pow(2, r2.z) * t2.wrap) * a2, l2 = r2.y * a2, c2 = this.point, h2 = this.angle, _2 = Math.sin(-h2), u2 = -Math.cos(-h2);
  53217. return o2[i3] = { bearing: [_2, u2], center: [(c2.x - s2) * n2, (c2.y - l2) * n2], scale: a2 / e.EXTENT * n2 }, o2[i3];
  53218. }
  53219. calculateFogTileMatrix(t2) {
  53220. const i3 = t2.key, o2 = this._fogTileMatrixCache;
  53221. if (o2[i3])
  53222. return o2[i3];
  53223. const r2 = this.calculatePosMatrix(t2, this.cameraWorldSize);
  53224. return e.multiply$1(r2, this.worldToFogMatrix, r2), o2[i3] = new Float32Array(r2), o2[i3];
  53225. }
  53226. calculateProjMatrix(t2, i3 = false) {
  53227. const o2 = t2.key, r2 = i3 ? this._alignedProjMatrixCache : this._projMatrixCache;
  53228. if (r2[o2])
  53229. return r2[o2];
  53230. const n2 = this.calculatePosMatrix(t2, this.worldSize);
  53231. return e.multiply$1(n2, this.projection.isReprojectedInTileSpace ? this.mercatorMatrix : i3 ? this.alignedProjMatrix : this.projMatrix, n2), r2[o2] = new Float32Array(n2), r2[o2];
  53232. }
  53233. calculatePixelsToTileUnitsMatrix(t2) {
  53234. const i3 = t2.tileID.key, o2 = this._pixelsToTileUnitsCache;
  53235. if (o2[i3])
  53236. return o2[i3];
  53237. const r2 = function(t3, i4) {
  53238. const { scale: o3 } = t3.tileTransform, r3 = o3 * e.EXTENT / (t3.tileSize * Math.pow(2, i4.zoom - t3.tileID.overscaledZ + t3.tileID.canonical.z));
  53239. return n2 = new Float32Array(4), l2 = (a2 = i4.inverseAdjustmentMatrix)[1], c2 = a2[2], h2 = a2[3], u2 = (s2 = [r3, r3])[1], n2[0] = a2[0] * (_2 = s2[0]), n2[1] = l2 * _2, n2[2] = c2 * u2, n2[3] = h2 * u2, n2;
  53240. var n2, a2, s2, l2, c2, h2, _2, u2;
  53241. }(t2, this);
  53242. return o2[i3] = r2, o2[i3];
  53243. }
  53244. customLayerMatrix() {
  53245. return this.mercatorMatrix.slice();
  53246. }
  53247. recenterOnTerrain() {
  53248. if (!this._elevation)
  53249. return;
  53250. const t2 = this._elevation;
  53251. this._updateCameraState();
  53252. const i3 = e.mercatorZfromAltitude(1, this._center.lat) * this.worldSize, o2 = this._computeCameraPosition(i3), r2 = this._camera.forward(), n2 = e.mercatorZfromAltitude(1, this._center.lat);
  53253. o2[2] /= n2, r2[2] /= n2, e.normalize(r2, r2);
  53254. const a2 = t2.raycast(o2, r2, t2.exaggeration());
  53255. if (a2) {
  53256. const t3 = e.scaleAndAdd([], o2, r2, a2), i4 = new e.MercatorCoordinate(t3[0], t3[1], e.mercatorZfromAltitude(t3[2], e.latFromMercatorY(t3[1]))), s2 = (i4.z + e.length([i4.x - o2[0], i4.y - o2[1], i4.z - o2[2] * n2])) * this._projectionScaler;
  53257. this._seaLevelZoom = this._zoomFromMercatorZ(s2), this._centerAltitude = i4.toAltitude(), this._center = this.coordinateLocation(i4), this._updateZoomFromElevation(), this._constrain(), this._calcMatrices();
  53258. }
  53259. }
  53260. _constrainCameraAltitude() {
  53261. if (!this._elevation)
  53262. return;
  53263. const t2 = this._elevation;
  53264. this._updateCameraState();
  53265. const i3 = e.mercatorZfromAltitude(1, this._center.lat) * this.worldSize, o2 = this._computeCameraPosition(i3), r2 = t2.getAtPointOrZero(new e.MercatorCoordinate(...o2)), n2 = this._minimumHeightOverTerrain() * Math.cos(e.degToRad(this._maxPitch)), a2 = this._camera.position[2] - this.pixelsPerMeter / this.worldSize * r2;
  53266. if (a2 < n2) {
  53267. const t3 = this.locationCoordinate(this._center, this._centerAltitude), i4 = [t3.x - o2[0], t3.y - o2[1], t3.z - o2[2]], r3 = e.length(i4);
  53268. i4[2] -= (n2 - a2) / this._projectionScaler;
  53269. const s2 = e.length(i4);
  53270. if (0 === s2)
  53271. return;
  53272. e.scale$2(i4, i4, r3 / s2 * this._projectionScaler), this._camera.position = [t3.x - i4[0], t3.y - i4[1], t3.z * this._projectionScaler - i4[2]], this._camera.orientation = Po(i4, this._camera.up()), this._updateStateFromCamera();
  53273. }
  53274. }
  53275. _constrain() {
  53276. if (!this.center || !this.width || !this.height || this._constraining)
  53277. return;
  53278. if (this._constraining = true, this.projection.isReprojectedInTileSpace) {
  53279. const t3 = this.center;
  53280. return t3.lat = e.clamp(t3.lat, this.minLat, this.maxLat), !this.maxBounds && this.renderWorldCopies || (t3.lng = e.clamp(t3.lng, this.minLng, this.maxLng)), this.center = t3, void (this._constraining = false);
  53281. }
  53282. const t2 = this._unmodified, { x: i3, y: o2 } = this.point;
  53283. let r2 = 0, n2 = i3, a2 = o2;
  53284. const s2 = this.width / 2, l2 = this.height / 2, c2 = this.worldMinY * this.scale, h2 = this.worldMaxY * this.scale;
  53285. if (o2 - l2 < c2 && (a2 = c2 + l2), o2 + l2 > h2 && (a2 = h2 - l2), h2 - c2 < this.height && (r2 = Math.max(r2, this.height / (h2 - c2)), a2 = (h2 + c2) / 2), this.maxBounds || !this._renderWorldCopies || !this.projection.wrap) {
  53286. const e2 = this.worldMinX * this.scale, t3 = this.worldMaxX * this.scale, o3 = this.worldSize / 2 - (e2 + t3) / 2;
  53287. n2 = (i3 + o3 + this.worldSize) % this.worldSize - o3, n2 - s2 < e2 && (n2 = e2 + s2), n2 + s2 > t3 && (n2 = t3 - s2), t3 - e2 < this.width && (r2 = Math.max(r2, this.width / (t3 - e2)), n2 = (t3 + e2) / 2);
  53288. }
  53289. n2 === i3 && a2 === o2 || (this.center = this.unproject(new e.pointGeometry(n2, a2))), r2 && (this.zoom += this.scaleZoom(r2)), this._constrainCameraAltitude(), this._unmodified = t2, this._constraining = false;
  53290. }
  53291. _minZoomForBounds() {
  53292. let e2 = Math.max(0, this.scaleZoom(this.height / (this.worldMaxY - this.worldMinY)));
  53293. return this.maxBounds && (e2 = Math.max(e2, this.scaleZoom(this.width / (this.worldMaxX - this.worldMinX)))), e2;
  53294. }
  53295. _maxCameraBoundsDistance() {
  53296. return this._mercatorZfromZoom(this._minZoomForBounds());
  53297. }
  53298. _calcMatrices() {
  53299. if (!this.height)
  53300. return;
  53301. const t2 = this._fov / 2, i3 = this.centerOffset, o2 = this.pixelsPerMeter;
  53302. this._projectionScaler = o2 / (e.mercatorZfromAltitude(1, this.center.lat) * this.worldSize), this.cameraToCenterDistance = 0.5 / Math.tan(t2) * this.height * this._projectionScaler, this._updateCameraState(), this._farZ = this.projection.farthestPixelDistance(this), this._nearZ = this.height / 50;
  53303. const r2 = this._camera.getWorldToCamera(this.worldSize, "meters" === this.projection.zAxisUnit ? o2 : 1), n2 = this._camera.getCameraToClipPerspective(this._fov, this.width / this.height, this._nearZ, this._farZ);
  53304. n2[8] = 2 * -i3.x / this.width, n2[9] = 2 * i3.y / this.height;
  53305. let a2 = e.mul([], n2, r2);
  53306. if (this.projection.isReprojectedInTileSpace) {
  53307. const t3 = this.locationCoordinate(this.center), i4 = e.identity([]);
  53308. e.translate(i4, i4, [t3.x * this.worldSize, t3.y * this.worldSize, 0]), e.multiply$1(i4, i4, Ro(this)), e.translate(i4, i4, [-t3.x * this.worldSize, -t3.y * this.worldSize, 0]), e.multiply$1(a2, a2, i4), this.inverseAdjustmentMatrix = function(e2) {
  53309. const t4 = Ro(e2, true);
  53310. return v([], [t4[0], t4[1], t4[4], t4[5]]);
  53311. }(this);
  53312. } else
  53313. this.inverseAdjustmentMatrix = [1, 0, 0, 1];
  53314. this.mercatorMatrix = e.scale([], a2, [this.worldSize, this.worldSize, this.worldSize / o2, 1]), this.projMatrix = a2, this.invProjMatrix = e.invert(new Float64Array(16), this.projMatrix);
  53315. const s2 = new Float32Array(16);
  53316. e.identity(s2), e.scale(s2, s2, [1, -1, 1]), e.rotateX(s2, s2, this._pitch), e.rotateZ(s2, s2, this.angle);
  53317. const l2 = e.perspective(new Float32Array(16), this._fov, this.width / this.height, this._nearZ, this._farZ), c2 = (Math.PI / 2 - this._pitch) * (this.height / this._fov) * this._horizonShift;
  53318. l2[8] = 2 * -i3.x / this.width, l2[9] = 2 * (i3.y + c2) / this.height, this.skyboxMatrix = e.multiply$1(s2, l2, s2);
  53319. const h2 = this.point, _2 = h2.x, u2 = h2.y, d2 = this.width % 2 / 2, p2 = this.height % 2 / 2, m2 = Math.cos(this.angle), f2 = Math.sin(this.angle), g2 = _2 - Math.round(_2) + m2 * d2 + f2 * p2, x2 = u2 - Math.round(u2) + m2 * p2 + f2 * d2, y2 = new Float64Array(a2);
  53320. if (e.translate(y2, y2, [g2 > 0.5 ? g2 - 1 : g2, x2 > 0.5 ? x2 - 1 : x2, 0]), this.alignedProjMatrix = y2, a2 = e.create(), e.scale(a2, a2, [this.width / 2, -this.height / 2, 1]), e.translate(a2, a2, [1, -1, 0]), this.labelPlaneMatrix = a2, a2 = e.create(), e.scale(a2, a2, [1, -1, 1]), e.translate(a2, a2, [-1, -1, 0]), e.scale(a2, a2, [2 / this.width, 2 / this.height, 1]), this.glCoordMatrix = a2, this.pixelMatrix = e.multiply$1(new Float64Array(16), this.labelPlaneMatrix, this.projMatrix), this._calcFogMatrices(), this._distanceTileDataCache = {}, a2 = e.invert(new Float64Array(16), this.pixelMatrix), !a2)
  53321. throw new Error("failed to invert matrix");
  53322. this.pixelMatrixInverse = a2, this.globeMatrix = "globe" === this.projection.name ? e.calculateGlobeMatrix(this) : a2, this._projMatrixCache = {}, this._alignedProjMatrixCache = {}, this._pixelsToTileUnitsCache = {};
  53323. }
  53324. _calcFogMatrices() {
  53325. this._fogTileMatrixCache = {};
  53326. const t2 = this.cameraWorldSize, i3 = this.cameraPixelsPerMeter, o2 = this._camera.position, r2 = 1 / this.height, n2 = [t2, t2, i3];
  53327. e.scale$2(n2, n2, r2), e.scale$2(o2, o2, -1), e.multiply$2(o2, o2, n2);
  53328. const a2 = e.create();
  53329. e.translate(a2, a2, o2), e.scale(a2, a2, n2), this.mercatorFogMatrix = a2, this.worldToFogMatrix = this._camera.getWorldToCameraPosition(t2, i3, r2);
  53330. }
  53331. _computeCameraPosition(e2) {
  53332. const t2 = (e2 = e2 || this.pixelsPerMeter) / this.pixelsPerMeter, i3 = this._camera.forward(), o2 = this.point, r2 = this._mercatorZfromZoom(this._seaLevelZoom ? this._seaLevelZoom : this._zoom) * t2 - e2 / this.worldSize * this._centerAltitude;
  53333. return [o2.x / this.worldSize - i3[0] * r2, o2.y / this.worldSize - i3[1] * r2, e2 / this.worldSize * this._centerAltitude - i3[2] * r2];
  53334. }
  53335. _updateCameraState() {
  53336. this.height && (this._camera.setPitchBearing(this._pitch, this.angle), this._camera.position = this._computeCameraPosition());
  53337. }
  53338. _translateCameraConstrained(t2) {
  53339. const i3 = this._maxCameraBoundsDistance() * Math.cos(this._pitch), o2 = t2[2];
  53340. let r2 = 1;
  53341. o2 > 0 && (r2 = Math.min((i3 - this._camera.position[2]) / o2, 1)), this._camera.position = e.scaleAndAdd([], this._camera.position, t2, r2), this._updateStateFromCamera(), this.projection.wrap && (this.center = this.center.wrap());
  53342. }
  53343. _updateStateFromCamera() {
  53344. const t2 = this._camera.position, i3 = this._camera.forward(), { pitch: o2, bearing: r2 } = this._camera.getPitchBearing(), n2 = e.mercatorZfromAltitude(this._centerAltitude, this.center.lat) * this._projectionScaler, a2 = this._mercatorZfromZoom(this._maxZoom) * Math.cos(e.degToRad(this._maxPitch)), s2 = Math.max((t2[2] - n2) / Math.cos(o2), a2), l2 = this._zoomFromMercatorZ(s2);
  53345. e.scaleAndAdd(t2, t2, i3, s2), this._pitch = e.clamp(o2, e.degToRad(this.minPitch), e.degToRad(this.maxPitch)), this.angle = e.wrap(r2, -Math.PI, Math.PI), this._setZoom(e.clamp(l2, this._minZoom, this._maxZoom)), this._updateSeaLevelZoom(), this._center = this.coordinateLocation(new e.MercatorCoordinate(t2[0], t2[1], t2[2])), this._unmodified = false, this._constrain(), this._calcMatrices();
  53346. }
  53347. _worldSizeFromZoom(e2) {
  53348. return Math.pow(2, e2) * this.tileSize;
  53349. }
  53350. _mercatorZfromZoom(e2) {
  53351. return this.cameraToCenterDistance / this._worldSizeFromZoom(e2);
  53352. }
  53353. _minimumHeightOverTerrain() {
  53354. const e2 = Math.min((null != this._seaLevelZoom ? this._seaLevelZoom : this._zoom) + 2, this._maxZoom);
  53355. return this._mercatorZfromZoom(e2);
  53356. }
  53357. _zoomFromMercatorZ(e2) {
  53358. return this.scaleZoom(this.cameraToCenterDistance / (e2 * this.tileSize));
  53359. }
  53360. _terrainEnabled() {
  53361. return !(!this._elevation || !this.projection.supportsTerrain && (e.warnOnce("Terrain is not yet supported with alternate projections. Use mercator to enable terrain."), 1));
  53362. }
  53363. anyCornerOffEdge(t2, i3) {
  53364. const o2 = Math.min(t2.x, i3.x), r2 = Math.max(t2.x, i3.x), n2 = Math.min(t2.y, i3.y), a2 = Math.max(t2.y, i3.y);
  53365. if (n2 < this.horizonLineFromTop(false))
  53366. return true;
  53367. if ("mercator" !== this.projection.name)
  53368. return false;
  53369. const s2 = [new e.pointGeometry(o2, n2), new e.pointGeometry(r2, a2), new e.pointGeometry(o2, a2), new e.pointGeometry(r2, n2)], l2 = this.renderWorldCopies ? -3 : 0, c2 = this.renderWorldCopies ? 4 : 1;
  53370. for (const e2 of s2) {
  53371. const t3 = this.pointRayIntersection(e2);
  53372. if (t3.t < 0)
  53373. return true;
  53374. const i4 = this.rayIntersectionCoordinate(t3);
  53375. if (i4.x < l2 || i4.y < 0 || i4.x > c2 || i4.y > 1)
  53376. return true;
  53377. }
  53378. return false;
  53379. }
  53380. isHorizonVisible() {
  53381. return this.pitch + e.radToDeg(this.fovAboveCenter) > 88 || this.anyCornerOffEdge(new e.pointGeometry(0, 0), new e.pointGeometry(this.width, this.height));
  53382. }
  53383. zoomDeltaToMovement(t2, i3) {
  53384. const o2 = e.length(e.sub([], this._camera.position, t2)), r2 = this._zoomFromMercatorZ(o2) + i3;
  53385. return o2 - this._mercatorZfromZoom(r2);
  53386. }
  53387. getCameraPoint() {
  53388. const t2 = Math.tan(this._pitch) * (this.cameraToCenterDistance || 1);
  53389. return this.centerPoint.add(new e.pointGeometry(0, t2));
  53390. }
  53391. }
  53392. function Go(e2, t2) {
  53393. let i3 = false, o2 = null;
  53394. const r2 = () => {
  53395. o2 = null, i3 && (e2(), o2 = setTimeout(r2, t2), i3 = false);
  53396. };
  53397. return () => (i3 = true, o2 || r2(), o2);
  53398. }
  53399. class jo {
  53400. constructor(t2) {
  53401. this._hashName = t2 && encodeURIComponent(t2), e.bindAll(["_getCurrentHash", "_onHashChange", "_updateHash"], this), this._updateHash = Go(this._updateHashUnthrottled.bind(this), 300);
  53402. }
  53403. addTo(t2) {
  53404. return this._map = t2, e.window.addEventListener("hashchange", this._onHashChange, false), t2.on("moveend", this._updateHash), this;
  53405. }
  53406. remove() {
  53407. return this._map ? (this._map.off("moveend", this._updateHash), e.window.removeEventListener("hashchange", this._onHashChange, false), clearTimeout(this._updateHash()), this._map = void 0, this) : this;
  53408. }
  53409. getHashString(t2) {
  53410. const i3 = this._map;
  53411. if (!i3)
  53412. return "";
  53413. const o2 = i3.getCenter(), r2 = Math.round(100 * i3.getZoom()) / 100, n2 = Math.ceil((r2 * Math.LN2 + Math.log(512 / 360 / 0.5)) / Math.LN10), a2 = Math.pow(10, n2), s2 = Math.round(o2.lng * a2) / a2, l2 = Math.round(o2.lat * a2) / a2, c2 = i3.getBearing(), h2 = i3.getPitch();
  53414. let _2 = "";
  53415. if (_2 += t2 ? `/${s2}/${l2}/${r2}` : `${r2}/${l2}/${s2}`, (c2 || h2) && (_2 += "/" + Math.round(10 * c2) / 10), h2 && (_2 += `/${Math.round(h2)}`), this._hashName) {
  53416. const t3 = this._hashName;
  53417. let i4 = false;
  53418. const o3 = e.window.location.hash.slice(1).split("&").map((e2) => {
  53419. const o4 = e2.split("=")[0];
  53420. return o4 === t3 ? (i4 = true, `${o4}=${_2}`) : e2;
  53421. }).filter((e2) => e2);
  53422. return i4 || o3.push(`${t3}=${_2}`), `#${o3.join("&")}`;
  53423. }
  53424. return `#${_2}`;
  53425. }
  53426. _getCurrentHash() {
  53427. const t2 = e.window.location.hash.replace("#", "");
  53428. if (this._hashName) {
  53429. let e2;
  53430. return t2.split("&").map((e3) => e3.split("=")).forEach((t3) => {
  53431. t3[0] === this._hashName && (e2 = t3);
  53432. }), (e2 && e2[1] || "").split("/");
  53433. }
  53434. return t2.split("/");
  53435. }
  53436. _onHashChange() {
  53437. const e2 = this._map;
  53438. if (!e2)
  53439. return false;
  53440. const t2 = this._getCurrentHash();
  53441. if (t2.length >= 3 && !t2.some((e3) => isNaN(e3))) {
  53442. const i3 = e2.dragRotate.isEnabled() && e2.touchZoomRotate.isEnabled() ? +(t2[3] || 0) : e2.getBearing();
  53443. return e2.jumpTo({ center: [+t2[2], +t2[1]], zoom: +t2[0], bearing: i3, pitch: +(t2[4] || 0) }), true;
  53444. }
  53445. return false;
  53446. }
  53447. _updateHashUnthrottled() {
  53448. const t2 = e.window.location.href.replace(/(#.+)?$/, this.getHashString());
  53449. e.window.history.replaceState(e.window.history.state, null, t2);
  53450. }
  53451. }
  53452. const Zo = { linearity: 0.3, easing: e.bezier(0, 0, 0.3, 1) }, Vo = e.extend({ deceleration: 2500, maxSpeed: 1400 }, Zo), Wo = e.extend({ deceleration: 20, maxSpeed: 1400 }, Zo), qo = e.extend({ deceleration: 1e3, maxSpeed: 360 }, Zo), Xo = e.extend({ deceleration: 1e3, maxSpeed: 90 }, Zo);
  53453. class $o {
  53454. constructor(e2) {
  53455. this._map = e2, this.clear();
  53456. }
  53457. clear() {
  53458. this._inertiaBuffer = [];
  53459. }
  53460. record(t2) {
  53461. this._drainInertiaBuffer(), this._inertiaBuffer.push({ time: e.exported.now(), settings: t2 });
  53462. }
  53463. _drainInertiaBuffer() {
  53464. const t2 = this._inertiaBuffer, i3 = e.exported.now();
  53465. for (; t2.length > 0 && i3 - t2[0].time > 160; )
  53466. t2.shift();
  53467. }
  53468. _onMoveEnd(t2) {
  53469. if (this._drainInertiaBuffer(), this._inertiaBuffer.length < 2)
  53470. return;
  53471. const i3 = { zoom: 0, bearing: 0, pitch: 0, pan: new e.pointGeometry(0, 0), pinchAround: void 0, around: void 0 };
  53472. for (const { settings: e2 } of this._inertiaBuffer)
  53473. i3.zoom += e2.zoomDelta || 0, i3.bearing += e2.bearingDelta || 0, i3.pitch += e2.pitchDelta || 0, e2.panDelta && i3.pan._add(e2.panDelta), e2.around && (i3.around = e2.around), e2.pinchAround && (i3.pinchAround = e2.pinchAround);
  53474. const o2 = this._inertiaBuffer[this._inertiaBuffer.length - 1].time - this._inertiaBuffer[0].time, r2 = {};
  53475. if (i3.pan.mag()) {
  53476. const n2 = Ko(i3.pan.mag(), o2, e.extend({}, Vo, t2 || {}));
  53477. r2.offset = i3.pan.mult(n2.amount / i3.pan.mag()), r2.center = this._map.transform.center, Ho(r2, n2);
  53478. }
  53479. if (i3.zoom) {
  53480. const e2 = Ko(i3.zoom, o2, Wo);
  53481. r2.zoom = this._map.transform.zoom + e2.amount, Ho(r2, e2);
  53482. }
  53483. if (i3.bearing) {
  53484. const t3 = Ko(i3.bearing, o2, qo);
  53485. r2.bearing = this._map.transform.bearing + e.clamp(t3.amount, -179, 179), Ho(r2, t3);
  53486. }
  53487. if (i3.pitch) {
  53488. const e2 = Ko(i3.pitch, o2, Xo);
  53489. r2.pitch = this._map.transform.pitch + e2.amount, Ho(r2, e2);
  53490. }
  53491. if (r2.zoom || r2.bearing) {
  53492. const e2 = void 0 === i3.pinchAround ? i3.around : i3.pinchAround;
  53493. r2.around = e2 ? this._map.unproject(e2) : this._map.getCenter();
  53494. }
  53495. return this.clear(), r2.noMoveStart = true, r2;
  53496. }
  53497. }
  53498. function Ho(e2, t2) {
  53499. (!e2.duration || e2.duration < t2.duration) && (e2.duration = t2.duration, e2.easing = t2.easing);
  53500. }
  53501. function Ko(t2, i3, o2) {
  53502. const { maxSpeed: r2, linearity: n2, deceleration: a2 } = o2, s2 = e.clamp(t2 * n2 / (i3 / 1e3), -r2, r2), l2 = Math.abs(s2) / (a2 * n2);
  53503. return { easing: o2.easing, duration: 1e3 * l2, amount: s2 * (l2 / 2) };
  53504. }
  53505. class Yo extends e.Event {
  53506. preventDefault() {
  53507. this._defaultPrevented = true;
  53508. }
  53509. get defaultPrevented() {
  53510. return this._defaultPrevented;
  53511. }
  53512. constructor(t2, i3, o2, r2 = {}) {
  53513. const n2 = p(i3.getCanvasContainer(), o2), a2 = i3.unproject(n2);
  53514. super(t2, e.extend({ point: n2, lngLat: a2, originalEvent: o2 }, r2)), this._defaultPrevented = false, this.target = i3;
  53515. }
  53516. }
  53517. class Jo extends e.Event {
  53518. preventDefault() {
  53519. this._defaultPrevented = true;
  53520. }
  53521. get defaultPrevented() {
  53522. return this._defaultPrevented;
  53523. }
  53524. constructor(t2, i3, o2) {
  53525. const r2 = "touchend" === t2 ? o2.changedTouches : o2.touches, n2 = m(i3.getCanvasContainer(), r2), a2 = n2.map((e2) => i3.unproject(e2)), s2 = n2.reduce((e2, t3, i4, o3) => e2.add(t3.div(o3.length)), new e.pointGeometry(0, 0));
  53526. super(t2, { points: n2, point: s2, lngLats: a2, lngLat: i3.unproject(s2), originalEvent: o2 }), this._defaultPrevented = false;
  53527. }
  53528. }
  53529. class Qo extends e.Event {
  53530. preventDefault() {
  53531. this._defaultPrevented = true;
  53532. }
  53533. get defaultPrevented() {
  53534. return this._defaultPrevented;
  53535. }
  53536. constructor(e2, t2, i3) {
  53537. super(e2, { originalEvent: i3 }), this._defaultPrevented = false;
  53538. }
  53539. }
  53540. class er {
  53541. constructor(e2, t2) {
  53542. this._map = e2, this._clickTolerance = t2.clickTolerance;
  53543. }
  53544. reset() {
  53545. this._mousedownPos = void 0;
  53546. }
  53547. wheel(e2) {
  53548. return this._firePreventable(new Qo(e2.type, this._map, e2));
  53549. }
  53550. mousedown(e2, t2) {
  53551. return this._mousedownPos = t2, this._firePreventable(new Yo(e2.type, this._map, e2));
  53552. }
  53553. mouseup(e2) {
  53554. this._map.fire(new Yo(e2.type, this._map, e2));
  53555. }
  53556. preclick(t2) {
  53557. const i3 = e.extend({}, t2);
  53558. i3.type = "preclick", this._map.fire(new Yo(i3.type, this._map, i3));
  53559. }
  53560. click(e2, t2) {
  53561. this._mousedownPos && this._mousedownPos.dist(t2) >= this._clickTolerance || (this.preclick(e2), this._map.fire(new Yo(e2.type, this._map, e2)));
  53562. }
  53563. dblclick(e2) {
  53564. return this._firePreventable(new Yo(e2.type, this._map, e2));
  53565. }
  53566. mouseover(e2) {
  53567. this._map.fire(new Yo(e2.type, this._map, e2));
  53568. }
  53569. mouseout(e2) {
  53570. this._map.fire(new Yo(e2.type, this._map, e2));
  53571. }
  53572. touchstart(e2) {
  53573. return this._firePreventable(new Jo(e2.type, this._map, e2));
  53574. }
  53575. touchmove(e2) {
  53576. this._map.fire(new Jo(e2.type, this._map, e2));
  53577. }
  53578. touchend(e2) {
  53579. this._map.fire(new Jo(e2.type, this._map, e2));
  53580. }
  53581. touchcancel(e2) {
  53582. this._map.fire(new Jo(e2.type, this._map, e2));
  53583. }
  53584. _firePreventable(e2) {
  53585. if (this._map.fire(e2), e2.defaultPrevented)
  53586. return {};
  53587. }
  53588. isEnabled() {
  53589. return true;
  53590. }
  53591. isActive() {
  53592. return false;
  53593. }
  53594. enable() {
  53595. }
  53596. disable() {
  53597. }
  53598. }
  53599. class tr {
  53600. constructor(e2) {
  53601. this._map = e2;
  53602. }
  53603. reset() {
  53604. this._delayContextMenu = false, this._contextMenuEvent = void 0;
  53605. }
  53606. mousemove(e2) {
  53607. this._map.fire(new Yo(e2.type, this._map, e2));
  53608. }
  53609. mousedown() {
  53610. this._delayContextMenu = true;
  53611. }
  53612. mouseup() {
  53613. this._delayContextMenu = false, this._contextMenuEvent && (this._map.fire(new Yo("contextmenu", this._map, this._contextMenuEvent)), delete this._contextMenuEvent);
  53614. }
  53615. contextmenu(e2) {
  53616. this._delayContextMenu ? this._contextMenuEvent = e2 : this._map.fire(new Yo(e2.type, this._map, e2)), this._map.listens("contextmenu") && e2.preventDefault();
  53617. }
  53618. isEnabled() {
  53619. return true;
  53620. }
  53621. isActive() {
  53622. return false;
  53623. }
  53624. enable() {
  53625. }
  53626. disable() {
  53627. }
  53628. }
  53629. class ir {
  53630. constructor(e2, t2) {
  53631. this._map = e2, this._el = e2.getCanvasContainer(), this._container = e2.getContainer(), this._clickTolerance = t2.clickTolerance || 1;
  53632. }
  53633. isEnabled() {
  53634. return !!this._enabled;
  53635. }
  53636. isActive() {
  53637. return !!this._active;
  53638. }
  53639. enable() {
  53640. this.isEnabled() || (this._enabled = true);
  53641. }
  53642. disable() {
  53643. this.isEnabled() && (this._enabled = false);
  53644. }
  53645. mousedown(e2, t2) {
  53646. this.isEnabled() && e2.shiftKey && 0 === e2.button && (h(), this._startPos = this._lastPos = t2, this._active = true);
  53647. }
  53648. mousemoveWindow(e2, t2) {
  53649. if (!this._active)
  53650. return;
  53651. const i3 = t2;
  53652. if (this._lastPos.equals(i3) || !this._box && i3.dist(this._startPos) < this._clickTolerance)
  53653. return;
  53654. const o2 = this._startPos;
  53655. this._lastPos = i3, this._box || (this._box = n("div", "mapboxgl-boxzoom", this._container), this._container.classList.add("mapboxgl-crosshair"), this._fireEvent("boxzoomstart", e2));
  53656. const r2 = Math.min(o2.x, i3.x), a2 = Math.max(o2.x, i3.x), s2 = Math.min(o2.y, i3.y), l2 = Math.max(o2.y, i3.y);
  53657. this._map._requestDomTask(() => {
  53658. this._box && (this._box.style.transform = `translate(${r2}px,${s2}px)`, this._box.style.width = a2 - r2 + "px", this._box.style.height = l2 - s2 + "px");
  53659. });
  53660. }
  53661. mouseupWindow(t2, i3) {
  53662. if (!this._active)
  53663. return;
  53664. if (0 !== t2.button)
  53665. return;
  53666. const o2 = this._startPos, r2 = i3;
  53667. if (this.reset(), d(), o2.x !== r2.x || o2.y !== r2.y)
  53668. return this._map.fire(new e.Event("boxzoomend", { originalEvent: t2 })), { cameraAnimation: (e2) => e2.fitScreenCoordinates(o2, r2, this._map.getBearing(), { linear: false }) };
  53669. this._fireEvent("boxzoomcancel", t2);
  53670. }
  53671. keydown(e2) {
  53672. this._active && 27 === e2.keyCode && (this.reset(), this._fireEvent("boxzoomcancel", e2));
  53673. }
  53674. blur() {
  53675. this.reset();
  53676. }
  53677. reset() {
  53678. this._active = false, this._container.classList.remove("mapboxgl-crosshair"), this._box && (this._box.remove(), this._box = null), _(), delete this._startPos, delete this._lastPos;
  53679. }
  53680. _fireEvent(t2, i3) {
  53681. return this._map.fire(new e.Event(t2, { originalEvent: i3 }));
  53682. }
  53683. }
  53684. function or(e2, t2) {
  53685. const i3 = {};
  53686. for (let o2 = 0; o2 < e2.length; o2++)
  53687. i3[e2[o2].identifier] = t2[o2];
  53688. return i3;
  53689. }
  53690. class rr {
  53691. constructor(e2) {
  53692. this.reset(), this.numTouches = e2.numTouches;
  53693. }
  53694. reset() {
  53695. this.centroid = void 0, this.startTime = 0, this.touches = {}, this.aborted = false;
  53696. }
  53697. touchstart(t2, i3, o2) {
  53698. (this.centroid || o2.length > this.numTouches) && (this.aborted = true), this.aborted || (0 === this.startTime && (this.startTime = t2.timeStamp), o2.length === this.numTouches && (this.centroid = function(t3) {
  53699. const i4 = new e.pointGeometry(0, 0);
  53700. for (const e2 of t3)
  53701. i4._add(e2);
  53702. return i4.div(t3.length);
  53703. }(i3), this.touches = or(o2, i3)));
  53704. }
  53705. touchmove(e2, t2, i3) {
  53706. if (this.aborted || !this.centroid)
  53707. return;
  53708. const o2 = or(i3, t2);
  53709. for (const e3 in this.touches) {
  53710. const t3 = this.touches[e3], i4 = o2[e3];
  53711. (!i4 || i4.dist(t3) > 30) && (this.aborted = true);
  53712. }
  53713. }
  53714. touchend(e2, t2, i3) {
  53715. if ((!this.centroid || e2.timeStamp - this.startTime > 500) && (this.aborted = true), 0 === i3.length) {
  53716. const e3 = !this.aborted && this.centroid;
  53717. if (this.reset(), e3)
  53718. return e3;
  53719. }
  53720. }
  53721. }
  53722. class nr {
  53723. constructor(e2) {
  53724. this.singleTap = new rr(e2), this.numTaps = e2.numTaps, this.reset();
  53725. }
  53726. reset() {
  53727. this.lastTime = 1 / 0, this.lastTap = void 0, this.count = 0, this.singleTap.reset();
  53728. }
  53729. touchstart(e2, t2, i3) {
  53730. this.singleTap.touchstart(e2, t2, i3);
  53731. }
  53732. touchmove(e2, t2, i3) {
  53733. this.singleTap.touchmove(e2, t2, i3);
  53734. }
  53735. touchend(e2, t2, i3) {
  53736. const o2 = this.singleTap.touchend(e2, t2, i3);
  53737. if (o2) {
  53738. const t3 = e2.timeStamp - this.lastTime < 500, i4 = !this.lastTap || this.lastTap.dist(o2) < 30;
  53739. if (t3 && i4 || this.reset(), this.count++, this.lastTime = e2.timeStamp, this.lastTap = o2, this.count === this.numTaps)
  53740. return this.reset(), o2;
  53741. }
  53742. }
  53743. }
  53744. class ar {
  53745. constructor() {
  53746. this._zoomIn = new nr({ numTouches: 1, numTaps: 2 }), this._zoomOut = new nr({ numTouches: 2, numTaps: 1 }), this.reset();
  53747. }
  53748. reset() {
  53749. this._active = false, this._zoomIn.reset(), this._zoomOut.reset();
  53750. }
  53751. touchstart(e2, t2, i3) {
  53752. this._zoomIn.touchstart(e2, t2, i3), this._zoomOut.touchstart(e2, t2, i3);
  53753. }
  53754. touchmove(e2, t2, i3) {
  53755. this._zoomIn.touchmove(e2, t2, i3), this._zoomOut.touchmove(e2, t2, i3);
  53756. }
  53757. touchend(e2, t2, i3) {
  53758. const o2 = this._zoomIn.touchend(e2, t2, i3), r2 = this._zoomOut.touchend(e2, t2, i3);
  53759. return o2 ? (this._active = true, e2.preventDefault(), setTimeout(() => this.reset(), 0), { cameraAnimation: (t3) => t3.easeTo({ duration: 300, zoom: t3.getZoom() + 1, around: t3.unproject(o2) }, { originalEvent: e2 }) }) : r2 ? (this._active = true, e2.preventDefault(), setTimeout(() => this.reset(), 0), { cameraAnimation: (t3) => t3.easeTo({ duration: 300, zoom: t3.getZoom() - 1, around: t3.unproject(r2) }, { originalEvent: e2 }) }) : void 0;
  53760. }
  53761. touchcancel() {
  53762. this.reset();
  53763. }
  53764. enable() {
  53765. this._enabled = true;
  53766. }
  53767. disable() {
  53768. this._enabled = false, this.reset();
  53769. }
  53770. isEnabled() {
  53771. return this._enabled;
  53772. }
  53773. isActive() {
  53774. return this._active;
  53775. }
  53776. }
  53777. const sr = { 0: 1, 2: 2 };
  53778. class lr {
  53779. constructor(e2) {
  53780. this.reset(), this._clickTolerance = e2.clickTolerance || 1;
  53781. }
  53782. blur() {
  53783. this.reset();
  53784. }
  53785. reset() {
  53786. this._active = false, this._moved = false, this._lastPoint = void 0, this._eventButton = void 0;
  53787. }
  53788. _correctButton(e2, t2) {
  53789. return false;
  53790. }
  53791. _move(e2, t2) {
  53792. return {};
  53793. }
  53794. mousedown(e2, t2) {
  53795. if (this._lastPoint)
  53796. return;
  53797. const i3 = f(e2);
  53798. this._correctButton(e2, i3) && (this._lastPoint = t2, this._eventButton = i3);
  53799. }
  53800. mousemoveWindow(e2, t2) {
  53801. const i3 = this._lastPoint;
  53802. if (i3) {
  53803. if (e2.preventDefault(), null != this._eventButton && function(e3, t3) {
  53804. const i4 = sr[t3];
  53805. return void 0 === e3.buttons || (e3.buttons & i4) !== i4;
  53806. }(e2, this._eventButton))
  53807. this.reset();
  53808. else if (this._moved || !(t2.dist(i3) < this._clickTolerance))
  53809. return this._moved = true, this._lastPoint = t2, this._move(i3, t2);
  53810. }
  53811. }
  53812. mouseupWindow(e2) {
  53813. this._lastPoint && f(e2) === this._eventButton && (this._moved && d(), this.reset());
  53814. }
  53815. enable() {
  53816. this._enabled = true;
  53817. }
  53818. disable() {
  53819. this._enabled = false, this.reset();
  53820. }
  53821. isEnabled() {
  53822. return this._enabled;
  53823. }
  53824. isActive() {
  53825. return this._active;
  53826. }
  53827. }
  53828. class cr extends lr {
  53829. mousedown(e2, t2) {
  53830. super.mousedown(e2, t2), this._lastPoint && (this._active = true);
  53831. }
  53832. _correctButton(e2, t2) {
  53833. return 0 === t2 && !e2.ctrlKey;
  53834. }
  53835. _move(e2, t2) {
  53836. return { around: t2, panDelta: t2.sub(e2) };
  53837. }
  53838. }
  53839. class hr extends lr {
  53840. _correctButton(e2, t2) {
  53841. return 0 === t2 && e2.ctrlKey || 2 === t2;
  53842. }
  53843. _move(e2, t2) {
  53844. const i3 = 0.8 * (t2.x - e2.x);
  53845. if (i3)
  53846. return this._active = true, { bearingDelta: i3 };
  53847. }
  53848. contextmenu(e2) {
  53849. e2.preventDefault();
  53850. }
  53851. }
  53852. class _r extends lr {
  53853. _correctButton(e2, t2) {
  53854. return 0 === t2 && e2.ctrlKey || 2 === t2;
  53855. }
  53856. _move(e2, t2) {
  53857. const i3 = -0.5 * (t2.y - e2.y);
  53858. if (i3)
  53859. return this._active = true, { pitchDelta: i3 };
  53860. }
  53861. contextmenu(e2) {
  53862. e2.preventDefault();
  53863. }
  53864. }
  53865. class ur {
  53866. constructor(t2, i3) {
  53867. this._map = t2, this._el = t2.getCanvasContainer(), this._minTouches = 1, this._clickTolerance = i3.clickTolerance || 1, this.reset(), e.bindAll(["_addTouchPanBlocker", "_showTouchPanBlockerAlert"], this);
  53868. }
  53869. reset() {
  53870. this._active = false, this._touches = {}, this._sum = new e.pointGeometry(0, 0);
  53871. }
  53872. touchstart(e2, t2, i3) {
  53873. return this._calculateTransform(e2, t2, i3);
  53874. }
  53875. touchmove(e2, t2, i3) {
  53876. if (this._active && !(i3.length < this._minTouches)) {
  53877. if (this._map._cooperativeGestures && !this._map.isMoving()) {
  53878. if (1 === i3.length)
  53879. return void this._showTouchPanBlockerAlert();
  53880. "hidden" !== this._alertContainer.style.visibility && (this._alertContainer.style.visibility = "hidden", clearTimeout(this._alertTimer));
  53881. }
  53882. return e2.preventDefault(), this._calculateTransform(e2, t2, i3);
  53883. }
  53884. }
  53885. touchend(e2, t2, i3) {
  53886. this._calculateTransform(e2, t2, i3), this._active && i3.length < this._minTouches && this.reset();
  53887. }
  53888. touchcancel() {
  53889. this.reset();
  53890. }
  53891. _calculateTransform(t2, i3, o2) {
  53892. o2.length > 0 && (this._active = true);
  53893. const r2 = or(o2, i3), n2 = new e.pointGeometry(0, 0), a2 = new e.pointGeometry(0, 0);
  53894. let s2 = 0;
  53895. for (const e2 in r2) {
  53896. const t3 = r2[e2], i4 = this._touches[e2];
  53897. i4 && (n2._add(t3), a2._add(t3.sub(i4)), s2++, r2[e2] = t3);
  53898. }
  53899. if (this._touches = r2, s2 < this._minTouches || !a2.mag())
  53900. return;
  53901. const l2 = a2.div(s2);
  53902. return this._sum._add(l2), this._sum.mag() < this._clickTolerance ? void 0 : { around: n2.div(s2), panDelta: l2 };
  53903. }
  53904. enable() {
  53905. this._enabled = true, this._map._cooperativeGestures && (this._addTouchPanBlocker(), this._el.classList.add("mapboxgl-touch-pan-blocker-override", "mapboxgl-scrollable-page"));
  53906. }
  53907. disable() {
  53908. this._enabled = false, this._map._cooperativeGestures && (clearTimeout(this._alertTimer), this._alertContainer.remove(), this._el.classList.remove("mapboxgl-touch-pan-blocker-override", "mapboxgl-scrollable-page")), this.reset();
  53909. }
  53910. isEnabled() {
  53911. return this._enabled;
  53912. }
  53913. isActive() {
  53914. return this._active;
  53915. }
  53916. _addTouchPanBlocker() {
  53917. this._map && !this._alertContainer && (this._alertContainer = n("div", "mapboxgl-touch-pan-blocker", this._map._container), this._alertContainer.textContent = this._map._getUIString("TouchPanBlocker.Message"), this._alertContainer.style.fontSize = `${Math.max(10, Math.min(24, Math.floor(0.05 * this._el.clientWidth)))}px`);
  53918. }
  53919. _showTouchPanBlockerAlert() {
  53920. "hidden" === this._alertContainer.style.visibility && (this._alertContainer.style.visibility = "visible"), this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"), clearTimeout(this._alertTimer), this._alertTimer = setTimeout(() => {
  53921. this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show");
  53922. }, 500);
  53923. }
  53924. }
  53925. class dr {
  53926. constructor() {
  53927. this.reset();
  53928. }
  53929. reset() {
  53930. this._active = false, this._firstTwoTouches = void 0;
  53931. }
  53932. _start(e2) {
  53933. }
  53934. _move(e2, t2, i3) {
  53935. return {};
  53936. }
  53937. touchstart(e2, t2, i3) {
  53938. this._firstTwoTouches || i3.length < 2 || (this._firstTwoTouches = [i3[0].identifier, i3[1].identifier], this._start([t2[0], t2[1]]));
  53939. }
  53940. touchmove(e2, t2, i3) {
  53941. const o2 = this._firstTwoTouches;
  53942. if (!o2)
  53943. return;
  53944. e2.preventDefault();
  53945. const [r2, n2] = o2, a2 = pr(i3, t2, r2), s2 = pr(i3, t2, n2);
  53946. if (!a2 || !s2)
  53947. return;
  53948. const l2 = this._aroundCenter ? null : a2.add(s2).div(2);
  53949. return this._move([a2, s2], l2, e2);
  53950. }
  53951. touchend(e2, t2, i3) {
  53952. if (!this._firstTwoTouches)
  53953. return;
  53954. const [o2, r2] = this._firstTwoTouches, n2 = pr(i3, t2, o2), a2 = pr(i3, t2, r2);
  53955. n2 && a2 || (this._active && d(), this.reset());
  53956. }
  53957. touchcancel() {
  53958. this.reset();
  53959. }
  53960. enable(e2) {
  53961. this._enabled = true, this._aroundCenter = !!e2 && "center" === e2.around;
  53962. }
  53963. disable() {
  53964. this._enabled = false, this.reset();
  53965. }
  53966. isEnabled() {
  53967. return this._enabled;
  53968. }
  53969. isActive() {
  53970. return this._active;
  53971. }
  53972. }
  53973. function pr(e2, t2, i3) {
  53974. for (let o2 = 0; o2 < e2.length; o2++)
  53975. if (e2[o2].identifier === i3)
  53976. return t2[o2];
  53977. }
  53978. function mr(e2, t2) {
  53979. return Math.log(e2 / t2) / Math.LN2;
  53980. }
  53981. class fr extends dr {
  53982. reset() {
  53983. super.reset(), this._distance = 0, this._startDistance = 0;
  53984. }
  53985. _start(e2) {
  53986. this._startDistance = this._distance = e2[0].dist(e2[1]);
  53987. }
  53988. _move(e2, t2) {
  53989. const i3 = this._distance;
  53990. if (this._distance = e2[0].dist(e2[1]), this._active || !(Math.abs(mr(this._distance, this._startDistance)) < 0.1))
  53991. return this._active = true, { zoomDelta: mr(this._distance, i3), pinchAround: t2 };
  53992. }
  53993. }
  53994. function gr(e2, t2) {
  53995. return 180 * e2.angleWith(t2) / Math.PI;
  53996. }
  53997. class vr extends dr {
  53998. reset() {
  53999. super.reset(), this._minDiameter = 0, this._startVector = void 0, this._vector = void 0;
  54000. }
  54001. _start(e2) {
  54002. this._startVector = this._vector = e2[0].sub(e2[1]), this._minDiameter = e2[0].dist(e2[1]);
  54003. }
  54004. _move(e2, t2) {
  54005. const i3 = this._vector;
  54006. if (this._vector = e2[0].sub(e2[1]), this._active || !this._isBelowThreshold(this._vector))
  54007. return this._active = true, { bearingDelta: gr(this._vector, i3), pinchAround: t2 };
  54008. }
  54009. _isBelowThreshold(e2) {
  54010. this._minDiameter = Math.min(this._minDiameter, e2.mag());
  54011. const t2 = 25 / (Math.PI * this._minDiameter) * 360, i3 = gr(e2, this._startVector);
  54012. return Math.abs(i3) < t2;
  54013. }
  54014. }
  54015. function xr(e2) {
  54016. return Math.abs(e2.y) > Math.abs(e2.x);
  54017. }
  54018. class yr extends dr {
  54019. constructor(e2) {
  54020. super(), this._map = e2;
  54021. }
  54022. reset() {
  54023. super.reset(), this._valid = void 0, this._firstMove = void 0, this._lastPoints = void 0;
  54024. }
  54025. _start(e2) {
  54026. this._lastPoints = e2, xr(e2[0].sub(e2[1])) && (this._valid = false);
  54027. }
  54028. _move(e2, t2, i3) {
  54029. const o2 = this._lastPoints;
  54030. if (!o2)
  54031. return;
  54032. const r2 = e2[0].sub(o2[0]), n2 = e2[1].sub(o2[1]);
  54033. return this._map._cooperativeGestures && i3.touches.length < 3 || (this._valid = this.gestureBeginsVertically(r2, n2, i3.timeStamp), !this._valid) ? void 0 : (this._lastPoints = e2, this._active = true, { pitchDelta: (r2.y + n2.y) / 2 * -0.5 });
  54034. }
  54035. gestureBeginsVertically(e2, t2, i3) {
  54036. if (void 0 !== this._valid)
  54037. return this._valid;
  54038. const o2 = e2.mag() >= 2, r2 = t2.mag() >= 2;
  54039. if (!o2 && !r2)
  54040. return;
  54041. if (!o2 || !r2)
  54042. return null == this._firstMove && (this._firstMove = i3), i3 - this._firstMove < 100 && void 0;
  54043. const n2 = e2.y > 0 == t2.y > 0;
  54044. return xr(e2) && xr(t2) && n2;
  54045. }
  54046. }
  54047. const br = { panStep: 100, bearingStep: 15, pitchStep: 10 };
  54048. class wr {
  54049. constructor() {
  54050. const e2 = br;
  54051. this._panStep = e2.panStep, this._bearingStep = e2.bearingStep, this._pitchStep = e2.pitchStep, this._rotationDisabled = false;
  54052. }
  54053. blur() {
  54054. this.reset();
  54055. }
  54056. reset() {
  54057. this._active = false;
  54058. }
  54059. keydown(e2) {
  54060. if (e2.altKey || e2.ctrlKey || e2.metaKey)
  54061. return;
  54062. let t2 = 0, i3 = 0, o2 = 0, r2 = 0, n2 = 0;
  54063. switch (e2.keyCode) {
  54064. case 61:
  54065. case 107:
  54066. case 171:
  54067. case 187:
  54068. t2 = 1;
  54069. break;
  54070. case 189:
  54071. case 109:
  54072. case 173:
  54073. t2 = -1;
  54074. break;
  54075. case 37:
  54076. e2.shiftKey ? i3 = -1 : (e2.preventDefault(), r2 = -1);
  54077. break;
  54078. case 39:
  54079. e2.shiftKey ? i3 = 1 : (e2.preventDefault(), r2 = 1);
  54080. break;
  54081. case 38:
  54082. e2.shiftKey ? o2 = 1 : (e2.preventDefault(), n2 = -1);
  54083. break;
  54084. case 40:
  54085. e2.shiftKey ? o2 = -1 : (e2.preventDefault(), n2 = 1);
  54086. break;
  54087. default:
  54088. return;
  54089. }
  54090. return this._rotationDisabled && (i3 = 0, o2 = 0), { cameraAnimation: (a2) => {
  54091. const s2 = a2.getZoom();
  54092. a2.easeTo({ duration: 300, easeId: "keyboardHandler", easing: Tr, zoom: t2 ? Math.round(s2) + t2 * (e2.shiftKey ? 2 : 1) : s2, bearing: a2.getBearing() + i3 * this._bearingStep, pitch: a2.getPitch() + o2 * this._pitchStep, offset: [-r2 * this._panStep, -n2 * this._panStep], center: a2.getCenter() }, { originalEvent: e2 });
  54093. } };
  54094. }
  54095. enable() {
  54096. this._enabled = true;
  54097. }
  54098. disable() {
  54099. this._enabled = false, this.reset();
  54100. }
  54101. isEnabled() {
  54102. return this._enabled;
  54103. }
  54104. isActive() {
  54105. return this._active;
  54106. }
  54107. disableRotation() {
  54108. this._rotationDisabled = true;
  54109. }
  54110. enableRotation() {
  54111. this._rotationDisabled = false;
  54112. }
  54113. }
  54114. function Tr(e2) {
  54115. return e2 * (2 - e2);
  54116. }
  54117. const Er = 4.000244140625;
  54118. class Cr {
  54119. constructor(t2, i3) {
  54120. this._map = t2, this._el = t2.getCanvasContainer(), this._handler = i3, this._delta = 0, this._defaultZoomRate = 0.01, this._wheelZoomRate = 0.0022222222222222222, e.bindAll(["_onTimeout", "_addScrollZoomBlocker", "_showBlockerAlert", "_isFullscreen"], this);
  54121. }
  54122. setZoomRate(e2) {
  54123. this._defaultZoomRate = e2;
  54124. }
  54125. setWheelZoomRate(e2) {
  54126. this._wheelZoomRate = e2;
  54127. }
  54128. isEnabled() {
  54129. return !!this._enabled;
  54130. }
  54131. isActive() {
  54132. return !!this._active || void 0 !== this._finishTimeout;
  54133. }
  54134. isZooming() {
  54135. return !!this._zooming;
  54136. }
  54137. enable(e2) {
  54138. this.isEnabled() || (this._enabled = true, this._aroundCenter = !!e2 && "center" === e2.around, this._map._cooperativeGestures && this._addScrollZoomBlocker());
  54139. }
  54140. disable() {
  54141. this.isEnabled() && (this._enabled = false, this._map._cooperativeGestures && (clearTimeout(this._alertTimer), this._alertContainer.remove()));
  54142. }
  54143. wheel(t2) {
  54144. if (!this.isEnabled())
  54145. return;
  54146. if (this._map._cooperativeGestures) {
  54147. if (!(t2.ctrlKey || t2.metaKey || this.isZooming() || this._isFullscreen()))
  54148. return void this._showBlockerAlert();
  54149. "hidden" !== this._alertContainer.style.visibility && (this._alertContainer.style.visibility = "hidden", clearTimeout(this._alertTimer));
  54150. }
  54151. let i3 = t2.deltaMode === e.window.WheelEvent.DOM_DELTA_LINE ? 40 * t2.deltaY : t2.deltaY;
  54152. const o2 = e.exported.now(), r2 = o2 - (this._lastWheelEventTime || 0);
  54153. this._lastWheelEventTime = o2, 0 !== i3 && i3 % Er == 0 ? this._type = "wheel" : 0 !== i3 && Math.abs(i3) < 4 ? this._type = "trackpad" : r2 > 400 ? (this._type = null, this._lastValue = i3, this._timeout = setTimeout(this._onTimeout, 40, t2)) : this._type || (this._type = Math.abs(r2 * i3) < 200 ? "trackpad" : "wheel", this._timeout && (clearTimeout(this._timeout), this._timeout = null, i3 += this._lastValue)), t2.shiftKey && i3 && (i3 /= 4), this._type && (this._lastWheelEvent = t2, this._delta -= i3, this._active || this._start(t2)), t2.preventDefault();
  54154. }
  54155. _onTimeout(e2) {
  54156. this._type = "wheel", this._delta -= this._lastValue, this._active || this._start(e2);
  54157. }
  54158. _start(e2) {
  54159. if (!this._delta)
  54160. return;
  54161. this._frameId && (this._frameId = null), this._active = true, this.isZooming() || (this._zooming = true), this._finishTimeout && (clearTimeout(this._finishTimeout), delete this._finishTimeout);
  54162. const t2 = p(this._el, e2);
  54163. this._aroundPoint = this._aroundCenter ? this._map.transform.centerPoint : t2, this._aroundCoord = this._map.transform.pointCoordinate3D(this._aroundPoint), this._targetZoom = void 0, this._frameId || (this._frameId = true, this._handler._triggerRenderFrame());
  54164. }
  54165. renderFrame() {
  54166. if (!this._frameId)
  54167. return;
  54168. if (this._frameId = null, !this.isActive())
  54169. return;
  54170. const t2 = this._map.transform, i3 = () => t2._terrainEnabled() && this._aroundCoord ? t2.computeZoomRelativeTo(this._aroundCoord) : t2.zoom;
  54171. if (0 !== this._delta) {
  54172. const e2 = "wheel" === this._type && Math.abs(this._delta) > Er ? this._wheelZoomRate : this._defaultZoomRate;
  54173. let o3 = 2 / (1 + Math.exp(-Math.abs(this._delta * e2)));
  54174. this._delta < 0 && 0 !== o3 && (o3 = 1 / o3);
  54175. const r3 = i3(), n3 = Math.pow(2, r3), a3 = "number" == typeof this._targetZoom ? t2.zoomScale(this._targetZoom) : n3;
  54176. this._targetZoom = Math.min(t2.maxZoom, Math.max(t2.minZoom, t2.scaleZoom(a3 * o3))), "wheel" === this._type && (this._startZoom = i3(), this._easing = this._smoothOutEasing(200)), this._delta = 0;
  54177. }
  54178. const o2 = "number" == typeof this._targetZoom ? this._targetZoom : i3(), r2 = this._startZoom, n2 = this._easing;
  54179. let a2, s2 = false;
  54180. if ("wheel" === this._type && r2 && n2) {
  54181. const t3 = Math.min((e.exported.now() - this._lastWheelEventTime) / 200, 1), i4 = n2(t3);
  54182. a2 = e.number(r2, o2, i4), t3 < 1 ? this._frameId || (this._frameId = true) : s2 = true;
  54183. } else
  54184. a2 = o2, s2 = true;
  54185. return this._active = true, s2 && (this._active = false, this._finishTimeout = setTimeout(() => {
  54186. this._zooming = false, this._handler._triggerRenderFrame(), delete this._targetZoom, delete this._finishTimeout;
  54187. }, 200)), { noInertia: true, needsRenderFrame: !s2, zoomDelta: a2 - i3(), around: this._aroundPoint, aroundCoord: this._aroundCoord, originalEvent: this._lastWheelEvent };
  54188. }
  54189. _smoothOutEasing(t2) {
  54190. let i3 = e.ease;
  54191. if (this._prevEase) {
  54192. const t3 = this._prevEase, o2 = (e.exported.now() - t3.start) / t3.duration, r2 = t3.easing(o2 + 0.01) - t3.easing(o2), n2 = 0.27 / Math.sqrt(r2 * r2 + 1e-4) * 0.01, a2 = Math.sqrt(0.0729 - n2 * n2);
  54193. i3 = e.bezier(n2, a2, 0.25, 1);
  54194. }
  54195. return this._prevEase = { start: e.exported.now(), duration: t2, easing: i3 }, i3;
  54196. }
  54197. blur() {
  54198. this.reset();
  54199. }
  54200. reset() {
  54201. this._active = false;
  54202. }
  54203. _addScrollZoomBlocker() {
  54204. this._map && !this._alertContainer && (this._alertContainer = n("div", "mapboxgl-scroll-zoom-blocker", this._map._container), this._alertContainer.textContent = /(Mac|iPad)/i.test(e.window.navigator.userAgent) ? this._map._getUIString("ScrollZoomBlocker.CmdMessage") : this._map._getUIString("ScrollZoomBlocker.CtrlMessage"), this._alertContainer.style.fontSize = `${Math.max(10, Math.min(24, Math.floor(0.05 * this._el.clientWidth)))}px`);
  54205. }
  54206. _isFullscreen() {
  54207. return !!e.window.document.fullscreenElement || !!e.window.document.webkitFullscreenElement;
  54208. }
  54209. _showBlockerAlert() {
  54210. "hidden" === this._alertContainer.style.visibility && (this._alertContainer.style.visibility = "visible"), this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"), clearTimeout(this._alertTimer), this._alertTimer = setTimeout(() => {
  54211. this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show");
  54212. }, 200);
  54213. }
  54214. }
  54215. class Ir {
  54216. constructor(e2, t2) {
  54217. this._clickZoom = e2, this._tapZoom = t2;
  54218. }
  54219. enable() {
  54220. this._clickZoom.enable(), this._tapZoom.enable();
  54221. }
  54222. disable() {
  54223. this._clickZoom.disable(), this._tapZoom.disable();
  54224. }
  54225. isEnabled() {
  54226. return this._clickZoom.isEnabled() && this._tapZoom.isEnabled();
  54227. }
  54228. isActive() {
  54229. return this._clickZoom.isActive() || this._tapZoom.isActive();
  54230. }
  54231. }
  54232. class Mr {
  54233. constructor() {
  54234. this.reset();
  54235. }
  54236. reset() {
  54237. this._active = false;
  54238. }
  54239. blur() {
  54240. this.reset();
  54241. }
  54242. dblclick(e2, t2) {
  54243. return e2.preventDefault(), { cameraAnimation: (i3) => {
  54244. i3.easeTo({ duration: 300, zoom: i3.getZoom() + (e2.shiftKey ? -1 : 1), around: i3.unproject(t2) }, { originalEvent: e2 });
  54245. } };
  54246. }
  54247. enable() {
  54248. this._enabled = true;
  54249. }
  54250. disable() {
  54251. this._enabled = false, this.reset();
  54252. }
  54253. isEnabled() {
  54254. return this._enabled;
  54255. }
  54256. isActive() {
  54257. return this._active;
  54258. }
  54259. }
  54260. class Sr {
  54261. constructor() {
  54262. this._tap = new nr({ numTouches: 1, numTaps: 1 }), this.reset();
  54263. }
  54264. reset() {
  54265. this._active = false, this._swipePoint = void 0, this._swipeTouch = 0, this._tapTime = 0, this._tap.reset();
  54266. }
  54267. touchstart(e2, t2, i3) {
  54268. this._swipePoint || (this._tapTime && e2.timeStamp - this._tapTime > 500 && this.reset(), this._tapTime ? i3.length > 0 && (this._swipePoint = t2[0], this._swipeTouch = i3[0].identifier) : this._tap.touchstart(e2, t2, i3));
  54269. }
  54270. touchmove(e2, t2, i3) {
  54271. if (this._tapTime) {
  54272. if (this._swipePoint) {
  54273. if (i3[0].identifier !== this._swipeTouch)
  54274. return;
  54275. const o2 = t2[0], r2 = o2.y - this._swipePoint.y;
  54276. return this._swipePoint = o2, e2.preventDefault(), this._active = true, { zoomDelta: r2 / 128 };
  54277. }
  54278. } else
  54279. this._tap.touchmove(e2, t2, i3);
  54280. }
  54281. touchend(e2, t2, i3) {
  54282. this._tapTime ? this._swipePoint && 0 === i3.length && this.reset() : this._tap.touchend(e2, t2, i3) && (this._tapTime = e2.timeStamp);
  54283. }
  54284. touchcancel() {
  54285. this.reset();
  54286. }
  54287. enable() {
  54288. this._enabled = true;
  54289. }
  54290. disable() {
  54291. this._enabled = false, this.reset();
  54292. }
  54293. isEnabled() {
  54294. return this._enabled;
  54295. }
  54296. isActive() {
  54297. return this._active;
  54298. }
  54299. }
  54300. class zr {
  54301. constructor(e2, t2, i3) {
  54302. this._el = e2, this._mousePan = t2, this._touchPan = i3;
  54303. }
  54304. enable(e2) {
  54305. this._inertiaOptions = e2 || {}, this._mousePan.enable(), this._touchPan.enable(), this._el.classList.add("mapboxgl-touch-drag-pan");
  54306. }
  54307. disable() {
  54308. this._mousePan.disable(), this._touchPan.disable(), this._el.classList.remove("mapboxgl-touch-drag-pan");
  54309. }
  54310. isEnabled() {
  54311. return this._mousePan.isEnabled() && this._touchPan.isEnabled();
  54312. }
  54313. isActive() {
  54314. return this._mousePan.isActive() || this._touchPan.isActive();
  54315. }
  54316. }
  54317. class Dr {
  54318. constructor(e2, t2, i3) {
  54319. this._pitchWithRotate = e2.pitchWithRotate, this._mouseRotate = t2, this._mousePitch = i3;
  54320. }
  54321. enable() {
  54322. this._mouseRotate.enable(), this._pitchWithRotate && this._mousePitch.enable();
  54323. }
  54324. disable() {
  54325. this._mouseRotate.disable(), this._mousePitch.disable();
  54326. }
  54327. isEnabled() {
  54328. return this._mouseRotate.isEnabled() && (!this._pitchWithRotate || this._mousePitch.isEnabled());
  54329. }
  54330. isActive() {
  54331. return this._mouseRotate.isActive() || this._mousePitch.isActive();
  54332. }
  54333. }
  54334. class Pr {
  54335. constructor(e2, t2, i3, o2) {
  54336. this._el = e2, this._touchZoom = t2, this._touchRotate = i3, this._tapDragZoom = o2, this._rotationDisabled = false, this._enabled = true;
  54337. }
  54338. enable(e2) {
  54339. this._touchZoom.enable(e2), this._rotationDisabled || this._touchRotate.enable(e2), this._tapDragZoom.enable(), this._el.classList.add("mapboxgl-touch-zoom-rotate");
  54340. }
  54341. disable() {
  54342. this._touchZoom.disable(), this._touchRotate.disable(), this._tapDragZoom.disable(), this._el.classList.remove("mapboxgl-touch-zoom-rotate");
  54343. }
  54344. isEnabled() {
  54345. return this._touchZoom.isEnabled() && (this._rotationDisabled || this._touchRotate.isEnabled()) && this._tapDragZoom.isEnabled();
  54346. }
  54347. isActive() {
  54348. return this._touchZoom.isActive() || this._touchRotate.isActive() || this._tapDragZoom.isActive();
  54349. }
  54350. disableRotation() {
  54351. this._rotationDisabled = true, this._touchRotate.disable();
  54352. }
  54353. enableRotation() {
  54354. this._rotationDisabled = false, this._touchZoom.isEnabled() && this._touchRotate.enable();
  54355. }
  54356. }
  54357. const Ar = (e2) => e2.zoom || e2.drag || e2.pitch || e2.rotate;
  54358. class Lr extends e.Event {
  54359. }
  54360. class Rr {
  54361. constructor() {
  54362. this.constants = [1, 1, 0.01], this.radius = 0;
  54363. }
  54364. setup(t2, i3) {
  54365. const o2 = e.sub([], i3, t2);
  54366. this.radius = e.length(o2[2] < 0 ? e.div([], o2, this.constants) : [o2[0], o2[1], 0]);
  54367. }
  54368. projectRay(t2) {
  54369. e.div(t2, t2, this.constants), e.normalize(t2, t2), e.mul$1(t2, t2, this.constants);
  54370. const i3 = e.scale$2([], t2, this.radius);
  54371. if (i3[2] > 0) {
  54372. const t3 = e.scale$2([], [0, 0, 1], e.dot(i3, [0, 0, 1])), o2 = e.scale$2([], e.normalize([], [i3[0], i3[1], 0]), this.radius), r2 = e.add([], i3, e.scale$2([], e.sub([], e.add([], o2, t3), i3), 2));
  54373. i3[0] = r2[0], i3[1] = r2[1];
  54374. }
  54375. return i3;
  54376. }
  54377. }
  54378. function kr(e2) {
  54379. return e2.panDelta && e2.panDelta.mag() || e2.zoomDelta || e2.bearingDelta || e2.pitchDelta;
  54380. }
  54381. class Or {
  54382. constructor(t2, i3) {
  54383. this._map = t2, this._el = this._map.getCanvasContainer(), this._handlers = [], this._handlersById = {}, this._changes = [], this._inertia = new $o(t2), this._bearingSnap = i3.bearingSnap, this._previousActiveHandlers = {}, this._trackingEllipsoid = new Rr(), this._dragOrigin = null, this._eventsInProgress = {}, this._addDefaultHandlers(i3), e.bindAll(["handleEvent", "handleWindowEvent"], this);
  54384. const o2 = this._el;
  54385. this._listeners = [[o2, "touchstart", { passive: true }], [o2, "touchmove", { passive: false }], [o2, "touchend", void 0], [o2, "touchcancel", void 0], [o2, "mousedown", void 0], [o2, "mousemove", void 0], [o2, "mouseup", void 0], [e.window.document, "mousemove", { capture: true }], [e.window.document, "mouseup", void 0], [o2, "mouseover", void 0], [o2, "mouseout", void 0], [o2, "dblclick", void 0], [o2, "click", void 0], [o2, "keydown", { capture: false }], [o2, "keyup", void 0], [o2, "wheel", { passive: false }], [o2, "contextmenu", void 0], [e.window, "blur", void 0]];
  54386. for (const [t3, i4, o3] of this._listeners)
  54387. t3.addEventListener(i4, t3 === e.window.document ? this.handleWindowEvent : this.handleEvent, o3);
  54388. }
  54389. destroy() {
  54390. for (const [t2, i3, o2] of this._listeners)
  54391. t2.removeEventListener(i3, t2 === e.window.document ? this.handleWindowEvent : this.handleEvent, o2);
  54392. }
  54393. _addDefaultHandlers(e2) {
  54394. const t2 = this._map, i3 = t2.getCanvasContainer();
  54395. this._add("mapEvent", new er(t2, e2));
  54396. const o2 = t2.boxZoom = new ir(t2, e2);
  54397. this._add("boxZoom", o2);
  54398. const r2 = new ar(), n2 = new Mr();
  54399. t2.doubleClickZoom = new Ir(n2, r2), this._add("tapZoom", r2), this._add("clickZoom", n2);
  54400. const a2 = new Sr();
  54401. this._add("tapDragZoom", a2);
  54402. const s2 = t2.touchPitch = new yr(t2);
  54403. this._add("touchPitch", s2);
  54404. const l2 = new hr(e2), c2 = new _r(e2);
  54405. t2.dragRotate = new Dr(e2, l2, c2), this._add("mouseRotate", l2, ["mousePitch"]), this._add("mousePitch", c2, ["mouseRotate"]);
  54406. const h2 = new cr(e2), _2 = new ur(t2, e2);
  54407. t2.dragPan = new zr(i3, h2, _2), this._add("mousePan", h2), this._add("touchPan", _2, ["touchZoom", "touchRotate"]);
  54408. const u2 = new vr(), d2 = new fr();
  54409. t2.touchZoomRotate = new Pr(i3, d2, u2, a2), this._add("touchRotate", u2, ["touchPan", "touchZoom"]), this._add("touchZoom", d2, ["touchPan", "touchRotate"]), this._add("blockableMapEvent", new tr(t2));
  54410. const p2 = t2.scrollZoom = new Cr(t2, this);
  54411. this._add("scrollZoom", p2, ["mousePan"]);
  54412. const m2 = t2.keyboard = new wr();
  54413. this._add("keyboard", m2);
  54414. for (const i4 of ["boxZoom", "doubleClickZoom", "tapDragZoom", "touchPitch", "dragRotate", "dragPan", "touchZoomRotate", "scrollZoom", "keyboard"])
  54415. e2.interactive && e2[i4] && t2[i4].enable(e2[i4]);
  54416. }
  54417. _add(e2, t2, i3) {
  54418. this._handlers.push({ handlerName: e2, handler: t2, allowed: i3 }), this._handlersById[e2] = t2;
  54419. }
  54420. stop(e2) {
  54421. if (!this._updatingCamera) {
  54422. for (const { handler: e3 } of this._handlers)
  54423. e3.reset();
  54424. this._inertia.clear(), this._fireEvents({}, {}, e2), this._changes = [];
  54425. }
  54426. }
  54427. isActive() {
  54428. for (const { handler: e2 } of this._handlers)
  54429. if (e2.isActive())
  54430. return true;
  54431. return false;
  54432. }
  54433. isZooming() {
  54434. return !!this._eventsInProgress.zoom || this._map.scrollZoom.isZooming();
  54435. }
  54436. isRotating() {
  54437. return !!this._eventsInProgress.rotate;
  54438. }
  54439. isMoving() {
  54440. return !!Ar(this._eventsInProgress) || this.isZooming();
  54441. }
  54442. _blockedByActive(e2, t2, i3) {
  54443. for (const o2 in e2)
  54444. if (o2 !== i3 && (!t2 || t2.indexOf(o2) < 0))
  54445. return true;
  54446. return false;
  54447. }
  54448. handleWindowEvent(e2) {
  54449. this.handleEvent(e2, `${e2.type}Window`);
  54450. }
  54451. _getMapTouches(e2) {
  54452. const t2 = [];
  54453. for (const i3 of e2)
  54454. this._el.contains(i3.target) && t2.push(i3);
  54455. return t2;
  54456. }
  54457. handleEvent(e2, t2) {
  54458. this._updatingCamera = true;
  54459. const i3 = "renderFrame" === e2.type, o2 = i3 ? void 0 : e2, r2 = { needsRenderFrame: false }, n2 = {}, a2 = {}, s2 = e2.touches ? this._getMapTouches(e2.touches) : void 0, l2 = s2 ? m(this._el, s2) : i3 ? void 0 : p(this._el, e2);
  54460. for (const { handlerName: i4, handler: c3, allowed: h3 } of this._handlers) {
  54461. if (!c3.isEnabled())
  54462. continue;
  54463. let _2;
  54464. this._blockedByActive(a2, h3, i4) ? c3.reset() : c3[t2 || e2.type] && (_2 = c3[t2 || e2.type](e2, l2, s2), this.mergeHandlerResult(r2, n2, _2, i4, o2), _2 && _2.needsRenderFrame && this._triggerRenderFrame()), (_2 || c3.isActive()) && (a2[i4] = c3);
  54465. }
  54466. const c2 = {};
  54467. for (const e3 in this._previousActiveHandlers)
  54468. a2[e3] || (c2[e3] = o2);
  54469. this._previousActiveHandlers = a2, (Object.keys(c2).length || kr(r2)) && (this._changes.push([r2, n2, c2]), this._triggerRenderFrame()), (Object.keys(a2).length || kr(r2)) && this._map._stop(true), this._updatingCamera = false;
  54470. const { cameraAnimation: h2 } = r2;
  54471. h2 && (this._inertia.clear(), this._fireEvents({}, {}, true), this._changes = [], h2(this._map));
  54472. }
  54473. mergeHandlerResult(t2, i3, o2, r2, n2) {
  54474. if (!o2)
  54475. return;
  54476. e.extend(t2, o2);
  54477. const a2 = { handlerName: r2, originalEvent: o2.originalEvent || n2 };
  54478. void 0 !== o2.zoomDelta && (i3.zoom = a2), void 0 !== o2.panDelta && (i3.drag = a2), void 0 !== o2.pitchDelta && (i3.pitch = a2), void 0 !== o2.bearingDelta && (i3.rotate = a2);
  54479. }
  54480. _applyChanges() {
  54481. const t2 = {}, i3 = {}, o2 = {};
  54482. for (const [r2, n2, a2] of this._changes)
  54483. r2.panDelta && (t2.panDelta = (t2.panDelta || new e.pointGeometry(0, 0))._add(r2.panDelta)), r2.zoomDelta && (t2.zoomDelta = (t2.zoomDelta || 0) + r2.zoomDelta), r2.bearingDelta && (t2.bearingDelta = (t2.bearingDelta || 0) + r2.bearingDelta), r2.pitchDelta && (t2.pitchDelta = (t2.pitchDelta || 0) + r2.pitchDelta), void 0 !== r2.around && (t2.around = r2.around), void 0 !== r2.aroundCoord && (t2.aroundCoord = r2.aroundCoord), void 0 !== r2.pinchAround && (t2.pinchAround = r2.pinchAround), r2.noInertia && (t2.noInertia = r2.noInertia), e.extend(i3, n2), e.extend(o2, a2);
  54484. this._updateMapTransform(t2, i3, o2), this._changes = [];
  54485. }
  54486. _updateMapTransform(t2, i3, o2) {
  54487. const r2 = this._map, n2 = r2.transform, a2 = (e2) => [e2.x, e2.y, e2.z];
  54488. if (((e2) => {
  54489. const t3 = this._eventsInProgress.drag;
  54490. return t3 && !this._handlersById[t3.handlerName].isActive();
  54491. })() && !kr(t2)) {
  54492. const e2 = n2.zoom;
  54493. n2.cameraElevationReference = "sea", n2.recenterOnTerrain(), n2.cameraElevationReference = "ground", e2 !== n2.zoom && this._map._update(true);
  54494. }
  54495. if (!kr(t2))
  54496. return void this._fireEvents(i3, o2, true);
  54497. let { panDelta: s2, zoomDelta: l2, bearingDelta: c2, pitchDelta: h2, around: _2, aroundCoord: u2, pinchAround: d2 } = t2;
  54498. void 0 !== d2 && (_2 = d2), ((e2) => i3.drag && !this._eventsInProgress.drag)() && _2 && (this._dragOrigin = a2(n2.pointCoordinate3D(_2)), this._trackingEllipsoid.setup(n2._camera.position, this._dragOrigin)), n2.cameraElevationReference = "sea", r2._stop(true), _2 = _2 || r2.transform.centerPoint, c2 && (n2.bearing += c2), h2 && (n2.pitch += h2), n2._updateCameraState();
  54499. const p2 = [0, 0, 0];
  54500. if (s2) {
  54501. const t3 = n2.pointCoordinate(_2);
  54502. if ("globe" === n2.projection.name) {
  54503. const i4 = e.latFromMercatorY(t3.y), o3 = n2.center.lat, r3 = Math.min(e.mercatorZfromAltitude(1, i4) / e.mercatorZfromAltitude(1, o3), 2);
  54504. s2 = s2.rotate(-n2.angle), p2[0] = -s2.x / n2.worldSize * r3, p2[1] = -s2.y / n2.worldSize * r3;
  54505. } else {
  54506. const e2 = n2.pointCoordinate(_2.sub(s2));
  54507. t3 && e2 && (p2[0] = e2.x - t3.x, p2[1] = e2.y - t3.y);
  54508. }
  54509. }
  54510. const m2 = n2.zoom, f2 = [0, 0, 0];
  54511. if (l2) {
  54512. const t3 = a2(u2 || n2.pointCoordinate3D(_2)), i4 = { dir: e.normalize([], e.sub([], t3, n2._camera.position)) };
  54513. if (i4.dir[2] < 0) {
  54514. const o3 = n2.zoomDeltaToMovement(t3, l2);
  54515. e.scale$2(f2, i4.dir, o3);
  54516. }
  54517. }
  54518. const g2 = e.add(p2, p2, f2);
  54519. n2._translateCameraConstrained(g2), l2 && Math.abs(n2.zoom - m2) > 1e-4 && n2.recenterOnTerrain(), n2.cameraElevationReference = "ground", this._map._update(), t2.noInertia || this._inertia.record(t2), this._fireEvents(i3, o2, true);
  54520. }
  54521. _fireEvents(t2, i3, o2) {
  54522. const r2 = Ar(this._eventsInProgress), n2 = Ar(t2), a2 = {};
  54523. for (const e2 in t2) {
  54524. const { originalEvent: i4 } = t2[e2];
  54525. this._eventsInProgress[e2] || (a2[`${e2}start`] = i4), this._eventsInProgress[e2] = t2[e2];
  54526. }
  54527. !r2 && n2 && this._fireEvent("movestart", n2.originalEvent);
  54528. for (const e2 in a2)
  54529. this._fireEvent(e2, a2[e2]);
  54530. n2 && this._fireEvent("move", n2.originalEvent);
  54531. for (const e2 in t2) {
  54532. const { originalEvent: i4 } = t2[e2];
  54533. this._fireEvent(e2, i4);
  54534. }
  54535. const s2 = {};
  54536. let l2;
  54537. for (const e2 in this._eventsInProgress) {
  54538. const { handlerName: t3, originalEvent: o3 } = this._eventsInProgress[e2];
  54539. this._handlersById[t3].isActive() || (delete this._eventsInProgress[e2], l2 = i3[t3] || o3, s2[`${e2}end`] = l2);
  54540. }
  54541. for (const e2 in s2)
  54542. this._fireEvent(e2, s2[e2]);
  54543. const c2 = Ar(this._eventsInProgress);
  54544. if (o2 && (r2 || n2) && !c2) {
  54545. this._updatingCamera = true;
  54546. const t3 = this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions), i4 = (e2) => 0 !== e2 && -this._bearingSnap < e2 && e2 < this._bearingSnap;
  54547. t3 ? (i4(t3.bearing || this._map.getBearing()) && (t3.bearing = 0), this._map.easeTo(t3, { originalEvent: l2 })) : (this._map.fire(new e.Event("moveend", { originalEvent: l2 })), i4(this._map.getBearing()) && this._map.resetNorth()), this._updatingCamera = false;
  54548. }
  54549. }
  54550. _fireEvent(t2, i3) {
  54551. this._map.fire(new e.Event(t2, i3 ? { originalEvent: i3 } : {}));
  54552. }
  54553. _requestFrame() {
  54554. return this._map.triggerRepaint(), this._map._renderTaskQueue.add((e2) => {
  54555. this._frameId = void 0, this.handleEvent(new Lr("renderFrame", { timeStamp: e2 })), this._applyChanges();
  54556. });
  54557. }
  54558. _triggerRenderFrame() {
  54559. void 0 === this._frameId && (this._frameId = this._requestFrame());
  54560. }
  54561. }
  54562. const Br = "map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";
  54563. class Fr extends e.Evented {
  54564. constructor(t2, i3) {
  54565. super(), this._moving = false, this._zooming = false, this.transform = t2, this._bearingSnap = i3.bearingSnap, e.bindAll(["_renderFrameCallback"], this);
  54566. }
  54567. getCenter() {
  54568. return new e.LngLat(this.transform.center.lng, this.transform.center.lat);
  54569. }
  54570. setCenter(e2, t2) {
  54571. return this.jumpTo({ center: e2 }, t2);
  54572. }
  54573. panBy(t2, i3, o2) {
  54574. return t2 = e.pointGeometry.convert(t2).mult(-1), this.panTo(this.transform.center, e.extend({ offset: t2 }, i3), o2);
  54575. }
  54576. panTo(t2, i3, o2) {
  54577. return this.easeTo(e.extend({ center: t2 }, i3), o2);
  54578. }
  54579. getZoom() {
  54580. return this.transform.zoom;
  54581. }
  54582. setZoom(e2, t2) {
  54583. return this.jumpTo({ zoom: e2 }, t2), this;
  54584. }
  54585. zoomTo(t2, i3, o2) {
  54586. return this.easeTo(e.extend({ zoom: t2 }, i3), o2);
  54587. }
  54588. zoomIn(e2, t2) {
  54589. return this.zoomTo(this.getZoom() + 1, e2, t2), this;
  54590. }
  54591. zoomOut(e2, t2) {
  54592. return this.zoomTo(this.getZoom() - 1, e2, t2), this;
  54593. }
  54594. getBearing() {
  54595. return this.transform.bearing;
  54596. }
  54597. setBearing(e2, t2) {
  54598. return this.jumpTo({ bearing: e2 }, t2), this;
  54599. }
  54600. getPadding() {
  54601. return this.transform.padding;
  54602. }
  54603. setPadding(e2, t2) {
  54604. return this.jumpTo({ padding: e2 }, t2), this;
  54605. }
  54606. rotateTo(t2, i3, o2) {
  54607. return this.easeTo(e.extend({ bearing: t2 }, i3), o2);
  54608. }
  54609. resetNorth(t2, i3) {
  54610. return this.rotateTo(0, e.extend({ duration: 1e3 }, t2), i3), this;
  54611. }
  54612. resetNorthPitch(t2, i3) {
  54613. return this.easeTo(e.extend({ bearing: 0, pitch: 0, duration: 1e3 }, t2), i3), this;
  54614. }
  54615. snapToNorth(e2, t2) {
  54616. return Math.abs(this.getBearing()) < this._bearingSnap ? this.resetNorth(e2, t2) : this;
  54617. }
  54618. getPitch() {
  54619. return this.transform.pitch;
  54620. }
  54621. setPitch(e2, t2) {
  54622. return this.jumpTo({ pitch: e2 }, t2), this;
  54623. }
  54624. cameraForBounds(t2, i3) {
  54625. t2 = e.LngLatBounds.convert(t2);
  54626. const o2 = i3 && i3.bearing || 0;
  54627. return this._cameraForBoxAndBearing(t2.getNorthWest(), t2.getSouthEast(), o2, i3);
  54628. }
  54629. _extendCameraOptions(t2) {
  54630. const i3 = { top: 0, bottom: 0, right: 0, left: 0 };
  54631. if ("number" == typeof (t2 = e.extend({ padding: i3, offset: [0, 0], maxZoom: this.transform.maxZoom }, t2)).padding) {
  54632. const e2 = t2.padding;
  54633. t2.padding = { top: e2, bottom: e2, right: e2, left: e2 };
  54634. }
  54635. return t2.padding = e.extend(i3, t2.padding), t2;
  54636. }
  54637. _cameraForBoxAndBearing(t2, i3, o2, r2) {
  54638. const n2 = this._extendCameraOptions(r2), a2 = this.transform, s2 = a2.padding, l2 = a2.project(e.LngLat.convert(t2)), c2 = a2.project(e.LngLat.convert(i3)), h2 = new e.pointGeometry(l2.x, c2.y), _2 = new e.pointGeometry(c2.x, l2.y), u2 = -e.degToRad(o2), d2 = l2.rotate(u2), p2 = c2.rotate(u2), m2 = h2.rotate(u2), f2 = _2.rotate(u2), g2 = new e.pointGeometry(Math.max(d2.x, p2.x, m2.x, f2.x), Math.max(d2.y, p2.y, m2.y, f2.y)), v2 = new e.pointGeometry(Math.min(d2.x, p2.x, m2.x, f2.x), Math.min(d2.y, p2.y, m2.y, f2.y)), x2 = g2.sub(v2), y2 = (a2.width - ((s2.left || 0) + (s2.right || 0) + n2.padding.left + n2.padding.right)) / x2.x, b2 = (a2.height - ((s2.top || 0) + (s2.bottom || 0) + n2.padding.top + n2.padding.bottom)) / x2.y;
  54639. if (b2 < 0 || y2 < 0)
  54640. return void e.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");
  54641. const w2 = Math.min(a2.scaleZoom(a2.scale * Math.min(y2, b2)), n2.maxZoom), T2 = "number" == typeof n2.offset.x && "number" == typeof n2.offset.y ? new e.pointGeometry(n2.offset.x, n2.offset.y) : e.pointGeometry.convert(n2.offset), E2 = new e.pointGeometry((n2.padding.left - n2.padding.right) / 2, (n2.padding.top - n2.padding.bottom) / 2).rotate(o2 * Math.PI / 180), C2 = T2.add(E2).mult(a2.scale / a2.zoomScale(w2));
  54642. return { center: a2.unproject(l2.add(c2).div(2).sub(C2)), zoom: w2, bearing: o2 };
  54643. }
  54644. _cameraForBox(t2, i3, o2, r2, n2) {
  54645. const a2 = this._extendCameraOptions(n2);
  54646. o2 = o2 || 0, r2 = r2 || 0, t2 = e.LngLat.convert(t2), i3 = e.LngLat.convert(i3);
  54647. const s2 = this.transform.clone();
  54648. s2.padding = a2.padding;
  54649. const l2 = this.getFreeCameraOptions(), c2 = new e.LngLat(0.5 * (t2.lng + i3.lng), 0.5 * (t2.lat + i3.lat)), h2 = 0.5 * (o2 + r2);
  54650. if (s2._camera.position[2] < e.mercatorZfromAltitude(h2, c2.lat))
  54651. return void e.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");
  54652. l2.lookAtPoint(c2), s2.setFreeCameraOptions(l2);
  54653. const _2 = e.MercatorCoordinate.fromLngLat(t2), u2 = e.MercatorCoordinate.fromLngLat(i3), d2 = s2.pointRayIntersection(s2.centerPoint, h2), p2 = [(m2 = s2.rayIntersectionCoordinate(d2)).x, m2.y, m2.z];
  54654. var m2;
  54655. const f2 = s2.screenPointToMercatorRay(s2.centerPoint), g2 = "globe" !== s2.projection.name;
  54656. let v2, x2 = 0;
  54657. do {
  54658. const t3 = Math.floor(s2.zoom), i4 = 1 << t3, n3 = Math.min(i4 * _2.x, i4 * u2.x), a3 = Math.min(i4 * _2.y, i4 * u2.y), l3 = Math.max(i4 * _2.x, i4 * u2.x), c3 = Math.max(i4 * _2.y, i4 * u2.y), h3 = new e.Aabb([n3, a3, o2], [l3, c3, r2]), d3 = e.Frustum.fromInvProjectionMatrix(s2.invProjMatrix, s2.worldSize, t3, g2);
  54659. if (2 !== h3.intersects(d3)) {
  54660. v2 && (s2._camera.position = e.scaleAndAdd([], s2._camera.position, f2.dir, -v2), s2._updateStateFromCamera());
  54661. break;
  54662. }
  54663. const m3 = e.sub([], s2._camera.position, p2);
  54664. v2 = 0.5 * e.length(m3), s2._camera.position = e.scaleAndAdd([], s2._camera.position, f2.dir, v2);
  54665. try {
  54666. s2._updateStateFromCamera();
  54667. } catch (t4) {
  54668. return void e.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");
  54669. }
  54670. } while (++x2 < 10);
  54671. return { center: s2.center, zoom: s2.zoom, bearing: s2.bearing, pitch: s2.pitch };
  54672. }
  54673. fitBounds(e2, t2, i3) {
  54674. return this._fitInternal(this.cameraForBounds(e2, t2), t2, i3);
  54675. }
  54676. _raycastElevationBox(t2, i3) {
  54677. const o2 = this.transform.elevation;
  54678. if (!o2)
  54679. return;
  54680. const r2 = new e.pointGeometry(t2.x, i3.y), n2 = new e.pointGeometry(i3.x, t2.y), a2 = o2.pointCoordinate(t2);
  54681. if (!a2)
  54682. return;
  54683. const s2 = o2.pointCoordinate(i3);
  54684. if (!s2)
  54685. return;
  54686. const l2 = o2.pointCoordinate(r2);
  54687. if (!l2)
  54688. return;
  54689. const c2 = o2.pointCoordinate(n2);
  54690. if (!c2)
  54691. return;
  54692. const h2 = new e.MercatorCoordinate(a2[0], a2[1]).toLngLat(), _2 = new e.MercatorCoordinate(s2[0], s2[1]).toLngLat(), u2 = new e.MercatorCoordinate(l2[0], l2[1]).toLngLat(), d2 = new e.MercatorCoordinate(c2[0], c2[1]).toLngLat(), p2 = Math.min(h2.lng, Math.min(_2.lng, Math.min(u2.lng, d2.lng))), m2 = Math.min(h2.lat, Math.min(_2.lat, Math.min(u2.lat, d2.lat))), f2 = Math.max(h2.lng, Math.max(_2.lng, Math.max(u2.lng, d2.lng))), g2 = Math.max(h2.lat, Math.max(_2.lat, Math.max(u2.lat, d2.lat))), v2 = Math.min(a2[3], Math.min(s2[3], Math.min(l2[3], c2[3]))), x2 = Math.max(a2[3], Math.max(s2[3], Math.max(l2[3], c2[3])));
  54693. return { minLngLat: new e.LngLat(p2, m2), maxLngLat: new e.LngLat(f2, g2), minAltitude: v2, maxAltitude: x2 };
  54694. }
  54695. fitScreenCoordinates(t2, i3, o2, r2, n2) {
  54696. let a2, s2, l2, c2;
  54697. const h2 = e.pointGeometry.convert(t2), _2 = e.pointGeometry.convert(i3), u2 = this._raycastElevationBox(h2, _2);
  54698. if (u2)
  54699. a2 = u2.minLngLat, s2 = u2.maxLngLat, l2 = u2.minAltitude, c2 = u2.maxAltitude;
  54700. else {
  54701. if (this.transform.anyCornerOffEdge(h2, _2))
  54702. return this;
  54703. a2 = this.transform.pointLocation(h2), s2 = this.transform.pointLocation(_2);
  54704. }
  54705. return this._fitInternal(0 === this.transform.pitch ? this._cameraForBoxAndBearing(this.transform.pointLocation(e.pointGeometry.convert(t2)), this.transform.pointLocation(e.pointGeometry.convert(i3)), o2, r2) : this._cameraForBox(a2, s2, l2, c2, r2), r2, n2);
  54706. }
  54707. _fitInternal(t2, i3, o2) {
  54708. return t2 ? (delete (i3 = e.extend(t2, i3)).padding, i3.linear ? this.easeTo(i3, o2) : this.flyTo(i3, o2)) : this;
  54709. }
  54710. jumpTo(t2, i3) {
  54711. this.stop();
  54712. const o2 = t2.preloadOnly ? this.transform.clone() : this.transform;
  54713. let r2 = false, n2 = false, a2 = false;
  54714. return "zoom" in t2 && o2.zoom !== +t2.zoom && (r2 = true, o2.zoom = +t2.zoom), void 0 !== t2.center && (o2.center = e.LngLat.convert(t2.center)), "bearing" in t2 && o2.bearing !== +t2.bearing && (n2 = true, o2.bearing = +t2.bearing), "pitch" in t2 && o2.pitch !== +t2.pitch && (a2 = true, o2.pitch = +t2.pitch), null == t2.padding || o2.isPaddingEqual(t2.padding) || (o2.padding = t2.padding), t2.preloadOnly ? (this._preloadTiles(o2), this) : (this.fire(new e.Event("movestart", i3)).fire(new e.Event("move", i3)), r2 && this.fire(new e.Event("zoomstart", i3)).fire(new e.Event("zoom", i3)).fire(new e.Event("zoomend", i3)), n2 && this.fire(new e.Event("rotatestart", i3)).fire(new e.Event("rotate", i3)).fire(new e.Event("rotateend", i3)), a2 && this.fire(new e.Event("pitchstart", i3)).fire(new e.Event("pitch", i3)).fire(new e.Event("pitchend", i3)), this.fire(new e.Event("moveend", i3)));
  54715. }
  54716. getFreeCameraOptions() {
  54717. return this.transform.projection.supportsFreeCamera || e.warnOnce(Br), this.transform.getFreeCameraOptions();
  54718. }
  54719. setFreeCameraOptions(t2, i3) {
  54720. const o2 = this.transform;
  54721. if (!o2.projection.supportsFreeCamera)
  54722. return e.warnOnce(Br), this;
  54723. this.stop();
  54724. const r2 = o2.zoom, n2 = o2.pitch, a2 = o2.bearing;
  54725. o2.setFreeCameraOptions(t2);
  54726. const s2 = r2 !== o2.zoom, l2 = n2 !== o2.pitch, c2 = a2 !== o2.bearing;
  54727. return this.fire(new e.Event("movestart", i3)).fire(new e.Event("move", i3)), s2 && this.fire(new e.Event("zoomstart", i3)).fire(new e.Event("zoom", i3)).fire(new e.Event("zoomend", i3)), c2 && this.fire(new e.Event("rotatestart", i3)).fire(new e.Event("rotate", i3)).fire(new e.Event("rotateend", i3)), l2 && this.fire(new e.Event("pitchstart", i3)).fire(new e.Event("pitch", i3)).fire(new e.Event("pitchend", i3)), this.fire(new e.Event("moveend", i3)), this;
  54728. }
  54729. easeTo(t2, i3) {
  54730. this._stop(false, t2.easeId), (false === (t2 = e.extend({ offset: [0, 0], duration: 500, easing: e.ease }, t2)).animate || !t2.essential && e.exported.prefersReducedMotion) && (t2.duration = 0);
  54731. const o2 = this.transform, r2 = this.getZoom(), n2 = this.getBearing(), a2 = this.getPitch(), s2 = this.getPadding(), l2 = "zoom" in t2 ? +t2.zoom : r2, c2 = "bearing" in t2 ? this._normalizeBearing(t2.bearing, n2) : n2, h2 = "pitch" in t2 ? +t2.pitch : a2, _2 = "padding" in t2 ? t2.padding : o2.padding, u2 = e.pointGeometry.convert(t2.offset);
  54732. let d2, p2, m2;
  54733. if ("globe" === o2.projection.name) {
  54734. const i4 = e.MercatorCoordinate.fromLngLat(o2.center), r3 = u2.rotate(-o2.angle);
  54735. i4.x += r3.x / o2.worldSize, i4.y += r3.y / o2.worldSize;
  54736. const n3 = i4.toLngLat(), a3 = e.LngLat.convert(t2.center || n3);
  54737. this._normalizeCenter(a3), d2 = o2.centerPoint.add(r3), p2 = new e.pointGeometry(i4.x, i4.y).mult(o2.worldSize), m2 = new e.pointGeometry(e.mercatorXfromLng(a3.lng), e.mercatorYfromLat(a3.lat)).mult(o2.worldSize).sub(p2);
  54738. } else {
  54739. d2 = o2.centerPoint.add(u2);
  54740. const i4 = o2.pointLocation(d2), r3 = e.LngLat.convert(t2.center || i4);
  54741. this._normalizeCenter(r3), p2 = o2.project(i4), m2 = o2.project(r3).sub(p2);
  54742. }
  54743. const f2 = o2.zoomScale(l2 - r2);
  54744. let g2, v2;
  54745. t2.around && (g2 = e.LngLat.convert(t2.around), v2 = o2.locationPoint(g2));
  54746. const x2 = this._zooming || l2 !== r2, y2 = this._rotating || n2 !== c2, b2 = this._pitching || h2 !== a2, w2 = !o2.isPaddingEqual(_2), T2 = (o3) => (T3) => {
  54747. if (x2 && (o3.zoom = e.number(r2, l2, T3)), y2 && (o3.bearing = e.number(n2, c2, T3)), b2 && (o3.pitch = e.number(a2, h2, T3)), w2 && (o3.interpolatePadding(s2, _2, T3), d2 = o3.centerPoint.add(u2)), g2)
  54748. o3.setLocationAtPoint(g2, v2);
  54749. else {
  54750. const e2 = o3.zoomScale(o3.zoom - r2), t3 = l2 > r2 ? Math.min(2, f2) : Math.max(0.5, f2), i4 = Math.pow(t3, 1 - T3), n3 = o3.unproject(p2.add(m2.mult(T3 * i4)).mult(e2));
  54751. o3.setLocationAtPoint(o3.renderWorldCopies ? n3.wrap() : n3, d2);
  54752. }
  54753. return t2.preloadOnly || this._fireMoveEvents(i3), o3;
  54754. };
  54755. if (t2.preloadOnly) {
  54756. const e2 = this._emulate(T2, t2.duration, o2);
  54757. return this._preloadTiles(e2), this;
  54758. }
  54759. const E2 = { moving: this._moving, zooming: this._zooming, rotating: this._rotating, pitching: this._pitching };
  54760. return this._zooming = x2, this._rotating = y2, this._pitching = b2, this._padding = w2, this._easeId = t2.easeId, this._prepareEase(i3, t2.noMoveStart, E2), this._ease(T2(o2), (e2) => {
  54761. o2.recenterOnTerrain(), this._afterEase(i3, e2);
  54762. }, t2), this;
  54763. }
  54764. _prepareEase(t2, i3, o2 = {}) {
  54765. this._moving = true, this.transform.cameraElevationReference = "sea", i3 || o2.moving || this.fire(new e.Event("movestart", t2)), this._zooming && !o2.zooming && this.fire(new e.Event("zoomstart", t2)), this._rotating && !o2.rotating && this.fire(new e.Event("rotatestart", t2)), this._pitching && !o2.pitching && this.fire(new e.Event("pitchstart", t2));
  54766. }
  54767. _fireMoveEvents(t2) {
  54768. this.fire(new e.Event("move", t2)), this._zooming && this.fire(new e.Event("zoom", t2)), this._rotating && this.fire(new e.Event("rotate", t2)), this._pitching && this.fire(new e.Event("pitch", t2));
  54769. }
  54770. _afterEase(t2, i3) {
  54771. if (this._easeId && i3 && this._easeId === i3)
  54772. return;
  54773. this._easeId = void 0, this.transform.cameraElevationReference = "ground";
  54774. const o2 = this._zooming, r2 = this._rotating, n2 = this._pitching;
  54775. this._moving = false, this._zooming = false, this._rotating = false, this._pitching = false, this._padding = false, o2 && this.fire(new e.Event("zoomend", t2)), r2 && this.fire(new e.Event("rotateend", t2)), n2 && this.fire(new e.Event("pitchend", t2)), this.fire(new e.Event("moveend", t2));
  54776. }
  54777. flyTo(t2, i3) {
  54778. if (!t2.essential && e.exported.prefersReducedMotion) {
  54779. const o3 = e.pick(t2, ["center", "zoom", "bearing", "pitch", "around"]);
  54780. return this.jumpTo(o3, i3);
  54781. }
  54782. this.stop(), t2 = e.extend({ offset: [0, 0], speed: 1.2, curve: 1.42, easing: e.ease }, t2);
  54783. const o2 = this.transform, r2 = this.getZoom(), n2 = this.getBearing(), a2 = this.getPitch(), s2 = this.getPadding(), l2 = "zoom" in t2 ? e.clamp(+t2.zoom, o2.minZoom, o2.maxZoom) : r2, c2 = "bearing" in t2 ? this._normalizeBearing(t2.bearing, n2) : n2, h2 = "pitch" in t2 ? +t2.pitch : a2, _2 = "padding" in t2 ? t2.padding : o2.padding, u2 = o2.zoomScale(l2 - r2), d2 = e.pointGeometry.convert(t2.offset);
  54784. let p2 = o2.centerPoint.add(d2);
  54785. const m2 = o2.pointLocation(p2), f2 = e.LngLat.convert(t2.center || m2);
  54786. this._normalizeCenter(f2);
  54787. const g2 = o2.project(m2), v2 = o2.project(f2).sub(g2);
  54788. let x2 = t2.curve;
  54789. const y2 = Math.max(o2.width, o2.height), b2 = y2 / u2, w2 = v2.mag();
  54790. if ("minZoom" in t2) {
  54791. const i4 = e.clamp(Math.min(t2.minZoom, r2, l2), o2.minZoom, o2.maxZoom), n3 = y2 / o2.zoomScale(i4 - r2);
  54792. x2 = Math.sqrt(n3 / w2 * 2);
  54793. }
  54794. const T2 = x2 * x2;
  54795. function E2(e2) {
  54796. const t3 = (b2 * b2 - y2 * y2 + (e2 ? -1 : 1) * T2 * T2 * w2 * w2) / (2 * (e2 ? b2 : y2) * T2 * w2);
  54797. return Math.log(Math.sqrt(t3 * t3 + 1) - t3);
  54798. }
  54799. function C2(e2) {
  54800. return (Math.exp(e2) - Math.exp(-e2)) / 2;
  54801. }
  54802. function I2(e2) {
  54803. return (Math.exp(e2) + Math.exp(-e2)) / 2;
  54804. }
  54805. const M2 = E2(0);
  54806. let S2 = function(e2) {
  54807. return I2(M2) / I2(M2 + x2 * e2);
  54808. }, z2 = function(e2) {
  54809. return y2 * ((I2(M2) * (C2(t3 = M2 + x2 * e2) / I2(t3)) - C2(M2)) / T2) / w2;
  54810. var t3;
  54811. }, D2 = (E2(1) - M2) / x2;
  54812. if (Math.abs(w2) < 1e-6 || !isFinite(D2)) {
  54813. if (Math.abs(y2 - b2) < 1e-6)
  54814. return this.easeTo(t2, i3);
  54815. const e2 = b2 < y2 ? -1 : 1;
  54816. D2 = Math.abs(Math.log(b2 / y2)) / x2, z2 = function() {
  54817. return 0;
  54818. }, S2 = function(t3) {
  54819. return Math.exp(e2 * x2 * t3);
  54820. };
  54821. }
  54822. t2.duration = "duration" in t2 ? +t2.duration : 1e3 * D2 / ("screenSpeed" in t2 ? +t2.screenSpeed / x2 : +t2.speed), t2.maxDuration && t2.duration > t2.maxDuration && (t2.duration = 0);
  54823. const P2 = n2 !== c2, A2 = h2 !== a2, L2 = !o2.isPaddingEqual(_2), R2 = (o3) => (u3) => {
  54824. const m3 = u3 * D2, x3 = 1 / S2(m3);
  54825. o3.zoom = 1 === u3 ? l2 : r2 + o3.scaleZoom(x3), P2 && (o3.bearing = e.number(n2, c2, u3)), A2 && (o3.pitch = e.number(a2, h2, u3)), L2 && (o3.interpolatePadding(s2, _2, u3), p2 = o3.centerPoint.add(d2));
  54826. const y3 = 1 === u3 ? f2 : o3.unproject(g2.add(v2.mult(z2(m3))).mult(x3));
  54827. return o3.setLocationAtPoint(o3.renderWorldCopies ? y3.wrap() : y3, p2), o3._updateCameraOnTerrain(), t2.preloadOnly || this._fireMoveEvents(i3), o3;
  54828. };
  54829. if (t2.preloadOnly) {
  54830. const e2 = this._emulate(R2, t2.duration, o2);
  54831. return this._preloadTiles(e2), this;
  54832. }
  54833. return this._zooming = true, this._rotating = P2, this._pitching = A2, this._padding = L2, this._prepareEase(i3, false), this._ease(R2(o2), () => this._afterEase(i3), t2), this;
  54834. }
  54835. isEasing() {
  54836. return !!this._easeFrameId;
  54837. }
  54838. stop() {
  54839. return this._stop();
  54840. }
  54841. _stop(e2, t2) {
  54842. if (this._easeFrameId && (this._cancelRenderFrame(this._easeFrameId), this._easeFrameId = void 0, this._onEaseFrame = void 0), this._onEaseEnd) {
  54843. const e3 = this._onEaseEnd;
  54844. this._onEaseEnd = void 0, e3.call(this, t2);
  54845. }
  54846. if (!e2) {
  54847. const e3 = this.handlers;
  54848. e3 && e3.stop(false);
  54849. }
  54850. return this;
  54851. }
  54852. _ease(t2, i3, o2) {
  54853. false === o2.animate || 0 === o2.duration ? (t2(1), i3()) : (this._easeStart = e.exported.now(), this._easeOptions = o2, this._onEaseFrame = t2, this._onEaseEnd = i3, this._easeFrameId = this._requestRenderFrame(this._renderFrameCallback));
  54854. }
  54855. _renderFrameCallback() {
  54856. const t2 = Math.min((e.exported.now() - this._easeStart) / this._easeOptions.duration, 1), i3 = this._onEaseFrame;
  54857. i3 && i3(this._easeOptions.easing(t2)), t2 < 1 ? this._easeFrameId = this._requestRenderFrame(this._renderFrameCallback) : this.stop();
  54858. }
  54859. _normalizeBearing(t2, i3) {
  54860. t2 = e.wrap(t2, -180, 180);
  54861. const o2 = Math.abs(t2 - i3);
  54862. return Math.abs(t2 - 360 - i3) < o2 && (t2 -= 360), Math.abs(t2 + 360 - i3) < o2 && (t2 += 360), t2;
  54863. }
  54864. _normalizeCenter(e2) {
  54865. const t2 = this.transform;
  54866. if (!t2.renderWorldCopies || t2.maxBounds)
  54867. return;
  54868. const i3 = e2.lng - t2.center.lng;
  54869. e2.lng += i3 > 180 ? -360 : i3 < -180 ? 360 : 0;
  54870. }
  54871. _emulate(e2, t2, i3) {
  54872. const o2 = Math.ceil(15 * t2 / 1e3), r2 = [], n2 = e2(i3.clone());
  54873. for (let e3 = 0; e3 <= o2; e3++) {
  54874. const t3 = n2(e3 / o2);
  54875. r2.push(t3.clone());
  54876. }
  54877. return r2;
  54878. }
  54879. }
  54880. class Ur {
  54881. constructor(t2 = {}) {
  54882. this.options = t2, e.bindAll(["_toggleAttribution", "_updateEditLink", "_updateData", "_updateCompact"], this);
  54883. }
  54884. getDefaultPosition() {
  54885. return "bottom-right";
  54886. }
  54887. onAdd(e2) {
  54888. const t2 = this.options && this.options.compact;
  54889. return this._map = e2, this._container = n("div", "mapboxgl-ctrl mapboxgl-ctrl-attrib"), this._compactButton = n("button", "mapboxgl-ctrl-attrib-button", this._container), n("span", "mapboxgl-ctrl-icon", this._compactButton).setAttribute("aria-hidden", "true"), this._compactButton.type = "button", this._compactButton.addEventListener("click", this._toggleAttribution), this._setElementTitle(this._compactButton, "ToggleAttribution"), this._innerContainer = n("div", "mapboxgl-ctrl-attrib-inner", this._container), this._innerContainer.setAttribute("role", "list"), t2 && this._container.classList.add("mapboxgl-compact"), this._updateAttributions(), this._updateEditLink(), this._map.on("styledata", this._updateData), this._map.on("sourcedata", this._updateData), this._map.on("moveend", this._updateEditLink), void 0 === t2 && (this._map.on("resize", this._updateCompact), this._updateCompact()), this._container;
  54890. }
  54891. onRemove() {
  54892. this._container.remove(), this._map.off("styledata", this._updateData), this._map.off("sourcedata", this._updateData), this._map.off("moveend", this._updateEditLink), this._map.off("resize", this._updateCompact), this._map = void 0, this._attribHTML = void 0;
  54893. }
  54894. _setElementTitle(e2, t2) {
  54895. const i3 = this._map._getUIString(`AttributionControl.${t2}`);
  54896. e2.setAttribute("aria-label", i3), e2.removeAttribute("title"), e2.firstElementChild && e2.firstElementChild.setAttribute("title", i3);
  54897. }
  54898. _toggleAttribution() {
  54899. this._container.classList.contains("mapboxgl-compact-show") ? (this._container.classList.remove("mapboxgl-compact-show"), this._compactButton.setAttribute("aria-expanded", "false")) : (this._container.classList.add("mapboxgl-compact-show"), this._compactButton.setAttribute("aria-expanded", "true"));
  54900. }
  54901. _updateEditLink() {
  54902. let t2 = this._editLink;
  54903. t2 || (t2 = this._editLink = this._container.querySelector(".mapbox-improve-map"));
  54904. const i3 = [{ key: "owner", value: this.styleOwner }, { key: "id", value: this.styleId }, { key: "access_token", value: this._map._requestManager._customAccessToken || e.config.ACCESS_TOKEN }];
  54905. if (t2) {
  54906. const o2 = i3.reduce((e2, t3, o3) => (t3.value && (e2 += `${t3.key}=${t3.value}${o3 < i3.length - 1 ? "&" : ""}`), e2), "?");
  54907. t2.href = `${e.config.FEEDBACK_URL}/${o2}${this._map._hash ? this._map._hash.getHashString(true) : ""}`, t2.rel = "noopener nofollow", this._setElementTitle(t2, "MapFeedback");
  54908. }
  54909. }
  54910. _updateData(e2) {
  54911. !e2 || "metadata" !== e2.sourceDataType && "visibility" !== e2.sourceDataType && "style" !== e2.dataType || (this._updateAttributions(), this._updateEditLink());
  54912. }
  54913. _updateAttributions() {
  54914. if (!this._map.style)
  54915. return;
  54916. let e2 = [];
  54917. if (this._map.style.stylesheet) {
  54918. const e3 = this._map.style.stylesheet;
  54919. this.styleOwner = e3.owner, this.styleId = e3.id;
  54920. }
  54921. const t2 = this._map.style._sourceCaches;
  54922. for (const i4 in t2) {
  54923. const o2 = t2[i4];
  54924. if (o2.used) {
  54925. const t3 = o2.getSource();
  54926. t3.attribution && e2.indexOf(t3.attribution) < 0 && e2.push(t3.attribution);
  54927. }
  54928. }
  54929. e2.sort((e3, t3) => e3.length - t3.length), e2 = e2.filter((t3, i4) => {
  54930. for (let o2 = i4 + 1; o2 < e2.length; o2++)
  54931. if (e2[o2].indexOf(t3) >= 0)
  54932. return false;
  54933. return true;
  54934. }), this.options.customAttribution && (Array.isArray(this.options.customAttribution) ? e2 = [...this.options.customAttribution, ...e2] : e2.unshift(this.options.customAttribution));
  54935. const i3 = e2.join(" | ");
  54936. i3 !== this._attribHTML && (this._attribHTML = i3, e2.length ? (this._innerContainer.innerHTML = i3, this._container.classList.remove("mapboxgl-attrib-empty")) : this._container.classList.add("mapboxgl-attrib-empty"), this._editLink = null);
  54937. }
  54938. _updateCompact() {
  54939. this._map.getCanvasContainer().offsetWidth <= 640 ? this._container.classList.add("mapboxgl-compact") : this._container.classList.remove("mapboxgl-compact", "mapboxgl-compact-show");
  54940. }
  54941. }
  54942. class Nr {
  54943. constructor() {
  54944. e.bindAll(["_updateLogo", "_updateCompact"], this);
  54945. }
  54946. onAdd(e2) {
  54947. this._map = e2, this._container = n("div", "mapboxgl-ctrl");
  54948. const t2 = n("a", "mapboxgl-ctrl-logo");
  54949. return t2.target = "_blank", t2.rel = "noopener nofollow", t2.href = "https://www.mapbox.com/", t2.setAttribute("aria-label", this._map._getUIString("LogoControl.Title")), t2.setAttribute("rel", "noopener nofollow"), this._container.appendChild(t2), this._container.style.display = "none", this._map.on("sourcedata", this._updateLogo), this._updateLogo(), this._map.on("resize", this._updateCompact), this._updateCompact(), this._container;
  54950. }
  54951. onRemove() {
  54952. this._container.remove(), this._map.off("sourcedata", this._updateLogo), this._map.off("resize", this._updateCompact);
  54953. }
  54954. getDefaultPosition() {
  54955. return "bottom-left";
  54956. }
  54957. _updateLogo(e2) {
  54958. e2 && "metadata" !== e2.sourceDataType || (this._container.style.display = this._logoRequired() ? "block" : "none");
  54959. }
  54960. _logoRequired() {
  54961. if (!this._map.style)
  54962. return true;
  54963. const e2 = this._map.style._sourceCaches;
  54964. if (0 === Object.entries(e2).length)
  54965. return true;
  54966. for (const t2 in e2) {
  54967. const i3 = e2[t2].getSource();
  54968. if (i3.hasOwnProperty("mapbox_logo") && !i3.mapbox_logo)
  54969. return false;
  54970. }
  54971. return true;
  54972. }
  54973. _updateCompact() {
  54974. const e2 = this._container.children;
  54975. if (e2.length) {
  54976. const t2 = e2[0];
  54977. this._map.getCanvasContainer().offsetWidth < 250 ? t2.classList.add("mapboxgl-compact") : t2.classList.remove("mapboxgl-compact");
  54978. }
  54979. }
  54980. }
  54981. class Gr {
  54982. constructor() {
  54983. this._queue = [], this._id = 0, this._cleared = false, this._currentlyRunning = false;
  54984. }
  54985. add(e2) {
  54986. const t2 = ++this._id;
  54987. return this._queue.push({ callback: e2, id: t2, cancelled: false }), t2;
  54988. }
  54989. remove(e2) {
  54990. const t2 = this._currentlyRunning, i3 = t2 ? this._queue.concat(t2) : this._queue;
  54991. for (const t3 of i3)
  54992. if (t3.id === e2)
  54993. return void (t3.cancelled = true);
  54994. }
  54995. run(e2 = 0) {
  54996. const t2 = this._currentlyRunning = this._queue;
  54997. this._queue = [];
  54998. for (const i3 of t2)
  54999. if (!i3.cancelled && (i3.callback(e2), this._cleared))
  55000. break;
  55001. this._cleared = false, this._currentlyRunning = false;
  55002. }
  55003. clear() {
  55004. this._currentlyRunning && (this._cleared = true), this._queue = [];
  55005. }
  55006. }
  55007. function jr(t2, i3, o2) {
  55008. if (t2 = new e.LngLat(t2.lng, t2.lat), i3) {
  55009. const r2 = new e.LngLat(t2.lng - 360, t2.lat), n2 = new e.LngLat(t2.lng + 360, t2.lat), a2 = 360 * Math.ceil(Math.abs(t2.lng - o2.center.lng) / 360), s2 = o2.locationPoint(t2).distSqr(i3), l2 = i3.x < 0 || i3.y < 0 || i3.x > o2.width || i3.y > o2.height;
  55010. o2.locationPoint(r2).distSqr(i3) < s2 && (l2 || Math.abs(r2.lng - o2.center.lng) < a2) ? t2 = r2 : o2.locationPoint(n2).distSqr(i3) < s2 && (l2 || Math.abs(n2.lng - o2.center.lng) < a2) && (t2 = n2);
  55011. }
  55012. for (; Math.abs(t2.lng - o2.center.lng) > 180; ) {
  55013. const e2 = o2.locationPoint(t2);
  55014. if (e2.x >= 0 && e2.y >= 0 && e2.x <= o2.width && e2.y <= o2.height)
  55015. break;
  55016. t2.lng > o2.center.lng ? t2.lng -= 360 : t2.lng += 360;
  55017. }
  55018. return t2;
  55019. }
  55020. const Zr = { center: "translate(-50%,-50%)", top: "translate(-50%,0)", "top-left": "translate(0,0)", "top-right": "translate(-100%,0)", bottom: "translate(-50%,-100%)", "bottom-left": "translate(0,-100%)", "bottom-right": "translate(-100%,-100%)", left: "translate(0,-50%)", right: "translate(-100%,-50%)" };
  55021. class Vr extends e.Evented {
  55022. constructor(t2, i3) {
  55023. if (super(), (t2 instanceof e.window.HTMLElement || i3) && (t2 = e.extend({ element: t2 }, i3)), e.bindAll(["_update", "_onMove", "_onUp", "_addDragHandler", "_onMapClick", "_onKeyPress", "_clearFadeTimer"], this), this._anchor = t2 && t2.anchor || "center", this._color = t2 && t2.color || "#3FB1CE", this._scale = t2 && t2.scale || 1, this._draggable = t2 && t2.draggable || false, this._clickTolerance = t2 && t2.clickTolerance || 0, this._isDragging = false, this._state = "inactive", this._rotation = t2 && t2.rotation || 0, this._rotationAlignment = t2 && t2.rotationAlignment || "auto", this._pitchAlignment = t2 && t2.pitchAlignment && "auto" !== t2.pitchAlignment ? t2.pitchAlignment : this._rotationAlignment, this._updateMoving = () => this._update(true), t2 && t2.element)
  55024. this._element = t2.element, this._offset = e.pointGeometry.convert(t2 && t2.offset || [0, 0]);
  55025. else {
  55026. this._defaultMarker = true, this._element = n("div");
  55027. const i4 = 41, o3 = 27, r2 = a("svg", { display: "block", height: i4 * this._scale + "px", width: o3 * this._scale + "px", viewBox: `0 0 ${o3} ${i4}` }, this._element), s2 = a("radialGradient", { id: "shadowGradient" }, a("defs", {}, r2));
  55028. a("stop", { offset: "10%", "stop-opacity": 0.4 }, s2), a("stop", { offset: "100%", "stop-opacity": 0.05 }, s2), a("ellipse", { cx: 13.5, cy: 34.8, rx: 10.5, ry: 5.25, fill: "url(#shadowGradient)" }, r2), a("path", { fill: this._color, d: "M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z" }, r2), a("path", { opacity: 0.25, d: "M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z" }, r2), a("circle", { fill: "white", cx: 13.5, cy: 13.5, r: 5.5 }, r2), this._offset = e.pointGeometry.convert(t2 && t2.offset || [0, -14]);
  55029. }
  55030. this._element.hasAttribute("aria-label") || this._element.setAttribute("aria-label", "Map marker"), this._element.classList.add("mapboxgl-marker"), this._element.addEventListener("dragstart", (e2) => {
  55031. e2.preventDefault();
  55032. }), this._element.addEventListener("mousedown", (e2) => {
  55033. e2.preventDefault();
  55034. });
  55035. const o2 = this._element.classList;
  55036. for (const e2 in Zr)
  55037. o2.remove(`mapboxgl-marker-anchor-${e2}`);
  55038. o2.add(`mapboxgl-marker-anchor-${this._anchor}`), this._popup = null;
  55039. }
  55040. addTo(e2) {
  55041. return e2 === this._map || (this.remove(), this._map = e2, e2.getCanvasContainer().appendChild(this._element), e2.on("move", this._updateMoving), e2.on("moveend", this._update), e2.on("remove", this._clearFadeTimer), e2._addMarker(this), this.setDraggable(this._draggable), this._update(), e2.on("click", this._onMapClick)), this;
  55042. }
  55043. remove() {
  55044. const e2 = this._map;
  55045. return e2 && (e2.off("click", this._onMapClick), e2.off("move", this._updateMoving), e2.off("moveend", this._update), e2.off("mousedown", this._addDragHandler), e2.off("touchstart", this._addDragHandler), e2.off("mouseup", this._onUp), e2.off("touchend", this._onUp), e2.off("mousemove", this._onMove), e2.off("touchmove", this._onMove), e2.off("remove", this._clearFadeTimer), e2._removeMarker(this), this._map = void 0), this._clearFadeTimer(), this._element.remove(), this._popup && this._popup.remove(), this;
  55046. }
  55047. getLngLat() {
  55048. return this._lngLat;
  55049. }
  55050. setLngLat(t2) {
  55051. return this._lngLat = e.LngLat.convert(t2), this._pos = null, this._popup && this._popup.setLngLat(this._lngLat), this._update(true), this;
  55052. }
  55053. getElement() {
  55054. return this._element;
  55055. }
  55056. setPopup(e2) {
  55057. if (this._popup && (this._popup.remove(), this._popup = null, this._element.removeAttribute("role"), this._element.removeEventListener("keypress", this._onKeyPress), this._originalTabIndex || this._element.removeAttribute("tabindex")), e2) {
  55058. if (!("offset" in e2.options)) {
  55059. const t2 = 38.1, i3 = 13.5, o2 = Math.sqrt(Math.pow(i3, 2) / 2);
  55060. e2.options.offset = this._defaultMarker ? { top: [0, 0], "top-left": [0, 0], "top-right": [0, 0], bottom: [0, -t2], "bottom-left": [o2, -1 * (t2 - i3 + o2)], "bottom-right": [-o2, -1 * (t2 - i3 + o2)], left: [i3, -1 * (t2 - i3)], right: [-i3, -1 * (t2 - i3)] } : this._offset;
  55061. }
  55062. this._popup = e2, this._lngLat && this._popup.setLngLat(this._lngLat), this._element.setAttribute("role", "button"), this._originalTabIndex = this._element.getAttribute("tabindex"), this._originalTabIndex || this._element.setAttribute("tabindex", "0"), this._element.addEventListener("keypress", this._onKeyPress), this._element.setAttribute("aria-expanded", "false");
  55063. }
  55064. return this;
  55065. }
  55066. _onKeyPress(e2) {
  55067. const t2 = e2.code, i3 = e2.charCode || e2.keyCode;
  55068. "Space" !== t2 && "Enter" !== t2 && 32 !== i3 && 13 !== i3 || this.togglePopup();
  55069. }
  55070. _onMapClick(e2) {
  55071. const t2 = e2.originalEvent.target, i3 = this._element;
  55072. this._popup && (t2 === i3 || i3.contains(t2)) && this.togglePopup();
  55073. }
  55074. getPopup() {
  55075. return this._popup;
  55076. }
  55077. togglePopup() {
  55078. const e2 = this._popup;
  55079. return e2 ? (e2.isOpen() ? (e2.remove(), this._element.setAttribute("aria-expanded", "false")) : this._map && (e2.addTo(this._map), this._element.setAttribute("aria-expanded", "true")), this) : this;
  55080. }
  55081. _evaluateOpacity() {
  55082. const e2 = this._map;
  55083. if (!e2)
  55084. return;
  55085. const t2 = this._pos;
  55086. if (!t2 || t2.x < 0 || t2.x > e2.transform.width || t2.y < 0 || t2.y > e2.transform.height)
  55087. return void this._clearFadeTimer();
  55088. const i3 = e2.unproject(t2);
  55089. let o2 = false;
  55090. if (e2.transform._terrainEnabled() && e2.getTerrain()) {
  55091. const t3 = e2.getFreeCameraOptions();
  55092. if (t3.position) {
  55093. const e3 = t3.position.toLngLat();
  55094. o2 = e3.distanceTo(i3) < 0.9 * e3.distanceTo(this._lngLat);
  55095. }
  55096. }
  55097. const r2 = (1 - e2._queryFogOpacity(i3)) * (o2 ? 0.2 : 1);
  55098. this._element.style.opacity = `${r2}`, this._popup && this._popup._setOpacity(`${r2}`), this._fadeTimer = null;
  55099. }
  55100. _clearFadeTimer() {
  55101. this._fadeTimer && (clearTimeout(this._fadeTimer), this._fadeTimer = null);
  55102. }
  55103. _updateDOM() {
  55104. const e2 = this._pos;
  55105. if (!e2)
  55106. return;
  55107. const t2 = this._offset.mult(this._scale), i3 = this._calculatePitch(), o2 = this._calculateRotation();
  55108. this._element.style.transform = `
  55109. translate(${e2.x}px, ${e2.y}px) ${Zr[this._anchor]}
  55110. rotateX(${i3}deg) rotateZ(${o2}deg)
  55111. translate(${t2.x}px, ${t2.y}px)
  55112. `;
  55113. }
  55114. _calculatePitch() {
  55115. return "viewport" === this._pitchAlignment || "auto" === this._pitchAlignment ? 0 : this._map && "map" === this._pitchAlignment ? this._map.getPitch() : 0;
  55116. }
  55117. _calculateRotation() {
  55118. return "viewport" === this._rotationAlignment || "auto" === this._rotationAlignment ? this._rotation : this._map && "map" === this._rotationAlignment ? this._rotation - this._map.getBearing() : 0;
  55119. }
  55120. _update(t2) {
  55121. e.window.cancelAnimationFrame(this._updateFrameId);
  55122. const i3 = this._map;
  55123. i3 && (i3.transform.renderWorldCopies && (this._lngLat = jr(this._lngLat, this._pos, i3.transform)), this._pos = i3.project(this._lngLat), true === t2 ? this._updateFrameId = e.window.requestAnimationFrame(() => {
  55124. this._element && this._pos && this._anchor && (this._pos = this._pos.round(), this._updateDOM());
  55125. }) : this._pos = this._pos.round(), i3._requestDomTask(() => {
  55126. this._map && (this._element && this._pos && this._anchor && this._updateDOM(), !i3.getTerrain() && !i3.getFog() || this._fadeTimer || (this._fadeTimer = setTimeout(this._evaluateOpacity.bind(this), 60)));
  55127. }));
  55128. }
  55129. getOffset() {
  55130. return this._offset;
  55131. }
  55132. setOffset(t2) {
  55133. return this._offset = e.pointGeometry.convert(t2), this._update(), this;
  55134. }
  55135. _onMove(t2) {
  55136. const i3 = this._map;
  55137. if (i3) {
  55138. if (!this._isDragging) {
  55139. const e2 = this._clickTolerance || i3._clickTolerance;
  55140. this._isDragging = t2.point.dist(this._pointerdownPos) >= e2;
  55141. }
  55142. this._isDragging && (this._pos = t2.point.sub(this._positionDelta), this._lngLat = i3.unproject(this._pos), this.setLngLat(this._lngLat), this._element.style.pointerEvents = "none", "pending" === this._state && (this._state = "active", this.fire(new e.Event("dragstart"))), this.fire(new e.Event("drag")));
  55143. }
  55144. }
  55145. _onUp() {
  55146. this._element.style.pointerEvents = "auto", this._positionDelta = null, this._pointerdownPos = null, this._isDragging = false;
  55147. const t2 = this._map;
  55148. t2 && (t2.off("mousemove", this._onMove), t2.off("touchmove", this._onMove)), "active" === this._state && this.fire(new e.Event("dragend")), this._state = "inactive";
  55149. }
  55150. _addDragHandler(e2) {
  55151. const t2 = this._map;
  55152. t2 && this._element.contains(e2.originalEvent.target) && (e2.preventDefault(), this._positionDelta = e2.point.sub(this._pos), this._pointerdownPos = e2.point, this._state = "pending", t2.on("mousemove", this._onMove), t2.on("touchmove", this._onMove), t2.once("mouseup", this._onUp), t2.once("touchend", this._onUp));
  55153. }
  55154. setDraggable(e2) {
  55155. this._draggable = !!e2;
  55156. const t2 = this._map;
  55157. return t2 && (e2 ? (t2.on("mousedown", this._addDragHandler), t2.on("touchstart", this._addDragHandler)) : (t2.off("mousedown", this._addDragHandler), t2.off("touchstart", this._addDragHandler))), this;
  55158. }
  55159. isDraggable() {
  55160. return this._draggable;
  55161. }
  55162. setRotation(e2) {
  55163. return this._rotation = e2 || 0, this._update(), this;
  55164. }
  55165. getRotation() {
  55166. return this._rotation;
  55167. }
  55168. setRotationAlignment(e2) {
  55169. return this._rotationAlignment = e2 || "auto", this._update(), this;
  55170. }
  55171. getRotationAlignment() {
  55172. return this._rotationAlignment;
  55173. }
  55174. setPitchAlignment(e2) {
  55175. return this._pitchAlignment = e2 && "auto" !== e2 ? e2 : this._rotationAlignment, this._update(), this;
  55176. }
  55177. getPitchAlignment() {
  55178. return this._pitchAlignment;
  55179. }
  55180. }
  55181. class Wr {
  55182. constructor(e2) {
  55183. this.jumpTo(e2);
  55184. }
  55185. getValue(t2) {
  55186. if (t2 <= this._startTime)
  55187. return this._start;
  55188. if (t2 >= this._endTime)
  55189. return this._end;
  55190. const i3 = e.easeCubicInOut((t2 - this._startTime) / (this._endTime - this._startTime));
  55191. return this._start * (1 - i3) + this._end * i3;
  55192. }
  55193. isEasing(e2) {
  55194. return e2 >= this._startTime && e2 <= this._endTime;
  55195. }
  55196. jumpTo(e2) {
  55197. this._startTime = -1 / 0, this._endTime = -1 / 0, this._start = e2, this._end = e2;
  55198. }
  55199. easeTo(e2, t2, i3) {
  55200. this._start = this.getValue(t2), this._end = e2, this._startTime = t2, this._endTime = t2 + i3;
  55201. }
  55202. }
  55203. const qr = { "AttributionControl.ToggleAttribution": "Toggle attribution", "AttributionControl.MapFeedback": "Map feedback", "FullscreenControl.Enter": "Enter fullscreen", "FullscreenControl.Exit": "Exit fullscreen", "GeolocateControl.FindMyLocation": "Find my location", "GeolocateControl.LocationNotAvailable": "Location not available", "LogoControl.Title": "Mapbox logo", "NavigationControl.ResetBearing": "Reset bearing to north", "NavigationControl.ZoomIn": "Zoom in", "NavigationControl.ZoomOut": "Zoom out", "ScaleControl.Feet": "ft", "ScaleControl.Meters": "m", "ScaleControl.Kilometers": "km", "ScaleControl.Miles": "mi", "ScaleControl.NauticalMiles": "nm", "ScrollZoomBlocker.CtrlMessage": "Use ctrl + scroll to zoom the map", "ScrollZoomBlocker.CmdMessage": "Use ⌘ + scroll to zoom the map", "TouchPanBlocker.Message": "Use two fingers to move the map" }, Xr = { center: [0, 0], zoom: 0, bearing: 0, pitch: 0, minZoom: -2, maxZoom: 22, minPitch: 0, maxPitch: 85, interactive: true, scrollZoom: true, boxZoom: true, dragRotate: true, dragPan: true, keyboard: true, doubleClickZoom: true, touchZoomRotate: true, touchPitch: true, cooperativeGestures: false, bearingSnap: 7, clickTolerance: 3, pitchWithRotate: true, hash: false, attributionControl: true, failIfMajorPerformanceCaveat: false, preserveDrawingBuffer: false, trackResize: true, optimizeForTerrain: true, renderWorldCopies: true, refreshExpiredTiles: true, minTileCacheSize: null, maxTileCacheSize: null, localIdeographFontFamily: "sans-serif", localFontFamily: null, transformRequest: null, accessToken: null, fadeDuration: 300, crossSourceCollisions: true };
  55204. function $r(e2) {
  55205. e2.parentNode && e2.parentNode.removeChild(e2);
  55206. }
  55207. const Hr = { showCompass: true, showZoom: true, visualizePitch: false };
  55208. class Kr {
  55209. constructor(t2, i3, o2 = false) {
  55210. this._clickTolerance = 10, this.element = i3, this.mouseRotate = new hr({ clickTolerance: t2.dragRotate._mouseRotate._clickTolerance }), this.map = t2, o2 && (this.mousePitch = new _r({ clickTolerance: t2.dragRotate._mousePitch._clickTolerance })), e.bindAll(["mousedown", "mousemove", "mouseup", "touchstart", "touchmove", "touchend", "reset"], this), i3.addEventListener("mousedown", this.mousedown), i3.addEventListener("touchstart", this.touchstart, { passive: false }), i3.addEventListener("touchmove", this.touchmove), i3.addEventListener("touchend", this.touchend), i3.addEventListener("touchcancel", this.reset);
  55211. }
  55212. down(e2, t2) {
  55213. this.mouseRotate.mousedown(e2, t2), this.mousePitch && this.mousePitch.mousedown(e2, t2), h();
  55214. }
  55215. move(e2, t2) {
  55216. const i3 = this.map, o2 = this.mouseRotate.mousemoveWindow(e2, t2), r2 = o2 && o2.bearingDelta;
  55217. if (r2 && i3.setBearing(i3.getBearing() + r2), this.mousePitch) {
  55218. const o3 = this.mousePitch.mousemoveWindow(e2, t2), r3 = o3 && o3.pitchDelta;
  55219. r3 && i3.setPitch(i3.getPitch() + r3);
  55220. }
  55221. }
  55222. off() {
  55223. const e2 = this.element;
  55224. e2.removeEventListener("mousedown", this.mousedown), e2.removeEventListener("touchstart", this.touchstart, { passive: false }), e2.removeEventListener("touchmove", this.touchmove), e2.removeEventListener("touchend", this.touchend), e2.removeEventListener("touchcancel", this.reset), this.offTemp();
  55225. }
  55226. offTemp() {
  55227. _(), e.window.removeEventListener("mousemove", this.mousemove), e.window.removeEventListener("mouseup", this.mouseup);
  55228. }
  55229. mousedown(t2) {
  55230. this.down(e.extend({}, t2, { ctrlKey: true, preventDefault: () => t2.preventDefault() }), p(this.element, t2)), e.window.addEventListener("mousemove", this.mousemove), e.window.addEventListener("mouseup", this.mouseup);
  55231. }
  55232. mousemove(e2) {
  55233. this.move(e2, p(this.element, e2));
  55234. }
  55235. mouseup(e2) {
  55236. this.mouseRotate.mouseupWindow(e2), this.mousePitch && this.mousePitch.mouseupWindow(e2), this.offTemp();
  55237. }
  55238. touchstart(e2) {
  55239. 1 !== e2.targetTouches.length ? this.reset() : (this._startPos = this._lastPos = m(this.element, e2.targetTouches)[0], this.down({ type: "mousedown", button: 0, ctrlKey: true, preventDefault: () => e2.preventDefault() }, this._startPos));
  55240. }
  55241. touchmove(e2) {
  55242. 1 !== e2.targetTouches.length ? this.reset() : (this._lastPos = m(this.element, e2.targetTouches)[0], this.move({ preventDefault: () => e2.preventDefault() }, this._lastPos));
  55243. }
  55244. touchend(e2) {
  55245. 0 === e2.targetTouches.length && this._startPos && this._lastPos && this._startPos.dist(this._lastPos) < this._clickTolerance && this.element.click(), this.reset();
  55246. }
  55247. reset() {
  55248. this.mouseRotate.reset(), this.mousePitch && this.mousePitch.reset(), delete this._startPos, delete this._lastPos, this.offTemp();
  55249. }
  55250. }
  55251. const Yr = { positionOptions: { enableHighAccuracy: false, maximumAge: 0, timeout: 6e3 }, fitBoundsOptions: { maxZoom: 15 }, trackUserLocation: false, showAccuracyCircle: true, showUserLocation: true, showUserHeading: false };
  55252. let Jr, Qr = 0, en = false;
  55253. const tn = { maxWidth: 100, unit: "metric" };
  55254. function on(e2, t2, i3) {
  55255. const o2 = i3 && i3.maxWidth || 100, r2 = e2._containerHeight / 2, n2 = e2._containerWidth / 2 - o2 / 2, a2 = e2.unproject([n2, r2]), s2 = e2.unproject([n2 + o2, r2]), l2 = a2.distanceTo(s2);
  55256. if (i3 && "imperial" === i3.unit) {
  55257. const i4 = 3.2808 * l2;
  55258. i4 > 5280 ? rn(t2, o2, i4 / 5280, e2._getUIString("ScaleControl.Miles"), e2) : rn(t2, o2, i4, e2._getUIString("ScaleControl.Feet"), e2);
  55259. } else
  55260. i3 && "nautical" === i3.unit ? rn(t2, o2, l2 / 1852, e2._getUIString("ScaleControl.NauticalMiles"), e2) : l2 >= 1e3 ? rn(t2, o2, l2 / 1e3, e2._getUIString("ScaleControl.Kilometers"), e2) : rn(t2, o2, l2, e2._getUIString("ScaleControl.Meters"), e2);
  55261. }
  55262. function rn(e2, t2, i3, o2, r2) {
  55263. const n2 = function(e3) {
  55264. const t3 = Math.pow(10, `${Math.floor(e3)}`.length - 1);
  55265. let i4 = e3 / t3;
  55266. return i4 = i4 >= 10 ? 10 : i4 >= 5 ? 5 : i4 >= 3 ? 3 : i4 >= 2 ? 2 : i4 >= 1 ? 1 : function(e4) {
  55267. const t4 = Math.pow(10, Math.ceil(-Math.log(e4) / Math.LN10));
  55268. return Math.round(e4 * t4) / t4;
  55269. }(i4), t3 * i4;
  55270. }(i3), a2 = n2 / i3;
  55271. r2._requestDomTask(() => {
  55272. e2.style.width = t2 * a2 + "px", e2.innerHTML = `${n2}&nbsp;${o2}`;
  55273. });
  55274. }
  55275. const nn = { closeButton: true, closeOnClick: true, focusAfterOpen: true, className: "", maxWidth: "240px" }, an = ["a[href]", "[tabindex]:not([tabindex='-1'])", "[contenteditable]:not([contenteditable='false'])", "button:not([disabled])", "input:not([disabled])", "select:not([disabled])", "textarea:not([disabled])"].join(", ");
  55276. function sn(t2 = new e.pointGeometry(0, 0), i3 = "bottom") {
  55277. if ("number" == typeof t2) {
  55278. const o2 = Math.round(Math.sqrt(0.5 * Math.pow(t2, 2)));
  55279. switch (i3) {
  55280. case "top":
  55281. return new e.pointGeometry(0, t2);
  55282. case "top-left":
  55283. return new e.pointGeometry(o2, o2);
  55284. case "top-right":
  55285. return new e.pointGeometry(-o2, o2);
  55286. case "bottom":
  55287. return new e.pointGeometry(0, -t2);
  55288. case "bottom-left":
  55289. return new e.pointGeometry(o2, -o2);
  55290. case "bottom-right":
  55291. return new e.pointGeometry(-o2, -o2);
  55292. case "left":
  55293. return new e.pointGeometry(t2, 0);
  55294. case "right":
  55295. return new e.pointGeometry(-t2, 0);
  55296. }
  55297. return new e.pointGeometry(0, 0);
  55298. }
  55299. return t2 instanceof e.pointGeometry || Array.isArray(t2) ? e.pointGeometry.convert(t2) : e.pointGeometry.convert(t2[i3] || [0, 0]);
  55300. }
  55301. const ln = { version: e.version, supported: t, setRTLTextPlugin: e.setRTLTextPlugin, getRTLTextPluginStatus: e.getRTLTextPluginStatus, Map: class extends Fr {
  55302. constructor(t2) {
  55303. if (null != (t2 = e.extend({}, Xr, t2)).minZoom && null != t2.maxZoom && t2.minZoom > t2.maxZoom)
  55304. throw new Error("maxZoom must be greater than or equal to minZoom");
  55305. if (null != t2.minPitch && null != t2.maxPitch && t2.minPitch > t2.maxPitch)
  55306. throw new Error("maxPitch must be greater than or equal to minPitch");
  55307. if (null != t2.minPitch && t2.minPitch < 0)
  55308. throw new Error("minPitch must be greater than or equal to 0");
  55309. if (null != t2.maxPitch && t2.maxPitch > 85)
  55310. throw new Error("maxPitch must be less than or equal to 85");
  55311. if (t2.antialias && e.isSafariWithAntialiasingBug(e.window) && (t2.antialias = false, e.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")), super(new No(t2.minZoom, t2.maxZoom, t2.minPitch, t2.maxPitch, t2.renderWorldCopies), t2), this._interactive = t2.interactive, this._minTileCacheSize = t2.minTileCacheSize, this._maxTileCacheSize = t2.maxTileCacheSize, this._failIfMajorPerformanceCaveat = t2.failIfMajorPerformanceCaveat, this._preserveDrawingBuffer = t2.preserveDrawingBuffer, this._antialias = t2.antialias, this._trackResize = t2.trackResize, this._bearingSnap = t2.bearingSnap, this._refreshExpiredTiles = t2.refreshExpiredTiles, this._fadeDuration = t2.fadeDuration, this._isInitialLoad = true, this._crossSourceCollisions = t2.crossSourceCollisions, this._crossFadingFactor = 1, this._collectResourceTiming = t2.collectResourceTiming, this._optimizeForTerrain = t2.optimizeForTerrain, this._renderTaskQueue = new Gr(), this._domRenderTaskQueue = new Gr(), this._controls = [], this._markers = [], this._mapId = e.uniqueId(), this._locale = e.extend({}, qr, t2.locale), this._clickTolerance = t2.clickTolerance, this._cooperativeGestures = t2.cooperativeGestures, this._containerWidth = 0, this._containerHeight = 0, this._averageElevationLastSampledAt = -1 / 0, this._averageElevationExaggeration = 0, this._averageElevation = new Wr(0), this._explicitProjection = null, this._requestManager = new e.RequestManager(t2.transformRequest, t2.accessToken, t2.testMode), this._silenceAuthErrors = !!t2.testMode, "string" == typeof t2.container) {
  55312. if (this._container = e.window.document.getElementById(t2.container), !this._container)
  55313. throw new Error(`Container '${t2.container}' not found.`);
  55314. } else {
  55315. if (!(t2.container instanceof e.window.HTMLElement))
  55316. throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
  55317. this._container = t2.container;
  55318. }
  55319. if (this._container.childNodes.length > 0 && e.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."), t2.maxBounds && this.setMaxBounds(t2.maxBounds), e.bindAll(["_onWindowOnline", "_onWindowResize", "_onMapScroll", "_contextLost", "_contextRestored"], this), this._setupContainer(), this._setupPainter(), void 0 === this.painter)
  55320. throw new Error("Failed to initialize WebGL.");
  55321. this.on("move", () => this._update(false)), this.on("moveend", () => this._update(false)), this.on("zoom", () => this._update(true)), void 0 !== e.window && (e.window.addEventListener("online", this._onWindowOnline, false), e.window.addEventListener("resize", this._onWindowResize, false), e.window.addEventListener("orientationchange", this._onWindowResize, false), e.window.addEventListener("webkitfullscreenchange", this._onWindowResize, false)), this.handlers = new Or(this, t2), this._localFontFamily = t2.localFontFamily, this._localIdeographFontFamily = t2.localIdeographFontFamily, t2.style && this.setStyle(t2.style, { localFontFamily: this._localFontFamily, localIdeographFontFamily: this._localIdeographFontFamily }), t2.projection && this.setProjection(t2.projection), this._hash = t2.hash && new jo("string" == typeof t2.hash && t2.hash || void 0).addTo(this), this._hash && this._hash._onHashChange() || (this.jumpTo({ center: t2.center, zoom: t2.zoom, bearing: t2.bearing, pitch: t2.pitch }), t2.bounds && (this.resize(), this.fitBounds(t2.bounds, e.extend({}, t2.fitBoundsOptions, { duration: 0 })))), this.resize(), t2.attributionControl && this.addControl(new Ur({ customAttribution: t2.customAttribution })), this._logoControl = new Nr(), this.addControl(this._logoControl, t2.logoPosition), this.on("style.load", () => {
  55322. this.transform.unmodified && this.jumpTo(this.style.stylesheet);
  55323. }), this.on("data", (t3) => {
  55324. this._update("style" === t3.dataType), this.fire(new e.Event(`${t3.dataType}data`, t3));
  55325. }), this.on("dataloading", (t3) => {
  55326. this.fire(new e.Event(`${t3.dataType}dataloading`, t3));
  55327. });
  55328. }
  55329. _getMapId() {
  55330. return this._mapId;
  55331. }
  55332. addControl(t2, i3) {
  55333. if (void 0 === i3 && (i3 = t2.getDefaultPosition ? t2.getDefaultPosition() : "top-right"), !t2 || !t2.onAdd)
  55334. return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));
  55335. const o2 = t2.onAdd(this);
  55336. this._controls.push(t2);
  55337. const r2 = this._controlPositions[i3];
  55338. return -1 !== i3.indexOf("bottom") ? r2.insertBefore(o2, r2.firstChild) : r2.appendChild(o2), this;
  55339. }
  55340. removeControl(t2) {
  55341. if (!t2 || !t2.onRemove)
  55342. return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));
  55343. const i3 = this._controls.indexOf(t2);
  55344. return i3 > -1 && this._controls.splice(i3, 1), t2.onRemove(this), this;
  55345. }
  55346. hasControl(e2) {
  55347. return this._controls.indexOf(e2) > -1;
  55348. }
  55349. getContainer() {
  55350. return this._container;
  55351. }
  55352. getCanvasContainer() {
  55353. return this._canvasContainer;
  55354. }
  55355. getCanvas() {
  55356. return this._canvas;
  55357. }
  55358. resize(t2) {
  55359. if (this._updateContainerDimensions(), this._containerWidth === this.transform.width && this._containerHeight === this.transform.height)
  55360. return this;
  55361. this._resizeCanvas(this._containerWidth, this._containerHeight), this.transform.resize(this._containerWidth, this._containerHeight), this.painter.resize(Math.ceil(this._containerWidth), Math.ceil(this._containerHeight));
  55362. const i3 = !this._moving;
  55363. return i3 && this.fire(new e.Event("movestart", t2)).fire(new e.Event("move", t2)), this.fire(new e.Event("resize", t2)), i3 && this.fire(new e.Event("moveend", t2)), this;
  55364. }
  55365. getBounds() {
  55366. return this.transform.getBounds();
  55367. }
  55368. getMaxBounds() {
  55369. return this.transform.getMaxBounds() || null;
  55370. }
  55371. setMaxBounds(t2) {
  55372. return this.transform.setMaxBounds(e.LngLatBounds.convert(t2)), this._update();
  55373. }
  55374. setMinZoom(t2) {
  55375. if ((t2 = null == t2 ? -2 : t2) >= -2 && t2 <= this.transform.maxZoom)
  55376. return this.transform.minZoom = t2, this._update(), this.getZoom() < t2 ? this.setZoom(t2) : this.fire(new e.Event("zoomstart")).fire(new e.Event("zoom")).fire(new e.Event("zoomend")), this;
  55377. throw new Error("minZoom must be between -2 and the current maxZoom, inclusive");
  55378. }
  55379. getMinZoom() {
  55380. return this.transform.minZoom;
  55381. }
  55382. setMaxZoom(t2) {
  55383. if ((t2 = null == t2 ? 22 : t2) >= this.transform.minZoom)
  55384. return this.transform.maxZoom = t2, this._update(), this.getZoom() > t2 ? this.setZoom(t2) : this.fire(new e.Event("zoomstart")).fire(new e.Event("zoom")).fire(new e.Event("zoomend")), this;
  55385. throw new Error("maxZoom must be greater than the current minZoom");
  55386. }
  55387. getMaxZoom() {
  55388. return this.transform.maxZoom;
  55389. }
  55390. setMinPitch(t2) {
  55391. if ((t2 = null == t2 ? 0 : t2) < 0)
  55392. throw new Error("minPitch must be greater than or equal to 0");
  55393. if (t2 >= 0 && t2 <= this.transform.maxPitch)
  55394. return this.transform.minPitch = t2, this._update(), this.getPitch() < t2 ? this.setPitch(t2) : this.fire(new e.Event("pitchstart")).fire(new e.Event("pitch")).fire(new e.Event("pitchend")), this;
  55395. throw new Error("minPitch must be between 0 and the current maxPitch, inclusive");
  55396. }
  55397. getMinPitch() {
  55398. return this.transform.minPitch;
  55399. }
  55400. setMaxPitch(t2) {
  55401. if ((t2 = null == t2 ? 85 : t2) > 85)
  55402. throw new Error("maxPitch must be less than or equal to 85");
  55403. if (t2 >= this.transform.minPitch)
  55404. return this.transform.maxPitch = t2, this._update(), this.getPitch() > t2 ? this.setPitch(t2) : this.fire(new e.Event("pitchstart")).fire(new e.Event("pitch")).fire(new e.Event("pitchend")), this;
  55405. throw new Error("maxPitch must be greater than the current minPitch");
  55406. }
  55407. getMaxPitch() {
  55408. return this.transform.maxPitch;
  55409. }
  55410. getRenderWorldCopies() {
  55411. return this.transform.renderWorldCopies;
  55412. }
  55413. setRenderWorldCopies(e2) {
  55414. return this.transform.renderWorldCopies = e2, this._update();
  55415. }
  55416. getProjection() {
  55417. return this._explicitProjection ? this._explicitProjection : this.style && this.style.stylesheet && this.style.stylesheet.projection ? this.style.stylesheet.projection : { name: "mercator", center: [0, 0] };
  55418. }
  55419. setProjection(e2) {
  55420. return this._lazyInitEmptyStyle(), e2 ? "string" == typeof e2 && (e2 = { name: e2 }) : e2 = null, this._updateProjection(e2);
  55421. }
  55422. _updateProjection(e2) {
  55423. null === e2 && (this._explicitProjection = null);
  55424. const t2 = e2 || this.getProjection(), i3 = this.transform.setProjection(t2);
  55425. if (e2 && (this._explicitProjection = this.transform.getProjection()), i3) {
  55426. this.painter.clearBackgroundTiles();
  55427. for (const e3 in this.style._sourceCaches)
  55428. this.style._sourceCaches[e3].clearTiles();
  55429. this.style.applyProjectionUpdate(), this._update(true);
  55430. }
  55431. return this;
  55432. }
  55433. project(t2) {
  55434. return this.transform.locationPoint3D(e.LngLat.convert(t2));
  55435. }
  55436. unproject(t2) {
  55437. return this.transform.pointLocation3D(e.pointGeometry.convert(t2));
  55438. }
  55439. isMoving() {
  55440. return this._moving || this.handlers && this.handlers.isMoving() || false;
  55441. }
  55442. isZooming() {
  55443. return this._zooming || this.handlers && this.handlers.isZooming() || false;
  55444. }
  55445. isRotating() {
  55446. return this._rotating || this.handlers && this.handlers.isRotating() || false;
  55447. }
  55448. _createDelegatedListener(e2, t2, i3) {
  55449. if ("mouseenter" === e2 || "mouseover" === e2) {
  55450. let o2 = false;
  55451. const r2 = (r3) => {
  55452. const n3 = t2.filter((e3) => this.getLayer(e3)), a2 = n3.length ? this.queryRenderedFeatures(r3.point, { layers: n3 }) : [];
  55453. a2.length ? o2 || (o2 = true, i3.call(this, new Yo(e2, this, r3.originalEvent, { features: a2 }))) : o2 = false;
  55454. }, n2 = () => {
  55455. o2 = false;
  55456. };
  55457. return { layers: new Set(t2), listener: i3, delegates: { mousemove: r2, mouseout: n2 } };
  55458. }
  55459. if ("mouseleave" === e2 || "mouseout" === e2) {
  55460. let o2 = false;
  55461. const r2 = (r3) => {
  55462. const n3 = t2.filter((e3) => this.getLayer(e3));
  55463. (n3.length ? this.queryRenderedFeatures(r3.point, { layers: n3 }) : []).length ? o2 = true : o2 && (o2 = false, i3.call(this, new Yo(e2, this, r3.originalEvent)));
  55464. }, n2 = (t3) => {
  55465. o2 && (o2 = false, i3.call(this, new Yo(e2, this, t3.originalEvent)));
  55466. };
  55467. return { layers: new Set(t2), listener: i3, delegates: { mousemove: r2, mouseout: n2 } };
  55468. }
  55469. {
  55470. const o2 = (e3) => {
  55471. const o3 = t2.filter((e4) => this.getLayer(e4)), r2 = o3.length ? this.queryRenderedFeatures(e3.point, { layers: o3 }) : [];
  55472. r2.length && (e3.features = r2, i3.call(this, e3), delete e3.features);
  55473. };
  55474. return { layers: new Set(t2), listener: i3, delegates: { [e2]: o2 } };
  55475. }
  55476. }
  55477. on(e2, t2, i3) {
  55478. if (void 0 === i3)
  55479. return super.on(e2, t2);
  55480. Array.isArray(t2) || (t2 = [t2]);
  55481. const o2 = this._createDelegatedListener(e2, t2, i3);
  55482. this._delegatedListeners = this._delegatedListeners || {}, this._delegatedListeners[e2] = this._delegatedListeners[e2] || [], this._delegatedListeners[e2].push(o2);
  55483. for (const e3 in o2.delegates)
  55484. this.on(e3, o2.delegates[e3]);
  55485. return this;
  55486. }
  55487. once(e2, t2, i3) {
  55488. if (void 0 === i3)
  55489. return super.once(e2, t2);
  55490. Array.isArray(t2) || (t2 = [t2]);
  55491. const o2 = this._createDelegatedListener(e2, t2, i3);
  55492. for (const e3 in o2.delegates)
  55493. this.once(e3, o2.delegates[e3]);
  55494. return this;
  55495. }
  55496. off(e2, t2, i3) {
  55497. if (void 0 === i3)
  55498. return super.off(e2, t2);
  55499. t2 = new Set(Array.isArray(t2) ? t2 : [t2]);
  55500. const o2 = (e3, t3) => {
  55501. if (e3.size !== t3.size)
  55502. return false;
  55503. for (const i4 of e3)
  55504. if (!t3.has(i4))
  55505. return false;
  55506. return true;
  55507. }, r2 = this._delegatedListeners ? this._delegatedListeners[e2] : void 0;
  55508. return r2 && ((e3) => {
  55509. for (let r3 = 0; r3 < e3.length; r3++) {
  55510. const n2 = e3[r3];
  55511. if (n2.listener === i3 && o2(n2.layers, t2)) {
  55512. for (const e4 in n2.delegates)
  55513. this.off(e4, n2.delegates[e4]);
  55514. return e3.splice(r3, 1), this;
  55515. }
  55516. }
  55517. })(r2), this;
  55518. }
  55519. queryRenderedFeatures(t2, i3) {
  55520. return this.style ? (void 0 !== i3 || void 0 === t2 || t2 instanceof e.pointGeometry || Array.isArray(t2) || (i3 = t2, t2 = void 0), this.style.queryRenderedFeatures(t2 = t2 || [[0, 0], [this.transform.width, this.transform.height]], i3 = i3 || {}, this.transform)) : [];
  55521. }
  55522. querySourceFeatures(e2, t2) {
  55523. return this.style.querySourceFeatures(e2, t2);
  55524. }
  55525. queryTerrainElevation(t2, i3) {
  55526. const o2 = this.transform.elevation;
  55527. return o2 ? (i3 = e.extend({}, { exaggerated: true }, i3), o2.getAtPoint(e.MercatorCoordinate.fromLngLat(t2), null, i3.exaggerated)) : null;
  55528. }
  55529. setStyle(t2, i3) {
  55530. return false !== (i3 = e.extend({}, { localIdeographFontFamily: this._localIdeographFontFamily, localFontFamily: this._localFontFamily }, i3)).diff && i3.localIdeographFontFamily === this._localIdeographFontFamily && i3.localFontFamily === this._localFontFamily && this.style && t2 ? (this._diffStyle(t2, i3), this) : (this._localIdeographFontFamily = i3.localIdeographFontFamily, this._localFontFamily = i3.localFontFamily, this._updateStyle(t2, i3));
  55531. }
  55532. _getUIString(e2) {
  55533. const t2 = this._locale[e2];
  55534. if (null == t2)
  55535. throw new Error(`Missing UI string '${e2}'`);
  55536. return t2;
  55537. }
  55538. _updateStyle(e2, t2) {
  55539. return this.style && (this.style.setEventedParent(null), this.style._remove(), this.style = void 0), e2 && (this.style = new $t(this, t2 || {}), this.style.setEventedParent(this, { style: this.style }), "string" == typeof e2 ? this.style.loadURL(e2) : this.style.loadJSON(e2)), this._updateTerrain(), this;
  55540. }
  55541. _lazyInitEmptyStyle() {
  55542. this.style || (this.style = new $t(this, {}), this.style.setEventedParent(this, { style: this.style }), this.style.loadEmpty());
  55543. }
  55544. _diffStyle(t2, i3) {
  55545. if ("string" == typeof t2) {
  55546. const o2 = this._requestManager.normalizeStyleURL(t2), r2 = this._requestManager.transformRequest(o2, e.ResourceType.Style);
  55547. e.getJSON(r2, (t3, o3) => {
  55548. t3 ? this.fire(new e.ErrorEvent(t3)) : o3 && this._updateDiff(o3, i3);
  55549. });
  55550. } else
  55551. "object" == typeof t2 && this._updateDiff(t2, i3);
  55552. }
  55553. _updateDiff(t2, i3) {
  55554. try {
  55555. this.style.setState(t2) && this._update(true);
  55556. } catch (o2) {
  55557. e.warnOnce(`Unable to perform style diff: ${o2.message || o2.error || o2}. Rebuilding the style from scratch.`), this._updateStyle(t2, i3);
  55558. }
  55559. }
  55560. getStyle() {
  55561. if (this.style)
  55562. return this.style.serialize();
  55563. }
  55564. isStyleLoaded() {
  55565. return this.style ? this.style.loaded() : (e.warnOnce("There is no style added to the map."), false);
  55566. }
  55567. addSource(e2, t2) {
  55568. return this._lazyInitEmptyStyle(), this.style.addSource(e2, t2), this._update(true);
  55569. }
  55570. isSourceLoaded(e2) {
  55571. return !!this.style && this.style._isSourceCacheLoaded(e2);
  55572. }
  55573. areTilesLoaded() {
  55574. const e2 = this.style && this.style._sourceCaches;
  55575. for (const t2 in e2) {
  55576. const i3 = e2[t2]._tiles;
  55577. for (const e3 in i3) {
  55578. const t3 = i3[e3];
  55579. if ("loaded" !== t3.state && "errored" !== t3.state)
  55580. return false;
  55581. }
  55582. }
  55583. return true;
  55584. }
  55585. addSourceType(e2, t2, i3) {
  55586. this._lazyInitEmptyStyle(), this.style.addSourceType(e2, t2, i3);
  55587. }
  55588. removeSource(e2) {
  55589. return this.style.removeSource(e2), this._updateTerrain(), this._update(true);
  55590. }
  55591. getSource(e2) {
  55592. return this.style.getSource(e2);
  55593. }
  55594. addImage(t2, i3, { pixelRatio: o2 = 1, sdf: r2 = false, stretchX: n2, stretchY: a2, content: s2 } = {}) {
  55595. if (this._lazyInitEmptyStyle(), i3 instanceof e.window.HTMLImageElement || e.window.ImageBitmap && i3 instanceof e.window.ImageBitmap) {
  55596. const { width: l2, height: c2, data: h2 } = e.exported.getImageData(i3);
  55597. this.style.addImage(t2, { data: new e.RGBAImage({ width: l2, height: c2 }, h2), pixelRatio: o2, stretchX: n2, stretchY: a2, content: s2, sdf: r2, version: 0 });
  55598. } else if (void 0 === i3.width || void 0 === i3.height)
  55599. this.fire(new e.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));
  55600. else {
  55601. const { width: l2, height: c2 } = i3, h2 = i3;
  55602. this.style.addImage(t2, { data: new e.RGBAImage({ width: l2, height: c2 }, new Uint8Array(h2.data)), pixelRatio: o2, stretchX: n2, stretchY: a2, content: s2, sdf: r2, version: 0, userImage: h2 }), h2.onAdd && h2.onAdd(this, t2);
  55603. }
  55604. }
  55605. updateImage(t2, i3) {
  55606. const o2 = this.style.getImage(t2);
  55607. if (!o2)
  55608. return void this.fire(new e.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));
  55609. const r2 = i3 instanceof e.window.HTMLImageElement || e.window.ImageBitmap && i3 instanceof e.window.ImageBitmap ? e.exported.getImageData(i3) : i3, { width: n2, height: a2 } = r2;
  55610. void 0 !== n2 && void 0 !== a2 ? n2 === o2.data.width && a2 === o2.data.height ? (o2.data.replace(r2.data, !(i3 instanceof e.window.HTMLImageElement || e.window.ImageBitmap && i3 instanceof e.window.ImageBitmap)), this.style.updateImage(t2, o2)) : this.fire(new e.ErrorEvent(new Error("The width and height of the updated image must be that same as the previous version of the image"))) : this.fire(new e.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));
  55611. }
  55612. hasImage(t2) {
  55613. return t2 ? !!this.style.getImage(t2) : (this.fire(new e.ErrorEvent(new Error("Missing required image id"))), false);
  55614. }
  55615. removeImage(e2) {
  55616. this.style.removeImage(e2);
  55617. }
  55618. loadImage(t2, i3) {
  55619. e.getImage(this._requestManager.transformRequest(t2, e.ResourceType.Image), (t3, o2) => {
  55620. i3(t3, o2 instanceof e.window.HTMLImageElement ? e.exported.getImageData(o2) : o2);
  55621. });
  55622. }
  55623. listImages() {
  55624. return this.style.listImages();
  55625. }
  55626. addLayer(e2, t2) {
  55627. return this._lazyInitEmptyStyle(), this.style.addLayer(e2, t2), this._update(true);
  55628. }
  55629. moveLayer(e2, t2) {
  55630. return this.style.moveLayer(e2, t2), this._update(true);
  55631. }
  55632. removeLayer(e2) {
  55633. return this.style.removeLayer(e2), this._update(true);
  55634. }
  55635. getLayer(e2) {
  55636. return this.style.getLayer(e2);
  55637. }
  55638. setLayerZoomRange(e2, t2, i3) {
  55639. return this.style.setLayerZoomRange(e2, t2, i3), this._update(true);
  55640. }
  55641. setFilter(e2, t2, i3 = {}) {
  55642. return this.style.setFilter(e2, t2, i3), this._update(true);
  55643. }
  55644. getFilter(e2) {
  55645. return this.style.getFilter(e2);
  55646. }
  55647. setPaintProperty(e2, t2, i3, o2 = {}) {
  55648. return this.style.setPaintProperty(e2, t2, i3, o2), this._update(true);
  55649. }
  55650. getPaintProperty(e2, t2) {
  55651. return this.style.getPaintProperty(e2, t2);
  55652. }
  55653. setLayoutProperty(e2, t2, i3, o2 = {}) {
  55654. return this.style.setLayoutProperty(e2, t2, i3, o2), this._update(true);
  55655. }
  55656. getLayoutProperty(e2, t2) {
  55657. return this.style.getLayoutProperty(e2, t2);
  55658. }
  55659. setLight(e2, t2 = {}) {
  55660. return this._lazyInitEmptyStyle(), this.style.setLight(e2, t2), this._update(true);
  55661. }
  55662. getLight() {
  55663. return this.style.getLight();
  55664. }
  55665. setTerrain(e2) {
  55666. return this._lazyInitEmptyStyle(), !e2 && this.transform.projection.requiresDraping ? this.style.setTerrainForDraping() : this.style.setTerrain(e2), this._averageElevationLastSampledAt = -1 / 0, this._update(true);
  55667. }
  55668. getTerrain() {
  55669. return this.style ? this.style.getTerrain() : null;
  55670. }
  55671. setFog(e2) {
  55672. return this._lazyInitEmptyStyle(), this.style.setFog(e2), this._update(true);
  55673. }
  55674. getFog() {
  55675. return this.style ? this.style.getFog() : null;
  55676. }
  55677. _queryFogOpacity(t2) {
  55678. return this.style && this.style.fog ? this.style.fog.getOpacityAtLatLng(e.LngLat.convert(t2), this.transform) : 0;
  55679. }
  55680. setFeatureState(e2, t2) {
  55681. return this.style.setFeatureState(e2, t2), this._update();
  55682. }
  55683. removeFeatureState(e2, t2) {
  55684. return this.style.removeFeatureState(e2, t2), this._update();
  55685. }
  55686. getFeatureState(e2) {
  55687. return this.style.getFeatureState(e2);
  55688. }
  55689. _updateContainerDimensions() {
  55690. if (!this._container)
  55691. return;
  55692. const t2 = this._container.getBoundingClientRect().width || 400, i3 = this._container.getBoundingClientRect().height || 300;
  55693. let o2, r2, n2, a2 = this._container;
  55694. for (; a2 && (!r2 || !n2); ) {
  55695. const t3 = e.window.getComputedStyle(a2).transform;
  55696. t3 && "none" !== t3 && (o2 = t3.match(/matrix.*\((.+)\)/)[1].split(", "), o2[0] && "0" !== o2[0] && "1" !== o2[0] && (r2 = o2[0]), o2[3] && "0" !== o2[3] && "1" !== o2[3] && (n2 = o2[3])), a2 = a2.parentElement;
  55697. }
  55698. this._containerWidth = r2 ? Math.abs(t2 / r2) : t2, this._containerHeight = n2 ? Math.abs(i3 / n2) : i3;
  55699. }
  55700. _detectMissingCSS() {
  55701. "rgb(250, 128, 114)" !== e.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color") && e.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.");
  55702. }
  55703. _setupContainer() {
  55704. const e2 = this._container;
  55705. e2.classList.add("mapboxgl-map"), (this._missingCSSCanary = n("div", "mapboxgl-canary", e2)).style.visibility = "hidden", this._detectMissingCSS();
  55706. const t2 = this._canvasContainer = n("div", "mapboxgl-canvas-container", e2);
  55707. this._interactive && t2.classList.add("mapboxgl-interactive"), this._canvas = n("canvas", "mapboxgl-canvas", t2), this._canvas.addEventListener("webglcontextlost", this._contextLost, false), this._canvas.addEventListener("webglcontextrestored", this._contextRestored, false), this._canvas.setAttribute("tabindex", "0"), this._canvas.setAttribute("aria-label", "Map"), this._canvas.setAttribute("role", "region"), this._updateContainerDimensions(), this._resizeCanvas(this._containerWidth, this._containerHeight);
  55708. const i3 = this._controlContainer = n("div", "mapboxgl-control-container", e2), o2 = this._controlPositions = {};
  55709. ["top-left", "top-right", "bottom-left", "bottom-right"].forEach((e3) => {
  55710. o2[e3] = n("div", `mapboxgl-ctrl-${e3}`, i3);
  55711. }), this._container.addEventListener("scroll", this._onMapScroll, false);
  55712. }
  55713. _resizeCanvas(t2, i3) {
  55714. const o2 = e.exported.devicePixelRatio || 1;
  55715. this._canvas.width = o2 * Math.ceil(t2), this._canvas.height = o2 * Math.ceil(i3), this._canvas.style.width = `${t2}px`, this._canvas.style.height = `${i3}px`;
  55716. }
  55717. _addMarker(e2) {
  55718. this._markers.push(e2);
  55719. }
  55720. _removeMarker(e2) {
  55721. const t2 = this._markers.indexOf(e2);
  55722. -1 !== t2 && this._markers.splice(t2, 1);
  55723. }
  55724. _setupPainter() {
  55725. const i3 = e.extend({}, t.webGLContextAttributes, { failIfMajorPerformanceCaveat: this._failIfMajorPerformanceCaveat, preserveDrawingBuffer: this._preserveDrawingBuffer, antialias: this._antialias || false }), o2 = this._canvas.getContext("webgl", i3) || this._canvas.getContext("experimental-webgl", i3);
  55726. o2 ? (e.storeAuthState(o2, true), this.painter = new Mo(o2, this.transform), this.on("data", (e2) => {
  55727. "source" === e2.dataType && this.painter.setTileLoadedFlag(true);
  55728. }), e.exported$1.testSupport(o2)) : this.fire(new e.ErrorEvent(new Error("Failed to initialize WebGL")));
  55729. }
  55730. _contextLost(t2) {
  55731. t2.preventDefault(), this._frame && (this._frame.cancel(), this._frame = null), this.fire(new e.Event("webglcontextlost", { originalEvent: t2 }));
  55732. }
  55733. _contextRestored(t2) {
  55734. this._setupPainter(), this.resize(), this._update(), this.fire(new e.Event("webglcontextrestored", { originalEvent: t2 }));
  55735. }
  55736. _onMapScroll(e2) {
  55737. if (e2.target === this._container)
  55738. return this._container.scrollTop = 0, this._container.scrollLeft = 0, false;
  55739. }
  55740. loaded() {
  55741. return !this._styleDirty && !this._sourcesDirty && !!this.style && this.style.loaded();
  55742. }
  55743. _update(e2) {
  55744. return this.style ? (this._styleDirty = this._styleDirty || e2, this._sourcesDirty = true, this.triggerRepaint(), this) : this;
  55745. }
  55746. _requestRenderFrame(e2) {
  55747. return this._update(), this._renderTaskQueue.add(e2);
  55748. }
  55749. _cancelRenderFrame(e2) {
  55750. this._renderTaskQueue.remove(e2);
  55751. }
  55752. _requestDomTask(e2) {
  55753. !this.loaded() || this.loaded() && !this.isMoving() ? e2() : this._domRenderTaskQueue.add(e2);
  55754. }
  55755. _render(t2) {
  55756. let i3;
  55757. const o2 = this.painter.context.extTimerQuery, r2 = e.exported.now();
  55758. if (this.listens("gpu-timing-frame") && (i3 = o2.createQueryEXT(), o2.beginQueryEXT(o2.TIME_ELAPSED_EXT, i3)), this.painter.context.setDirty(), this.painter.setBaseState(), this._renderTaskQueue.run(t2), this._domRenderTaskQueue.run(t2), this._removed)
  55759. return;
  55760. let n2 = false;
  55761. const a2 = this._isInitialLoad ? 0 : this._fadeDuration;
  55762. if (this.style && this._styleDirty) {
  55763. this._styleDirty = false;
  55764. const t3 = this.transform.zoom, i4 = this.transform.pitch, o3 = e.exported.now();
  55765. this.style.zoomHistory.update(t3, o3);
  55766. const r3 = new e.EvaluationParameters(t3, { now: o3, fadeDuration: a2, pitch: i4, zoomHistory: this.style.zoomHistory, transition: this.style.getTransition() }), s3 = r3.crossFadingFactor();
  55767. 1 === s3 && s3 === this._crossFadingFactor || (n2 = true, this._crossFadingFactor = s3), this.style.update(r3);
  55768. }
  55769. this.style && this.style.fog && this.style.fog.hasTransition() && (this.style._markersNeedUpdate = true, this._sourcesDirty = true);
  55770. let s2 = false;
  55771. if (this.style && this._sourcesDirty ? (this._sourcesDirty = false, this.painter._updateFog(this.style), this._updateTerrain(), s2 = this._updateAverageElevation(r2), this.style._updateSources(this.transform), this._forceMarkerUpdate()) : s2 = this._updateAverageElevation(r2), this._placementDirty = this.style && this.style._updatePlacement(this.painter.transform, this.showCollisionBoxes, a2, this._crossSourceCollisions), this.style && this.painter.render(this.style, { showTileBoundaries: this.showTileBoundaries, showTerrainWireframe: this.showTerrainWireframe, showOverdrawInspector: this._showOverdrawInspector, showQueryGeometry: !!this._showQueryGeometry, rotating: this.isRotating(), zooming: this.isZooming(), moving: this.isMoving(), fadeDuration: a2, isInitialLoad: this._isInitialLoad, showPadding: this.showPadding, gpuTiming: !!this.listens("gpu-timing-layer"), speedIndexTiming: this.speedIndexTiming }), this.fire(new e.Event("render")), this.loaded() && !this._loaded && (this._loaded = true, this.fire(new e.Event("load"))), this.style && (this.style.hasTransitions() || n2) && (this._styleDirty = true), this.style && !this._placementDirty && this.style._releaseSymbolFadeTiles(), this.listens("gpu-timing-frame")) {
  55772. const t3 = e.exported.now() - r2;
  55773. o2.endQueryEXT(o2.TIME_ELAPSED_EXT, i3), setTimeout(() => {
  55774. const r3 = o2.getQueryObjectEXT(i3, o2.QUERY_RESULT_EXT) / 1e6;
  55775. o2.deleteQueryEXT(i3), this.fire(new e.Event("gpu-timing-frame", { cpuTime: t3, gpuTime: r3 }));
  55776. }, 50);
  55777. }
  55778. if (this.listens("gpu-timing-layer")) {
  55779. const t3 = this.painter.collectGpuTimers();
  55780. setTimeout(() => {
  55781. const i4 = this.painter.queryGpuTimers(t3);
  55782. this.fire(new e.Event("gpu-timing-layer", { layerTimes: i4 }));
  55783. }, 50);
  55784. }
  55785. const l2 = this._sourcesDirty || this._styleDirty || this._placementDirty || s2;
  55786. if (l2 || this._repaint)
  55787. this.triggerRepaint();
  55788. else {
  55789. const t3 = !this.isMoving() && this.loaded();
  55790. if (t3 && (s2 = this._updateAverageElevation(r2, true)), s2)
  55791. this.triggerRepaint();
  55792. else if (this._triggerFrame(false), t3 && (this.fire(new e.Event("idle")), this._isInitialLoad = false, this.speedIndexTiming)) {
  55793. const t4 = this._calculateSpeedIndex();
  55794. this.fire(new e.Event("speedindexcompleted", { speedIndex: t4 })), this.speedIndexTiming = false;
  55795. }
  55796. }
  55797. !this._loaded || this._fullyLoaded || l2 || (this._fullyLoaded = true, this._authenticate());
  55798. }
  55799. _forceMarkerUpdate() {
  55800. for (const e2 of this._markers)
  55801. e2._update();
  55802. }
  55803. _updateAverageElevation(e2, t2 = false) {
  55804. const i3 = (e3) => (this.transform.averageElevation = e3, this._update(false), true);
  55805. if (!this.painter.averageElevationNeedsEasing())
  55806. return 0 !== this.transform.averageElevation && i3(0);
  55807. if ((t2 || e2 - this._averageElevationLastSampledAt > 500) && !this._averageElevation.isEasing(e2)) {
  55808. const t3 = this.transform.averageElevation;
  55809. let o2 = this.transform.sampleAverageElevation(), r2 = false;
  55810. this.transform.elevation && (r2 = this.transform.elevation.exaggeration() !== this._averageElevationExaggeration, this._averageElevationExaggeration = this.transform.elevation.exaggeration()), isNaN(o2) ? o2 = 0 : this._averageElevationLastSampledAt = e2;
  55811. const n2 = Math.abs(t3 - o2);
  55812. if (n2 > 1) {
  55813. if (this._isInitialLoad || r2)
  55814. return this._averageElevation.jumpTo(o2), i3(o2);
  55815. this._averageElevation.easeTo(o2, e2, 300);
  55816. } else if (n2 > 1e-4)
  55817. return this._averageElevation.jumpTo(o2), i3(o2);
  55818. }
  55819. return !!this._averageElevation.isEasing(e2) && i3(this._averageElevation.getValue(e2));
  55820. }
  55821. _authenticate() {
  55822. e.getMapSessionAPI(this._getMapId(), this._requestManager._skuToken, this._requestManager._customAccessToken, (t2) => {
  55823. if (t2 && (t2.message === e.AUTH_ERR_MSG || 401 === t2.status)) {
  55824. const t3 = this.painter.context.gl;
  55825. e.storeAuthState(t3, false), this._logoControl instanceof Nr && this._logoControl._updateLogo(), t3 && t3.clear(t3.DEPTH_BUFFER_BIT | t3.COLOR_BUFFER_BIT | t3.STENCIL_BUFFER_BIT), this._silenceAuthErrors || this.fire(new e.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")));
  55826. }
  55827. }), e.postMapLoadEvent(this._getMapId(), this._requestManager._skuToken, this._requestManager._customAccessToken, () => {
  55828. });
  55829. }
  55830. _updateTerrain() {
  55831. this.painter.updateTerrain(this.style, this.isMoving() || this.isRotating() || this.isZooming());
  55832. }
  55833. _calculateSpeedIndex() {
  55834. const e2 = this.painter.canvasCopy(), t2 = this.painter.getCanvasCopiesAndTimestamps();
  55835. t2.timeStamps.push(performance.now());
  55836. const i3 = this.painter.context.gl, o2 = i3.createFramebuffer();
  55837. function r2(e3) {
  55838. i3.framebufferTexture2D(i3.FRAMEBUFFER, i3.COLOR_ATTACHMENT0, i3.TEXTURE_2D, e3, 0);
  55839. const t3 = new Uint8Array(i3.drawingBufferWidth * i3.drawingBufferHeight * 4);
  55840. return i3.readPixels(0, 0, i3.drawingBufferWidth, i3.drawingBufferHeight, i3.RGBA, i3.UNSIGNED_BYTE, t3), t3;
  55841. }
  55842. return i3.bindFramebuffer(i3.FRAMEBUFFER, o2), this._canvasPixelComparison(r2(e2), t2.canvasCopies.map(r2), t2.timeStamps);
  55843. }
  55844. _canvasPixelComparison(e2, t2, i3) {
  55845. let o2 = i3[1] - i3[0];
  55846. const r2 = e2.length / 4;
  55847. for (let n2 = 0; n2 < t2.length; n2++) {
  55848. const a2 = t2[n2];
  55849. let s2 = 0;
  55850. for (let t3 = 0; t3 < a2.length; t3 += 4)
  55851. a2[t3] === e2[t3] && a2[t3 + 1] === e2[t3 + 1] && a2[t3 + 2] === e2[t3 + 2] && a2[t3 + 3] === e2[t3 + 3] && (s2 += 1);
  55852. o2 += (i3[n2 + 2] - i3[n2 + 1]) * (1 - s2 / r2);
  55853. }
  55854. return o2;
  55855. }
  55856. remove() {
  55857. this._hash && this._hash.remove();
  55858. for (const e2 of this._controls)
  55859. e2.onRemove(this);
  55860. this._controls = [], this._frame && (this._frame.cancel(), this._frame = null), this._renderTaskQueue.clear(), this._domRenderTaskQueue.clear(), this.style && this.style.destroy(), this.painter.destroy(), this.handlers && this.handlers.destroy(), this.handlers = void 0, this.setStyle(null), void 0 !== e.window && (e.window.removeEventListener("resize", this._onWindowResize, false), e.window.removeEventListener("orientationchange", this._onWindowResize, false), e.window.removeEventListener("webkitfullscreenchange", this._onWindowResize, false), e.window.removeEventListener("online", this._onWindowOnline, false));
  55861. const t2 = this.painter.context.gl.getExtension("WEBGL_lose_context");
  55862. t2 && t2.loseContext(), $r(this._canvasContainer), $r(this._controlContainer), $r(this._missingCSSCanary), this._container.classList.remove("mapboxgl-map"), e.removeAuthState(this.painter.context.gl), this._removed = true, this.fire(new e.Event("remove"));
  55863. }
  55864. triggerRepaint() {
  55865. this._triggerFrame(true);
  55866. }
  55867. _triggerFrame(t2) {
  55868. this._renderNextFrame = this._renderNextFrame || t2, this.style && !this._frame && (this._frame = e.exported.frame((e2) => {
  55869. const t3 = !!this._renderNextFrame;
  55870. this._frame = null, this._renderNextFrame = null, t3 && this._render(e2);
  55871. }));
  55872. }
  55873. _preloadTiles(t2) {
  55874. const i3 = this.style ? Object.values(this.style._sourceCaches) : [];
  55875. return e.asyncAll(i3, (e2, i4) => e2._preloadTiles(t2, i4), () => {
  55876. this.triggerRepaint();
  55877. }), this;
  55878. }
  55879. _onWindowOnline() {
  55880. this._update();
  55881. }
  55882. _onWindowResize(e2) {
  55883. this._trackResize && this.resize({ originalEvent: e2 })._update();
  55884. }
  55885. get showTileBoundaries() {
  55886. return !!this._showTileBoundaries;
  55887. }
  55888. set showTileBoundaries(e2) {
  55889. this._showTileBoundaries !== e2 && (this._showTileBoundaries = e2, this._update());
  55890. }
  55891. get showTerrainWireframe() {
  55892. return !!this._showTerrainWireframe;
  55893. }
  55894. set showTerrainWireframe(e2) {
  55895. this._showTerrainWireframe !== e2 && (this._showTerrainWireframe = e2, this._update());
  55896. }
  55897. get speedIndexTiming() {
  55898. return !!this._speedIndexTiming;
  55899. }
  55900. set speedIndexTiming(e2) {
  55901. this._speedIndexTiming !== e2 && (this._speedIndexTiming = e2, this._update());
  55902. }
  55903. get showPadding() {
  55904. return !!this._showPadding;
  55905. }
  55906. set showPadding(e2) {
  55907. this._showPadding !== e2 && (this._showPadding = e2, this._update());
  55908. }
  55909. get showCollisionBoxes() {
  55910. return !!this._showCollisionBoxes;
  55911. }
  55912. set showCollisionBoxes(e2) {
  55913. this._showCollisionBoxes !== e2 && (this._showCollisionBoxes = e2, e2 ? this.style._generateCollisionBoxes() : this._update());
  55914. }
  55915. get showOverdrawInspector() {
  55916. return !!this._showOverdrawInspector;
  55917. }
  55918. set showOverdrawInspector(e2) {
  55919. this._showOverdrawInspector !== e2 && (this._showOverdrawInspector = e2, this._update());
  55920. }
  55921. get repaint() {
  55922. return !!this._repaint;
  55923. }
  55924. set repaint(e2) {
  55925. this._repaint !== e2 && (this._repaint = e2, this.triggerRepaint());
  55926. }
  55927. get vertices() {
  55928. return !!this._vertices;
  55929. }
  55930. set vertices(e2) {
  55931. this._vertices = e2, this._update();
  55932. }
  55933. _setCacheLimits(t2, i3) {
  55934. e.setCacheLimits(t2, i3);
  55935. }
  55936. get version() {
  55937. return e.version;
  55938. }
  55939. }, NavigationControl: class {
  55940. constructor(t2) {
  55941. this.options = e.extend({}, Hr, t2), this._container = n("div", "mapboxgl-ctrl mapboxgl-ctrl-group"), this._container.addEventListener("contextmenu", (e2) => e2.preventDefault()), this.options.showZoom && (e.bindAll(["_setButtonTitle", "_updateZoomButtons"], this), this._zoomInButton = this._createButton("mapboxgl-ctrl-zoom-in", (e2) => {
  55942. this._map && this._map.zoomIn({}, { originalEvent: e2 });
  55943. }), n("span", "mapboxgl-ctrl-icon", this._zoomInButton).setAttribute("aria-hidden", "true"), this._zoomOutButton = this._createButton("mapboxgl-ctrl-zoom-out", (e2) => {
  55944. this._map && this._map.zoomOut({}, { originalEvent: e2 });
  55945. }), n("span", "mapboxgl-ctrl-icon", this._zoomOutButton).setAttribute("aria-hidden", "true")), this.options.showCompass && (e.bindAll(["_rotateCompassArrow"], this), this._compass = this._createButton("mapboxgl-ctrl-compass", (e2) => {
  55946. const t3 = this._map;
  55947. t3 && (this.options.visualizePitch ? t3.resetNorthPitch({}, { originalEvent: e2 }) : t3.resetNorth({}, { originalEvent: e2 }));
  55948. }), this._compassIcon = n("span", "mapboxgl-ctrl-icon", this._compass), this._compassIcon.setAttribute("aria-hidden", "true"));
  55949. }
  55950. _updateZoomButtons() {
  55951. const e2 = this._map;
  55952. if (!e2)
  55953. return;
  55954. const t2 = e2.getZoom(), i3 = t2 === e2.getMaxZoom(), o2 = t2 === e2.getMinZoom();
  55955. this._zoomInButton.disabled = i3, this._zoomOutButton.disabled = o2, this._zoomInButton.setAttribute("aria-disabled", i3.toString()), this._zoomOutButton.setAttribute("aria-disabled", o2.toString());
  55956. }
  55957. _rotateCompassArrow() {
  55958. const e2 = this._map;
  55959. if (!e2)
  55960. return;
  55961. const t2 = this.options.visualizePitch ? `scale(${1 / Math.pow(Math.cos(e2.transform.pitch * (Math.PI / 180)), 0.5)}) rotateX(${e2.transform.pitch}deg) rotateZ(${e2.transform.angle * (180 / Math.PI)}deg)` : `rotate(${e2.transform.angle * (180 / Math.PI)}deg)`;
  55962. e2._requestDomTask(() => {
  55963. this._compassIcon && (this._compassIcon.style.transform = t2);
  55964. });
  55965. }
  55966. onAdd(e2) {
  55967. return this._map = e2, this.options.showZoom && (this._setButtonTitle(this._zoomInButton, "ZoomIn"), this._setButtonTitle(this._zoomOutButton, "ZoomOut"), e2.on("zoom", this._updateZoomButtons), this._updateZoomButtons()), this.options.showCompass && (this._setButtonTitle(this._compass, "ResetBearing"), this.options.visualizePitch && e2.on("pitch", this._rotateCompassArrow), e2.on("rotate", this._rotateCompassArrow), this._rotateCompassArrow(), this._handler = new Kr(e2, this._compass, this.options.visualizePitch)), this._container;
  55968. }
  55969. onRemove() {
  55970. const e2 = this._map;
  55971. e2 && (this._container.remove(), this.options.showZoom && e2.off("zoom", this._updateZoomButtons), this.options.showCompass && (this.options.visualizePitch && e2.off("pitch", this._rotateCompassArrow), e2.off("rotate", this._rotateCompassArrow), this._handler && this._handler.off(), this._handler = void 0), this._map = void 0);
  55972. }
  55973. _createButton(e2, t2) {
  55974. const i3 = n("button", e2, this._container);
  55975. return i3.type = "button", i3.addEventListener("click", t2), i3;
  55976. }
  55977. _setButtonTitle(e2, t2) {
  55978. if (!this._map)
  55979. return;
  55980. const i3 = this._map._getUIString(`NavigationControl.${t2}`);
  55981. e2.setAttribute("aria-label", i3), e2.firstElementChild && e2.firstElementChild.setAttribute("title", i3);
  55982. }
  55983. }, GeolocateControl: class extends e.Evented {
  55984. constructor(t2) {
  55985. super(), this.options = e.extend({}, Yr, t2), e.bindAll(["_onSuccess", "_onError", "_onZoom", "_finish", "_setupUI", "_updateCamera", "_updateMarker", "_updateMarkerRotation", "_onDeviceOrientation"], this), this._updateMarkerRotationThrottled = Go(this._updateMarkerRotation, 20);
  55986. }
  55987. onAdd(t2) {
  55988. var i3;
  55989. return this._map = t2, this._container = n("div", "mapboxgl-ctrl mapboxgl-ctrl-group"), i3 = this._setupUI, void 0 !== Jr ? i3(Jr) : void 0 !== e.window.navigator.permissions ? e.window.navigator.permissions.query({ name: "geolocation" }).then((e2) => {
  55990. Jr = "denied" !== e2.state, i3(Jr);
  55991. }) : (Jr = !!e.window.navigator.geolocation, i3(Jr)), this._container;
  55992. }
  55993. onRemove() {
  55994. void 0 !== this._geolocationWatchID && (e.window.navigator.geolocation.clearWatch(this._geolocationWatchID), this._geolocationWatchID = void 0), this.options.showUserLocation && this._userLocationDotMarker && this._userLocationDotMarker.remove(), this.options.showAccuracyCircle && this._accuracyCircleMarker && this._accuracyCircleMarker.remove(), this._container.remove(), this._map.off("zoom", this._onZoom), this._map = void 0, Qr = 0, en = false;
  55995. }
  55996. _isOutOfMapMaxBounds(e2) {
  55997. const t2 = this._map.getMaxBounds(), i3 = e2.coords;
  55998. return !!t2 && (i3.longitude < t2.getWest() || i3.longitude > t2.getEast() || i3.latitude < t2.getSouth() || i3.latitude > t2.getNorth());
  55999. }
  56000. _setErrorState() {
  56001. switch (this._watchState) {
  56002. case "WAITING_ACTIVE":
  56003. this._watchState = "ACTIVE_ERROR", this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"), this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");
  56004. break;
  56005. case "ACTIVE_LOCK":
  56006. this._watchState = "ACTIVE_ERROR", this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"), this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"), this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");
  56007. break;
  56008. case "BACKGROUND":
  56009. this._watchState = "BACKGROUND_ERROR", this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"), this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"), this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");
  56010. }
  56011. }
  56012. _onSuccess(t2) {
  56013. if (this._map) {
  56014. if (this._isOutOfMapMaxBounds(t2))
  56015. return this._setErrorState(), this.fire(new e.Event("outofmaxbounds", t2)), this._updateMarker(), void this._finish();
  56016. if (this.options.trackUserLocation)
  56017. switch (this._lastKnownPosition = t2, this._watchState) {
  56018. case "WAITING_ACTIVE":
  56019. case "ACTIVE_LOCK":
  56020. case "ACTIVE_ERROR":
  56021. this._watchState = "ACTIVE_LOCK", this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"), this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"), this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");
  56022. break;
  56023. case "BACKGROUND":
  56024. case "BACKGROUND_ERROR":
  56025. this._watchState = "BACKGROUND", this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"), this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"), this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");
  56026. }
  56027. this.options.showUserLocation && "OFF" !== this._watchState && this._updateMarker(t2), this.options.trackUserLocation && "ACTIVE_LOCK" !== this._watchState || this._updateCamera(t2), this.options.showUserLocation && this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"), this.fire(new e.Event("geolocate", t2)), this._finish();
  56028. }
  56029. }
  56030. _updateCamera(t2) {
  56031. const i3 = new e.LngLat(t2.coords.longitude, t2.coords.latitude), o2 = t2.coords.accuracy, r2 = this._map.getBearing(), n2 = e.extend({ bearing: r2 }, this.options.fitBoundsOptions);
  56032. this._map.fitBounds(i3.toBounds(o2), n2, { geolocateSource: true });
  56033. }
  56034. _updateMarker(t2) {
  56035. if (t2) {
  56036. const i3 = new e.LngLat(t2.coords.longitude, t2.coords.latitude);
  56037. this._accuracyCircleMarker.setLngLat(i3).addTo(this._map), this._userLocationDotMarker.setLngLat(i3).addTo(this._map), this._accuracy = t2.coords.accuracy, this.options.showUserLocation && this.options.showAccuracyCircle && this._updateCircleRadius();
  56038. } else
  56039. this._userLocationDotMarker.remove(), this._accuracyCircleMarker.remove();
  56040. }
  56041. _updateCircleRadius() {
  56042. const e2 = this._map._containerHeight / 2, t2 = this._map.unproject([0, e2]), i3 = this._map.unproject([100, e2]), o2 = t2.distanceTo(i3) / 100, r2 = Math.ceil(2 * this._accuracy / o2);
  56043. this._circleElement.style.width = `${r2}px`, this._circleElement.style.height = `${r2}px`;
  56044. }
  56045. _onZoom() {
  56046. this.options.showUserLocation && this.options.showAccuracyCircle && this._updateCircleRadius();
  56047. }
  56048. _updateMarkerRotation() {
  56049. this._userLocationDotMarker && "number" == typeof this._heading ? (this._userLocationDotMarker.setRotation(this._heading), this._dotElement.classList.add("mapboxgl-user-location-show-heading")) : (this._dotElement.classList.remove("mapboxgl-user-location-show-heading"), this._userLocationDotMarker.setRotation(0));
  56050. }
  56051. _onError(t2) {
  56052. if (this._map) {
  56053. if (this.options.trackUserLocation)
  56054. if (1 === t2.code) {
  56055. this._watchState = "OFF", this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"), this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"), this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"), this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"), this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"), this._geolocateButton.disabled = true;
  56056. const e2 = this._map._getUIString("GeolocateControl.LocationNotAvailable");
  56057. this._geolocateButton.setAttribute("aria-label", e2), this._geolocateButton.firstElementChild && this._geolocateButton.firstElementChild.setAttribute("title", e2), void 0 !== this._geolocationWatchID && this._clearWatch();
  56058. } else {
  56059. if (3 === t2.code && en)
  56060. return;
  56061. this._setErrorState();
  56062. }
  56063. "OFF" !== this._watchState && this.options.showUserLocation && this._dotElement.classList.add("mapboxgl-user-location-dot-stale"), this.fire(new e.Event("error", t2)), this._finish();
  56064. }
  56065. }
  56066. _finish() {
  56067. this._timeoutId && clearTimeout(this._timeoutId), this._timeoutId = void 0;
  56068. }
  56069. _setupUI(t2) {
  56070. if (this._container.addEventListener("contextmenu", (e2) => e2.preventDefault()), this._geolocateButton = n("button", "mapboxgl-ctrl-geolocate", this._container), n("span", "mapboxgl-ctrl-icon", this._geolocateButton).setAttribute("aria-hidden", "true"), this._geolocateButton.type = "button", false === t2) {
  56071. e.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");
  56072. const t3 = this._map._getUIString("GeolocateControl.LocationNotAvailable");
  56073. this._geolocateButton.disabled = true, this._geolocateButton.setAttribute("aria-label", t3), this._geolocateButton.firstElementChild && this._geolocateButton.firstElementChild.setAttribute("title", t3);
  56074. } else {
  56075. const e2 = this._map._getUIString("GeolocateControl.FindMyLocation");
  56076. this._geolocateButton.setAttribute("aria-label", e2), this._geolocateButton.firstElementChild && this._geolocateButton.firstElementChild.setAttribute("title", e2);
  56077. }
  56078. this.options.trackUserLocation && (this._geolocateButton.setAttribute("aria-pressed", "false"), this._watchState = "OFF"), this.options.showUserLocation && (this._dotElement = n("div", "mapboxgl-user-location"), this._dotElement.appendChild(n("div", "mapboxgl-user-location-dot")), this._dotElement.appendChild(n("div", "mapboxgl-user-location-heading")), this._userLocationDotMarker = new Vr({ element: this._dotElement, rotationAlignment: "map", pitchAlignment: "map" }), this._circleElement = n("div", "mapboxgl-user-location-accuracy-circle"), this._accuracyCircleMarker = new Vr({ element: this._circleElement, pitchAlignment: "map" }), this.options.trackUserLocation && (this._watchState = "OFF"), this._map.on("zoom", this._onZoom)), this._geolocateButton.addEventListener("click", this.trigger.bind(this)), this._setup = true, this.options.trackUserLocation && this._map.on("movestart", (t3) => {
  56079. t3.geolocateSource || "ACTIVE_LOCK" !== this._watchState || t3.originalEvent && "resize" === t3.originalEvent.type || (this._watchState = "BACKGROUND", this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"), this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"), this.fire(new e.Event("trackuserlocationend")));
  56080. });
  56081. }
  56082. _onDeviceOrientation(e2) {
  56083. this._userLocationDotMarker && (e2.webkitCompassHeading ? this._heading = e2.webkitCompassHeading : true === e2.absolute && (this._heading = -1 * e2.alpha), this._updateMarkerRotationThrottled());
  56084. }
  56085. trigger() {
  56086. if (!this._setup)
  56087. return e.warnOnce("Geolocate control triggered before added to a map"), false;
  56088. if (this.options.trackUserLocation) {
  56089. switch (this._watchState) {
  56090. case "OFF":
  56091. this._watchState = "WAITING_ACTIVE", this.fire(new e.Event("trackuserlocationstart"));
  56092. break;
  56093. case "WAITING_ACTIVE":
  56094. case "ACTIVE_LOCK":
  56095. case "ACTIVE_ERROR":
  56096. case "BACKGROUND_ERROR":
  56097. Qr--, en = false, this._watchState = "OFF", this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"), this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"), this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"), this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"), this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"), this.fire(new e.Event("trackuserlocationend"));
  56098. break;
  56099. case "BACKGROUND":
  56100. this._watchState = "ACTIVE_LOCK", this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"), this._lastKnownPosition && this._updateCamera(this._lastKnownPosition), this.fire(new e.Event("trackuserlocationstart"));
  56101. }
  56102. switch (this._watchState) {
  56103. case "WAITING_ACTIVE":
  56104. this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"), this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");
  56105. break;
  56106. case "ACTIVE_LOCK":
  56107. this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");
  56108. break;
  56109. case "ACTIVE_ERROR":
  56110. this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"), this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");
  56111. break;
  56112. case "BACKGROUND":
  56113. this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");
  56114. break;
  56115. case "BACKGROUND_ERROR":
  56116. this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"), this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error");
  56117. }
  56118. if ("OFF" === this._watchState && void 0 !== this._geolocationWatchID)
  56119. this._clearWatch();
  56120. else if (void 0 === this._geolocationWatchID) {
  56121. let t2;
  56122. this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"), this._geolocateButton.setAttribute("aria-pressed", "true"), Qr++, Qr > 1 ? (t2 = { maximumAge: 6e5, timeout: 0 }, en = true) : (t2 = this.options.positionOptions, en = false), this._geolocationWatchID = e.window.navigator.geolocation.watchPosition(this._onSuccess, this._onError, t2), this.options.showUserHeading && this._addDeviceOrientationListener();
  56123. }
  56124. } else
  56125. e.window.navigator.geolocation.getCurrentPosition(this._onSuccess, this._onError, this.options.positionOptions), this._timeoutId = setTimeout(this._finish, 1e4);
  56126. return true;
  56127. }
  56128. _addDeviceOrientationListener() {
  56129. const t2 = () => {
  56130. e.window.addEventListener("ondeviceorientationabsolute" in e.window ? "deviceorientationabsolute" : "deviceorientation", this._onDeviceOrientation);
  56131. };
  56132. void 0 !== e.window.DeviceMotionEvent && "function" == typeof e.window.DeviceMotionEvent.requestPermission ? DeviceOrientationEvent.requestPermission().then((e2) => {
  56133. "granted" === e2 && t2();
  56134. }).catch(console.error) : t2();
  56135. }
  56136. _clearWatch() {
  56137. e.window.navigator.geolocation.clearWatch(this._geolocationWatchID), e.window.removeEventListener("deviceorientation", this._onDeviceOrientation), e.window.removeEventListener("deviceorientationabsolute", this._onDeviceOrientation), this._geolocationWatchID = void 0, this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"), this._geolocateButton.setAttribute("aria-pressed", "false"), this.options.showUserLocation && this._updateMarker(null);
  56138. }
  56139. }, AttributionControl: Ur, ScaleControl: class {
  56140. constructor(t2) {
  56141. this.options = e.extend({}, tn, t2), e.bindAll(["_onMove", "setUnit"], this);
  56142. }
  56143. getDefaultPosition() {
  56144. return "bottom-left";
  56145. }
  56146. _onMove() {
  56147. on(this._map, this._container, this.options);
  56148. }
  56149. onAdd(e2) {
  56150. return this._map = e2, this._container = n("div", "mapboxgl-ctrl mapboxgl-ctrl-scale", e2.getContainer()), this._map.on("move", this._onMove), this._onMove(), this._container;
  56151. }
  56152. onRemove() {
  56153. this._container.remove(), this._map.off("move", this._onMove), this._map = void 0;
  56154. }
  56155. setUnit(e2) {
  56156. this.options.unit = e2, on(this._map, this._container, this.options);
  56157. }
  56158. }, FullscreenControl: class {
  56159. constructor(t2) {
  56160. this._fullscreen = false, t2 && t2.container && (t2.container instanceof e.window.HTMLElement ? this._container = t2.container : e.warnOnce("Full screen control 'container' must be a DOM element.")), e.bindAll(["_onClickFullscreen", "_changeIcon"], this), "onfullscreenchange" in e.window.document ? this._fullscreenchange = "fullscreenchange" : "onwebkitfullscreenchange" in e.window.document && (this._fullscreenchange = "webkitfullscreenchange");
  56161. }
  56162. onAdd(t2) {
  56163. return this._map = t2, this._container || (this._container = this._map.getContainer()), this._controlContainer = n("div", "mapboxgl-ctrl mapboxgl-ctrl-group"), this._checkFullscreenSupport() ? this._setupUI() : (this._controlContainer.style.display = "none", e.warnOnce("This device does not support fullscreen mode.")), this._controlContainer;
  56164. }
  56165. onRemove() {
  56166. this._controlContainer.remove(), this._map = null, e.window.document.removeEventListener(this._fullscreenchange, this._changeIcon);
  56167. }
  56168. _checkFullscreenSupport() {
  56169. return !(!e.window.document.fullscreenEnabled && !e.window.document.webkitFullscreenEnabled);
  56170. }
  56171. _setupUI() {
  56172. const t2 = this._fullscreenButton = n("button", "mapboxgl-ctrl-fullscreen", this._controlContainer);
  56173. n("span", "mapboxgl-ctrl-icon", t2).setAttribute("aria-hidden", "true"), t2.type = "button", this._updateTitle(), this._fullscreenButton.addEventListener("click", this._onClickFullscreen), e.window.document.addEventListener(this._fullscreenchange, this._changeIcon);
  56174. }
  56175. _updateTitle() {
  56176. const e2 = this._getTitle();
  56177. this._fullscreenButton.setAttribute("aria-label", e2), this._fullscreenButton.firstElementChild && this._fullscreenButton.firstElementChild.setAttribute("title", e2);
  56178. }
  56179. _getTitle() {
  56180. return this._map._getUIString(this._isFullscreen() ? "FullscreenControl.Exit" : "FullscreenControl.Enter");
  56181. }
  56182. _isFullscreen() {
  56183. return this._fullscreen;
  56184. }
  56185. _changeIcon() {
  56186. (e.window.document.fullscreenElement || e.window.document.webkitFullscreenElement) === this._container !== this._fullscreen && (this._fullscreen = !this._fullscreen, this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"), this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"), this._updateTitle());
  56187. }
  56188. _onClickFullscreen() {
  56189. this._isFullscreen() ? e.window.document.exitFullscreen ? e.window.document.exitFullscreen() : e.window.document.webkitCancelFullScreen && e.window.document.webkitCancelFullScreen() : this._container.requestFullscreen ? this._container.requestFullscreen() : this._container.webkitRequestFullscreen && this._container.webkitRequestFullscreen();
  56190. }
  56191. }, Popup: class extends e.Evented {
  56192. constructor(t2) {
  56193. super(), this.options = e.extend(Object.create(nn), t2), e.bindAll(["_update", "_onClose", "remove", "_onMouseEvent"], this), this._classList = new Set(t2 && t2.className ? t2.className.trim().split(/\s+/) : []);
  56194. }
  56195. addTo(t2) {
  56196. return this._map && this.remove(), this._map = t2, this.options.closeOnClick && t2.on("preclick", this._onClose), this.options.closeOnMove && t2.on("move", this._onClose), t2.on("remove", this.remove), this._update(), this._focusFirstElement(), this._trackPointer ? (t2.on("mousemove", this._onMouseEvent), t2.on("mouseup", this._onMouseEvent), t2._canvasContainer.classList.add("mapboxgl-track-pointer")) : t2.on("move", this._update), this.fire(new e.Event("open")), this;
  56197. }
  56198. isOpen() {
  56199. return !!this._map;
  56200. }
  56201. remove() {
  56202. this._content && this._content.remove(), this._container && (this._container.remove(), this._container = void 0);
  56203. const t2 = this._map;
  56204. return t2 && (t2.off("move", this._update), t2.off("move", this._onClose), t2.off("preclick", this._onClose), t2.off("click", this._onClose), t2.off("remove", this.remove), t2.off("mousemove", this._onMouseEvent), t2.off("mouseup", this._onMouseEvent), t2.off("drag", this._onMouseEvent), this._map = void 0), this.fire(new e.Event("close")), this;
  56205. }
  56206. getLngLat() {
  56207. return this._lngLat;
  56208. }
  56209. setLngLat(t2) {
  56210. this._lngLat = e.LngLat.convert(t2), this._pos = null, this._trackPointer = false, this._update();
  56211. const i3 = this._map;
  56212. return i3 && (i3.on("move", this._update), i3.off("mousemove", this._onMouseEvent), i3._canvasContainer.classList.remove("mapboxgl-track-pointer")), this;
  56213. }
  56214. trackPointer() {
  56215. this._trackPointer = true, this._pos = null, this._update();
  56216. const e2 = this._map;
  56217. return e2 && (e2.off("move", this._update), e2.on("mousemove", this._onMouseEvent), e2.on("drag", this._onMouseEvent), e2._canvasContainer.classList.add("mapboxgl-track-pointer")), this;
  56218. }
  56219. getElement() {
  56220. return this._container;
  56221. }
  56222. setText(t2) {
  56223. return this.setDOMContent(e.window.document.createTextNode(t2));
  56224. }
  56225. setHTML(t2) {
  56226. const i3 = e.window.document.createDocumentFragment(), o2 = e.window.document.createElement("body");
  56227. let r2;
  56228. for (o2.innerHTML = t2; r2 = o2.firstChild, r2; )
  56229. i3.appendChild(r2);
  56230. return this.setDOMContent(i3);
  56231. }
  56232. getMaxWidth() {
  56233. return this._container && this._container.style.maxWidth;
  56234. }
  56235. setMaxWidth(e2) {
  56236. return this.options.maxWidth = e2, this._update(), this;
  56237. }
  56238. setDOMContent(e2) {
  56239. let t2 = this._content;
  56240. if (t2)
  56241. for (; t2.hasChildNodes(); )
  56242. t2.firstChild && t2.removeChild(t2.firstChild);
  56243. else
  56244. t2 = this._content = n("div", "mapboxgl-popup-content", this._container || void 0);
  56245. if (t2.appendChild(e2), this.options.closeButton) {
  56246. const e3 = this._closeButton = n("button", "mapboxgl-popup-close-button", t2);
  56247. e3.type = "button", e3.setAttribute("aria-label", "Close popup"), e3.setAttribute("aria-hidden", "true"), e3.innerHTML = "&#215;", e3.addEventListener("click", this._onClose);
  56248. }
  56249. return this._update(), this._focusFirstElement(), this;
  56250. }
  56251. addClassName(e2) {
  56252. return this._classList.add(e2), this._updateClassList(), this;
  56253. }
  56254. removeClassName(e2) {
  56255. return this._classList.delete(e2), this._updateClassList(), this;
  56256. }
  56257. setOffset(e2) {
  56258. return this.options.offset = e2, this._update(), this;
  56259. }
  56260. toggleClassName(e2) {
  56261. let t2;
  56262. return this._classList.delete(e2) ? t2 = false : (this._classList.add(e2), t2 = true), this._updateClassList(), t2;
  56263. }
  56264. _onMouseEvent(e2) {
  56265. this._update(e2.point);
  56266. }
  56267. _getAnchor(e2) {
  56268. if (this.options.anchor)
  56269. return this.options.anchor;
  56270. const t2 = this._map, i3 = this._container, o2 = this._pos;
  56271. if (!t2 || !i3 || !o2)
  56272. return "bottom";
  56273. const r2 = i3.offsetWidth, n2 = i3.offsetHeight, a2 = o2.x < r2 / 2, s2 = o2.x > t2.transform.width - r2 / 2;
  56274. if (o2.y + e2 < n2)
  56275. return a2 ? "top-left" : s2 ? "top-right" : "top";
  56276. if (o2.y > t2.transform.height - n2) {
  56277. if (a2)
  56278. return "bottom-left";
  56279. if (s2)
  56280. return "bottom-right";
  56281. }
  56282. return a2 ? "left" : s2 ? "right" : "bottom";
  56283. }
  56284. _updateClassList() {
  56285. const e2 = this._container;
  56286. if (!e2)
  56287. return;
  56288. const t2 = [...this._classList];
  56289. t2.push("mapboxgl-popup"), this._anchor && t2.push(`mapboxgl-popup-anchor-${this._anchor}`), this._trackPointer && t2.push("mapboxgl-popup-track-pointer"), e2.className = t2.join(" ");
  56290. }
  56291. _update(e2) {
  56292. const t2 = this._map, i3 = this._content;
  56293. if (!t2 || !this._lngLat && !this._trackPointer || !i3)
  56294. return;
  56295. let o2 = this._container;
  56296. if (o2 || (o2 = this._container = n("div", "mapboxgl-popup", t2.getContainer()), this._tip = n("div", "mapboxgl-popup-tip", o2), o2.appendChild(i3)), this.options.maxWidth && o2.style.maxWidth !== this.options.maxWidth && (o2.style.maxWidth = this.options.maxWidth), t2.transform.renderWorldCopies && !this._trackPointer && (this._lngLat = jr(this._lngLat, this._pos, t2.transform)), !this._trackPointer || e2) {
  56297. const i4 = this._pos = this._trackPointer && e2 ? e2 : t2.project(this._lngLat), o3 = sn(this.options.offset), r2 = this._anchor = this._getAnchor(o3.y), n2 = sn(this.options.offset, r2), a2 = i4.add(n2).round();
  56298. t2._requestDomTask(() => {
  56299. this._container && r2 && (this._container.style.transform = `${Zr[r2]} translate(${a2.x}px,${a2.y}px)`);
  56300. });
  56301. }
  56302. this._updateClassList();
  56303. }
  56304. _focusFirstElement() {
  56305. if (!this.options.focusAfterOpen || !this._container)
  56306. return;
  56307. const e2 = this._container.querySelector(an);
  56308. e2 && e2.focus();
  56309. }
  56310. _onClose() {
  56311. this.remove();
  56312. }
  56313. _setOpacity(e2) {
  56314. this._content && (this._content.style.opacity = e2), this._tip && (this._tip.style.opacity = e2);
  56315. }
  56316. }, Marker: Vr, Style: $t, LngLat: e.LngLat, LngLatBounds: e.LngLatBounds, Point: e.pointGeometry, MercatorCoordinate: e.MercatorCoordinate, FreeCameraOptions: Ao, Evented: e.Evented, config: e.config, prewarm: function() {
  56317. Ue().acquire(Oe);
  56318. }, clearPrewarmedResources: function() {
  56319. const e2 = Fe;
  56320. e2 && (e2.isPreloaded() && 1 === e2.numActive() ? (e2.release(Oe), Fe = null) : console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"));
  56321. }, get accessToken() {
  56322. return e.config.ACCESS_TOKEN;
  56323. }, set accessToken(t2) {
  56324. e.config.ACCESS_TOKEN = t2;
  56325. }, get baseApiUrl() {
  56326. return e.config.API_URL;
  56327. }, set baseApiUrl(t2) {
  56328. e.config.API_URL = t2;
  56329. }, get workerCount() {
  56330. return Be.workerCount;
  56331. }, set workerCount(e2) {
  56332. Be.workerCount = e2;
  56333. }, get maxParallelImageRequests() {
  56334. return e.config.MAX_PARALLEL_IMAGE_REQUESTS;
  56335. }, set maxParallelImageRequests(t2) {
  56336. e.config.MAX_PARALLEL_IMAGE_REQUESTS = t2;
  56337. }, clearStorage(t2) {
  56338. e.clearTileCache(t2);
  56339. }, workerUrl: "", workerClass: null, setNow: e.exported.setNow, restoreNow: e.exported.restoreNow };
  56340. return ln;
  56341. });
  56342. var mapboxgl$1 = mapboxgl2;
  56343. return mapboxgl$1;
  56344. });
  56345. })(mapboxGl);
  56346. var mapboxGlExports = mapboxGl.exports;
  56347. const mapboxgl = /* @__PURE__ */ getDefaultExportFromCjs(mapboxGlExports);
  56348. const ThirdPartyMaps = {
  56349. /** 加载天地图普通地图 */
  56350. tdtsl() {
  56351. return {
  56352. layers: [
  56353. ["tdtsl", "TianDiTu.Normal.Map"],
  56354. ["tdtslzj", "TianDiTu.Normal.Annotion"]
  56355. ],
  56356. key: "fb258b4c0bbf60ff7a0205b519ad9a96"
  56357. };
  56358. },
  56359. /** 天地图影像 */
  56360. tdtyx() {
  56361. return {
  56362. layers: [
  56363. ["tdtyx", "TianDiTu.Satellite.Map"],
  56364. ["tdtyxzj", "TianDiTu.Satellite.Annotion"]
  56365. ],
  56366. key: "fb258b4c0bbf60ff7a0205b519ad9a96"
  56367. };
  56368. },
  56369. /** 天地图地形 */
  56370. tdtdx() {
  56371. return {
  56372. layers: [
  56373. ["tdtdx", "TianDiTu.Terrain.Map"],
  56374. ["tdtdxzj", "TianDiTu.Terrain.Annotion"]
  56375. ],
  56376. key: "fb258b4c0bbf60ff7a0205b519ad9a96"
  56377. };
  56378. },
  56379. /** 高德矢量 */
  56380. gdsl() {
  56381. return { layers: [["gdsl", "GaoDe.Normal.Map"]] };
  56382. },
  56383. /** 高德矢量,无注记版 */
  56384. gdslwzj() {
  56385. return { layers: [["gdslwzj", "GaoDe.Normal_NoTag.Map"]] };
  56386. },
  56387. /** 高德影像*/
  56388. gdyx() {
  56389. return {
  56390. layers: [
  56391. ["gdyx", "GaoDe.Satellite.Map"],
  56392. ["gdyxzj", "GaoDe.Satellite.Annotion"]
  56393. ]
  56394. };
  56395. },
  56396. /** 百度矢量*/
  56397. bdsl() {
  56398. return { layers: [["bdsl", "Baidu.Normal.Map"]] };
  56399. },
  56400. /** 百度影像*/
  56401. bdyx() {
  56402. return {
  56403. layers: [
  56404. ["bdyx", "Baidu.Satellite.Map"],
  56405. ["bdyxzj", "Baidu.Satellite.Annotion"]
  56406. ]
  56407. };
  56408. },
  56409. /** OSM地图 */
  56410. osm() {
  56411. return { layers: [["osm", "OSM.Normal.Map"]] };
  56412. },
  56413. /** GeoQ普通地图 */
  56414. geoq() {
  56415. return { layers: [["geoq", "Geoq.Normal.Map"]] };
  56416. },
  56417. /** GeoQ深蓝色地图 */
  56418. geoqPurplishBlue() {
  56419. return { layers: [["geoqPurplishBlue", "Geoq.Normal.PurplishBlue"]] };
  56420. },
  56421. /** GeoQ浅色地图 */
  56422. geoqGray() {
  56423. return { layers: [["geoqGray", "Geoq.Normal.Gray"]] };
  56424. },
  56425. /** GeoQ暖色调地图 */
  56426. geoqWarm() {
  56427. return { layers: [["geoqWarm", "Geoq.Normal.Warm"]] };
  56428. },
  56429. /** GeoQ冷色调地图 */
  56430. geoqCold() {
  56431. return { layers: [["geoqCold", "Geoq.Normal.Cold"]] };
  56432. }
  56433. };
  56434. function mxtest_addTtifRaster(map2) {
  56435. const url = "./gis/radar.tiff";
  56436. console.log(url);
  56437. let w = (114.06825863001939 - 104.18084906665138) * 5e-3;
  56438. let h = (32.396413467808586 - 22.54283198132819) * 5e-3;
  56439. let cenx = 114.07867152431874;
  56440. let ceny = 22.563727343812303;
  56441. map2.addSource("radar", {
  56442. "type": "image",
  56443. "url": url,
  56444. //加载的tiff文件路径
  56445. "coordinates": [
  56446. [cenx - w * 0.5, ceny + h * 0.5],
  56447. [cenx + w * 0.5, ceny + h * 0.5],
  56448. [cenx + w * 0.5, ceny - h * 0.5],
  56449. [cenx - w * 0.5, ceny - h * 0.5]
  56450. ]
  56451. //文件展示的经纬度(四个角/顺时针)
  56452. });
  56453. map2.addLayer({
  56454. id: "radar-layer",
  56455. "type": "raster",
  56456. "source": "radar",
  56457. "paint": {
  56458. "raster-fade-duration": 0
  56459. }
  56460. });
  56461. }
  56462. function add_geoserver_wmts_EPSG900913_ttif(map2) {
  56463. var vectorLayerUrl = "http://192.168.5.19:8080/geoserver/gwc/service/wmts?layer=mytest%3Amxcadtest2&style=&tilematrixset=EPSG:900913&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png&TileMatrix=EPSG:900913:{z}&TileCol={x}&TileRow={y}";
  56464. map2.addSource("wmts-source", {
  56465. "type": "raster",
  56466. "tiles": [
  56467. vectorLayerUrl
  56468. ],
  56469. "tileSize": 256
  56470. });
  56471. map2.addLayer({
  56472. "id": "wmts-layer",
  56473. "type": "raster",
  56474. "source": "wmts-source",
  56475. "paint": {
  56476. "raster-opacity": 0.95
  56477. }
  56478. });
  56479. }
  56480. let map;
  56481. let mxmap;
  56482. function init_mouse_coord_tip(isLoad_googlecn_map2) {
  56483. map.on("click", function(e) {
  56484. return __async(this, null, function* () {
  56485. let { lng, lat } = e.lngLat;
  56486. if (isLoad_googlecn_map2) {
  56487. let gps84 = mxcad2.mx_gcj02_To_gps84(lng, lat);
  56488. lng = gps84.lng;
  56489. lat = gps84.lat;
  56490. }
  56491. console.log("经纬度坐标:", JSON.stringify([lng, lat]));
  56492. let pt = mapboxgl.MercatorCoordinate.fromLngLat(
  56493. [lng, lat],
  56494. 0
  56495. );
  56496. console.log("墨卡托坐标:", JSON.stringify(mxmap.map_lnglat_to_meters(lng, lat)));
  56497. let ptCAD = mxmap.mercatorCoord2CAD(pt.x, pt.y);
  56498. console.log("CAD坐标:", JSON.stringify(ptCAD));
  56499. });
  56500. });
  56501. }
  56502. let isLoad_googlecn_map = false;
  56503. let isLoad_geoserver_wmts_EPSG900913_ttif = true;
  56504. isLoad_geoserver_wmts_EPSG900913_ttif = false;
  56505. if (isLoad_geoserver_wmts_EPSG900913_ttif)
  56506. isLoad_googlecn_map = false;
  56507. function getMapDefaultData() {
  56508. let map_default_data = new mxcad2.MxCADPluginMapDefaultData();
  56509. map_default_data.cadOrigin = [116275.977014, 19273.279085];
  56510. map_default_data.mapOrigin = [114.06825863001939, 22.54283198132819];
  56511. map_default_data.meterInCADUnits = 1;
  56512. map_default_data.openFile = "./demo/road.dwg.mxweb";
  56513. let mapType = mxdraw.MxFun.getQueryString("maptype");
  56514. if (!isLoad_geoserver_wmts_EPSG900913_ttif) {
  56515. if (mapType == "google") {
  56516. let hx = mxcad2.mx_gps84_To_gcj02(map_default_data.mapOrigin[0], map_default_data.mapOrigin[1]);
  56517. map_default_data.mapOrigin = [hx.lng, hx.lat];
  56518. isLoad_googlecn_map = true;
  56519. map_default_data.viewColor = { red: 0, green: 0, blue: 0 };
  56520. } else {
  56521. let rastermap = ThirdPartyMaps.gdslwzj();
  56522. if (mapType == "gdslwzj") {
  56523. rastermap = ThirdPartyMaps.gdslwzj();
  56524. } else if (mapType == "gdyx") {
  56525. rastermap = ThirdPartyMaps.gdyx();
  56526. } else if (mapType == "tdtsl") {
  56527. rastermap = ThirdPartyMaps.tdtsl();
  56528. } else if (mapType == "bdsl") {
  56529. rastermap = ThirdPartyMaps.bdsl();
  56530. } else if (mapType == "geoq") {
  56531. rastermap = ThirdPartyMaps.geoq();
  56532. }
  56533. map_default_data.rasterTileLayerList = rastermap.layers;
  56534. if (rastermap.key)
  56535. map_default_data.rasterTileKey = rastermap.key;
  56536. }
  56537. }
  56538. return map_default_data;
  56539. }
  56540. function init$1(map_val) {
  56541. mxmap = map_val;
  56542. map = map_val.getMapbox();
  56543. if (isLoad_googlecn_map) {
  56544. mxcad2.MxMapAddGoogleCnLayer(map, ["Image", "Lable"]);
  56545. }
  56546. init_mouse_coord_tip(isLoad_googlecn_map);
  56547. if (isLoad_geoserver_wmts_EPSG900913_ttif) {
  56548. add_geoserver_wmts_EPSG900913_ttif(map);
  56549. } else {
  56550. mxtest_addTtifRaster(map);
  56551. }
  56552. }
  56553. function MxTest_Map_Download() {
  56554. return __async(this, null, function* () {
  56555. let getPoint = new mxcad2.MxCADUiPrPoint();
  56556. getPoint.setMessage("\n指定下载范围第一点:");
  56557. let pt1 = yield getPoint.go();
  56558. if (!pt1)
  56559. return;
  56560. getPoint.setMessage("\n指定下载范围第二点:");
  56561. getPoint.setUserDraw((currentPoint, worldDraw) => {
  56562. worldDraw.setColor(16711680);
  56563. let pl = new mxcad2.McDbPolyline();
  56564. pl.addVertexAt(pt1);
  56565. pl.addVertexAt(new mxcad2.McGePoint3d(pt1.x, currentPoint.y));
  56566. pl.addVertexAt(currentPoint);
  56567. pl.addVertexAt(new mxcad2.McGePoint3d(currentPoint.x, pt1.y));
  56568. pl.constantWidth = mxdraw.MxFun.screenCoordLong2Doc(2);
  56569. pl.isClosed = true;
  56570. worldDraw.drawMcDbEntity(pl);
  56571. let points = [];
  56572. points.push(pt1.toVector3());
  56573. points.push(new THREE.Vector3(pt1.x, currentPoint.y));
  56574. points.push(currentPoint.toVector3());
  56575. points.push(new THREE.Vector3(currentPoint.x, pt1.y));
  56576. worldDraw.setColor(12868);
  56577. worldDraw.drawSolid(points, 0.5);
  56578. });
  56579. getPoint.setDisableOsnap(true);
  56580. getPoint.setDisableOrthoTrace(true);
  56581. getPoint.setDynamicInputType(mxdraw.DynamicInputType.kXYCoordInput);
  56582. let pt2 = yield getPoint.go();
  56583. if (!pt2) {
  56584. return;
  56585. }
  56586. let lnglat1 = mxmap.cadTolnglat(pt1.toVector3());
  56587. let lnglat2 = mxmap.cadTolnglat(pt2.toVector3());
  56588. let map_pt1 = mxmap.map_lnglat_to_meters(lnglat1[0], lnglat1[1]);
  56589. let map_pt2 = mxmap.map_lnglat_to_meters(lnglat2[0], lnglat2[1]);
  56590. if (isLoad_googlecn_map) {
  56591. if (!(mxmap.outOfChina(lnglat1[0], lnglat1[1]) && mxmap.outOfChina(lnglat2[0], lnglat2[1]))) {
  56592. let lnglat_gps841 = mxcad2.mx_gcj02_To_gps84(lnglat1[0], lnglat1[1]);
  56593. let lnglat_gps842 = mxcad2.mx_gcj02_To_gps84(lnglat2[0], lnglat2[1]);
  56594. map_pt1 = mxmap.map_lnglat_to_meters(lnglat_gps841.lng, lnglat_gps841.lat);
  56595. map_pt2 = mxmap.map_lnglat_to_meters(lnglat_gps842.lng, lnglat_gps842.lat);
  56596. }
  56597. }
  56598. let map_download_param = {
  56599. url: "https://gac-geo.googlecnapps.cn/maps/vt?lyrs=s&x={x}&y={y}&z={z}",
  56600. polygon: [map_pt1[0], map_pt1[1], map_pt2[0], map_pt2[1]],
  56601. zoom: 18,
  56602. auto_close: false,
  56603. no_repeated_download: true,
  56604. download_dir: "",
  56605. thread_count: 32
  56606. };
  56607. mxdraw.MxFun.acutPrintf("\n 使用教程:https://help.mxdraw.com/?pid=111");
  56608. mxdraw.MxFun.acutPrintf("\n 复制下面的范围,到下载器下载地图,下载范围:");
  56609. let sbound = "\n" + JSON.stringify([map_pt1[0], map_pt1[1], map_pt2[0], map_pt2[1]]);
  56610. mxdraw.MxFun.acutPrintf(sbound);
  56611. mxdraw.MxFun.acutPrintf("\n");
  56612. axios2({
  56613. method: "post",
  56614. url: "http://localhost:1337/users/mxgis/download",
  56615. data: map_download_param
  56616. }).then((ret) => {
  56617. console.log(ret.data);
  56618. alert(JSON.stringify(ret.data));
  56619. }).catch((err) => {
  56620. console.log("网络错误");
  56621. });
  56622. });
  56623. }
  56624. window._iconfont_svg_string_4337873 = '<svg><symbol id="icon-zidian" viewBox="0 0 1024 1024"><path d="M893.080181 585.210149h-86.234525v-37.615932h79.557697a57.552376 57.552376 0 0 0 1.786757-115.104753l-20.500683-0.658279 2.445035-20.312603a153.473004 153.473004 0 0 0 1.034439-17.679488A148.300813 148.300813 0 0 0 723.056167 245.72636a151.310088 151.310088 0 0 0-39.966928 5.64239l-20.782803 5.64239-3.009274-21.347042A225.695594 225.695594 0 0 0 209.222531 266.415123v18.807966l-16.739089 1.880797a130.715365 130.715365 0 0 0 14.952333 260.490331v37.615932a168.331297 168.331297 0 0 1-35.547056-332.806961 263.311526 263.311526 0 0 1 521.074702-41.753685 181.120714 181.120714 0 0 1 29.998706-2.539075 185.916746 185.916746 0 0 1 185.822706 185.728666v3.573513a95.168309 95.168309 0 0 1-15.704652 187.515423z" fill="#282D33" ></path><path d="M399.371069 341.646988H329.875634a74.573586 74.573586 0 0 0-74.291466 73.257028v478.944858-18.807966 14.576174a74.573586 74.573586 0 0 1 74.573586-74.479546h431.454744V341.646988H399.371069z" fill="#FFFFFF" ></path><path d="M255.584168 908.519088h-18.807966V414.715936A94.039831 94.039831 0 0 1 329.875634 322.839021h69.495435v37.615933H329.875634a56.423898 56.423898 0 0 0-55.4835 54.825221v399.481201a93.381552 93.381552 0 0 1 55.76562-18.807966h412.646778V360.454954H506.012238v-37.615933h274.408226v511.106481H329.875634a55.85966 55.85966 0 0 0-55.4835 52.568265v7.523187h-0.940398a18.807966 18.807966 0 0 1-17.867568 14.482134z" fill="#282D33" ></path><path d="M369.654483 392.804655H710.736949v371.363292H369.654483z" fill="#F8C44F" ></path><path d="M761.612498 815.137536H329.875634a74.573586 74.573586 0 1 0 0 149.053132h431.736864z" fill="#FFFFFF" ></path><path d="M780.420464 982.998634H329.875634a93.381552 93.381552 0 1 1 0-186.669064h450.54483zM329.875634 833.945502a55.76562 55.76562 0 1 0 0 111.437199h412.928898V833.945502z" fill="#282D33" ></path><path d="M475.073133 1024l-54.072903-34.230498-54.072902 34.230498v-127.89417h108.145805v127.89417z" fill="#34CA9D" ></path><path d="M324.327284 893.942914z" fill="#FFFFFF" ></path><path d="M324.327284 875.134948h437.285214v37.615932h-437.285214z" fill="#282D33" ></path><path d="M324.327284 810.529584z" fill="#FFFFFF" ></path><path d="M305.519318 349.076134h37.615933v461.45345h-37.615933zM520.494371 257.857498L453.067813 190.524979l-67.332519 67.332519-26.613272-26.613272L453.067813 137.392475l94.039831 93.851751-26.613273 26.613272z" fill="#282D33" ></path><path d="M436.422763 189.302462h37.615932v248.829392h-37.615932zM559.803021 694.390393l-94.039831-93.851751 26.613272-26.613272 67.426559 67.332519 67.426558-67.332519 26.519233 26.613272-93.945791 93.851751z" fill="#282D33" ></path><path d="M538.832138 393.556974h37.615933v248.829393h-37.615933z" fill="#282D33" ></path></symbol></svg>', function(a) {
  56625. var t = (t = document.getElementsByTagName("script"))[t.length - 1], e = t.getAttribute("data-injectcss"), t = t.getAttribute("data-disable-injectsvg");
  56626. if (!t) {
  56627. var n, i2, l, o, h, d = function(t2, e2) {
  56628. e2.parentNode.insertBefore(t2, e2);
  56629. };
  56630. if (e && !a.__iconfont__svg__cssinject__) {
  56631. a.__iconfont__svg__cssinject__ = true;
  56632. try {
  56633. document.write("<style>.svgfont {display: inline-block;width: 1em;height: 1em;fill: currentColor;vertical-align: -0.1em;font-size:16px;}</style>");
  56634. } catch (t2) {
  56635. console && console.log(t2);
  56636. }
  56637. }
  56638. n = function() {
  56639. var t2, e2 = document.createElement("div");
  56640. e2.innerHTML = a._iconfont_svg_string_4337873, (e2 = e2.getElementsByTagName("svg")[0]) && (e2.setAttribute("aria-hidden", "true"), e2.style.position = "absolute", e2.style.width = 0, e2.style.height = 0, e2.style.overflow = "hidden", e2 = e2, (t2 = document.body).firstChild ? d(e2, t2.firstChild) : t2.appendChild(e2));
  56641. }, document.addEventListener ? ~["complete", "loaded", "interactive"].indexOf(document.readyState) ? setTimeout(n, 0) : (i2 = function() {
  56642. document.removeEventListener("DOMContentLoaded", i2, false), n();
  56643. }, document.addEventListener("DOMContentLoaded", i2, false)) : document.attachEvent && (l = n, o = a.document, h = false, s(), o.onreadystatechange = function() {
  56644. "complete" == o.readyState && (o.onreadystatechange = null, c());
  56645. });
  56646. }
  56647. function c() {
  56648. h || (h = true, l());
  56649. }
  56650. function s() {
  56651. try {
  56652. o.documentElement.doScroll("left");
  56653. } catch (t2) {
  56654. return void setTimeout(s, 50);
  56655. }
  56656. c();
  56657. }
  56658. }(window);
  56659. var GLTFLoader = function() {
  56660. function GLTFLoader2(manager) {
  56661. Loader.call(this, manager);
  56662. this.dracoLoader = null;
  56663. this.ddsLoader = null;
  56664. }
  56665. GLTFLoader2.prototype = Object.assign(Object.create(Loader.prototype), {
  56666. constructor: GLTFLoader2,
  56667. load: function(url, onLoad, onProgress, onError) {
  56668. var scope = this;
  56669. var resourcePath;
  56670. if (this.resourcePath !== "") {
  56671. resourcePath = this.resourcePath;
  56672. } else if (this.path !== "") {
  56673. resourcePath = this.path;
  56674. } else {
  56675. resourcePath = LoaderUtils.extractUrlBase(url);
  56676. }
  56677. scope.manager.itemStart(url);
  56678. var _onError = function(e) {
  56679. if (onError) {
  56680. onError(e);
  56681. } else {
  56682. console.error(e);
  56683. }
  56684. scope.manager.itemError(url);
  56685. scope.manager.itemEnd(url);
  56686. };
  56687. var loader = new FileLoader(scope.manager);
  56688. loader.setPath(this.path);
  56689. loader.setResponseType("arraybuffer");
  56690. if (scope.crossOrigin === "use-credentials") {
  56691. loader.setWithCredentials(true);
  56692. }
  56693. loader.load(url, function(data) {
  56694. try {
  56695. scope.parse(data, resourcePath, function(gltf) {
  56696. onLoad(gltf);
  56697. scope.manager.itemEnd(url);
  56698. }, _onError);
  56699. } catch (e) {
  56700. _onError(e);
  56701. }
  56702. }, onProgress, _onError);
  56703. },
  56704. setDRACOLoader: function(dracoLoader) {
  56705. this.dracoLoader = dracoLoader;
  56706. return this;
  56707. },
  56708. setDDSLoader: function(ddsLoader) {
  56709. this.ddsLoader = ddsLoader;
  56710. return this;
  56711. },
  56712. parse: function(data, path, onLoad, onError) {
  56713. var content;
  56714. var extensions = {};
  56715. if (typeof data === "string") {
  56716. content = data;
  56717. } else {
  56718. var magic = LoaderUtils.decodeText(new Uint8Array(data, 0, 4));
  56719. if (magic === BINARY_EXTENSION_HEADER_MAGIC) {
  56720. try {
  56721. extensions[EXTENSIONS.KHR_BINARY_GLTF] = new GLTFBinaryExtension(data);
  56722. } catch (error) {
  56723. if (onError)
  56724. onError(error);
  56725. return;
  56726. }
  56727. content = extensions[EXTENSIONS.KHR_BINARY_GLTF].content;
  56728. } else {
  56729. content = LoaderUtils.decodeText(new Uint8Array(data));
  56730. }
  56731. }
  56732. var json = JSON.parse(content);
  56733. if (json.asset === void 0 || json.asset.version[0] < 2) {
  56734. if (onError)
  56735. onError(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
  56736. return;
  56737. }
  56738. if (json.extensionsUsed) {
  56739. for (var i2 = 0; i2 < json.extensionsUsed.length; ++i2) {
  56740. var extensionName = json.extensionsUsed[i2];
  56741. var extensionsRequired = json.extensionsRequired || [];
  56742. switch (extensionName) {
  56743. case EXTENSIONS.KHR_LIGHTS_PUNCTUAL:
  56744. extensions[extensionName] = new GLTFLightsExtension(json);
  56745. break;
  56746. case EXTENSIONS.KHR_MATERIALS_UNLIT:
  56747. extensions[extensionName] = new GLTFMaterialsUnlitExtension();
  56748. break;
  56749. case EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:
  56750. extensions[extensionName] = new GLTFMaterialsPbrSpecularGlossinessExtension();
  56751. break;
  56752. case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:
  56753. extensions[extensionName] = new GLTFDracoMeshCompressionExtension(json, this.dracoLoader);
  56754. break;
  56755. case EXTENSIONS.MSFT_TEXTURE_DDS:
  56756. extensions[extensionName] = new GLTFTextureDDSExtension(this.ddsLoader);
  56757. break;
  56758. case EXTENSIONS.KHR_TEXTURE_TRANSFORM:
  56759. extensions[extensionName] = new GLTFTextureTransformExtension();
  56760. break;
  56761. case EXTENSIONS.KHR_MESH_QUANTIZATION:
  56762. extensions[extensionName] = new GLTFMeshQuantizationExtension();
  56763. break;
  56764. default:
  56765. if (extensionsRequired.indexOf(extensionName) >= 0) {
  56766. console.warn('THREE.GLTFLoader: Unknown extension "' + extensionName + '".');
  56767. }
  56768. }
  56769. }
  56770. }
  56771. var parser = new GLTFParser(json, extensions, {
  56772. path: path || this.resourcePath || "",
  56773. crossOrigin: this.crossOrigin,
  56774. manager: this.manager
  56775. });
  56776. parser.parse(onLoad, onError);
  56777. }
  56778. });
  56779. function GLTFRegistry() {
  56780. var objects = {};
  56781. return {
  56782. get: function(key) {
  56783. return objects[key];
  56784. },
  56785. add: function(key, object) {
  56786. objects[key] = object;
  56787. },
  56788. remove: function(key) {
  56789. delete objects[key];
  56790. },
  56791. removeAll: function() {
  56792. objects = {};
  56793. }
  56794. };
  56795. }
  56796. var EXTENSIONS = {
  56797. KHR_BINARY_GLTF: "KHR_binary_glTF",
  56798. KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
  56799. KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
  56800. KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: "KHR_materials_pbrSpecularGlossiness",
  56801. KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
  56802. KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
  56803. KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
  56804. MSFT_TEXTURE_DDS: "MSFT_texture_dds"
  56805. };
  56806. function GLTFTextureDDSExtension(ddsLoader) {
  56807. if (!ddsLoader) {
  56808. throw new Error("THREE.GLTFLoader: Attempting to load .dds texture without importing DDSLoader");
  56809. }
  56810. this.name = EXTENSIONS.MSFT_TEXTURE_DDS;
  56811. this.ddsLoader = ddsLoader;
  56812. }
  56813. function GLTFLightsExtension(json) {
  56814. this.name = EXTENSIONS.KHR_LIGHTS_PUNCTUAL;
  56815. var extension = json.extensions && json.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL] || {};
  56816. this.lightDefs = extension.lights || [];
  56817. }
  56818. GLTFLightsExtension.prototype.loadLight = function(lightIndex) {
  56819. var lightDef = this.lightDefs[lightIndex];
  56820. var lightNode;
  56821. var color = new Color(16777215);
  56822. if (lightDef.color !== void 0)
  56823. color.fromArray(lightDef.color);
  56824. var range = lightDef.range !== void 0 ? lightDef.range : 0;
  56825. switch (lightDef.type) {
  56826. case "directional":
  56827. lightNode = new DirectionalLight(color);
  56828. lightNode.target.position.set(0, 0, -1);
  56829. lightNode.add(lightNode.target);
  56830. break;
  56831. case "point":
  56832. lightNode = new PointLight(color);
  56833. lightNode.distance = range;
  56834. break;
  56835. case "spot":
  56836. lightNode = new SpotLight(color);
  56837. lightNode.distance = range;
  56838. lightDef.spot = lightDef.spot || {};
  56839. lightDef.spot.innerConeAngle = lightDef.spot.innerConeAngle !== void 0 ? lightDef.spot.innerConeAngle : 0;
  56840. lightDef.spot.outerConeAngle = lightDef.spot.outerConeAngle !== void 0 ? lightDef.spot.outerConeAngle : Math.PI / 4;
  56841. lightNode.angle = lightDef.spot.outerConeAngle;
  56842. lightNode.penumbra = 1 - lightDef.spot.innerConeAngle / lightDef.spot.outerConeAngle;
  56843. lightNode.target.position.set(0, 0, -1);
  56844. lightNode.add(lightNode.target);
  56845. break;
  56846. default:
  56847. throw new Error('THREE.GLTFLoader: Unexpected light type, "' + lightDef.type + '".');
  56848. }
  56849. lightNode.position.set(0, 0, 0);
  56850. lightNode.decay = 2;
  56851. if (lightDef.intensity !== void 0)
  56852. lightNode.intensity = lightDef.intensity;
  56853. lightNode.name = lightDef.name || "light_" + lightIndex;
  56854. return Promise.resolve(lightNode);
  56855. };
  56856. function GLTFMaterialsUnlitExtension() {
  56857. this.name = EXTENSIONS.KHR_MATERIALS_UNLIT;
  56858. }
  56859. GLTFMaterialsUnlitExtension.prototype.getMaterialType = function() {
  56860. return MeshBasicMaterial;
  56861. };
  56862. GLTFMaterialsUnlitExtension.prototype.extendParams = function(materialParams, materialDef, parser) {
  56863. var pending = [];
  56864. materialParams.color = new Color(1, 1, 1);
  56865. materialParams.opacity = 1;
  56866. var metallicRoughness = materialDef.pbrMetallicRoughness;
  56867. if (metallicRoughness) {
  56868. if (Array.isArray(metallicRoughness.baseColorFactor)) {
  56869. var array = metallicRoughness.baseColorFactor;
  56870. materialParams.color.fromArray(array);
  56871. materialParams.opacity = array[3];
  56872. }
  56873. if (metallicRoughness.baseColorTexture !== void 0) {
  56874. pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture));
  56875. }
  56876. }
  56877. return Promise.all(pending);
  56878. };
  56879. var BINARY_EXTENSION_HEADER_MAGIC = "glTF";
  56880. var BINARY_EXTENSION_HEADER_LENGTH = 12;
  56881. var BINARY_EXTENSION_CHUNK_TYPES = { JSON: 1313821514, BIN: 5130562 };
  56882. function GLTFBinaryExtension(data) {
  56883. this.name = EXTENSIONS.KHR_BINARY_GLTF;
  56884. this.content = null;
  56885. this.body = null;
  56886. var headerView = new DataView(data, 0, BINARY_EXTENSION_HEADER_LENGTH);
  56887. this.header = {
  56888. magic: LoaderUtils.decodeText(new Uint8Array(data.slice(0, 4))),
  56889. version: headerView.getUint32(4, true),
  56890. length: headerView.getUint32(8, true)
  56891. };
  56892. if (this.header.magic !== BINARY_EXTENSION_HEADER_MAGIC) {
  56893. throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
  56894. } else if (this.header.version < 2) {
  56895. throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
  56896. }
  56897. var chunkView = new DataView(data, BINARY_EXTENSION_HEADER_LENGTH);
  56898. var chunkIndex = 0;
  56899. while (chunkIndex < chunkView.byteLength) {
  56900. var chunkLength = chunkView.getUint32(chunkIndex, true);
  56901. chunkIndex += 4;
  56902. var chunkType = chunkView.getUint32(chunkIndex, true);
  56903. chunkIndex += 4;
  56904. if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON) {
  56905. var contentArray = new Uint8Array(data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength);
  56906. this.content = LoaderUtils.decodeText(contentArray);
  56907. } else if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN) {
  56908. var byteOffset = BINARY_EXTENSION_HEADER_LENGTH + chunkIndex;
  56909. this.body = data.slice(byteOffset, byteOffset + chunkLength);
  56910. }
  56911. chunkIndex += chunkLength;
  56912. }
  56913. if (this.content === null) {
  56914. throw new Error("THREE.GLTFLoader: JSON content not found.");
  56915. }
  56916. }
  56917. function GLTFDracoMeshCompressionExtension(json, dracoLoader) {
  56918. if (!dracoLoader) {
  56919. throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
  56920. }
  56921. this.name = EXTENSIONS.KHR_DRACO_MESH_COMPRESSION;
  56922. this.json = json;
  56923. this.dracoLoader = dracoLoader;
  56924. this.dracoLoader.preload();
  56925. }
  56926. GLTFDracoMeshCompressionExtension.prototype.decodePrimitive = function(primitive, parser) {
  56927. var json = this.json;
  56928. var dracoLoader = this.dracoLoader;
  56929. var bufferViewIndex = primitive.extensions[this.name].bufferView;
  56930. var gltfAttributeMap = primitive.extensions[this.name].attributes;
  56931. var threeAttributeMap = {};
  56932. var attributeNormalizedMap = {};
  56933. var attributeTypeMap = {};
  56934. for (var attributeName in gltfAttributeMap) {
  56935. var threeAttributeName = ATTRIBUTES[attributeName] || attributeName.toLowerCase();
  56936. threeAttributeMap[threeAttributeName] = gltfAttributeMap[attributeName];
  56937. }
  56938. for (attributeName in primitive.attributes) {
  56939. var threeAttributeName = ATTRIBUTES[attributeName] || attributeName.toLowerCase();
  56940. if (gltfAttributeMap[attributeName] !== void 0) {
  56941. var accessorDef = json.accessors[primitive.attributes[attributeName]];
  56942. var componentType = WEBGL_COMPONENT_TYPES[accessorDef.componentType];
  56943. attributeTypeMap[threeAttributeName] = componentType;
  56944. attributeNormalizedMap[threeAttributeName] = accessorDef.normalized === true;
  56945. }
  56946. }
  56947. return parser.getDependency("bufferView", bufferViewIndex).then(function(bufferView) {
  56948. return new Promise(function(resolve) {
  56949. dracoLoader.decodeDracoFile(bufferView, function(geometry) {
  56950. for (var attributeName2 in geometry.attributes) {
  56951. var attribute = geometry.attributes[attributeName2];
  56952. var normalized = attributeNormalizedMap[attributeName2];
  56953. if (normalized !== void 0)
  56954. attribute.normalized = normalized;
  56955. }
  56956. resolve(geometry);
  56957. }, threeAttributeMap, attributeTypeMap);
  56958. });
  56959. });
  56960. };
  56961. function GLTFTextureTransformExtension() {
  56962. this.name = EXTENSIONS.KHR_TEXTURE_TRANSFORM;
  56963. }
  56964. GLTFTextureTransformExtension.prototype.extendTexture = function(texture, transform) {
  56965. texture = texture.clone();
  56966. if (transform.offset !== void 0) {
  56967. texture.offset.fromArray(transform.offset);
  56968. }
  56969. if (transform.rotation !== void 0) {
  56970. texture.rotation = transform.rotation;
  56971. }
  56972. if (transform.scale !== void 0) {
  56973. texture.repeat.fromArray(transform.scale);
  56974. }
  56975. if (transform.texCoord !== void 0) {
  56976. console.warn('THREE.GLTFLoader: Custom UV sets in "' + this.name + '" extension not yet supported.');
  56977. }
  56978. texture.needsUpdate = true;
  56979. return texture;
  56980. };
  56981. function GLTFMeshStandardSGMaterial(params) {
  56982. MeshStandardMaterial.call(this);
  56983. this.isGLTFSpecularGlossinessMaterial = true;
  56984. var specularMapParsFragmentChunk = [
  56985. "#ifdef USE_SPECULARMAP",
  56986. " uniform sampler2D specularMap;",
  56987. "#endif"
  56988. ].join("\n");
  56989. var glossinessMapParsFragmentChunk = [
  56990. "#ifdef USE_GLOSSINESSMAP",
  56991. " uniform sampler2D glossinessMap;",
  56992. "#endif"
  56993. ].join("\n");
  56994. var specularMapFragmentChunk = [
  56995. "vec3 specularFactor = specular;",
  56996. "#ifdef USE_SPECULARMAP",
  56997. " vec4 texelSpecular = texture2D( specularMap, vUv );",
  56998. " texelSpecular = sRGBToLinear( texelSpecular );",
  56999. " // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture",
  57000. " specularFactor *= texelSpecular.rgb;",
  57001. "#endif"
  57002. ].join("\n");
  57003. var glossinessMapFragmentChunk = [
  57004. "float glossinessFactor = glossiness;",
  57005. "#ifdef USE_GLOSSINESSMAP",
  57006. " vec4 texelGlossiness = texture2D( glossinessMap, vUv );",
  57007. " // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture",
  57008. " glossinessFactor *= texelGlossiness.a;",
  57009. "#endif"
  57010. ].join("\n");
  57011. var lightPhysicalFragmentChunk = [
  57012. "PhysicalMaterial material;",
  57013. "material.diffuseColor = diffuseColor.rgb;",
  57014. "vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );",
  57015. "float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );",
  57016. "material.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.",
  57017. "material.specularRoughness += geometryRoughness;",
  57018. "material.specularRoughness = min( material.specularRoughness, 1.0 );",
  57019. "material.specularColor = specularFactor.rgb;"
  57020. ].join("\n");
  57021. var uniforms = {
  57022. specular: { value: new Color().setHex(16777215) },
  57023. glossiness: { value: 1 },
  57024. specularMap: { value: null },
  57025. glossinessMap: { value: null }
  57026. };
  57027. this._extraUniforms = uniforms;
  57028. this.onBeforeCompile = function(shader) {
  57029. for (var uniformName in uniforms) {
  57030. shader.uniforms[uniformName] = uniforms[uniformName];
  57031. }
  57032. shader.fragmentShader = shader.fragmentShader.replace("uniform float roughness;", "uniform vec3 specular;");
  57033. shader.fragmentShader = shader.fragmentShader.replace("uniform float metalness;", "uniform float glossiness;");
  57034. shader.fragmentShader = shader.fragmentShader.replace("#include <roughnessmap_pars_fragment>", specularMapParsFragmentChunk);
  57035. shader.fragmentShader = shader.fragmentShader.replace("#include <metalnessmap_pars_fragment>", glossinessMapParsFragmentChunk);
  57036. shader.fragmentShader = shader.fragmentShader.replace("#include <roughnessmap_fragment>", specularMapFragmentChunk);
  57037. shader.fragmentShader = shader.fragmentShader.replace("#include <metalnessmap_fragment>", glossinessMapFragmentChunk);
  57038. shader.fragmentShader = shader.fragmentShader.replace("#include <lights_physical_fragment>", lightPhysicalFragmentChunk);
  57039. };
  57040. Object.defineProperties(
  57041. this,
  57042. {
  57043. specular: {
  57044. get: function() {
  57045. return uniforms.specular.value;
  57046. },
  57047. set: function(v) {
  57048. uniforms.specular.value = v;
  57049. }
  57050. },
  57051. specularMap: {
  57052. get: function() {
  57053. return uniforms.specularMap.value;
  57054. },
  57055. set: function(v) {
  57056. uniforms.specularMap.value = v;
  57057. }
  57058. },
  57059. glossiness: {
  57060. get: function() {
  57061. return uniforms.glossiness.value;
  57062. },
  57063. set: function(v) {
  57064. uniforms.glossiness.value = v;
  57065. }
  57066. },
  57067. glossinessMap: {
  57068. get: function() {
  57069. return uniforms.glossinessMap.value;
  57070. },
  57071. set: function(v) {
  57072. uniforms.glossinessMap.value = v;
  57073. if (v) {
  57074. this.defines.USE_GLOSSINESSMAP = "";
  57075. this.defines.USE_ROUGHNESSMAP = "";
  57076. } else {
  57077. delete this.defines.USE_ROUGHNESSMAP;
  57078. delete this.defines.USE_GLOSSINESSMAP;
  57079. }
  57080. }
  57081. }
  57082. }
  57083. );
  57084. delete this.metalness;
  57085. delete this.roughness;
  57086. delete this.metalnessMap;
  57087. delete this.roughnessMap;
  57088. this.setValues(params);
  57089. }
  57090. GLTFMeshStandardSGMaterial.prototype = Object.create(MeshStandardMaterial.prototype);
  57091. GLTFMeshStandardSGMaterial.prototype.constructor = GLTFMeshStandardSGMaterial;
  57092. GLTFMeshStandardSGMaterial.prototype.copy = function(source) {
  57093. MeshStandardMaterial.prototype.copy.call(this, source);
  57094. this.specularMap = source.specularMap;
  57095. this.specular.copy(source.specular);
  57096. this.glossinessMap = source.glossinessMap;
  57097. this.glossiness = source.glossiness;
  57098. delete this.metalness;
  57099. delete this.roughness;
  57100. delete this.metalnessMap;
  57101. delete this.roughnessMap;
  57102. return this;
  57103. };
  57104. function GLTFMaterialsPbrSpecularGlossinessExtension() {
  57105. return {
  57106. name: EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,
  57107. specularGlossinessParams: [
  57108. "color",
  57109. "map",
  57110. "lightMap",
  57111. "lightMapIntensity",
  57112. "aoMap",
  57113. "aoMapIntensity",
  57114. "emissive",
  57115. "emissiveIntensity",
  57116. "emissiveMap",
  57117. "bumpMap",
  57118. "bumpScale",
  57119. "normalMap",
  57120. "normalMapType",
  57121. "displacementMap",
  57122. "displacementScale",
  57123. "displacementBias",
  57124. "specularMap",
  57125. "specular",
  57126. "glossinessMap",
  57127. "glossiness",
  57128. "alphaMap",
  57129. "envMap",
  57130. "envMapIntensity",
  57131. "refractionRatio"
  57132. ],
  57133. getMaterialType: function() {
  57134. return GLTFMeshStandardSGMaterial;
  57135. },
  57136. extendParams: function(materialParams, materialDef, parser) {
  57137. var pbrSpecularGlossiness = materialDef.extensions[this.name];
  57138. materialParams.color = new Color(1, 1, 1);
  57139. materialParams.opacity = 1;
  57140. var pending = [];
  57141. if (Array.isArray(pbrSpecularGlossiness.diffuseFactor)) {
  57142. var array = pbrSpecularGlossiness.diffuseFactor;
  57143. materialParams.color.fromArray(array);
  57144. materialParams.opacity = array[3];
  57145. }
  57146. if (pbrSpecularGlossiness.diffuseTexture !== void 0) {
  57147. pending.push(parser.assignTexture(materialParams, "map", pbrSpecularGlossiness.diffuseTexture));
  57148. }
  57149. materialParams.emissive = new Color(0, 0, 0);
  57150. materialParams.glossiness = pbrSpecularGlossiness.glossinessFactor !== void 0 ? pbrSpecularGlossiness.glossinessFactor : 1;
  57151. materialParams.specular = new Color(1, 1, 1);
  57152. if (Array.isArray(pbrSpecularGlossiness.specularFactor)) {
  57153. materialParams.specular.fromArray(pbrSpecularGlossiness.specularFactor);
  57154. }
  57155. if (pbrSpecularGlossiness.specularGlossinessTexture !== void 0) {
  57156. var specGlossMapDef = pbrSpecularGlossiness.specularGlossinessTexture;
  57157. pending.push(parser.assignTexture(materialParams, "glossinessMap", specGlossMapDef));
  57158. pending.push(parser.assignTexture(materialParams, "specularMap", specGlossMapDef));
  57159. }
  57160. return Promise.all(pending);
  57161. },
  57162. createMaterial: function(materialParams) {
  57163. var material = new GLTFMeshStandardSGMaterial(materialParams);
  57164. material.fog = true;
  57165. material.color = materialParams.color;
  57166. material.map = materialParams.map === void 0 ? null : materialParams.map;
  57167. material.lightMap = null;
  57168. material.lightMapIntensity = 1;
  57169. material.aoMap = materialParams.aoMap === void 0 ? null : materialParams.aoMap;
  57170. material.aoMapIntensity = 1;
  57171. material.emissive = materialParams.emissive;
  57172. material.emissiveIntensity = 1;
  57173. material.emissiveMap = materialParams.emissiveMap === void 0 ? null : materialParams.emissiveMap;
  57174. material.bumpMap = materialParams.bumpMap === void 0 ? null : materialParams.bumpMap;
  57175. material.bumpScale = 1;
  57176. material.normalMap = materialParams.normalMap === void 0 ? null : materialParams.normalMap;
  57177. material.normalMapType = TangentSpaceNormalMap;
  57178. if (materialParams.normalScale)
  57179. material.normalScale = materialParams.normalScale;
  57180. material.displacementMap = null;
  57181. material.displacementScale = 1;
  57182. material.displacementBias = 0;
  57183. material.specularMap = materialParams.specularMap === void 0 ? null : materialParams.specularMap;
  57184. material.specular = materialParams.specular;
  57185. material.glossinessMap = materialParams.glossinessMap === void 0 ? null : materialParams.glossinessMap;
  57186. material.glossiness = materialParams.glossiness;
  57187. material.alphaMap = null;
  57188. material.envMap = materialParams.envMap === void 0 ? null : materialParams.envMap;
  57189. material.envMapIntensity = 1;
  57190. material.refractionRatio = 0.98;
  57191. return material;
  57192. }
  57193. };
  57194. }
  57195. function GLTFMeshQuantizationExtension() {
  57196. this.name = EXTENSIONS.KHR_MESH_QUANTIZATION;
  57197. }
  57198. function GLTFCubicSplineInterpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {
  57199. Interpolant.call(this, parameterPositions, sampleValues, sampleSize, resultBuffer);
  57200. }
  57201. GLTFCubicSplineInterpolant.prototype = Object.create(Interpolant.prototype);
  57202. GLTFCubicSplineInterpolant.prototype.constructor = GLTFCubicSplineInterpolant;
  57203. GLTFCubicSplineInterpolant.prototype.copySampleValue_ = function(index) {
  57204. var result = this.resultBuffer, values = this.sampleValues, valueSize = this.valueSize, offset = index * valueSize * 3 + valueSize;
  57205. for (var i2 = 0; i2 !== valueSize; i2++) {
  57206. result[i2] = values[offset + i2];
  57207. }
  57208. return result;
  57209. };
  57210. GLTFCubicSplineInterpolant.prototype.beforeStart_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_;
  57211. GLTFCubicSplineInterpolant.prototype.afterEnd_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_;
  57212. GLTFCubicSplineInterpolant.prototype.interpolate_ = function(i1, t0, t, t1) {
  57213. var result = this.resultBuffer;
  57214. var values = this.sampleValues;
  57215. var stride = this.valueSize;
  57216. var stride2 = stride * 2;
  57217. var stride3 = stride * 3;
  57218. var td = t1 - t0;
  57219. var p = (t - t0) / td;
  57220. var pp = p * p;
  57221. var ppp = pp * p;
  57222. var offset1 = i1 * stride3;
  57223. var offset0 = offset1 - stride3;
  57224. var s2 = -2 * ppp + 3 * pp;
  57225. var s3 = ppp - pp;
  57226. var s0 = 1 - s2;
  57227. var s1 = s3 - pp + p;
  57228. for (var i2 = 0; i2 !== stride; i2++) {
  57229. var p0 = values[offset0 + i2 + stride];
  57230. var m0 = values[offset0 + i2 + stride2] * td;
  57231. var p1 = values[offset1 + i2 + stride];
  57232. var m1 = values[offset1 + i2] * td;
  57233. result[i2] = s0 * p0 + s1 * m0 + s2 * p1 + s3 * m1;
  57234. }
  57235. return result;
  57236. };
  57237. var WEBGL_CONSTANTS = {
  57238. FLOAT: 5126,
  57239. //FLOAT_MAT2: 35674,
  57240. FLOAT_MAT3: 35675,
  57241. FLOAT_MAT4: 35676,
  57242. FLOAT_VEC2: 35664,
  57243. FLOAT_VEC3: 35665,
  57244. FLOAT_VEC4: 35666,
  57245. LINEAR: 9729,
  57246. REPEAT: 10497,
  57247. SAMPLER_2D: 35678,
  57248. POINTS: 0,
  57249. LINES: 1,
  57250. LINE_LOOP: 2,
  57251. LINE_STRIP: 3,
  57252. TRIANGLES: 4,
  57253. TRIANGLE_STRIP: 5,
  57254. TRIANGLE_FAN: 6,
  57255. UNSIGNED_BYTE: 5121,
  57256. UNSIGNED_SHORT: 5123
  57257. };
  57258. var WEBGL_COMPONENT_TYPES = {
  57259. 5120: Int8Array,
  57260. 5121: Uint8Array,
  57261. 5122: Int16Array,
  57262. 5123: Uint16Array,
  57263. 5125: Uint32Array,
  57264. 5126: Float32Array
  57265. };
  57266. var WEBGL_FILTERS = {
  57267. 9728: NearestFilter,
  57268. 9729: LinearFilter,
  57269. 9984: NearestMipmapNearestFilter,
  57270. 9985: LinearMipmapNearestFilter,
  57271. 9986: NearestMipmapLinearFilter,
  57272. 9987: LinearMipmapLinearFilter
  57273. };
  57274. var WEBGL_WRAPPINGS = {
  57275. 33071: ClampToEdgeWrapping,
  57276. 33648: MirroredRepeatWrapping,
  57277. 10497: RepeatWrapping
  57278. };
  57279. var WEBGL_TYPE_SIZES = {
  57280. "SCALAR": 1,
  57281. "VEC2": 2,
  57282. "VEC3": 3,
  57283. "VEC4": 4,
  57284. "MAT2": 4,
  57285. "MAT3": 9,
  57286. "MAT4": 16
  57287. };
  57288. var ATTRIBUTES = {
  57289. POSITION: "position",
  57290. NORMAL: "normal",
  57291. TANGENT: "tangent",
  57292. TEXCOORD_0: "uv",
  57293. TEXCOORD_1: "uv2",
  57294. COLOR_0: "color",
  57295. WEIGHTS_0: "skinWeight",
  57296. JOINTS_0: "skinIndex"
  57297. };
  57298. var PATH_PROPERTIES = {
  57299. scale: "scale",
  57300. translation: "position",
  57301. rotation: "quaternion",
  57302. weights: "morphTargetInfluences"
  57303. };
  57304. var INTERPOLATION = {
  57305. CUBICSPLINE: void 0,
  57306. // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
  57307. // keyframe track will be initialized with a default interpolation type, then modified.
  57308. LINEAR: InterpolateLinear,
  57309. STEP: InterpolateDiscrete
  57310. };
  57311. var ALPHA_MODES = {
  57312. OPAQUE: "OPAQUE",
  57313. MASK: "MASK",
  57314. BLEND: "BLEND"
  57315. };
  57316. var MIME_TYPE_FORMATS = {
  57317. "image/png": RGBAFormat,
  57318. "image/jpeg": RGBFormat
  57319. };
  57320. function resolveURL(url, path) {
  57321. if (typeof url !== "string" || url === "")
  57322. return "";
  57323. if (/^https?:\/\//i.test(path) && /^\//.test(url)) {
  57324. path = path.replace(/(^https?:\/\/[^\/]+).*/i, "$1");
  57325. }
  57326. if (/^(https?:)?\/\//i.test(url))
  57327. return url;
  57328. if (/^data:.*,.*$/i.test(url))
  57329. return url;
  57330. if (/^blob:.*$/i.test(url))
  57331. return url;
  57332. return path + url;
  57333. }
  57334. function createDefaultMaterial(cache) {
  57335. if (cache["DefaultMaterial"] === void 0) {
  57336. cache["DefaultMaterial"] = new MeshStandardMaterial({
  57337. color: 16777215,
  57338. emissive: 0,
  57339. metalness: 1,
  57340. roughness: 1,
  57341. transparent: false,
  57342. depthTest: true,
  57343. side: FrontSide
  57344. });
  57345. }
  57346. return cache["DefaultMaterial"];
  57347. }
  57348. function addUnknownExtensionsToUserData(knownExtensions, object, objectDef) {
  57349. for (var name in objectDef.extensions) {
  57350. if (knownExtensions[name] === void 0) {
  57351. object.userData.gltfExtensions = object.userData.gltfExtensions || {};
  57352. object.userData.gltfExtensions[name] = objectDef.extensions[name];
  57353. }
  57354. }
  57355. }
  57356. function assignExtrasToUserData(object, gltfDef) {
  57357. if (gltfDef.extras !== void 0) {
  57358. if (typeof gltfDef.extras === "object") {
  57359. Object.assign(object.userData, gltfDef.extras);
  57360. } else {
  57361. console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + gltfDef.extras);
  57362. }
  57363. }
  57364. }
  57365. function addMorphTargets(geometry, targets, parser) {
  57366. var hasMorphPosition = false;
  57367. var hasMorphNormal = false;
  57368. for (var i2 = 0, il = targets.length; i2 < il; i2++) {
  57369. var target = targets[i2];
  57370. if (target.POSITION !== void 0)
  57371. hasMorphPosition = true;
  57372. if (target.NORMAL !== void 0)
  57373. hasMorphNormal = true;
  57374. if (hasMorphPosition && hasMorphNormal)
  57375. break;
  57376. }
  57377. if (!hasMorphPosition && !hasMorphNormal)
  57378. return Promise.resolve(geometry);
  57379. var pendingPositionAccessors = [];
  57380. var pendingNormalAccessors = [];
  57381. for (var i2 = 0, il = targets.length; i2 < il; i2++) {
  57382. var target = targets[i2];
  57383. if (hasMorphPosition) {
  57384. var pendingAccessor = target.POSITION !== void 0 ? parser.getDependency("accessor", target.POSITION) : geometry.attributes.position;
  57385. pendingPositionAccessors.push(pendingAccessor);
  57386. }
  57387. if (hasMorphNormal) {
  57388. var pendingAccessor = target.NORMAL !== void 0 ? parser.getDependency("accessor", target.NORMAL) : geometry.attributes.normal;
  57389. pendingNormalAccessors.push(pendingAccessor);
  57390. }
  57391. }
  57392. return Promise.all([
  57393. Promise.all(pendingPositionAccessors),
  57394. Promise.all(pendingNormalAccessors)
  57395. ]).then(function(accessors) {
  57396. var morphPositions = accessors[0];
  57397. var morphNormals = accessors[1];
  57398. if (hasMorphPosition)
  57399. geometry.morphAttributes.position = morphPositions;
  57400. if (hasMorphNormal)
  57401. geometry.morphAttributes.normal = morphNormals;
  57402. geometry.morphTargetsRelative = true;
  57403. return geometry;
  57404. });
  57405. }
  57406. function updateMorphTargets(mesh, meshDef) {
  57407. mesh.updateMorphTargets();
  57408. if (meshDef.weights !== void 0) {
  57409. for (var i2 = 0, il = meshDef.weights.length; i2 < il; i2++) {
  57410. mesh.morphTargetInfluences[i2] = meshDef.weights[i2];
  57411. }
  57412. }
  57413. if (meshDef.extras && Array.isArray(meshDef.extras.targetNames)) {
  57414. var targetNames = meshDef.extras.targetNames;
  57415. if (mesh.morphTargetInfluences.length === targetNames.length) {
  57416. mesh.morphTargetDictionary = {};
  57417. for (var i2 = 0, il = targetNames.length; i2 < il; i2++) {
  57418. mesh.morphTargetDictionary[targetNames[i2]] = i2;
  57419. }
  57420. } else {
  57421. console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
  57422. }
  57423. }
  57424. }
  57425. function createPrimitiveKey(primitiveDef) {
  57426. var dracoExtension = primitiveDef.extensions && primitiveDef.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION];
  57427. var geometryKey;
  57428. if (dracoExtension) {
  57429. geometryKey = "draco:" + dracoExtension.bufferView + ":" + dracoExtension.indices + ":" + createAttributesKey(dracoExtension.attributes);
  57430. } else {
  57431. geometryKey = primitiveDef.indices + ":" + createAttributesKey(primitiveDef.attributes) + ":" + primitiveDef.mode;
  57432. }
  57433. return geometryKey;
  57434. }
  57435. function createAttributesKey(attributes) {
  57436. var attributesKey = "";
  57437. var keys = Object.keys(attributes).sort();
  57438. for (var i2 = 0, il = keys.length; i2 < il; i2++) {
  57439. attributesKey += keys[i2] + ":" + attributes[keys[i2]] + ";";
  57440. }
  57441. return attributesKey;
  57442. }
  57443. function GLTFParser(json, extensions, options) {
  57444. this.json = json || {};
  57445. this.extensions = extensions || {};
  57446. this.options = options || {};
  57447. this.cache = new GLTFRegistry();
  57448. this.primitiveCache = {};
  57449. this.textureLoader = new TextureLoader(this.options.manager);
  57450. this.textureLoader.setCrossOrigin(this.options.crossOrigin);
  57451. this.fileLoader = new FileLoader(this.options.manager);
  57452. this.fileLoader.setResponseType("arraybuffer");
  57453. if (this.options.crossOrigin === "use-credentials") {
  57454. this.fileLoader.setWithCredentials(true);
  57455. }
  57456. }
  57457. GLTFParser.prototype.parse = function(onLoad, onError) {
  57458. var parser = this;
  57459. var json = this.json;
  57460. var extensions = this.extensions;
  57461. this.cache.removeAll();
  57462. this.markDefs();
  57463. Promise.all([
  57464. this.getDependencies("scene"),
  57465. this.getDependencies("animation"),
  57466. this.getDependencies("camera")
  57467. ]).then(function(dependencies) {
  57468. var result = {
  57469. scene: dependencies[0][json.scene || 0],
  57470. scenes: dependencies[0],
  57471. animations: dependencies[1],
  57472. cameras: dependencies[2],
  57473. asset: json.asset,
  57474. parser,
  57475. userData: {}
  57476. };
  57477. addUnknownExtensionsToUserData(extensions, result, json);
  57478. assignExtrasToUserData(result, json);
  57479. onLoad(result);
  57480. }).catch(onError);
  57481. };
  57482. GLTFParser.prototype.markDefs = function() {
  57483. var nodeDefs = this.json.nodes || [];
  57484. var skinDefs = this.json.skins || [];
  57485. var meshDefs = this.json.meshes || [];
  57486. var meshReferences = {};
  57487. var meshUses = {};
  57488. for (var skinIndex = 0, skinLength = skinDefs.length; skinIndex < skinLength; skinIndex++) {
  57489. var joints = skinDefs[skinIndex].joints;
  57490. for (var i2 = 0, il = joints.length; i2 < il; i2++) {
  57491. nodeDefs[joints[i2]].isBone = true;
  57492. }
  57493. }
  57494. for (var nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex++) {
  57495. var nodeDef = nodeDefs[nodeIndex];
  57496. if (nodeDef.mesh !== void 0) {
  57497. if (meshReferences[nodeDef.mesh] === void 0) {
  57498. meshReferences[nodeDef.mesh] = meshUses[nodeDef.mesh] = 0;
  57499. }
  57500. meshReferences[nodeDef.mesh]++;
  57501. if (nodeDef.skin !== void 0) {
  57502. meshDefs[nodeDef.mesh].isSkinnedMesh = true;
  57503. }
  57504. }
  57505. }
  57506. this.json.meshReferences = meshReferences;
  57507. this.json.meshUses = meshUses;
  57508. };
  57509. GLTFParser.prototype.getDependency = function(type, index) {
  57510. var cacheKey = type + ":" + index;
  57511. var dependency = this.cache.get(cacheKey);
  57512. if (!dependency) {
  57513. switch (type) {
  57514. case "scene":
  57515. dependency = this.loadScene(index);
  57516. break;
  57517. case "node":
  57518. dependency = this.loadNode(index);
  57519. break;
  57520. case "mesh":
  57521. dependency = this.loadMesh(index);
  57522. break;
  57523. case "accessor":
  57524. dependency = this.loadAccessor(index);
  57525. break;
  57526. case "bufferView":
  57527. dependency = this.loadBufferView(index);
  57528. break;
  57529. case "buffer":
  57530. dependency = this.loadBuffer(index);
  57531. break;
  57532. case "material":
  57533. dependency = this.loadMaterial(index);
  57534. break;
  57535. case "texture":
  57536. dependency = this.loadTexture(index);
  57537. break;
  57538. case "skin":
  57539. dependency = this.loadSkin(index);
  57540. break;
  57541. case "animation":
  57542. dependency = this.loadAnimation(index);
  57543. break;
  57544. case "camera":
  57545. dependency = this.loadCamera(index);
  57546. break;
  57547. case "light":
  57548. dependency = this.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL].loadLight(index);
  57549. break;
  57550. default:
  57551. throw new Error("Unknown type: " + type);
  57552. }
  57553. this.cache.add(cacheKey, dependency);
  57554. }
  57555. return dependency;
  57556. };
  57557. GLTFParser.prototype.getDependencies = function(type) {
  57558. var dependencies = this.cache.get(type);
  57559. if (!dependencies) {
  57560. var parser = this;
  57561. var defs = this.json[type + (type === "mesh" ? "es" : "s")] || [];
  57562. dependencies = Promise.all(defs.map(function(def, index) {
  57563. return parser.getDependency(type, index);
  57564. }));
  57565. this.cache.add(type, dependencies);
  57566. }
  57567. return dependencies;
  57568. };
  57569. GLTFParser.prototype.loadBuffer = function(bufferIndex) {
  57570. var bufferDef = this.json.buffers[bufferIndex];
  57571. var loader = this.fileLoader;
  57572. if (bufferDef.type && bufferDef.type !== "arraybuffer") {
  57573. throw new Error("THREE.GLTFLoader: " + bufferDef.type + " buffer type is not supported.");
  57574. }
  57575. if (bufferDef.uri === void 0 && bufferIndex === 0) {
  57576. return Promise.resolve(this.extensions[EXTENSIONS.KHR_BINARY_GLTF].body);
  57577. }
  57578. var options = this.options;
  57579. return new Promise(function(resolve, reject) {
  57580. loader.load(resolveURL(bufferDef.uri, options.path), resolve, void 0, function() {
  57581. reject(new Error('THREE.GLTFLoader: Failed to load buffer "' + bufferDef.uri + '".'));
  57582. });
  57583. });
  57584. };
  57585. GLTFParser.prototype.loadBufferView = function(bufferViewIndex) {
  57586. var bufferViewDef = this.json.bufferViews[bufferViewIndex];
  57587. return this.getDependency("buffer", bufferViewDef.buffer).then(function(buffer) {
  57588. var byteLength = bufferViewDef.byteLength || 0;
  57589. var byteOffset = bufferViewDef.byteOffset || 0;
  57590. return buffer.slice(byteOffset, byteOffset + byteLength);
  57591. });
  57592. };
  57593. GLTFParser.prototype.loadAccessor = function(accessorIndex) {
  57594. var parser = this;
  57595. var json = this.json;
  57596. var accessorDef = this.json.accessors[accessorIndex];
  57597. if (accessorDef.bufferView === void 0 && accessorDef.sparse === void 0) {
  57598. return Promise.resolve(null);
  57599. }
  57600. var pendingBufferViews = [];
  57601. if (accessorDef.bufferView !== void 0) {
  57602. pendingBufferViews.push(this.getDependency("bufferView", accessorDef.bufferView));
  57603. } else {
  57604. pendingBufferViews.push(null);
  57605. }
  57606. if (accessorDef.sparse !== void 0) {
  57607. pendingBufferViews.push(this.getDependency("bufferView", accessorDef.sparse.indices.bufferView));
  57608. pendingBufferViews.push(this.getDependency("bufferView", accessorDef.sparse.values.bufferView));
  57609. }
  57610. return Promise.all(pendingBufferViews).then(function(bufferViews) {
  57611. var bufferView = bufferViews[0];
  57612. var itemSize = WEBGL_TYPE_SIZES[accessorDef.type];
  57613. var TypedArray = WEBGL_COMPONENT_TYPES[accessorDef.componentType];
  57614. var elementBytes = TypedArray.BYTES_PER_ELEMENT;
  57615. var itemBytes = elementBytes * itemSize;
  57616. var byteOffset = accessorDef.byteOffset || 0;
  57617. var byteStride = accessorDef.bufferView !== void 0 ? json.bufferViews[accessorDef.bufferView].byteStride : void 0;
  57618. var normalized = accessorDef.normalized === true;
  57619. var array, bufferAttribute;
  57620. if (byteStride && byteStride !== itemBytes) {
  57621. var ibSlice = Math.floor(byteOffset / byteStride);
  57622. var ibCacheKey = "InterleavedBuffer:" + accessorDef.bufferView + ":" + accessorDef.componentType + ":" + ibSlice + ":" + accessorDef.count;
  57623. var ib = parser.cache.get(ibCacheKey);
  57624. if (!ib) {
  57625. array = new TypedArray(bufferView, ibSlice * byteStride, accessorDef.count * byteStride / elementBytes);
  57626. ib = new InterleavedBuffer(array, byteStride / elementBytes);
  57627. parser.cache.add(ibCacheKey, ib);
  57628. }
  57629. bufferAttribute = new InterleavedBufferAttribute(ib, itemSize, byteOffset % byteStride / elementBytes, normalized);
  57630. } else {
  57631. if (bufferView === null) {
  57632. array = new TypedArray(accessorDef.count * itemSize);
  57633. } else {
  57634. array = new TypedArray(bufferView, byteOffset, accessorDef.count * itemSize);
  57635. }
  57636. bufferAttribute = new BufferAttribute(array, itemSize, normalized);
  57637. }
  57638. if (accessorDef.sparse !== void 0) {
  57639. var itemSizeIndices = WEBGL_TYPE_SIZES.SCALAR;
  57640. var TypedArrayIndices = WEBGL_COMPONENT_TYPES[accessorDef.sparse.indices.componentType];
  57641. var byteOffsetIndices = accessorDef.sparse.indices.byteOffset || 0;
  57642. var byteOffsetValues = accessorDef.sparse.values.byteOffset || 0;
  57643. var sparseIndices = new TypedArrayIndices(bufferViews[1], byteOffsetIndices, accessorDef.sparse.count * itemSizeIndices);
  57644. var sparseValues = new TypedArray(bufferViews[2], byteOffsetValues, accessorDef.sparse.count * itemSize);
  57645. if (bufferView !== null) {
  57646. bufferAttribute = new BufferAttribute(bufferAttribute.array.slice(), bufferAttribute.itemSize, bufferAttribute.normalized);
  57647. }
  57648. for (var i2 = 0, il = sparseIndices.length; i2 < il; i2++) {
  57649. var index = sparseIndices[i2];
  57650. bufferAttribute.setX(index, sparseValues[i2 * itemSize]);
  57651. if (itemSize >= 2)
  57652. bufferAttribute.setY(index, sparseValues[i2 * itemSize + 1]);
  57653. if (itemSize >= 3)
  57654. bufferAttribute.setZ(index, sparseValues[i2 * itemSize + 2]);
  57655. if (itemSize >= 4)
  57656. bufferAttribute.setW(index, sparseValues[i2 * itemSize + 3]);
  57657. if (itemSize >= 5)
  57658. throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
  57659. }
  57660. }
  57661. return bufferAttribute;
  57662. });
  57663. };
  57664. GLTFParser.prototype.loadTexture = function(textureIndex) {
  57665. var parser = this;
  57666. var json = this.json;
  57667. var options = this.options;
  57668. var textureLoader = this.textureLoader;
  57669. var URL2 = window.URL || window.webkitURL;
  57670. var textureDef = json.textures[textureIndex];
  57671. var textureExtensions = textureDef.extensions || {};
  57672. var source;
  57673. if (textureExtensions[EXTENSIONS.MSFT_TEXTURE_DDS]) {
  57674. source = json.images[textureExtensions[EXTENSIONS.MSFT_TEXTURE_DDS].source];
  57675. } else {
  57676. source = json.images[textureDef.source];
  57677. }
  57678. var sourceURI = source.uri;
  57679. var isObjectURL = false;
  57680. if (source.bufferView !== void 0) {
  57681. sourceURI = parser.getDependency("bufferView", source.bufferView).then(function(bufferView) {
  57682. isObjectURL = true;
  57683. var blob = new Blob([bufferView], { type: source.mimeType });
  57684. sourceURI = URL2.createObjectURL(blob);
  57685. return sourceURI;
  57686. });
  57687. }
  57688. return Promise.resolve(sourceURI).then(function(sourceURI2) {
  57689. var loader = options.manager.getHandler(sourceURI2);
  57690. if (!loader) {
  57691. loader = textureExtensions[EXTENSIONS.MSFT_TEXTURE_DDS] ? parser.extensions[EXTENSIONS.MSFT_TEXTURE_DDS].ddsLoader : textureLoader;
  57692. }
  57693. return new Promise(function(resolve, reject) {
  57694. loader.load(resolveURL(sourceURI2, options.path), resolve, void 0, reject);
  57695. });
  57696. }).then(function(texture) {
  57697. if (isObjectURL === true) {
  57698. URL2.revokeObjectURL(sourceURI);
  57699. }
  57700. texture.flipY = false;
  57701. if (textureDef.name !== void 0)
  57702. texture.name = textureDef.name;
  57703. if (source.mimeType in MIME_TYPE_FORMATS) {
  57704. texture.format = MIME_TYPE_FORMATS[source.mimeType];
  57705. }
  57706. var samplers = json.samplers || {};
  57707. var sampler = samplers[textureDef.sampler] || {};
  57708. texture.magFilter = WEBGL_FILTERS[sampler.magFilter] || LinearFilter;
  57709. texture.minFilter = WEBGL_FILTERS[sampler.minFilter] || LinearMipmapLinearFilter;
  57710. texture.wrapS = WEBGL_WRAPPINGS[sampler.wrapS] || RepeatWrapping;
  57711. texture.wrapT = WEBGL_WRAPPINGS[sampler.wrapT] || RepeatWrapping;
  57712. return texture;
  57713. });
  57714. };
  57715. GLTFParser.prototype.assignTexture = function(materialParams, mapName, mapDef) {
  57716. var parser = this;
  57717. return this.getDependency("texture", mapDef.index).then(function(texture) {
  57718. if (!texture.isCompressedTexture) {
  57719. switch (mapName) {
  57720. case "aoMap":
  57721. case "emissiveMap":
  57722. case "metalnessMap":
  57723. case "normalMap":
  57724. case "roughnessMap":
  57725. texture.format = RGBFormat;
  57726. break;
  57727. }
  57728. }
  57729. if (mapDef.texCoord !== void 0 && mapDef.texCoord != 0 && !(mapName === "aoMap" && mapDef.texCoord == 1)) {
  57730. console.warn("THREE.GLTFLoader: Custom UV set " + mapDef.texCoord + " for texture " + mapName + " not yet supported.");
  57731. }
  57732. if (parser.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]) {
  57733. var transform = mapDef.extensions !== void 0 ? mapDef.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM] : void 0;
  57734. if (transform) {
  57735. texture = parser.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM].extendTexture(texture, transform);
  57736. }
  57737. }
  57738. materialParams[mapName] = texture;
  57739. });
  57740. };
  57741. GLTFParser.prototype.assignFinalMaterial = function(mesh) {
  57742. var geometry = mesh.geometry;
  57743. var material = mesh.material;
  57744. this.extensions;
  57745. var useVertexTangents = geometry.attributes.tangent !== void 0;
  57746. var useVertexColors = geometry.attributes.color !== void 0;
  57747. var useFlatShading = geometry.attributes.normal === void 0;
  57748. var useSkinning = mesh.isSkinnedMesh === true;
  57749. var useMorphTargets = Object.keys(geometry.morphAttributes).length > 0;
  57750. var useMorphNormals = useMorphTargets && geometry.morphAttributes.normal !== void 0;
  57751. if (mesh.isPoints) {
  57752. var cacheKey = "PointsMaterial:" + material.uuid;
  57753. var pointsMaterial = this.cache.get(cacheKey);
  57754. if (!pointsMaterial) {
  57755. pointsMaterial = new PointsMaterial();
  57756. Material.prototype.copy.call(pointsMaterial, material);
  57757. pointsMaterial.color.copy(material.color);
  57758. pointsMaterial.map = material.map;
  57759. pointsMaterial.sizeAttenuation = false;
  57760. this.cache.add(cacheKey, pointsMaterial);
  57761. }
  57762. material = pointsMaterial;
  57763. } else if (mesh.isLine) {
  57764. var cacheKey = "LineBasicMaterial:" + material.uuid;
  57765. var lineMaterial = this.cache.get(cacheKey);
  57766. if (!lineMaterial) {
  57767. lineMaterial = new LineBasicMaterial();
  57768. Material.prototype.copy.call(lineMaterial, material);
  57769. lineMaterial.color.copy(material.color);
  57770. this.cache.add(cacheKey, lineMaterial);
  57771. }
  57772. material = lineMaterial;
  57773. }
  57774. if (useVertexTangents || useVertexColors || useFlatShading || useSkinning || useMorphTargets) {
  57775. var cacheKey = "ClonedMaterial:" + material.uuid + ":";
  57776. if (material.isGLTFSpecularGlossinessMaterial)
  57777. cacheKey += "specular-glossiness:";
  57778. if (useSkinning)
  57779. cacheKey += "skinning:";
  57780. if (useVertexTangents)
  57781. cacheKey += "vertex-tangents:";
  57782. if (useVertexColors)
  57783. cacheKey += "vertex-colors:";
  57784. if (useFlatShading)
  57785. cacheKey += "flat-shading:";
  57786. if (useMorphTargets)
  57787. cacheKey += "morph-targets:";
  57788. if (useMorphNormals)
  57789. cacheKey += "morph-normals:";
  57790. var cachedMaterial = this.cache.get(cacheKey);
  57791. if (!cachedMaterial) {
  57792. cachedMaterial = material.clone();
  57793. if (useSkinning)
  57794. cachedMaterial.skinning = true;
  57795. if (useVertexTangents)
  57796. cachedMaterial.vertexTangents = true;
  57797. if (useVertexColors)
  57798. cachedMaterial.vertexColors = VertexColors;
  57799. if (useFlatShading)
  57800. cachedMaterial.flatShading = true;
  57801. if (useMorphTargets)
  57802. cachedMaterial.morphTargets = true;
  57803. if (useMorphNormals)
  57804. cachedMaterial.morphNormals = true;
  57805. this.cache.add(cacheKey, cachedMaterial);
  57806. }
  57807. material = cachedMaterial;
  57808. }
  57809. if (material.aoMap && geometry.attributes.uv2 === void 0 && geometry.attributes.uv !== void 0) {
  57810. geometry.setAttribute("uv2", new BufferAttribute(geometry.attributes.uv.array, 2));
  57811. }
  57812. if (material.normalScale && !useVertexTangents) {
  57813. material.normalScale.y = -material.normalScale.y;
  57814. }
  57815. mesh.material = material;
  57816. };
  57817. GLTFParser.prototype.loadMaterial = function(materialIndex) {
  57818. var parser = this;
  57819. var json = this.json;
  57820. var extensions = this.extensions;
  57821. var materialDef = json.materials[materialIndex];
  57822. var materialType;
  57823. var materialParams = {};
  57824. var materialExtensions = materialDef.extensions || {};
  57825. var pending = [];
  57826. if (materialExtensions[EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]) {
  57827. var sgExtension = extensions[EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];
  57828. materialType = sgExtension.getMaterialType();
  57829. pending.push(sgExtension.extendParams(materialParams, materialDef, parser));
  57830. } else if (materialExtensions[EXTENSIONS.KHR_MATERIALS_UNLIT]) {
  57831. var kmuExtension = extensions[EXTENSIONS.KHR_MATERIALS_UNLIT];
  57832. materialType = kmuExtension.getMaterialType();
  57833. pending.push(kmuExtension.extendParams(materialParams, materialDef, parser));
  57834. } else {
  57835. materialType = MeshStandardMaterial;
  57836. var metallicRoughness = materialDef.pbrMetallicRoughness || {};
  57837. materialParams.color = new Color(1, 1, 1);
  57838. materialParams.opacity = 1;
  57839. if (Array.isArray(metallicRoughness.baseColorFactor)) {
  57840. var array = metallicRoughness.baseColorFactor;
  57841. materialParams.color.fromArray(array);
  57842. materialParams.opacity = array[3];
  57843. }
  57844. if (metallicRoughness.baseColorTexture !== void 0) {
  57845. pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture));
  57846. }
  57847. materialParams.metalness = metallicRoughness.metallicFactor !== void 0 ? metallicRoughness.metallicFactor : 1;
  57848. materialParams.roughness = metallicRoughness.roughnessFactor !== void 0 ? metallicRoughness.roughnessFactor : 1;
  57849. if (metallicRoughness.metallicRoughnessTexture !== void 0) {
  57850. pending.push(parser.assignTexture(materialParams, "metalnessMap", metallicRoughness.metallicRoughnessTexture));
  57851. pending.push(parser.assignTexture(materialParams, "roughnessMap", metallicRoughness.metallicRoughnessTexture));
  57852. }
  57853. }
  57854. if (materialDef.doubleSided === true) {
  57855. materialParams.side = DoubleSide;
  57856. }
  57857. var alphaMode = materialDef.alphaMode || ALPHA_MODES.OPAQUE;
  57858. if (alphaMode === ALPHA_MODES.BLEND) {
  57859. materialParams.transparent = true;
  57860. } else {
  57861. materialParams.transparent = false;
  57862. if (alphaMode === ALPHA_MODES.MASK) {
  57863. materialParams.alphaTest = materialDef.alphaCutoff !== void 0 ? materialDef.alphaCutoff : 0.5;
  57864. }
  57865. }
  57866. if (materialDef.normalTexture !== void 0 && materialType !== MeshBasicMaterial) {
  57867. pending.push(parser.assignTexture(materialParams, "normalMap", materialDef.normalTexture));
  57868. materialParams.normalScale = new Vector2(1, 1);
  57869. if (materialDef.normalTexture.scale !== void 0) {
  57870. materialParams.normalScale.set(materialDef.normalTexture.scale, materialDef.normalTexture.scale);
  57871. }
  57872. }
  57873. if (materialDef.occlusionTexture !== void 0 && materialType !== MeshBasicMaterial) {
  57874. pending.push(parser.assignTexture(materialParams, "aoMap", materialDef.occlusionTexture));
  57875. if (materialDef.occlusionTexture.strength !== void 0) {
  57876. materialParams.aoMapIntensity = materialDef.occlusionTexture.strength;
  57877. }
  57878. }
  57879. if (materialDef.emissiveFactor !== void 0 && materialType !== MeshBasicMaterial) {
  57880. materialParams.emissive = new Color().fromArray(materialDef.emissiveFactor);
  57881. }
  57882. if (materialDef.emissiveTexture !== void 0 && materialType !== MeshBasicMaterial) {
  57883. pending.push(parser.assignTexture(materialParams, "emissiveMap", materialDef.emissiveTexture));
  57884. }
  57885. return Promise.all(pending).then(function() {
  57886. var material;
  57887. if (materialType === GLTFMeshStandardSGMaterial) {
  57888. material = extensions[EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(materialParams);
  57889. } else {
  57890. material = new materialType(materialParams);
  57891. }
  57892. if (materialDef.name !== void 0)
  57893. material.name = materialDef.name;
  57894. if (material.map)
  57895. material.map.encoding = sRGBEncoding;
  57896. if (material.emissiveMap)
  57897. material.emissiveMap.encoding = sRGBEncoding;
  57898. assignExtrasToUserData(material, materialDef);
  57899. if (materialDef.extensions)
  57900. addUnknownExtensionsToUserData(extensions, material, materialDef);
  57901. return material;
  57902. });
  57903. };
  57904. function computeBounds(geometry, primitiveDef, parser) {
  57905. var attributes = primitiveDef.attributes;
  57906. var box = new Box3();
  57907. if (attributes.POSITION !== void 0) {
  57908. var accessor = parser.json.accessors[attributes.POSITION];
  57909. var min = accessor.min;
  57910. var max = accessor.max;
  57911. if (min !== void 0 && max !== void 0) {
  57912. box.set(
  57913. new Vector3(min[0], min[1], min[2]),
  57914. new Vector3(max[0], max[1], max[2])
  57915. );
  57916. } else {
  57917. console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
  57918. return;
  57919. }
  57920. } else {
  57921. return;
  57922. }
  57923. var targets = primitiveDef.targets;
  57924. if (targets !== void 0) {
  57925. var vector = new Vector3();
  57926. for (var i2 = 0, il = targets.length; i2 < il; i2++) {
  57927. var target = targets[i2];
  57928. if (target.POSITION !== void 0) {
  57929. var accessor = parser.json.accessors[target.POSITION];
  57930. var min = accessor.min;
  57931. var max = accessor.max;
  57932. if (min !== void 0 && max !== void 0) {
  57933. vector.setX(Math.max(Math.abs(min[0]), Math.abs(max[0])));
  57934. vector.setY(Math.max(Math.abs(min[1]), Math.abs(max[1])));
  57935. vector.setZ(Math.max(Math.abs(min[2]), Math.abs(max[2])));
  57936. box.expandByVector(vector);
  57937. } else {
  57938. console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
  57939. }
  57940. }
  57941. }
  57942. }
  57943. geometry.boundingBox = box;
  57944. var sphere = new Sphere();
  57945. box.getCenter(sphere.center);
  57946. sphere.radius = box.min.distanceTo(box.max) / 2;
  57947. geometry.boundingSphere = sphere;
  57948. }
  57949. function addPrimitiveAttributes(geometry, primitiveDef, parser) {
  57950. var attributes = primitiveDef.attributes;
  57951. var pending = [];
  57952. function assignAttributeAccessor(accessorIndex, attributeName) {
  57953. return parser.getDependency("accessor", accessorIndex).then(function(accessor2) {
  57954. geometry.setAttribute(attributeName, accessor2);
  57955. });
  57956. }
  57957. for (var gltfAttributeName in attributes) {
  57958. var threeAttributeName = ATTRIBUTES[gltfAttributeName] || gltfAttributeName.toLowerCase();
  57959. if (threeAttributeName in geometry.attributes)
  57960. continue;
  57961. pending.push(assignAttributeAccessor(attributes[gltfAttributeName], threeAttributeName));
  57962. }
  57963. if (primitiveDef.indices !== void 0 && !geometry.index) {
  57964. var accessor = parser.getDependency("accessor", primitiveDef.indices).then(function(accessor2) {
  57965. geometry.setIndex(accessor2);
  57966. });
  57967. pending.push(accessor);
  57968. }
  57969. assignExtrasToUserData(geometry, primitiveDef);
  57970. computeBounds(geometry, primitiveDef, parser);
  57971. return Promise.all(pending).then(function() {
  57972. return primitiveDef.targets !== void 0 ? addMorphTargets(geometry, primitiveDef.targets, parser) : geometry;
  57973. });
  57974. }
  57975. function toTrianglesDrawMode(geometry, drawMode) {
  57976. var index = geometry.getIndex();
  57977. if (index === null) {
  57978. var indices = [];
  57979. var position = geometry.getAttribute("position");
  57980. if (position !== void 0) {
  57981. for (var i2 = 0; i2 < position.count; i2++) {
  57982. indices.push(i2);
  57983. }
  57984. geometry.setIndex(indices);
  57985. index = geometry.getIndex();
  57986. } else {
  57987. console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.");
  57988. return geometry;
  57989. }
  57990. }
  57991. var numberOfTriangles = index.count - 2;
  57992. var newIndices = [];
  57993. if (drawMode === TriangleFanDrawMode) {
  57994. for (var i2 = 1; i2 <= numberOfTriangles; i2++) {
  57995. newIndices.push(index.getX(0));
  57996. newIndices.push(index.getX(i2));
  57997. newIndices.push(index.getX(i2 + 1));
  57998. }
  57999. } else {
  58000. for (var i2 = 0; i2 < numberOfTriangles; i2++) {
  58001. if (i2 % 2 === 0) {
  58002. newIndices.push(index.getX(i2));
  58003. newIndices.push(index.getX(i2 + 1));
  58004. newIndices.push(index.getX(i2 + 2));
  58005. } else {
  58006. newIndices.push(index.getX(i2 + 2));
  58007. newIndices.push(index.getX(i2 + 1));
  58008. newIndices.push(index.getX(i2));
  58009. }
  58010. }
  58011. }
  58012. if (newIndices.length / 3 !== numberOfTriangles) {
  58013. console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
  58014. }
  58015. var newGeometry = geometry.clone();
  58016. newGeometry.setIndex(newIndices);
  58017. return newGeometry;
  58018. }
  58019. GLTFParser.prototype.loadGeometries = function(primitives) {
  58020. var parser = this;
  58021. var extensions = this.extensions;
  58022. var cache = this.primitiveCache;
  58023. function createDracoPrimitive(primitive2) {
  58024. return extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(primitive2, parser).then(function(geometry) {
  58025. return addPrimitiveAttributes(geometry, primitive2, parser);
  58026. });
  58027. }
  58028. var pending = [];
  58029. for (var i2 = 0, il = primitives.length; i2 < il; i2++) {
  58030. var primitive = primitives[i2];
  58031. var cacheKey = createPrimitiveKey(primitive);
  58032. var cached = cache[cacheKey];
  58033. if (cached) {
  58034. pending.push(cached.promise);
  58035. } else {
  58036. var geometryPromise;
  58037. if (primitive.extensions && primitive.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]) {
  58038. geometryPromise = createDracoPrimitive(primitive);
  58039. } else {
  58040. geometryPromise = addPrimitiveAttributes(new BufferGeometry(), primitive, parser);
  58041. }
  58042. cache[cacheKey] = { primitive, promise: geometryPromise };
  58043. pending.push(geometryPromise);
  58044. }
  58045. }
  58046. return Promise.all(pending);
  58047. };
  58048. GLTFParser.prototype.loadMesh = function(meshIndex) {
  58049. var parser = this;
  58050. var json = this.json;
  58051. var meshDef = json.meshes[meshIndex];
  58052. var primitives = meshDef.primitives;
  58053. var pending = [];
  58054. for (var i2 = 0, il = primitives.length; i2 < il; i2++) {
  58055. var material = primitives[i2].material === void 0 ? createDefaultMaterial(this.cache) : this.getDependency("material", primitives[i2].material);
  58056. pending.push(material);
  58057. }
  58058. pending.push(parser.loadGeometries(primitives));
  58059. return Promise.all(pending).then(function(results) {
  58060. var materials = results.slice(0, results.length - 1);
  58061. var geometries = results[results.length - 1];
  58062. var meshes = [];
  58063. for (var i3 = 0, il2 = geometries.length; i3 < il2; i3++) {
  58064. var geometry = geometries[i3];
  58065. var primitive = primitives[i3];
  58066. var mesh;
  58067. var material2 = materials[i3];
  58068. if (primitive.mode === WEBGL_CONSTANTS.TRIANGLES || primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP || primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN || primitive.mode === void 0) {
  58069. mesh = meshDef.isSkinnedMesh === true ? new SkinnedMesh(geometry, material2) : new Mesh(geometry, material2);
  58070. if (mesh.isSkinnedMesh === true && !mesh.geometry.attributes.skinWeight.normalized) {
  58071. mesh.normalizeSkinWeights();
  58072. }
  58073. if (primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP) {
  58074. mesh.geometry = toTrianglesDrawMode(mesh.geometry, TriangleStripDrawMode);
  58075. } else if (primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN) {
  58076. mesh.geometry = toTrianglesDrawMode(mesh.geometry, TriangleFanDrawMode);
  58077. }
  58078. } else if (primitive.mode === WEBGL_CONSTANTS.LINES) {
  58079. mesh = new LineSegments(geometry, material2);
  58080. } else if (primitive.mode === WEBGL_CONSTANTS.LINE_STRIP) {
  58081. mesh = new Line(geometry, material2);
  58082. } else if (primitive.mode === WEBGL_CONSTANTS.LINE_LOOP) {
  58083. mesh = new LineLoop(geometry, material2);
  58084. } else if (primitive.mode === WEBGL_CONSTANTS.POINTS) {
  58085. mesh = new Points(geometry, material2);
  58086. } else {
  58087. throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + primitive.mode);
  58088. }
  58089. if (Object.keys(mesh.geometry.morphAttributes).length > 0) {
  58090. updateMorphTargets(mesh, meshDef);
  58091. }
  58092. mesh.name = meshDef.name || "mesh_" + meshIndex;
  58093. if (geometries.length > 1)
  58094. mesh.name += "_" + i3;
  58095. assignExtrasToUserData(mesh, meshDef);
  58096. parser.assignFinalMaterial(mesh);
  58097. meshes.push(mesh);
  58098. }
  58099. if (meshes.length === 1) {
  58100. return meshes[0];
  58101. }
  58102. var group = new Group();
  58103. for (var i3 = 0, il2 = meshes.length; i3 < il2; i3++) {
  58104. group.add(meshes[i3]);
  58105. }
  58106. return group;
  58107. });
  58108. };
  58109. GLTFParser.prototype.loadCamera = function(cameraIndex) {
  58110. var camera;
  58111. var cameraDef = this.json.cameras[cameraIndex];
  58112. var params = cameraDef[cameraDef.type];
  58113. if (!params) {
  58114. console.warn("THREE.GLTFLoader: Missing camera parameters.");
  58115. return;
  58116. }
  58117. if (cameraDef.type === "perspective") {
  58118. camera = new PerspectiveCamera(MathUtils.radToDeg(params.yfov), params.aspectRatio || 1, params.znear || 1, params.zfar || 2e6);
  58119. } else if (cameraDef.type === "orthographic") {
  58120. camera = new OrthographicCamera(params.xmag / -2, params.xmag / 2, params.ymag / 2, params.ymag / -2, params.znear, params.zfar);
  58121. }
  58122. if (cameraDef.name !== void 0)
  58123. camera.name = cameraDef.name;
  58124. assignExtrasToUserData(camera, cameraDef);
  58125. return Promise.resolve(camera);
  58126. };
  58127. GLTFParser.prototype.loadSkin = function(skinIndex) {
  58128. var skinDef = this.json.skins[skinIndex];
  58129. var skinEntry = { joints: skinDef.joints };
  58130. if (skinDef.inverseBindMatrices === void 0) {
  58131. return Promise.resolve(skinEntry);
  58132. }
  58133. return this.getDependency("accessor", skinDef.inverseBindMatrices).then(function(accessor) {
  58134. skinEntry.inverseBindMatrices = accessor;
  58135. return skinEntry;
  58136. });
  58137. };
  58138. GLTFParser.prototype.loadAnimation = function(animationIndex) {
  58139. var json = this.json;
  58140. var animationDef = json.animations[animationIndex];
  58141. var pendingNodes = [];
  58142. var pendingInputAccessors = [];
  58143. var pendingOutputAccessors = [];
  58144. var pendingSamplers = [];
  58145. var pendingTargets = [];
  58146. for (var i2 = 0, il = animationDef.channels.length; i2 < il; i2++) {
  58147. var channel = animationDef.channels[i2];
  58148. var sampler = animationDef.samplers[channel.sampler];
  58149. var target = channel.target;
  58150. var name = target.node !== void 0 ? target.node : target.id;
  58151. var input = animationDef.parameters !== void 0 ? animationDef.parameters[sampler.input] : sampler.input;
  58152. var output = animationDef.parameters !== void 0 ? animationDef.parameters[sampler.output] : sampler.output;
  58153. pendingNodes.push(this.getDependency("node", name));
  58154. pendingInputAccessors.push(this.getDependency("accessor", input));
  58155. pendingOutputAccessors.push(this.getDependency("accessor", output));
  58156. pendingSamplers.push(sampler);
  58157. pendingTargets.push(target);
  58158. }
  58159. return Promise.all([
  58160. Promise.all(pendingNodes),
  58161. Promise.all(pendingInputAccessors),
  58162. Promise.all(pendingOutputAccessors),
  58163. Promise.all(pendingSamplers),
  58164. Promise.all(pendingTargets)
  58165. ]).then(function(dependencies) {
  58166. var nodes = dependencies[0];
  58167. var inputAccessors = dependencies[1];
  58168. var outputAccessors = dependencies[2];
  58169. var samplers = dependencies[3];
  58170. var targets = dependencies[4];
  58171. var tracks = [];
  58172. for (var i3 = 0, il2 = nodes.length; i3 < il2; i3++) {
  58173. var node = nodes[i3];
  58174. var inputAccessor = inputAccessors[i3];
  58175. var outputAccessor = outputAccessors[i3];
  58176. var sampler2 = samplers[i3];
  58177. var target2 = targets[i3];
  58178. if (node === void 0)
  58179. continue;
  58180. node.updateMatrix();
  58181. node.matrixAutoUpdate = true;
  58182. var TypedKeyframeTrack;
  58183. switch (PATH_PROPERTIES[target2.path]) {
  58184. case PATH_PROPERTIES.weights:
  58185. TypedKeyframeTrack = NumberKeyframeTrack;
  58186. break;
  58187. case PATH_PROPERTIES.rotation:
  58188. TypedKeyframeTrack = QuaternionKeyframeTrack;
  58189. break;
  58190. case PATH_PROPERTIES.position:
  58191. case PATH_PROPERTIES.scale:
  58192. default:
  58193. TypedKeyframeTrack = VectorKeyframeTrack;
  58194. break;
  58195. }
  58196. var targetName = node.name ? node.name : node.uuid;
  58197. var interpolation = sampler2.interpolation !== void 0 ? INTERPOLATION[sampler2.interpolation] : InterpolateLinear;
  58198. var targetNames = [];
  58199. if (PATH_PROPERTIES[target2.path] === PATH_PROPERTIES.weights) {
  58200. node.traverse(function(object) {
  58201. if (object.isMesh === true && object.morphTargetInfluences) {
  58202. targetNames.push(object.name ? object.name : object.uuid);
  58203. }
  58204. });
  58205. } else {
  58206. targetNames.push(targetName);
  58207. }
  58208. var outputArray = outputAccessor.array;
  58209. if (outputAccessor.normalized) {
  58210. var scale;
  58211. if (outputArray.constructor === Int8Array) {
  58212. scale = 1 / 127;
  58213. } else if (outputArray.constructor === Uint8Array) {
  58214. scale = 1 / 255;
  58215. } else if (outputArray.constructor == Int16Array) {
  58216. scale = 1 / 32767;
  58217. } else if (outputArray.constructor === Uint16Array) {
  58218. scale = 1 / 65535;
  58219. } else {
  58220. throw new Error("THREE.GLTFLoader: Unsupported output accessor component type.");
  58221. }
  58222. var scaled = new Float32Array(outputArray.length);
  58223. for (var j = 0, jl = outputArray.length; j < jl; j++) {
  58224. scaled[j] = outputArray[j] * scale;
  58225. }
  58226. outputArray = scaled;
  58227. }
  58228. for (var j = 0, jl = targetNames.length; j < jl; j++) {
  58229. var track = new TypedKeyframeTrack(
  58230. targetNames[j] + "." + PATH_PROPERTIES[target2.path],
  58231. inputAccessor.array,
  58232. outputArray,
  58233. interpolation
  58234. );
  58235. if (sampler2.interpolation === "CUBICSPLINE") {
  58236. track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline(result) {
  58237. return new GLTFCubicSplineInterpolant(this.times, this.values, this.getValueSize() / 3, result);
  58238. };
  58239. track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true;
  58240. }
  58241. tracks.push(track);
  58242. }
  58243. }
  58244. var name2 = animationDef.name !== void 0 ? animationDef.name : "animation_" + animationIndex;
  58245. return new AnimationClip(name2, void 0, tracks);
  58246. });
  58247. };
  58248. GLTFParser.prototype.loadNode = function(nodeIndex) {
  58249. var json = this.json;
  58250. var extensions = this.extensions;
  58251. var parser = this;
  58252. var meshReferences = json.meshReferences;
  58253. var meshUses = json.meshUses;
  58254. var nodeDef = json.nodes[nodeIndex];
  58255. return function() {
  58256. var pending = [];
  58257. if (nodeDef.mesh !== void 0) {
  58258. pending.push(parser.getDependency("mesh", nodeDef.mesh).then(function(mesh) {
  58259. var node;
  58260. if (meshReferences[nodeDef.mesh] > 1) {
  58261. var instanceNum = meshUses[nodeDef.mesh]++;
  58262. node = mesh.clone();
  58263. node.name += "_instance_" + instanceNum;
  58264. } else {
  58265. node = mesh;
  58266. }
  58267. if (nodeDef.weights !== void 0) {
  58268. node.traverse(function(o) {
  58269. if (!o.isMesh)
  58270. return;
  58271. for (var i2 = 0, il = nodeDef.weights.length; i2 < il; i2++) {
  58272. o.morphTargetInfluences[i2] = nodeDef.weights[i2];
  58273. }
  58274. });
  58275. }
  58276. return node;
  58277. }));
  58278. }
  58279. if (nodeDef.camera !== void 0) {
  58280. pending.push(parser.getDependency("camera", nodeDef.camera));
  58281. }
  58282. if (nodeDef.extensions && nodeDef.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL] && nodeDef.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL].light !== void 0) {
  58283. pending.push(parser.getDependency("light", nodeDef.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL].light));
  58284. }
  58285. return Promise.all(pending);
  58286. }().then(function(objects) {
  58287. var node;
  58288. if (nodeDef.isBone === true) {
  58289. node = new Bone();
  58290. } else if (objects.length > 1) {
  58291. node = new Group();
  58292. } else if (objects.length === 1) {
  58293. node = objects[0];
  58294. } else {
  58295. node = new Object3D();
  58296. }
  58297. if (node !== objects[0]) {
  58298. for (var i2 = 0, il = objects.length; i2 < il; i2++) {
  58299. node.add(objects[i2]);
  58300. }
  58301. }
  58302. if (nodeDef.name !== void 0) {
  58303. node.userData.name = nodeDef.name;
  58304. node.name = PropertyBinding.sanitizeNodeName(nodeDef.name);
  58305. }
  58306. assignExtrasToUserData(node, nodeDef);
  58307. if (nodeDef.extensions)
  58308. addUnknownExtensionsToUserData(extensions, node, nodeDef);
  58309. if (nodeDef.matrix !== void 0) {
  58310. var matrix = new Matrix4();
  58311. matrix.fromArray(nodeDef.matrix);
  58312. node.applyMatrix4(matrix);
  58313. } else {
  58314. if (nodeDef.translation !== void 0) {
  58315. node.position.fromArray(nodeDef.translation);
  58316. }
  58317. if (nodeDef.rotation !== void 0) {
  58318. node.quaternion.fromArray(nodeDef.rotation);
  58319. }
  58320. if (nodeDef.scale !== void 0) {
  58321. node.scale.fromArray(nodeDef.scale);
  58322. }
  58323. }
  58324. return node;
  58325. });
  58326. };
  58327. GLTFParser.prototype.loadScene = function() {
  58328. function buildNodeHierachy(nodeId, parentObject, json, parser) {
  58329. var nodeDef = json.nodes[nodeId];
  58330. return parser.getDependency("node", nodeId).then(function(node) {
  58331. if (nodeDef.skin === void 0)
  58332. return node;
  58333. var skinEntry;
  58334. return parser.getDependency("skin", nodeDef.skin).then(function(skin) {
  58335. skinEntry = skin;
  58336. var pendingJoints = [];
  58337. for (var i2 = 0, il = skinEntry.joints.length; i2 < il; i2++) {
  58338. pendingJoints.push(parser.getDependency("node", skinEntry.joints[i2]));
  58339. }
  58340. return Promise.all(pendingJoints);
  58341. }).then(function(jointNodes) {
  58342. node.traverse(function(mesh) {
  58343. if (!mesh.isMesh)
  58344. return;
  58345. var bones = [];
  58346. var boneInverses = [];
  58347. for (var j = 0, jl = jointNodes.length; j < jl; j++) {
  58348. var jointNode = jointNodes[j];
  58349. if (jointNode) {
  58350. bones.push(jointNode);
  58351. var mat = new Matrix4();
  58352. if (skinEntry.inverseBindMatrices !== void 0) {
  58353. mat.fromArray(skinEntry.inverseBindMatrices.array, j * 16);
  58354. }
  58355. boneInverses.push(mat);
  58356. } else {
  58357. console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', skinEntry.joints[j]);
  58358. }
  58359. }
  58360. mesh.bind(new Skeleton(bones, boneInverses), mesh.matrixWorld);
  58361. });
  58362. return node;
  58363. });
  58364. }).then(function(node) {
  58365. parentObject.add(node);
  58366. var pending = [];
  58367. if (nodeDef.children) {
  58368. var children = nodeDef.children;
  58369. for (var i2 = 0, il = children.length; i2 < il; i2++) {
  58370. var child = children[i2];
  58371. pending.push(buildNodeHierachy(child, node, json, parser));
  58372. }
  58373. }
  58374. return Promise.all(pending);
  58375. });
  58376. }
  58377. return function loadScene(sceneIndex) {
  58378. var json = this.json;
  58379. var extensions = this.extensions;
  58380. var sceneDef = this.json.scenes[sceneIndex];
  58381. var parser = this;
  58382. var scene = new Scene();
  58383. if (sceneDef.name !== void 0)
  58384. scene.name = sceneDef.name;
  58385. assignExtrasToUserData(scene, sceneDef);
  58386. if (sceneDef.extensions)
  58387. addUnknownExtensionsToUserData(extensions, scene, sceneDef);
  58388. var nodeIds = sceneDef.nodes || [];
  58389. var pending = [];
  58390. for (var i2 = 0, il = nodeIds.length; i2 < il; i2++) {
  58391. pending.push(buildNodeHierachy(nodeIds[i2], scene, json, parser));
  58392. }
  58393. return Promise.all(pending).then(function() {
  58394. return scene;
  58395. });
  58396. };
  58397. }();
  58398. return GLTFLoader2;
  58399. }();
  58400. function mxtest_add_3d_model(mxdraw2) {
  58401. const loader = new GLTFLoader();
  58402. loader.load(
  58403. "./gis/34M_17.gltf",
  58404. (gltf) => {
  58405. gltf.scene.position.set(116577.28779765591, 19632.646909285337, 0);
  58406. gltf.scene.rotateX(Math.PI / 2);
  58407. gltf.scene.scale.set(2, 2, 2);
  58408. mxdraw2.addObject(gltf.scene);
  58409. }
  58410. );
  58411. }
  58412. {
  58413. const ws = new WebSocket("ws://localhost:24678");
  58414. ws.addEventListener("message", (event) => {
  58415. const info = JSON.parse(event.data);
  58416. if (info.type === "full-reload")
  58417. location.reload();
  58418. });
  58419. }
  58420. class MxCADPlugin extends mxcad2.MxCADPluginBase {
  58421. constructor() {
  58422. super();
  58423. this.map_default_data = getMapDefaultData();
  58424. }
  58425. }
  58426. let mxcadui;
  58427. const { showModal, hideModal } = useModalVisible();
  58428. function My_PluginTest() {
  58429. return __async(this, null, function* () {
  58430. showModal({
  58431. title: "My Test Draw",
  58432. text: "测试Modal",
  58433. oncancel: () => {
  58434. hideModal();
  58435. },
  58436. onsubmit: () => {
  58437. hideModal();
  58438. },
  58439. ongetallentity: () => {
  58440. hideModal();
  58441. mxdraw.MxFun.sendStringToExecute("TestGetAllEntity");
  58442. },
  58443. ondrawline: () => {
  58444. hideModal();
  58445. mxdraw.MxFun.sendStringToExecute("Mx_Circle");
  58446. },
  58447. docommand: (cmd) => {
  58448. hideModal();
  58449. mxdraw.MxFun.sendStringToExecute(cmd);
  58450. }
  58451. });
  58452. });
  58453. }
  58454. const div = document.createElement("div");
  58455. document.body.appendChild(div);
  58456. const app = vue.createApp(_sfc_main);
  58457. app.mount(div);
  58458. init$p();
  58459. mxdraw.MxFun.on("mxcadApplicationStart", (mxcaduiimp) => {
  58460. mxcadui = mxcaduiimp;
  58461. mxcadui.init(new MxCADPlugin());
  58462. });
  58463. mxdraw.MxFun.on("mxcadApplicationInitMap", () => {
  58464. init$1(mxcadui.mxmap);
  58465. });
  58466. mxdraw.MxFun.on("mxcadApplicationCreatedMxCADObject", (param) => {
  58467. let mxcad$1 = param.mxcad;
  58468. mxcad$1.on("selectChange", (ids) => {
  58469. if (ids.length == 0)
  58470. return;
  58471. let id = ids[0];
  58472. let mxent = id.getMxDbEntity();
  58473. if (mxent !== null) {
  58474. console.log(mxent.getTypeName());
  58475. if (mxent instanceof mxdraw.MxDbRectBoxLeadComment) {
  58476. let comment = mxent;
  58477. console.log(comment.text);
  58478. }
  58479. return;
  58480. }
  58481. let ent = id.getMcDbEntity();
  58482. if (ent !== null) {
  58483. console.log(ent.objectName);
  58484. if (ent instanceof mxcad2.McDbText) {
  58485. let text = ent;
  58486. console.log(text.textString);
  58487. } else if (ent instanceof mxcad2.McDbBlockReference) {
  58488. let blkRef = ent;
  58489. let aryId = blkRef.getAllAttribute();
  58490. aryId.forEach((id2) => {
  58491. let attribt = id2.getMcDbEntity();
  58492. console.log(attribt.textString);
  58493. console.log(attribt.tag);
  58494. });
  58495. }
  58496. }
  58497. });
  58498. mxcad2.MxCpp.PropertiesWindow.onEvent_getProperties((id) => {
  58499. let ent = id.getMcDbEntity();
  58500. if (!ent)
  58501. return [];
  58502. let dn = ent.getxDataDouble("DN");
  58503. let len = ent.getxDataDouble("LEN");
  58504. let ret = [];
  58505. if (dn.ret) {
  58506. ret.push({
  58507. sVarName: "DN",
  58508. iVarType: mxcad2.MxPropertiesWindowCustomValueType.kDouble,
  58509. val: dn.val,
  58510. isOnlyRead: false
  58511. });
  58512. }
  58513. if (len.ret) {
  58514. ret.push({
  58515. sVarName: "LEN",
  58516. iVarType: mxcad2.MxPropertiesWindowCustomValueType.kDouble,
  58517. val: len.val,
  58518. isOnlyRead: false
  58519. });
  58520. }
  58521. return ret;
  58522. });
  58523. mxcad2.MxCpp.PropertiesWindow.onEvent_setProperties((id, prop) => {
  58524. let ent = id.getMcDbEntity();
  58525. if (!ent)
  58526. return;
  58527. if (prop.sVarName == "DN") {
  58528. ent.setxDataDouble("DN", prop.val);
  58529. } else if (prop.sVarName == "LEN") {
  58530. ent.setxDataDouble("LEN", prop.val);
  58531. }
  58532. });
  58533. });
  58534. function getMxCADUi() {
  58535. return mxcadui;
  58536. }
  58537. function McGePoint3dToString(pt) {
  58538. return "x=" + pt.x + ",y=" + pt.y + ",z=" + pt.z;
  58539. }
  58540. function Mx_Open_DemoCode() {
  58541. window.open("https://demo.mxdraw3d.com:3562/MxCADCode.7z");
  58542. }
  58543. function Mx_Open_DevInstall() {
  58544. window.open(
  58545. "https://demo.mxdraw3d.com:3562/MxDrawCloudServer1.0TryVersion.7z"
  58546. );
  58547. }
  58548. function getMapUrl(type) {
  58549. var url = window.location.href;
  58550. if (url.indexOf("?") != -1) {
  58551. url = url.replace(/(\?|#)[^'"]*/, "");
  58552. }
  58553. return `${url}?map=true&maptype=${type}`;
  58554. }
  58555. function Mx_Open_Map_gdslwzj() {
  58556. window.open(getMapUrl("gdslwzj"));
  58557. }
  58558. function Mx_Open_Map_googlecn() {
  58559. window.open(getMapUrl("google"));
  58560. }
  58561. function Mx_Open_Map_gdyx() {
  58562. window.open(getMapUrl("gdyx"));
  58563. }
  58564. function Mx_Open_Map_tdtsl() {
  58565. window.open(getMapUrl("tdtsl"));
  58566. }
  58567. function Mx_Open_Map_bdsl() {
  58568. window.open(getMapUrl("bdsl"));
  58569. }
  58570. function Mx_Open_Map_geoq() {
  58571. window.open(getMapUrl("geoq"));
  58572. }
  58573. function Mx_ViewBackgroundColor() {
  58574. mxcad2.MxCpp.getCurrentMxCAD().setViewBackgroundColor(255, 255, 255);
  58575. mxdraw.MxFun.callEvent("updateBackgroundColor", new mxcad2.McCmColor(255, 255, 255));
  58576. }
  58577. function Mx_TestExProp() {
  58578. return __async(this, null, function* () {
  58579. let selEntity1 = new mxcad2.MxCADUiPrEntity();
  58580. selEntity1.setMessage("选择要需要开启自定义属性的对象");
  58581. let idText = yield selEntity1.go();
  58582. if (!idText.isValid())
  58583. return;
  58584. let ent = idText.getMcDbEntity();
  58585. mxcad2.MxCpp.PropertiesWindow.setEntitySupportCustom(idText);
  58586. ent.setxDataDouble("DN", 100);
  58587. ent.setxDataDouble("LEN", 2e3);
  58588. });
  58589. }
  58590. function Mx_Test_OpenFile() {
  58591. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  58592. mxcad$1.openWebFile(
  58593. "http://localhost:1337/mxcad/file/a9cbed3d3a351b79f24484e87bd78338.DWG.mxweb"
  58594. );
  58595. }
  58596. function Mx_Test_GetFile() {
  58597. return __async(this, null, function* () {
  58598. });
  58599. }
  58600. function Mx_SelectEntitHideLayer() {
  58601. return __async(this, null, function* () {
  58602. let selEntity1 = new mxcad2.MxCADUiPrEntity();
  58603. selEntity1.setMessage("选择要隐藏的对象");
  58604. let id = yield selEntity1.go();
  58605. if (!id.isValid())
  58606. return;
  58607. let ent = id.getMcDbEntity();
  58608. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  58609. let layerTable = mxcad$1.getDatabase().getLayerTable();
  58610. let layerId = layerTable.get(ent.layer);
  58611. let layerRec = layerId.getMcDbLayerTableRecord();
  58612. if (layerRec === null)
  58613. return;
  58614. layerRec.isOff = true;
  58615. mxcad$1.updateLayerDisplayStatus();
  58616. mxcad$1.updateDisplay();
  58617. });
  58618. }
  58619. function getCurrentPagePath() {
  58620. return window.location.origin + window.location.pathname;
  58621. }
  58622. function Mx_Test_DrawImage() {
  58623. return __async(this, null, function* () {
  58624. const getPoint = new mxcad2.MxCADUiPrPoint();
  58625. getPoint.setMessage("\n指定插入点:");
  58626. let pt = yield getPoint.go();
  58627. if (!pt)
  58628. return;
  58629. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  58630. let imagUrl = getCurrentPagePath() + "mxcad.jpg";
  58631. mxcad$1.loadImage(imagUrl, (image) => {
  58632. if (!image) {
  58633. console.log("loadImage failed");
  58634. return;
  58635. }
  58636. let width = mxcad$1.mxdraw.viewCoordLong2Cad(100);
  58637. let height = image.height / image.width * width;
  58638. mxcad$1.drawImage(pt.x, pt.y, width, height, 0, imagUrl);
  58639. mxcad$1.updateDisplay();
  58640. });
  58641. });
  58642. }
  58643. function MxTest_TestAddCurrentSelect() {
  58644. return __async(this, null, function* () {
  58645. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  58646. let getPoint = new mxcad2.MxCADUiPrPoint();
  58647. let pt1 = yield getPoint.go();
  58648. if (pt1 == null)
  58649. return;
  58650. getPoint.setBasePt(pt1);
  58651. let pt2 = yield getPoint.go();
  58652. if (pt2 == null)
  58653. return;
  58654. let id = mxcad$1.drawLine(pt1.x, pt1.y, pt2.x, pt2.y);
  58655. mxcad$1.addCurrentSelect(id);
  58656. });
  58657. }
  58658. let lAng = 0;
  58659. function MxTest_TestSetViewAngle() {
  58660. return __async(this, null, function* () {
  58661. lAng += Math.PI * 0.5;
  58662. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  58663. mxcad$1.zoomAngle(lAng);
  58664. });
  58665. }
  58666. function MxText_ZoomCenter() {
  58667. let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
  58668. mxcad$1.zoomCenter(900, 900);
  58669. }
  58670. mxdraw.MxFun.on("mxcadApplicationStartCreatingMxCADObject", (param) => {
  58671. let mxdraw2 = param.mxdraw;
  58672. mxdraw2.setViewMovementMethod(true);
  58673. mxdraw2.on("openFileComplete", () => {
  58674. console.log("MxTip:openFileComplete ");
  58675. });
  58676. mxdraw2.addControlsEvent("mousedown", (event) => {
  58677. let x = event.offsetX;
  58678. let y = event.offsetY;
  58679. let pt = mxdraw2.viewCoord2Cad(x, y, 0);
  58680. console.log("mousedown:", pt);
  58681. return 0;
  58682. });
  58683. });
  58684. mxdraw.MxFun.on("mxcadApplicationCreatedMxCADObject", (param) => {
  58685. let mxcad$1 = param.mxcad;
  58686. mxcad$1.on("selectChange", (ids) => {
  58687. if (ids.length == 0)
  58688. return;
  58689. let id = ids[0];
  58690. let mxent = id.getMxDbEntity();
  58691. if (mxent !== null) {
  58692. console.log(mxent.getTypeName());
  58693. if (mxent instanceof mxdraw.MxDbRectBoxLeadComment) {
  58694. let comment = mxent;
  58695. console.log(comment.text);
  58696. }
  58697. return;
  58698. }
  58699. let ent = id.getMcDbEntity();
  58700. if (ent !== null) {
  58701. console.log(ent.objectName);
  58702. if (ent instanceof mxcad2.McDbText) {
  58703. let text = ent;
  58704. console.log(text.textString);
  58705. } else if (ent instanceof mxcad2.McDbBlockReference) {
  58706. let blkRef = ent;
  58707. let aryId = blkRef.getAllAttribute();
  58708. aryId.forEach((id2) => {
  58709. let attribt = id2.getMcDbEntity();
  58710. console.log(attribt.textString);
  58711. console.log(attribt.tag);
  58712. });
  58713. }
  58714. }
  58715. });
  58716. mxcad2.MxCpp.PropertiesWindow.onEvent_getProperties((id) => {
  58717. let ent = id.getMcDbEntity();
  58718. if (!ent)
  58719. return [];
  58720. let dn = ent.getxDataDouble("DN");
  58721. let len = ent.getxDataDouble("LEN");
  58722. let ret = [];
  58723. if (dn.ret) {
  58724. ret.push({
  58725. sVarName: "DN",
  58726. iVarType: mxcad2.MxPropertiesWindowCustomValueType.kDouble,
  58727. val: dn.val,
  58728. isOnlyRead: false
  58729. });
  58730. }
  58731. if (len.ret) {
  58732. ret.push({
  58733. sVarName: "LEN",
  58734. iVarType: mxcad2.MxPropertiesWindowCustomValueType.kDouble,
  58735. val: len.val,
  58736. isOnlyRead: false
  58737. });
  58738. }
  58739. return ret;
  58740. });
  58741. mxcad2.MxCpp.PropertiesWindow.onEvent_setProperties((id, prop) => {
  58742. let ent = id.getMcDbEntity();
  58743. if (!ent)
  58744. return;
  58745. if (prop.sVarName == "DN") {
  58746. ent.setxDataDouble("DN", prop.val);
  58747. } else if (prop.sVarName == "LEN") {
  58748. ent.setxDataDouble("LEN", prop.val);
  58749. }
  58750. });
  58751. init();
  58752. });
  58753. function init() {
  58754. mxdraw.MxFun.addCommand("My_PluginTest", My_PluginTest);
  58755. mxdraw.MxFun.addCommand("Mx_Open_DemoCode", Mx_Open_DemoCode);
  58756. mxdraw.MxFun.addCommand("Mx_Open_DevInstall", Mx_Open_DevInstall);
  58757. mxdraw.MxFun.addCommand("Mx_Open_Map_gdslwzj", Mx_Open_Map_gdslwzj);
  58758. mxdraw.MxFun.addCommand("Mx_Open_Map_gdyx", Mx_Open_Map_gdyx);
  58759. mxdraw.MxFun.addCommand("Mx_Open_Map_tdtsl", Mx_Open_Map_tdtsl);
  58760. mxdraw.MxFun.addCommand("Mx_Open_Map_bdsl", Mx_Open_Map_bdsl);
  58761. mxdraw.MxFun.addCommand("Mx_Open_Map_geoq", Mx_Open_Map_geoq);
  58762. mxdraw.MxFun.addCommand("Mx_Open_Map_googlecn", Mx_Open_Map_googlecn);
  58763. mxdraw.MxFun.addCommand("Mx_ViewBackgroundColor", Mx_ViewBackgroundColor);
  58764. mxdraw.MxFun.addCommand("Mx_TestExProp", Mx_TestExProp);
  58765. mxdraw.MxFun.addCommand("Mx_Test_OpenFile", Mx_Test_OpenFile);
  58766. mxdraw.MxFun.addCommand("Mx_Test_GetFile", Mx_Test_GetFile);
  58767. mxdraw.MxFun.addCommand("Mx_TestExProp", Mx_TestExProp);
  58768. mxdraw.MxFun.addCommand("Mx_SelectEntitHideLayer", Mx_SelectEntitHideLayer);
  58769. mxdraw.MxFun.addCommand("MxTest_TestAddCurrentSelect", MxTest_TestAddCurrentSelect);
  58770. mxdraw.MxFun.addCommand("MxTest_TestSetViewAngle", MxTest_TestSetViewAngle);
  58771. mxdraw.MxFun.addCommand("MxText_ZoomCenter", MxText_ZoomCenter);
  58772. mxdraw.MxFun.addCommand("MxTest_Map_Download", MxTest_Map_Download);
  58773. mxdraw.MxFun.addCommand("Mx_Test_DrawImage", Mx_Test_DrawImage);
  58774. init$o();
  58775. init$n();
  58776. init$m();
  58777. init$l();
  58778. init$k();
  58779. init$j();
  58780. init$i();
  58781. init$g();
  58782. init$f();
  58783. init$5();
  58784. init$3();
  58785. init$h();
  58786. init$2();
  58787. if (mxcadui.mxmap) {
  58788. mxtest_add_3d_model(mxdraw.MxFun.getCurrentDraw());
  58789. }
  58790. }
  58791. exports.McGePoint3dToString = McGePoint3dToString;
  58792. exports.MxTest_TestAddCurrentSelect = MxTest_TestAddCurrentSelect;
  58793. exports.MxTest_TestSetViewAngle = MxTest_TestSetViewAngle;
  58794. exports.MxText_ZoomCenter = MxText_ZoomCenter;
  58795. exports.getMxCADUi = getMxCADUi;
  58796. Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
  58797. return exports;
  58798. }({}, Mx, mxcad, Vue, axios);
  58799. //# sourceMappingURL=test.js.map