| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812 |
- var test = function(exports, mxdraw, mxcad2, vue, axios2) {
- var __vite_style__ = document.createElement("style");
- __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}";
- document.head.appendChild(__vite_style__);
- "use strict";var __pow = Math.pow;
- var __async = (__this, __arguments, generator) => {
- return new Promise((resolve, reject) => {
- var fulfilled = (value) => {
- try {
- step(generator.next(value));
- } catch (e) {
- reject(e);
- }
- };
- var rejected = (value) => {
- try {
- step(generator.throw(value));
- } catch (e) {
- reject(e);
- }
- };
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
- step((generator = generator.apply(__this, __arguments)).next());
- });
- };
- const isModalVisible = vue.ref(false);
- const showModal$1 = (options) => {
- isModalVisible.value = true;
- modalOptions.value = Object.assign(modalOptions.value, options || {});
- };
- const hideModal$1 = () => {
- isModalVisible.value = false;
- };
- const modalOpts = {
- title: "Modal",
- text: "",
- oncancel: hideModal$1,
- onsubmit: hideModal$1,
- ongetallentity: hideModal$1,
- ondrawline: hideModal$1,
- docommand: (cmd) => {
- }
- };
- const modalOptions = vue.ref(modalOpts);
- const useModalVisible = () => {
- return {
- isModalVisible,
- showModal: showModal$1,
- hideModal: hideModal$1,
- modalOptions
- };
- };
- const _withScopeId = (n) => (vue.pushScopeId("data-v-9bd7093d"), n = n(), vue.popScopeId(), n);
- const _hoisted_1 = {
- key: 0,
- class: "modal-wrapper",
- id: "modal"
- };
- const _hoisted_2 = { class: "modal-body card" };
- const _hoisted_3 = { class: "modal-header" };
- const _hoisted_4 = { class: "heading" };
- const _hoisted_5 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ vue.createElementVNode("svg", { viewBox: "0 0 24 24" }, [
- /* @__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" })
- ], -1));
- const _hoisted_6 = [
- _hoisted_5
- ];
- const _hoisted_7 = { style: { "overflow-y": "auto", "height": "500px" } };
- const _hoisted_8 = { class: "btn_box" };
- const _hoisted_9 = { class: "btn_box" };
- const _hoisted_10 = { class: "btn_box" };
- const _hoisted_11 = { class: "btn_box" };
- const _hoisted_12 = { class: "btn_box" };
- const _hoisted_13 = { class: "btn_box" };
- const _hoisted_14 = { class: "btn_box" };
- const _hoisted_15 = { class: "btn_box" };
- const _hoisted_16 = { class: "btn_box" };
- const _hoisted_17 = { class: "btn_box" };
- const _hoisted_18 = { class: "btn_box" };
- const _hoisted_19 = { class: "btn_box" };
- const _hoisted_20 = { class: "btn_box" };
- const _hoisted_21 = { class: "btn_box" };
- const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
- __name: "Modal",
- setup(__props) {
- const { isModalVisible: isModalVisible2, hideModal: hideModal2, modalOptions: modalOptions2 } = useModalVisible();
- hideModal2();
- return (_ctx, _cache) => {
- return vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
- vue.createTextVNode(" 2356788909-80976564578697809-090897867 "),
- vue.unref(isModalVisible2) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
- vue.createElementVNode("div", _hoisted_2, [
- vue.createElementVNode("div", _hoisted_3, [
- vue.createElementVNode("h2", _hoisted_4, vue.toDisplayString(vue.unref(modalOptions2).title), 1),
- vue.createElementVNode("a", {
- href: "#!",
- onClick: _cache[0] || (_cache[0] = //@ts-ignore
- (...args) => vue.unref(hideModal2) && vue.unref(hideModal2)(...args)),
- role: "button",
- class: "close",
- "aria-label": "close this modal"
- }, _hoisted_6)
- ]),
- vue.createElementVNode("div", _hoisted_7, [
- vue.createElementVNode("div", _hoisted_8, [
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[1] || (_cache[1] = ($event) => vue.unref(modalOptions2).docommand("Mx_Open_DemoCode"))
- }, " 下载开Demo代码 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[2] || (_cache[2] = ($event) => vue.unref(modalOptions2).docommand("Mx_Open_DevInstall"))
- }, " 下载开发包 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[3] || (_cache[3] = //@ts-ignore
- (...args) => vue.unref(modalOptions2).ondrawline && vue.unref(modalOptions2).ondrawline(...args))
- }, " 调用画圆线命令 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[4] || (_cache[4] = ($event) => vue.unref(modalOptions2).docommand("MxTest_DrawLine"))
- }, " 交互画直线 ")
- ]),
- vue.createElementVNode("div", _hoisted_9, [
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[5] || (_cache[5] = ($event) => vue.unref(modalOptions2).docommand("MxTest_AddLayer"))
- }, " 添加图层 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[6] || (_cache[6] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetAllLayer"))
- }, " 得到所有图层 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[7] || (_cache[7] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetAllTextStyle"))
- }, " 得到所有文字样式 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[8] || (_cache[8] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetAllBlock"))
- }, " 得到所有图块 ")
- ]),
- vue.createElementVNode("div", _hoisted_10, [
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[9] || (_cache[9] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetAllLinetype"))
- }, " 得到所有线型 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[10] || (_cache[10] = ($event) => vue.unref(modalOptions2).docommand("MxTest_WritexData"))
- }, " 写扩展数据 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[11] || (_cache[11] = ($event) => vue.unref(modalOptions2).docommand("MxTest_ReadxData"))
- }, " 读扩展数据 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[12] || (_cache[12] = ($event) => vue.unref(modalOptions2).docommand("MxTest_InsertBlock"))
- }, " 测试插入一个图块 ")
- ]),
- vue.createElementVNode("div", _hoisted_11, [
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[13] || (_cache[13] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawLine"))
- }, " 绘直线 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[14] || (_cache[14] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawArc"))
- }, " 绘圆弧 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[15] || (_cache[15] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawCircle"))
- }, " 绘圆 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[16] || (_cache[16] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawPolyline"))
- }, " 绘PL线 ")
- ]),
- vue.createElementVNode("div", _hoisted_12, [
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[17] || (_cache[17] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawHatch"))
- }, " 绘填充 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[18] || (_cache[18] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawText"))
- }, " 绘文字 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[19] || (_cache[19] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_Ellipse"))
- }, " 绘椭圆 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[20] || (_cache[20] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_EllipseArc"))
- }, " 绘椭圆弧 ")
- ]),
- vue.createElementVNode("div", _hoisted_13, [
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[21] || (_cache[21] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_MText"))
- }, " 绘制多行文字 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[22] || (_cache[22] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawTable"))
- }, " 绘制表格 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[23] || (_cache[23] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_QRCode"))
- }, " 绘制二维码 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[24] || (_cache[24] = ($event) => vue.unref(modalOptions2).docommand("MxTest_InsertStamp"))
- }, " 插入图章 ")
- ]),
- vue.createElementVNode("div", _hoisted_14, [
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[25] || (_cache[25] = //@ts-ignore
- (...args) => vue.unref(modalOptions2).ongetallentity && vue.unref(modalOptions2).ongetallentity(...args))
- }, " 得到所有对象 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[26] || (_cache[26] = ($event) => vue.unref(modalOptions2).docommand("MxTest_SelectEntity"))
- }, " 交互选择对象 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[27] || (_cache[27] = ($event) => vue.unref(modalOptions2).docommand("Mx_Export_MxWeb"))
- }, " 保存mxweb到服务器 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[28] || (_cache[28] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetSysVars"))
- }, " 得到系统变量 ")
- ]),
- vue.createElementVNode("div", _hoisted_15, [
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[29] || (_cache[29] = ($event) => vue.unref(modalOptions2).docommand("MxTest_NewFile"))
- }, " 新建图纸 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[30] || (_cache[30] = ($event) => vue.unref(modalOptions2).docommand("Mx_ViewBackgroundColor"))
- }, " 白色背景色 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[31] || (_cache[31] = ($event) => vue.unref(modalOptions2).docommand("MxTest_FindText"))
- }, " 文字查找定位 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[32] || (_cache[32] = ($event) => vue.unref(modalOptions2).docommand("MxTest_SelectEntitysToBlock"))
- }, " 选择实体做块 ")
- ]),
- vue.createElementVNode("div", _hoisted_16, [
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[33] || (_cache[33] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_Text"))
- }, " 绘制单行文字 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[34] || (_cache[34] = ($event) => vue.unref(modalOptions2).docommand("MxTest_DrawHatchFormPoint"))
- }, " 选点填充 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[35] || (_cache[35] = ($event) => vue.unref(modalOptions2).docommand("Mx_TestExProp"))
- }, " 设置扩展属性 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[36] || (_cache[36] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DimAligned"))
- }, " 绘制对齐标注 ")
- ]),
- vue.createElementVNode("div", _hoisted_17, [
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[37] || (_cache[37] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawDimRotated"))
- }, " 绘性线标注 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[38] || (_cache[38] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawDimAngular"))
- }, " 角度标注 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[39] || (_cache[39] = ($event) => vue.unref(modalOptions2).docommand("MxTest_LineTypeTest"))
- }, " 修改对象线型 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[40] || (_cache[40] = ($event) => vue.unref(modalOptions2).docommand("Mx_SelectEntitHideLayer"))
- }, " 选择隐藏对象层 ")
- ]),
- vue.createElementVNode("div", _hoisted_18, [
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[41] || (_cache[41] = ($event) => vue.unref(modalOptions2).docommand("MxTest_TestAddCurrentSelect"))
- }, " 添加到当前选择 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[42] || (_cache[42] = ($event) => vue.unref(modalOptions2).docommand("MxTest_TestSetViewAngle"))
- }, " 视区旋转 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[43] || (_cache[43] = ($event) => vue.unref(modalOptions2).docommand("MxTest_WriteXRecord"))
- }, " 写扩展记录 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[44] || (_cache[44] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetNamedObjectsDictionary"))
- }, " 得到命名字典 ")
- ]),
- vue.createElementVNode("div", _hoisted_19, [
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[45] || (_cache[45] = ($event) => vue.unref(modalOptions2).docommand("MxTest_AddTextStyleTable"))
- }, " 添加文字样式 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[46] || (_cache[46] = ($event) => vue.unref(modalOptions2).docommand("MxTest_DrawCustomEntity"))
- }, " 绘自定义实体 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[47] || (_cache[47] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_ChangeColor"))
- }, " 修改对象颜色 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[48] || (_cache[48] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_ChangeVisible"))
- }, " 修改对象不可见 ")
- ]),
- vue.createElementVNode("div", _hoisted_20, [
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[49] || (_cache[49] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_ChangeEntityLayer"))
- }, " 修改对象层 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[50] || (_cache[50] = ($event) => vue.unref(modalOptions2).docommand("Mx_ChaneEntityDrawOrder"))
- }, " 修改对象显示顺序 "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[51] || (_cache[51] = ($event) => vue.unref(modalOptions2).docommand("Mx_Export_Pdf"))
- }, " 指定范围输出pdf "),
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[52] || (_cache[52] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawImage"))
- }, " 绘制image ")
- ]),
- vue.createElementVNode("div", _hoisted_21, [
- vue.createElementVNode("button", {
- class: "button button2",
- onClick: _cache[53] || (_cache[53] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetObjectExDictionaryData"))
- }, " 读取对象扩展字典 ")
- ])
- ])
- ])
- ])) : vue.createCommentVNode("", true)
- ]);
- };
- }
- });
- const Modal_vue_vue_type_style_index_0_scoped_9bd7093d_lang = "";
- const _export_sfc = (sfc, props) => {
- const target = sfc.__vccOpts || sfc;
- for (const [key, val] of props) {
- target[key] = val;
- }
- return target;
- };
- const Modal = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-9bd7093d"]]);
- const _sfc_main = /* @__PURE__ */ vue.defineComponent({
- __name: "Test",
- setup(__props) {
- return (_ctx, _cache) => {
- return vue.openBlock(), vue.createElementBlock("div", null, [
- vue.createVNode(Modal)
- ]);
- };
- }
- });
- const MxIFrame = {
- init() {
- mxdraw.MxFun.setPostMessageToParentFrameFunction(function(param) {
- top.postMessage(param, "*");
- });
- window.addEventListener("message", function(event) {
- if (event.data.type === "sendStringToExecute") {
- mxdraw.MxFun.sendStringToExecute(event.data.cmd, event.data);
- } else {
- console.log("mx:unprocessed message:");
- console.log(event.data);
- }
- }, false);
- }
- };
- function init$p() {
- MxIFrame.init();
- }
- function BR_Comment() {
- return __async(this, null, function* () {
- const getPoint = new mxdraw.MrxDbgUiPrPoint();
- getPoint.setMessage("\n指定第一点:");
- getPoint.go((status) => {
- if (status != 0) {
- return;
- }
- const pt1 = getPoint.value();
- let leadComment = new mxdraw.MxDbLeadComment();
- leadComment.point1 = pt1.clone();
- leadComment.textHeight = mxdraw.MxFun.screenCoordLong2Doc(50);
- leadComment.text = "测试Test1";
- leadComment.textWidth = mxdraw.MxFun.screenCoordLong2Doc(300);
- leadComment.fixedSize = true;
- if (leadComment.fixedSize) {
- leadComment.textHeight = 50;
- leadComment.textWidth = 250;
- }
- leadComment.color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
- const worldDrawComment = new mxdraw.McEdGetPointWorldDrawObject();
- worldDrawComment.setDraw(
- (currentPoint, pWorldDraw) => {
- leadComment.point2 = currentPoint;
- pWorldDraw.drawCustomEntity(leadComment);
- }
- );
- getPoint.setBasePt(pt1);
- getPoint.setUseBasePt(true);
- getPoint.setUserDraw(worldDrawComment);
- getPoint.setMessage("\n指定第二点:");
- getPoint.go((status2) => {
- if (status2 != 0) {
- console.log(status2);
- return;
- }
- const currentPoint = getPoint.value();
- leadComment.point2 = currentPoint;
- mxdraw.MxFun.addToCurrentSpace(leadComment);
- });
- });
- });
- }
- function BR_Print() {
- mxdraw.MxFun.getCurrentDraw().createCanvasImageData(
- (imageData) => {
- const newWindow = window.open();
- if (newWindow != null) {
- newWindow.document.write('<img src="' + imageData + '"/>');
- setTimeout(() => {
- newWindow.print();
- }, 300);
- }
- },
- {
- width: 349,
- height: 536
- }
- );
- }
- function BR_CheckDraw() {
- return __async(this, null, function* () {
- let color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
- const point = new mxdraw.MrxDbgUiPrPoint();
- const mxDraw = mxdraw.MxFun.getCurrentDraw();
- const worldDrawComment = new mxdraw.McEdGetPointWorldDrawObject();
- const mxCheckDraw = new mxdraw.MxDbRectBoxLeadComment();
- mxCheckDraw.color = color.getHex();
- if (mxCheckDraw.color == 0)
- mxCheckDraw.color = 65793;
- mxCheckDraw.radius = mxdraw.MxFun.screenCoordLong2Doc(8);
- mxCheckDraw.setLineWidth(3);
- mxCheckDraw.setLineWidthByPixels(true);
- point.setMessage("\n云线框起始点:");
- point.go((status) => {
- if (status != mxdraw.MrxDbgUiPrBaseReturn.kOk) {
- return;
- }
- mxCheckDraw.point1 = point.value();
- worldDrawComment.setDraw((currentPoint) => {
- mxCheckDraw.point2 = currentPoint;
- worldDrawComment.drawCustomEntity(mxCheckDraw);
- });
- point.setUserDraw(worldDrawComment);
- point.setMessage("\n云线框结束点:");
- point.go((status2) => {
- if (status2 != mxdraw.MrxDbgUiPrBaseReturn.kOk) {
- return;
- }
- mxCheckDraw.point2 = point.value();
- worldDrawComment.setDraw((currentPoint) => {
- mxCheckDraw.point3 = currentPoint;
- worldDrawComment.drawCustomEntity(mxCheckDraw);
- });
- mxCheckDraw.text = "审图批注XXXXXXXXXX";
- mxCheckDraw.textWidth = mxdraw.MxFun.screenCoordLong2Doc(200);
- mxCheckDraw.textHeight = mxdraw.MxFun.screenCoordLong2Doc(50);
- mxCheckDraw.fixedSize = true;
- if (mxCheckDraw.fixedSize) {
- mxCheckDraw.textHeight = 20;
- mxCheckDraw.textWidth = 230;
- }
- point.setMessage("\n审图标注点:");
- point.go((status3) => {
- if (status3 != mxdraw.MrxDbgUiPrBaseReturn.kOk) {
- return;
- }
- mxCheckDraw.point3 = point.value();
- mxDraw.addMxEntity(mxCheckDraw);
- });
- });
- });
- });
- }
- function getScreenPixel(pixel, isFontSize) {
- let _pixel = mxdraw.MxFun.screenCoordLong2World(isFontSize ? pixel : pixel - pixel / 3);
- _pixel = mxdraw.MxFun.worldCoordLong2Doc(_pixel);
- return _pixel;
- }
- function BR_Arrow() {
- const worldDraw = new mxdraw.McEdGetPointWorldDrawObject();
- const lines = new mxdraw.MxDbArrow();
- const mxDraw = mxdraw.MxFun.getCurrentDraw();
- const point = new mxdraw.MrxDbgUiPrPoint();
- point.setUserDraw(worldDraw);
- lines.setLineWidth(10);
- lines.innerOffset = getScreenPixel(10);
- lines.outerOffset = getScreenPixel(22);
- lines.topOffset = getScreenPixel(36);
- lines.color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
- point.go(() => {
- lines.startPoint = point.value();
- worldDraw.setDraw((v) => {
- lines.endPoint = v;
- worldDraw.drawCustomEntity(lines);
- });
- point.go((status) => __async(this, null, function* () {
- lines.endPoint = point.value();
- mxDraw.addMxEntity(lines);
- }));
- });
- }
- function BR_CloudLine() {
- const point = new mxdraw.MrxDbgUiPrPoint();
- const mxDraw = mxdraw.MxFun.getCurrentDraw();
- const worldDrawComment = new mxdraw.McEdGetPointWorldDrawObject();
- const radius = mxdraw.MxFun.screenCoordLong2Doc(16);
- point.setMessage("\n点击开启绘制云线:");
- point.go(() => {
- let pt = point.value();
- const mxCloudLine = new mxdraw.MxDbCloudLine();
- mxCloudLine.setRadius(radius);
- mxCloudLine.addPoint(pt);
- mxCloudLine.color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
- worldDrawComment.setDraw((currentPoint) => {
- if (pt.distanceTo(currentPoint) > radius) {
- pt = currentPoint.clone();
- mxCloudLine.addPoint(currentPoint, true);
- }
- worldDrawComment.drawCustomEntity(mxCloudLine);
- });
- point.setUserDraw(worldDrawComment);
- point.setMessage("\n再次点击结束绘制云线:");
- point.go(() => {
- mxDraw.addMxEntity(mxCloudLine);
- });
- });
- }
- let sSaveData = "";
- function BR_SaveAllMxEntity() {
- let mxobj = mxdraw.MxFun.getCurrentDraw();
- sSaveData = mxobj.saveMxEntityToJson();
- console.log(sSaveData);
- }
- function BR_LoadAllMxEntity() {
- return __async(this, null, function* () {
- if (sSaveData.length == 0)
- return;
- let mxobj = mxdraw.MxFun.getCurrentDraw();
- yield mxobj.loadMxEntityFromJson(sSaveData, ["models/svg/mark.svg"]);
- mxobj.updateDisplay();
- });
- }
- function BR_Area() {
- const getPoint = new mxdraw.MrxDbgUiPrPoint();
- getPoint.setMessage("\n指定第一点:");
- getPoint.go((status) => {
- if (status != 0) {
- return;
- }
- const pt1 = getPoint.value();
- let area2 = new mxdraw.MxDbArea();
- area2.addPoint(pt1);
- area2.color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
- const worldDrawComment = new mxdraw.McEdGetPointWorldDrawObject();
- worldDrawComment.setDraw((currentPoint, pWorldDraw) => {
- let tmp2 = area2.clone();
- tmp2.addPoint(currentPoint);
- worldDrawComment.drawCustomEntity(tmp2);
- });
- getPoint.setUserDraw(worldDrawComment);
- getPoint.setMessage("\n指定下一点:");
- getPoint.goWhile(
- (status2) => {
- if (status2 == 0) {
- const pt2 = getPoint.value();
- area2.addPoint(pt2);
- }
- },
- (status2) => {
- area2.isFill = true;
- area2.fillOpacity = 0.7;
- area2.fillColor = 6697540;
- mxdraw.MxFun.getCurrentDraw().addMxEntity(area2);
- }
- );
- });
- }
- function init$o() {
- mxdraw.MxFun.addCommand("BR_Comment", BR_Comment);
- mxdraw.MxFun.addCommand("BR_CheckDraw", BR_CheckDraw);
- mxdraw.MxFun.addCommand("BR_Arrow", BR_Arrow);
- mxdraw.MxFun.addCommand("BR_CloudLine", BR_CloudLine);
- mxdraw.MxFun.addCommand("BR_Print", BR_Print);
- mxdraw.MxFun.addCommand("BR_SaveAllMxEntity", BR_SaveAllMxEntity);
- mxdraw.MxFun.addCommand("BR_LoadAllMxEntity", BR_LoadAllMxEntity);
- mxdraw.MxFun.addCommand("BR_Area", BR_Area);
- }
- function Mx_Test_DrawLine() {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.newFile();
- mxcad$1.drawColorIndex = 0;
- mxcad$1.drawLinetype = "";
- mxcad$1.drawLineWidth = 0;
- mxcad$1.addLayer("LineLayer");
- mxcad$1.drawLayer = "LineLayer";
- mxcad$1.drawLine(0, 0, 100, 0);
- mxcad$1.drawLine(200, 0, 300, 100);
- mxcad$1.addLinetype("MyLineType", "6,-10");
- mxcad$1.drawLinetype = "MyLineType";
- mxcad$1.drawLine(0, 30, 100, 30);
- mxcad$1.drawLine(200, 30, 300, 130);
- mxcad$1.drawColor = new mxcad2.McCmColor(0, 0, 255);
- mxcad$1.drawLine(0, 60, 100, 60);
- mxcad$1.drawLine(200, 60, 300, 160);
- mxcad$1.drawColorIndex = 0;
- mxcad$1.drawLinetype = "";
- mxcad$1.drawLineWidth = 4;
- mxcad$1.drawLine(0, 90, 100, 90);
- mxcad$1.drawLine(200, 90, 300, 190);
- mxcad$1.addLinetype("MyLineType2", "10,-2,3,-2");
- mxcad$1.drawLinetype = "MyLineType2";
- mxcad$1.drawColor = new mxcad2.McCmColor(255, 0, 0);
- mxcad$1.drawLine(0, 120, 100, 120);
- mxcad$1.drawLine(200, 120, 300, 220);
- mxcad$1.addTextStyle("MyLineTypeTextStyle", "txt.shx", "hztxt.shx", 1);
- 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");
- mxcad$1.drawLinetype = "MyLineType3";
- mxcad$1.drawLineWidth = 0;
- mxcad$1.drawLine(350, 120, 600, 120);
- mxcad$1.drawColorIndex = 0;
- mxcad$1.drawLineWidth = 4;
- mxcad$1.drawLine(350, 220, 600, 220);
- mxcad$1.zoomAll();
- mxcad$1.updateDisplay();
- }
- function Mx_Test_DrawArc() {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.newFile();
- mxcad$1.drawColorIndex = 0;
- mxcad$1.drawLinetype = "";
- mxcad$1.drawLineWidth = 0;
- mxcad$1.addLayer("ArcLayer");
- mxcad$1.drawLayer = "ArcLayer";
- mxcad$1.drawArc(0, 1e3, 100, 30, 200);
- mxcad$1.addLinetype("ArcLineType", "30,-5,7,-7");
- mxcad$1.drawLinetype = "ArcLineType";
- mxcad$1.drawColor = new mxcad2.McCmColor(255, 25, 0);
- mxcad$1.drawArc(300, 1e3, 100, 30, 200);
- mxcad$1.drawLineWidth = 15;
- mxcad$1.drawColorIndex = 255;
- mxcad$1.drawArc(600, 1e3, 100, 30, 200);
- mxcad$1.drawArc2(800, 1e3, 900, 1200, 1e3, 900);
- mxcad$1.drawLinetype = "";
- mxcad$1.drawLineWidth = 40;
- mxcad$1.drawArc3(1200, 1e3, 1400, 1e3, 0.6);
- mxcad$1.zoomAll();
- mxcad$1.regen();
- mxcad$1.updateDisplay();
- }
- function Mx_Test_DrawCircle() {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.newFile();
- mxcad$1.drawColorIndex = 0;
- mxcad$1.drawLinetype = "";
- mxcad$1.drawLineWidth = 0;
- mxcad$1.addLayer("CircleLayer");
- mxcad$1.drawLayer = "CircleLayer";
- mxcad$1.drawCircle(0, 800, 120);
- mxcad$1.addLinetype("CircleLineType", "30,-5,7,-7");
- mxcad$1.drawLinetype = "CircleLineType";
- mxcad$1.drawColor = new mxcad2.McCmColor(0, 25, 255);
- mxcad$1.drawCircle(300, 800, 120);
- mxcad$1.addLinetype("CircleLineType", "30,-5,7,-7");
- mxcad$1.drawLinetype = "CircleLineType";
- mxcad$1.drawLineWidth = 40;
- mxcad$1.drawCircle(600, 800, 120);
- mxcad$1.zoomAll();
- mxcad$1.regen();
- mxcad$1.updateDisplay();
- }
- function Mx_Test_DrawPolyline() {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.newFile();
- mxcad$1.drawColorIndex = 0;
- mxcad$1.drawLinetype = "";
- mxcad$1.drawLineWidth = 0;
- mxcad$1.addLayer("PolylineLayer");
- mxcad$1.drawLayer = "PolylineLayer";
- mxcad$1.pathMoveTo(0, 300);
- mxcad$1.pathLineTo(100, 300);
- mxcad$1.pathLineTo(100, 400);
- mxcad$1.pathLineTo(0, 400);
- mxcad$1.pathMakeClosed();
- mxcad$1.drawPathToPolyline();
- mxcad$1.pathMoveTo(200, 300);
- mxcad$1.pathLineTo(300, 300);
- mxcad$1.pathLineTo(300, 400);
- mxcad$1.pathLineTo(200, 400);
- mxcad$1.pathMakeClosed();
- mxcad$1.addLinetype("MyLineType3", "30,-10");
- mxcad$1.drawLinetype = "MyLineType3";
- mxcad$1.drawColorIndex = 255;
- mxcad$1.drawLineWidth = 5;
- mxcad$1.drawPathToPolyline();
- mxcad$1.pathMoveTo(400, 300);
- mxcad$1.pathLineTo(500, 300);
- mxcad$1.pathLineTo(500, 400);
- mxcad$1.pathLineTo(400, 400);
- mxcad$1.pathMakeClosed();
- mxcad$1.drawLinetype = "";
- mxcad$1.drawColor = new mxcad2.McCmColor(0, 25, 255);
- mxcad$1.drawLineWidth = 10;
- mxcad$1.drawPathToPolyline();
- mxcad$1.pathMoveTo(400, 300);
- mxcad$1.pathLineTo(500, 300);
- mxcad$1.pathLineTo(500, 400);
- mxcad$1.pathLineTo(400, 400);
- mxcad$1.pathMakeClosed();
- mxcad$1.drawLinetype = "";
- mxcad$1.drawColor = new mxcad2.McCmColor(255, 25, 0);
- mxcad$1.drawLineWidth = 10;
- mxcad$1.drawPathToPolyline();
- mxcad$1.pathMoveTo(600, 300);
- mxcad$1.pathLineTo(700, 300);
- mxcad$1.pathLineTo(700, 400);
- mxcad$1.pathLineTo(600, 400);
- mxcad$1.drawLinetype = "";
- mxcad$1.drawColor = new mxcad2.McCmColor(0, 255, 0);
- mxcad$1.drawLineWidth = 10;
- mxcad$1.drawPathToPolyline();
- mxcad$1.pathMoveTo(800, 300);
- mxcad$1.pathLineTo(900, 300);
- mxcad$1.pathLineTo(900, 400);
- mxcad$1.pathMakeClosed();
- mxcad$1.drawLinetype = "";
- mxcad$1.drawColor = new mxcad2.McCmColor(25, 255, 0);
- mxcad$1.drawLineWidth = 10;
- mxcad$1.drawPathToPolyline();
- mxcad$1.pathMoveToEx(1e3, 300, 10, 10, 0);
- mxcad$1.pathLineToEx(1e3, 500, 30, 0, 0);
- mxcad$1.pathLineTo(1e3, 580);
- mxcad$1.drawPathToPolyline();
- mxcad$1.pathMoveToEx(1200, 300, 10, 10, 0);
- mxcad$1.pathLineToEx(1200, 500, 30, 0, 0);
- mxcad$1.pathLineTo(1200, 580);
- mxcad$1.drawColor = new mxcad2.McCmColor(25, 255, 0);
- mxcad$1.drawLinetype = "MyLineType3";
- mxcad$1.drawPathToPolyline();
- mxcad$1.pathMoveToEx(1400, 300, 10, 10, -0.34);
- mxcad$1.pathLineToEx(1400, 500, 30, 0, 0.34);
- mxcad$1.pathLineTo(1400, 600);
- mxcad$1.drawColor = new mxcad2.McCmColor(255, 255, 25);
- mxcad$1.drawLinetype = "MyLineType3";
- mxcad$1.drawPathToPolyline();
- mxcad$1.zoomAll();
- mxcad$1.regen();
- mxcad$1.updateDisplay();
- }
- function Mx_Test_DrawHatch() {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.newFile();
- mxcad$1.drawColorIndex = 0;
- mxcad$1.drawLinetype = "";
- mxcad$1.drawLineWidth = 0;
- mxcad$1.addLayer("HatchLayer");
- mxcad$1.drawLayer = "HatchLayer";
- mxcad$1.pathMoveToEx(200, 3300, 0, 0, 0.3);
- mxcad$1.pathLineTo(300, 3300);
- mxcad$1.pathLineTo(300, 3400);
- mxcad$1.pathLineTo(200, 3300);
- mxcad$1.drawColor = new mxcad2.McCmColor(25, 255, 0);
- mxcad$1.drawPathToHatch(1);
- mxcad$1.pathMoveTo(150, 3300);
- mxcad$1.pathLineTo(250, 3300);
- mxcad$1.pathLineTo(250, 3400);
- mxcad$1.pathLineTo(150, 3300);
- mxcad$1.drawColor = new mxcad2.McCmColor(255, 0, 0);
- mxcad$1.drawPathToHatch(1);
- mxcad$1.pathMoveToEx(440, 3310, 0, 0, 0);
- mxcad$1.pathLineTo(480, 3310);
- mxcad$1.pathLineTo(480, 3360);
- mxcad$1.pathLineTo(450, 3340);
- mxcad$1.pathMakeExclude(true);
- mxcad$1.pathMoveToEx(400, 3300, 0, 0, 0.3);
- mxcad$1.pathLineTo(500, 3300);
- mxcad$1.pathLineTo(500, 3400);
- mxcad$1.pathLineTo(400, 3300);
- mxcad$1.drawColor = new mxcad2.McCmColor(255, 25, 0);
- mxcad$1.drawPathToHatch(1);
- mxcad$1.addPatternDefinition("MyHatchPattern1", "((45, 0,0, 0,0.125))");
- mxcad$1.drawPatternDefinition = "MyHatchPattern1";
- mxcad$1.pathMoveToEx(600, 3300, 0, 0, 0.3);
- mxcad$1.pathLineTo(700, 3300);
- mxcad$1.pathLineTo(700, 3400);
- mxcad$1.pathLineTo(600, 3300);
- mxcad$1.drawPathToHatch(100);
- mxcad$1.addPatternDefinition("MyHatchPattern2", "((45, 0,0, 0,0.25) (45, 0.176776695,0, 0,0.25, 0.125,-0.0625))");
- mxcad$1.drawPatternDefinition = "MyHatchPattern2";
- mxcad$1.pathMoveToEx(800, 3300, 0, 0, 0.3);
- mxcad$1.pathLineTo(900, 3300);
- mxcad$1.pathLineTo(900, 3400);
- mxcad$1.pathLineTo(800, 3300);
- mxcad$1.drawPathToHatch(100);
- mxcad$1.zoomAll();
- mxcad$1.regen();
- mxcad$1.updateDisplay();
- }
- function Mx_Test_DrawText() {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.newFile();
- mxcad$1.drawColorIndex = 0;
- mxcad$1.addLayer("TextLayer");
- mxcad$1.drawLayer = "TextLayer";
- mxcad$1.drawText(0, 1900, "绘图控件文字测试", 100, 0, 0, 1);
- mxcad$1.drawColor = new mxcad2.McCmColor(255, 25, 0);
- mxcad$1.drawText(3e3, 2100, "绘图控件文字测试", 100, -20, 2, 1);
- mxcad$1.addTextStyle("MyTextStyle", "italicc.shx", "gbcbig.shx", 0.7);
- mxcad$1.drawTextStyle = "MyTextStyle";
- mxcad$1.drawColor = new mxcad2.McCmColor(255, 0, 0);
- mxcad$1.drawText(0, 3e3, "绘图控件文字测试", 100, 0, 0, 1);
- mxcad$1.AddTureTypeTextStyle("MyTrueTypeTextStyle");
- mxcad$1.drawTextStyle = "MyTrueTypeTextStyle";
- mxcad$1.drawColor = new mxcad2.McCmColor(200, 255, 50);
- mxcad$1.drawText(0, 3500, "绘图控件TrueType文字测试", 100, 0, 0, 1);
- mxcad$1.zoomAll();
- mxcad$1.regen();
- mxcad$1.updateDisplay();
- }
- function Mx_Test_Ellipse() {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.newFile();
- mxcad$1.drawColorIndex = 0;
- mxcad$1.drawLinetype = "";
- mxcad$1.drawLineWidth = 0;
- mxcad$1.addLayer("LineLayer");
- mxcad$1.drawLayer = "LineLayer";
- mxcad$1.drawEllipse(0, 1400, 100, 0, 0.7);
- mxcad$1.addLinetype("MyEllipseType", "6,-10");
- mxcad$1.drawLinetype = "MyEllipseType";
- mxcad$1.drawColor = new mxcad2.McCmColor(200, 0, 0);
- mxcad$1.drawEllipse(200, 1400, 80, 30, 0.5);
- mxcad$1.zoomAll();
- mxcad$1.regen();
- mxcad$1.updateDisplay();
- }
- function Mx_Test_EllipseArc() {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.newFile();
- mxcad$1.drawColorIndex = 0;
- mxcad$1.drawLineWidth = 0;
- mxcad$1.addLayer("EllipseArcLayer");
- mxcad$1.drawLayer = "EllipseArcLayer";
- mxcad$1.drawEllipseArc(0, 1600, 80, 30, 0.4, 30, 200);
- mxcad$1.addLinetype("MyEllipseArcType", "6,-10");
- mxcad$1.drawLinetype = "MyEllipseArcType";
- mxcad$1.drawColor = new mxcad2.McCmColor(200, 200, 0);
- mxcad$1.drawEllipseArc(200, 1600, -80, 30, 0.5, 60, 300);
- mxcad$1.drawLinetype = "";
- mxcad$1.zoomAll();
- mxcad$1.regen();
- mxcad$1.updateDisplay();
- }
- function Mx_Test_MText() {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.newFile();
- mxcad$1.drawColorIndex = 0;
- mxcad$1.addLayer("MtextLayer");
- mxcad$1.drawLayer = "MtextLayer";
- mxcad$1.drawTextStyle = "";
- mxcad$1.drawMText(0, -100, "控件:\\P多行文字测试", 50, 400, 0, 1);
- mxcad$1.zoomAll();
- mxcad$1.regen();
- mxcad$1.updateDisplay();
- }
- function Mx_ParamDrawLine(data) {
- if (!data || !data.param)
- return;
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.newFile();
- mxcad$1.drawColorIndex = 0;
- mxcad$1.drawLinetype = "";
- mxcad$1.drawLineWidth = 0;
- mxcad$1.addLayer("LineLayer");
- mxcad$1.drawLayer = "LineLayer";
- mxcad$1.drawLine(data.param.x1, data.param.y1, data.param.x2, data.param.y2);
- mxcad$1.zoomAll();
- mxcad$1.updateDisplay();
- mxdraw.MxFun.postMessageToParentFrame({ cmd: "Mx_ParamDrawLine", message: "ok" });
- }
- function Mx_Test_Text() {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.newFile();
- mxcad$1.drawText(
- 350831.77,
- 1940511845e-2,
- "1.034",
- 10,
- 0,
- mxcad2.McDb.TextHorzMode.kTextLeft,
- mxcad2.McDb.TextVertMode.kTextVertMid
- );
- mxcad$1.zoomAll();
- mxcad$1.regen(100);
- }
- function Mx_Test_DimAligned() {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.newFile();
- mxcad$1.addDimStyle("MyDimStyle", "41,0.18,141,0.09,40,200", "77,1,271,3", "", "");
- mxcad$1.drawDimStyle = "MyDimStyle";
- mxcad$1.drawColorIndex = 0;
- mxcad$1.drawLinetype = "";
- mxcad$1.drawLineWidth = 0;
- mxcad$1.drawDimAligned(0, 4e3, 300, 4500, 150, 4600);
- mxcad$1.zoomAll();
- mxcad$1.updateDisplay();
- }
- function Mx_Test_DrawDimRotated() {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.newFile();
- mxcad$1.addDimStyle("MyDimStyle", "41,0.18,141,0.09,40,200", "77,1,271,3", "", "");
- mxcad$1.drawDimStyle = "MyDimStyle";
- mxcad$1.drawColorIndex = 0;
- mxcad$1.drawLinetype = "";
- mxcad$1.drawLineWidth = 0;
- mxcad$1.drawDimRotated(0, 7e3, 600, 7e3, 250, 7050, 0);
- mxcad$1.drawDimRotated(0, 7200, 0, 7600, 150, 7300, 0.771);
- mxcad$1.zoomAll();
- mxcad$1.updateDisplay();
- }
- function Mx_Test_DrawDimAngular() {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.newFile();
- mxcad$1.addDimStyle("MyDimStyle2", "41,0.18,141,0.09,40,200", "77,1,271,3", "", "");
- mxcad$1.drawDimStyle = "MyDimStyle2";
- mxcad$1.drawColorIndex = 0;
- mxcad$1.drawLinetype = "";
- mxcad$1.drawLineWidth = 0;
- mxcad$1.drawDimAngular(500, 5e3, 0, 5500, 1e3, 5500, 500, 5500);
- mxcad$1.zoomAll();
- mxcad$1.updateDisplay();
- }
- function init$n() {
- mxdraw.MxFun.addCommand("Mx_Test_DrawLine", Mx_Test_DrawLine);
- mxdraw.MxFun.addCommand("Mx_Test_DrawArc", Mx_Test_DrawArc);
- mxdraw.MxFun.addCommand("Mx_Test_DrawCircle", Mx_Test_DrawCircle);
- mxdraw.MxFun.addCommand("Mx_Test_DrawPolyline", Mx_Test_DrawPolyline);
- mxdraw.MxFun.addCommand("Mx_Test_DrawHatch", Mx_Test_DrawHatch);
- mxdraw.MxFun.addCommand("Mx_Test_DrawText", Mx_Test_DrawText);
- mxdraw.MxFun.addCommand("Mx_Test_Ellipse", Mx_Test_Ellipse);
- mxdraw.MxFun.addCommand("Mx_Test_EllipseArc", Mx_Test_EllipseArc);
- mxdraw.MxFun.addCommand("Mx_Test_MText", Mx_Test_MText);
- mxdraw.MxFun.addCommand("Mx_Test_Text", Mx_Test_Text);
- mxdraw.MxFun.addCommand("Mx_ParamDrawLine", Mx_ParamDrawLine);
- mxdraw.MxFun.addCommand("Mx_Test_DimAligned", Mx_Test_DimAligned);
- mxdraw.MxFun.addCommand("Mx_Test_DrawDimRotated", Mx_Test_DrawDimRotated);
- mxdraw.MxFun.addCommand("Mx_Test_DrawDimAngular", Mx_Test_DrawDimAngular);
- }
- if (Number.EPSILON === void 0) {
- Number.EPSILON = Math.pow(2, -52);
- }
- if (Number.isInteger === void 0) {
- Number.isInteger = function(value) {
- return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
- };
- }
- if (Math.sign === void 0) {
- Math.sign = function(x) {
- return x < 0 ? -1 : x > 0 ? 1 : +x;
- };
- }
- if ("name" in Function.prototype === false) {
- Object.defineProperty(Function.prototype, "name", {
- get: function() {
- return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1];
- }
- });
- }
- if (Object.assign === void 0) {
- Object.assign = function(target) {
- if (target === void 0 || target === null) {
- throw new TypeError("Cannot convert undefined or null to object");
- }
- var output = Object(target);
- for (var index = 1; index < arguments.length; index++) {
- var source = arguments[index];
- if (source !== void 0 && source !== null) {
- for (var nextKey in source) {
- if (Object.prototype.hasOwnProperty.call(source, nextKey)) {
- output[nextKey] = source[nextKey];
- }
- }
- }
- }
- return output;
- };
- }
- var REVISION = "113";
- var CullFaceNone = 0;
- var CullFaceBack = 1;
- var CullFaceFront = 2;
- var PCFShadowMap = 1;
- var PCFSoftShadowMap = 2;
- var VSMShadowMap = 3;
- var FrontSide = 0;
- var BackSide = 1;
- var DoubleSide = 2;
- var FlatShading = 1;
- var NoColors = 0;
- var FaceColors = 1;
- var VertexColors = 2;
- var NoBlending = 0;
- var NormalBlending = 1;
- var AdditiveBlending = 2;
- var SubtractiveBlending = 3;
- var MultiplyBlending = 4;
- var CustomBlending = 5;
- var AddEquation = 100;
- var SubtractEquation = 101;
- var ReverseSubtractEquation = 102;
- var MinEquation = 103;
- var MaxEquation = 104;
- var ZeroFactor = 200;
- var OneFactor = 201;
- var SrcColorFactor = 202;
- var OneMinusSrcColorFactor = 203;
- var SrcAlphaFactor = 204;
- var OneMinusSrcAlphaFactor = 205;
- var DstAlphaFactor = 206;
- var OneMinusDstAlphaFactor = 207;
- var DstColorFactor = 208;
- var OneMinusDstColorFactor = 209;
- var SrcAlphaSaturateFactor = 210;
- var NeverDepth = 0;
- var AlwaysDepth = 1;
- var LessDepth = 2;
- var LessEqualDepth = 3;
- var EqualDepth = 4;
- var GreaterEqualDepth = 5;
- var GreaterDepth = 6;
- var NotEqualDepth = 7;
- var MultiplyOperation = 0;
- var MixOperation = 1;
- var AddOperation = 2;
- var NoToneMapping = 0;
- var LinearToneMapping = 1;
- var ReinhardToneMapping = 2;
- var Uncharted2ToneMapping = 3;
- var CineonToneMapping = 4;
- var ACESFilmicToneMapping = 5;
- var UVMapping = 300;
- var CubeReflectionMapping = 301;
- var CubeRefractionMapping = 302;
- var EquirectangularReflectionMapping = 303;
- var EquirectangularRefractionMapping = 304;
- var SphericalReflectionMapping = 305;
- var CubeUVReflectionMapping = 306;
- var CubeUVRefractionMapping = 307;
- var RepeatWrapping = 1e3;
- var ClampToEdgeWrapping = 1001;
- var MirroredRepeatWrapping = 1002;
- var NearestFilter = 1003;
- var NearestMipmapNearestFilter = 1004;
- var NearestMipmapLinearFilter = 1005;
- var LinearFilter = 1006;
- var LinearMipmapNearestFilter = 1007;
- var LinearMipmapLinearFilter = 1008;
- var UnsignedByteType = 1009;
- var ByteType = 1010;
- var ShortType = 1011;
- var UnsignedShortType = 1012;
- var IntType = 1013;
- var UnsignedIntType = 1014;
- var FloatType = 1015;
- var HalfFloatType = 1016;
- var UnsignedShort4444Type = 1017;
- var UnsignedShort5551Type = 1018;
- var UnsignedShort565Type = 1019;
- var UnsignedInt248Type = 1020;
- var AlphaFormat = 1021;
- var RGBFormat = 1022;
- var RGBAFormat = 1023;
- var LuminanceFormat = 1024;
- var LuminanceAlphaFormat = 1025;
- var RGBEFormat = RGBAFormat;
- var DepthFormat = 1026;
- var DepthStencilFormat = 1027;
- var RedFormat = 1028;
- var RedIntegerFormat = 1029;
- var RGFormat = 1030;
- var RGIntegerFormat = 1031;
- var RGBIntegerFormat = 1032;
- var RGBAIntegerFormat = 1033;
- var RGB_S3TC_DXT1_Format = 33776;
- var RGBA_S3TC_DXT1_Format = 33777;
- var RGBA_S3TC_DXT3_Format = 33778;
- var RGBA_S3TC_DXT5_Format = 33779;
- var RGB_PVRTC_4BPPV1_Format = 35840;
- var RGB_PVRTC_2BPPV1_Format = 35841;
- var RGBA_PVRTC_4BPPV1_Format = 35842;
- var RGBA_PVRTC_2BPPV1_Format = 35843;
- var RGB_ETC1_Format = 36196;
- var RGBA_ASTC_4x4_Format = 37808;
- var RGBA_ASTC_5x4_Format = 37809;
- var RGBA_ASTC_5x5_Format = 37810;
- var RGBA_ASTC_6x5_Format = 37811;
- var RGBA_ASTC_6x6_Format = 37812;
- var RGBA_ASTC_8x5_Format = 37813;
- var RGBA_ASTC_8x6_Format = 37814;
- var RGBA_ASTC_8x8_Format = 37815;
- var RGBA_ASTC_10x5_Format = 37816;
- var RGBA_ASTC_10x6_Format = 37817;
- var RGBA_ASTC_10x8_Format = 37818;
- var RGBA_ASTC_10x10_Format = 37819;
- var RGBA_ASTC_12x10_Format = 37820;
- var RGBA_ASTC_12x12_Format = 37821;
- var LoopOnce = 2200;
- var LoopRepeat = 2201;
- var LoopPingPong = 2202;
- var InterpolateDiscrete = 2300;
- var InterpolateLinear = 2301;
- var InterpolateSmooth = 2302;
- var ZeroCurvatureEnding = 2400;
- var ZeroSlopeEnding = 2401;
- var WrapAroundEnding = 2402;
- var TrianglesDrawMode = 0;
- var TriangleStripDrawMode = 1;
- var TriangleFanDrawMode = 2;
- var LinearEncoding = 3e3;
- var sRGBEncoding = 3001;
- var GammaEncoding = 3007;
- var RGBEEncoding = 3002;
- var LogLuvEncoding = 3003;
- var RGBM7Encoding = 3004;
- var RGBM16Encoding = 3005;
- var RGBDEncoding = 3006;
- var BasicDepthPacking = 3200;
- var RGBADepthPacking = 3201;
- var TangentSpaceNormalMap = 0;
- var ObjectSpaceNormalMap = 1;
- var KeepStencilOp = 7680;
- var AlwaysStencilFunc = 519;
- var StaticDrawUsage = 35044;
- var DynamicDrawUsage = 35048;
- function EventDispatcher() {
- }
- Object.assign(EventDispatcher.prototype, {
- addEventListener: function(type, listener) {
- if (this._listeners === void 0)
- this._listeners = {};
- var listeners = this._listeners;
- if (listeners[type] === void 0) {
- listeners[type] = [];
- }
- if (listeners[type].indexOf(listener) === -1) {
- listeners[type].push(listener);
- }
- },
- hasEventListener: function(type, listener) {
- if (this._listeners === void 0)
- return false;
- var listeners = this._listeners;
- return listeners[type] !== void 0 && listeners[type].indexOf(listener) !== -1;
- },
- removeEventListener: function(type, listener) {
- if (this._listeners === void 0)
- return;
- var listeners = this._listeners;
- var listenerArray = listeners[type];
- if (listenerArray !== void 0) {
- var index = listenerArray.indexOf(listener);
- if (index !== -1) {
- listenerArray.splice(index, 1);
- }
- }
- },
- dispatchEvent: function(event) {
- if (this._listeners === void 0)
- return;
- var listeners = this._listeners;
- var listenerArray = listeners[event.type];
- if (listenerArray !== void 0) {
- event.target = this;
- var array = listenerArray.slice(0);
- for (var i2 = 0, l = array.length; i2 < l; i2++) {
- array[i2].call(this, event);
- }
- }
- }
- });
- var _lut = [];
- for (var i = 0; i < 256; i++) {
- _lut[i] = (i < 16 ? "0" : "") + i.toString(16);
- }
- var MathUtils = {
- DEG2RAD: Math.PI / 180,
- RAD2DEG: 180 / Math.PI,
- generateUUID: function() {
- var d0 = Math.random() * 4294967295 | 0;
- var d1 = Math.random() * 4294967295 | 0;
- var d2 = Math.random() * 4294967295 | 0;
- var d3 = Math.random() * 4294967295 | 0;
- 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];
- return uuid.toUpperCase();
- },
- clamp: function(value, min, max) {
- return Math.max(min, Math.min(max, value));
- },
- // compute euclidian modulo of m % n
- // https://en.wikipedia.org/wiki/Modulo_operation
- euclideanModulo: function(n, m) {
- return (n % m + m) % m;
- },
- // Linear mapping from range <a1, a2> to range <b1, b2>
- mapLinear: function(x, a1, a2, b1, b2) {
- return b1 + (x - a1) * (b2 - b1) / (a2 - a1);
- },
- // https://en.wikipedia.org/wiki/Linear_interpolation
- lerp: function(x, y, t) {
- return (1 - t) * x + t * y;
- },
- // http://en.wikipedia.org/wiki/Smoothstep
- smoothstep: function(x, min, max) {
- if (x <= min)
- return 0;
- if (x >= max)
- return 1;
- x = (x - min) / (max - min);
- return x * x * (3 - 2 * x);
- },
- smootherstep: function(x, min, max) {
- if (x <= min)
- return 0;
- if (x >= max)
- return 1;
- x = (x - min) / (max - min);
- return x * x * x * (x * (x * 6 - 15) + 10);
- },
- // Random integer from <low, high> interval
- randInt: function(low, high) {
- return low + Math.floor(Math.random() * (high - low + 1));
- },
- // Random float from <low, high> interval
- randFloat: function(low, high) {
- return low + Math.random() * (high - low);
- },
- // Random float from <-range/2, range/2> interval
- randFloatSpread: function(range) {
- return range * (0.5 - Math.random());
- },
- degToRad: function(degrees) {
- return degrees * MathUtils.DEG2RAD;
- },
- radToDeg: function(radians) {
- return radians * MathUtils.RAD2DEG;
- },
- isPowerOfTwo: function(value) {
- return (value & value - 1) === 0 && value !== 0;
- },
- ceilPowerOfTwo: function(value) {
- return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));
- },
- floorPowerOfTwo: function(value) {
- return Math.pow(2, Math.floor(Math.log(value) / Math.LN2));
- },
- setQuaternionFromProperEuler: function(q, a, b, c, order) {
- var cos = Math.cos;
- var sin = Math.sin;
- var c2 = cos(b / 2);
- var s2 = sin(b / 2);
- var c13 = cos((a + c) / 2);
- var s13 = sin((a + c) / 2);
- var c1_3 = cos((a - c) / 2);
- var s1_3 = sin((a - c) / 2);
- var c3_1 = cos((c - a) / 2);
- var s3_1 = sin((c - a) / 2);
- if (order === "XYX") {
- q.set(c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13);
- } else if (order === "YZY") {
- q.set(s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13);
- } else if (order === "ZXZ") {
- q.set(s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13);
- } else if (order === "XZX") {
- q.set(c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13);
- } else if (order === "YXY") {
- q.set(s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13);
- } else if (order === "ZYZ") {
- q.set(s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13);
- } else {
- console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order.");
- }
- }
- };
- function Vector2(x, y) {
- this.x = x || 0;
- this.y = y || 0;
- }
- Object.defineProperties(Vector2.prototype, {
- "width": {
- get: function() {
- return this.x;
- },
- set: function(value) {
- this.x = value;
- }
- },
- "height": {
- get: function() {
- return this.y;
- },
- set: function(value) {
- this.y = value;
- }
- }
- });
- Object.assign(Vector2.prototype, {
- isVector2: true,
- set: function(x, y) {
- this.x = x;
- this.y = y;
- return this;
- },
- setScalar: function(scalar) {
- this.x = scalar;
- this.y = scalar;
- return this;
- },
- setX: function(x) {
- this.x = x;
- return this;
- },
- setY: function(y) {
- this.y = y;
- return this;
- },
- setComponent: function(index, value) {
- switch (index) {
- case 0:
- this.x = value;
- break;
- case 1:
- this.y = value;
- break;
- default:
- throw new Error("index is out of range: " + index);
- }
- return this;
- },
- getComponent: function(index) {
- switch (index) {
- case 0:
- return this.x;
- case 1:
- return this.y;
- default:
- throw new Error("index is out of range: " + index);
- }
- },
- clone: function() {
- return new this.constructor(this.x, this.y);
- },
- copy: function(v) {
- this.x = v.x;
- this.y = v.y;
- return this;
- },
- add: function(v, w) {
- if (w !== void 0) {
- console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.");
- return this.addVectors(v, w);
- }
- this.x += v.x;
- this.y += v.y;
- return this;
- },
- addScalar: function(s) {
- this.x += s;
- this.y += s;
- return this;
- },
- addVectors: function(a, b) {
- this.x = a.x + b.x;
- this.y = a.y + b.y;
- return this;
- },
- addScaledVector: function(v, s) {
- this.x += v.x * s;
- this.y += v.y * s;
- return this;
- },
- sub: function(v, w) {
- if (w !== void 0) {
- console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.");
- return this.subVectors(v, w);
- }
- this.x -= v.x;
- this.y -= v.y;
- return this;
- },
- subScalar: function(s) {
- this.x -= s;
- this.y -= s;
- return this;
- },
- subVectors: function(a, b) {
- this.x = a.x - b.x;
- this.y = a.y - b.y;
- return this;
- },
- multiply: function(v) {
- this.x *= v.x;
- this.y *= v.y;
- return this;
- },
- multiplyScalar: function(scalar) {
- this.x *= scalar;
- this.y *= scalar;
- return this;
- },
- divide: function(v) {
- this.x /= v.x;
- this.y /= v.y;
- return this;
- },
- divideScalar: function(scalar) {
- return this.multiplyScalar(1 / scalar);
- },
- applyMatrix3: function(m) {
- var x = this.x, y = this.y;
- var e = m.elements;
- this.x = e[0] * x + e[3] * y + e[6];
- this.y = e[1] * x + e[4] * y + e[7];
- return this;
- },
- min: function(v) {
- this.x = Math.min(this.x, v.x);
- this.y = Math.min(this.y, v.y);
- return this;
- },
- max: function(v) {
- this.x = Math.max(this.x, v.x);
- this.y = Math.max(this.y, v.y);
- return this;
- },
- clamp: function(min, max) {
- this.x = Math.max(min.x, Math.min(max.x, this.x));
- this.y = Math.max(min.y, Math.min(max.y, this.y));
- return this;
- },
- clampScalar: function(minVal, maxVal) {
- this.x = Math.max(minVal, Math.min(maxVal, this.x));
- this.y = Math.max(minVal, Math.min(maxVal, this.y));
- return this;
- },
- clampLength: function(min, max) {
- var length = this.length();
- return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));
- },
- floor: function() {
- this.x = Math.floor(this.x);
- this.y = Math.floor(this.y);
- return this;
- },
- ceil: function() {
- this.x = Math.ceil(this.x);
- this.y = Math.ceil(this.y);
- return this;
- },
- round: function() {
- this.x = Math.round(this.x);
- this.y = Math.round(this.y);
- return this;
- },
- roundToZero: function() {
- this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);
- this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);
- return this;
- },
- negate: function() {
- this.x = -this.x;
- this.y = -this.y;
- return this;
- },
- dot: function(v) {
- return this.x * v.x + this.y * v.y;
- },
- cross: function(v) {
- return this.x * v.y - this.y * v.x;
- },
- lengthSq: function() {
- return this.x * this.x + this.y * this.y;
- },
- length: function() {
- return Math.sqrt(this.x * this.x + this.y * this.y);
- },
- manhattanLength: function() {
- return Math.abs(this.x) + Math.abs(this.y);
- },
- normalize: function() {
- return this.divideScalar(this.length() || 1);
- },
- angle: function() {
- var angle = Math.atan2(this.y, this.x);
- if (angle < 0)
- angle += 2 * Math.PI;
- return angle;
- },
- distanceTo: function(v) {
- return Math.sqrt(this.distanceToSquared(v));
- },
- distanceToSquared: function(v) {
- var dx = this.x - v.x, dy = this.y - v.y;
- return dx * dx + dy * dy;
- },
- manhattanDistanceTo: function(v) {
- return Math.abs(this.x - v.x) + Math.abs(this.y - v.y);
- },
- setLength: function(length) {
- return this.normalize().multiplyScalar(length);
- },
- lerp: function(v, alpha) {
- this.x += (v.x - this.x) * alpha;
- this.y += (v.y - this.y) * alpha;
- return this;
- },
- lerpVectors: function(v1, v2, alpha) {
- return this.subVectors(v2, v1).multiplyScalar(alpha).add(v1);
- },
- equals: function(v) {
- return v.x === this.x && v.y === this.y;
- },
- fromArray: function(array, offset) {
- if (offset === void 0)
- offset = 0;
- this.x = array[offset];
- this.y = array[offset + 1];
- return this;
- },
- toArray: function(array, offset) {
- if (array === void 0)
- array = [];
- if (offset === void 0)
- offset = 0;
- array[offset] = this.x;
- array[offset + 1] = this.y;
- return array;
- },
- fromBufferAttribute: function(attribute, index, offset) {
- if (offset !== void 0) {
- console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute().");
- }
- this.x = attribute.getX(index);
- this.y = attribute.getY(index);
- return this;
- },
- rotateAround: function(center, angle) {
- var c = Math.cos(angle), s = Math.sin(angle);
- var x = this.x - center.x;
- var y = this.y - center.y;
- this.x = x * c - y * s + center.x;
- this.y = x * s + y * c + center.y;
- return this;
- }
- });
- function Matrix3() {
- this.elements = [
- 1,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 1
- ];
- if (arguments.length > 0) {
- console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.");
- }
- }
- Object.assign(Matrix3.prototype, {
- isMatrix3: true,
- set: function(n11, n12, n13, n21, n22, n23, n31, n32, n33) {
- var te = this.elements;
- te[0] = n11;
- te[1] = n21;
- te[2] = n31;
- te[3] = n12;
- te[4] = n22;
- te[5] = n32;
- te[6] = n13;
- te[7] = n23;
- te[8] = n33;
- return this;
- },
- identity: function() {
- this.set(
- 1,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 1
- );
- return this;
- },
- clone: function() {
- return new this.constructor().fromArray(this.elements);
- },
- copy: function(m) {
- var te = this.elements;
- var me = m.elements;
- te[0] = me[0];
- te[1] = me[1];
- te[2] = me[2];
- te[3] = me[3];
- te[4] = me[4];
- te[5] = me[5];
- te[6] = me[6];
- te[7] = me[7];
- te[8] = me[8];
- return this;
- },
- setFromMatrix4: function(m) {
- var me = m.elements;
- this.set(
- me[0],
- me[4],
- me[8],
- me[1],
- me[5],
- me[9],
- me[2],
- me[6],
- me[10]
- );
- return this;
- },
- multiply: function(m) {
- return this.multiplyMatrices(this, m);
- },
- premultiply: function(m) {
- return this.multiplyMatrices(m, this);
- },
- multiplyMatrices: function(a, b) {
- var ae = a.elements;
- var be = b.elements;
- var te = this.elements;
- var a11 = ae[0], a12 = ae[3], a13 = ae[6];
- var a21 = ae[1], a22 = ae[4], a23 = ae[7];
- var a31 = ae[2], a32 = ae[5], a33 = ae[8];
- var b11 = be[0], b12 = be[3], b13 = be[6];
- var b21 = be[1], b22 = be[4], b23 = be[7];
- var b31 = be[2], b32 = be[5], b33 = be[8];
- te[0] = a11 * b11 + a12 * b21 + a13 * b31;
- te[3] = a11 * b12 + a12 * b22 + a13 * b32;
- te[6] = a11 * b13 + a12 * b23 + a13 * b33;
- te[1] = a21 * b11 + a22 * b21 + a23 * b31;
- te[4] = a21 * b12 + a22 * b22 + a23 * b32;
- te[7] = a21 * b13 + a22 * b23 + a23 * b33;
- te[2] = a31 * b11 + a32 * b21 + a33 * b31;
- te[5] = a31 * b12 + a32 * b22 + a33 * b32;
- te[8] = a31 * b13 + a32 * b23 + a33 * b33;
- return this;
- },
- multiplyScalar: function(s) {
- var te = this.elements;
- te[0] *= s;
- te[3] *= s;
- te[6] *= s;
- te[1] *= s;
- te[4] *= s;
- te[7] *= s;
- te[2] *= s;
- te[5] *= s;
- te[8] *= s;
- return this;
- },
- determinant: function() {
- var te = this.elements;
- 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];
- return a * e * i2 - a * f * h - b * d * i2 + b * f * g + c * d * h - c * e * g;
- },
- getInverse: function(matrix, throwOnDegenerate) {
- if (matrix && matrix.isMatrix4) {
- console.error("THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument.");
- }
- 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;
- if (det === 0) {
- var msg = "THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0";
- if (throwOnDegenerate === true) {
- throw new Error(msg);
- } else {
- console.warn(msg);
- }
- return this.identity();
- }
- var detInv = 1 / det;
- te[0] = t11 * detInv;
- te[1] = (n31 * n23 - n33 * n21) * detInv;
- te[2] = (n32 * n21 - n31 * n22) * detInv;
- te[3] = t12 * detInv;
- te[4] = (n33 * n11 - n31 * n13) * detInv;
- te[5] = (n31 * n12 - n32 * n11) * detInv;
- te[6] = t13 * detInv;
- te[7] = (n21 * n13 - n23 * n11) * detInv;
- te[8] = (n22 * n11 - n21 * n12) * detInv;
- return this;
- },
- transpose: function() {
- var tmp2, m = this.elements;
- tmp2 = m[1];
- m[1] = m[3];
- m[3] = tmp2;
- tmp2 = m[2];
- m[2] = m[6];
- m[6] = tmp2;
- tmp2 = m[5];
- m[5] = m[7];
- m[7] = tmp2;
- return this;
- },
- getNormalMatrix: function(matrix4) {
- return this.setFromMatrix4(matrix4).getInverse(this).transpose();
- },
- transposeIntoArray: function(r) {
- var m = this.elements;
- r[0] = m[0];
- r[1] = m[3];
- r[2] = m[6];
- r[3] = m[1];
- r[4] = m[4];
- r[5] = m[7];
- r[6] = m[2];
- r[7] = m[5];
- r[8] = m[8];
- return this;
- },
- setUvTransform: function(tx, ty, sx, sy, rotation, cx, cy) {
- var c = Math.cos(rotation);
- var s = Math.sin(rotation);
- this.set(
- sx * c,
- sx * s,
- -sx * (c * cx + s * cy) + cx + tx,
- -sy * s,
- sy * c,
- -sy * (-s * cx + c * cy) + cy + ty,
- 0,
- 0,
- 1
- );
- },
- scale: function(sx, sy) {
- var te = this.elements;
- te[0] *= sx;
- te[3] *= sx;
- te[6] *= sx;
- te[1] *= sy;
- te[4] *= sy;
- te[7] *= sy;
- return this;
- },
- rotate: function(theta) {
- var c = Math.cos(theta);
- var s = Math.sin(theta);
- var te = this.elements;
- var a11 = te[0], a12 = te[3], a13 = te[6];
- var a21 = te[1], a22 = te[4], a23 = te[7];
- te[0] = c * a11 + s * a21;
- te[3] = c * a12 + s * a22;
- te[6] = c * a13 + s * a23;
- te[1] = -s * a11 + c * a21;
- te[4] = -s * a12 + c * a22;
- te[7] = -s * a13 + c * a23;
- return this;
- },
- translate: function(tx, ty) {
- var te = this.elements;
- te[0] += tx * te[2];
- te[3] += tx * te[5];
- te[6] += tx * te[8];
- te[1] += ty * te[2];
- te[4] += ty * te[5];
- te[7] += ty * te[8];
- return this;
- },
- equals: function(matrix) {
- var te = this.elements;
- var me = matrix.elements;
- for (var i2 = 0; i2 < 9; i2++) {
- if (te[i2] !== me[i2])
- return false;
- }
- return true;
- },
- fromArray: function(array, offset) {
- if (offset === void 0)
- offset = 0;
- for (var i2 = 0; i2 < 9; i2++) {
- this.elements[i2] = array[i2 + offset];
- }
- return this;
- },
- toArray: function(array, offset) {
- if (array === void 0)
- array = [];
- if (offset === void 0)
- offset = 0;
- var te = this.elements;
- array[offset] = te[0];
- array[offset + 1] = te[1];
- array[offset + 2] = te[2];
- array[offset + 3] = te[3];
- array[offset + 4] = te[4];
- array[offset + 5] = te[5];
- array[offset + 6] = te[6];
- array[offset + 7] = te[7];
- array[offset + 8] = te[8];
- return array;
- }
- });
- var _canvas;
- var ImageUtils = {
- getDataURL: function(image) {
- var canvas;
- if (typeof HTMLCanvasElement == "undefined") {
- return image.src;
- } else if (image instanceof HTMLCanvasElement) {
- canvas = image;
- } else {
- if (_canvas === void 0)
- _canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
- _canvas.width = image.width;
- _canvas.height = image.height;
- var context = _canvas.getContext("2d");
- if (image instanceof ImageData) {
- context.putImageData(image, 0, 0);
- } else {
- context.drawImage(image, 0, 0, image.width, image.height);
- }
- canvas = _canvas;
- }
- if (canvas.width > 2048 || canvas.height > 2048) {
- return canvas.toDataURL("image/jpeg", 0.6);
- } else {
- return canvas.toDataURL("image/png");
- }
- }
- };
- var textureId = 0;
- function Texture(image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding) {
- Object.defineProperty(this, "id", { value: textureId++ });
- this.uuid = MathUtils.generateUUID();
- this.name = "";
- this.image = image !== void 0 ? image : Texture.DEFAULT_IMAGE;
- this.mipmaps = [];
- this.mapping = mapping !== void 0 ? mapping : Texture.DEFAULT_MAPPING;
- this.wrapS = wrapS !== void 0 ? wrapS : ClampToEdgeWrapping;
- this.wrapT = wrapT !== void 0 ? wrapT : ClampToEdgeWrapping;
- this.magFilter = magFilter !== void 0 ? magFilter : LinearFilter;
- this.minFilter = minFilter !== void 0 ? minFilter : LinearMipmapLinearFilter;
- this.anisotropy = anisotropy !== void 0 ? anisotropy : 1;
- this.format = format !== void 0 ? format : RGBAFormat;
- this.internalFormat = null;
- this.type = type !== void 0 ? type : UnsignedByteType;
- this.offset = new Vector2(0, 0);
- this.repeat = new Vector2(1, 1);
- this.center = new Vector2(0, 0);
- this.rotation = 0;
- this.matrixAutoUpdate = true;
- this.matrix = new Matrix3();
- this.generateMipmaps = true;
- this.premultiplyAlpha = false;
- this.flipY = true;
- this.unpackAlignment = 4;
- this.encoding = encoding !== void 0 ? encoding : LinearEncoding;
- this.version = 0;
- this.onUpdate = null;
- }
- Texture.DEFAULT_IMAGE = void 0;
- Texture.DEFAULT_MAPPING = UVMapping;
- Texture.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
- constructor: Texture,
- isTexture: true,
- updateMatrix: function() {
- this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);
- },
- clone: function() {
- return new this.constructor().copy(this);
- },
- copy: function(source) {
- this.name = source.name;
- this.image = source.image;
- this.mipmaps = source.mipmaps.slice(0);
- this.mapping = source.mapping;
- this.wrapS = source.wrapS;
- this.wrapT = source.wrapT;
- this.magFilter = source.magFilter;
- this.minFilter = source.minFilter;
- this.anisotropy = source.anisotropy;
- this.format = source.format;
- this.internalFormat = source.internalFormat;
- this.type = source.type;
- this.offset.copy(source.offset);
- this.repeat.copy(source.repeat);
- this.center.copy(source.center);
- this.rotation = source.rotation;
- this.matrixAutoUpdate = source.matrixAutoUpdate;
- this.matrix.copy(source.matrix);
- this.generateMipmaps = source.generateMipmaps;
- this.premultiplyAlpha = source.premultiplyAlpha;
- this.flipY = source.flipY;
- this.unpackAlignment = source.unpackAlignment;
- this.encoding = source.encoding;
- return this;
- },
- toJSON: function(meta) {
- var isRootObject = meta === void 0 || typeof meta === "string";
- if (!isRootObject && meta.textures[this.uuid] !== void 0) {
- return meta.textures[this.uuid];
- }
- var output = {
- metadata: {
- version: 4.5,
- type: "Texture",
- generator: "Texture.toJSON"
- },
- uuid: this.uuid,
- name: this.name,
- mapping: this.mapping,
- repeat: [this.repeat.x, this.repeat.y],
- offset: [this.offset.x, this.offset.y],
- center: [this.center.x, this.center.y],
- rotation: this.rotation,
- wrap: [this.wrapS, this.wrapT],
- format: this.format,
- type: this.type,
- encoding: this.encoding,
- minFilter: this.minFilter,
- magFilter: this.magFilter,
- anisotropy: this.anisotropy,
- flipY: this.flipY,
- premultiplyAlpha: this.premultiplyAlpha,
- unpackAlignment: this.unpackAlignment
- };
- if (this.image !== void 0) {
- var image = this.image;
- if (image.uuid === void 0) {
- image.uuid = MathUtils.generateUUID();
- }
- if (!isRootObject && meta.images[image.uuid] === void 0) {
- var url;
- if (Array.isArray(image)) {
- url = [];
- for (var i2 = 0, l = image.length; i2 < l; i2++) {
- url.push(ImageUtils.getDataURL(image[i2]));
- }
- } else {
- url = ImageUtils.getDataURL(image);
- }
- meta.images[image.uuid] = {
- uuid: image.uuid,
- url
- };
- }
- output.image = image.uuid;
- }
- if (!isRootObject) {
- meta.textures[this.uuid] = output;
- }
- return output;
- },
- dispose: function() {
- this.dispatchEvent({ type: "dispose" });
- },
- transformUv: function(uv) {
- if (this.mapping !== UVMapping)
- return uv;
- uv.applyMatrix3(this.matrix);
- if (uv.x < 0 || uv.x > 1) {
- switch (this.wrapS) {
- case RepeatWrapping:
- uv.x = uv.x - Math.floor(uv.x);
- break;
- case ClampToEdgeWrapping:
- uv.x = uv.x < 0 ? 0 : 1;
- break;
- case MirroredRepeatWrapping:
- if (Math.abs(Math.floor(uv.x) % 2) === 1) {
- uv.x = Math.ceil(uv.x) - uv.x;
- } else {
- uv.x = uv.x - Math.floor(uv.x);
- }
- break;
- }
- }
- if (uv.y < 0 || uv.y > 1) {
- switch (this.wrapT) {
- case RepeatWrapping:
- uv.y = uv.y - Math.floor(uv.y);
- break;
- case ClampToEdgeWrapping:
- uv.y = uv.y < 0 ? 0 : 1;
- break;
- case MirroredRepeatWrapping:
- if (Math.abs(Math.floor(uv.y) % 2) === 1) {
- uv.y = Math.ceil(uv.y) - uv.y;
- } else {
- uv.y = uv.y - Math.floor(uv.y);
- }
- break;
- }
- }
- if (this.flipY) {
- uv.y = 1 - uv.y;
- }
- return uv;
- }
- });
- Object.defineProperty(Texture.prototype, "needsUpdate", {
- set: function(value) {
- if (value === true)
- this.version++;
- }
- });
- function Vector4(x, y, z, w) {
- this.x = x || 0;
- this.y = y || 0;
- this.z = z || 0;
- this.w = w !== void 0 ? w : 1;
- }
- Object.defineProperties(Vector4.prototype, {
- "width": {
- get: function() {
- return this.z;
- },
- set: function(value) {
- this.z = value;
- }
- },
- "height": {
- get: function() {
- return this.w;
- },
- set: function(value) {
- this.w = value;
- }
- }
- });
- Object.assign(Vector4.prototype, {
- isVector4: true,
- set: function(x, y, z, w) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- return this;
- },
- setScalar: function(scalar) {
- this.x = scalar;
- this.y = scalar;
- this.z = scalar;
- this.w = scalar;
- return this;
- },
- setX: function(x) {
- this.x = x;
- return this;
- },
- setY: function(y) {
- this.y = y;
- return this;
- },
- setZ: function(z) {
- this.z = z;
- return this;
- },
- setW: function(w) {
- this.w = w;
- return this;
- },
- setComponent: function(index, value) {
- switch (index) {
- case 0:
- this.x = value;
- break;
- case 1:
- this.y = value;
- break;
- case 2:
- this.z = value;
- break;
- case 3:
- this.w = value;
- break;
- default:
- throw new Error("index is out of range: " + index);
- }
- return this;
- },
- getComponent: function(index) {
- switch (index) {
- case 0:
- return this.x;
- case 1:
- return this.y;
- case 2:
- return this.z;
- case 3:
- return this.w;
- default:
- throw new Error("index is out of range: " + index);
- }
- },
- clone: function() {
- return new this.constructor(this.x, this.y, this.z, this.w);
- },
- copy: function(v) {
- this.x = v.x;
- this.y = v.y;
- this.z = v.z;
- this.w = v.w !== void 0 ? v.w : 1;
- return this;
- },
- add: function(v, w) {
- if (w !== void 0) {
- console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.");
- return this.addVectors(v, w);
- }
- this.x += v.x;
- this.y += v.y;
- this.z += v.z;
- this.w += v.w;
- return this;
- },
- addScalar: function(s) {
- this.x += s;
- this.y += s;
- this.z += s;
- this.w += s;
- return this;
- },
- addVectors: function(a, b) {
- this.x = a.x + b.x;
- this.y = a.y + b.y;
- this.z = a.z + b.z;
- this.w = a.w + b.w;
- return this;
- },
- addScaledVector: function(v, s) {
- this.x += v.x * s;
- this.y += v.y * s;
- this.z += v.z * s;
- this.w += v.w * s;
- return this;
- },
- sub: function(v, w) {
- if (w !== void 0) {
- console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.");
- return this.subVectors(v, w);
- }
- this.x -= v.x;
- this.y -= v.y;
- this.z -= v.z;
- this.w -= v.w;
- return this;
- },
- subScalar: function(s) {
- this.x -= s;
- this.y -= s;
- this.z -= s;
- this.w -= s;
- return this;
- },
- subVectors: function(a, b) {
- this.x = a.x - b.x;
- this.y = a.y - b.y;
- this.z = a.z - b.z;
- this.w = a.w - b.w;
- return this;
- },
- multiplyScalar: function(scalar) {
- this.x *= scalar;
- this.y *= scalar;
- this.z *= scalar;
- this.w *= scalar;
- return this;
- },
- applyMatrix4: function(m) {
- var x = this.x, y = this.y, z = this.z, w = this.w;
- var e = m.elements;
- this.x = e[0] * x + e[4] * y + e[8] * z + e[12] * w;
- this.y = e[1] * x + e[5] * y + e[9] * z + e[13] * w;
- this.z = e[2] * x + e[6] * y + e[10] * z + e[14] * w;
- this.w = e[3] * x + e[7] * y + e[11] * z + e[15] * w;
- return this;
- },
- divideScalar: function(scalar) {
- return this.multiplyScalar(1 / scalar);
- },
- setAxisAngleFromQuaternion: function(q) {
- this.w = 2 * Math.acos(q.w);
- var s = Math.sqrt(1 - q.w * q.w);
- if (s < 1e-4) {
- this.x = 1;
- this.y = 0;
- this.z = 0;
- } else {
- this.x = q.x / s;
- this.y = q.y / s;
- this.z = q.z / s;
- }
- return this;
- },
- setAxisAngleFromRotationMatrix: function(m) {
- 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];
- if (Math.abs(m12 - m21) < epsilon && Math.abs(m13 - m31) < epsilon && Math.abs(m23 - m32) < epsilon) {
- if (Math.abs(m12 + m21) < epsilon2 && Math.abs(m13 + m31) < epsilon2 && Math.abs(m23 + m32) < epsilon2 && Math.abs(m11 + m22 + m33 - 3) < epsilon2) {
- this.set(1, 0, 0, 0);
- return this;
- }
- angle = Math.PI;
- var xx = (m11 + 1) / 2;
- var yy = (m22 + 1) / 2;
- var zz = (m33 + 1) / 2;
- var xy = (m12 + m21) / 4;
- var xz = (m13 + m31) / 4;
- var yz = (m23 + m32) / 4;
- if (xx > yy && xx > zz) {
- if (xx < epsilon) {
- x = 0;
- y = 0.707106781;
- z = 0.707106781;
- } else {
- x = Math.sqrt(xx);
- y = xy / x;
- z = xz / x;
- }
- } else if (yy > zz) {
- if (yy < epsilon) {
- x = 0.707106781;
- y = 0;
- z = 0.707106781;
- } else {
- y = Math.sqrt(yy);
- x = xy / y;
- z = yz / y;
- }
- } else {
- if (zz < epsilon) {
- x = 0.707106781;
- y = 0.707106781;
- z = 0;
- } else {
- z = Math.sqrt(zz);
- x = xz / z;
- y = yz / z;
- }
- }
- this.set(x, y, z, angle);
- return this;
- }
- var s = Math.sqrt((m32 - m23) * (m32 - m23) + (m13 - m31) * (m13 - m31) + (m21 - m12) * (m21 - m12));
- if (Math.abs(s) < 1e-3)
- s = 1;
- this.x = (m32 - m23) / s;
- this.y = (m13 - m31) / s;
- this.z = (m21 - m12) / s;
- this.w = Math.acos((m11 + m22 + m33 - 1) / 2);
- return this;
- },
- min: function(v) {
- this.x = Math.min(this.x, v.x);
- this.y = Math.min(this.y, v.y);
- this.z = Math.min(this.z, v.z);
- this.w = Math.min(this.w, v.w);
- return this;
- },
- max: function(v) {
- this.x = Math.max(this.x, v.x);
- this.y = Math.max(this.y, v.y);
- this.z = Math.max(this.z, v.z);
- this.w = Math.max(this.w, v.w);
- return this;
- },
- clamp: function(min, max) {
- this.x = Math.max(min.x, Math.min(max.x, this.x));
- this.y = Math.max(min.y, Math.min(max.y, this.y));
- this.z = Math.max(min.z, Math.min(max.z, this.z));
- this.w = Math.max(min.w, Math.min(max.w, this.w));
- return this;
- },
- clampScalar: function(minVal, maxVal) {
- this.x = Math.max(minVal, Math.min(maxVal, this.x));
- this.y = Math.max(minVal, Math.min(maxVal, this.y));
- this.z = Math.max(minVal, Math.min(maxVal, this.z));
- this.w = Math.max(minVal, Math.min(maxVal, this.w));
- return this;
- },
- clampLength: function(min, max) {
- var length = this.length();
- return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));
- },
- floor: function() {
- this.x = Math.floor(this.x);
- this.y = Math.floor(this.y);
- this.z = Math.floor(this.z);
- this.w = Math.floor(this.w);
- return this;
- },
- ceil: function() {
- this.x = Math.ceil(this.x);
- this.y = Math.ceil(this.y);
- this.z = Math.ceil(this.z);
- this.w = Math.ceil(this.w);
- return this;
- },
- round: function() {
- this.x = Math.round(this.x);
- this.y = Math.round(this.y);
- this.z = Math.round(this.z);
- this.w = Math.round(this.w);
- return this;
- },
- roundToZero: function() {
- this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);
- this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);
- this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z);
- this.w = this.w < 0 ? Math.ceil(this.w) : Math.floor(this.w);
- return this;
- },
- negate: function() {
- this.x = -this.x;
- this.y = -this.y;
- this.z = -this.z;
- this.w = -this.w;
- return this;
- },
- dot: function(v) {
- return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
- },
- lengthSq: function() {
- return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
- },
- length: function() {
- return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
- },
- manhattanLength: function() {
- return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w);
- },
- normalize: function() {
- return this.divideScalar(this.length() || 1);
- },
- setLength: function(length) {
- return this.normalize().multiplyScalar(length);
- },
- lerp: function(v, alpha) {
- this.x += (v.x - this.x) * alpha;
- this.y += (v.y - this.y) * alpha;
- this.z += (v.z - this.z) * alpha;
- this.w += (v.w - this.w) * alpha;
- return this;
- },
- lerpVectors: function(v1, v2, alpha) {
- return this.subVectors(v2, v1).multiplyScalar(alpha).add(v1);
- },
- equals: function(v) {
- return v.x === this.x && v.y === this.y && v.z === this.z && v.w === this.w;
- },
- fromArray: function(array, offset) {
- if (offset === void 0)
- offset = 0;
- this.x = array[offset];
- this.y = array[offset + 1];
- this.z = array[offset + 2];
- this.w = array[offset + 3];
- return this;
- },
- toArray: function(array, offset) {
- if (array === void 0)
- array = [];
- if (offset === void 0)
- offset = 0;
- array[offset] = this.x;
- array[offset + 1] = this.y;
- array[offset + 2] = this.z;
- array[offset + 3] = this.w;
- return array;
- },
- fromBufferAttribute: function(attribute, index, offset) {
- if (offset !== void 0) {
- console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute().");
- }
- this.x = attribute.getX(index);
- this.y = attribute.getY(index);
- this.z = attribute.getZ(index);
- this.w = attribute.getW(index);
- return this;
- }
- });
- function WebGLRenderTarget(width, height, options) {
- this.width = width;
- this.height = height;
- this.scissor = new Vector4(0, 0, width, height);
- this.scissorTest = false;
- this.viewport = new Vector4(0, 0, width, height);
- options = options || {};
- this.texture = new Texture(void 0, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding);
- this.texture.image = {};
- this.texture.image.width = width;
- this.texture.image.height = height;
- this.texture.generateMipmaps = options.generateMipmaps !== void 0 ? options.generateMipmaps : false;
- this.texture.minFilter = options.minFilter !== void 0 ? options.minFilter : LinearFilter;
- this.depthBuffer = options.depthBuffer !== void 0 ? options.depthBuffer : true;
- this.stencilBuffer = options.stencilBuffer !== void 0 ? options.stencilBuffer : true;
- this.depthTexture = options.depthTexture !== void 0 ? options.depthTexture : null;
- }
- WebGLRenderTarget.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
- constructor: WebGLRenderTarget,
- isWebGLRenderTarget: true,
- setSize: function(width, height) {
- if (this.width !== width || this.height !== height) {
- this.width = width;
- this.height = height;
- this.texture.image.width = width;
- this.texture.image.height = height;
- this.dispose();
- }
- this.viewport.set(0, 0, width, height);
- this.scissor.set(0, 0, width, height);
- },
- clone: function() {
- return new this.constructor().copy(this);
- },
- copy: function(source) {
- this.width = source.width;
- this.height = source.height;
- this.viewport.copy(source.viewport);
- this.texture = source.texture.clone();
- this.depthBuffer = source.depthBuffer;
- this.stencilBuffer = source.stencilBuffer;
- this.depthTexture = source.depthTexture;
- return this;
- },
- dispose: function() {
- this.dispatchEvent({ type: "dispose" });
- }
- });
- function WebGLMultisampleRenderTarget(width, height, options) {
- WebGLRenderTarget.call(this, width, height, options);
- this.samples = 4;
- }
- WebGLMultisampleRenderTarget.prototype = Object.assign(Object.create(WebGLRenderTarget.prototype), {
- constructor: WebGLMultisampleRenderTarget,
- isWebGLMultisampleRenderTarget: true,
- copy: function(source) {
- WebGLRenderTarget.prototype.copy.call(this, source);
- this.samples = source.samples;
- return this;
- }
- });
- function Quaternion(x, y, z, w) {
- this._x = x || 0;
- this._y = y || 0;
- this._z = z || 0;
- this._w = w !== void 0 ? w : 1;
- }
- Object.assign(Quaternion, {
- slerp: function(qa, qb, qm, t) {
- return qm.copy(qa).slerp(qb, t);
- },
- slerpFlat: function(dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t) {
- 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];
- if (w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1) {
- var s = 1 - t, cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1, dir = cos >= 0 ? 1 : -1, sqrSin = 1 - cos * cos;
- if (sqrSin > Number.EPSILON) {
- var sin = Math.sqrt(sqrSin), len = Math.atan2(sin, cos * dir);
- s = Math.sin(s * len) / sin;
- t = Math.sin(t * len) / sin;
- }
- var tDir = t * dir;
- x0 = x0 * s + x1 * tDir;
- y0 = y0 * s + y1 * tDir;
- z0 = z0 * s + z1 * tDir;
- w0 = w0 * s + w1 * tDir;
- if (s === 1 - t) {
- var f = 1 / Math.sqrt(x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0);
- x0 *= f;
- y0 *= f;
- z0 *= f;
- w0 *= f;
- }
- }
- dst[dstOffset] = x0;
- dst[dstOffset + 1] = y0;
- dst[dstOffset + 2] = z0;
- dst[dstOffset + 3] = w0;
- }
- });
- Object.defineProperties(Quaternion.prototype, {
- x: {
- get: function() {
- return this._x;
- },
- set: function(value) {
- this._x = value;
- this._onChangeCallback();
- }
- },
- y: {
- get: function() {
- return this._y;
- },
- set: function(value) {
- this._y = value;
- this._onChangeCallback();
- }
- },
- z: {
- get: function() {
- return this._z;
- },
- set: function(value) {
- this._z = value;
- this._onChangeCallback();
- }
- },
- w: {
- get: function() {
- return this._w;
- },
- set: function(value) {
- this._w = value;
- this._onChangeCallback();
- }
- }
- });
- Object.assign(Quaternion.prototype, {
- isQuaternion: true,
- set: function(x, y, z, w) {
- this._x = x;
- this._y = y;
- this._z = z;
- this._w = w;
- this._onChangeCallback();
- return this;
- },
- clone: function() {
- return new this.constructor(this._x, this._y, this._z, this._w);
- },
- copy: function(quaternion) {
- this._x = quaternion.x;
- this._y = quaternion.y;
- this._z = quaternion.z;
- this._w = quaternion.w;
- this._onChangeCallback();
- return this;
- },
- setFromEuler: function(euler, update) {
- if (!(euler && euler.isEuler)) {
- throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");
- }
- var x = euler._x, y = euler._y, z = euler._z, order = euler.order;
- var cos = Math.cos;
- var sin = Math.sin;
- var c1 = cos(x / 2);
- var c2 = cos(y / 2);
- var c3 = cos(z / 2);
- var s1 = sin(x / 2);
- var s2 = sin(y / 2);
- var s3 = sin(z / 2);
- if (order === "XYZ") {
- this._x = s1 * c2 * c3 + c1 * s2 * s3;
- this._y = c1 * s2 * c3 - s1 * c2 * s3;
- this._z = c1 * c2 * s3 + s1 * s2 * c3;
- this._w = c1 * c2 * c3 - s1 * s2 * s3;
- } else if (order === "YXZ") {
- this._x = s1 * c2 * c3 + c1 * s2 * s3;
- this._y = c1 * s2 * c3 - s1 * c2 * s3;
- this._z = c1 * c2 * s3 - s1 * s2 * c3;
- this._w = c1 * c2 * c3 + s1 * s2 * s3;
- } else if (order === "ZXY") {
- this._x = s1 * c2 * c3 - c1 * s2 * s3;
- this._y = c1 * s2 * c3 + s1 * c2 * s3;
- this._z = c1 * c2 * s3 + s1 * s2 * c3;
- this._w = c1 * c2 * c3 - s1 * s2 * s3;
- } else if (order === "ZYX") {
- this._x = s1 * c2 * c3 - c1 * s2 * s3;
- this._y = c1 * s2 * c3 + s1 * c2 * s3;
- this._z = c1 * c2 * s3 - s1 * s2 * c3;
- this._w = c1 * c2 * c3 + s1 * s2 * s3;
- } else if (order === "YZX") {
- this._x = s1 * c2 * c3 + c1 * s2 * s3;
- this._y = c1 * s2 * c3 + s1 * c2 * s3;
- this._z = c1 * c2 * s3 - s1 * s2 * c3;
- this._w = c1 * c2 * c3 - s1 * s2 * s3;
- } else if (order === "XZY") {
- this._x = s1 * c2 * c3 - c1 * s2 * s3;
- this._y = c1 * s2 * c3 - s1 * c2 * s3;
- this._z = c1 * c2 * s3 + s1 * s2 * c3;
- this._w = c1 * c2 * c3 + s1 * s2 * s3;
- }
- if (update !== false)
- this._onChangeCallback();
- return this;
- },
- setFromAxisAngle: function(axis, angle) {
- var halfAngle = angle / 2, s = Math.sin(halfAngle);
- this._x = axis.x * s;
- this._y = axis.y * s;
- this._z = axis.z * s;
- this._w = Math.cos(halfAngle);
- this._onChangeCallback();
- return this;
- },
- setFromRotationMatrix: function(m) {
- 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;
- if (trace > 0) {
- s = 0.5 / Math.sqrt(trace + 1);
- this._w = 0.25 / s;
- this._x = (m32 - m23) * s;
- this._y = (m13 - m31) * s;
- this._z = (m21 - m12) * s;
- } else if (m11 > m22 && m11 > m33) {
- s = 2 * Math.sqrt(1 + m11 - m22 - m33);
- this._w = (m32 - m23) / s;
- this._x = 0.25 * s;
- this._y = (m12 + m21) / s;
- this._z = (m13 + m31) / s;
- } else if (m22 > m33) {
- s = 2 * Math.sqrt(1 + m22 - m11 - m33);
- this._w = (m13 - m31) / s;
- this._x = (m12 + m21) / s;
- this._y = 0.25 * s;
- this._z = (m23 + m32) / s;
- } else {
- s = 2 * Math.sqrt(1 + m33 - m11 - m22);
- this._w = (m21 - m12) / s;
- this._x = (m13 + m31) / s;
- this._y = (m23 + m32) / s;
- this._z = 0.25 * s;
- }
- this._onChangeCallback();
- return this;
- },
- setFromUnitVectors: function(vFrom, vTo) {
- var EPS = 1e-6;
- var r = vFrom.dot(vTo) + 1;
- if (r < EPS) {
- r = 0;
- if (Math.abs(vFrom.x) > Math.abs(vFrom.z)) {
- this._x = -vFrom.y;
- this._y = vFrom.x;
- this._z = 0;
- this._w = r;
- } else {
- this._x = 0;
- this._y = -vFrom.z;
- this._z = vFrom.y;
- this._w = r;
- }
- } else {
- this._x = vFrom.y * vTo.z - vFrom.z * vTo.y;
- this._y = vFrom.z * vTo.x - vFrom.x * vTo.z;
- this._z = vFrom.x * vTo.y - vFrom.y * vTo.x;
- this._w = r;
- }
- return this.normalize();
- },
- angleTo: function(q) {
- return 2 * Math.acos(Math.abs(MathUtils.clamp(this.dot(q), -1, 1)));
- },
- rotateTowards: function(q, step) {
- var angle = this.angleTo(q);
- if (angle === 0)
- return this;
- var t = Math.min(1, step / angle);
- this.slerp(q, t);
- return this;
- },
- inverse: function() {
- return this.conjugate();
- },
- conjugate: function() {
- this._x *= -1;
- this._y *= -1;
- this._z *= -1;
- this._onChangeCallback();
- return this;
- },
- dot: function(v) {
- return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
- },
- lengthSq: function() {
- return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
- },
- length: function() {
- return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
- },
- normalize: function() {
- var l = this.length();
- if (l === 0) {
- this._x = 0;
- this._y = 0;
- this._z = 0;
- this._w = 1;
- } else {
- l = 1 / l;
- this._x = this._x * l;
- this._y = this._y * l;
- this._z = this._z * l;
- this._w = this._w * l;
- }
- this._onChangeCallback();
- return this;
- },
- multiply: function(q, p) {
- if (p !== void 0) {
- console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.");
- return this.multiplyQuaternions(q, p);
- }
- return this.multiplyQuaternions(this, q);
- },
- premultiply: function(q) {
- return this.multiplyQuaternions(q, this);
- },
- multiplyQuaternions: function(a, b) {
- var qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;
- var qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;
- this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
- this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
- this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
- this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
- this._onChangeCallback();
- return this;
- },
- slerp: function(qb, t) {
- if (t === 0)
- return this;
- if (t === 1)
- return this.copy(qb);
- var x = this._x, y = this._y, z = this._z, w = this._w;
- var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;
- if (cosHalfTheta < 0) {
- this._w = -qb._w;
- this._x = -qb._x;
- this._y = -qb._y;
- this._z = -qb._z;
- cosHalfTheta = -cosHalfTheta;
- } else {
- this.copy(qb);
- }
- if (cosHalfTheta >= 1) {
- this._w = w;
- this._x = x;
- this._y = y;
- this._z = z;
- return this;
- }
- var sqrSinHalfTheta = 1 - cosHalfTheta * cosHalfTheta;
- if (sqrSinHalfTheta <= Number.EPSILON) {
- var s = 1 - t;
- this._w = s * w + t * this._w;
- this._x = s * x + t * this._x;
- this._y = s * y + t * this._y;
- this._z = s * z + t * this._z;
- this.normalize();
- this._onChangeCallback();
- return this;
- }
- var sinHalfTheta = Math.sqrt(sqrSinHalfTheta);
- var halfTheta = Math.atan2(sinHalfTheta, cosHalfTheta);
- var ratioA = Math.sin((1 - t) * halfTheta) / sinHalfTheta, ratioB = Math.sin(t * halfTheta) / sinHalfTheta;
- this._w = w * ratioA + this._w * ratioB;
- this._x = x * ratioA + this._x * ratioB;
- this._y = y * ratioA + this._y * ratioB;
- this._z = z * ratioA + this._z * ratioB;
- this._onChangeCallback();
- return this;
- },
- equals: function(quaternion) {
- return quaternion._x === this._x && quaternion._y === this._y && quaternion._z === this._z && quaternion._w === this._w;
- },
- fromArray: function(array, offset) {
- if (offset === void 0)
- offset = 0;
- this._x = array[offset];
- this._y = array[offset + 1];
- this._z = array[offset + 2];
- this._w = array[offset + 3];
- this._onChangeCallback();
- return this;
- },
- toArray: function(array, offset) {
- if (array === void 0)
- array = [];
- if (offset === void 0)
- offset = 0;
- array[offset] = this._x;
- array[offset + 1] = this._y;
- array[offset + 2] = this._z;
- array[offset + 3] = this._w;
- return array;
- },
- _onChange: function(callback) {
- this._onChangeCallback = callback;
- return this;
- },
- _onChangeCallback: function() {
- }
- });
- var _vector = new Vector3();
- var _quaternion = new Quaternion();
- function Vector3(x, y, z) {
- this.x = x || 0;
- this.y = y || 0;
- this.z = z || 0;
- }
- Object.assign(Vector3.prototype, {
- isVector3: true,
- set: function(x, y, z) {
- this.x = x;
- this.y = y;
- this.z = z;
- return this;
- },
- setScalar: function(scalar) {
- this.x = scalar;
- this.y = scalar;
- this.z = scalar;
- return this;
- },
- setX: function(x) {
- this.x = x;
- return this;
- },
- setY: function(y) {
- this.y = y;
- return this;
- },
- setZ: function(z) {
- this.z = z;
- return this;
- },
- setComponent: function(index, value) {
- switch (index) {
- case 0:
- this.x = value;
- break;
- case 1:
- this.y = value;
- break;
- case 2:
- this.z = value;
- break;
- default:
- throw new Error("index is out of range: " + index);
- }
- return this;
- },
- getComponent: function(index) {
- switch (index) {
- case 0:
- return this.x;
- case 1:
- return this.y;
- case 2:
- return this.z;
- default:
- throw new Error("index is out of range: " + index);
- }
- },
- clone: function() {
- return new this.constructor(this.x, this.y, this.z);
- },
- copy: function(v) {
- this.x = v.x;
- this.y = v.y;
- this.z = v.z;
- return this;
- },
- add: function(v, w) {
- if (w !== void 0) {
- console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.");
- return this.addVectors(v, w);
- }
- this.x += v.x;
- this.y += v.y;
- this.z += v.z;
- return this;
- },
- addScalar: function(s) {
- this.x += s;
- this.y += s;
- this.z += s;
- return this;
- },
- addVectors: function(a, b) {
- this.x = a.x + b.x;
- this.y = a.y + b.y;
- this.z = a.z + b.z;
- return this;
- },
- addScaledVector: function(v, s) {
- this.x += v.x * s;
- this.y += v.y * s;
- this.z += v.z * s;
- return this;
- },
- sub: function(v, w) {
- if (w !== void 0) {
- console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.");
- return this.subVectors(v, w);
- }
- this.x -= v.x;
- this.y -= v.y;
- this.z -= v.z;
- return this;
- },
- subScalar: function(s) {
- this.x -= s;
- this.y -= s;
- this.z -= s;
- return this;
- },
- subVectors: function(a, b) {
- this.x = a.x - b.x;
- this.y = a.y - b.y;
- this.z = a.z - b.z;
- return this;
- },
- multiply: function(v, w) {
- if (w !== void 0) {
- console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.");
- return this.multiplyVectors(v, w);
- }
- this.x *= v.x;
- this.y *= v.y;
- this.z *= v.z;
- return this;
- },
- multiplyScalar: function(scalar) {
- this.x *= scalar;
- this.y *= scalar;
- this.z *= scalar;
- return this;
- },
- multiplyVectors: function(a, b) {
- this.x = a.x * b.x;
- this.y = a.y * b.y;
- this.z = a.z * b.z;
- return this;
- },
- applyEuler: function(euler) {
- if (!(euler && euler.isEuler)) {
- console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");
- }
- return this.applyQuaternion(_quaternion.setFromEuler(euler));
- },
- applyAxisAngle: function(axis, angle) {
- return this.applyQuaternion(_quaternion.setFromAxisAngle(axis, angle));
- },
- applyMatrix3: function(m) {
- var x = this.x, y = this.y, z = this.z;
- var e = m.elements;
- this.x = e[0] * x + e[3] * y + e[6] * z;
- this.y = e[1] * x + e[4] * y + e[7] * z;
- this.z = e[2] * x + e[5] * y + e[8] * z;
- return this;
- },
- applyNormalMatrix: function(m) {
- return this.applyMatrix3(m).normalize();
- },
- applyMatrix4: function(m) {
- var x = this.x, y = this.y, z = this.z;
- var e = m.elements;
- var w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);
- this.x = (e[0] * x + e[4] * y + e[8] * z + e[12]) * w;
- this.y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;
- this.z = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;
- return this;
- },
- applyQuaternion: function(q) {
- var x = this.x, y = this.y, z = this.z;
- var qx = q.x, qy = q.y, qz = q.z, qw = q.w;
- var ix = qw * x + qy * z - qz * y;
- var iy = qw * y + qz * x - qx * z;
- var iz = qw * z + qx * y - qy * x;
- var iw = -qx * x - qy * y - qz * z;
- this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy;
- this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
- this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
- return this;
- },
- project: function(camera) {
- return this.applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix);
- },
- unproject: function(camera) {
- return this.applyMatrix4(camera.projectionMatrixInverse).applyMatrix4(camera.matrixWorld);
- },
- transformDirection: function(m) {
- var x = this.x, y = this.y, z = this.z;
- var e = m.elements;
- this.x = e[0] * x + e[4] * y + e[8] * z;
- this.y = e[1] * x + e[5] * y + e[9] * z;
- this.z = e[2] * x + e[6] * y + e[10] * z;
- return this.normalize();
- },
- divide: function(v) {
- this.x /= v.x;
- this.y /= v.y;
- this.z /= v.z;
- return this;
- },
- divideScalar: function(scalar) {
- return this.multiplyScalar(1 / scalar);
- },
- min: function(v) {
- this.x = Math.min(this.x, v.x);
- this.y = Math.min(this.y, v.y);
- this.z = Math.min(this.z, v.z);
- return this;
- },
- max: function(v) {
- this.x = Math.max(this.x, v.x);
- this.y = Math.max(this.y, v.y);
- this.z = Math.max(this.z, v.z);
- return this;
- },
- clamp: function(min, max) {
- this.x = Math.max(min.x, Math.min(max.x, this.x));
- this.y = Math.max(min.y, Math.min(max.y, this.y));
- this.z = Math.max(min.z, Math.min(max.z, this.z));
- return this;
- },
- clampScalar: function(minVal, maxVal) {
- this.x = Math.max(minVal, Math.min(maxVal, this.x));
- this.y = Math.max(minVal, Math.min(maxVal, this.y));
- this.z = Math.max(minVal, Math.min(maxVal, this.z));
- return this;
- },
- clampLength: function(min, max) {
- var length = this.length();
- return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));
- },
- floor: function() {
- this.x = Math.floor(this.x);
- this.y = Math.floor(this.y);
- this.z = Math.floor(this.z);
- return this;
- },
- ceil: function() {
- this.x = Math.ceil(this.x);
- this.y = Math.ceil(this.y);
- this.z = Math.ceil(this.z);
- return this;
- },
- round: function() {
- this.x = Math.round(this.x);
- this.y = Math.round(this.y);
- this.z = Math.round(this.z);
- return this;
- },
- roundToZero: function() {
- this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);
- this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);
- this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z);
- return this;
- },
- negate: function() {
- this.x = -this.x;
- this.y = -this.y;
- this.z = -this.z;
- return this;
- },
- dot: function(v) {
- return this.x * v.x + this.y * v.y + this.z * v.z;
- },
- // TODO lengthSquared?
- lengthSq: function() {
- return this.x * this.x + this.y * this.y + this.z * this.z;
- },
- length: function() {
- return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
- },
- manhattanLength: function() {
- return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
- },
- normalize: function() {
- return this.divideScalar(this.length() || 1);
- },
- setLength: function(length) {
- return this.normalize().multiplyScalar(length);
- },
- lerp: function(v, alpha) {
- this.x += (v.x - this.x) * alpha;
- this.y += (v.y - this.y) * alpha;
- this.z += (v.z - this.z) * alpha;
- return this;
- },
- lerpVectors: function(v1, v2, alpha) {
- return this.subVectors(v2, v1).multiplyScalar(alpha).add(v1);
- },
- cross: function(v, w) {
- if (w !== void 0) {
- console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.");
- return this.crossVectors(v, w);
- }
- return this.crossVectors(this, v);
- },
- crossVectors: function(a, b) {
- var ax = a.x, ay = a.y, az = a.z;
- var bx = b.x, by = b.y, bz = b.z;
- this.x = ay * bz - az * by;
- this.y = az * bx - ax * bz;
- this.z = ax * by - ay * bx;
- return this;
- },
- projectOnVector: function(v) {
- var denominator = v.lengthSq();
- if (denominator === 0)
- return this.set(0, 0, 0);
- var scalar = v.dot(this) / denominator;
- return this.copy(v).multiplyScalar(scalar);
- },
- projectOnPlane: function(planeNormal) {
- _vector.copy(this).projectOnVector(planeNormal);
- return this.sub(_vector);
- },
- reflect: function(normal) {
- return this.sub(_vector.copy(normal).multiplyScalar(2 * this.dot(normal)));
- },
- angleTo: function(v) {
- var denominator = Math.sqrt(this.lengthSq() * v.lengthSq());
- if (denominator === 0)
- return Math.PI / 2;
- var theta = this.dot(v) / denominator;
- return Math.acos(MathUtils.clamp(theta, -1, 1));
- },
- distanceTo: function(v) {
- return Math.sqrt(this.distanceToSquared(v));
- },
- distanceToSquared: function(v) {
- var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
- return dx * dx + dy * dy + dz * dz;
- },
- manhattanDistanceTo: function(v) {
- return Math.abs(this.x - v.x) + Math.abs(this.y - v.y) + Math.abs(this.z - v.z);
- },
- setFromSpherical: function(s) {
- return this.setFromSphericalCoords(s.radius, s.phi, s.theta);
- },
- setFromSphericalCoords: function(radius, phi, theta) {
- var sinPhiRadius = Math.sin(phi) * radius;
- this.x = sinPhiRadius * Math.sin(theta);
- this.y = Math.cos(phi) * radius;
- this.z = sinPhiRadius * Math.cos(theta);
- return this;
- },
- setFromCylindrical: function(c) {
- return this.setFromCylindricalCoords(c.radius, c.theta, c.y);
- },
- setFromCylindricalCoords: function(radius, theta, y) {
- this.x = radius * Math.sin(theta);
- this.y = y;
- this.z = radius * Math.cos(theta);
- return this;
- },
- setFromMatrixPosition: function(m) {
- var e = m.elements;
- this.x = e[12];
- this.y = e[13];
- this.z = e[14];
- return this;
- },
- setFromMatrixScale: function(m) {
- var sx = this.setFromMatrixColumn(m, 0).length();
- var sy = this.setFromMatrixColumn(m, 1).length();
- var sz = this.setFromMatrixColumn(m, 2).length();
- this.x = sx;
- this.y = sy;
- this.z = sz;
- return this;
- },
- setFromMatrixColumn: function(m, index) {
- return this.fromArray(m.elements, index * 4);
- },
- setFromMatrix3Column: function(m, index) {
- return this.fromArray(m.elements, index * 3);
- },
- equals: function(v) {
- return v.x === this.x && v.y === this.y && v.z === this.z;
- },
- fromArray: function(array, offset) {
- if (offset === void 0)
- offset = 0;
- this.x = array[offset];
- this.y = array[offset + 1];
- this.z = array[offset + 2];
- return this;
- },
- toArray: function(array, offset) {
- if (array === void 0)
- array = [];
- if (offset === void 0)
- offset = 0;
- array[offset] = this.x;
- array[offset + 1] = this.y;
- array[offset + 2] = this.z;
- return array;
- },
- fromBufferAttribute: function(attribute, index, offset) {
- if (offset !== void 0) {
- console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute().");
- }
- this.x = attribute.getX(index);
- this.y = attribute.getY(index);
- this.z = attribute.getZ(index);
- return this;
- }
- });
- var _v1 = new Vector3();
- var _m1 = new Matrix4();
- var _zero = new Vector3(0, 0, 0);
- var _one = new Vector3(1, 1, 1);
- var _x = new Vector3();
- var _y = new Vector3();
- var _z = new Vector3();
- function Matrix4() {
- this.elements = [
- 1,
- 0,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1
- ];
- if (arguments.length > 0) {
- console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.");
- }
- }
- Object.assign(Matrix4.prototype, {
- isMatrix4: true,
- set: function(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
- var te = this.elements;
- te[0] = n11;
- te[4] = n12;
- te[8] = n13;
- te[12] = n14;
- te[1] = n21;
- te[5] = n22;
- te[9] = n23;
- te[13] = n24;
- te[2] = n31;
- te[6] = n32;
- te[10] = n33;
- te[14] = n34;
- te[3] = n41;
- te[7] = n42;
- te[11] = n43;
- te[15] = n44;
- return this;
- },
- identity: function() {
- this.set(
- 1,
- 0,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1
- );
- return this;
- },
- clone: function() {
- return new Matrix4().fromArray(this.elements);
- },
- copy: function(m) {
- var te = this.elements;
- var me = m.elements;
- te[0] = me[0];
- te[1] = me[1];
- te[2] = me[2];
- te[3] = me[3];
- te[4] = me[4];
- te[5] = me[5];
- te[6] = me[6];
- te[7] = me[7];
- te[8] = me[8];
- te[9] = me[9];
- te[10] = me[10];
- te[11] = me[11];
- te[12] = me[12];
- te[13] = me[13];
- te[14] = me[14];
- te[15] = me[15];
- return this;
- },
- copyPosition: function(m) {
- var te = this.elements, me = m.elements;
- te[12] = me[12];
- te[13] = me[13];
- te[14] = me[14];
- return this;
- },
- extractBasis: function(xAxis, yAxis, zAxis) {
- xAxis.setFromMatrixColumn(this, 0);
- yAxis.setFromMatrixColumn(this, 1);
- zAxis.setFromMatrixColumn(this, 2);
- return this;
- },
- makeBasis: function(xAxis, yAxis, zAxis) {
- this.set(
- xAxis.x,
- yAxis.x,
- zAxis.x,
- 0,
- xAxis.y,
- yAxis.y,
- zAxis.y,
- 0,
- xAxis.z,
- yAxis.z,
- zAxis.z,
- 0,
- 0,
- 0,
- 0,
- 1
- );
- return this;
- },
- extractRotation: function(m) {
- var te = this.elements;
- var me = m.elements;
- var scaleX = 1 / _v1.setFromMatrixColumn(m, 0).length();
- var scaleY = 1 / _v1.setFromMatrixColumn(m, 1).length();
- var scaleZ = 1 / _v1.setFromMatrixColumn(m, 2).length();
- te[0] = me[0] * scaleX;
- te[1] = me[1] * scaleX;
- te[2] = me[2] * scaleX;
- te[3] = 0;
- te[4] = me[4] * scaleY;
- te[5] = me[5] * scaleY;
- te[6] = me[6] * scaleY;
- te[7] = 0;
- te[8] = me[8] * scaleZ;
- te[9] = me[9] * scaleZ;
- te[10] = me[10] * scaleZ;
- te[11] = 0;
- te[12] = 0;
- te[13] = 0;
- te[14] = 0;
- te[15] = 1;
- return this;
- },
- makeRotationFromEuler: function(euler) {
- if (!(euler && euler.isEuler)) {
- console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");
- }
- var te = this.elements;
- var x = euler.x, y = euler.y, z = euler.z;
- var a = Math.cos(x), b = Math.sin(x);
- var c = Math.cos(y), d = Math.sin(y);
- var e = Math.cos(z), f = Math.sin(z);
- if (euler.order === "XYZ") {
- var ae = a * e, af = a * f, be = b * e, bf = b * f;
- te[0] = c * e;
- te[4] = -c * f;
- te[8] = d;
- te[1] = af + be * d;
- te[5] = ae - bf * d;
- te[9] = -b * c;
- te[2] = bf - ae * d;
- te[6] = be + af * d;
- te[10] = a * c;
- } else if (euler.order === "YXZ") {
- var ce = c * e, cf = c * f, de = d * e, df = d * f;
- te[0] = ce + df * b;
- te[4] = de * b - cf;
- te[8] = a * d;
- te[1] = a * f;
- te[5] = a * e;
- te[9] = -b;
- te[2] = cf * b - de;
- te[6] = df + ce * b;
- te[10] = a * c;
- } else if (euler.order === "ZXY") {
- var ce = c * e, cf = c * f, de = d * e, df = d * f;
- te[0] = ce - df * b;
- te[4] = -a * f;
- te[8] = de + cf * b;
- te[1] = cf + de * b;
- te[5] = a * e;
- te[9] = df - ce * b;
- te[2] = -a * d;
- te[6] = b;
- te[10] = a * c;
- } else if (euler.order === "ZYX") {
- var ae = a * e, af = a * f, be = b * e, bf = b * f;
- te[0] = c * e;
- te[4] = be * d - af;
- te[8] = ae * d + bf;
- te[1] = c * f;
- te[5] = bf * d + ae;
- te[9] = af * d - be;
- te[2] = -d;
- te[6] = b * c;
- te[10] = a * c;
- } else if (euler.order === "YZX") {
- var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
- te[0] = c * e;
- te[4] = bd - ac * f;
- te[8] = bc * f + ad;
- te[1] = f;
- te[5] = a * e;
- te[9] = -b * e;
- te[2] = -d * e;
- te[6] = ad * f + bc;
- te[10] = ac - bd * f;
- } else if (euler.order === "XZY") {
- var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
- te[0] = c * e;
- te[4] = -f;
- te[8] = d * e;
- te[1] = ac * f + bd;
- te[5] = a * e;
- te[9] = ad * f - bc;
- te[2] = bc * f - ad;
- te[6] = b * e;
- te[10] = bd * f + ac;
- }
- te[3] = 0;
- te[7] = 0;
- te[11] = 0;
- te[12] = 0;
- te[13] = 0;
- te[14] = 0;
- te[15] = 1;
- return this;
- },
- makeRotationFromQuaternion: function(q) {
- return this.compose(_zero, q, _one);
- },
- lookAt: function(eye, target, up) {
- var te = this.elements;
- _z.subVectors(eye, target);
- if (_z.lengthSq() === 0) {
- _z.z = 1;
- }
- _z.normalize();
- _x.crossVectors(up, _z);
- if (_x.lengthSq() === 0) {
- if (Math.abs(up.z) === 1) {
- _z.x += 1e-4;
- } else {
- _z.z += 1e-4;
- }
- _z.normalize();
- _x.crossVectors(up, _z);
- }
- _x.normalize();
- _y.crossVectors(_z, _x);
- te[0] = _x.x;
- te[4] = _y.x;
- te[8] = _z.x;
- te[1] = _x.y;
- te[5] = _y.y;
- te[9] = _z.y;
- te[2] = _x.z;
- te[6] = _y.z;
- te[10] = _z.z;
- return this;
- },
- multiply: function(m, n) {
- if (n !== void 0) {
- console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.");
- return this.multiplyMatrices(m, n);
- }
- return this.multiplyMatrices(this, m);
- },
- premultiply: function(m) {
- return this.multiplyMatrices(m, this);
- },
- multiplyMatrices: function(a, b) {
- var ae = a.elements;
- var be = b.elements;
- var te = this.elements;
- var a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
- var a21 = ae[1], a22 = ae[5], a23 = ae[9], a24 = ae[13];
- var a31 = ae[2], a32 = ae[6], a33 = ae[10], a34 = ae[14];
- var a41 = ae[3], a42 = ae[7], a43 = ae[11], a44 = ae[15];
- var b11 = be[0], b12 = be[4], b13 = be[8], b14 = be[12];
- var b21 = be[1], b22 = be[5], b23 = be[9], b24 = be[13];
- var b31 = be[2], b32 = be[6], b33 = be[10], b34 = be[14];
- var b41 = be[3], b42 = be[7], b43 = be[11], b44 = be[15];
- te[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
- te[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
- te[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
- te[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
- te[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
- te[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
- te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
- te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
- te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
- te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
- te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
- te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
- te[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
- te[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
- te[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
- te[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
- return this;
- },
- multiplyScalar: function(s) {
- var te = this.elements;
- te[0] *= s;
- te[4] *= s;
- te[8] *= s;
- te[12] *= s;
- te[1] *= s;
- te[5] *= s;
- te[9] *= s;
- te[13] *= s;
- te[2] *= s;
- te[6] *= s;
- te[10] *= s;
- te[14] *= s;
- te[3] *= s;
- te[7] *= s;
- te[11] *= s;
- te[15] *= s;
- return this;
- },
- determinant: function() {
- var te = this.elements;
- var n11 = te[0], n12 = te[4], n13 = te[8], n14 = te[12];
- var n21 = te[1], n22 = te[5], n23 = te[9], n24 = te[13];
- var n31 = te[2], n32 = te[6], n33 = te[10], n34 = te[14];
- var n41 = te[3], n42 = te[7], n43 = te[11], n44 = te[15];
- 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);
- },
- transpose: function() {
- var te = this.elements;
- var tmp2;
- tmp2 = te[1];
- te[1] = te[4];
- te[4] = tmp2;
- tmp2 = te[2];
- te[2] = te[8];
- te[8] = tmp2;
- tmp2 = te[6];
- te[6] = te[9];
- te[9] = tmp2;
- tmp2 = te[3];
- te[3] = te[12];
- te[12] = tmp2;
- tmp2 = te[7];
- te[7] = te[13];
- te[13] = tmp2;
- tmp2 = te[11];
- te[11] = te[14];
- te[14] = tmp2;
- return this;
- },
- setPosition: function(x, y, z) {
- var te = this.elements;
- if (x.isVector3) {
- te[12] = x.x;
- te[13] = x.y;
- te[14] = x.z;
- } else {
- te[12] = x;
- te[13] = y;
- te[14] = z;
- }
- return this;
- },
- getInverse: function(m, throwOnDegenerate) {
- 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;
- var det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
- if (det === 0) {
- var msg = "THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0";
- if (throwOnDegenerate === true) {
- throw new Error(msg);
- } else {
- console.warn(msg);
- }
- return this.identity();
- }
- var detInv = 1 / det;
- te[0] = t11 * detInv;
- te[1] = (n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44) * detInv;
- te[2] = (n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44) * detInv;
- te[3] = (n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43) * detInv;
- te[4] = t12 * detInv;
- te[5] = (n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44) * detInv;
- te[6] = (n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44) * detInv;
- te[7] = (n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43) * detInv;
- te[8] = t13 * detInv;
- te[9] = (n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44) * detInv;
- te[10] = (n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44) * detInv;
- te[11] = (n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43) * detInv;
- te[12] = t14 * detInv;
- te[13] = (n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34) * detInv;
- te[14] = (n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34) * detInv;
- te[15] = (n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33) * detInv;
- return this;
- },
- scale: function(v) {
- var te = this.elements;
- var x = v.x, y = v.y, z = v.z;
- te[0] *= x;
- te[4] *= y;
- te[8] *= z;
- te[1] *= x;
- te[5] *= y;
- te[9] *= z;
- te[2] *= x;
- te[6] *= y;
- te[10] *= z;
- te[3] *= x;
- te[7] *= y;
- te[11] *= z;
- return this;
- },
- getMaxScaleOnAxis: function() {
- var te = this.elements;
- var scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2];
- var scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6];
- var scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10];
- return Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));
- },
- makeTranslation: function(x, y, z) {
- this.set(
- 1,
- 0,
- 0,
- x,
- 0,
- 1,
- 0,
- y,
- 0,
- 0,
- 1,
- z,
- 0,
- 0,
- 0,
- 1
- );
- return this;
- },
- makeRotationX: function(theta) {
- var c = Math.cos(theta), s = Math.sin(theta);
- this.set(
- 1,
- 0,
- 0,
- 0,
- 0,
- c,
- -s,
- 0,
- 0,
- s,
- c,
- 0,
- 0,
- 0,
- 0,
- 1
- );
- return this;
- },
- makeRotationY: function(theta) {
- var c = Math.cos(theta), s = Math.sin(theta);
- this.set(
- c,
- 0,
- s,
- 0,
- 0,
- 1,
- 0,
- 0,
- -s,
- 0,
- c,
- 0,
- 0,
- 0,
- 0,
- 1
- );
- return this;
- },
- makeRotationZ: function(theta) {
- var c = Math.cos(theta), s = Math.sin(theta);
- this.set(
- c,
- -s,
- 0,
- 0,
- s,
- c,
- 0,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1
- );
- return this;
- },
- makeRotationAxis: function(axis, angle) {
- var c = Math.cos(angle);
- var s = Math.sin(angle);
- var t = 1 - c;
- var x = axis.x, y = axis.y, z = axis.z;
- var tx = t * x, ty = t * y;
- this.set(
- tx * x + c,
- tx * y - s * z,
- tx * z + s * y,
- 0,
- tx * y + s * z,
- ty * y + c,
- ty * z - s * x,
- 0,
- tx * z - s * y,
- ty * z + s * x,
- t * z * z + c,
- 0,
- 0,
- 0,
- 0,
- 1
- );
- return this;
- },
- makeScale: function(x, y, z) {
- this.set(
- x,
- 0,
- 0,
- 0,
- 0,
- y,
- 0,
- 0,
- 0,
- 0,
- z,
- 0,
- 0,
- 0,
- 0,
- 1
- );
- return this;
- },
- makeShear: function(x, y, z) {
- this.set(
- 1,
- y,
- z,
- 0,
- x,
- 1,
- z,
- 0,
- x,
- y,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1
- );
- return this;
- },
- compose: function(position, quaternion, scale) {
- var te = this.elements;
- var x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;
- var x2 = x + x, y2 = y + y, z2 = z + z;
- var xx = x * x2, xy = x * y2, xz = x * z2;
- var yy = y * y2, yz = y * z2, zz = z * z2;
- var wx = w * x2, wy = w * y2, wz = w * z2;
- var sx = scale.x, sy = scale.y, sz = scale.z;
- te[0] = (1 - (yy + zz)) * sx;
- te[1] = (xy + wz) * sx;
- te[2] = (xz - wy) * sx;
- te[3] = 0;
- te[4] = (xy - wz) * sy;
- te[5] = (1 - (xx + zz)) * sy;
- te[6] = (yz + wx) * sy;
- te[7] = 0;
- te[8] = (xz + wy) * sz;
- te[9] = (yz - wx) * sz;
- te[10] = (1 - (xx + yy)) * sz;
- te[11] = 0;
- te[12] = position.x;
- te[13] = position.y;
- te[14] = position.z;
- te[15] = 1;
- return this;
- },
- decompose: function(position, quaternion, scale) {
- var te = this.elements;
- var sx = _v1.set(te[0], te[1], te[2]).length();
- var sy = _v1.set(te[4], te[5], te[6]).length();
- var sz = _v1.set(te[8], te[9], te[10]).length();
- var det = this.determinant();
- if (det < 0)
- sx = -sx;
- position.x = te[12];
- position.y = te[13];
- position.z = te[14];
- _m1.copy(this);
- var invSX = 1 / sx;
- var invSY = 1 / sy;
- var invSZ = 1 / sz;
- _m1.elements[0] *= invSX;
- _m1.elements[1] *= invSX;
- _m1.elements[2] *= invSX;
- _m1.elements[4] *= invSY;
- _m1.elements[5] *= invSY;
- _m1.elements[6] *= invSY;
- _m1.elements[8] *= invSZ;
- _m1.elements[9] *= invSZ;
- _m1.elements[10] *= invSZ;
- quaternion.setFromRotationMatrix(_m1);
- scale.x = sx;
- scale.y = sy;
- scale.z = sz;
- return this;
- },
- makePerspective: function(left, right, top2, bottom, near, far) {
- if (far === void 0) {
- console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");
- }
- var te = this.elements;
- var x = 2 * near / (right - left);
- var y = 2 * near / (top2 - bottom);
- var a = (right + left) / (right - left);
- var b = (top2 + bottom) / (top2 - bottom);
- var c = -(far + near) / (far - near);
- var d = -2 * far * near / (far - near);
- te[0] = x;
- te[4] = 0;
- te[8] = a;
- te[12] = 0;
- te[1] = 0;
- te[5] = y;
- te[9] = b;
- te[13] = 0;
- te[2] = 0;
- te[6] = 0;
- te[10] = c;
- te[14] = d;
- te[3] = 0;
- te[7] = 0;
- te[11] = -1;
- te[15] = 0;
- return this;
- },
- makeOrthographic: function(left, right, top2, bottom, near, far) {
- var te = this.elements;
- var w = 1 / (right - left);
- var h = 1 / (top2 - bottom);
- var p = 1 / (far - near);
- var x = (right + left) * w;
- var y = (top2 + bottom) * h;
- var z = (far + near) * p;
- te[0] = 2 * w;
- te[4] = 0;
- te[8] = 0;
- te[12] = -x;
- te[1] = 0;
- te[5] = 2 * h;
- te[9] = 0;
- te[13] = -y;
- te[2] = 0;
- te[6] = 0;
- te[10] = -2 * p;
- te[14] = -z;
- te[3] = 0;
- te[7] = 0;
- te[11] = 0;
- te[15] = 1;
- return this;
- },
- equals: function(matrix) {
- var te = this.elements;
- var me = matrix.elements;
- for (var i2 = 0; i2 < 16; i2++) {
- if (te[i2] !== me[i2])
- return false;
- }
- return true;
- },
- fromArray: function(array, offset) {
- if (offset === void 0)
- offset = 0;
- for (var i2 = 0; i2 < 16; i2++) {
- this.elements[i2] = array[i2 + offset];
- }
- return this;
- },
- toArray: function(array, offset) {
- if (array === void 0)
- array = [];
- if (offset === void 0)
- offset = 0;
- var te = this.elements;
- array[offset] = te[0];
- array[offset + 1] = te[1];
- array[offset + 2] = te[2];
- array[offset + 3] = te[3];
- array[offset + 4] = te[4];
- array[offset + 5] = te[5];
- array[offset + 6] = te[6];
- array[offset + 7] = te[7];
- array[offset + 8] = te[8];
- array[offset + 9] = te[9];
- array[offset + 10] = te[10];
- array[offset + 11] = te[11];
- array[offset + 12] = te[12];
- array[offset + 13] = te[13];
- array[offset + 14] = te[14];
- array[offset + 15] = te[15];
- return array;
- }
- });
- var _matrix = new Matrix4();
- var _quaternion$1 = new Quaternion();
- function Euler(x, y, z, order) {
- this._x = x || 0;
- this._y = y || 0;
- this._z = z || 0;
- this._order = order || Euler.DefaultOrder;
- }
- Euler.RotationOrders = ["XYZ", "YZX", "ZXY", "XZY", "YXZ", "ZYX"];
- Euler.DefaultOrder = "XYZ";
- Object.defineProperties(Euler.prototype, {
- x: {
- get: function() {
- return this._x;
- },
- set: function(value) {
- this._x = value;
- this._onChangeCallback();
- }
- },
- y: {
- get: function() {
- return this._y;
- },
- set: function(value) {
- this._y = value;
- this._onChangeCallback();
- }
- },
- z: {
- get: function() {
- return this._z;
- },
- set: function(value) {
- this._z = value;
- this._onChangeCallback();
- }
- },
- order: {
- get: function() {
- return this._order;
- },
- set: function(value) {
- this._order = value;
- this._onChangeCallback();
- }
- }
- });
- Object.assign(Euler.prototype, {
- isEuler: true,
- set: function(x, y, z, order) {
- this._x = x;
- this._y = y;
- this._z = z;
- this._order = order || this._order;
- this._onChangeCallback();
- return this;
- },
- clone: function() {
- return new this.constructor(this._x, this._y, this._z, this._order);
- },
- copy: function(euler) {
- this._x = euler._x;
- this._y = euler._y;
- this._z = euler._z;
- this._order = euler._order;
- this._onChangeCallback();
- return this;
- },
- setFromRotationMatrix: function(m, order, update) {
- var clamp = MathUtils.clamp;
- var te = m.elements;
- var m11 = te[0], m12 = te[4], m13 = te[8];
- var m21 = te[1], m22 = te[5], m23 = te[9];
- var m31 = te[2], m32 = te[6], m33 = te[10];
- order = order || this._order;
- if (order === "XYZ") {
- this._y = Math.asin(clamp(m13, -1, 1));
- if (Math.abs(m13) < 0.9999999) {
- this._x = Math.atan2(-m23, m33);
- this._z = Math.atan2(-m12, m11);
- } else {
- this._x = Math.atan2(m32, m22);
- this._z = 0;
- }
- } else if (order === "YXZ") {
- this._x = Math.asin(-clamp(m23, -1, 1));
- if (Math.abs(m23) < 0.9999999) {
- this._y = Math.atan2(m13, m33);
- this._z = Math.atan2(m21, m22);
- } else {
- this._y = Math.atan2(-m31, m11);
- this._z = 0;
- }
- } else if (order === "ZXY") {
- this._x = Math.asin(clamp(m32, -1, 1));
- if (Math.abs(m32) < 0.9999999) {
- this._y = Math.atan2(-m31, m33);
- this._z = Math.atan2(-m12, m22);
- } else {
- this._y = 0;
- this._z = Math.atan2(m21, m11);
- }
- } else if (order === "ZYX") {
- this._y = Math.asin(-clamp(m31, -1, 1));
- if (Math.abs(m31) < 0.9999999) {
- this._x = Math.atan2(m32, m33);
- this._z = Math.atan2(m21, m11);
- } else {
- this._x = 0;
- this._z = Math.atan2(-m12, m22);
- }
- } else if (order === "YZX") {
- this._z = Math.asin(clamp(m21, -1, 1));
- if (Math.abs(m21) < 0.9999999) {
- this._x = Math.atan2(-m23, m22);
- this._y = Math.atan2(-m31, m11);
- } else {
- this._x = 0;
- this._y = Math.atan2(m13, m33);
- }
- } else if (order === "XZY") {
- this._z = Math.asin(-clamp(m12, -1, 1));
- if (Math.abs(m12) < 0.9999999) {
- this._x = Math.atan2(m32, m22);
- this._y = Math.atan2(m13, m11);
- } else {
- this._x = Math.atan2(-m23, m33);
- this._y = 0;
- }
- } else {
- console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: " + order);
- }
- this._order = order;
- if (update !== false)
- this._onChangeCallback();
- return this;
- },
- setFromQuaternion: function(q, order, update) {
- _matrix.makeRotationFromQuaternion(q);
- return this.setFromRotationMatrix(_matrix, order, update);
- },
- setFromVector3: function(v, order) {
- return this.set(v.x, v.y, v.z, order || this._order);
- },
- reorder: function(newOrder) {
- _quaternion$1.setFromEuler(this);
- return this.setFromQuaternion(_quaternion$1, newOrder);
- },
- equals: function(euler) {
- return euler._x === this._x && euler._y === this._y && euler._z === this._z && euler._order === this._order;
- },
- fromArray: function(array) {
- this._x = array[0];
- this._y = array[1];
- this._z = array[2];
- if (array[3] !== void 0)
- this._order = array[3];
- this._onChangeCallback();
- return this;
- },
- toArray: function(array, offset) {
- if (array === void 0)
- array = [];
- if (offset === void 0)
- offset = 0;
- array[offset] = this._x;
- array[offset + 1] = this._y;
- array[offset + 2] = this._z;
- array[offset + 3] = this._order;
- return array;
- },
- toVector3: function(optionalResult) {
- if (optionalResult) {
- return optionalResult.set(this._x, this._y, this._z);
- } else {
- return new Vector3(this._x, this._y, this._z);
- }
- },
- _onChange: function(callback) {
- this._onChangeCallback = callback;
- return this;
- },
- _onChangeCallback: function() {
- }
- });
- function Layers() {
- this.mask = 1 | 0;
- }
- Object.assign(Layers.prototype, {
- set: function(channel) {
- this.mask = 1 << channel | 0;
- },
- enable: function(channel) {
- this.mask |= 1 << channel | 0;
- },
- enableAll: function() {
- this.mask = 4294967295 | 0;
- },
- toggle: function(channel) {
- this.mask ^= 1 << channel | 0;
- },
- disable: function(channel) {
- this.mask &= ~(1 << channel | 0);
- },
- disableAll: function() {
- this.mask = 0;
- },
- test: function(layers) {
- return (this.mask & layers.mask) !== 0;
- }
- });
- var _object3DId = 0;
- var _v1$1 = new Vector3();
- var _q1 = new Quaternion();
- var _m1$1 = new Matrix4();
- var _target = new Vector3();
- var _position = new Vector3();
- var _scale = new Vector3();
- var _quaternion$2 = new Quaternion();
- var _xAxis = new Vector3(1, 0, 0);
- var _yAxis = new Vector3(0, 1, 0);
- var _zAxis = new Vector3(0, 0, 1);
- var _addedEvent = { type: "added" };
- var _removedEvent = { type: "removed" };
- function Object3D() {
- Object.defineProperty(this, "id", { value: _object3DId++ });
- this.uuid = MathUtils.generateUUID();
- this.name = "";
- this.type = "Object3D";
- this.parent = null;
- this.children = [];
- this.up = Object3D.DefaultUp.clone();
- var position = new Vector3();
- var rotation = new Euler();
- var quaternion = new Quaternion();
- var scale = new Vector3(1, 1, 1);
- function onRotationChange() {
- quaternion.setFromEuler(rotation, false);
- }
- function onQuaternionChange() {
- rotation.setFromQuaternion(quaternion, void 0, false);
- }
- rotation._onChange(onRotationChange);
- quaternion._onChange(onQuaternionChange);
- Object.defineProperties(this, {
- position: {
- configurable: true,
- enumerable: true,
- value: position
- },
- rotation: {
- configurable: true,
- enumerable: true,
- value: rotation
- },
- quaternion: {
- configurable: true,
- enumerable: true,
- value: quaternion
- },
- scale: {
- configurable: true,
- enumerable: true,
- value: scale
- },
- modelViewMatrix: {
- value: new Matrix4()
- },
- normalMatrix: {
- value: new Matrix3()
- }
- });
- this.matrix = new Matrix4();
- this.matrixWorld = new Matrix4();
- this.matrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate;
- this.matrixWorldNeedsUpdate = false;
- this.layers = new Layers();
- this.visible = true;
- this.castShadow = false;
- this.receiveShadow = false;
- this.frustumCulled = true;
- this.renderOrder = 0;
- this.userData = {};
- }
- Object3D.DefaultUp = new Vector3(0, 1, 0);
- Object3D.DefaultMatrixAutoUpdate = true;
- Object3D.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
- constructor: Object3D,
- isObject3D: true,
- onBeforeRender: function() {
- },
- onAfterRender: function() {
- },
- applyMatrix4: function(matrix) {
- if (this.matrixAutoUpdate)
- this.updateMatrix();
- this.matrix.premultiply(matrix);
- this.matrix.decompose(this.position, this.quaternion, this.scale);
- },
- applyQuaternion: function(q) {
- this.quaternion.premultiply(q);
- return this;
- },
- setRotationFromAxisAngle: function(axis, angle) {
- this.quaternion.setFromAxisAngle(axis, angle);
- },
- setRotationFromEuler: function(euler) {
- this.quaternion.setFromEuler(euler, true);
- },
- setRotationFromMatrix: function(m) {
- this.quaternion.setFromRotationMatrix(m);
- },
- setRotationFromQuaternion: function(q) {
- this.quaternion.copy(q);
- },
- rotateOnAxis: function(axis, angle) {
- _q1.setFromAxisAngle(axis, angle);
- this.quaternion.multiply(_q1);
- return this;
- },
- rotateOnWorldAxis: function(axis, angle) {
- _q1.setFromAxisAngle(axis, angle);
- this.quaternion.premultiply(_q1);
- return this;
- },
- rotateX: function(angle) {
- return this.rotateOnAxis(_xAxis, angle);
- },
- rotateY: function(angle) {
- return this.rotateOnAxis(_yAxis, angle);
- },
- rotateZ: function(angle) {
- return this.rotateOnAxis(_zAxis, angle);
- },
- translateOnAxis: function(axis, distance) {
- _v1$1.copy(axis).applyQuaternion(this.quaternion);
- this.position.add(_v1$1.multiplyScalar(distance));
- return this;
- },
- translateX: function(distance) {
- return this.translateOnAxis(_xAxis, distance);
- },
- translateY: function(distance) {
- return this.translateOnAxis(_yAxis, distance);
- },
- translateZ: function(distance) {
- return this.translateOnAxis(_zAxis, distance);
- },
- localToWorld: function(vector) {
- return vector.applyMatrix4(this.matrixWorld);
- },
- worldToLocal: function(vector) {
- return vector.applyMatrix4(_m1$1.getInverse(this.matrixWorld));
- },
- lookAt: function(x, y, z) {
- if (x.isVector3) {
- _target.copy(x);
- } else {
- _target.set(x, y, z);
- }
- var parent = this.parent;
- this.updateWorldMatrix(true, false);
- _position.setFromMatrixPosition(this.matrixWorld);
- if (this.isCamera || this.isLight) {
- _m1$1.lookAt(_position, _target, this.up);
- } else {
- _m1$1.lookAt(_target, _position, this.up);
- }
- this.quaternion.setFromRotationMatrix(_m1$1);
- if (parent) {
- _m1$1.extractRotation(parent.matrixWorld);
- _q1.setFromRotationMatrix(_m1$1);
- this.quaternion.premultiply(_q1.inverse());
- }
- },
- add: function(object) {
- if (arguments.length > 1) {
- for (var i2 = 0; i2 < arguments.length; i2++) {
- this.add(arguments[i2]);
- }
- return this;
- }
- if (object === this) {
- console.error("THREE.Object3D.add: object can't be added as a child of itself.", object);
- return this;
- }
- if (object && object.isObject3D) {
- if (object.parent !== null) {
- object.parent.remove(object);
- }
- object.parent = this;
- this.children.push(object);
- object.dispatchEvent(_addedEvent);
- } else {
- console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", object);
- }
- return this;
- },
- remove: function(object) {
- if (arguments.length > 1) {
- for (var i2 = 0; i2 < arguments.length; i2++) {
- this.remove(arguments[i2]);
- }
- return this;
- }
- var index = this.children.indexOf(object);
- if (index !== -1) {
- object.parent = null;
- this.children.splice(index, 1);
- object.dispatchEvent(_removedEvent);
- }
- return this;
- },
- attach: function(object) {
- this.updateWorldMatrix(true, false);
- _m1$1.getInverse(this.matrixWorld);
- if (object.parent !== null) {
- object.parent.updateWorldMatrix(true, false);
- _m1$1.multiply(object.parent.matrixWorld);
- }
- object.applyMatrix4(_m1$1);
- object.updateWorldMatrix(false, false);
- this.add(object);
- return this;
- },
- getObjectById: function(id) {
- return this.getObjectByProperty("id", id);
- },
- getObjectByName: function(name) {
- return this.getObjectByProperty("name", name);
- },
- getObjectByProperty: function(name, value) {
- if (this[name] === value)
- return this;
- for (var i2 = 0, l = this.children.length; i2 < l; i2++) {
- var child = this.children[i2];
- var object = child.getObjectByProperty(name, value);
- if (object !== void 0) {
- return object;
- }
- }
- return void 0;
- },
- getWorldPosition: function(target) {
- if (target === void 0) {
- console.warn("THREE.Object3D: .getWorldPosition() target is now required");
- target = new Vector3();
- }
- this.updateMatrixWorld(true);
- return target.setFromMatrixPosition(this.matrixWorld);
- },
- getWorldQuaternion: function(target) {
- if (target === void 0) {
- console.warn("THREE.Object3D: .getWorldQuaternion() target is now required");
- target = new Quaternion();
- }
- this.updateMatrixWorld(true);
- this.matrixWorld.decompose(_position, target, _scale);
- return target;
- },
- getWorldScale: function(target) {
- if (target === void 0) {
- console.warn("THREE.Object3D: .getWorldScale() target is now required");
- target = new Vector3();
- }
- this.updateMatrixWorld(true);
- this.matrixWorld.decompose(_position, _quaternion$2, target);
- return target;
- },
- getWorldDirection: function(target) {
- if (target === void 0) {
- console.warn("THREE.Object3D: .getWorldDirection() target is now required");
- target = new Vector3();
- }
- this.updateMatrixWorld(true);
- var e = this.matrixWorld.elements;
- return target.set(e[8], e[9], e[10]).normalize();
- },
- raycast: function() {
- },
- traverse: function(callback) {
- callback(this);
- var children = this.children;
- for (var i2 = 0, l = children.length; i2 < l; i2++) {
- children[i2].traverse(callback);
- }
- },
- traverseVisible: function(callback) {
- if (this.visible === false)
- return;
- callback(this);
- var children = this.children;
- for (var i2 = 0, l = children.length; i2 < l; i2++) {
- children[i2].traverseVisible(callback);
- }
- },
- traverseAncestors: function(callback) {
- var parent = this.parent;
- if (parent !== null) {
- callback(parent);
- parent.traverseAncestors(callback);
- }
- },
- updateMatrix: function() {
- this.matrix.compose(this.position, this.quaternion, this.scale);
- this.matrixWorldNeedsUpdate = true;
- },
- updateMatrixWorld: function(force) {
- if (this.matrixAutoUpdate)
- this.updateMatrix();
- if (this.matrixWorldNeedsUpdate || force) {
- if (this.parent === null) {
- this.matrixWorld.copy(this.matrix);
- } else {
- this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix);
- }
- this.matrixWorldNeedsUpdate = false;
- force = true;
- }
- var children = this.children;
- for (var i2 = 0, l = children.length; i2 < l; i2++) {
- children[i2].updateMatrixWorld(force);
- }
- },
- updateWorldMatrix: function(updateParents, updateChildren) {
- var parent = this.parent;
- if (updateParents === true && parent !== null) {
- parent.updateWorldMatrix(true, false);
- }
- if (this.matrixAutoUpdate)
- this.updateMatrix();
- if (this.parent === null) {
- this.matrixWorld.copy(this.matrix);
- } else {
- this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix);
- }
- if (updateChildren === true) {
- var children = this.children;
- for (var i2 = 0, l = children.length; i2 < l; i2++) {
- children[i2].updateWorldMatrix(false, true);
- }
- }
- },
- toJSON: function(meta) {
- var isRootObject = meta === void 0 || typeof meta === "string";
- var output = {};
- if (isRootObject) {
- meta = {
- geometries: {},
- materials: {},
- textures: {},
- images: {},
- shapes: {}
- };
- output.metadata = {
- version: 4.5,
- type: "Object",
- generator: "Object3D.toJSON"
- };
- }
- var object = {};
- object.uuid = this.uuid;
- object.type = this.type;
- if (this.name !== "")
- object.name = this.name;
- if (this.castShadow === true)
- object.castShadow = true;
- if (this.receiveShadow === true)
- object.receiveShadow = true;
- if (this.visible === false)
- object.visible = false;
- if (this.frustumCulled === false)
- object.frustumCulled = false;
- if (this.renderOrder !== 0)
- object.renderOrder = this.renderOrder;
- if (JSON.stringify(this.userData) !== "{}")
- object.userData = this.userData;
- object.layers = this.layers.mask;
- object.matrix = this.matrix.toArray();
- if (this.matrixAutoUpdate === false)
- object.matrixAutoUpdate = false;
- if (this.isInstancedMesh) {
- object.type = "InstancedMesh";
- object.count = this.count;
- object.instanceMatrix = this.instanceMatrix.toJSON();
- }
- function serialize(library, element) {
- if (library[element.uuid] === void 0) {
- library[element.uuid] = element.toJSON(meta);
- }
- return element.uuid;
- }
- if (this.isMesh || this.isLine || this.isPoints) {
- object.geometry = serialize(meta.geometries, this.geometry);
- var parameters = this.geometry.parameters;
- if (parameters !== void 0 && parameters.shapes !== void 0) {
- var shapes = parameters.shapes;
- if (Array.isArray(shapes)) {
- for (var i2 = 0, l = shapes.length; i2 < l; i2++) {
- var shape = shapes[i2];
- serialize(meta.shapes, shape);
- }
- } else {
- serialize(meta.shapes, shapes);
- }
- }
- }
- if (this.material !== void 0) {
- if (Array.isArray(this.material)) {
- var uuids = [];
- for (var i2 = 0, l = this.material.length; i2 < l; i2++) {
- uuids.push(serialize(meta.materials, this.material[i2]));
- }
- object.material = uuids;
- } else {
- object.material = serialize(meta.materials, this.material);
- }
- }
- if (this.children.length > 0) {
- object.children = [];
- for (var i2 = 0; i2 < this.children.length; i2++) {
- object.children.push(this.children[i2].toJSON(meta).object);
- }
- }
- if (isRootObject) {
- var geometries = extractFromCache(meta.geometries);
- var materials = extractFromCache(meta.materials);
- var textures = extractFromCache(meta.textures);
- var images = extractFromCache(meta.images);
- var shapes = extractFromCache(meta.shapes);
- if (geometries.length > 0)
- output.geometries = geometries;
- if (materials.length > 0)
- output.materials = materials;
- if (textures.length > 0)
- output.textures = textures;
- if (images.length > 0)
- output.images = images;
- if (shapes.length > 0)
- output.shapes = shapes;
- }
- output.object = object;
- return output;
- function extractFromCache(cache) {
- var values = [];
- for (var key in cache) {
- var data = cache[key];
- delete data.metadata;
- values.push(data);
- }
- return values;
- }
- },
- clone: function(recursive) {
- return new this.constructor().copy(this, recursive);
- },
- copy: function(source, recursive) {
- if (recursive === void 0)
- recursive = true;
- this.name = source.name;
- this.up.copy(source.up);
- this.position.copy(source.position);
- this.quaternion.copy(source.quaternion);
- this.scale.copy(source.scale);
- this.matrix.copy(source.matrix);
- this.matrixWorld.copy(source.matrixWorld);
- this.matrixAutoUpdate = source.matrixAutoUpdate;
- this.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;
- this.layers.mask = source.layers.mask;
- this.visible = source.visible;
- this.castShadow = source.castShadow;
- this.receiveShadow = source.receiveShadow;
- this.frustumCulled = source.frustumCulled;
- this.renderOrder = source.renderOrder;
- this.userData = JSON.parse(JSON.stringify(source.userData));
- if (recursive === true) {
- for (var i2 = 0; i2 < source.children.length; i2++) {
- var child = source.children[i2];
- this.add(child.clone());
- }
- }
- return this;
- }
- });
- function Scene() {
- Object3D.call(this);
- this.type = "Scene";
- this.background = null;
- this.environment = null;
- this.fog = null;
- this.overrideMaterial = null;
- this.autoUpdate = true;
- if (typeof __THREE_DEVTOOLS__ !== "undefined") {
- __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
- }
- }
- Scene.prototype = Object.assign(Object.create(Object3D.prototype), {
- constructor: Scene,
- isScene: true,
- copy: function(source, recursive) {
- Object3D.prototype.copy.call(this, source, recursive);
- if (source.background !== null)
- this.background = source.background.clone();
- if (source.environment !== null)
- this.environment = source.environment.clone();
- if (source.fog !== null)
- this.fog = source.fog.clone();
- if (source.overrideMaterial !== null)
- this.overrideMaterial = source.overrideMaterial.clone();
- this.autoUpdate = source.autoUpdate;
- this.matrixAutoUpdate = source.matrixAutoUpdate;
- return this;
- },
- toJSON: function(meta) {
- var data = Object3D.prototype.toJSON.call(this, meta);
- if (this.background !== null)
- data.object.background = this.background.toJSON(meta);
- if (this.environment !== null)
- data.object.environment = this.environment.toJSON(meta);
- if (this.fog !== null)
- data.object.fog = this.fog.toJSON();
- return data;
- },
- dispose: function() {
- this.dispatchEvent({ type: "dispose" });
- }
- });
- var _points = [
- new Vector3(),
- new Vector3(),
- new Vector3(),
- new Vector3(),
- new Vector3(),
- new Vector3(),
- new Vector3(),
- new Vector3()
- ];
- var _vector$1 = new Vector3();
- var _box = new Box3();
- var _v0 = new Vector3();
- var _v1$2 = new Vector3();
- var _v2 = new Vector3();
- var _f0 = new Vector3();
- var _f1 = new Vector3();
- var _f2 = new Vector3();
- var _center = new Vector3();
- var _extents = new Vector3();
- var _triangleNormal = new Vector3();
- var _testAxis = new Vector3();
- function Box3(min, max) {
- this.min = min !== void 0 ? min : new Vector3(Infinity, Infinity, Infinity);
- this.max = max !== void 0 ? max : new Vector3(-Infinity, -Infinity, -Infinity);
- }
- Object.assign(Box3.prototype, {
- isBox3: true,
- set: function(min, max) {
- this.min.copy(min);
- this.max.copy(max);
- return this;
- },
- setFromArray: function(array) {
- var minX = Infinity;
- var minY = Infinity;
- var minZ = Infinity;
- var maxX = -Infinity;
- var maxY = -Infinity;
- var maxZ = -Infinity;
- for (var i2 = 0, l = array.length; i2 < l; i2 += 3) {
- var x = array[i2];
- var y = array[i2 + 1];
- var z = array[i2 + 2];
- if (x < minX)
- minX = x;
- if (y < minY)
- minY = y;
- if (z < minZ)
- minZ = z;
- if (x > maxX)
- maxX = x;
- if (y > maxY)
- maxY = y;
- if (z > maxZ)
- maxZ = z;
- }
- this.min.set(minX, minY, minZ);
- this.max.set(maxX, maxY, maxZ);
- return this;
- },
- setFromBufferAttribute: function(attribute) {
- var minX = Infinity;
- var minY = Infinity;
- var minZ = Infinity;
- var maxX = -Infinity;
- var maxY = -Infinity;
- var maxZ = -Infinity;
- for (var i2 = 0, l = attribute.count; i2 < l; i2++) {
- var x = attribute.getX(i2);
- var y = attribute.getY(i2);
- var z = attribute.getZ(i2);
- if (x < minX)
- minX = x;
- if (y < minY)
- minY = y;
- if (z < minZ)
- minZ = z;
- if (x > maxX)
- maxX = x;
- if (y > maxY)
- maxY = y;
- if (z > maxZ)
- maxZ = z;
- }
- this.min.set(minX, minY, minZ);
- this.max.set(maxX, maxY, maxZ);
- return this;
- },
- setFromPoints: function(points) {
- this.makeEmpty();
- for (var i2 = 0, il = points.length; i2 < il; i2++) {
- this.expandByPoint(points[i2]);
- }
- return this;
- },
- setFromCenterAndSize: function(center, size) {
- var halfSize = _vector$1.copy(size).multiplyScalar(0.5);
- this.min.copy(center).sub(halfSize);
- this.max.copy(center).add(halfSize);
- return this;
- },
- setFromObject: function(object) {
- this.makeEmpty();
- return this.expandByObject(object);
- },
- clone: function() {
- return new this.constructor().copy(this);
- },
- copy: function(box) {
- this.min.copy(box.min);
- this.max.copy(box.max);
- return this;
- },
- makeEmpty: function() {
- this.min.x = this.min.y = this.min.z = Infinity;
- this.max.x = this.max.y = this.max.z = -Infinity;
- return this;
- },
- isEmpty: function() {
- return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z;
- },
- getCenter: function(target) {
- if (target === void 0) {
- console.warn("THREE.Box3: .getCenter() target is now required");
- target = new Vector3();
- }
- return this.isEmpty() ? target.set(0, 0, 0) : target.addVectors(this.min, this.max).multiplyScalar(0.5);
- },
- getSize: function(target) {
- if (target === void 0) {
- console.warn("THREE.Box3: .getSize() target is now required");
- target = new Vector3();
- }
- return this.isEmpty() ? target.set(0, 0, 0) : target.subVectors(this.max, this.min);
- },
- expandByPoint: function(point) {
- this.min.min(point);
- this.max.max(point);
- return this;
- },
- expandByVector: function(vector) {
- this.min.sub(vector);
- this.max.add(vector);
- return this;
- },
- expandByScalar: function(scalar) {
- this.min.addScalar(-scalar);
- this.max.addScalar(scalar);
- return this;
- },
- expandByObject: function(object) {
- object.updateWorldMatrix(false, false);
- var geometry = object.geometry;
- if (geometry !== void 0) {
- if (geometry.boundingBox === null) {
- geometry.computeBoundingBox();
- }
- _box.copy(geometry.boundingBox);
- _box.applyMatrix4(object.matrixWorld);
- this.expandByPoint(_box.min);
- this.expandByPoint(_box.max);
- }
- var children = object.children;
- for (var i2 = 0, l = children.length; i2 < l; i2++) {
- this.expandByObject(children[i2]);
- }
- return this;
- },
- containsPoint: function(point) {
- 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;
- },
- containsBox: function(box) {
- 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;
- },
- getParameter: function(point, target) {
- if (target === void 0) {
- console.warn("THREE.Box3: .getParameter() target is now required");
- target = new Vector3();
- }
- return target.set(
- (point.x - this.min.x) / (this.max.x - this.min.x),
- (point.y - this.min.y) / (this.max.y - this.min.y),
- (point.z - this.min.z) / (this.max.z - this.min.z)
- );
- },
- intersectsBox: function(box) {
- 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;
- },
- intersectsSphere: function(sphere) {
- this.clampPoint(sphere.center, _vector$1);
- return _vector$1.distanceToSquared(sphere.center) <= sphere.radius * sphere.radius;
- },
- intersectsPlane: function(plane) {
- var min, max;
- if (plane.normal.x > 0) {
- min = plane.normal.x * this.min.x;
- max = plane.normal.x * this.max.x;
- } else {
- min = plane.normal.x * this.max.x;
- max = plane.normal.x * this.min.x;
- }
- if (plane.normal.y > 0) {
- min += plane.normal.y * this.min.y;
- max += plane.normal.y * this.max.y;
- } else {
- min += plane.normal.y * this.max.y;
- max += plane.normal.y * this.min.y;
- }
- if (plane.normal.z > 0) {
- min += plane.normal.z * this.min.z;
- max += plane.normal.z * this.max.z;
- } else {
- min += plane.normal.z * this.max.z;
- max += plane.normal.z * this.min.z;
- }
- return min <= -plane.constant && max >= -plane.constant;
- },
- intersectsTriangle: function(triangle) {
- if (this.isEmpty()) {
- return false;
- }
- this.getCenter(_center);
- _extents.subVectors(this.max, _center);
- _v0.subVectors(triangle.a, _center);
- _v1$2.subVectors(triangle.b, _center);
- _v2.subVectors(triangle.c, _center);
- _f0.subVectors(_v1$2, _v0);
- _f1.subVectors(_v2, _v1$2);
- _f2.subVectors(_v0, _v2);
- var axes = [
- 0,
- -_f0.z,
- _f0.y,
- 0,
- -_f1.z,
- _f1.y,
- 0,
- -_f2.z,
- _f2.y,
- _f0.z,
- 0,
- -_f0.x,
- _f1.z,
- 0,
- -_f1.x,
- _f2.z,
- 0,
- -_f2.x,
- -_f0.y,
- _f0.x,
- 0,
- -_f1.y,
- _f1.x,
- 0,
- -_f2.y,
- _f2.x,
- 0
- ];
- if (!satForAxes(axes, _v0, _v1$2, _v2, _extents)) {
- return false;
- }
- axes = [1, 0, 0, 0, 1, 0, 0, 0, 1];
- if (!satForAxes(axes, _v0, _v1$2, _v2, _extents)) {
- return false;
- }
- _triangleNormal.crossVectors(_f0, _f1);
- axes = [_triangleNormal.x, _triangleNormal.y, _triangleNormal.z];
- return satForAxes(axes, _v0, _v1$2, _v2, _extents);
- },
- clampPoint: function(point, target) {
- if (target === void 0) {
- console.warn("THREE.Box3: .clampPoint() target is now required");
- target = new Vector3();
- }
- return target.copy(point).clamp(this.min, this.max);
- },
- distanceToPoint: function(point) {
- var clampedPoint = _vector$1.copy(point).clamp(this.min, this.max);
- return clampedPoint.sub(point).length();
- },
- getBoundingSphere: function(target) {
- if (target === void 0) {
- console.error("THREE.Box3: .getBoundingSphere() target is now required");
- }
- this.getCenter(target.center);
- target.radius = this.getSize(_vector$1).length() * 0.5;
- return target;
- },
- intersect: function(box) {
- this.min.max(box.min);
- this.max.min(box.max);
- if (this.isEmpty())
- this.makeEmpty();
- return this;
- },
- union: function(box) {
- this.min.min(box.min);
- this.max.max(box.max);
- return this;
- },
- applyMatrix4: function(matrix) {
- if (this.isEmpty())
- return this;
- _points[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(matrix);
- _points[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(matrix);
- _points[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(matrix);
- _points[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(matrix);
- _points[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(matrix);
- _points[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(matrix);
- _points[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(matrix);
- _points[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(matrix);
- this.setFromPoints(_points);
- return this;
- },
- translate: function(offset) {
- this.min.add(offset);
- this.max.add(offset);
- return this;
- },
- equals: function(box) {
- return box.min.equals(this.min) && box.max.equals(this.max);
- }
- });
- function satForAxes(axes, v0, v1, v2, extents) {
- var i2, j;
- for (i2 = 0, j = axes.length - 3; i2 <= j; i2 += 3) {
- _testAxis.fromArray(axes, i2);
- var r = extents.x * Math.abs(_testAxis.x) + extents.y * Math.abs(_testAxis.y) + extents.z * Math.abs(_testAxis.z);
- var p0 = v0.dot(_testAxis);
- var p1 = v1.dot(_testAxis);
- var p2 = v2.dot(_testAxis);
- if (Math.max(-Math.max(p0, p1, p2), Math.min(p0, p1, p2)) > r) {
- return false;
- }
- }
- return true;
- }
- var _box$1 = new Box3();
- function Sphere(center, radius) {
- this.center = center !== void 0 ? center : new Vector3();
- this.radius = radius !== void 0 ? radius : 0;
- }
- Object.assign(Sphere.prototype, {
- set: function(center, radius) {
- this.center.copy(center);
- this.radius = radius;
- return this;
- },
- setFromPoints: function(points, optionalCenter) {
- var center = this.center;
- if (optionalCenter !== void 0) {
- center.copy(optionalCenter);
- } else {
- _box$1.setFromPoints(points).getCenter(center);
- }
- var maxRadiusSq = 0;
- for (var i2 = 0, il = points.length; i2 < il; i2++) {
- maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(points[i2]));
- }
- this.radius = Math.sqrt(maxRadiusSq);
- return this;
- },
- clone: function() {
- return new this.constructor().copy(this);
- },
- copy: function(sphere) {
- this.center.copy(sphere.center);
- this.radius = sphere.radius;
- return this;
- },
- empty: function() {
- return this.radius <= 0;
- },
- containsPoint: function(point) {
- return point.distanceToSquared(this.center) <= this.radius * this.radius;
- },
- distanceToPoint: function(point) {
- return point.distanceTo(this.center) - this.radius;
- },
- intersectsSphere: function(sphere) {
- var radiusSum = this.radius + sphere.radius;
- return sphere.center.distanceToSquared(this.center) <= radiusSum * radiusSum;
- },
- intersectsBox: function(box) {
- return box.intersectsSphere(this);
- },
- intersectsPlane: function(plane) {
- return Math.abs(plane.distanceToPoint(this.center)) <= this.radius;
- },
- clampPoint: function(point, target) {
- var deltaLengthSq = this.center.distanceToSquared(point);
- if (target === void 0) {
- console.warn("THREE.Sphere: .clampPoint() target is now required");
- target = new Vector3();
- }
- target.copy(point);
- if (deltaLengthSq > this.radius * this.radius) {
- target.sub(this.center).normalize();
- target.multiplyScalar(this.radius).add(this.center);
- }
- return target;
- },
- getBoundingBox: function(target) {
- if (target === void 0) {
- console.warn("THREE.Sphere: .getBoundingBox() target is now required");
- target = new Box3();
- }
- target.set(this.center, this.center);
- target.expandByScalar(this.radius);
- return target;
- },
- applyMatrix4: function(matrix) {
- this.center.applyMatrix4(matrix);
- this.radius = this.radius * matrix.getMaxScaleOnAxis();
- return this;
- },
- translate: function(offset) {
- this.center.add(offset);
- return this;
- },
- equals: function(sphere) {
- return sphere.center.equals(this.center) && sphere.radius === this.radius;
- }
- });
- var _vector$2 = new Vector3();
- var _segCenter = new Vector3();
- var _segDir = new Vector3();
- var _diff = new Vector3();
- var _edge1 = new Vector3();
- var _edge2 = new Vector3();
- var _normal = new Vector3();
- function Ray(origin, direction) {
- this.origin = origin !== void 0 ? origin : new Vector3();
- this.direction = direction !== void 0 ? direction : new Vector3(0, 0, -1);
- }
- Object.assign(Ray.prototype, {
- set: function(origin, direction) {
- this.origin.copy(origin);
- this.direction.copy(direction);
- return this;
- },
- clone: function() {
- return new this.constructor().copy(this);
- },
- copy: function(ray) {
- this.origin.copy(ray.origin);
- this.direction.copy(ray.direction);
- return this;
- },
- at: function(t, target) {
- if (target === void 0) {
- console.warn("THREE.Ray: .at() target is now required");
- target = new Vector3();
- }
- return target.copy(this.direction).multiplyScalar(t).add(this.origin);
- },
- lookAt: function(v) {
- this.direction.copy(v).sub(this.origin).normalize();
- return this;
- },
- recast: function(t) {
- this.origin.copy(this.at(t, _vector$2));
- return this;
- },
- closestPointToPoint: function(point, target) {
- if (target === void 0) {
- console.warn("THREE.Ray: .closestPointToPoint() target is now required");
- target = new Vector3();
- }
- target.subVectors(point, this.origin);
- var directionDistance = target.dot(this.direction);
- if (directionDistance < 0) {
- return target.copy(this.origin);
- }
- return target.copy(this.direction).multiplyScalar(directionDistance).add(this.origin);
- },
- distanceToPoint: function(point) {
- return Math.sqrt(this.distanceSqToPoint(point));
- },
- distanceSqToPoint: function(point) {
- var directionDistance = _vector$2.subVectors(point, this.origin).dot(this.direction);
- if (directionDistance < 0) {
- return this.origin.distanceToSquared(point);
- }
- _vector$2.copy(this.direction).multiplyScalar(directionDistance).add(this.origin);
- return _vector$2.distanceToSquared(point);
- },
- distanceSqToSegment: function(v0, v1, optionalPointOnRay, optionalPointOnSegment) {
- _segCenter.copy(v0).add(v1).multiplyScalar(0.5);
- _segDir.copy(v1).sub(v0).normalize();
- _diff.copy(this.origin).sub(_segCenter);
- var segExtent = v0.distanceTo(v1) * 0.5;
- var a01 = -this.direction.dot(_segDir);
- var b0 = _diff.dot(this.direction);
- var b1 = -_diff.dot(_segDir);
- var c = _diff.lengthSq();
- var det = Math.abs(1 - a01 * a01);
- var s0, s1, sqrDist, extDet;
- if (det > 0) {
- s0 = a01 * b1 - b0;
- s1 = a01 * b0 - b1;
- extDet = segExtent * det;
- if (s0 >= 0) {
- if (s1 >= -extDet) {
- if (s1 <= extDet) {
- var invDet = 1 / det;
- s0 *= invDet;
- s1 *= invDet;
- sqrDist = s0 * (s0 + a01 * s1 + 2 * b0) + s1 * (a01 * s0 + s1 + 2 * b1) + c;
- } else {
- s1 = segExtent;
- s0 = Math.max(0, -(a01 * s1 + b0));
- sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
- }
- } else {
- s1 = -segExtent;
- s0 = Math.max(0, -(a01 * s1 + b0));
- sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
- }
- } else {
- if (s1 <= -extDet) {
- s0 = Math.max(0, -(-a01 * segExtent + b0));
- s1 = s0 > 0 ? -segExtent : Math.min(Math.max(-segExtent, -b1), segExtent);
- sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
- } else if (s1 <= extDet) {
- s0 = 0;
- s1 = Math.min(Math.max(-segExtent, -b1), segExtent);
- sqrDist = s1 * (s1 + 2 * b1) + c;
- } else {
- s0 = Math.max(0, -(a01 * segExtent + b0));
- s1 = s0 > 0 ? segExtent : Math.min(Math.max(-segExtent, -b1), segExtent);
- sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
- }
- }
- } else {
- s1 = a01 > 0 ? -segExtent : segExtent;
- s0 = Math.max(0, -(a01 * s1 + b0));
- sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
- }
- if (optionalPointOnRay) {
- optionalPointOnRay.copy(this.direction).multiplyScalar(s0).add(this.origin);
- }
- if (optionalPointOnSegment) {
- optionalPointOnSegment.copy(_segDir).multiplyScalar(s1).add(_segCenter);
- }
- return sqrDist;
- },
- intersectSphere: function(sphere, target) {
- _vector$2.subVectors(sphere.center, this.origin);
- var tca = _vector$2.dot(this.direction);
- var d2 = _vector$2.dot(_vector$2) - tca * tca;
- var radius2 = sphere.radius * sphere.radius;
- if (d2 > radius2)
- return null;
- var thc = Math.sqrt(radius2 - d2);
- var t0 = tca - thc;
- var t1 = tca + thc;
- if (t0 < 0 && t1 < 0)
- return null;
- if (t0 < 0)
- return this.at(t1, target);
- return this.at(t0, target);
- },
- intersectsSphere: function(sphere) {
- return this.distanceSqToPoint(sphere.center) <= sphere.radius * sphere.radius;
- },
- distanceToPlane: function(plane) {
- var denominator = plane.normal.dot(this.direction);
- if (denominator === 0) {
- if (plane.distanceToPoint(this.origin) === 0) {
- return 0;
- }
- return null;
- }
- var t = -(this.origin.dot(plane.normal) + plane.constant) / denominator;
- return t >= 0 ? t : null;
- },
- intersectPlane: function(plane, target) {
- var t = this.distanceToPlane(plane);
- if (t === null) {
- return null;
- }
- return this.at(t, target);
- },
- intersectsPlane: function(plane) {
- var distToPoint = plane.distanceToPoint(this.origin);
- if (distToPoint === 0) {
- return true;
- }
- var denominator = plane.normal.dot(this.direction);
- if (denominator * distToPoint < 0) {
- return true;
- }
- return false;
- },
- intersectBox: function(box, target) {
- var tmin, tmax, tymin, tymax, tzmin, tzmax;
- var invdirx = 1 / this.direction.x, invdiry = 1 / this.direction.y, invdirz = 1 / this.direction.z;
- var origin = this.origin;
- if (invdirx >= 0) {
- tmin = (box.min.x - origin.x) * invdirx;
- tmax = (box.max.x - origin.x) * invdirx;
- } else {
- tmin = (box.max.x - origin.x) * invdirx;
- tmax = (box.min.x - origin.x) * invdirx;
- }
- if (invdiry >= 0) {
- tymin = (box.min.y - origin.y) * invdiry;
- tymax = (box.max.y - origin.y) * invdiry;
- } else {
- tymin = (box.max.y - origin.y) * invdiry;
- tymax = (box.min.y - origin.y) * invdiry;
- }
- if (tmin > tymax || tymin > tmax)
- return null;
- if (tymin > tmin || tmin !== tmin)
- tmin = tymin;
- if (tymax < tmax || tmax !== tmax)
- tmax = tymax;
- if (invdirz >= 0) {
- tzmin = (box.min.z - origin.z) * invdirz;
- tzmax = (box.max.z - origin.z) * invdirz;
- } else {
- tzmin = (box.max.z - origin.z) * invdirz;
- tzmax = (box.min.z - origin.z) * invdirz;
- }
- if (tmin > tzmax || tzmin > tmax)
- return null;
- if (tzmin > tmin || tmin !== tmin)
- tmin = tzmin;
- if (tzmax < tmax || tmax !== tmax)
- tmax = tzmax;
- if (tmax < 0)
- return null;
- return this.at(tmin >= 0 ? tmin : tmax, target);
- },
- intersectsBox: function(box) {
- return this.intersectBox(box, _vector$2) !== null;
- },
- intersectTriangle: function(a, b, c, backfaceCulling, target) {
- _edge1.subVectors(b, a);
- _edge2.subVectors(c, a);
- _normal.crossVectors(_edge1, _edge2);
- var DdN = this.direction.dot(_normal);
- var sign;
- if (DdN > 0) {
- if (backfaceCulling)
- return null;
- sign = 1;
- } else if (DdN < 0) {
- sign = -1;
- DdN = -DdN;
- } else {
- return null;
- }
- _diff.subVectors(this.origin, a);
- var DdQxE2 = sign * this.direction.dot(_edge2.crossVectors(_diff, _edge2));
- if (DdQxE2 < 0) {
- return null;
- }
- var DdE1xQ = sign * this.direction.dot(_edge1.cross(_diff));
- if (DdE1xQ < 0) {
- return null;
- }
- if (DdQxE2 + DdE1xQ > DdN) {
- return null;
- }
- var QdN = -sign * _diff.dot(_normal);
- if (QdN < 0) {
- return null;
- }
- return this.at(QdN / DdN, target);
- },
- applyMatrix4: function(matrix4) {
- this.origin.applyMatrix4(matrix4);
- this.direction.transformDirection(matrix4);
- return this;
- },
- equals: function(ray) {
- return ray.origin.equals(this.origin) && ray.direction.equals(this.direction);
- }
- });
- var _vector1 = new Vector3();
- var _vector2 = new Vector3();
- var _normalMatrix = new Matrix3();
- function Plane(normal, constant) {
- this.normal = normal !== void 0 ? normal : new Vector3(1, 0, 0);
- this.constant = constant !== void 0 ? constant : 0;
- }
- Object.assign(Plane.prototype, {
- isPlane: true,
- set: function(normal, constant) {
- this.normal.copy(normal);
- this.constant = constant;
- return this;
- },
- setComponents: function(x, y, z, w) {
- this.normal.set(x, y, z);
- this.constant = w;
- return this;
- },
- setFromNormalAndCoplanarPoint: function(normal, point) {
- this.normal.copy(normal);
- this.constant = -point.dot(this.normal);
- return this;
- },
- setFromCoplanarPoints: function(a, b, c) {
- var normal = _vector1.subVectors(c, b).cross(_vector2.subVectors(a, b)).normalize();
- this.setFromNormalAndCoplanarPoint(normal, a);
- return this;
- },
- clone: function() {
- return new this.constructor().copy(this);
- },
- copy: function(plane) {
- this.normal.copy(plane.normal);
- this.constant = plane.constant;
- return this;
- },
- normalize: function() {
- var inverseNormalLength = 1 / this.normal.length();
- this.normal.multiplyScalar(inverseNormalLength);
- this.constant *= inverseNormalLength;
- return this;
- },
- negate: function() {
- this.constant *= -1;
- this.normal.negate();
- return this;
- },
- distanceToPoint: function(point) {
- return this.normal.dot(point) + this.constant;
- },
- distanceToSphere: function(sphere) {
- return this.distanceToPoint(sphere.center) - sphere.radius;
- },
- projectPoint: function(point, target) {
- if (target === void 0) {
- console.warn("THREE.Plane: .projectPoint() target is now required");
- target = new Vector3();
- }
- return target.copy(this.normal).multiplyScalar(-this.distanceToPoint(point)).add(point);
- },
- intersectLine: function(line, target) {
- if (target === void 0) {
- console.warn("THREE.Plane: .intersectLine() target is now required");
- target = new Vector3();
- }
- var direction = line.delta(_vector1);
- var denominator = this.normal.dot(direction);
- if (denominator === 0) {
- if (this.distanceToPoint(line.start) === 0) {
- return target.copy(line.start);
- }
- return void 0;
- }
- var t = -(line.start.dot(this.normal) + this.constant) / denominator;
- if (t < 0 || t > 1) {
- return void 0;
- }
- return target.copy(direction).multiplyScalar(t).add(line.start);
- },
- intersectsLine: function(line) {
- var startSign = this.distanceToPoint(line.start);
- var endSign = this.distanceToPoint(line.end);
- return startSign < 0 && endSign > 0 || endSign < 0 && startSign > 0;
- },
- intersectsBox: function(box) {
- return box.intersectsPlane(this);
- },
- intersectsSphere: function(sphere) {
- return sphere.intersectsPlane(this);
- },
- coplanarPoint: function(target) {
- if (target === void 0) {
- console.warn("THREE.Plane: .coplanarPoint() target is now required");
- target = new Vector3();
- }
- return target.copy(this.normal).multiplyScalar(-this.constant);
- },
- applyMatrix4: function(matrix, optionalNormalMatrix) {
- var normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix(matrix);
- var referencePoint = this.coplanarPoint(_vector1).applyMatrix4(matrix);
- var normal = this.normal.applyMatrix3(normalMatrix).normalize();
- this.constant = -referencePoint.dot(normal);
- return this;
- },
- translate: function(offset) {
- this.constant -= offset.dot(this.normal);
- return this;
- },
- equals: function(plane) {
- return plane.normal.equals(this.normal) && plane.constant === this.constant;
- }
- });
- var _v0$1 = new Vector3();
- var _v1$3 = new Vector3();
- var _v2$1 = new Vector3();
- var _v3 = new Vector3();
- var _vab = new Vector3();
- var _vac = new Vector3();
- var _vbc = new Vector3();
- var _vap = new Vector3();
- var _vbp = new Vector3();
- var _vcp = new Vector3();
- function Triangle(a, b, c) {
- this.a = a !== void 0 ? a : new Vector3();
- this.b = b !== void 0 ? b : new Vector3();
- this.c = c !== void 0 ? c : new Vector3();
- }
- Object.assign(Triangle, {
- getNormal: function(a, b, c, target) {
- if (target === void 0) {
- console.warn("THREE.Triangle: .getNormal() target is now required");
- target = new Vector3();
- }
- target.subVectors(c, b);
- _v0$1.subVectors(a, b);
- target.cross(_v0$1);
- var targetLengthSq = target.lengthSq();
- if (targetLengthSq > 0) {
- return target.multiplyScalar(1 / Math.sqrt(targetLengthSq));
- }
- return target.set(0, 0, 0);
- },
- // static/instance method to calculate barycentric coordinates
- // based on: http://www.blackpawn.com/texts/pointinpoly/default.html
- getBarycoord: function(point, a, b, c, target) {
- _v0$1.subVectors(c, a);
- _v1$3.subVectors(b, a);
- _v2$1.subVectors(point, a);
- var dot00 = _v0$1.dot(_v0$1);
- var dot01 = _v0$1.dot(_v1$3);
- var dot02 = _v0$1.dot(_v2$1);
- var dot11 = _v1$3.dot(_v1$3);
- var dot12 = _v1$3.dot(_v2$1);
- var denom = dot00 * dot11 - dot01 * dot01;
- if (target === void 0) {
- console.warn("THREE.Triangle: .getBarycoord() target is now required");
- target = new Vector3();
- }
- if (denom === 0) {
- return target.set(-2, -1, -1);
- }
- var invDenom = 1 / denom;
- var u = (dot11 * dot02 - dot01 * dot12) * invDenom;
- var v = (dot00 * dot12 - dot01 * dot02) * invDenom;
- return target.set(1 - u - v, v, u);
- },
- containsPoint: function(point, a, b, c) {
- Triangle.getBarycoord(point, a, b, c, _v3);
- return _v3.x >= 0 && _v3.y >= 0 && _v3.x + _v3.y <= 1;
- },
- getUV: function(point, p1, p2, p3, uv1, uv2, uv3, target) {
- this.getBarycoord(point, p1, p2, p3, _v3);
- target.set(0, 0);
- target.addScaledVector(uv1, _v3.x);
- target.addScaledVector(uv2, _v3.y);
- target.addScaledVector(uv3, _v3.z);
- return target;
- },
- isFrontFacing: function(a, b, c, direction) {
- _v0$1.subVectors(c, b);
- _v1$3.subVectors(a, b);
- return _v0$1.cross(_v1$3).dot(direction) < 0 ? true : false;
- }
- });
- Object.assign(Triangle.prototype, {
- set: function(a, b, c) {
- this.a.copy(a);
- this.b.copy(b);
- this.c.copy(c);
- return this;
- },
- setFromPointsAndIndices: function(points, i0, i1, i2) {
- this.a.copy(points[i0]);
- this.b.copy(points[i1]);
- this.c.copy(points[i2]);
- return this;
- },
- clone: function() {
- return new this.constructor().copy(this);
- },
- copy: function(triangle) {
- this.a.copy(triangle.a);
- this.b.copy(triangle.b);
- this.c.copy(triangle.c);
- return this;
- },
- getArea: function() {
- _v0$1.subVectors(this.c, this.b);
- _v1$3.subVectors(this.a, this.b);
- return _v0$1.cross(_v1$3).length() * 0.5;
- },
- getMidpoint: function(target) {
- if (target === void 0) {
- console.warn("THREE.Triangle: .getMidpoint() target is now required");
- target = new Vector3();
- }
- return target.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3);
- },
- getNormal: function(target) {
- return Triangle.getNormal(this.a, this.b, this.c, target);
- },
- getPlane: function(target) {
- if (target === void 0) {
- console.warn("THREE.Triangle: .getPlane() target is now required");
- target = new Plane();
- }
- return target.setFromCoplanarPoints(this.a, this.b, this.c);
- },
- getBarycoord: function(point, target) {
- return Triangle.getBarycoord(point, this.a, this.b, this.c, target);
- },
- getUV: function(point, uv1, uv2, uv3, target) {
- return Triangle.getUV(point, this.a, this.b, this.c, uv1, uv2, uv3, target);
- },
- containsPoint: function(point) {
- return Triangle.containsPoint(point, this.a, this.b, this.c);
- },
- isFrontFacing: function(direction) {
- return Triangle.isFrontFacing(this.a, this.b, this.c, direction);
- },
- intersectsBox: function(box) {
- return box.intersectsTriangle(this);
- },
- closestPointToPoint: function(p, target) {
- if (target === void 0) {
- console.warn("THREE.Triangle: .closestPointToPoint() target is now required");
- target = new Vector3();
- }
- var a = this.a, b = this.b, c = this.c;
- var v, w;
- _vab.subVectors(b, a);
- _vac.subVectors(c, a);
- _vap.subVectors(p, a);
- var d1 = _vab.dot(_vap);
- var d2 = _vac.dot(_vap);
- if (d1 <= 0 && d2 <= 0) {
- return target.copy(a);
- }
- _vbp.subVectors(p, b);
- var d3 = _vab.dot(_vbp);
- var d4 = _vac.dot(_vbp);
- if (d3 >= 0 && d4 <= d3) {
- return target.copy(b);
- }
- var vc = d1 * d4 - d3 * d2;
- if (vc <= 0 && d1 >= 0 && d3 <= 0) {
- v = d1 / (d1 - d3);
- return target.copy(a).addScaledVector(_vab, v);
- }
- _vcp.subVectors(p, c);
- var d5 = _vab.dot(_vcp);
- var d6 = _vac.dot(_vcp);
- if (d6 >= 0 && d5 <= d6) {
- return target.copy(c);
- }
- var vb = d5 * d2 - d1 * d6;
- if (vb <= 0 && d2 >= 0 && d6 <= 0) {
- w = d2 / (d2 - d6);
- return target.copy(a).addScaledVector(_vac, w);
- }
- var va = d3 * d6 - d5 * d4;
- if (va <= 0 && d4 - d3 >= 0 && d5 - d6 >= 0) {
- _vbc.subVectors(c, b);
- w = (d4 - d3) / (d4 - d3 + (d5 - d6));
- return target.copy(b).addScaledVector(_vbc, w);
- }
- var denom = 1 / (va + vb + vc);
- v = vb * denom;
- w = vc * denom;
- return target.copy(a).addScaledVector(_vab, v).addScaledVector(_vac, w);
- },
- equals: function(triangle) {
- return triangle.a.equals(this.a) && triangle.b.equals(this.b) && triangle.c.equals(this.c);
- }
- });
- var _colorKeywords = {
- "aliceblue": 15792383,
- "antiquewhite": 16444375,
- "aqua": 65535,
- "aquamarine": 8388564,
- "azure": 15794175,
- "beige": 16119260,
- "bisque": 16770244,
- "black": 0,
- "blanchedalmond": 16772045,
- "blue": 255,
- "blueviolet": 9055202,
- "brown": 10824234,
- "burlywood": 14596231,
- "cadetblue": 6266528,
- "chartreuse": 8388352,
- "chocolate": 13789470,
- "coral": 16744272,
- "cornflowerblue": 6591981,
- "cornsilk": 16775388,
- "crimson": 14423100,
- "cyan": 65535,
- "darkblue": 139,
- "darkcyan": 35723,
- "darkgoldenrod": 12092939,
- "darkgray": 11119017,
- "darkgreen": 25600,
- "darkgrey": 11119017,
- "darkkhaki": 12433259,
- "darkmagenta": 9109643,
- "darkolivegreen": 5597999,
- "darkorange": 16747520,
- "darkorchid": 10040012,
- "darkred": 9109504,
- "darksalmon": 15308410,
- "darkseagreen": 9419919,
- "darkslateblue": 4734347,
- "darkslategray": 3100495,
- "darkslategrey": 3100495,
- "darkturquoise": 52945,
- "darkviolet": 9699539,
- "deeppink": 16716947,
- "deepskyblue": 49151,
- "dimgray": 6908265,
- "dimgrey": 6908265,
- "dodgerblue": 2003199,
- "firebrick": 11674146,
- "floralwhite": 16775920,
- "forestgreen": 2263842,
- "fuchsia": 16711935,
- "gainsboro": 14474460,
- "ghostwhite": 16316671,
- "gold": 16766720,
- "goldenrod": 14329120,
- "gray": 8421504,
- "green": 32768,
- "greenyellow": 11403055,
- "grey": 8421504,
- "honeydew": 15794160,
- "hotpink": 16738740,
- "indianred": 13458524,
- "indigo": 4915330,
- "ivory": 16777200,
- "khaki": 15787660,
- "lavender": 15132410,
- "lavenderblush": 16773365,
- "lawngreen": 8190976,
- "lemonchiffon": 16775885,
- "lightblue": 11393254,
- "lightcoral": 15761536,
- "lightcyan": 14745599,
- "lightgoldenrodyellow": 16448210,
- "lightgray": 13882323,
- "lightgreen": 9498256,
- "lightgrey": 13882323,
- "lightpink": 16758465,
- "lightsalmon": 16752762,
- "lightseagreen": 2142890,
- "lightskyblue": 8900346,
- "lightslategray": 7833753,
- "lightslategrey": 7833753,
- "lightsteelblue": 11584734,
- "lightyellow": 16777184,
- "lime": 65280,
- "limegreen": 3329330,
- "linen": 16445670,
- "magenta": 16711935,
- "maroon": 8388608,
- "mediumaquamarine": 6737322,
- "mediumblue": 205,
- "mediumorchid": 12211667,
- "mediumpurple": 9662683,
- "mediumseagreen": 3978097,
- "mediumslateblue": 8087790,
- "mediumspringgreen": 64154,
- "mediumturquoise": 4772300,
- "mediumvioletred": 13047173,
- "midnightblue": 1644912,
- "mintcream": 16121850,
- "mistyrose": 16770273,
- "moccasin": 16770229,
- "navajowhite": 16768685,
- "navy": 128,
- "oldlace": 16643558,
- "olive": 8421376,
- "olivedrab": 7048739,
- "orange": 16753920,
- "orangered": 16729344,
- "orchid": 14315734,
- "palegoldenrod": 15657130,
- "palegreen": 10025880,
- "paleturquoise": 11529966,
- "palevioletred": 14381203,
- "papayawhip": 16773077,
- "peachpuff": 16767673,
- "peru": 13468991,
- "pink": 16761035,
- "plum": 14524637,
- "powderblue": 11591910,
- "purple": 8388736,
- "rebeccapurple": 6697881,
- "red": 16711680,
- "rosybrown": 12357519,
- "royalblue": 4286945,
- "saddlebrown": 9127187,
- "salmon": 16416882,
- "sandybrown": 16032864,
- "seagreen": 3050327,
- "seashell": 16774638,
- "sienna": 10506797,
- "silver": 12632256,
- "skyblue": 8900331,
- "slateblue": 6970061,
- "slategray": 7372944,
- "slategrey": 7372944,
- "snow": 16775930,
- "springgreen": 65407,
- "steelblue": 4620980,
- "tan": 13808780,
- "teal": 32896,
- "thistle": 14204888,
- "tomato": 16737095,
- "turquoise": 4251856,
- "violet": 15631086,
- "wheat": 16113331,
- "white": 16777215,
- "whitesmoke": 16119285,
- "yellow": 16776960,
- "yellowgreen": 10145074
- };
- var _hslA = { h: 0, s: 0, l: 0 };
- var _hslB = { h: 0, s: 0, l: 0 };
- function Color(r, g, b) {
- if (g === void 0 && b === void 0) {
- return this.set(r);
- }
- return this.setRGB(r, g, b);
- }
- function hue2rgb(p, q, t) {
- if (t < 0)
- t += 1;
- if (t > 1)
- t -= 1;
- if (t < 1 / 6)
- return p + (q - p) * 6 * t;
- if (t < 1 / 2)
- return q;
- if (t < 2 / 3)
- return p + (q - p) * 6 * (2 / 3 - t);
- return p;
- }
- function SRGBToLinear(c) {
- return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
- }
- function LinearToSRGB(c) {
- return c < 31308e-7 ? c * 12.92 : 1.055 * Math.pow(c, 0.41666) - 0.055;
- }
- Object.assign(Color.prototype, {
- isColor: true,
- r: 1,
- g: 1,
- b: 1,
- set: function(value) {
- if (value && value.isColor) {
- this.copy(value);
- } else if (typeof value === "number") {
- this.setHex(value);
- } else if (typeof value === "string") {
- this.setStyle(value);
- }
- return this;
- },
- setScalar: function(scalar) {
- this.r = scalar;
- this.g = scalar;
- this.b = scalar;
- return this;
- },
- setHex: function(hex) {
- hex = Math.floor(hex);
- this.r = (hex >> 16 & 255) / 255;
- this.g = (hex >> 8 & 255) / 255;
- this.b = (hex & 255) / 255;
- return this;
- },
- setRGB: function(r, g, b) {
- this.r = r;
- this.g = g;
- this.b = b;
- return this;
- },
- setHSL: function(h, s, l) {
- h = MathUtils.euclideanModulo(h, 1);
- s = MathUtils.clamp(s, 0, 1);
- l = MathUtils.clamp(l, 0, 1);
- if (s === 0) {
- this.r = this.g = this.b = l;
- } else {
- var p = l <= 0.5 ? l * (1 + s) : l + s - l * s;
- var q = 2 * l - p;
- this.r = hue2rgb(q, p, h + 1 / 3);
- this.g = hue2rgb(q, p, h);
- this.b = hue2rgb(q, p, h - 1 / 3);
- }
- return this;
- },
- setStyle: function(style) {
- function handleAlpha(string) {
- if (string === void 0)
- return;
- if (parseFloat(string) < 1) {
- console.warn("THREE.Color: Alpha component of " + style + " will be ignored.");
- }
- }
- var m;
- if (m = /^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(style)) {
- var color;
- var name = m[1];
- var components = m[2];
- switch (name) {
- case "rgb":
- case "rgba":
- if (color = /^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(components)) {
- this.r = Math.min(255, parseInt(color[1], 10)) / 255;
- this.g = Math.min(255, parseInt(color[2], 10)) / 255;
- this.b = Math.min(255, parseInt(color[3], 10)) / 255;
- handleAlpha(color[5]);
- return this;
- }
- if (color = /^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(components)) {
- this.r = Math.min(100, parseInt(color[1], 10)) / 100;
- this.g = Math.min(100, parseInt(color[2], 10)) / 100;
- this.b = Math.min(100, parseInt(color[3], 10)) / 100;
- handleAlpha(color[5]);
- return this;
- }
- break;
- case "hsl":
- case "hsla":
- if (color = /^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(components)) {
- var h = parseFloat(color[1]) / 360;
- var s = parseInt(color[2], 10) / 100;
- var l = parseInt(color[3], 10) / 100;
- handleAlpha(color[5]);
- return this.setHSL(h, s, l);
- }
- break;
- }
- } else if (m = /^\#([A-Fa-f0-9]+)$/.exec(style)) {
- var hex = m[1];
- var size = hex.length;
- if (size === 3) {
- this.r = parseInt(hex.charAt(0) + hex.charAt(0), 16) / 255;
- this.g = parseInt(hex.charAt(1) + hex.charAt(1), 16) / 255;
- this.b = parseInt(hex.charAt(2) + hex.charAt(2), 16) / 255;
- return this;
- } else if (size === 6) {
- this.r = parseInt(hex.charAt(0) + hex.charAt(1), 16) / 255;
- this.g = parseInt(hex.charAt(2) + hex.charAt(3), 16) / 255;
- this.b = parseInt(hex.charAt(4) + hex.charAt(5), 16) / 255;
- return this;
- }
- }
- if (style && style.length > 0) {
- return this.setColorName(style);
- }
- return this;
- },
- setColorName: function(style) {
- var hex = _colorKeywords[style];
- if (hex !== void 0) {
- this.setHex(hex);
- } else {
- console.warn("THREE.Color: Unknown color " + style);
- }
- return this;
- },
- clone: function() {
- return new this.constructor(this.r, this.g, this.b);
- },
- copy: function(color) {
- this.r = color.r;
- this.g = color.g;
- this.b = color.b;
- return this;
- },
- copyGammaToLinear: function(color, gammaFactor) {
- if (gammaFactor === void 0)
- gammaFactor = 2;
- this.r = Math.pow(color.r, gammaFactor);
- this.g = Math.pow(color.g, gammaFactor);
- this.b = Math.pow(color.b, gammaFactor);
- return this;
- },
- copyLinearToGamma: function(color, gammaFactor) {
- if (gammaFactor === void 0)
- gammaFactor = 2;
- var safeInverse = gammaFactor > 0 ? 1 / gammaFactor : 1;
- this.r = Math.pow(color.r, safeInverse);
- this.g = Math.pow(color.g, safeInverse);
- this.b = Math.pow(color.b, safeInverse);
- return this;
- },
- convertGammaToLinear: function(gammaFactor) {
- this.copyGammaToLinear(this, gammaFactor);
- return this;
- },
- convertLinearToGamma: function(gammaFactor) {
- this.copyLinearToGamma(this, gammaFactor);
- return this;
- },
- copySRGBToLinear: function(color) {
- this.r = SRGBToLinear(color.r);
- this.g = SRGBToLinear(color.g);
- this.b = SRGBToLinear(color.b);
- return this;
- },
- copyLinearToSRGB: function(color) {
- this.r = LinearToSRGB(color.r);
- this.g = LinearToSRGB(color.g);
- this.b = LinearToSRGB(color.b);
- return this;
- },
- convertSRGBToLinear: function() {
- this.copySRGBToLinear(this);
- return this;
- },
- convertLinearToSRGB: function() {
- this.copyLinearToSRGB(this);
- return this;
- },
- getHex: function() {
- return this.r * 255 << 16 ^ this.g * 255 << 8 ^ this.b * 255 << 0;
- },
- getHexString: function() {
- return ("000000" + this.getHex().toString(16)).slice(-6);
- },
- getHSL: function(target) {
- if (target === void 0) {
- console.warn("THREE.Color: .getHSL() target is now required");
- target = { h: 0, s: 0, l: 0 };
- }
- var r = this.r, g = this.g, b = this.b;
- var max = Math.max(r, g, b);
- var min = Math.min(r, g, b);
- var hue, saturation;
- var lightness = (min + max) / 2;
- if (min === max) {
- hue = 0;
- saturation = 0;
- } else {
- var delta = max - min;
- saturation = lightness <= 0.5 ? delta / (max + min) : delta / (2 - max - min);
- switch (max) {
- case r:
- hue = (g - b) / delta + (g < b ? 6 : 0);
- break;
- case g:
- hue = (b - r) / delta + 2;
- break;
- case b:
- hue = (r - g) / delta + 4;
- break;
- }
- hue /= 6;
- }
- target.h = hue;
- target.s = saturation;
- target.l = lightness;
- return target;
- },
- getStyle: function() {
- return "rgb(" + (this.r * 255 | 0) + "," + (this.g * 255 | 0) + "," + (this.b * 255 | 0) + ")";
- },
- offsetHSL: function(h, s, l) {
- this.getHSL(_hslA);
- _hslA.h += h;
- _hslA.s += s;
- _hslA.l += l;
- this.setHSL(_hslA.h, _hslA.s, _hslA.l);
- return this;
- },
- add: function(color) {
- this.r += color.r;
- this.g += color.g;
- this.b += color.b;
- return this;
- },
- addColors: function(color1, color2) {
- this.r = color1.r + color2.r;
- this.g = color1.g + color2.g;
- this.b = color1.b + color2.b;
- return this;
- },
- addScalar: function(s) {
- this.r += s;
- this.g += s;
- this.b += s;
- return this;
- },
- sub: function(color) {
- this.r = Math.max(0, this.r - color.r);
- this.g = Math.max(0, this.g - color.g);
- this.b = Math.max(0, this.b - color.b);
- return this;
- },
- multiply: function(color) {
- this.r *= color.r;
- this.g *= color.g;
- this.b *= color.b;
- return this;
- },
- multiplyScalar: function(s) {
- this.r *= s;
- this.g *= s;
- this.b *= s;
- return this;
- },
- lerp: function(color, alpha) {
- this.r += (color.r - this.r) * alpha;
- this.g += (color.g - this.g) * alpha;
- this.b += (color.b - this.b) * alpha;
- return this;
- },
- lerpHSL: function(color, alpha) {
- this.getHSL(_hslA);
- color.getHSL(_hslB);
- var h = MathUtils.lerp(_hslA.h, _hslB.h, alpha);
- var s = MathUtils.lerp(_hslA.s, _hslB.s, alpha);
- var l = MathUtils.lerp(_hslA.l, _hslB.l, alpha);
- this.setHSL(h, s, l);
- return this;
- },
- equals: function(c) {
- return c.r === this.r && c.g === this.g && c.b === this.b;
- },
- fromArray: function(array, offset) {
- if (offset === void 0)
- offset = 0;
- this.r = array[offset];
- this.g = array[offset + 1];
- this.b = array[offset + 2];
- return this;
- },
- toArray: function(array, offset) {
- if (array === void 0)
- array = [];
- if (offset === void 0)
- offset = 0;
- array[offset] = this.r;
- array[offset + 1] = this.g;
- array[offset + 2] = this.b;
- return array;
- },
- toJSON: function() {
- return this.getHex();
- }
- });
- Color.NAMES = _colorKeywords;
- function Face3(a, b, c, normal, color, materialIndex) {
- this.a = a;
- this.b = b;
- this.c = c;
- this.normal = normal && normal.isVector3 ? normal : new Vector3();
- this.vertexNormals = Array.isArray(normal) ? normal : [];
- this.color = color && color.isColor ? color : new Color();
- this.vertexColors = Array.isArray(color) ? color : [];
- this.materialIndex = materialIndex !== void 0 ? materialIndex : 0;
- }
- Object.assign(Face3.prototype, {
- clone: function() {
- return new this.constructor().copy(this);
- },
- copy: function(source) {
- this.a = source.a;
- this.b = source.b;
- this.c = source.c;
- this.normal.copy(source.normal);
- this.color.copy(source.color);
- this.materialIndex = source.materialIndex;
- for (var i2 = 0, il = source.vertexNormals.length; i2 < il; i2++) {
- this.vertexNormals[i2] = source.vertexNormals[i2].clone();
- }
- for (var i2 = 0, il = source.vertexColors.length; i2 < il; i2++) {
- this.vertexColors[i2] = source.vertexColors[i2].clone();
- }
- return this;
- }
- });
- var materialId = 0;
- function Material() {
- Object.defineProperty(this, "id", { value: materialId++ });
- this.uuid = MathUtils.generateUUID();
- this.name = "";
- this.type = "Material";
- this.fog = true;
- this.blending = NormalBlending;
- this.side = FrontSide;
- this.flatShading = false;
- this.vertexTangents = false;
- this.vertexColors = NoColors;
- this.opacity = 1;
- this.transparent = false;
- this.blendSrc = SrcAlphaFactor;
- this.blendDst = OneMinusSrcAlphaFactor;
- this.blendEquation = AddEquation;
- this.blendSrcAlpha = null;
- this.blendDstAlpha = null;
- this.blendEquationAlpha = null;
- this.depthFunc = LessEqualDepth;
- this.depthTest = true;
- this.depthWrite = true;
- this.stencilWriteMask = 255;
- this.stencilFunc = AlwaysStencilFunc;
- this.stencilRef = 0;
- this.stencilFuncMask = 255;
- this.stencilFail = KeepStencilOp;
- this.stencilZFail = KeepStencilOp;
- this.stencilZPass = KeepStencilOp;
- this.stencilWrite = false;
- this.clippingPlanes = null;
- this.clipIntersection = false;
- this.clipShadows = false;
- this.shadowSide = null;
- this.colorWrite = true;
- this.precision = null;
- this.polygonOffset = false;
- this.polygonOffsetFactor = 0;
- this.polygonOffsetUnits = 0;
- this.dithering = false;
- this.alphaTest = 0;
- this.premultipliedAlpha = false;
- this.visible = true;
- this.toneMapped = true;
- this.userData = {};
- this.version = 0;
- }
- Material.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
- constructor: Material,
- isMaterial: true,
- onBeforeCompile: function() {
- },
- setValues: function(values) {
- if (values === void 0)
- return;
- for (var key in values) {
- var newValue = values[key];
- if (newValue === void 0) {
- console.warn("THREE.Material: '" + key + "' parameter is undefined.");
- continue;
- }
- if (key === "shading") {
- console.warn("THREE." + this.type + ": .shading has been removed. Use the boolean .flatShading instead.");
- this.flatShading = newValue === FlatShading ? true : false;
- continue;
- }
- var currentValue = this[key];
- if (currentValue === void 0) {
- console.warn("THREE." + this.type + ": '" + key + "' is not a property of this material.");
- continue;
- }
- if (currentValue && currentValue.isColor) {
- currentValue.set(newValue);
- } else if (currentValue && currentValue.isVector3 && (newValue && newValue.isVector3)) {
- currentValue.copy(newValue);
- } else {
- this[key] = newValue;
- }
- }
- },
- toJSON: function(meta) {
- var isRoot = meta === void 0 || typeof meta === "string";
- if (isRoot) {
- meta = {
- textures: {},
- images: {}
- };
- }
- var data = {
- metadata: {
- version: 4.5,
- type: "Material",
- generator: "Material.toJSON"
- }
- };
- data.uuid = this.uuid;
- data.type = this.type;
- if (this.name !== "")
- data.name = this.name;
- if (this.color && this.color.isColor)
- data.color = this.color.getHex();
- if (this.roughness !== void 0)
- data.roughness = this.roughness;
- if (this.metalness !== void 0)
- data.metalness = this.metalness;
- if (this.sheen && this.sheen.isColor)
- data.sheen = this.sheen.getHex();
- if (this.emissive && this.emissive.isColor)
- data.emissive = this.emissive.getHex();
- if (this.emissiveIntensity && this.emissiveIntensity !== 1)
- data.emissiveIntensity = this.emissiveIntensity;
- if (this.specular && this.specular.isColor)
- data.specular = this.specular.getHex();
- if (this.shininess !== void 0)
- data.shininess = this.shininess;
- if (this.clearcoat !== void 0)
- data.clearcoat = this.clearcoat;
- if (this.clearcoatRoughness !== void 0)
- data.clearcoatRoughness = this.clearcoatRoughness;
- if (this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture) {
- data.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(meta).uuid;
- data.clearcoatNormalScale = this.clearcoatNormalScale.toArray();
- }
- if (this.map && this.map.isTexture)
- data.map = this.map.toJSON(meta).uuid;
- if (this.matcap && this.matcap.isTexture)
- data.matcap = this.matcap.toJSON(meta).uuid;
- if (this.alphaMap && this.alphaMap.isTexture)
- data.alphaMap = this.alphaMap.toJSON(meta).uuid;
- if (this.lightMap && this.lightMap.isTexture)
- data.lightMap = this.lightMap.toJSON(meta).uuid;
- if (this.aoMap && this.aoMap.isTexture) {
- data.aoMap = this.aoMap.toJSON(meta).uuid;
- data.aoMapIntensity = this.aoMapIntensity;
- }
- if (this.bumpMap && this.bumpMap.isTexture) {
- data.bumpMap = this.bumpMap.toJSON(meta).uuid;
- data.bumpScale = this.bumpScale;
- }
- if (this.normalMap && this.normalMap.isTexture) {
- data.normalMap = this.normalMap.toJSON(meta).uuid;
- data.normalMapType = this.normalMapType;
- data.normalScale = this.normalScale.toArray();
- }
- if (this.displacementMap && this.displacementMap.isTexture) {
- data.displacementMap = this.displacementMap.toJSON(meta).uuid;
- data.displacementScale = this.displacementScale;
- data.displacementBias = this.displacementBias;
- }
- if (this.roughnessMap && this.roughnessMap.isTexture)
- data.roughnessMap = this.roughnessMap.toJSON(meta).uuid;
- if (this.metalnessMap && this.metalnessMap.isTexture)
- data.metalnessMap = this.metalnessMap.toJSON(meta).uuid;
- if (this.emissiveMap && this.emissiveMap.isTexture)
- data.emissiveMap = this.emissiveMap.toJSON(meta).uuid;
- if (this.specularMap && this.specularMap.isTexture)
- data.specularMap = this.specularMap.toJSON(meta).uuid;
- if (this.envMap && this.envMap.isTexture) {
- data.envMap = this.envMap.toJSON(meta).uuid;
- data.reflectivity = this.reflectivity;
- data.refractionRatio = this.refractionRatio;
- if (this.combine !== void 0)
- data.combine = this.combine;
- if (this.envMapIntensity !== void 0)
- data.envMapIntensity = this.envMapIntensity;
- }
- if (this.gradientMap && this.gradientMap.isTexture) {
- data.gradientMap = this.gradientMap.toJSON(meta).uuid;
- }
- if (this.size !== void 0)
- data.size = this.size;
- if (this.sizeAttenuation !== void 0)
- data.sizeAttenuation = this.sizeAttenuation;
- if (this.blending !== NormalBlending)
- data.blending = this.blending;
- if (this.flatShading === true)
- data.flatShading = this.flatShading;
- if (this.side !== FrontSide)
- data.side = this.side;
- if (this.vertexColors !== NoColors)
- data.vertexColors = this.vertexColors;
- if (this.opacity < 1)
- data.opacity = this.opacity;
- if (this.transparent === true)
- data.transparent = this.transparent;
- data.depthFunc = this.depthFunc;
- data.depthTest = this.depthTest;
- data.depthWrite = this.depthWrite;
- data.stencilWrite = this.stencilWrite;
- data.stencilWriteMask = this.stencilWriteMask;
- data.stencilFunc = this.stencilFunc;
- data.stencilRef = this.stencilRef;
- data.stencilFuncMask = this.stencilFuncMask;
- data.stencilFail = this.stencilFail;
- data.stencilZFail = this.stencilZFail;
- data.stencilZPass = this.stencilZPass;
- if (this.rotation && this.rotation !== 0)
- data.rotation = this.rotation;
- if (this.polygonOffset === true)
- data.polygonOffset = true;
- if (this.polygonOffsetFactor !== 0)
- data.polygonOffsetFactor = this.polygonOffsetFactor;
- if (this.polygonOffsetUnits !== 0)
- data.polygonOffsetUnits = this.polygonOffsetUnits;
- if (this.linewidth && this.linewidth !== 1)
- data.linewidth = this.linewidth;
- if (this.dashSize !== void 0)
- data.dashSize = this.dashSize;
- if (this.gapSize !== void 0)
- data.gapSize = this.gapSize;
- if (this.scale !== void 0)
- data.scale = this.scale;
- if (this.dithering === true)
- data.dithering = true;
- if (this.alphaTest > 0)
- data.alphaTest = this.alphaTest;
- if (this.premultipliedAlpha === true)
- data.premultipliedAlpha = this.premultipliedAlpha;
- if (this.wireframe === true)
- data.wireframe = this.wireframe;
- if (this.wireframeLinewidth > 1)
- data.wireframeLinewidth = this.wireframeLinewidth;
- if (this.wireframeLinecap !== "round")
- data.wireframeLinecap = this.wireframeLinecap;
- if (this.wireframeLinejoin !== "round")
- data.wireframeLinejoin = this.wireframeLinejoin;
- if (this.morphTargets === true)
- data.morphTargets = true;
- if (this.morphNormals === true)
- data.morphNormals = true;
- if (this.skinning === true)
- data.skinning = true;
- if (this.visible === false)
- data.visible = false;
- if (this.toneMapped === false)
- data.toneMapped = false;
- if (JSON.stringify(this.userData) !== "{}")
- data.userData = this.userData;
- function extractFromCache(cache) {
- var values = [];
- for (var key in cache) {
- var data2 = cache[key];
- delete data2.metadata;
- values.push(data2);
- }
- return values;
- }
- if (isRoot) {
- var textures = extractFromCache(meta.textures);
- var images = extractFromCache(meta.images);
- if (textures.length > 0)
- data.textures = textures;
- if (images.length > 0)
- data.images = images;
- }
- return data;
- },
- clone: function() {
- return new this.constructor().copy(this);
- },
- copy: function(source) {
- this.name = source.name;
- this.fog = source.fog;
- this.blending = source.blending;
- this.side = source.side;
- this.flatShading = source.flatShading;
- this.vertexTangents = source.vertexTangents;
- this.vertexColors = source.vertexColors;
- this.opacity = source.opacity;
- this.transparent = source.transparent;
- this.blendSrc = source.blendSrc;
- this.blendDst = source.blendDst;
- this.blendEquation = source.blendEquation;
- this.blendSrcAlpha = source.blendSrcAlpha;
- this.blendDstAlpha = source.blendDstAlpha;
- this.blendEquationAlpha = source.blendEquationAlpha;
- this.depthFunc = source.depthFunc;
- this.depthTest = source.depthTest;
- this.depthWrite = source.depthWrite;
- this.stencilWriteMask = source.stencilWriteMask;
- this.stencilFunc = source.stencilFunc;
- this.stencilRef = source.stencilRef;
- this.stencilFuncMask = source.stencilFuncMask;
- this.stencilFail = source.stencilFail;
- this.stencilZFail = source.stencilZFail;
- this.stencilZPass = source.stencilZPass;
- this.stencilWrite = source.stencilWrite;
- var srcPlanes = source.clippingPlanes, dstPlanes = null;
- if (srcPlanes !== null) {
- var n = srcPlanes.length;
- dstPlanes = new Array(n);
- for (var i2 = 0; i2 !== n; ++i2)
- dstPlanes[i2] = srcPlanes[i2].clone();
- }
- this.clippingPlanes = dstPlanes;
- this.clipIntersection = source.clipIntersection;
- this.clipShadows = source.clipShadows;
- this.shadowSide = source.shadowSide;
- this.colorWrite = source.colorWrite;
- this.precision = source.precision;
- this.polygonOffset = source.polygonOffset;
- this.polygonOffsetFactor = source.polygonOffsetFactor;
- this.polygonOffsetUnits = source.polygonOffsetUnits;
- this.dithering = source.dithering;
- this.alphaTest = source.alphaTest;
- this.premultipliedAlpha = source.premultipliedAlpha;
- this.visible = source.visible;
- this.toneMapped = source.toneMapped;
- this.userData = JSON.parse(JSON.stringify(source.userData));
- return this;
- },
- dispose: function() {
- this.dispatchEvent({ type: "dispose" });
- }
- });
- Object.defineProperty(Material.prototype, "needsUpdate", {
- set: function(value) {
- if (value === true)
- this.version++;
- }
- });
- function MeshBasicMaterial(parameters) {
- Material.call(this);
- this.type = "MeshBasicMaterial";
- this.color = new Color(16777215);
- this.map = null;
- this.lightMap = null;
- this.lightMapIntensity = 1;
- this.aoMap = null;
- this.aoMapIntensity = 1;
- this.specularMap = null;
- this.alphaMap = null;
- this.envMap = null;
- this.combine = MultiplyOperation;
- this.reflectivity = 1;
- this.refractionRatio = 0.98;
- this.wireframe = false;
- this.wireframeLinewidth = 1;
- this.wireframeLinecap = "round";
- this.wireframeLinejoin = "round";
- this.skinning = false;
- this.morphTargets = false;
- this.setValues(parameters);
- }
- MeshBasicMaterial.prototype = Object.create(Material.prototype);
- MeshBasicMaterial.prototype.constructor = MeshBasicMaterial;
- MeshBasicMaterial.prototype.isMeshBasicMaterial = true;
- MeshBasicMaterial.prototype.copy = function(source) {
- Material.prototype.copy.call(this, source);
- this.color.copy(source.color);
- this.map = source.map;
- this.lightMap = source.lightMap;
- this.lightMapIntensity = source.lightMapIntensity;
- this.aoMap = source.aoMap;
- this.aoMapIntensity = source.aoMapIntensity;
- this.specularMap = source.specularMap;
- this.alphaMap = source.alphaMap;
- this.envMap = source.envMap;
- this.combine = source.combine;
- this.reflectivity = source.reflectivity;
- this.refractionRatio = source.refractionRatio;
- this.wireframe = source.wireframe;
- this.wireframeLinewidth = source.wireframeLinewidth;
- this.wireframeLinecap = source.wireframeLinecap;
- this.wireframeLinejoin = source.wireframeLinejoin;
- this.skinning = source.skinning;
- this.morphTargets = source.morphTargets;
- return this;
- };
- var _vector$3 = new Vector3();
- function BufferAttribute(array, itemSize, normalized) {
- if (Array.isArray(array)) {
- throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");
- }
- this.name = "";
- this.array = array;
- this.itemSize = itemSize;
- this.count = array !== void 0 ? array.length / itemSize : 0;
- this.normalized = normalized === true;
- this.usage = StaticDrawUsage;
- this.updateRange = { offset: 0, count: -1 };
- this.version = 0;
- }
- Object.defineProperty(BufferAttribute.prototype, "needsUpdate", {
- set: function(value) {
- if (value === true)
- this.version++;
- }
- });
- Object.assign(BufferAttribute.prototype, {
- isBufferAttribute: true,
- onUploadCallback: function() {
- },
- setUsage: function(value) {
- this.usage = value;
- return this;
- },
- copy: function(source) {
- this.name = source.name;
- this.array = new source.array.constructor(source.array);
- this.itemSize = source.itemSize;
- this.count = source.count;
- this.normalized = source.normalized;
- this.usage = source.usage;
- return this;
- },
- copyAt: function(index1, attribute, index2) {
- index1 *= this.itemSize;
- index2 *= attribute.itemSize;
- for (var i2 = 0, l = this.itemSize; i2 < l; i2++) {
- this.array[index1 + i2] = attribute.array[index2 + i2];
- }
- return this;
- },
- copyArray: function(array) {
- this.array.set(array);
- return this;
- },
- copyColorsArray: function(colors) {
- var array = this.array, offset = 0;
- for (var i2 = 0, l = colors.length; i2 < l; i2++) {
- var color = colors[i2];
- if (color === void 0) {
- console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined", i2);
- color = new Color();
- }
- array[offset++] = color.r;
- array[offset++] = color.g;
- array[offset++] = color.b;
- }
- return this;
- },
- copyVector2sArray: function(vectors) {
- var array = this.array, offset = 0;
- for (var i2 = 0, l = vectors.length; i2 < l; i2++) {
- var vector = vectors[i2];
- if (vector === void 0) {
- console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined", i2);
- vector = new Vector2();
- }
- array[offset++] = vector.x;
- array[offset++] = vector.y;
- }
- return this;
- },
- copyVector3sArray: function(vectors) {
- var array = this.array, offset = 0;
- for (var i2 = 0, l = vectors.length; i2 < l; i2++) {
- var vector = vectors[i2];
- if (vector === void 0) {
- console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined", i2);
- vector = new Vector3();
- }
- array[offset++] = vector.x;
- array[offset++] = vector.y;
- array[offset++] = vector.z;
- }
- return this;
- },
- copyVector4sArray: function(vectors) {
- var array = this.array, offset = 0;
- for (var i2 = 0, l = vectors.length; i2 < l; i2++) {
- var vector = vectors[i2];
- if (vector === void 0) {
- console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined", i2);
- vector = new Vector4();
- }
- array[offset++] = vector.x;
- array[offset++] = vector.y;
- array[offset++] = vector.z;
- array[offset++] = vector.w;
- }
- return this;
- },
- applyMatrix3: function(m) {
- for (var i2 = 0, l = this.count; i2 < l; i2++) {
- _vector$3.x = this.getX(i2);
- _vector$3.y = this.getY(i2);
- _vector$3.z = this.getZ(i2);
- _vector$3.applyMatrix3(m);
- this.setXYZ(i2, _vector$3.x, _vector$3.y, _vector$3.z);
- }
- return this;
- },
- applyMatrix4: function(m) {
- for (var i2 = 0, l = this.count; i2 < l; i2++) {
- _vector$3.x = this.getX(i2);
- _vector$3.y = this.getY(i2);
- _vector$3.z = this.getZ(i2);
- _vector$3.applyMatrix4(m);
- this.setXYZ(i2, _vector$3.x, _vector$3.y, _vector$3.z);
- }
- return this;
- },
- applyNormalMatrix: function(m) {
- for (var i2 = 0, l = this.count; i2 < l; i2++) {
- _vector$3.x = this.getX(i2);
- _vector$3.y = this.getY(i2);
- _vector$3.z = this.getZ(i2);
- _vector$3.applyNormalMatrix(m);
- this.setXYZ(i2, _vector$3.x, _vector$3.y, _vector$3.z);
- }
- return this;
- },
- transformDirection: function(m) {
- for (var i2 = 0, l = this.count; i2 < l; i2++) {
- _vector$3.x = this.getX(i2);
- _vector$3.y = this.getY(i2);
- _vector$3.z = this.getZ(i2);
- _vector$3.transformDirection(m);
- this.setXYZ(i2, _vector$3.x, _vector$3.y, _vector$3.z);
- }
- return this;
- },
- set: function(value, offset) {
- if (offset === void 0)
- offset = 0;
- this.array.set(value, offset);
- return this;
- },
- getX: function(index) {
- return this.array[index * this.itemSize];
- },
- setX: function(index, x) {
- this.array[index * this.itemSize] = x;
- return this;
- },
- getY: function(index) {
- return this.array[index * this.itemSize + 1];
- },
- setY: function(index, y) {
- this.array[index * this.itemSize + 1] = y;
- return this;
- },
- getZ: function(index) {
- return this.array[index * this.itemSize + 2];
- },
- setZ: function(index, z) {
- this.array[index * this.itemSize + 2] = z;
- return this;
- },
- getW: function(index) {
- return this.array[index * this.itemSize + 3];
- },
- setW: function(index, w) {
- this.array[index * this.itemSize + 3] = w;
- return this;
- },
- setXY: function(index, x, y) {
- index *= this.itemSize;
- this.array[index + 0] = x;
- this.array[index + 1] = y;
- return this;
- },
- setXYZ: function(index, x, y, z) {
- index *= this.itemSize;
- this.array[index + 0] = x;
- this.array[index + 1] = y;
- this.array[index + 2] = z;
- return this;
- },
- setXYZW: function(index, x, y, z, w) {
- index *= this.itemSize;
- this.array[index + 0] = x;
- this.array[index + 1] = y;
- this.array[index + 2] = z;
- this.array[index + 3] = w;
- return this;
- },
- onUpload: function(callback) {
- this.onUploadCallback = callback;
- return this;
- },
- clone: function() {
- return new this.constructor(this.array, this.itemSize).copy(this);
- },
- toJSON: function() {
- return {
- itemSize: this.itemSize,
- type: this.array.constructor.name,
- array: Array.prototype.slice.call(this.array),
- normalized: this.normalized
- };
- }
- });
- function Int8BufferAttribute(array, itemSize, normalized) {
- BufferAttribute.call(this, new Int8Array(array), itemSize, normalized);
- }
- Int8BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
- Int8BufferAttribute.prototype.constructor = Int8BufferAttribute;
- function Uint8BufferAttribute(array, itemSize, normalized) {
- BufferAttribute.call(this, new Uint8Array(array), itemSize, normalized);
- }
- Uint8BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
- Uint8BufferAttribute.prototype.constructor = Uint8BufferAttribute;
- function Uint8ClampedBufferAttribute(array, itemSize, normalized) {
- BufferAttribute.call(this, new Uint8ClampedArray(array), itemSize, normalized);
- }
- Uint8ClampedBufferAttribute.prototype = Object.create(BufferAttribute.prototype);
- Uint8ClampedBufferAttribute.prototype.constructor = Uint8ClampedBufferAttribute;
- function Int16BufferAttribute(array, itemSize, normalized) {
- BufferAttribute.call(this, new Int16Array(array), itemSize, normalized);
- }
- Int16BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
- Int16BufferAttribute.prototype.constructor = Int16BufferAttribute;
- function Uint16BufferAttribute(array, itemSize, normalized) {
- BufferAttribute.call(this, new Uint16Array(array), itemSize, normalized);
- }
- Uint16BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
- Uint16BufferAttribute.prototype.constructor = Uint16BufferAttribute;
- function Int32BufferAttribute(array, itemSize, normalized) {
- BufferAttribute.call(this, new Int32Array(array), itemSize, normalized);
- }
- Int32BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
- Int32BufferAttribute.prototype.constructor = Int32BufferAttribute;
- function Uint32BufferAttribute(array, itemSize, normalized) {
- BufferAttribute.call(this, new Uint32Array(array), itemSize, normalized);
- }
- Uint32BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
- Uint32BufferAttribute.prototype.constructor = Uint32BufferAttribute;
- function Float32BufferAttribute(array, itemSize, normalized) {
- BufferAttribute.call(this, new Float32Array(array), itemSize, normalized);
- }
- Float32BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
- Float32BufferAttribute.prototype.constructor = Float32BufferAttribute;
- function Float64BufferAttribute(array, itemSize, normalized) {
- BufferAttribute.call(this, new Float64Array(array), itemSize, normalized);
- }
- Float64BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
- Float64BufferAttribute.prototype.constructor = Float64BufferAttribute;
- function DirectGeometry() {
- this.vertices = [];
- this.normals = [];
- this.colors = [];
- this.uvs = [];
- this.uvs2 = [];
- this.groups = [];
- this.morphTargets = {};
- this.skinWeights = [];
- this.skinIndices = [];
- this.boundingBox = null;
- this.boundingSphere = null;
- this.verticesNeedUpdate = false;
- this.normalsNeedUpdate = false;
- this.colorsNeedUpdate = false;
- this.uvsNeedUpdate = false;
- this.groupsNeedUpdate = false;
- }
- Object.assign(DirectGeometry.prototype, {
- computeGroups: function(geometry) {
- var group;
- var groups = [];
- var materialIndex = void 0;
- var faces = geometry.faces;
- for (var i2 = 0; i2 < faces.length; i2++) {
- var face = faces[i2];
- if (face.materialIndex !== materialIndex) {
- materialIndex = face.materialIndex;
- if (group !== void 0) {
- group.count = i2 * 3 - group.start;
- groups.push(group);
- }
- group = {
- start: i2 * 3,
- materialIndex
- };
- }
- }
- if (group !== void 0) {
- group.count = i2 * 3 - group.start;
- groups.push(group);
- }
- this.groups = groups;
- },
- fromGeometry: function(geometry) {
- var faces = geometry.faces;
- var vertices = geometry.vertices;
- var faceVertexUvs = geometry.faceVertexUvs;
- var hasFaceVertexUv = faceVertexUvs[0] && faceVertexUvs[0].length > 0;
- var hasFaceVertexUv2 = faceVertexUvs[1] && faceVertexUvs[1].length > 0;
- var morphTargets = geometry.morphTargets;
- var morphTargetsLength = morphTargets.length;
- var morphTargetsPosition;
- if (morphTargetsLength > 0) {
- morphTargetsPosition = [];
- for (var i2 = 0; i2 < morphTargetsLength; i2++) {
- morphTargetsPosition[i2] = {
- name: morphTargets[i2].name,
- data: []
- };
- }
- this.morphTargets.position = morphTargetsPosition;
- }
- var morphNormals = geometry.morphNormals;
- var morphNormalsLength = morphNormals.length;
- var morphTargetsNormal;
- if (morphNormalsLength > 0) {
- morphTargetsNormal = [];
- for (var i2 = 0; i2 < morphNormalsLength; i2++) {
- morphTargetsNormal[i2] = {
- name: morphNormals[i2].name,
- data: []
- };
- }
- this.morphTargets.normal = morphTargetsNormal;
- }
- var skinIndices = geometry.skinIndices;
- var skinWeights = geometry.skinWeights;
- var hasSkinIndices = skinIndices.length === vertices.length;
- var hasSkinWeights = skinWeights.length === vertices.length;
- if (vertices.length > 0 && faces.length === 0) {
- console.error("THREE.DirectGeometry: Faceless geometries are not supported.");
- }
- for (var i2 = 0; i2 < faces.length; i2++) {
- var face = faces[i2];
- this.vertices.push(vertices[face.a], vertices[face.b], vertices[face.c]);
- var vertexNormals = face.vertexNormals;
- if (vertexNormals.length === 3) {
- this.normals.push(vertexNormals[0], vertexNormals[1], vertexNormals[2]);
- } else {
- var normal = face.normal;
- this.normals.push(normal, normal, normal);
- }
- var vertexColors = face.vertexColors;
- if (vertexColors.length === 3) {
- this.colors.push(vertexColors[0], vertexColors[1], vertexColors[2]);
- } else {
- var color = face.color;
- this.colors.push(color, color, color);
- }
- if (hasFaceVertexUv === true) {
- var vertexUvs = faceVertexUvs[0][i2];
- if (vertexUvs !== void 0) {
- this.uvs.push(vertexUvs[0], vertexUvs[1], vertexUvs[2]);
- } else {
- console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ", i2);
- this.uvs.push(new Vector2(), new Vector2(), new Vector2());
- }
- }
- if (hasFaceVertexUv2 === true) {
- var vertexUvs = faceVertexUvs[1][i2];
- if (vertexUvs !== void 0) {
- this.uvs2.push(vertexUvs[0], vertexUvs[1], vertexUvs[2]);
- } else {
- console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ", i2);
- this.uvs2.push(new Vector2(), new Vector2(), new Vector2());
- }
- }
- for (var j = 0; j < morphTargetsLength; j++) {
- var morphTarget = morphTargets[j].vertices;
- morphTargetsPosition[j].data.push(morphTarget[face.a], morphTarget[face.b], morphTarget[face.c]);
- }
- for (var j = 0; j < morphNormalsLength; j++) {
- var morphNormal = morphNormals[j].vertexNormals[i2];
- morphTargetsNormal[j].data.push(morphNormal.a, morphNormal.b, morphNormal.c);
- }
- if (hasSkinIndices) {
- this.skinIndices.push(skinIndices[face.a], skinIndices[face.b], skinIndices[face.c]);
- }
- if (hasSkinWeights) {
- this.skinWeights.push(skinWeights[face.a], skinWeights[face.b], skinWeights[face.c]);
- }
- }
- this.computeGroups(geometry);
- this.verticesNeedUpdate = geometry.verticesNeedUpdate;
- this.normalsNeedUpdate = geometry.normalsNeedUpdate;
- this.colorsNeedUpdate = geometry.colorsNeedUpdate;
- this.uvsNeedUpdate = geometry.uvsNeedUpdate;
- this.groupsNeedUpdate = geometry.groupsNeedUpdate;
- if (geometry.boundingSphere !== null) {
- this.boundingSphere = geometry.boundingSphere.clone();
- }
- if (geometry.boundingBox !== null) {
- this.boundingBox = geometry.boundingBox.clone();
- }
- return this;
- }
- });
- function arrayMax(array) {
- if (array.length === 0)
- return -Infinity;
- var max = array[0];
- for (var i2 = 1, l = array.length; i2 < l; ++i2) {
- if (array[i2] > max)
- max = array[i2];
- }
- return max;
- }
- var _bufferGeometryId = 1;
- var _m1$2 = new Matrix4();
- var _obj = new Object3D();
- var _offset = new Vector3();
- var _box$2 = new Box3();
- var _boxMorphTargets = new Box3();
- var _vector$4 = new Vector3();
- function BufferGeometry() {
- Object.defineProperty(this, "id", { value: _bufferGeometryId += 2 });
- this.uuid = MathUtils.generateUUID();
- this.name = "";
- this.type = "BufferGeometry";
- this.index = null;
- this.attributes = {};
- this.morphAttributes = {};
- this.morphTargetsRelative = false;
- this.groups = [];
- this.boundingBox = null;
- this.boundingSphere = null;
- this.drawRange = { start: 0, count: Infinity };
- this.userData = {};
- }
- BufferGeometry.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
- constructor: BufferGeometry,
- isBufferGeometry: true,
- getIndex: function() {
- return this.index;
- },
- setIndex: function(index) {
- if (Array.isArray(index)) {
- this.index = new (arrayMax(index) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute)(index, 1);
- } else {
- this.index = index;
- }
- },
- getAttribute: function(name) {
- return this.attributes[name];
- },
- setAttribute: function(name, attribute) {
- this.attributes[name] = attribute;
- return this;
- },
- deleteAttribute: function(name) {
- delete this.attributes[name];
- return this;
- },
- addGroup: function(start, count, materialIndex) {
- this.groups.push({
- start,
- count,
- materialIndex: materialIndex !== void 0 ? materialIndex : 0
- });
- },
- clearGroups: function() {
- this.groups = [];
- },
- setDrawRange: function(start, count) {
- this.drawRange.start = start;
- this.drawRange.count = count;
- },
- applyMatrix4: function(matrix) {
- var position = this.attributes.position;
- if (position !== void 0) {
- position.applyMatrix4(matrix);
- position.needsUpdate = true;
- }
- var normal = this.attributes.normal;
- if (normal !== void 0) {
- var normalMatrix = new Matrix3().getNormalMatrix(matrix);
- normal.applyNormalMatrix(normalMatrix);
- normal.needsUpdate = true;
- }
- var tangent = this.attributes.tangent;
- if (tangent !== void 0) {
- tangent.transformDirection(matrix);
- tangent.needsUpdate = true;
- }
- if (this.boundingBox !== null) {
- this.computeBoundingBox();
- }
- if (this.boundingSphere !== null) {
- this.computeBoundingSphere();
- }
- return this;
- },
- rotateX: function(angle) {
- _m1$2.makeRotationX(angle);
- this.applyMatrix4(_m1$2);
- return this;
- },
- rotateY: function(angle) {
- _m1$2.makeRotationY(angle);
- this.applyMatrix4(_m1$2);
- return this;
- },
- rotateZ: function(angle) {
- _m1$2.makeRotationZ(angle);
- this.applyMatrix4(_m1$2);
- return this;
- },
- translate: function(x, y, z) {
- _m1$2.makeTranslation(x, y, z);
- this.applyMatrix4(_m1$2);
- return this;
- },
- scale: function(x, y, z) {
- _m1$2.makeScale(x, y, z);
- this.applyMatrix4(_m1$2);
- return this;
- },
- lookAt: function(vector) {
- _obj.lookAt(vector);
- _obj.updateMatrix();
- this.applyMatrix4(_obj.matrix);
- return this;
- },
- center: function() {
- this.computeBoundingBox();
- this.boundingBox.getCenter(_offset).negate();
- this.translate(_offset.x, _offset.y, _offset.z);
- return this;
- },
- setFromObject: function(object) {
- var geometry = object.geometry;
- if (object.isPoints || object.isLine) {
- var positions = new Float32BufferAttribute(geometry.vertices.length * 3, 3);
- var colors = new Float32BufferAttribute(geometry.colors.length * 3, 3);
- this.setAttribute("position", positions.copyVector3sArray(geometry.vertices));
- this.setAttribute("color", colors.copyColorsArray(geometry.colors));
- if (geometry.lineDistances && geometry.lineDistances.length === geometry.vertices.length) {
- var lineDistances = new Float32BufferAttribute(geometry.lineDistances.length, 1);
- this.setAttribute("lineDistance", lineDistances.copyArray(geometry.lineDistances));
- }
- if (geometry.boundingSphere !== null) {
- this.boundingSphere = geometry.boundingSphere.clone();
- }
- if (geometry.boundingBox !== null) {
- this.boundingBox = geometry.boundingBox.clone();
- }
- } else if (object.isMesh) {
- if (geometry && geometry.isGeometry) {
- this.fromGeometry(geometry);
- }
- }
- return this;
- },
- setFromPoints: function(points) {
- var position = [];
- for (var i2 = 0, l = points.length; i2 < l; i2++) {
- var point = points[i2];
- position.push(point.x, point.y, point.z || 0);
- }
- this.setAttribute("position", new Float32BufferAttribute(position, 3));
- return this;
- },
- updateFromObject: function(object) {
- var geometry = object.geometry;
- if (object.isMesh) {
- var direct = geometry.__directGeometry;
- if (geometry.elementsNeedUpdate === true) {
- direct = void 0;
- geometry.elementsNeedUpdate = false;
- }
- if (direct === void 0) {
- return this.fromGeometry(geometry);
- }
- direct.verticesNeedUpdate = geometry.verticesNeedUpdate;
- direct.normalsNeedUpdate = geometry.normalsNeedUpdate;
- direct.colorsNeedUpdate = geometry.colorsNeedUpdate;
- direct.uvsNeedUpdate = geometry.uvsNeedUpdate;
- direct.groupsNeedUpdate = geometry.groupsNeedUpdate;
- geometry.verticesNeedUpdate = false;
- geometry.normalsNeedUpdate = false;
- geometry.colorsNeedUpdate = false;
- geometry.uvsNeedUpdate = false;
- geometry.groupsNeedUpdate = false;
- geometry = direct;
- }
- var attribute;
- if (geometry.verticesNeedUpdate === true) {
- attribute = this.attributes.position;
- if (attribute !== void 0) {
- attribute.copyVector3sArray(geometry.vertices);
- attribute.needsUpdate = true;
- }
- geometry.verticesNeedUpdate = false;
- }
- if (geometry.normalsNeedUpdate === true) {
- attribute = this.attributes.normal;
- if (attribute !== void 0) {
- attribute.copyVector3sArray(geometry.normals);
- attribute.needsUpdate = true;
- }
- geometry.normalsNeedUpdate = false;
- }
- if (geometry.colorsNeedUpdate === true) {
- attribute = this.attributes.color;
- if (attribute !== void 0) {
- attribute.copyColorsArray(geometry.colors);
- attribute.needsUpdate = true;
- }
- geometry.colorsNeedUpdate = false;
- }
- if (geometry.uvsNeedUpdate) {
- attribute = this.attributes.uv;
- if (attribute !== void 0) {
- attribute.copyVector2sArray(geometry.uvs);
- attribute.needsUpdate = true;
- }
- geometry.uvsNeedUpdate = false;
- }
- if (geometry.lineDistancesNeedUpdate) {
- attribute = this.attributes.lineDistance;
- if (attribute !== void 0) {
- attribute.copyArray(geometry.lineDistances);
- attribute.needsUpdate = true;
- }
- geometry.lineDistancesNeedUpdate = false;
- }
- if (geometry.groupsNeedUpdate) {
- geometry.computeGroups(object.geometry);
- this.groups = geometry.groups;
- geometry.groupsNeedUpdate = false;
- }
- return this;
- },
- fromGeometry: function(geometry) {
- geometry.__directGeometry = new DirectGeometry().fromGeometry(geometry);
- return this.fromDirectGeometry(geometry.__directGeometry);
- },
- fromDirectGeometry: function(geometry) {
- var positions = new Float32Array(geometry.vertices.length * 3);
- this.setAttribute("position", new BufferAttribute(positions, 3).copyVector3sArray(geometry.vertices));
- if (geometry.normals.length > 0) {
- var normals = new Float32Array(geometry.normals.length * 3);
- this.setAttribute("normal", new BufferAttribute(normals, 3).copyVector3sArray(geometry.normals));
- }
- if (geometry.colors.length > 0) {
- var colors = new Float32Array(geometry.colors.length * 3);
- this.setAttribute("color", new BufferAttribute(colors, 3).copyColorsArray(geometry.colors));
- }
- if (geometry.uvs.length > 0) {
- var uvs = new Float32Array(geometry.uvs.length * 2);
- this.setAttribute("uv", new BufferAttribute(uvs, 2).copyVector2sArray(geometry.uvs));
- }
- if (geometry.uvs2.length > 0) {
- var uvs2 = new Float32Array(geometry.uvs2.length * 2);
- this.setAttribute("uv2", new BufferAttribute(uvs2, 2).copyVector2sArray(geometry.uvs2));
- }
- this.groups = geometry.groups;
- for (var name in geometry.morphTargets) {
- var array = [];
- var morphTargets = geometry.morphTargets[name];
- for (var i2 = 0, l = morphTargets.length; i2 < l; i2++) {
- var morphTarget = morphTargets[i2];
- var attribute = new Float32BufferAttribute(morphTarget.data.length * 3, 3);
- attribute.name = morphTarget.name;
- array.push(attribute.copyVector3sArray(morphTarget.data));
- }
- this.morphAttributes[name] = array;
- }
- if (geometry.skinIndices.length > 0) {
- var skinIndices = new Float32BufferAttribute(geometry.skinIndices.length * 4, 4);
- this.setAttribute("skinIndex", skinIndices.copyVector4sArray(geometry.skinIndices));
- }
- if (geometry.skinWeights.length > 0) {
- var skinWeights = new Float32BufferAttribute(geometry.skinWeights.length * 4, 4);
- this.setAttribute("skinWeight", skinWeights.copyVector4sArray(geometry.skinWeights));
- }
- if (geometry.boundingSphere !== null) {
- this.boundingSphere = geometry.boundingSphere.clone();
- }
- if (geometry.boundingBox !== null) {
- this.boundingBox = geometry.boundingBox.clone();
- }
- return this;
- },
- computeBoundingBox: function() {
- if (this.boundingBox === null) {
- this.boundingBox = new Box3();
- }
- var position = this.attributes.position;
- var morphAttributesPosition = this.morphAttributes.position;
- if (position !== void 0) {
- this.boundingBox.setFromBufferAttribute(position);
- if (morphAttributesPosition) {
- for (var i2 = 0, il = morphAttributesPosition.length; i2 < il; i2++) {
- var morphAttribute = morphAttributesPosition[i2];
- _box$2.setFromBufferAttribute(morphAttribute);
- if (this.morphTargetsRelative) {
- _vector$4.addVectors(this.boundingBox.min, _box$2.min);
- this.boundingBox.expandByPoint(_vector$4);
- _vector$4.addVectors(this.boundingBox.max, _box$2.max);
- this.boundingBox.expandByPoint(_vector$4);
- } else {
- this.boundingBox.expandByPoint(_box$2.min);
- this.boundingBox.expandByPoint(_box$2.max);
- }
- }
- }
- } else {
- this.boundingBox.makeEmpty();
- }
- if (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) {
- console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this);
- }
- },
- computeBoundingSphere: function() {
- if (this.boundingSphere === null) {
- this.boundingSphere = new Sphere();
- }
- var position = this.attributes.position;
- var morphAttributesPosition = this.morphAttributes.position;
- if (position) {
- var center = this.boundingSphere.center;
- _box$2.setFromBufferAttribute(position);
- if (morphAttributesPosition) {
- for (var i2 = 0, il = morphAttributesPosition.length; i2 < il; i2++) {
- var morphAttribute = morphAttributesPosition[i2];
- _boxMorphTargets.setFromBufferAttribute(morphAttribute);
- if (this.morphTargetsRelative) {
- _vector$4.addVectors(_box$2.min, _boxMorphTargets.min);
- _box$2.expandByPoint(_vector$4);
- _vector$4.addVectors(_box$2.max, _boxMorphTargets.max);
- _box$2.expandByPoint(_vector$4);
- } else {
- _box$2.expandByPoint(_boxMorphTargets.min);
- _box$2.expandByPoint(_boxMorphTargets.max);
- }
- }
- }
- _box$2.getCenter(center);
- var maxRadiusSq = 0;
- for (var i2 = 0, il = position.count; i2 < il; i2++) {
- _vector$4.fromBufferAttribute(position, i2);
- maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_vector$4));
- }
- if (morphAttributesPosition) {
- for (var i2 = 0, il = morphAttributesPosition.length; i2 < il; i2++) {
- var morphAttribute = morphAttributesPosition[i2];
- var morphTargetsRelative = this.morphTargetsRelative;
- for (var j = 0, jl = morphAttribute.count; j < jl; j++) {
- _vector$4.fromBufferAttribute(morphAttribute, j);
- if (morphTargetsRelative) {
- _offset.fromBufferAttribute(position, j);
- _vector$4.add(_offset);
- }
- maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_vector$4));
- }
- }
- }
- this.boundingSphere.radius = Math.sqrt(maxRadiusSq);
- if (isNaN(this.boundingSphere.radius)) {
- console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this);
- }
- }
- },
- computeFaceNormals: function() {
- },
- computeVertexNormals: function() {
- var index = this.index;
- var attributes = this.attributes;
- if (attributes.position) {
- var positions = attributes.position.array;
- if (attributes.normal === void 0) {
- this.setAttribute("normal", new BufferAttribute(new Float32Array(positions.length), 3));
- } else {
- var array = attributes.normal.array;
- for (var i2 = 0, il = array.length; i2 < il; i2++) {
- array[i2] = 0;
- }
- }
- var normals = attributes.normal.array;
- var vA, vB, vC;
- var pA = new Vector3(), pB = new Vector3(), pC = new Vector3();
- var cb = new Vector3(), ab = new Vector3();
- if (index) {
- var indices = index.array;
- for (var i2 = 0, il = index.count; i2 < il; i2 += 3) {
- vA = indices[i2 + 0] * 3;
- vB = indices[i2 + 1] * 3;
- vC = indices[i2 + 2] * 3;
- pA.fromArray(positions, vA);
- pB.fromArray(positions, vB);
- pC.fromArray(positions, vC);
- cb.subVectors(pC, pB);
- ab.subVectors(pA, pB);
- cb.cross(ab);
- normals[vA] += cb.x;
- normals[vA + 1] += cb.y;
- normals[vA + 2] += cb.z;
- normals[vB] += cb.x;
- normals[vB + 1] += cb.y;
- normals[vB + 2] += cb.z;
- normals[vC] += cb.x;
- normals[vC + 1] += cb.y;
- normals[vC + 2] += cb.z;
- }
- } else {
- for (var i2 = 0, il = positions.length; i2 < il; i2 += 9) {
- pA.fromArray(positions, i2);
- pB.fromArray(positions, i2 + 3);
- pC.fromArray(positions, i2 + 6);
- cb.subVectors(pC, pB);
- ab.subVectors(pA, pB);
- cb.cross(ab);
- normals[i2] = cb.x;
- normals[i2 + 1] = cb.y;
- normals[i2 + 2] = cb.z;
- normals[i2 + 3] = cb.x;
- normals[i2 + 4] = cb.y;
- normals[i2 + 5] = cb.z;
- normals[i2 + 6] = cb.x;
- normals[i2 + 7] = cb.y;
- normals[i2 + 8] = cb.z;
- }
- }
- this.normalizeNormals();
- attributes.normal.needsUpdate = true;
- }
- },
- merge: function(geometry, offset) {
- if (!(geometry && geometry.isBufferGeometry)) {
- console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.", geometry);
- return;
- }
- if (offset === void 0) {
- offset = 0;
- console.warn(
- "THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."
- );
- }
- var attributes = this.attributes;
- for (var key in attributes) {
- if (geometry.attributes[key] === void 0)
- continue;
- var attribute1 = attributes[key];
- var attributeArray1 = attribute1.array;
- var attribute2 = geometry.attributes[key];
- var attributeArray2 = attribute2.array;
- var attributeOffset = attribute2.itemSize * offset;
- var length = Math.min(attributeArray2.length, attributeArray1.length - attributeOffset);
- for (var i2 = 0, j = attributeOffset; i2 < length; i2++, j++) {
- attributeArray1[j] = attributeArray2[i2];
- }
- }
- return this;
- },
- normalizeNormals: function() {
- var normals = this.attributes.normal;
- for (var i2 = 0, il = normals.count; i2 < il; i2++) {
- _vector$4.x = normals.getX(i2);
- _vector$4.y = normals.getY(i2);
- _vector$4.z = normals.getZ(i2);
- _vector$4.normalize();
- normals.setXYZ(i2, _vector$4.x, _vector$4.y, _vector$4.z);
- }
- },
- toNonIndexed: function() {
- function convertBufferAttribute(attribute2, indices2) {
- var array = attribute2.array;
- var itemSize = attribute2.itemSize;
- var array2 = new array.constructor(indices2.length * itemSize);
- var index = 0, index2 = 0;
- for (var i3 = 0, l2 = indices2.length; i3 < l2; i3++) {
- index = indices2[i3] * itemSize;
- for (var j = 0; j < itemSize; j++) {
- array2[index2++] = array[index++];
- }
- }
- return new BufferAttribute(array2, itemSize);
- }
- if (this.index === null) {
- console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed.");
- return this;
- }
- var geometry2 = new BufferGeometry();
- var indices = this.index.array;
- var attributes = this.attributes;
- for (var name in attributes) {
- var attribute = attributes[name];
- var newAttribute = convertBufferAttribute(attribute, indices);
- geometry2.setAttribute(name, newAttribute);
- }
- var morphAttributes = this.morphAttributes;
- for (name in morphAttributes) {
- var morphArray = [];
- var morphAttribute = morphAttributes[name];
- for (var i2 = 0, il = morphAttribute.length; i2 < il; i2++) {
- var attribute = morphAttribute[i2];
- var newAttribute = convertBufferAttribute(attribute, indices);
- morphArray.push(newAttribute);
- }
- geometry2.morphAttributes[name] = morphArray;
- }
- geometry2.morphTargetsRelative = this.morphTargetsRelative;
- var groups = this.groups;
- for (var i2 = 0, l = groups.length; i2 < l; i2++) {
- var group = groups[i2];
- geometry2.addGroup(group.start, group.count, group.materialIndex);
- }
- return geometry2;
- },
- toJSON: function() {
- var data = {
- metadata: {
- version: 4.5,
- type: "BufferGeometry",
- generator: "BufferGeometry.toJSON"
- }
- };
- data.uuid = this.uuid;
- data.type = this.type;
- if (this.name !== "")
- data.name = this.name;
- if (Object.keys(this.userData).length > 0)
- data.userData = this.userData;
- if (this.parameters !== void 0) {
- var parameters = this.parameters;
- for (var key in parameters) {
- if (parameters[key] !== void 0)
- data[key] = parameters[key];
- }
- return data;
- }
- data.data = { attributes: {} };
- var index = this.index;
- if (index !== null) {
- data.data.index = {
- type: index.array.constructor.name,
- array: Array.prototype.slice.call(index.array)
- };
- }
- var attributes = this.attributes;
- for (var key in attributes) {
- var attribute = attributes[key];
- var attributeData = attribute.toJSON();
- if (attribute.name !== "")
- attributeData.name = attribute.name;
- data.data.attributes[key] = attributeData;
- }
- var morphAttributes = {};
- var hasMorphAttributes = false;
- for (var key in this.morphAttributes) {
- var attributeArray = this.morphAttributes[key];
- var array = [];
- for (var i2 = 0, il = attributeArray.length; i2 < il; i2++) {
- var attribute = attributeArray[i2];
- var attributeData = attribute.toJSON();
- if (attribute.name !== "")
- attributeData.name = attribute.name;
- array.push(attributeData);
- }
- if (array.length > 0) {
- morphAttributes[key] = array;
- hasMorphAttributes = true;
- }
- }
- if (hasMorphAttributes) {
- data.data.morphAttributes = morphAttributes;
- data.data.morphTargetsRelative = this.morphTargetsRelative;
- }
- var groups = this.groups;
- if (groups.length > 0) {
- data.data.groups = JSON.parse(JSON.stringify(groups));
- }
- var boundingSphere = this.boundingSphere;
- if (boundingSphere !== null) {
- data.data.boundingSphere = {
- center: boundingSphere.center.toArray(),
- radius: boundingSphere.radius
- };
- }
- return data;
- },
- clone: function() {
- return new BufferGeometry().copy(this);
- },
- copy: function(source) {
- var name, i2, l;
- this.index = null;
- this.attributes = {};
- this.morphAttributes = {};
- this.groups = [];
- this.boundingBox = null;
- this.boundingSphere = null;
- this.name = source.name;
- var index = source.index;
- if (index !== null) {
- this.setIndex(index.clone());
- }
- var attributes = source.attributes;
- for (name in attributes) {
- var attribute = attributes[name];
- this.setAttribute(name, attribute.clone());
- }
- var morphAttributes = source.morphAttributes;
- for (name in morphAttributes) {
- var array = [];
- var morphAttribute = morphAttributes[name];
- for (i2 = 0, l = morphAttribute.length; i2 < l; i2++) {
- array.push(morphAttribute[i2].clone());
- }
- this.morphAttributes[name] = array;
- }
- this.morphTargetsRelative = source.morphTargetsRelative;
- var groups = source.groups;
- for (i2 = 0, l = groups.length; i2 < l; i2++) {
- var group = groups[i2];
- this.addGroup(group.start, group.count, group.materialIndex);
- }
- var boundingBox = source.boundingBox;
- if (boundingBox !== null) {
- this.boundingBox = boundingBox.clone();
- }
- var boundingSphere = source.boundingSphere;
- if (boundingSphere !== null) {
- this.boundingSphere = boundingSphere.clone();
- }
- this.drawRange.start = source.drawRange.start;
- this.drawRange.count = source.drawRange.count;
- this.userData = source.userData;
- return this;
- },
- dispose: function() {
- this.dispatchEvent({ type: "dispose" });
- }
- });
- var _inverseMatrix = new Matrix4();
- var _ray = new Ray();
- var _sphere = new Sphere();
- var _vA = new Vector3();
- var _vB = new Vector3();
- var _vC = new Vector3();
- var _tempA = new Vector3();
- var _tempB = new Vector3();
- var _tempC = new Vector3();
- var _morphA = new Vector3();
- var _morphB = new Vector3();
- var _morphC = new Vector3();
- var _uvA = new Vector2();
- var _uvB = new Vector2();
- var _uvC = new Vector2();
- var _intersectionPoint = new Vector3();
- var _intersectionPointWorld = new Vector3();
- function Mesh(geometry, material) {
- Object3D.call(this);
- this.type = "Mesh";
- this.geometry = geometry !== void 0 ? geometry : new BufferGeometry();
- this.material = material !== void 0 ? material : new MeshBasicMaterial();
- this.updateMorphTargets();
- }
- Mesh.prototype = Object.assign(Object.create(Object3D.prototype), {
- constructor: Mesh,
- isMesh: true,
- copy: function(source) {
- Object3D.prototype.copy.call(this, source);
- if (source.morphTargetInfluences !== void 0) {
- this.morphTargetInfluences = source.morphTargetInfluences.slice();
- }
- if (source.morphTargetDictionary !== void 0) {
- this.morphTargetDictionary = Object.assign({}, source.morphTargetDictionary);
- }
- return this;
- },
- updateMorphTargets: function() {
- var geometry = this.geometry;
- var m, ml, name;
- if (geometry.isBufferGeometry) {
- var morphAttributes = geometry.morphAttributes;
- var keys = Object.keys(morphAttributes);
- if (keys.length > 0) {
- var morphAttribute = morphAttributes[keys[0]];
- if (morphAttribute !== void 0) {
- this.morphTargetInfluences = [];
- this.morphTargetDictionary = {};
- for (m = 0, ml = morphAttribute.length; m < ml; m++) {
- name = morphAttribute[m].name || String(m);
- this.morphTargetInfluences.push(0);
- this.morphTargetDictionary[name] = m;
- }
- }
- }
- } else {
- var morphTargets = geometry.morphTargets;
- if (morphTargets !== void 0 && morphTargets.length > 0) {
- console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");
- }
- }
- },
- raycast: function(raycaster, intersects2) {
- var geometry = this.geometry;
- var material = this.material;
- var matrixWorld = this.matrixWorld;
- if (material === void 0)
- return;
- if (geometry.boundingSphere === null)
- geometry.computeBoundingSphere();
- _sphere.copy(geometry.boundingSphere);
- _sphere.applyMatrix4(matrixWorld);
- if (raycaster.ray.intersectsSphere(_sphere) === false)
- return;
- _inverseMatrix.getInverse(matrixWorld);
- _ray.copy(raycaster.ray).applyMatrix4(_inverseMatrix);
- if (geometry.boundingBox !== null) {
- if (_ray.intersectsBox(geometry.boundingBox) === false)
- return;
- }
- var intersection;
- if (geometry.isBufferGeometry) {
- var a, b, c;
- var index = geometry.index;
- var position = geometry.attributes.position;
- var morphPosition = geometry.morphAttributes.position;
- var morphTargetsRelative = geometry.morphTargetsRelative;
- var uv = geometry.attributes.uv;
- var uv2 = geometry.attributes.uv2;
- var groups = geometry.groups;
- var drawRange = geometry.drawRange;
- var i2, j, il, jl;
- var group, groupMaterial;
- var start, end;
- if (index !== null) {
- if (Array.isArray(material)) {
- for (i2 = 0, il = groups.length; i2 < il; i2++) {
- group = groups[i2];
- groupMaterial = material[group.materialIndex];
- start = Math.max(group.start, drawRange.start);
- end = Math.min(group.start + group.count, drawRange.start + drawRange.count);
- for (j = start, jl = end; j < jl; j += 3) {
- a = index.getX(j);
- b = index.getX(j + 1);
- c = index.getX(j + 2);
- intersection = checkBufferGeometryIntersection(this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c);
- if (intersection) {
- intersection.faceIndex = Math.floor(j / 3);
- intersection.face.materialIndex = group.materialIndex;
- intersects2.push(intersection);
- }
- }
- }
- } else {
- start = Math.max(0, drawRange.start);
- end = Math.min(index.count, drawRange.start + drawRange.count);
- for (i2 = start, il = end; i2 < il; i2 += 3) {
- a = index.getX(i2);
- b = index.getX(i2 + 1);
- c = index.getX(i2 + 2);
- intersection = checkBufferGeometryIntersection(this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c);
- if (intersection) {
- intersection.faceIndex = Math.floor(i2 / 3);
- intersects2.push(intersection);
- }
- }
- }
- } else if (position !== void 0) {
- if (Array.isArray(material)) {
- for (i2 = 0, il = groups.length; i2 < il; i2++) {
- group = groups[i2];
- groupMaterial = material[group.materialIndex];
- start = Math.max(group.start, drawRange.start);
- end = Math.min(group.start + group.count, drawRange.start + drawRange.count);
- for (j = start, jl = end; j < jl; j += 3) {
- a = j;
- b = j + 1;
- c = j + 2;
- intersection = checkBufferGeometryIntersection(this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c);
- if (intersection) {
- intersection.faceIndex = Math.floor(j / 3);
- intersection.face.materialIndex = group.materialIndex;
- intersects2.push(intersection);
- }
- }
- }
- } else {
- start = Math.max(0, drawRange.start);
- end = Math.min(position.count, drawRange.start + drawRange.count);
- for (i2 = start, il = end; i2 < il; i2 += 3) {
- a = i2;
- b = i2 + 1;
- c = i2 + 2;
- intersection = checkBufferGeometryIntersection(this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c);
- if (intersection) {
- intersection.faceIndex = Math.floor(i2 / 3);
- intersects2.push(intersection);
- }
- }
- }
- }
- } else if (geometry.isGeometry) {
- var fvA, fvB, fvC;
- var isMultiMaterial = Array.isArray(material);
- var vertices = geometry.vertices;
- var faces = geometry.faces;
- var uvs;
- var faceVertexUvs = geometry.faceVertexUvs[0];
- if (faceVertexUvs.length > 0)
- uvs = faceVertexUvs;
- for (var f = 0, fl = faces.length; f < fl; f++) {
- var face = faces[f];
- var faceMaterial = isMultiMaterial ? material[face.materialIndex] : material;
- if (faceMaterial === void 0)
- continue;
- fvA = vertices[face.a];
- fvB = vertices[face.b];
- fvC = vertices[face.c];
- intersection = checkIntersection(this, faceMaterial, raycaster, _ray, fvA, fvB, fvC, _intersectionPoint);
- if (intersection) {
- if (uvs && uvs[f]) {
- var uvs_f = uvs[f];
- _uvA.copy(uvs_f[0]);
- _uvB.copy(uvs_f[1]);
- _uvC.copy(uvs_f[2]);
- intersection.uv = Triangle.getUV(_intersectionPoint, fvA, fvB, fvC, _uvA, _uvB, _uvC, new Vector2());
- }
- intersection.face = face;
- intersection.faceIndex = f;
- intersects2.push(intersection);
- }
- }
- }
- },
- clone: function() {
- return new this.constructor(this.geometry, this.material).copy(this);
- }
- });
- function checkIntersection(object, material, raycaster, ray, pA, pB, pC, point) {
- var intersect;
- if (material.side === BackSide) {
- intersect = ray.intersectTriangle(pC, pB, pA, true, point);
- } else {
- intersect = ray.intersectTriangle(pA, pB, pC, material.side !== DoubleSide, point);
- }
- if (intersect === null)
- return null;
- _intersectionPointWorld.copy(point);
- _intersectionPointWorld.applyMatrix4(object.matrixWorld);
- var distance = raycaster.ray.origin.distanceTo(_intersectionPointWorld);
- if (distance < raycaster.near || distance > raycaster.far)
- return null;
- return {
- distance,
- point: _intersectionPointWorld.clone(),
- object
- };
- }
- function checkBufferGeometryIntersection(object, material, raycaster, ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c) {
- _vA.fromBufferAttribute(position, a);
- _vB.fromBufferAttribute(position, b);
- _vC.fromBufferAttribute(position, c);
- var morphInfluences = object.morphTargetInfluences;
- if (material.morphTargets && morphPosition && morphInfluences) {
- _morphA.set(0, 0, 0);
- _morphB.set(0, 0, 0);
- _morphC.set(0, 0, 0);
- for (var i2 = 0, il = morphPosition.length; i2 < il; i2++) {
- var influence = morphInfluences[i2];
- var morphAttribute = morphPosition[i2];
- if (influence === 0)
- continue;
- _tempA.fromBufferAttribute(morphAttribute, a);
- _tempB.fromBufferAttribute(morphAttribute, b);
- _tempC.fromBufferAttribute(morphAttribute, c);
- if (morphTargetsRelative) {
- _morphA.addScaledVector(_tempA, influence);
- _morphB.addScaledVector(_tempB, influence);
- _morphC.addScaledVector(_tempC, influence);
- } else {
- _morphA.addScaledVector(_tempA.sub(_vA), influence);
- _morphB.addScaledVector(_tempB.sub(_vB), influence);
- _morphC.addScaledVector(_tempC.sub(_vC), influence);
- }
- }
- _vA.add(_morphA);
- _vB.add(_morphB);
- _vC.add(_morphC);
- }
- var intersection = checkIntersection(object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint);
- if (intersection) {
- if (uv) {
- _uvA.fromBufferAttribute(uv, a);
- _uvB.fromBufferAttribute(uv, b);
- _uvC.fromBufferAttribute(uv, c);
- intersection.uv = Triangle.getUV(_intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2());
- }
- if (uv2) {
- _uvA.fromBufferAttribute(uv2, a);
- _uvB.fromBufferAttribute(uv2, b);
- _uvC.fromBufferAttribute(uv2, c);
- intersection.uv2 = Triangle.getUV(_intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2());
- }
- var face = new Face3(a, b, c);
- Triangle.getNormal(_vA, _vB, _vC, face.normal);
- intersection.face = face;
- }
- return intersection;
- }
- var _geometryId = 0;
- var _m1$3 = new Matrix4();
- var _obj$1 = new Object3D();
- var _offset$1 = new Vector3();
- function Geometry() {
- Object.defineProperty(this, "id", { value: _geometryId += 2 });
- this.uuid = MathUtils.generateUUID();
- this.name = "";
- this.type = "Geometry";
- this.vertices = [];
- this.colors = [];
- this.faces = [];
- this.faceVertexUvs = [[]];
- this.morphTargets = [];
- this.morphNormals = [];
- this.skinWeights = [];
- this.skinIndices = [];
- this.lineDistances = [];
- this.boundingBox = null;
- this.boundingSphere = null;
- this.elementsNeedUpdate = false;
- this.verticesNeedUpdate = false;
- this.uvsNeedUpdate = false;
- this.normalsNeedUpdate = false;
- this.colorsNeedUpdate = false;
- this.lineDistancesNeedUpdate = false;
- this.groupsNeedUpdate = false;
- }
- Geometry.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
- constructor: Geometry,
- isGeometry: true,
- applyMatrix4: function(matrix) {
- var normalMatrix = new Matrix3().getNormalMatrix(matrix);
- for (var i2 = 0, il = this.vertices.length; i2 < il; i2++) {
- var vertex = this.vertices[i2];
- vertex.applyMatrix4(matrix);
- }
- for (var i2 = 0, il = this.faces.length; i2 < il; i2++) {
- var face = this.faces[i2];
- face.normal.applyMatrix3(normalMatrix).normalize();
- for (var j = 0, jl = face.vertexNormals.length; j < jl; j++) {
- face.vertexNormals[j].applyMatrix3(normalMatrix).normalize();
- }
- }
- if (this.boundingBox !== null) {
- this.computeBoundingBox();
- }
- if (this.boundingSphere !== null) {
- this.computeBoundingSphere();
- }
- this.verticesNeedUpdate = true;
- this.normalsNeedUpdate = true;
- return this;
- },
- rotateX: function(angle) {
- _m1$3.makeRotationX(angle);
- this.applyMatrix4(_m1$3);
- return this;
- },
- rotateY: function(angle) {
- _m1$3.makeRotationY(angle);
- this.applyMatrix4(_m1$3);
- return this;
- },
- rotateZ: function(angle) {
- _m1$3.makeRotationZ(angle);
- this.applyMatrix4(_m1$3);
- return this;
- },
- translate: function(x, y, z) {
- _m1$3.makeTranslation(x, y, z);
- this.applyMatrix4(_m1$3);
- return this;
- },
- scale: function(x, y, z) {
- _m1$3.makeScale(x, y, z);
- this.applyMatrix4(_m1$3);
- return this;
- },
- lookAt: function(vector) {
- _obj$1.lookAt(vector);
- _obj$1.updateMatrix();
- this.applyMatrix4(_obj$1.matrix);
- return this;
- },
- fromBufferGeometry: function(geometry) {
- var scope = this;
- var indices = geometry.index !== null ? geometry.index.array : void 0;
- var attributes = geometry.attributes;
- if (attributes.position === void 0) {
- console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion.");
- return this;
- }
- var positions = attributes.position.array;
- var normals = attributes.normal !== void 0 ? attributes.normal.array : void 0;
- var colors = attributes.color !== void 0 ? attributes.color.array : void 0;
- var uvs = attributes.uv !== void 0 ? attributes.uv.array : void 0;
- var uvs2 = attributes.uv2 !== void 0 ? attributes.uv2.array : void 0;
- if (uvs2 !== void 0)
- this.faceVertexUvs[1] = [];
- for (var i2 = 0; i2 < positions.length; i2 += 3) {
- scope.vertices.push(new Vector3().fromArray(positions, i2));
- if (colors !== void 0) {
- scope.colors.push(new Color().fromArray(colors, i2));
- }
- }
- function addFace(a, b, c, materialIndex) {
- var vertexColors = colors === void 0 ? [] : [
- scope.colors[a].clone(),
- scope.colors[b].clone(),
- scope.colors[c].clone()
- ];
- var vertexNormals = normals === void 0 ? [] : [
- new Vector3().fromArray(normals, a * 3),
- new Vector3().fromArray(normals, b * 3),
- new Vector3().fromArray(normals, c * 3)
- ];
- var face = new Face3(a, b, c, vertexNormals, vertexColors, materialIndex);
- scope.faces.push(face);
- if (uvs !== void 0) {
- scope.faceVertexUvs[0].push([
- new Vector2().fromArray(uvs, a * 2),
- new Vector2().fromArray(uvs, b * 2),
- new Vector2().fromArray(uvs, c * 2)
- ]);
- }
- if (uvs2 !== void 0) {
- scope.faceVertexUvs[1].push([
- new Vector2().fromArray(uvs2, a * 2),
- new Vector2().fromArray(uvs2, b * 2),
- new Vector2().fromArray(uvs2, c * 2)
- ]);
- }
- }
- var groups = geometry.groups;
- if (groups.length > 0) {
- for (var i2 = 0; i2 < groups.length; i2++) {
- var group = groups[i2];
- var start = group.start;
- var count = group.count;
- for (var j = start, jl = start + count; j < jl; j += 3) {
- if (indices !== void 0) {
- addFace(indices[j], indices[j + 1], indices[j + 2], group.materialIndex);
- } else {
- addFace(j, j + 1, j + 2, group.materialIndex);
- }
- }
- }
- } else {
- if (indices !== void 0) {
- for (var i2 = 0; i2 < indices.length; i2 += 3) {
- addFace(indices[i2], indices[i2 + 1], indices[i2 + 2]);
- }
- } else {
- for (var i2 = 0; i2 < positions.length / 3; i2 += 3) {
- addFace(i2, i2 + 1, i2 + 2);
- }
- }
- }
- this.computeFaceNormals();
- if (geometry.boundingBox !== null) {
- this.boundingBox = geometry.boundingBox.clone();
- }
- if (geometry.boundingSphere !== null) {
- this.boundingSphere = geometry.boundingSphere.clone();
- }
- return this;
- },
- center: function() {
- this.computeBoundingBox();
- this.boundingBox.getCenter(_offset$1).negate();
- this.translate(_offset$1.x, _offset$1.y, _offset$1.z);
- return this;
- },
- normalize: function() {
- this.computeBoundingSphere();
- var center = this.boundingSphere.center;
- var radius = this.boundingSphere.radius;
- var s = radius === 0 ? 1 : 1 / radius;
- var matrix = new Matrix4();
- matrix.set(
- s,
- 0,
- 0,
- -s * center.x,
- 0,
- s,
- 0,
- -s * center.y,
- 0,
- 0,
- s,
- -s * center.z,
- 0,
- 0,
- 0,
- 1
- );
- this.applyMatrix4(matrix);
- return this;
- },
- computeFaceNormals: function() {
- var cb = new Vector3(), ab = new Vector3();
- for (var f = 0, fl = this.faces.length; f < fl; f++) {
- var face = this.faces[f];
- var vA = this.vertices[face.a];
- var vB = this.vertices[face.b];
- var vC = this.vertices[face.c];
- cb.subVectors(vC, vB);
- ab.subVectors(vA, vB);
- cb.cross(ab);
- cb.normalize();
- face.normal.copy(cb);
- }
- },
- computeVertexNormals: function(areaWeighted) {
- if (areaWeighted === void 0)
- areaWeighted = true;
- var v, vl, f, fl, face, vertices;
- vertices = new Array(this.vertices.length);
- for (v = 0, vl = this.vertices.length; v < vl; v++) {
- vertices[v] = new Vector3();
- }
- if (areaWeighted) {
- var vA, vB, vC;
- var cb = new Vector3(), ab = new Vector3();
- for (f = 0, fl = this.faces.length; f < fl; f++) {
- face = this.faces[f];
- vA = this.vertices[face.a];
- vB = this.vertices[face.b];
- vC = this.vertices[face.c];
- cb.subVectors(vC, vB);
- ab.subVectors(vA, vB);
- cb.cross(ab);
- vertices[face.a].add(cb);
- vertices[face.b].add(cb);
- vertices[face.c].add(cb);
- }
- } else {
- this.computeFaceNormals();
- for (f = 0, fl = this.faces.length; f < fl; f++) {
- face = this.faces[f];
- vertices[face.a].add(face.normal);
- vertices[face.b].add(face.normal);
- vertices[face.c].add(face.normal);
- }
- }
- for (v = 0, vl = this.vertices.length; v < vl; v++) {
- vertices[v].normalize();
- }
- for (f = 0, fl = this.faces.length; f < fl; f++) {
- face = this.faces[f];
- var vertexNormals = face.vertexNormals;
- if (vertexNormals.length === 3) {
- vertexNormals[0].copy(vertices[face.a]);
- vertexNormals[1].copy(vertices[face.b]);
- vertexNormals[2].copy(vertices[face.c]);
- } else {
- vertexNormals[0] = vertices[face.a].clone();
- vertexNormals[1] = vertices[face.b].clone();
- vertexNormals[2] = vertices[face.c].clone();
- }
- }
- if (this.faces.length > 0) {
- this.normalsNeedUpdate = true;
- }
- },
- computeFlatVertexNormals: function() {
- var f, fl, face;
- this.computeFaceNormals();
- for (f = 0, fl = this.faces.length; f < fl; f++) {
- face = this.faces[f];
- var vertexNormals = face.vertexNormals;
- if (vertexNormals.length === 3) {
- vertexNormals[0].copy(face.normal);
- vertexNormals[1].copy(face.normal);
- vertexNormals[2].copy(face.normal);
- } else {
- vertexNormals[0] = face.normal.clone();
- vertexNormals[1] = face.normal.clone();
- vertexNormals[2] = face.normal.clone();
- }
- }
- if (this.faces.length > 0) {
- this.normalsNeedUpdate = true;
- }
- },
- computeMorphNormals: function() {
- var i2, il, f, fl, face;
- for (f = 0, fl = this.faces.length; f < fl; f++) {
- face = this.faces[f];
- if (!face.__originalFaceNormal) {
- face.__originalFaceNormal = face.normal.clone();
- } else {
- face.__originalFaceNormal.copy(face.normal);
- }
- if (!face.__originalVertexNormals)
- face.__originalVertexNormals = [];
- for (i2 = 0, il = face.vertexNormals.length; i2 < il; i2++) {
- if (!face.__originalVertexNormals[i2]) {
- face.__originalVertexNormals[i2] = face.vertexNormals[i2].clone();
- } else {
- face.__originalVertexNormals[i2].copy(face.vertexNormals[i2]);
- }
- }
- }
- var tmpGeo = new Geometry();
- tmpGeo.faces = this.faces;
- for (i2 = 0, il = this.morphTargets.length; i2 < il; i2++) {
- if (!this.morphNormals[i2]) {
- this.morphNormals[i2] = {};
- this.morphNormals[i2].faceNormals = [];
- this.morphNormals[i2].vertexNormals = [];
- var dstNormalsFace = this.morphNormals[i2].faceNormals;
- var dstNormalsVertex = this.morphNormals[i2].vertexNormals;
- var faceNormal, vertexNormals;
- for (f = 0, fl = this.faces.length; f < fl; f++) {
- faceNormal = new Vector3();
- vertexNormals = { a: new Vector3(), b: new Vector3(), c: new Vector3() };
- dstNormalsFace.push(faceNormal);
- dstNormalsVertex.push(vertexNormals);
- }
- }
- var morphNormals = this.morphNormals[i2];
- tmpGeo.vertices = this.morphTargets[i2].vertices;
- tmpGeo.computeFaceNormals();
- tmpGeo.computeVertexNormals();
- var faceNormal, vertexNormals;
- for (f = 0, fl = this.faces.length; f < fl; f++) {
- face = this.faces[f];
- faceNormal = morphNormals.faceNormals[f];
- vertexNormals = morphNormals.vertexNormals[f];
- faceNormal.copy(face.normal);
- vertexNormals.a.copy(face.vertexNormals[0]);
- vertexNormals.b.copy(face.vertexNormals[1]);
- vertexNormals.c.copy(face.vertexNormals[2]);
- }
- }
- for (f = 0, fl = this.faces.length; f < fl; f++) {
- face = this.faces[f];
- face.normal = face.__originalFaceNormal;
- face.vertexNormals = face.__originalVertexNormals;
- }
- },
- computeBoundingBox: function() {
- if (this.boundingBox === null) {
- this.boundingBox = new Box3();
- }
- this.boundingBox.setFromPoints(this.vertices);
- },
- computeBoundingSphere: function() {
- if (this.boundingSphere === null) {
- this.boundingSphere = new Sphere();
- }
- this.boundingSphere.setFromPoints(this.vertices);
- },
- merge: function(geometry, matrix, materialIndexOffset) {
- if (!(geometry && geometry.isGeometry)) {
- console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.", geometry);
- return;
- }
- var normalMatrix, vertexOffset = this.vertices.length, vertices1 = this.vertices, vertices2 = geometry.vertices, faces1 = this.faces, faces2 = geometry.faces, colors1 = this.colors, colors2 = geometry.colors;
- if (materialIndexOffset === void 0)
- materialIndexOffset = 0;
- if (matrix !== void 0) {
- normalMatrix = new Matrix3().getNormalMatrix(matrix);
- }
- for (var i2 = 0, il = vertices2.length; i2 < il; i2++) {
- var vertex = vertices2[i2];
- var vertexCopy = vertex.clone();
- if (matrix !== void 0)
- vertexCopy.applyMatrix4(matrix);
- vertices1.push(vertexCopy);
- }
- for (var i2 = 0, il = colors2.length; i2 < il; i2++) {
- colors1.push(colors2[i2].clone());
- }
- for (i2 = 0, il = faces2.length; i2 < il; i2++) {
- var face = faces2[i2], faceCopy, normal, color, faceVertexNormals = face.vertexNormals, faceVertexColors = face.vertexColors;
- faceCopy = new Face3(face.a + vertexOffset, face.b + vertexOffset, face.c + vertexOffset);
- faceCopy.normal.copy(face.normal);
- if (normalMatrix !== void 0) {
- faceCopy.normal.applyMatrix3(normalMatrix).normalize();
- }
- for (var j = 0, jl = faceVertexNormals.length; j < jl; j++) {
- normal = faceVertexNormals[j].clone();
- if (normalMatrix !== void 0) {
- normal.applyMatrix3(normalMatrix).normalize();
- }
- faceCopy.vertexNormals.push(normal);
- }
- faceCopy.color.copy(face.color);
- for (var j = 0, jl = faceVertexColors.length; j < jl; j++) {
- color = faceVertexColors[j];
- faceCopy.vertexColors.push(color.clone());
- }
- faceCopy.materialIndex = face.materialIndex + materialIndexOffset;
- faces1.push(faceCopy);
- }
- for (var i2 = 0, il = geometry.faceVertexUvs.length; i2 < il; i2++) {
- var faceVertexUvs2 = geometry.faceVertexUvs[i2];
- if (this.faceVertexUvs[i2] === void 0)
- this.faceVertexUvs[i2] = [];
- for (var j = 0, jl = faceVertexUvs2.length; j < jl; j++) {
- var uvs2 = faceVertexUvs2[j], uvsCopy = [];
- for (var k = 0, kl = uvs2.length; k < kl; k++) {
- uvsCopy.push(uvs2[k].clone());
- }
- this.faceVertexUvs[i2].push(uvsCopy);
- }
- }
- },
- mergeMesh: function(mesh) {
- if (!(mesh && mesh.isMesh)) {
- console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.", mesh);
- return;
- }
- if (mesh.matrixAutoUpdate)
- mesh.updateMatrix();
- this.merge(mesh.geometry, mesh.matrix);
- },
- /*
- * Checks for duplicate vertices with hashmap.
- * Duplicated vertices are removed
- * and faces' vertices are updated.
- */
- mergeVertices: function() {
- var verticesMap = {};
- var unique = [], changes = [];
- var v, key;
- var precisionPoints = 4;
- var precision = Math.pow(10, precisionPoints);
- var i2, il, face;
- var indices, j, jl;
- for (i2 = 0, il = this.vertices.length; i2 < il; i2++) {
- v = this.vertices[i2];
- key = Math.round(v.x * precision) + "_" + Math.round(v.y * precision) + "_" + Math.round(v.z * precision);
- if (verticesMap[key] === void 0) {
- verticesMap[key] = i2;
- unique.push(this.vertices[i2]);
- changes[i2] = unique.length - 1;
- } else {
- changes[i2] = changes[verticesMap[key]];
- }
- }
- var faceIndicesToRemove = [];
- for (i2 = 0, il = this.faces.length; i2 < il; i2++) {
- face = this.faces[i2];
- face.a = changes[face.a];
- face.b = changes[face.b];
- face.c = changes[face.c];
- indices = [face.a, face.b, face.c];
- for (var n = 0; n < 3; n++) {
- if (indices[n] === indices[(n + 1) % 3]) {
- faceIndicesToRemove.push(i2);
- break;
- }
- }
- }
- for (i2 = faceIndicesToRemove.length - 1; i2 >= 0; i2--) {
- var idx = faceIndicesToRemove[i2];
- this.faces.splice(idx, 1);
- for (j = 0, jl = this.faceVertexUvs.length; j < jl; j++) {
- this.faceVertexUvs[j].splice(idx, 1);
- }
- }
- var diff = this.vertices.length - unique.length;
- this.vertices = unique;
- return diff;
- },
- setFromPoints: function(points) {
- this.vertices = [];
- for (var i2 = 0, l = points.length; i2 < l; i2++) {
- var point = points[i2];
- this.vertices.push(new Vector3(point.x, point.y, point.z || 0));
- }
- return this;
- },
- sortFacesByMaterialIndex: function() {
- var faces = this.faces;
- var length = faces.length;
- for (var i2 = 0; i2 < length; i2++) {
- faces[i2]._id = i2;
- }
- function materialIndexSort(a, b) {
- return a.materialIndex - b.materialIndex;
- }
- faces.sort(materialIndexSort);
- var uvs1 = this.faceVertexUvs[0];
- var uvs2 = this.faceVertexUvs[1];
- var newUvs1, newUvs2;
- if (uvs1 && uvs1.length === length)
- newUvs1 = [];
- if (uvs2 && uvs2.length === length)
- newUvs2 = [];
- for (var i2 = 0; i2 < length; i2++) {
- var id = faces[i2]._id;
- if (newUvs1)
- newUvs1.push(uvs1[id]);
- if (newUvs2)
- newUvs2.push(uvs2[id]);
- }
- if (newUvs1)
- this.faceVertexUvs[0] = newUvs1;
- if (newUvs2)
- this.faceVertexUvs[1] = newUvs2;
- },
- toJSON: function() {
- var data = {
- metadata: {
- version: 4.5,
- type: "Geometry",
- generator: "Geometry.toJSON"
- }
- };
- data.uuid = this.uuid;
- data.type = this.type;
- if (this.name !== "")
- data.name = this.name;
- if (this.parameters !== void 0) {
- var parameters = this.parameters;
- for (var key in parameters) {
- if (parameters[key] !== void 0)
- data[key] = parameters[key];
- }
- return data;
- }
- var vertices = [];
- for (var i2 = 0; i2 < this.vertices.length; i2++) {
- var vertex = this.vertices[i2];
- vertices.push(vertex.x, vertex.y, vertex.z);
- }
- var faces = [];
- var normals = [];
- var normalsHash = {};
- var colors = [];
- var colorsHash = {};
- var uvs = [];
- var uvsHash = {};
- for (var i2 = 0; i2 < this.faces.length; i2++) {
- var face = this.faces[i2];
- var hasMaterial = true;
- var hasFaceUv = false;
- var hasFaceVertexUv = this.faceVertexUvs[0][i2] !== void 0;
- var hasFaceNormal = face.normal.length() > 0;
- var hasFaceVertexNormal = face.vertexNormals.length > 0;
- var hasFaceColor = face.color.r !== 1 || face.color.g !== 1 || face.color.b !== 1;
- var hasFaceVertexColor = face.vertexColors.length > 0;
- var faceType = 0;
- faceType = setBit(faceType, 0, 0);
- faceType = setBit(faceType, 1, hasMaterial);
- faceType = setBit(faceType, 2, hasFaceUv);
- faceType = setBit(faceType, 3, hasFaceVertexUv);
- faceType = setBit(faceType, 4, hasFaceNormal);
- faceType = setBit(faceType, 5, hasFaceVertexNormal);
- faceType = setBit(faceType, 6, hasFaceColor);
- faceType = setBit(faceType, 7, hasFaceVertexColor);
- faces.push(faceType);
- faces.push(face.a, face.b, face.c);
- faces.push(face.materialIndex);
- if (hasFaceVertexUv) {
- var faceVertexUvs = this.faceVertexUvs[0][i2];
- faces.push(
- getUvIndex(faceVertexUvs[0]),
- getUvIndex(faceVertexUvs[1]),
- getUvIndex(faceVertexUvs[2])
- );
- }
- if (hasFaceNormal) {
- faces.push(getNormalIndex(face.normal));
- }
- if (hasFaceVertexNormal) {
- var vertexNormals = face.vertexNormals;
- faces.push(
- getNormalIndex(vertexNormals[0]),
- getNormalIndex(vertexNormals[1]),
- getNormalIndex(vertexNormals[2])
- );
- }
- if (hasFaceColor) {
- faces.push(getColorIndex(face.color));
- }
- if (hasFaceVertexColor) {
- var vertexColors = face.vertexColors;
- faces.push(
- getColorIndex(vertexColors[0]),
- getColorIndex(vertexColors[1]),
- getColorIndex(vertexColors[2])
- );
- }
- }
- function setBit(value, position, enabled) {
- return enabled ? value | 1 << position : value & ~(1 << position);
- }
- function getNormalIndex(normal) {
- var hash = normal.x.toString() + normal.y.toString() + normal.z.toString();
- if (normalsHash[hash] !== void 0) {
- return normalsHash[hash];
- }
- normalsHash[hash] = normals.length / 3;
- normals.push(normal.x, normal.y, normal.z);
- return normalsHash[hash];
- }
- function getColorIndex(color) {
- var hash = color.r.toString() + color.g.toString() + color.b.toString();
- if (colorsHash[hash] !== void 0) {
- return colorsHash[hash];
- }
- colorsHash[hash] = colors.length;
- colors.push(color.getHex());
- return colorsHash[hash];
- }
- function getUvIndex(uv) {
- var hash = uv.x.toString() + uv.y.toString();
- if (uvsHash[hash] !== void 0) {
- return uvsHash[hash];
- }
- uvsHash[hash] = uvs.length / 2;
- uvs.push(uv.x, uv.y);
- return uvsHash[hash];
- }
- data.data = {};
- data.data.vertices = vertices;
- data.data.normals = normals;
- if (colors.length > 0)
- data.data.colors = colors;
- if (uvs.length > 0)
- data.data.uvs = [uvs];
- data.data.faces = faces;
- return data;
- },
- clone: function() {
- return new Geometry().copy(this);
- },
- copy: function(source) {
- var i2, il, j, jl, k, kl;
- this.vertices = [];
- this.colors = [];
- this.faces = [];
- this.faceVertexUvs = [[]];
- this.morphTargets = [];
- this.morphNormals = [];
- this.skinWeights = [];
- this.skinIndices = [];
- this.lineDistances = [];
- this.boundingBox = null;
- this.boundingSphere = null;
- this.name = source.name;
- var vertices = source.vertices;
- for (i2 = 0, il = vertices.length; i2 < il; i2++) {
- this.vertices.push(vertices[i2].clone());
- }
- var colors = source.colors;
- for (i2 = 0, il = colors.length; i2 < il; i2++) {
- this.colors.push(colors[i2].clone());
- }
- var faces = source.faces;
- for (i2 = 0, il = faces.length; i2 < il; i2++) {
- this.faces.push(faces[i2].clone());
- }
- for (i2 = 0, il = source.faceVertexUvs.length; i2 < il; i2++) {
- var faceVertexUvs = source.faceVertexUvs[i2];
- if (this.faceVertexUvs[i2] === void 0) {
- this.faceVertexUvs[i2] = [];
- }
- for (j = 0, jl = faceVertexUvs.length; j < jl; j++) {
- var uvs = faceVertexUvs[j], uvsCopy = [];
- for (k = 0, kl = uvs.length; k < kl; k++) {
- var uv = uvs[k];
- uvsCopy.push(uv.clone());
- }
- this.faceVertexUvs[i2].push(uvsCopy);
- }
- }
- var morphTargets = source.morphTargets;
- for (i2 = 0, il = morphTargets.length; i2 < il; i2++) {
- var morphTarget = {};
- morphTarget.name = morphTargets[i2].name;
- if (morphTargets[i2].vertices !== void 0) {
- morphTarget.vertices = [];
- for (j = 0, jl = morphTargets[i2].vertices.length; j < jl; j++) {
- morphTarget.vertices.push(morphTargets[i2].vertices[j].clone());
- }
- }
- if (morphTargets[i2].normals !== void 0) {
- morphTarget.normals = [];
- for (j = 0, jl = morphTargets[i2].normals.length; j < jl; j++) {
- morphTarget.normals.push(morphTargets[i2].normals[j].clone());
- }
- }
- this.morphTargets.push(morphTarget);
- }
- var morphNormals = source.morphNormals;
- for (i2 = 0, il = morphNormals.length; i2 < il; i2++) {
- var morphNormal = {};
- if (morphNormals[i2].vertexNormals !== void 0) {
- morphNormal.vertexNormals = [];
- for (j = 0, jl = morphNormals[i2].vertexNormals.length; j < jl; j++) {
- var srcVertexNormal = morphNormals[i2].vertexNormals[j];
- var destVertexNormal = {};
- destVertexNormal.a = srcVertexNormal.a.clone();
- destVertexNormal.b = srcVertexNormal.b.clone();
- destVertexNormal.c = srcVertexNormal.c.clone();
- morphNormal.vertexNormals.push(destVertexNormal);
- }
- }
- if (morphNormals[i2].faceNormals !== void 0) {
- morphNormal.faceNormals = [];
- for (j = 0, jl = morphNormals[i2].faceNormals.length; j < jl; j++) {
- morphNormal.faceNormals.push(morphNormals[i2].faceNormals[j].clone());
- }
- }
- this.morphNormals.push(morphNormal);
- }
- var skinWeights = source.skinWeights;
- for (i2 = 0, il = skinWeights.length; i2 < il; i2++) {
- this.skinWeights.push(skinWeights[i2].clone());
- }
- var skinIndices = source.skinIndices;
- for (i2 = 0, il = skinIndices.length; i2 < il; i2++) {
- this.skinIndices.push(skinIndices[i2].clone());
- }
- var lineDistances = source.lineDistances;
- for (i2 = 0, il = lineDistances.length; i2 < il; i2++) {
- this.lineDistances.push(lineDistances[i2]);
- }
- var boundingBox = source.boundingBox;
- if (boundingBox !== null) {
- this.boundingBox = boundingBox.clone();
- }
- var boundingSphere = source.boundingSphere;
- if (boundingSphere !== null) {
- this.boundingSphere = boundingSphere.clone();
- }
- this.elementsNeedUpdate = source.elementsNeedUpdate;
- this.verticesNeedUpdate = source.verticesNeedUpdate;
- this.uvsNeedUpdate = source.uvsNeedUpdate;
- this.normalsNeedUpdate = source.normalsNeedUpdate;
- this.colorsNeedUpdate = source.colorsNeedUpdate;
- this.lineDistancesNeedUpdate = source.lineDistancesNeedUpdate;
- this.groupsNeedUpdate = source.groupsNeedUpdate;
- return this;
- },
- dispose: function() {
- this.dispatchEvent({ type: "dispose" });
- }
- });
- class BoxGeometry extends Geometry {
- constructor(width, height, depth, widthSegments, heightSegments, depthSegments) {
- super();
- this.type = "BoxGeometry";
- this.parameters = {
- width,
- height,
- depth,
- widthSegments,
- heightSegments,
- depthSegments
- };
- this.fromBufferGeometry(new BoxBufferGeometry(width, height, depth, widthSegments, heightSegments, depthSegments));
- this.mergeVertices();
- }
- }
- class BoxBufferGeometry extends BufferGeometry {
- constructor(width, height, depth, widthSegments, heightSegments, depthSegments) {
- super();
- this.type = "BoxBufferGeometry";
- this.parameters = {
- width,
- height,
- depth,
- widthSegments,
- heightSegments,
- depthSegments
- };
- var scope = this;
- width = width || 1;
- height = height || 1;
- depth = depth || 1;
- widthSegments = Math.floor(widthSegments) || 1;
- heightSegments = Math.floor(heightSegments) || 1;
- depthSegments = Math.floor(depthSegments) || 1;
- var indices = [];
- var vertices = [];
- var normals = [];
- var uvs = [];
- var numberOfVertices = 0;
- var groupStart = 0;
- buildPlane("z", "y", "x", -1, -1, depth, height, width, depthSegments, heightSegments, 0);
- buildPlane("z", "y", "x", 1, -1, depth, height, -width, depthSegments, heightSegments, 1);
- buildPlane("x", "z", "y", 1, 1, width, depth, height, widthSegments, depthSegments, 2);
- buildPlane("x", "z", "y", 1, -1, width, depth, -height, widthSegments, depthSegments, 3);
- buildPlane("x", "y", "z", 1, -1, width, height, depth, widthSegments, heightSegments, 4);
- buildPlane("x", "y", "z", -1, -1, width, height, -depth, widthSegments, heightSegments, 5);
- this.setIndex(indices);
- this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
- this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
- function buildPlane(u, v, w, udir, vdir, width2, height2, depth2, gridX, gridY, materialIndex) {
- var segmentWidth = width2 / gridX;
- var segmentHeight = height2 / gridY;
- var widthHalf = width2 / 2;
- var heightHalf = height2 / 2;
- var depthHalf = depth2 / 2;
- var gridX1 = gridX + 1;
- var gridY1 = gridY + 1;
- var vertexCounter = 0;
- var groupCount = 0;
- var ix, iy;
- var vector = new Vector3();
- for (iy = 0; iy < gridY1; iy++) {
- var y = iy * segmentHeight - heightHalf;
- for (ix = 0; ix < gridX1; ix++) {
- var x = ix * segmentWidth - widthHalf;
- vector[u] = x * udir;
- vector[v] = y * vdir;
- vector[w] = depthHalf;
- vertices.push(vector.x, vector.y, vector.z);
- vector[u] = 0;
- vector[v] = 0;
- vector[w] = depth2 > 0 ? 1 : -1;
- normals.push(vector.x, vector.y, vector.z);
- uvs.push(ix / gridX);
- uvs.push(1 - iy / gridY);
- vertexCounter += 1;
- }
- }
- for (iy = 0; iy < gridY; iy++) {
- for (ix = 0; ix < gridX; ix++) {
- var a = numberOfVertices + ix + gridX1 * iy;
- var b = numberOfVertices + ix + gridX1 * (iy + 1);
- var c = numberOfVertices + (ix + 1) + gridX1 * (iy + 1);
- var d = numberOfVertices + (ix + 1) + gridX1 * iy;
- indices.push(a, b, d);
- indices.push(b, c, d);
- groupCount += 6;
- }
- }
- scope.addGroup(groupStart, groupCount, materialIndex);
- groupStart += groupCount;
- numberOfVertices += vertexCounter;
- }
- }
- }
- function cloneUniforms(src) {
- var dst = {};
- for (var u in src) {
- dst[u] = {};
- for (var p in src[u]) {
- var property = src[u][p];
- if (property && (property.isColor || property.isMatrix3 || property.isMatrix4 || property.isVector2 || property.isVector3 || property.isVector4 || property.isTexture)) {
- dst[u][p] = property.clone();
- } else if (Array.isArray(property)) {
- dst[u][p] = property.slice();
- } else {
- dst[u][p] = property;
- }
- }
- }
- return dst;
- }
- function mergeUniforms(uniforms) {
- var merged = {};
- for (var u = 0; u < uniforms.length; u++) {
- var tmp2 = cloneUniforms(uniforms[u]);
- for (var p in tmp2) {
- merged[p] = tmp2[p];
- }
- }
- return merged;
- }
- var UniformsUtils = { clone: cloneUniforms, merge: mergeUniforms };
- var default_vertex = "void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}";
- var default_fragment = "void main() {\n gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}";
- function ShaderMaterial(parameters) {
- Material.call(this);
- this.type = "ShaderMaterial";
- this.defines = {};
- this.uniforms = {};
- this.vertexShader = default_vertex;
- this.fragmentShader = default_fragment;
- this.linewidth = 1;
- this.wireframe = false;
- this.wireframeLinewidth = 1;
- this.fog = false;
- this.lights = false;
- this.clipping = false;
- this.skinning = false;
- this.morphTargets = false;
- this.morphNormals = false;
- this.extensions = {
- derivatives: false,
- // set to use derivatives
- fragDepth: false,
- // set to use fragment depth values
- drawBuffers: false,
- // set to use draw buffers
- shaderTextureLOD: false
- // set to use shader texture LOD
- };
- this.defaultAttributeValues = {
- "color": [1, 1, 1],
- "uv": [0, 0],
- "uv2": [0, 0]
- };
- this.index0AttributeName = void 0;
- this.uniformsNeedUpdate = false;
- if (parameters !== void 0) {
- if (parameters.attributes !== void 0) {
- console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead.");
- }
- this.setValues(parameters);
- }
- }
- ShaderMaterial.prototype = Object.create(Material.prototype);
- ShaderMaterial.prototype.constructor = ShaderMaterial;
- ShaderMaterial.prototype.isShaderMaterial = true;
- ShaderMaterial.prototype.copy = function(source) {
- Material.prototype.copy.call(this, source);
- this.fragmentShader = source.fragmentShader;
- this.vertexShader = source.vertexShader;
- this.uniforms = cloneUniforms(source.uniforms);
- this.defines = Object.assign({}, source.defines);
- this.wireframe = source.wireframe;
- this.wireframeLinewidth = source.wireframeLinewidth;
- this.lights = source.lights;
- this.clipping = source.clipping;
- this.skinning = source.skinning;
- this.morphTargets = source.morphTargets;
- this.morphNormals = source.morphNormals;
- this.extensions = source.extensions;
- return this;
- };
- ShaderMaterial.prototype.toJSON = function(meta) {
- var data = Material.prototype.toJSON.call(this, meta);
- data.uniforms = {};
- for (var name in this.uniforms) {
- var uniform = this.uniforms[name];
- var value = uniform.value;
- if (value && value.isTexture) {
- data.uniforms[name] = {
- type: "t",
- value: value.toJSON(meta).uuid
- };
- } else if (value && value.isColor) {
- data.uniforms[name] = {
- type: "c",
- value: value.getHex()
- };
- } else if (value && value.isVector2) {
- data.uniforms[name] = {
- type: "v2",
- value: value.toArray()
- };
- } else if (value && value.isVector3) {
- data.uniforms[name] = {
- type: "v3",
- value: value.toArray()
- };
- } else if (value && value.isVector4) {
- data.uniforms[name] = {
- type: "v4",
- value: value.toArray()
- };
- } else if (value && value.isMatrix3) {
- data.uniforms[name] = {
- type: "m3",
- value: value.toArray()
- };
- } else if (value && value.isMatrix4) {
- data.uniforms[name] = {
- type: "m4",
- value: value.toArray()
- };
- } else {
- data.uniforms[name] = {
- value
- };
- }
- }
- if (Object.keys(this.defines).length > 0)
- data.defines = this.defines;
- data.vertexShader = this.vertexShader;
- data.fragmentShader = this.fragmentShader;
- var extensions = {};
- for (var key in this.extensions) {
- if (this.extensions[key] === true)
- extensions[key] = true;
- }
- if (Object.keys(extensions).length > 0)
- data.extensions = extensions;
- return data;
- };
- function Camera() {
- Object3D.call(this);
- this.type = "Camera";
- this.matrixWorldInverse = new Matrix4();
- this.projectionMatrix = new Matrix4();
- this.projectionMatrixInverse = new Matrix4();
- }
- Camera.prototype = Object.assign(Object.create(Object3D.prototype), {
- constructor: Camera,
- isCamera: true,
- copy: function(source, recursive) {
- Object3D.prototype.copy.call(this, source, recursive);
- this.matrixWorldInverse.copy(source.matrixWorldInverse);
- this.projectionMatrix.copy(source.projectionMatrix);
- this.projectionMatrixInverse.copy(source.projectionMatrixInverse);
- return this;
- },
- getWorldDirection: function(target) {
- if (target === void 0) {
- console.warn("THREE.Camera: .getWorldDirection() target is now required");
- target = new Vector3();
- }
- this.updateMatrixWorld(true);
- var e = this.matrixWorld.elements;
- return target.set(-e[8], -e[9], -e[10]).normalize();
- },
- updateMatrixWorld: function(force) {
- Object3D.prototype.updateMatrixWorld.call(this, force);
- this.matrixWorldInverse.getInverse(this.matrixWorld);
- },
- updateWorldMatrix: function(updateParents, updateChildren) {
- Object3D.prototype.updateWorldMatrix.call(this, updateParents, updateChildren);
- this.matrixWorldInverse.getInverse(this.matrixWorld);
- },
- clone: function() {
- return new this.constructor().copy(this);
- }
- });
- function PerspectiveCamera(fov2, aspect2, near, far) {
- Camera.call(this);
- this.type = "PerspectiveCamera";
- this.fov = fov2 !== void 0 ? fov2 : 50;
- this.zoom = 1;
- this.near = near !== void 0 ? near : 0.1;
- this.far = far !== void 0 ? far : 2e3;
- this.focus = 10;
- this.aspect = aspect2 !== void 0 ? aspect2 : 1;
- this.view = null;
- this.filmGauge = 35;
- this.filmOffset = 0;
- this.updateProjectionMatrix();
- }
- PerspectiveCamera.prototype = Object.assign(Object.create(Camera.prototype), {
- constructor: PerspectiveCamera,
- isPerspectiveCamera: true,
- copy: function(source, recursive) {
- Camera.prototype.copy.call(this, source, recursive);
- this.fov = source.fov;
- this.zoom = source.zoom;
- this.near = source.near;
- this.far = source.far;
- this.focus = source.focus;
- this.aspect = source.aspect;
- this.view = source.view === null ? null : Object.assign({}, source.view);
- this.filmGauge = source.filmGauge;
- this.filmOffset = source.filmOffset;
- return this;
- },
- /**
- * Sets the FOV by focal length in respect to the current .filmGauge.
- *
- * The default film gauge is 35, so that the focal length can be specified for
- * a 35mm (full frame) camera.
- *
- * Values for focal length and film gauge must have the same unit.
- */
- setFocalLength: function(focalLength) {
- var vExtentSlope = 0.5 * this.getFilmHeight() / focalLength;
- this.fov = MathUtils.RAD2DEG * 2 * Math.atan(vExtentSlope);
- this.updateProjectionMatrix();
- },
- /**
- * Calculates the focal length from the current .fov and .filmGauge.
- */
- getFocalLength: function() {
- var vExtentSlope = Math.tan(MathUtils.DEG2RAD * 0.5 * this.fov);
- return 0.5 * this.getFilmHeight() / vExtentSlope;
- },
- getEffectiveFOV: function() {
- return MathUtils.RAD2DEG * 2 * Math.atan(
- Math.tan(MathUtils.DEG2RAD * 0.5 * this.fov) / this.zoom
- );
- },
- getFilmWidth: function() {
- return this.filmGauge * Math.min(this.aspect, 1);
- },
- getFilmHeight: function() {
- return this.filmGauge / Math.max(this.aspect, 1);
- },
- /**
- * Sets an offset in a larger frustum. This is useful for multi-window or
- * multi-monitor/multi-machine setups.
- *
- * For example, if you have 3x2 monitors and each monitor is 1920x1080 and
- * the monitors are in grid like this
- *
- * +---+---+---+
- * | A | B | C |
- * +---+---+---+
- * | D | E | F |
- * +---+---+---+
- *
- * then for each monitor you would call it like this
- *
- * var w = 1920;
- * var h = 1080;
- * var fullWidth = w * 3;
- * var fullHeight = h * 2;
- *
- * --A--
- * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
- * --B--
- * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );
- * --C--
- * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );
- * --D--
- * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );
- * --E--
- * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
- * --F--
- * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );
- *
- * Note there is no reason monitors have to be the same size or in a grid.
- */
- setViewOffset: function(fullWidth, fullHeight, x, y, width, height) {
- this.aspect = fullWidth / fullHeight;
- if (this.view === null) {
- this.view = {
- enabled: true,
- fullWidth: 1,
- fullHeight: 1,
- offsetX: 0,
- offsetY: 0,
- width: 1,
- height: 1
- };
- }
- this.view.enabled = true;
- this.view.fullWidth = fullWidth;
- this.view.fullHeight = fullHeight;
- this.view.offsetX = x;
- this.view.offsetY = y;
- this.view.width = width;
- this.view.height = height;
- this.updateProjectionMatrix();
- },
- clearViewOffset: function() {
- if (this.view !== null) {
- this.view.enabled = false;
- }
- this.updateProjectionMatrix();
- },
- updateProjectionMatrix: function() {
- 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;
- if (this.view !== null && this.view.enabled) {
- var fullWidth = view.fullWidth, fullHeight = view.fullHeight;
- left += view.offsetX * width / fullWidth;
- top2 -= view.offsetY * height / fullHeight;
- width *= view.width / fullWidth;
- height *= view.height / fullHeight;
- }
- var skew = this.filmOffset;
- if (skew !== 0)
- left += near * skew / this.getFilmWidth();
- this.projectionMatrix.makePerspective(left, left + width, top2, top2 - height, near, this.far);
- this.projectionMatrixInverse.getInverse(this.projectionMatrix);
- },
- toJSON: function(meta) {
- var data = Object3D.prototype.toJSON.call(this, meta);
- data.object.fov = this.fov;
- data.object.zoom = this.zoom;
- data.object.near = this.near;
- data.object.far = this.far;
- data.object.focus = this.focus;
- data.object.aspect = this.aspect;
- if (this.view !== null)
- data.object.view = Object.assign({}, this.view);
- data.object.filmGauge = this.filmGauge;
- data.object.filmOffset = this.filmOffset;
- return data;
- }
- });
- var fov = 90, aspect = 1;
- function CubeCamera(near, far, cubeResolution, options) {
- Object3D.call(this);
- this.type = "CubeCamera";
- var cameraPX = new PerspectiveCamera(fov, aspect, near, far);
- cameraPX.up.set(0, -1, 0);
- cameraPX.lookAt(new Vector3(1, 0, 0));
- this.add(cameraPX);
- var cameraNX = new PerspectiveCamera(fov, aspect, near, far);
- cameraNX.up.set(0, -1, 0);
- cameraNX.lookAt(new Vector3(-1, 0, 0));
- this.add(cameraNX);
- var cameraPY = new PerspectiveCamera(fov, aspect, near, far);
- cameraPY.up.set(0, 0, 1);
- cameraPY.lookAt(new Vector3(0, 1, 0));
- this.add(cameraPY);
- var cameraNY = new PerspectiveCamera(fov, aspect, near, far);
- cameraNY.up.set(0, 0, -1);
- cameraNY.lookAt(new Vector3(0, -1, 0));
- this.add(cameraNY);
- var cameraPZ = new PerspectiveCamera(fov, aspect, near, far);
- cameraPZ.up.set(0, -1, 0);
- cameraPZ.lookAt(new Vector3(0, 0, 1));
- this.add(cameraPZ);
- var cameraNZ = new PerspectiveCamera(fov, aspect, near, far);
- cameraNZ.up.set(0, -1, 0);
- cameraNZ.lookAt(new Vector3(0, 0, -1));
- this.add(cameraNZ);
- options = options || { format: RGBFormat, magFilter: LinearFilter, minFilter: LinearFilter };
- this.renderTarget = new WebGLCubeRenderTarget(cubeResolution, options);
- this.renderTarget.texture.name = "CubeCamera";
- this.update = function(renderer, scene) {
- if (this.parent === null)
- this.updateMatrixWorld();
- var currentRenderTarget = renderer.getRenderTarget();
- var renderTarget = this.renderTarget;
- var generateMipmaps = renderTarget.texture.generateMipmaps;
- renderTarget.texture.generateMipmaps = false;
- renderer.setRenderTarget(renderTarget, 0);
- renderer.render(scene, cameraPX);
- renderer.setRenderTarget(renderTarget, 1);
- renderer.render(scene, cameraNX);
- renderer.setRenderTarget(renderTarget, 2);
- renderer.render(scene, cameraPY);
- renderer.setRenderTarget(renderTarget, 3);
- renderer.render(scene, cameraNY);
- renderer.setRenderTarget(renderTarget, 4);
- renderer.render(scene, cameraPZ);
- renderTarget.texture.generateMipmaps = generateMipmaps;
- renderer.setRenderTarget(renderTarget, 5);
- renderer.render(scene, cameraNZ);
- renderer.setRenderTarget(currentRenderTarget);
- };
- this.clear = function(renderer, color, depth, stencil) {
- var currentRenderTarget = renderer.getRenderTarget();
- var renderTarget = this.renderTarget;
- for (var i2 = 0; i2 < 6; i2++) {
- renderer.setRenderTarget(renderTarget, i2);
- renderer.clear(color, depth, stencil);
- }
- renderer.setRenderTarget(currentRenderTarget);
- };
- }
- CubeCamera.prototype = Object.create(Object3D.prototype);
- CubeCamera.prototype.constructor = CubeCamera;
- function WebGLCubeRenderTarget(size, options, dummy) {
- if (Number.isInteger(options)) {
- console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )");
- options = dummy;
- }
- WebGLRenderTarget.call(this, size, size, options);
- }
- WebGLCubeRenderTarget.prototype = Object.create(WebGLRenderTarget.prototype);
- WebGLCubeRenderTarget.prototype.constructor = WebGLCubeRenderTarget;
- WebGLCubeRenderTarget.prototype.isWebGLCubeRenderTarget = true;
- WebGLCubeRenderTarget.prototype.fromEquirectangularTexture = function(renderer, texture) {
- this.texture.type = texture.type;
- this.texture.format = texture.format;
- this.texture.encoding = texture.encoding;
- var scene = new Scene();
- var shader = {
- uniforms: {
- tEquirect: { value: null }
- },
- vertexShader: [
- "varying vec3 vWorldDirection;",
- "vec3 transformDirection( in vec3 dir, in mat4 matrix ) {",
- " return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );",
- "}",
- "void main() {",
- " vWorldDirection = transformDirection( position, modelMatrix );",
- " #include <begin_vertex>",
- " #include <project_vertex>",
- "}"
- ].join("\n"),
- fragmentShader: [
- "uniform sampler2D tEquirect;",
- "varying vec3 vWorldDirection;",
- "#define RECIPROCAL_PI 0.31830988618",
- "#define RECIPROCAL_PI2 0.15915494",
- "void main() {",
- " vec3 direction = normalize( vWorldDirection );",
- " vec2 sampleUV;",
- " sampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;",
- " sampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;",
- " gl_FragColor = texture2D( tEquirect, sampleUV );",
- "}"
- ].join("\n")
- };
- var material = new ShaderMaterial({
- type: "CubemapFromEquirect",
- uniforms: cloneUniforms(shader.uniforms),
- vertexShader: shader.vertexShader,
- fragmentShader: shader.fragmentShader,
- side: BackSide,
- blending: NoBlending
- });
- material.uniforms.tEquirect.value = texture;
- var mesh = new Mesh(new BoxBufferGeometry(5, 5, 5), material);
- scene.add(mesh);
- var camera = new CubeCamera(1, 10, 1);
- camera.renderTarget = this;
- camera.renderTarget.texture.name = "CubeCameraTexture";
- camera.update(renderer, scene);
- mesh.geometry.dispose();
- mesh.material.dispose();
- return this;
- };
- function DataTexture(data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding) {
- Texture.call(this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);
- this.image = { data: data || null, width: width || 1, height: height || 1 };
- this.magFilter = magFilter !== void 0 ? magFilter : NearestFilter;
- this.minFilter = minFilter !== void 0 ? minFilter : NearestFilter;
- this.generateMipmaps = false;
- this.flipY = false;
- this.unpackAlignment = 1;
- this.needsUpdate = true;
- }
- DataTexture.prototype = Object.create(Texture.prototype);
- DataTexture.prototype.constructor = DataTexture;
- DataTexture.prototype.isDataTexture = true;
- var _sphere$1 = new Sphere();
- var _vector$5 = new Vector3();
- function Frustum(p0, p1, p2, p3, p4, p5) {
- this.planes = [
- p0 !== void 0 ? p0 : new Plane(),
- p1 !== void 0 ? p1 : new Plane(),
- p2 !== void 0 ? p2 : new Plane(),
- p3 !== void 0 ? p3 : new Plane(),
- p4 !== void 0 ? p4 : new Plane(),
- p5 !== void 0 ? p5 : new Plane()
- ];
- }
- Object.assign(Frustum.prototype, {
- set: function(p0, p1, p2, p3, p4, p5) {
- var planes = this.planes;
- planes[0].copy(p0);
- planes[1].copy(p1);
- planes[2].copy(p2);
- planes[3].copy(p3);
- planes[4].copy(p4);
- planes[5].copy(p5);
- return this;
- },
- clone: function() {
- return new this.constructor().copy(this);
- },
- copy: function(frustum) {
- var planes = this.planes;
- for (var i2 = 0; i2 < 6; i2++) {
- planes[i2].copy(frustum.planes[i2]);
- }
- return this;
- },
- setFromProjectionMatrix: function(m) {
- var planes = this.planes;
- var me = m.elements;
- var me0 = me[0], me1 = me[1], me2 = me[2], me3 = me[3];
- var me4 = me[4], me5 = me[5], me6 = me[6], me7 = me[7];
- var me8 = me[8], me9 = me[9], me10 = me[10], me11 = me[11];
- var me12 = me[12], me13 = me[13], me14 = me[14], me15 = me[15];
- planes[0].setComponents(me3 - me0, me7 - me4, me11 - me8, me15 - me12).normalize();
- planes[1].setComponents(me3 + me0, me7 + me4, me11 + me8, me15 + me12).normalize();
- planes[2].setComponents(me3 + me1, me7 + me5, me11 + me9, me15 + me13).normalize();
- planes[3].setComponents(me3 - me1, me7 - me5, me11 - me9, me15 - me13).normalize();
- planes[4].setComponents(me3 - me2, me7 - me6, me11 - me10, me15 - me14).normalize();
- planes[5].setComponents(me3 + me2, me7 + me6, me11 + me10, me15 + me14).normalize();
- return this;
- },
- intersectsObject: function(object) {
- var geometry = object.geometry;
- if (geometry.boundingSphere === null)
- geometry.computeBoundingSphere();
- _sphere$1.copy(geometry.boundingSphere).applyMatrix4(object.matrixWorld);
- return this.intersectsSphere(_sphere$1);
- },
- intersectsSprite: function(sprite) {
- _sphere$1.center.set(0, 0, 0);
- _sphere$1.radius = 0.7071067811865476;
- _sphere$1.applyMatrix4(sprite.matrixWorld);
- return this.intersectsSphere(_sphere$1);
- },
- intersectsSphere: function(sphere) {
- var planes = this.planes;
- var center = sphere.center;
- var negRadius = -sphere.radius;
- for (var i2 = 0; i2 < 6; i2++) {
- var distance = planes[i2].distanceToPoint(center);
- if (distance < negRadius) {
- return false;
- }
- }
- return true;
- },
- intersectsBox: function(box) {
- var planes = this.planes;
- for (var i2 = 0; i2 < 6; i2++) {
- var plane = planes[i2];
- _vector$5.x = plane.normal.x > 0 ? box.max.x : box.min.x;
- _vector$5.y = plane.normal.y > 0 ? box.max.y : box.min.y;
- _vector$5.z = plane.normal.z > 0 ? box.max.z : box.min.z;
- if (plane.distanceToPoint(_vector$5) < 0) {
- return false;
- }
- }
- return true;
- },
- containsPoint: function(point) {
- var planes = this.planes;
- for (var i2 = 0; i2 < 6; i2++) {
- if (planes[i2].distanceToPoint(point) < 0) {
- return false;
- }
- }
- return true;
- }
- });
- var UniformsLib = {
- common: {
- diffuse: { value: new Color(15658734) },
- opacity: { value: 1 },
- map: { value: null },
- uvTransform: { value: new Matrix3() },
- uv2Transform: { value: new Matrix3() },
- alphaMap: { value: null }
- },
- specularmap: {
- specularMap: { value: null }
- },
- envmap: {
- envMap: { value: null },
- flipEnvMap: { value: -1 },
- reflectivity: { value: 1 },
- refractionRatio: { value: 0.98 },
- maxMipLevel: { value: 0 }
- },
- aomap: {
- aoMap: { value: null },
- aoMapIntensity: { value: 1 }
- },
- lightmap: {
- lightMap: { value: null },
- lightMapIntensity: { value: 1 }
- },
- emissivemap: {
- emissiveMap: { value: null }
- },
- bumpmap: {
- bumpMap: { value: null },
- bumpScale: { value: 1 }
- },
- normalmap: {
- normalMap: { value: null },
- normalScale: { value: new Vector2(1, 1) }
- },
- displacementmap: {
- displacementMap: { value: null },
- displacementScale: { value: 1 },
- displacementBias: { value: 0 }
- },
- roughnessmap: {
- roughnessMap: { value: null }
- },
- metalnessmap: {
- metalnessMap: { value: null }
- },
- gradientmap: {
- gradientMap: { value: null }
- },
- fog: {
- fogDensity: { value: 25e-5 },
- fogNear: { value: 1 },
- fogFar: { value: 2e3 },
- fogColor: { value: new Color(16777215) }
- },
- lights: {
- ambientLightColor: { value: [] },
- lightProbe: { value: [] },
- directionalLights: { value: [], properties: {
- direction: {},
- color: {},
- shadow: {},
- shadowBias: {},
- shadowRadius: {},
- shadowMapSize: {}
- } },
- directionalShadowMap: { value: [] },
- directionalShadowMatrix: { value: [] },
- spotLights: { value: [], properties: {
- color: {},
- position: {},
- direction: {},
- distance: {},
- coneCos: {},
- penumbraCos: {},
- decay: {},
- shadow: {},
- shadowBias: {},
- shadowRadius: {},
- shadowMapSize: {}
- } },
- spotShadowMap: { value: [] },
- spotShadowMatrix: { value: [] },
- pointLights: { value: [], properties: {
- color: {},
- position: {},
- decay: {},
- distance: {},
- shadow: {},
- shadowBias: {},
- shadowRadius: {},
- shadowMapSize: {},
- shadowCameraNear: {},
- shadowCameraFar: {}
- } },
- pointShadowMap: { value: [] },
- pointShadowMatrix: { value: [] },
- hemisphereLights: { value: [], properties: {
- direction: {},
- skyColor: {},
- groundColor: {}
- } },
- // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src
- rectAreaLights: { value: [], properties: {
- color: {},
- position: {},
- width: {},
- height: {}
- } }
- },
- points: {
- diffuse: { value: new Color(15658734) },
- opacity: { value: 1 },
- size: { value: 1 },
- scale: { value: 1 },
- map: { value: null },
- alphaMap: { value: null },
- uvTransform: { value: new Matrix3() }
- },
- sprite: {
- diffuse: { value: new Color(15658734) },
- opacity: { value: 1 },
- center: { value: new Vector2(0.5, 0.5) },
- rotation: { value: 0 },
- map: { value: null },
- alphaMap: { value: null },
- uvTransform: { value: new Matrix3() }
- }
- };
- function WebGLAnimation() {
- var context = null;
- var isAnimating = false;
- var animationLoop = null;
- function onAnimationFrame(time, frame) {
- if (isAnimating === false)
- return;
- animationLoop(time, frame);
- context.requestAnimationFrame(onAnimationFrame);
- }
- return {
- start: function() {
- if (isAnimating === true)
- return;
- if (animationLoop === null)
- return;
- context.requestAnimationFrame(onAnimationFrame);
- isAnimating = true;
- },
- stop: function() {
- isAnimating = false;
- },
- setAnimationLoop: function(callback) {
- animationLoop = callback;
- },
- setContext: function(value) {
- context = value;
- }
- };
- }
- function WebGLAttributes(gl, capabilities) {
- var isWebGL2 = capabilities.isWebGL2;
- var buffers = /* @__PURE__ */ new WeakMap();
- function createBuffer(attribute, bufferType) {
- var array = attribute.array;
- var usage = attribute.usage;
- var buffer = gl.createBuffer();
- gl.bindBuffer(bufferType, buffer);
- gl.bufferData(bufferType, array, usage);
- attribute.onUploadCallback();
- var type = 5126;
- if (array instanceof Float32Array) {
- type = 5126;
- } else if (array instanceof Float64Array) {
- console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.");
- } else if (array instanceof Uint16Array) {
- type = 5123;
- } else if (array instanceof Int16Array) {
- type = 5122;
- } else if (array instanceof Uint32Array) {
- type = 5125;
- } else if (array instanceof Int32Array) {
- type = 5124;
- } else if (array instanceof Int8Array) {
- type = 5120;
- } else if (array instanceof Uint8Array) {
- type = 5121;
- }
- return {
- buffer,
- type,
- bytesPerElement: array.BYTES_PER_ELEMENT,
- version: attribute.version
- };
- }
- function updateBuffer(buffer, attribute, bufferType) {
- var array = attribute.array;
- var updateRange = attribute.updateRange;
- gl.bindBuffer(bufferType, buffer);
- if (updateRange.count === -1) {
- gl.bufferSubData(bufferType, 0, array);
- } else {
- if (isWebGL2) {
- gl.bufferSubData(
- bufferType,
- updateRange.offset * array.BYTES_PER_ELEMENT,
- array,
- updateRange.offset,
- updateRange.count
- );
- } else {
- gl.bufferSubData(
- bufferType,
- updateRange.offset * array.BYTES_PER_ELEMENT,
- array.subarray(updateRange.offset, updateRange.offset + updateRange.count)
- );
- }
- updateRange.count = -1;
- }
- }
- function get(attribute) {
- if (attribute.isInterleavedBufferAttribute)
- attribute = attribute.data;
- return buffers.get(attribute);
- }
- function remove(attribute) {
- if (attribute.isInterleavedBufferAttribute)
- attribute = attribute.data;
- var data = buffers.get(attribute);
- if (data) {
- gl.deleteBuffer(data.buffer);
- buffers.delete(attribute);
- }
- }
- function update(attribute, bufferType) {
- if (attribute.isInterleavedBufferAttribute)
- attribute = attribute.data;
- var data = buffers.get(attribute);
- if (data === void 0) {
- buffers.set(attribute, createBuffer(attribute, bufferType));
- } else if (data.version < attribute.version) {
- updateBuffer(data.buffer, attribute, bufferType);
- data.version = attribute.version;
- }
- }
- return {
- get,
- remove,
- update
- };
- }
- function PlaneGeometry(width, height, widthSegments, heightSegments) {
- Geometry.call(this);
- this.type = "PlaneGeometry";
- this.parameters = {
- width,
- height,
- widthSegments,
- heightSegments
- };
- this.fromBufferGeometry(new PlaneBufferGeometry(width, height, widthSegments, heightSegments));
- this.mergeVertices();
- }
- PlaneGeometry.prototype = Object.create(Geometry.prototype);
- PlaneGeometry.prototype.constructor = PlaneGeometry;
- function PlaneBufferGeometry(width, height, widthSegments, heightSegments) {
- BufferGeometry.call(this);
- this.type = "PlaneBufferGeometry";
- this.parameters = {
- width,
- height,
- widthSegments,
- heightSegments
- };
- width = width || 1;
- height = height || 1;
- var width_half = width / 2;
- var height_half = height / 2;
- var gridX = Math.floor(widthSegments) || 1;
- var gridY = Math.floor(heightSegments) || 1;
- var gridX1 = gridX + 1;
- var gridY1 = gridY + 1;
- var segment_width = width / gridX;
- var segment_height = height / gridY;
- var ix, iy;
- var indices = [];
- var vertices = [];
- var normals = [];
- var uvs = [];
- for (iy = 0; iy < gridY1; iy++) {
- var y = iy * segment_height - height_half;
- for (ix = 0; ix < gridX1; ix++) {
- var x = ix * segment_width - width_half;
- vertices.push(x, -y, 0);
- normals.push(0, 0, 1);
- uvs.push(ix / gridX);
- uvs.push(1 - iy / gridY);
- }
- }
- for (iy = 0; iy < gridY; iy++) {
- for (ix = 0; ix < gridX; ix++) {
- var a = ix + gridX1 * iy;
- var b = ix + gridX1 * (iy + 1);
- var c = ix + 1 + gridX1 * (iy + 1);
- var d = ix + 1 + gridX1 * iy;
- indices.push(a, b, d);
- indices.push(b, c, d);
- }
- }
- this.setIndex(indices);
- this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
- this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
- }
- PlaneBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
- PlaneBufferGeometry.prototype.constructor = PlaneBufferGeometry;
- var alphamap_fragment = "#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif";
- var alphamap_pars_fragment = "#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif";
- var alphatest_fragment = "#ifdef ALPHATEST\n if ( diffuseColor.a < ALPHATEST ) discard;\n#endif";
- 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";
- var aomap_pars_fragment = "#ifdef USE_AOMAP\n uniform sampler2D aoMap;\n uniform float aoMapIntensity;\n#endif";
- var begin_vertex = "vec3 transformed = vec3( position );";
- var beginnormal_vertex = "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n vec3 objectTangent = vec3( tangent.xyz );\n#endif";
- 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";
- 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";
- 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";
- 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";
- var clipping_planes_pars_vertex = "#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n varying vec3 vViewPosition;\n#endif";
- var clipping_planes_vertex = "#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n vViewPosition = - mvPosition.xyz;\n#endif";
- var color_fragment = "#ifdef USE_COLOR\n diffuseColor.rgb *= vColor;\n#endif";
- var color_pars_fragment = "#ifdef USE_COLOR\n varying vec3 vColor;\n#endif";
- var color_pars_vertex = "#ifdef USE_COLOR\n varying vec3 vColor;\n#endif";
- var color_vertex = "#ifdef USE_COLOR\n vColor.xyz = color.xyz;\n#endif";
- 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}";
- 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";
- 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";
- var displacementmap_pars_vertex = "#ifdef USE_DISPLACEMENTMAP\n uniform sampler2D displacementMap;\n uniform float displacementScale;\n uniform float displacementBias;\n#endif";
- var displacementmap_vertex = "#ifdef USE_DISPLACEMENTMAP\n transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif";
- var emissivemap_fragment = "#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = texture2D( emissiveMap, vUv );\n emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n totalEmissiveRadiance *= emissiveColor.rgb;\n#endif";
- var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif";
- var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
- 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}";
- 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";
- 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";
- 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";
- 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";
- 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";
- var fog_vertex = "#ifdef USE_FOG\n fogDepth = -mvPosition.z;\n#endif";
- var fog_pars_vertex = "#ifdef USE_FOG\n varying float fogDepth;\n#endif";
- 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";
- 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";
- 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}";
- var lightmap_fragment = "#ifdef USE_LIGHTMAP\n vec4 lightMapTexel= texture2D( lightMap, vUv2 );\n reflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif";
- var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif";
- 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";
- 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";
- 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";
- var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
- 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)";
- var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
- 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)";
- 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";
- 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}";
- 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";
- 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";
- 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";
- 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";
- 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";
- 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";
- 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";
- var map_fragment = "#ifdef USE_MAP\n vec4 texelColor = texture2D( map, vUv );\n texelColor = mapTexelToLinear( texelColor );\n diffuseColor *= texelColor;\n#endif";
- var map_pars_fragment = "#ifdef USE_MAP\n uniform sampler2D map;\n#endif";
- 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";
- 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";
- var metalnessmap_fragment = "float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, vUv );\n metalnessFactor *= texelMetalness.b;\n#endif";
- var metalnessmap_pars_fragment = "#ifdef USE_METALNESSMAP\n uniform sampler2D metalnessMap;\n#endif";
- 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";
- 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";
- 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";
- 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;";
- 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";
- 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";
- var clearcoat_normal_fragment_begin = "#ifdef CLEARCOAT\n vec3 clearcoatNormal = geometryNormal;\n#endif";
- 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";
- var clearcoat_normalmap_pars_fragment = "#ifdef USE_CLEARCOAT_NORMALMAP\n uniform sampler2D clearcoatNormalMap;\n uniform vec2 clearcoatNormalScale;\n#endif";
- 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}";
- var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif";
- 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;";
- var dithering_fragment = "#ifdef DITHERING\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif";
- 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";
- var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, vUv );\n roughnessFactor *= texelRoughness.g;\n#endif";
- var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif";
- 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";
- 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";
- 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";
- 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}";
- 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";
- 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";
- 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";
- 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";
- 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";
- var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n uniform sampler2D specularMap;\n#endif";
- var tonemapping_fragment = "#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif";
- 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}";
- var uv_pars_fragment = "#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n varying vec2 vUv;\n#endif";
- 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";
- var uv_vertex = "#ifdef USE_UV\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif";
- var uv2_pars_fragment = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n varying vec2 vUv2;\n#endif";
- 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";
- var uv2_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif";
- 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";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- 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}";
- var ShaderChunk = {
- alphamap_fragment,
- alphamap_pars_fragment,
- alphatest_fragment,
- aomap_fragment,
- aomap_pars_fragment,
- begin_vertex,
- beginnormal_vertex,
- bsdfs,
- bumpmap_pars_fragment,
- clipping_planes_fragment,
- clipping_planes_pars_fragment,
- clipping_planes_pars_vertex,
- clipping_planes_vertex,
- color_fragment,
- color_pars_fragment,
- color_pars_vertex,
- color_vertex,
- common,
- cube_uv_reflection_fragment,
- defaultnormal_vertex,
- displacementmap_pars_vertex,
- displacementmap_vertex,
- emissivemap_fragment,
- emissivemap_pars_fragment,
- encodings_fragment,
- encodings_pars_fragment,
- envmap_fragment,
- envmap_common_pars_fragment,
- envmap_pars_fragment,
- envmap_pars_vertex,
- envmap_physical_pars_fragment,
- envmap_vertex,
- fog_vertex,
- fog_pars_vertex,
- fog_fragment,
- fog_pars_fragment,
- gradientmap_pars_fragment,
- lightmap_fragment,
- lightmap_pars_fragment,
- lights_lambert_vertex,
- lights_pars_begin,
- lights_toon_fragment,
- lights_toon_pars_fragment,
- lights_phong_fragment,
- lights_phong_pars_fragment,
- lights_physical_fragment,
- lights_physical_pars_fragment,
- lights_fragment_begin,
- lights_fragment_maps,
- lights_fragment_end,
- logdepthbuf_fragment,
- logdepthbuf_pars_fragment,
- logdepthbuf_pars_vertex,
- logdepthbuf_vertex,
- map_fragment,
- map_pars_fragment,
- map_particle_fragment,
- map_particle_pars_fragment,
- metalnessmap_fragment,
- metalnessmap_pars_fragment,
- morphnormal_vertex,
- morphtarget_pars_vertex,
- morphtarget_vertex,
- normal_fragment_begin,
- normal_fragment_maps,
- normalmap_pars_fragment,
- clearcoat_normal_fragment_begin,
- clearcoat_normal_fragment_maps,
- clearcoat_normalmap_pars_fragment,
- packing,
- premultiplied_alpha_fragment,
- project_vertex,
- dithering_fragment,
- dithering_pars_fragment,
- roughnessmap_fragment,
- roughnessmap_pars_fragment,
- shadowmap_pars_fragment,
- shadowmap_pars_vertex,
- shadowmap_vertex,
- shadowmask_pars_fragment,
- skinbase_vertex,
- skinning_pars_vertex,
- skinning_vertex,
- skinnormal_vertex,
- specularmap_fragment,
- specularmap_pars_fragment,
- tonemapping_fragment,
- tonemapping_pars_fragment,
- uv_pars_fragment,
- uv_pars_vertex,
- uv_vertex,
- uv2_pars_fragment,
- uv2_pars_vertex,
- uv2_vertex,
- worldpos_vertex,
- background_frag,
- background_vert,
- cube_frag,
- cube_vert,
- depth_frag,
- depth_vert,
- distanceRGBA_frag,
- distanceRGBA_vert,
- equirect_frag,
- equirect_vert,
- linedashed_frag,
- linedashed_vert,
- meshbasic_frag,
- meshbasic_vert,
- meshlambert_frag,
- meshlambert_vert,
- meshmatcap_frag,
- meshmatcap_vert,
- meshtoon_frag,
- meshtoon_vert,
- meshphong_frag,
- meshphong_vert,
- meshphysical_frag,
- meshphysical_vert,
- normal_frag,
- normal_vert,
- points_frag,
- points_vert,
- shadow_frag,
- shadow_vert,
- sprite_frag,
- sprite_vert
- };
- var ShaderLib = {
- basic: {
- uniforms: mergeUniforms([
- UniformsLib.common,
- UniformsLib.specularmap,
- UniformsLib.envmap,
- UniformsLib.aomap,
- UniformsLib.lightmap,
- UniformsLib.fog
- ]),
- vertexShader: ShaderChunk.meshbasic_vert,
- fragmentShader: ShaderChunk.meshbasic_frag
- },
- lambert: {
- uniforms: mergeUniforms([
- UniformsLib.common,
- UniformsLib.specularmap,
- UniformsLib.envmap,
- UniformsLib.aomap,
- UniformsLib.lightmap,
- UniformsLib.emissivemap,
- UniformsLib.fog,
- UniformsLib.lights,
- {
- emissive: { value: new Color(0) }
- }
- ]),
- vertexShader: ShaderChunk.meshlambert_vert,
- fragmentShader: ShaderChunk.meshlambert_frag
- },
- phong: {
- uniforms: mergeUniforms([
- UniformsLib.common,
- UniformsLib.specularmap,
- UniformsLib.envmap,
- UniformsLib.aomap,
- UniformsLib.lightmap,
- UniformsLib.emissivemap,
- UniformsLib.bumpmap,
- UniformsLib.normalmap,
- UniformsLib.displacementmap,
- UniformsLib.fog,
- UniformsLib.lights,
- {
- emissive: { value: new Color(0) },
- specular: { value: new Color(1118481) },
- shininess: { value: 30 }
- }
- ]),
- vertexShader: ShaderChunk.meshphong_vert,
- fragmentShader: ShaderChunk.meshphong_frag
- },
- standard: {
- uniforms: mergeUniforms([
- UniformsLib.common,
- UniformsLib.envmap,
- UniformsLib.aomap,
- UniformsLib.lightmap,
- UniformsLib.emissivemap,
- UniformsLib.bumpmap,
- UniformsLib.normalmap,
- UniformsLib.displacementmap,
- UniformsLib.roughnessmap,
- UniformsLib.metalnessmap,
- UniformsLib.fog,
- UniformsLib.lights,
- {
- emissive: { value: new Color(0) },
- roughness: { value: 0.5 },
- metalness: { value: 0.5 },
- envMapIntensity: { value: 1 }
- // temporary
- }
- ]),
- vertexShader: ShaderChunk.meshphysical_vert,
- fragmentShader: ShaderChunk.meshphysical_frag
- },
- toon: {
- uniforms: mergeUniforms([
- UniformsLib.common,
- UniformsLib.specularmap,
- UniformsLib.aomap,
- UniformsLib.lightmap,
- UniformsLib.emissivemap,
- UniformsLib.bumpmap,
- UniformsLib.normalmap,
- UniformsLib.displacementmap,
- UniformsLib.gradientmap,
- UniformsLib.fog,
- UniformsLib.lights,
- {
- emissive: { value: new Color(0) },
- specular: { value: new Color(1118481) },
- shininess: { value: 30 }
- }
- ]),
- vertexShader: ShaderChunk.meshtoon_vert,
- fragmentShader: ShaderChunk.meshtoon_frag
- },
- matcap: {
- uniforms: mergeUniforms([
- UniformsLib.common,
- UniformsLib.bumpmap,
- UniformsLib.normalmap,
- UniformsLib.displacementmap,
- UniformsLib.fog,
- {
- matcap: { value: null }
- }
- ]),
- vertexShader: ShaderChunk.meshmatcap_vert,
- fragmentShader: ShaderChunk.meshmatcap_frag
- },
- points: {
- uniforms: mergeUniforms([
- UniformsLib.points,
- UniformsLib.fog
- ]),
- vertexShader: ShaderChunk.points_vert,
- fragmentShader: ShaderChunk.points_frag
- },
- dashed: {
- uniforms: mergeUniforms([
- UniformsLib.common,
- UniformsLib.fog,
- {
- scale: { value: 1 },
- dashSize: { value: 1 },
- totalSize: { value: 2 }
- }
- ]),
- vertexShader: ShaderChunk.linedashed_vert,
- fragmentShader: ShaderChunk.linedashed_frag
- },
- depth: {
- uniforms: mergeUniforms([
- UniformsLib.common,
- UniformsLib.displacementmap
- ]),
- vertexShader: ShaderChunk.depth_vert,
- fragmentShader: ShaderChunk.depth_frag
- },
- normal: {
- uniforms: mergeUniforms([
- UniformsLib.common,
- UniformsLib.bumpmap,
- UniformsLib.normalmap,
- UniformsLib.displacementmap,
- {
- opacity: { value: 1 }
- }
- ]),
- vertexShader: ShaderChunk.normal_vert,
- fragmentShader: ShaderChunk.normal_frag
- },
- sprite: {
- uniforms: mergeUniforms([
- UniformsLib.sprite,
- UniformsLib.fog
- ]),
- vertexShader: ShaderChunk.sprite_vert,
- fragmentShader: ShaderChunk.sprite_frag
- },
- background: {
- uniforms: {
- uvTransform: { value: new Matrix3() },
- t2D: { value: null }
- },
- vertexShader: ShaderChunk.background_vert,
- fragmentShader: ShaderChunk.background_frag
- },
- /* -------------------------------------------------------------------------
- // Cube map shader
- ------------------------------------------------------------------------- */
- cube: {
- uniforms: mergeUniforms([
- UniformsLib.envmap,
- {
- opacity: { value: 1 }
- }
- ]),
- vertexShader: ShaderChunk.cube_vert,
- fragmentShader: ShaderChunk.cube_frag
- },
- equirect: {
- uniforms: {
- tEquirect: { value: null }
- },
- vertexShader: ShaderChunk.equirect_vert,
- fragmentShader: ShaderChunk.equirect_frag
- },
- distanceRGBA: {
- uniforms: mergeUniforms([
- UniformsLib.common,
- UniformsLib.displacementmap,
- {
- referencePosition: { value: new Vector3() },
- nearDistance: { value: 1 },
- farDistance: { value: 1e3 }
- }
- ]),
- vertexShader: ShaderChunk.distanceRGBA_vert,
- fragmentShader: ShaderChunk.distanceRGBA_frag
- },
- shadow: {
- uniforms: mergeUniforms([
- UniformsLib.lights,
- UniformsLib.fog,
- {
- color: { value: new Color(0) },
- opacity: { value: 1 }
- }
- ]),
- vertexShader: ShaderChunk.shadow_vert,
- fragmentShader: ShaderChunk.shadow_frag
- }
- };
- ShaderLib.physical = {
- uniforms: mergeUniforms([
- ShaderLib.standard.uniforms,
- {
- transparency: { value: 0 },
- clearcoat: { value: 0 },
- clearcoatRoughness: { value: 0 },
- sheen: { value: new Color(0) },
- clearcoatNormalScale: { value: new Vector2(1, 1) },
- clearcoatNormalMap: { value: null }
- }
- ]),
- vertexShader: ShaderChunk.meshphysical_vert,
- fragmentShader: ShaderChunk.meshphysical_frag
- };
- function WebGLBackground(renderer, state, objects, premultipliedAlpha) {
- var clearColor = new Color(0);
- var clearAlpha = 0;
- var planeMesh;
- var boxMesh;
- var currentBackground = null;
- var currentBackgroundVersion = 0;
- var currentTonemapping = null;
- function render(renderList, scene, camera, forceClear) {
- var background = scene.background;
- var xr = renderer.xr;
- var session = xr.getSession && xr.getSession();
- if (session && session.environmentBlendMode === "additive") {
- background = null;
- }
- if (background === null) {
- setClear(clearColor, clearAlpha);
- } else if (background && background.isColor) {
- setClear(background, 1);
- forceClear = true;
- }
- if (renderer.autoClear || forceClear) {
- renderer.clear(renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil);
- }
- if (background && (background.isCubeTexture || background.isWebGLCubeRenderTarget || background.mapping === CubeUVReflectionMapping)) {
- if (boxMesh === void 0) {
- boxMesh = new Mesh(
- new BoxBufferGeometry(1, 1, 1),
- new ShaderMaterial({
- type: "BackgroundCubeMaterial",
- uniforms: cloneUniforms(ShaderLib.cube.uniforms),
- vertexShader: ShaderLib.cube.vertexShader,
- fragmentShader: ShaderLib.cube.fragmentShader,
- side: BackSide,
- depthTest: false,
- depthWrite: false,
- fog: false
- })
- );
- boxMesh.geometry.deleteAttribute("normal");
- boxMesh.geometry.deleteAttribute("uv");
- boxMesh.onBeforeRender = function(renderer2, scene2, camera2) {
- this.matrixWorld.copyPosition(camera2.matrixWorld);
- };
- Object.defineProperty(boxMesh.material, "envMap", {
- get: function() {
- return this.uniforms.envMap.value;
- }
- });
- objects.update(boxMesh);
- }
- var texture = background.isWebGLCubeRenderTarget ? background.texture : background;
- boxMesh.material.uniforms.envMap.value = texture;
- boxMesh.material.uniforms.flipEnvMap.value = texture.isCubeTexture ? -1 : 1;
- if (currentBackground !== background || currentBackgroundVersion !== texture.version || currentTonemapping !== renderer.toneMapping) {
- boxMesh.material.needsUpdate = true;
- currentBackground = background;
- currentBackgroundVersion = texture.version;
- currentTonemapping = renderer.toneMapping;
- }
- renderList.unshift(boxMesh, boxMesh.geometry, boxMesh.material, 0, 0, null);
- } else if (background && background.isTexture) {
- if (planeMesh === void 0) {
- planeMesh = new Mesh(
- new PlaneBufferGeometry(2, 2),
- new ShaderMaterial({
- type: "BackgroundMaterial",
- uniforms: cloneUniforms(ShaderLib.background.uniforms),
- vertexShader: ShaderLib.background.vertexShader,
- fragmentShader: ShaderLib.background.fragmentShader,
- side: FrontSide,
- depthTest: false,
- depthWrite: false,
- fog: false
- })
- );
- planeMesh.geometry.deleteAttribute("normal");
- Object.defineProperty(planeMesh.material, "map", {
- get: function() {
- return this.uniforms.t2D.value;
- }
- });
- objects.update(planeMesh);
- }
- planeMesh.material.uniforms.t2D.value = background;
- if (background.matrixAutoUpdate === true) {
- background.updateMatrix();
- }
- planeMesh.material.uniforms.uvTransform.value.copy(background.matrix);
- if (currentBackground !== background || currentBackgroundVersion !== background.version || currentTonemapping !== renderer.toneMapping) {
- planeMesh.material.needsUpdate = true;
- currentBackground = background;
- currentBackgroundVersion = background.version;
- currentTonemapping = renderer.toneMapping;
- }
- renderList.unshift(planeMesh, planeMesh.geometry, planeMesh.material, 0, 0, null);
- }
- }
- function setClear(color, alpha) {
- state.buffers.color.setClear(color.r, color.g, color.b, alpha, premultipliedAlpha);
- }
- return {
- getClearColor: function() {
- return clearColor;
- },
- setClearColor: function(color, alpha) {
- clearColor.set(color);
- clearAlpha = alpha !== void 0 ? alpha : 1;
- setClear(clearColor, clearAlpha);
- },
- getClearAlpha: function() {
- return clearAlpha;
- },
- setClearAlpha: function(alpha) {
- clearAlpha = alpha;
- setClear(clearColor, clearAlpha);
- },
- render
- };
- }
- function WebGLBufferRenderer(gl, extensions, info, capabilities) {
- var isWebGL2 = capabilities.isWebGL2;
- var mode;
- function setMode(value) {
- mode = value;
- }
- function render(start, count) {
- gl.drawArrays(mode, start, count);
- info.update(count, mode);
- }
- function renderInstances(geometry, start, count, primcount) {
- if (primcount === 0)
- return;
- var extension, methodName;
- if (isWebGL2) {
- extension = gl;
- methodName = "drawArraysInstanced";
- } else {
- extension = extensions.get("ANGLE_instanced_arrays");
- methodName = "drawArraysInstancedANGLE";
- if (extension === null) {
- console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");
- return;
- }
- }
- extension[methodName](mode, start, count, primcount);
- info.update(count, mode, primcount);
- }
- this.setMode = setMode;
- this.render = render;
- this.renderInstances = renderInstances;
- }
- function WebGLCapabilities(gl, extensions, parameters) {
- var maxAnisotropy;
- function getMaxAnisotropy() {
- if (maxAnisotropy !== void 0)
- return maxAnisotropy;
- var extension = extensions.get("EXT_texture_filter_anisotropic");
- if (extension !== null) {
- maxAnisotropy = gl.getParameter(extension.MAX_TEXTURE_MAX_ANISOTROPY_EXT);
- } else {
- maxAnisotropy = 0;
- }
- return maxAnisotropy;
- }
- function getMaxPrecision(precision2) {
- if (precision2 === "highp") {
- if (gl.getShaderPrecisionFormat(35633, 36338).precision > 0 && gl.getShaderPrecisionFormat(35632, 36338).precision > 0) {
- return "highp";
- }
- precision2 = "mediump";
- }
- if (precision2 === "mediump") {
- if (gl.getShaderPrecisionFormat(35633, 36337).precision > 0 && gl.getShaderPrecisionFormat(35632, 36337).precision > 0) {
- return "mediump";
- }
- }
- return "lowp";
- }
- var isWebGL2 = typeof WebGL2RenderingContext !== "undefined" && gl instanceof WebGL2RenderingContext || typeof WebGL2ComputeRenderingContext !== "undefined" && gl instanceof WebGL2ComputeRenderingContext;
- var precision = parameters.precision !== void 0 ? parameters.precision : "highp";
- var maxPrecision = getMaxPrecision(precision);
- if (maxPrecision !== precision) {
- console.warn("THREE.WebGLRenderer:", precision, "not supported, using", maxPrecision, "instead.");
- precision = maxPrecision;
- }
- var logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
- var maxTextures = gl.getParameter(34930);
- var maxVertexTextures = gl.getParameter(35660);
- var maxTextureSize = gl.getParameter(3379);
- var maxCubemapSize = gl.getParameter(34076);
- var maxAttributes = gl.getParameter(34921);
- var maxVertexUniforms = gl.getParameter(36347);
- var maxVaryings = gl.getParameter(36348);
- var maxFragmentUniforms = gl.getParameter(36349);
- var vertexTextures = maxVertexTextures > 0;
- var floatFragmentTextures = isWebGL2 || !!extensions.get("OES_texture_float");
- var floatVertexTextures = vertexTextures && floatFragmentTextures;
- var maxSamples = isWebGL2 ? gl.getParameter(36183) : 0;
- return {
- isWebGL2,
- getMaxAnisotropy,
- getMaxPrecision,
- precision,
- logarithmicDepthBuffer,
- maxTextures,
- maxVertexTextures,
- maxTextureSize,
- maxCubemapSize,
- maxAttributes,
- maxVertexUniforms,
- maxVaryings,
- maxFragmentUniforms,
- vertexTextures,
- floatFragmentTextures,
- floatVertexTextures,
- maxSamples
- };
- }
- function WebGLClipping() {
- var scope = this, globalState = null, numGlobalPlanes = 0, localClippingEnabled = false, renderingShadows = false, plane = new Plane(), viewNormalMatrix = new Matrix3(), uniform = { value: null, needsUpdate: false };
- this.uniform = uniform;
- this.numPlanes = 0;
- this.numIntersection = 0;
- this.init = function(planes, enableLocalClipping, camera) {
- var enabled = planes.length !== 0 || enableLocalClipping || // enable state of previous frame - the clipping code has to
- // run another frame in order to reset the state:
- numGlobalPlanes !== 0 || localClippingEnabled;
- localClippingEnabled = enableLocalClipping;
- globalState = projectPlanes(planes, camera, 0);
- numGlobalPlanes = planes.length;
- return enabled;
- };
- this.beginShadows = function() {
- renderingShadows = true;
- projectPlanes(null);
- };
- this.endShadows = function() {
- renderingShadows = false;
- resetGlobalState();
- };
- this.setState = function(planes, clipIntersection, clipShadows, camera, cache, fromCache) {
- if (!localClippingEnabled || planes === null || planes.length === 0 || renderingShadows && !clipShadows) {
- if (renderingShadows) {
- projectPlanes(null);
- } else {
- resetGlobalState();
- }
- } else {
- var nGlobal = renderingShadows ? 0 : numGlobalPlanes, lGlobal = nGlobal * 4, dstArray = cache.clippingState || null;
- uniform.value = dstArray;
- dstArray = projectPlanes(planes, camera, lGlobal, fromCache);
- for (var i2 = 0; i2 !== lGlobal; ++i2) {
- dstArray[i2] = globalState[i2];
- }
- cache.clippingState = dstArray;
- this.numIntersection = clipIntersection ? this.numPlanes : 0;
- this.numPlanes += nGlobal;
- }
- };
- function resetGlobalState() {
- if (uniform.value !== globalState) {
- uniform.value = globalState;
- uniform.needsUpdate = numGlobalPlanes > 0;
- }
- scope.numPlanes = numGlobalPlanes;
- scope.numIntersection = 0;
- }
- function projectPlanes(planes, camera, dstOffset, skipTransform) {
- var nPlanes = planes !== null ? planes.length : 0, dstArray = null;
- if (nPlanes !== 0) {
- dstArray = uniform.value;
- if (skipTransform !== true || dstArray === null) {
- var flatSize = dstOffset + nPlanes * 4, viewMatrix = camera.matrixWorldInverse;
- viewNormalMatrix.getNormalMatrix(viewMatrix);
- if (dstArray === null || dstArray.length < flatSize) {
- dstArray = new Float32Array(flatSize);
- }
- for (var i2 = 0, i4 = dstOffset; i2 !== nPlanes; ++i2, i4 += 4) {
- plane.copy(planes[i2]).applyMatrix4(viewMatrix, viewNormalMatrix);
- plane.normal.toArray(dstArray, i4);
- dstArray[i4 + 3] = plane.constant;
- }
- }
- uniform.value = dstArray;
- uniform.needsUpdate = true;
- }
- scope.numPlanes = nPlanes;
- return dstArray;
- }
- }
- function WebGLExtensions(gl) {
- var extensions = {};
- return {
- get: function(name) {
- if (extensions[name] !== void 0) {
- return extensions[name];
- }
- var extension;
- switch (name) {
- case "WEBGL_depth_texture":
- extension = gl.getExtension("WEBGL_depth_texture") || gl.getExtension("MOZ_WEBGL_depth_texture") || gl.getExtension("WEBKIT_WEBGL_depth_texture");
- break;
- case "EXT_texture_filter_anisotropic":
- extension = gl.getExtension("EXT_texture_filter_anisotropic") || gl.getExtension("MOZ_EXT_texture_filter_anisotropic") || gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic");
- break;
- case "WEBGL_compressed_texture_s3tc":
- extension = gl.getExtension("WEBGL_compressed_texture_s3tc") || gl.getExtension("MOZ_WEBGL_compressed_texture_s3tc") || gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");
- break;
- case "WEBGL_compressed_texture_pvrtc":
- extension = gl.getExtension("WEBGL_compressed_texture_pvrtc") || gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");
- break;
- default:
- extension = gl.getExtension(name);
- }
- if (extension === null) {
- console.warn("THREE.WebGLRenderer: " + name + " extension not supported.");
- }
- extensions[name] = extension;
- return extension;
- }
- };
- }
- function WebGLGeometries(gl, attributes, info) {
- var geometries = /* @__PURE__ */ new WeakMap();
- var wireframeAttributes = /* @__PURE__ */ new WeakMap();
- function onGeometryDispose(event) {
- var geometry = event.target;
- var buffergeometry = geometries.get(geometry);
- if (buffergeometry.index !== null) {
- attributes.remove(buffergeometry.index);
- }
- for (var name in buffergeometry.attributes) {
- attributes.remove(buffergeometry.attributes[name]);
- }
- geometry.removeEventListener("dispose", onGeometryDispose);
- geometries.delete(geometry);
- var attribute = wireframeAttributes.get(buffergeometry);
- if (attribute) {
- attributes.remove(attribute);
- wireframeAttributes.delete(buffergeometry);
- }
- info.memory.geometries--;
- }
- function get(object, geometry) {
- var buffergeometry = geometries.get(geometry);
- if (buffergeometry)
- return buffergeometry;
- geometry.addEventListener("dispose", onGeometryDispose);
- if (geometry.isBufferGeometry) {
- buffergeometry = geometry;
- } else if (geometry.isGeometry) {
- if (geometry._bufferGeometry === void 0) {
- geometry._bufferGeometry = new BufferGeometry().setFromObject(object);
- }
- buffergeometry = geometry._bufferGeometry;
- }
- geometries.set(geometry, buffergeometry);
- info.memory.geometries++;
- return buffergeometry;
- }
- function update(geometry) {
- var index = geometry.index;
- var geometryAttributes = geometry.attributes;
- if (index !== null) {
- attributes.update(index, 34963);
- }
- for (var name in geometryAttributes) {
- attributes.update(geometryAttributes[name], 34962);
- }
- var morphAttributes = geometry.morphAttributes;
- for (var name in morphAttributes) {
- var array = morphAttributes[name];
- for (var i2 = 0, l = array.length; i2 < l; i2++) {
- attributes.update(array[i2], 34962);
- }
- }
- }
- function updateWireframeAttribute(geometry) {
- var indices = [];
- var geometryIndex = geometry.index;
- var geometryPosition = geometry.attributes.position;
- var version = 0;
- if (geometryIndex !== null) {
- var array = geometryIndex.array;
- version = geometryIndex.version;
- for (var i2 = 0, l = array.length; i2 < l; i2 += 3) {
- var a = array[i2 + 0];
- var b = array[i2 + 1];
- var c = array[i2 + 2];
- indices.push(a, b, b, c, c, a);
- }
- } else {
- var array = geometryPosition.array;
- version = geometryPosition.version;
- for (var i2 = 0, l = array.length / 3 - 1; i2 < l; i2 += 3) {
- var a = i2 + 0;
- var b = i2 + 1;
- var c = i2 + 2;
- indices.push(a, b, b, c, c, a);
- }
- }
- var attribute = new (arrayMax(indices) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute)(indices, 1);
- attribute.version = version;
- attributes.update(attribute, 34963);
- var previousAttribute = wireframeAttributes.get(geometry);
- if (previousAttribute)
- attributes.remove(previousAttribute);
- wireframeAttributes.set(geometry, attribute);
- }
- function getWireframeAttribute(geometry) {
- var currentAttribute = wireframeAttributes.get(geometry);
- if (currentAttribute) {
- var geometryIndex = geometry.index;
- if (geometryIndex !== null) {
- if (currentAttribute.version < geometryIndex.version) {
- updateWireframeAttribute(geometry);
- }
- }
- } else {
- updateWireframeAttribute(geometry);
- }
- return wireframeAttributes.get(geometry);
- }
- return {
- get,
- update,
- getWireframeAttribute
- };
- }
- function WebGLIndexedBufferRenderer(gl, extensions, info, capabilities) {
- var isWebGL2 = capabilities.isWebGL2;
- var mode;
- function setMode(value) {
- mode = value;
- }
- var type, bytesPerElement;
- function setIndex(value) {
- type = value.type;
- bytesPerElement = value.bytesPerElement;
- }
- function render(start, count) {
- gl.drawElements(mode, count, type, start * bytesPerElement);
- info.update(count, mode);
- }
- function renderInstances(geometry, start, count, primcount) {
- if (primcount === 0)
- return;
- var extension, methodName;
- if (isWebGL2) {
- extension = gl;
- methodName = "drawElementsInstanced";
- } else {
- extension = extensions.get("ANGLE_instanced_arrays");
- methodName = "drawElementsInstancedANGLE";
- if (extension === null) {
- console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");
- return;
- }
- }
- extension[methodName](mode, count, type, start * bytesPerElement, primcount);
- info.update(count, mode, primcount);
- }
- this.setMode = setMode;
- this.setIndex = setIndex;
- this.render = render;
- this.renderInstances = renderInstances;
- }
- function WebGLInfo(gl) {
- var memory = {
- geometries: 0,
- textures: 0
- };
- var render = {
- frame: 0,
- calls: 0,
- triangles: 0,
- points: 0,
- lines: 0
- };
- function update(count, mode, instanceCount) {
- instanceCount = instanceCount || 1;
- render.calls++;
- switch (mode) {
- case 4:
- render.triangles += instanceCount * (count / 3);
- break;
- case 1:
- render.lines += instanceCount * (count / 2);
- break;
- case 3:
- render.lines += instanceCount * (count - 1);
- break;
- case 2:
- render.lines += instanceCount * count;
- break;
- case 0:
- render.points += instanceCount * count;
- break;
- default:
- console.error("THREE.WebGLInfo: Unknown draw mode:", mode);
- break;
- }
- }
- function reset() {
- render.frame++;
- render.calls = 0;
- render.triangles = 0;
- render.points = 0;
- render.lines = 0;
- }
- return {
- memory,
- render,
- programs: null,
- autoReset: true,
- reset,
- update
- };
- }
- function absNumericalSort(a, b) {
- return Math.abs(b[1]) - Math.abs(a[1]);
- }
- function WebGLMorphtargets(gl) {
- var influencesList = {};
- var morphInfluences = new Float32Array(8);
- function update(object, geometry, material, program) {
- var objectInfluences = object.morphTargetInfluences;
- var length = objectInfluences === void 0 ? 0 : objectInfluences.length;
- var influences = influencesList[geometry.id];
- if (influences === void 0) {
- influences = [];
- for (var i2 = 0; i2 < length; i2++) {
- influences[i2] = [i2, 0];
- }
- influencesList[geometry.id] = influences;
- }
- var morphTargets = material.morphTargets && geometry.morphAttributes.position;
- var morphNormals = material.morphNormals && geometry.morphAttributes.normal;
- for (var i2 = 0; i2 < length; i2++) {
- var influence = influences[i2];
- if (influence[1] !== 0) {
- if (morphTargets)
- geometry.deleteAttribute("morphTarget" + i2);
- if (morphNormals)
- geometry.deleteAttribute("morphNormal" + i2);
- }
- }
- for (var i2 = 0; i2 < length; i2++) {
- var influence = influences[i2];
- influence[0] = i2;
- influence[1] = objectInfluences[i2];
- }
- influences.sort(absNumericalSort);
- var morphInfluencesSum = 0;
- for (var i2 = 0; i2 < 8; i2++) {
- var influence = influences[i2];
- if (influence) {
- var index = influence[0];
- var value = influence[1];
- if (value) {
- if (morphTargets)
- geometry.setAttribute("morphTarget" + i2, morphTargets[index]);
- if (morphNormals)
- geometry.setAttribute("morphNormal" + i2, morphNormals[index]);
- morphInfluences[i2] = value;
- morphInfluencesSum += value;
- continue;
- }
- }
- morphInfluences[i2] = 0;
- }
- var morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;
- program.getUniforms().setValue(gl, "morphTargetBaseInfluence", morphBaseInfluence);
- program.getUniforms().setValue(gl, "morphTargetInfluences", morphInfluences);
- }
- return {
- update
- };
- }
- function WebGLObjects(gl, geometries, attributes, info) {
- var updateList = {};
- function update(object) {
- var frame = info.render.frame;
- var geometry = object.geometry;
- var buffergeometry = geometries.get(object, geometry);
- if (updateList[buffergeometry.id] !== frame) {
- if (geometry.isGeometry) {
- buffergeometry.updateFromObject(object);
- }
- geometries.update(buffergeometry);
- updateList[buffergeometry.id] = frame;
- }
- if (object.isInstancedMesh) {
- attributes.update(object.instanceMatrix, 34962);
- }
- return buffergeometry;
- }
- function dispose() {
- updateList = {};
- }
- return {
- update,
- dispose
- };
- }
- function CubeTexture(images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding) {
- images = images !== void 0 ? images : [];
- mapping = mapping !== void 0 ? mapping : CubeReflectionMapping;
- format = format !== void 0 ? format : RGBFormat;
- Texture.call(this, images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);
- this.flipY = false;
- }
- CubeTexture.prototype = Object.create(Texture.prototype);
- CubeTexture.prototype.constructor = CubeTexture;
- CubeTexture.prototype.isCubeTexture = true;
- Object.defineProperty(CubeTexture.prototype, "images", {
- get: function() {
- return this.image;
- },
- set: function(value) {
- this.image = value;
- }
- });
- function DataTexture2DArray(data, width, height, depth) {
- Texture.call(this, null);
- this.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 };
- this.magFilter = NearestFilter;
- this.minFilter = NearestFilter;
- this.wrapR = ClampToEdgeWrapping;
- this.generateMipmaps = false;
- this.flipY = false;
- this.needsUpdate = true;
- }
- DataTexture2DArray.prototype = Object.create(Texture.prototype);
- DataTexture2DArray.prototype.constructor = DataTexture2DArray;
- DataTexture2DArray.prototype.isDataTexture2DArray = true;
- function DataTexture3D(data, width, height, depth) {
- Texture.call(this, null);
- this.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 };
- this.magFilter = NearestFilter;
- this.minFilter = NearestFilter;
- this.wrapR = ClampToEdgeWrapping;
- this.generateMipmaps = false;
- this.flipY = false;
- this.needsUpdate = true;
- }
- DataTexture3D.prototype = Object.create(Texture.prototype);
- DataTexture3D.prototype.constructor = DataTexture3D;
- DataTexture3D.prototype.isDataTexture3D = true;
- var emptyTexture = new Texture();
- var emptyTexture2dArray = new DataTexture2DArray();
- var emptyTexture3d = new DataTexture3D();
- var emptyCubeTexture = new CubeTexture();
- var arrayCacheF32 = [];
- var arrayCacheI32 = [];
- var mat4array = new Float32Array(16);
- var mat3array = new Float32Array(9);
- var mat2array = new Float32Array(4);
- function flatten(array, nBlocks, blockSize) {
- var firstElem = array[0];
- if (firstElem <= 0 || firstElem > 0)
- return array;
- var n = nBlocks * blockSize, r = arrayCacheF32[n];
- if (r === void 0) {
- r = new Float32Array(n);
- arrayCacheF32[n] = r;
- }
- if (nBlocks !== 0) {
- firstElem.toArray(r, 0);
- for (var i2 = 1, offset = 0; i2 !== nBlocks; ++i2) {
- offset += blockSize;
- array[i2].toArray(r, offset);
- }
- }
- return r;
- }
- function arraysEqual(a, b) {
- if (a.length !== b.length)
- return false;
- for (var i2 = 0, l = a.length; i2 < l; i2++) {
- if (a[i2] !== b[i2])
- return false;
- }
- return true;
- }
- function copyArray(a, b) {
- for (var i2 = 0, l = b.length; i2 < l; i2++) {
- a[i2] = b[i2];
- }
- }
- function allocTexUnits(textures, n) {
- var r = arrayCacheI32[n];
- if (r === void 0) {
- r = new Int32Array(n);
- arrayCacheI32[n] = r;
- }
- for (var i2 = 0; i2 !== n; ++i2)
- r[i2] = textures.allocateTextureUnit();
- return r;
- }
- function setValueV1f(gl, v) {
- var cache = this.cache;
- if (cache[0] === v)
- return;
- gl.uniform1f(this.addr, v);
- cache[0] = v;
- }
- function setValueV2f(gl, v) {
- var cache = this.cache;
- if (v.x !== void 0) {
- if (cache[0] !== v.x || cache[1] !== v.y) {
- gl.uniform2f(this.addr, v.x, v.y);
- cache[0] = v.x;
- cache[1] = v.y;
- }
- } else {
- if (arraysEqual(cache, v))
- return;
- gl.uniform2fv(this.addr, v);
- copyArray(cache, v);
- }
- }
- function setValueV3f(gl, v) {
- var cache = this.cache;
- if (v.x !== void 0) {
- if (cache[0] !== v.x || cache[1] !== v.y || cache[2] !== v.z) {
- gl.uniform3f(this.addr, v.x, v.y, v.z);
- cache[0] = v.x;
- cache[1] = v.y;
- cache[2] = v.z;
- }
- } else if (v.r !== void 0) {
- if (cache[0] !== v.r || cache[1] !== v.g || cache[2] !== v.b) {
- gl.uniform3f(this.addr, v.r, v.g, v.b);
- cache[0] = v.r;
- cache[1] = v.g;
- cache[2] = v.b;
- }
- } else {
- if (arraysEqual(cache, v))
- return;
- gl.uniform3fv(this.addr, v);
- copyArray(cache, v);
- }
- }
- function setValueV4f(gl, v) {
- var cache = this.cache;
- if (v.x !== void 0) {
- if (cache[0] !== v.x || cache[1] !== v.y || cache[2] !== v.z || cache[3] !== v.w) {
- gl.uniform4f(this.addr, v.x, v.y, v.z, v.w);
- cache[0] = v.x;
- cache[1] = v.y;
- cache[2] = v.z;
- cache[3] = v.w;
- }
- } else {
- if (arraysEqual(cache, v))
- return;
- gl.uniform4fv(this.addr, v);
- copyArray(cache, v);
- }
- }
- function setValueM2(gl, v) {
- var cache = this.cache;
- var elements = v.elements;
- if (elements === void 0) {
- if (arraysEqual(cache, v))
- return;
- gl.uniformMatrix2fv(this.addr, false, v);
- copyArray(cache, v);
- } else {
- if (arraysEqual(cache, elements))
- return;
- mat2array.set(elements);
- gl.uniformMatrix2fv(this.addr, false, mat2array);
- copyArray(cache, elements);
- }
- }
- function setValueM3(gl, v) {
- var cache = this.cache;
- var elements = v.elements;
- if (elements === void 0) {
- if (arraysEqual(cache, v))
- return;
- gl.uniformMatrix3fv(this.addr, false, v);
- copyArray(cache, v);
- } else {
- if (arraysEqual(cache, elements))
- return;
- mat3array.set(elements);
- gl.uniformMatrix3fv(this.addr, false, mat3array);
- copyArray(cache, elements);
- }
- }
- function setValueM4(gl, v) {
- var cache = this.cache;
- var elements = v.elements;
- if (elements === void 0) {
- if (arraysEqual(cache, v))
- return;
- gl.uniformMatrix4fv(this.addr, false, v);
- copyArray(cache, v);
- } else {
- if (arraysEqual(cache, elements))
- return;
- mat4array.set(elements);
- gl.uniformMatrix4fv(this.addr, false, mat4array);
- copyArray(cache, elements);
- }
- }
- function setValueT1(gl, v, textures) {
- var cache = this.cache;
- var unit = textures.allocateTextureUnit();
- if (cache[0] !== unit) {
- gl.uniform1i(this.addr, unit);
- cache[0] = unit;
- }
- textures.safeSetTexture2D(v || emptyTexture, unit);
- }
- function setValueT2DArray1(gl, v, textures) {
- var cache = this.cache;
- var unit = textures.allocateTextureUnit();
- if (cache[0] !== unit) {
- gl.uniform1i(this.addr, unit);
- cache[0] = unit;
- }
- textures.setTexture2DArray(v || emptyTexture2dArray, unit);
- }
- function setValueT3D1(gl, v, textures) {
- var cache = this.cache;
- var unit = textures.allocateTextureUnit();
- if (cache[0] !== unit) {
- gl.uniform1i(this.addr, unit);
- cache[0] = unit;
- }
- textures.setTexture3D(v || emptyTexture3d, unit);
- }
- function setValueT6(gl, v, textures) {
- var cache = this.cache;
- var unit = textures.allocateTextureUnit();
- if (cache[0] !== unit) {
- gl.uniform1i(this.addr, unit);
- cache[0] = unit;
- }
- textures.safeSetTextureCube(v || emptyCubeTexture, unit);
- }
- function setValueV1i(gl, v) {
- var cache = this.cache;
- if (cache[0] === v)
- return;
- gl.uniform1i(this.addr, v);
- cache[0] = v;
- }
- function setValueV2i(gl, v) {
- var cache = this.cache;
- if (arraysEqual(cache, v))
- return;
- gl.uniform2iv(this.addr, v);
- copyArray(cache, v);
- }
- function setValueV3i(gl, v) {
- var cache = this.cache;
- if (arraysEqual(cache, v))
- return;
- gl.uniform3iv(this.addr, v);
- copyArray(cache, v);
- }
- function setValueV4i(gl, v) {
- var cache = this.cache;
- if (arraysEqual(cache, v))
- return;
- gl.uniform4iv(this.addr, v);
- copyArray(cache, v);
- }
- function setValueV1ui(gl, v) {
- var cache = this.cache;
- if (cache[0] === v)
- return;
- gl.uniform1ui(this.addr, v);
- cache[0] = v;
- }
- function getSingularSetter(type) {
- switch (type) {
- case 5126:
- return setValueV1f;
- case 35664:
- return setValueV2f;
- case 35665:
- return setValueV3f;
- case 35666:
- return setValueV4f;
- case 35674:
- return setValueM2;
- case 35675:
- return setValueM3;
- case 35676:
- return setValueM4;
- case 5124:
- case 35670:
- return setValueV1i;
- case 35667:
- case 35671:
- return setValueV2i;
- case 35668:
- case 35672:
- return setValueV3i;
- case 35669:
- case 35673:
- return setValueV4i;
- case 5125:
- return setValueV1ui;
- case 35678:
- case 36198:
- case 36298:
- case 36306:
- case 35682:
- return setValueT1;
- case 35679:
- case 36299:
- case 36307:
- return setValueT3D1;
- case 35680:
- case 36300:
- case 36308:
- case 36293:
- return setValueT6;
- case 36289:
- case 36303:
- case 36311:
- case 36292:
- return setValueT2DArray1;
- }
- }
- function setValueV1fArray(gl, v) {
- gl.uniform1fv(this.addr, v);
- }
- function setValueV1iArray(gl, v) {
- gl.uniform1iv(this.addr, v);
- }
- function setValueV2iArray(gl, v) {
- gl.uniform2iv(this.addr, v);
- }
- function setValueV3iArray(gl, v) {
- gl.uniform3iv(this.addr, v);
- }
- function setValueV4iArray(gl, v) {
- gl.uniform4iv(this.addr, v);
- }
- function setValueV2fArray(gl, v) {
- var data = flatten(v, this.size, 2);
- gl.uniform2fv(this.addr, data);
- }
- function setValueV3fArray(gl, v) {
- var data = flatten(v, this.size, 3);
- gl.uniform3fv(this.addr, data);
- }
- function setValueV4fArray(gl, v) {
- var data = flatten(v, this.size, 4);
- gl.uniform4fv(this.addr, data);
- }
- function setValueM2Array(gl, v) {
- var data = flatten(v, this.size, 4);
- gl.uniformMatrix2fv(this.addr, false, data);
- }
- function setValueM3Array(gl, v) {
- var data = flatten(v, this.size, 9);
- gl.uniformMatrix3fv(this.addr, false, data);
- }
- function setValueM4Array(gl, v) {
- var data = flatten(v, this.size, 16);
- gl.uniformMatrix4fv(this.addr, false, data);
- }
- function setValueT1Array(gl, v, textures) {
- var n = v.length;
- var units = allocTexUnits(textures, n);
- gl.uniform1iv(this.addr, units);
- for (var i2 = 0; i2 !== n; ++i2) {
- textures.safeSetTexture2D(v[i2] || emptyTexture, units[i2]);
- }
- }
- function setValueT6Array(gl, v, textures) {
- var n = v.length;
- var units = allocTexUnits(textures, n);
- gl.uniform1iv(this.addr, units);
- for (var i2 = 0; i2 !== n; ++i2) {
- textures.safeSetTextureCube(v[i2] || emptyCubeTexture, units[i2]);
- }
- }
- function getPureArraySetter(type) {
- switch (type) {
- case 5126:
- return setValueV1fArray;
- case 35664:
- return setValueV2fArray;
- case 35665:
- return setValueV3fArray;
- case 35666:
- return setValueV4fArray;
- case 35674:
- return setValueM2Array;
- case 35675:
- return setValueM3Array;
- case 35676:
- return setValueM4Array;
- case 5124:
- case 35670:
- return setValueV1iArray;
- case 35667:
- case 35671:
- return setValueV2iArray;
- case 35668:
- case 35672:
- return setValueV3iArray;
- case 35669:
- case 35673:
- return setValueV4iArray;
- case 35678:
- case 36198:
- case 36298:
- case 36306:
- case 35682:
- return setValueT1Array;
- case 35680:
- case 36300:
- case 36308:
- case 36293:
- return setValueT6Array;
- }
- }
- function SingleUniform(id, activeInfo, addr) {
- this.id = id;
- this.addr = addr;
- this.cache = [];
- this.setValue = getSingularSetter(activeInfo.type);
- }
- function PureArrayUniform(id, activeInfo, addr) {
- this.id = id;
- this.addr = addr;
- this.cache = [];
- this.size = activeInfo.size;
- this.setValue = getPureArraySetter(activeInfo.type);
- }
- PureArrayUniform.prototype.updateCache = function(data) {
- var cache = this.cache;
- if (data instanceof Float32Array && cache.length !== data.length) {
- this.cache = new Float32Array(data.length);
- }
- copyArray(cache, data);
- };
- function StructuredUniform(id) {
- this.id = id;
- this.seq = [];
- this.map = {};
- }
- StructuredUniform.prototype.setValue = function(gl, value, textures) {
- var seq = this.seq;
- for (var i2 = 0, n = seq.length; i2 !== n; ++i2) {
- var u = seq[i2];
- u.setValue(gl, value[u.id], textures);
- }
- };
- var RePathPart = /([\w\d_]+)(\])?(\[|\.)?/g;
- function addUniform(container, uniformObject) {
- container.seq.push(uniformObject);
- container.map[uniformObject.id] = uniformObject;
- }
- function parseUniform(activeInfo, addr, container) {
- var path = activeInfo.name, pathLength = path.length;
- RePathPart.lastIndex = 0;
- while (true) {
- var match = RePathPart.exec(path), matchEnd = RePathPart.lastIndex, id = match[1], idIsIndex = match[2] === "]", subscript = match[3];
- if (idIsIndex)
- id = id | 0;
- if (subscript === void 0 || subscript === "[" && matchEnd + 2 === pathLength) {
- addUniform(container, subscript === void 0 ? new SingleUniform(id, activeInfo, addr) : new PureArrayUniform(id, activeInfo, addr));
- break;
- } else {
- var map2 = container.map, next = map2[id];
- if (next === void 0) {
- next = new StructuredUniform(id);
- addUniform(container, next);
- }
- container = next;
- }
- }
- }
- function WebGLUniforms(gl, program) {
- this.seq = [];
- this.map = {};
- var n = gl.getProgramParameter(program, 35718);
- for (var i2 = 0; i2 < n; ++i2) {
- var info = gl.getActiveUniform(program, i2), addr = gl.getUniformLocation(program, info.name);
- parseUniform(info, addr, this);
- }
- }
- WebGLUniforms.prototype.setValue = function(gl, name, value, textures) {
- var u = this.map[name];
- if (u !== void 0)
- u.setValue(gl, value, textures);
- };
- WebGLUniforms.prototype.setOptional = function(gl, object, name) {
- var v = object[name];
- if (v !== void 0)
- this.setValue(gl, name, v);
- };
- WebGLUniforms.upload = function(gl, seq, values, textures) {
- for (var i2 = 0, n = seq.length; i2 !== n; ++i2) {
- var u = seq[i2], v = values[u.id];
- if (v.needsUpdate !== false) {
- u.setValue(gl, v.value, textures);
- }
- }
- };
- WebGLUniforms.seqWithValue = function(seq, values) {
- var r = [];
- for (var i2 = 0, n = seq.length; i2 !== n; ++i2) {
- var u = seq[i2];
- if (u.id in values)
- r.push(u);
- }
- return r;
- };
- function WebGLShader(gl, type, string) {
- var shader = gl.createShader(type);
- gl.shaderSource(shader, string);
- gl.compileShader(shader);
- return shader;
- }
- var programIdCount = 0;
- function addLineNumbers(string) {
- var lines = string.split("\n");
- for (var i2 = 0; i2 < lines.length; i2++) {
- lines[i2] = i2 + 1 + ": " + lines[i2];
- }
- return lines.join("\n");
- }
- function getEncodingComponents(encoding) {
- switch (encoding) {
- case LinearEncoding:
- return ["Linear", "( value )"];
- case sRGBEncoding:
- return ["sRGB", "( value )"];
- case RGBEEncoding:
- return ["RGBE", "( value )"];
- case RGBM7Encoding:
- return ["RGBM", "( value, 7.0 )"];
- case RGBM16Encoding:
- return ["RGBM", "( value, 16.0 )"];
- case RGBDEncoding:
- return ["RGBD", "( value, 256.0 )"];
- case GammaEncoding:
- return ["Gamma", "( value, float( GAMMA_FACTOR ) )"];
- case LogLuvEncoding:
- return ["LogLuv", "( value )"];
- default:
- throw new Error("unsupported encoding: " + encoding);
- }
- }
- function getShaderErrors(gl, shader, type) {
- var status = gl.getShaderParameter(shader, 35713);
- var log = gl.getShaderInfoLog(shader).trim();
- if (status && log === "")
- return "";
- var source = gl.getShaderSource(shader);
- return "THREE.WebGLShader: gl.getShaderInfoLog() " + type + "\n" + log + addLineNumbers(source);
- }
- function getTexelDecodingFunction(functionName, encoding) {
- var components = getEncodingComponents(encoding);
- return "vec4 " + functionName + "( vec4 value ) { return " + components[0] + "ToLinear" + components[1] + "; }";
- }
- function getTexelEncodingFunction(functionName, encoding) {
- var components = getEncodingComponents(encoding);
- return "vec4 " + functionName + "( vec4 value ) { return LinearTo" + components[0] + components[1] + "; }";
- }
- function getToneMappingFunction(functionName, toneMapping) {
- var toneMappingName;
- switch (toneMapping) {
- case LinearToneMapping:
- toneMappingName = "Linear";
- break;
- case ReinhardToneMapping:
- toneMappingName = "Reinhard";
- break;
- case Uncharted2ToneMapping:
- toneMappingName = "Uncharted2";
- break;
- case CineonToneMapping:
- toneMappingName = "OptimizedCineon";
- break;
- case ACESFilmicToneMapping:
- toneMappingName = "ACESFilmic";
- break;
- default:
- throw new Error("unsupported toneMapping: " + toneMapping);
- }
- return "vec3 " + functionName + "( vec3 color ) { return " + toneMappingName + "ToneMapping( color ); }";
- }
- function generateExtensions(parameters) {
- var chunks = [
- parameters.extensionDerivatives || parameters.envMapCubeUV || parameters.bumpMap || parameters.tangentSpaceNormalMap || parameters.clearcoatNormalMap || parameters.flatShading || parameters.shaderID === "physical" ? "#extension GL_OES_standard_derivatives : enable" : "",
- (parameters.extensionFragDepth || parameters.logarithmicDepthBuffer) && parameters.rendererExtensionFragDepth ? "#extension GL_EXT_frag_depth : enable" : "",
- parameters.extensionDrawBuffers && parameters.rendererExtensionDrawBuffers ? "#extension GL_EXT_draw_buffers : require" : "",
- (parameters.extensionShaderTextureLOD || parameters.envMap) && parameters.rendererExtensionShaderTextureLod ? "#extension GL_EXT_shader_texture_lod : enable" : ""
- ];
- return chunks.filter(filterEmptyLine).join("\n");
- }
- function generateDefines(defines) {
- var chunks = [];
- for (var name in defines) {
- var value = defines[name];
- if (value === false)
- continue;
- chunks.push("#define " + name + " " + value);
- }
- return chunks.join("\n");
- }
- function fetchAttributeLocations(gl, program) {
- var attributes = {};
- var n = gl.getProgramParameter(program, 35721);
- for (var i2 = 0; i2 < n; i2++) {
- var info = gl.getActiveAttrib(program, i2);
- var name = info.name;
- attributes[name] = gl.getAttribLocation(program, name);
- }
- return attributes;
- }
- function filterEmptyLine(string) {
- return string !== "";
- }
- function replaceLightNums(string, parameters) {
- 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);
- }
- function replaceClippingPlaneNums(string, parameters) {
- return string.replace(/NUM_CLIPPING_PLANES/g, parameters.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, parameters.numClippingPlanes - parameters.numClipIntersection);
- }
- var includePattern = /^[ \t]*#include +<([\w\d./]+)>/gm;
- function resolveIncludes(string) {
- return string.replace(includePattern, includeReplacer);
- }
- function includeReplacer(match, include) {
- var string = ShaderChunk[include];
- if (string === void 0) {
- throw new Error("Can not resolve #include <" + include + ">");
- }
- return resolveIncludes(string);
- }
- var loopPattern = /#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;
- function unrollLoops(string) {
- return string.replace(loopPattern, loopReplacer);
- }
- function loopReplacer(match, start, end, snippet) {
- var string = "";
- for (var i2 = parseInt(start); i2 < parseInt(end); i2++) {
- string += snippet.replace(/\[ i \]/g, "[ " + i2 + " ]").replace(/UNROLLED_LOOP_INDEX/g, i2);
- }
- return string;
- }
- function generatePrecision(parameters) {
- var precisionstring = "precision " + parameters.precision + " float;\nprecision " + parameters.precision + " int;";
- if (parameters.precision === "highp") {
- precisionstring += "\n#define HIGH_PRECISION";
- } else if (parameters.precision === "mediump") {
- precisionstring += "\n#define MEDIUM_PRECISION";
- } else if (parameters.precision === "lowp") {
- precisionstring += "\n#define LOW_PRECISION";
- }
- return precisionstring;
- }
- function generateShadowMapTypeDefine(parameters) {
- var shadowMapTypeDefine = "SHADOWMAP_TYPE_BASIC";
- if (parameters.shadowMapType === PCFShadowMap) {
- shadowMapTypeDefine = "SHADOWMAP_TYPE_PCF";
- } else if (parameters.shadowMapType === PCFSoftShadowMap) {
- shadowMapTypeDefine = "SHADOWMAP_TYPE_PCF_SOFT";
- } else if (parameters.shadowMapType === VSMShadowMap) {
- shadowMapTypeDefine = "SHADOWMAP_TYPE_VSM";
- }
- return shadowMapTypeDefine;
- }
- function generateEnvMapTypeDefine(parameters) {
- var envMapTypeDefine = "ENVMAP_TYPE_CUBE";
- if (parameters.envMap) {
- switch (parameters.envMapMode) {
- case CubeReflectionMapping:
- case CubeRefractionMapping:
- envMapTypeDefine = "ENVMAP_TYPE_CUBE";
- break;
- case CubeUVReflectionMapping:
- case CubeUVRefractionMapping:
- envMapTypeDefine = "ENVMAP_TYPE_CUBE_UV";
- break;
- case EquirectangularReflectionMapping:
- case EquirectangularRefractionMapping:
- envMapTypeDefine = "ENVMAP_TYPE_EQUIREC";
- break;
- case SphericalReflectionMapping:
- envMapTypeDefine = "ENVMAP_TYPE_SPHERE";
- break;
- }
- }
- return envMapTypeDefine;
- }
- function generateEnvMapModeDefine(parameters) {
- var envMapModeDefine = "ENVMAP_MODE_REFLECTION";
- if (parameters.envMap) {
- switch (parameters.envMapMode) {
- case CubeRefractionMapping:
- case EquirectangularRefractionMapping:
- envMapModeDefine = "ENVMAP_MODE_REFRACTION";
- break;
- }
- }
- return envMapModeDefine;
- }
- function generateEnvMapBlendingDefine(parameters) {
- var envMapBlendingDefine = "ENVMAP_BLENDING_NONE";
- if (parameters.envMap) {
- switch (parameters.combine) {
- case MultiplyOperation:
- envMapBlendingDefine = "ENVMAP_BLENDING_MULTIPLY";
- break;
- case MixOperation:
- envMapBlendingDefine = "ENVMAP_BLENDING_MIX";
- break;
- case AddOperation:
- envMapBlendingDefine = "ENVMAP_BLENDING_ADD";
- break;
- }
- }
- return envMapBlendingDefine;
- }
- function WebGLProgram(renderer, cacheKey, parameters) {
- var gl = renderer.getContext();
- var defines = parameters.defines;
- var vertexShader = parameters.vertexShader;
- var fragmentShader = parameters.fragmentShader;
- var shadowMapTypeDefine = generateShadowMapTypeDefine(parameters);
- var envMapTypeDefine = generateEnvMapTypeDefine(parameters);
- var envMapModeDefine = generateEnvMapModeDefine(parameters);
- var envMapBlendingDefine = generateEnvMapBlendingDefine(parameters);
- var gammaFactorDefine = renderer.gammaFactor > 0 ? renderer.gammaFactor : 1;
- var customExtensions = parameters.isWebGL2 ? "" : generateExtensions(parameters);
- var customDefines = generateDefines(defines);
- var program = gl.createProgram();
- var prefixVertex, prefixFragment;
- var numMultiviewViews = parameters.numMultiviewViews;
- if (parameters.isRawShaderMaterial) {
- prefixVertex = [
- customDefines
- ].filter(filterEmptyLine).join("\n");
- if (prefixVertex.length > 0) {
- prefixVertex += "\n";
- }
- prefixFragment = [
- customExtensions,
- customDefines
- ].filter(filterEmptyLine).join("\n");
- if (prefixFragment.length > 0) {
- prefixFragment += "\n";
- }
- } else {
- prefixVertex = [
- generatePrecision(parameters),
- "#define SHADER_NAME " + parameters.shaderName,
- customDefines,
- parameters.instancing ? "#define USE_INSTANCING" : "",
- parameters.supportsVertexTextures ? "#define VERTEX_TEXTURES" : "",
- "#define GAMMA_FACTOR " + gammaFactorDefine,
- "#define MAX_BONES " + parameters.maxBones,
- parameters.useFog && parameters.fog ? "#define USE_FOG" : "",
- parameters.useFog && parameters.fogExp2 ? "#define FOG_EXP2" : "",
- parameters.map ? "#define USE_MAP" : "",
- parameters.envMap ? "#define USE_ENVMAP" : "",
- parameters.envMap ? "#define " + envMapModeDefine : "",
- parameters.lightMap ? "#define USE_LIGHTMAP" : "",
- parameters.aoMap ? "#define USE_AOMAP" : "",
- parameters.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
- parameters.bumpMap ? "#define USE_BUMPMAP" : "",
- parameters.normalMap ? "#define USE_NORMALMAP" : "",
- parameters.normalMap && parameters.objectSpaceNormalMap ? "#define OBJECTSPACE_NORMALMAP" : "",
- parameters.normalMap && parameters.tangentSpaceNormalMap ? "#define TANGENTSPACE_NORMALMAP" : "",
- parameters.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "",
- parameters.displacementMap && parameters.supportsVertexTextures ? "#define USE_DISPLACEMENTMAP" : "",
- parameters.specularMap ? "#define USE_SPECULARMAP" : "",
- parameters.roughnessMap ? "#define USE_ROUGHNESSMAP" : "",
- parameters.metalnessMap ? "#define USE_METALNESSMAP" : "",
- parameters.alphaMap ? "#define USE_ALPHAMAP" : "",
- parameters.vertexTangents ? "#define USE_TANGENT" : "",
- parameters.vertexColors ? "#define USE_COLOR" : "",
- parameters.vertexUvs ? "#define USE_UV" : "",
- parameters.uvsVertexOnly ? "#define UVS_VERTEX_ONLY" : "",
- parameters.flatShading ? "#define FLAT_SHADED" : "",
- parameters.skinning ? "#define USE_SKINNING" : "",
- parameters.useVertexTexture ? "#define BONE_TEXTURE" : "",
- parameters.morphTargets ? "#define USE_MORPHTARGETS" : "",
- parameters.morphNormals && parameters.flatShading === false ? "#define USE_MORPHNORMALS" : "",
- parameters.doubleSided ? "#define DOUBLE_SIDED" : "",
- parameters.flipSided ? "#define FLIP_SIDED" : "",
- parameters.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
- parameters.shadowMapEnabled ? "#define " + shadowMapTypeDefine : "",
- parameters.sizeAttenuation ? "#define USE_SIZEATTENUATION" : "",
- parameters.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "",
- parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? "#define USE_LOGDEPTHBUF_EXT" : "",
- "uniform mat4 modelMatrix;",
- "uniform mat4 modelViewMatrix;",
- "uniform mat4 projectionMatrix;",
- "uniform mat4 viewMatrix;",
- "uniform mat3 normalMatrix;",
- "uniform vec3 cameraPosition;",
- "uniform bool isOrthographic;",
- "#ifdef USE_INSTANCING",
- " attribute mat4 instanceMatrix;",
- "#endif",
- "attribute vec3 position;",
- "attribute vec3 normal;",
- "attribute vec2 uv;",
- "#ifdef USE_TANGENT",
- " attribute vec4 tangent;",
- "#endif",
- "#ifdef USE_COLOR",
- " attribute vec3 color;",
- "#endif",
- "#ifdef USE_MORPHTARGETS",
- " attribute vec3 morphTarget0;",
- " attribute vec3 morphTarget1;",
- " attribute vec3 morphTarget2;",
- " attribute vec3 morphTarget3;",
- " #ifdef USE_MORPHNORMALS",
- " attribute vec3 morphNormal0;",
- " attribute vec3 morphNormal1;",
- " attribute vec3 morphNormal2;",
- " attribute vec3 morphNormal3;",
- " #else",
- " attribute vec3 morphTarget4;",
- " attribute vec3 morphTarget5;",
- " attribute vec3 morphTarget6;",
- " attribute vec3 morphTarget7;",
- " #endif",
- "#endif",
- "#ifdef USE_SKINNING",
- " attribute vec4 skinIndex;",
- " attribute vec4 skinWeight;",
- "#endif",
- "\n"
- ].filter(filterEmptyLine).join("\n");
- prefixFragment = [
- customExtensions,
- generatePrecision(parameters),
- "#define SHADER_NAME " + parameters.shaderName,
- customDefines,
- parameters.alphaTest ? "#define ALPHATEST " + parameters.alphaTest + (parameters.alphaTest % 1 ? "" : ".0") : "",
- // add '.0' if integer
- "#define GAMMA_FACTOR " + gammaFactorDefine,
- parameters.useFog && parameters.fog ? "#define USE_FOG" : "",
- parameters.useFog && parameters.fogExp2 ? "#define FOG_EXP2" : "",
- parameters.map ? "#define USE_MAP" : "",
- parameters.matcap ? "#define USE_MATCAP" : "",
- parameters.envMap ? "#define USE_ENVMAP" : "",
- parameters.envMap ? "#define " + envMapTypeDefine : "",
- parameters.envMap ? "#define " + envMapModeDefine : "",
- parameters.envMap ? "#define " + envMapBlendingDefine : "",
- parameters.lightMap ? "#define USE_LIGHTMAP" : "",
- parameters.aoMap ? "#define USE_AOMAP" : "",
- parameters.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
- parameters.bumpMap ? "#define USE_BUMPMAP" : "",
- parameters.normalMap ? "#define USE_NORMALMAP" : "",
- parameters.normalMap && parameters.objectSpaceNormalMap ? "#define OBJECTSPACE_NORMALMAP" : "",
- parameters.normalMap && parameters.tangentSpaceNormalMap ? "#define TANGENTSPACE_NORMALMAP" : "",
- parameters.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "",
- parameters.specularMap ? "#define USE_SPECULARMAP" : "",
- parameters.roughnessMap ? "#define USE_ROUGHNESSMAP" : "",
- parameters.metalnessMap ? "#define USE_METALNESSMAP" : "",
- parameters.alphaMap ? "#define USE_ALPHAMAP" : "",
- parameters.sheen ? "#define USE_SHEEN" : "",
- parameters.vertexTangents ? "#define USE_TANGENT" : "",
- parameters.vertexColors ? "#define USE_COLOR" : "",
- parameters.vertexUvs ? "#define USE_UV" : "",
- parameters.uvsVertexOnly ? "#define UVS_VERTEX_ONLY" : "",
- parameters.gradientMap ? "#define USE_GRADIENTMAP" : "",
- parameters.flatShading ? "#define FLAT_SHADED" : "",
- parameters.doubleSided ? "#define DOUBLE_SIDED" : "",
- parameters.flipSided ? "#define FLIP_SIDED" : "",
- parameters.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
- parameters.shadowMapEnabled ? "#define " + shadowMapTypeDefine : "",
- parameters.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "",
- parameters.physicallyCorrectLights ? "#define PHYSICALLY_CORRECT_LIGHTS" : "",
- parameters.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "",
- parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? "#define USE_LOGDEPTHBUF_EXT" : "",
- (parameters.extensionShaderTextureLOD || parameters.envMap) && parameters.rendererExtensionShaderTextureLod ? "#define TEXTURE_LOD_EXT" : "",
- "uniform mat4 viewMatrix;",
- "uniform vec3 cameraPosition;",
- "uniform bool isOrthographic;",
- parameters.toneMapping !== NoToneMapping ? "#define TONE_MAPPING" : "",
- parameters.toneMapping !== NoToneMapping ? ShaderChunk["tonemapping_pars_fragment"] : "",
- // this code is required here because it is used by the toneMapping() function defined below
- parameters.toneMapping !== NoToneMapping ? getToneMappingFunction("toneMapping", parameters.toneMapping) : "",
- parameters.dithering ? "#define DITHERING" : "",
- parameters.outputEncoding || parameters.mapEncoding || parameters.matcapEncoding || parameters.envMapEncoding || parameters.emissiveMapEncoding || parameters.lightMapEncoding ? ShaderChunk["encodings_pars_fragment"] : "",
- // this code is required here because it is used by the various encoding/decoding function defined below
- parameters.mapEncoding ? getTexelDecodingFunction("mapTexelToLinear", parameters.mapEncoding) : "",
- parameters.matcapEncoding ? getTexelDecodingFunction("matcapTexelToLinear", parameters.matcapEncoding) : "",
- parameters.envMapEncoding ? getTexelDecodingFunction("envMapTexelToLinear", parameters.envMapEncoding) : "",
- parameters.emissiveMapEncoding ? getTexelDecodingFunction("emissiveMapTexelToLinear", parameters.emissiveMapEncoding) : "",
- parameters.lightMapEncoding ? getTexelDecodingFunction("lightMapTexelToLinear", parameters.lightMapEncoding) : "",
- parameters.outputEncoding ? getTexelEncodingFunction("linearToOutputTexel", parameters.outputEncoding) : "",
- parameters.depthPacking ? "#define DEPTH_PACKING " + parameters.depthPacking : "",
- "\n"
- ].filter(filterEmptyLine).join("\n");
- }
- vertexShader = resolveIncludes(vertexShader);
- vertexShader = replaceLightNums(vertexShader, parameters);
- vertexShader = replaceClippingPlaneNums(vertexShader, parameters);
- fragmentShader = resolveIncludes(fragmentShader);
- fragmentShader = replaceLightNums(fragmentShader, parameters);
- fragmentShader = replaceClippingPlaneNums(fragmentShader, parameters);
- vertexShader = unrollLoops(vertexShader);
- fragmentShader = unrollLoops(fragmentShader);
- if (parameters.isWebGL2 && !parameters.isRawShaderMaterial) {
- var isGLSL3ShaderMaterial = false;
- var versionRegex = /^\s*#version\s+300\s+es\s*\n/;
- if (parameters.isShaderMaterial && vertexShader.match(versionRegex) !== null && fragmentShader.match(versionRegex) !== null) {
- isGLSL3ShaderMaterial = true;
- vertexShader = vertexShader.replace(versionRegex, "");
- fragmentShader = fragmentShader.replace(versionRegex, "");
- }
- prefixVertex = [
- "#version 300 es\n",
- "#define attribute in",
- "#define varying out",
- "#define texture2D texture"
- ].join("\n") + "\n" + prefixVertex;
- prefixFragment = [
- "#version 300 es\n",
- "#define varying in",
- isGLSL3ShaderMaterial ? "" : "out highp vec4 pc_fragColor;",
- isGLSL3ShaderMaterial ? "" : "#define gl_FragColor pc_fragColor",
- "#define gl_FragDepthEXT gl_FragDepth",
- "#define texture2D texture",
- "#define textureCube texture",
- "#define texture2DProj textureProj",
- "#define texture2DLodEXT textureLod",
- "#define texture2DProjLodEXT textureProjLod",
- "#define textureCubeLodEXT textureLod",
- "#define texture2DGradEXT textureGrad",
- "#define texture2DProjGradEXT textureProjGrad",
- "#define textureCubeGradEXT textureGrad"
- ].join("\n") + "\n" + prefixFragment;
- if (numMultiviewViews > 0) {
- prefixVertex = prefixVertex.replace(
- "#version 300 es\n",
- [
- "#version 300 es\n",
- "#extension GL_OVR_multiview2 : require",
- "layout(num_views = " + numMultiviewViews + ") in;",
- "#define VIEW_ID gl_ViewID_OVR"
- ].join("\n")
- );
- prefixVertex = prefixVertex.replace(
- [
- "uniform mat4 modelViewMatrix;",
- "uniform mat4 projectionMatrix;",
- "uniform mat4 viewMatrix;",
- "uniform mat3 normalMatrix;"
- ].join("\n"),
- [
- "uniform mat4 modelViewMatrices[" + numMultiviewViews + "];",
- "uniform mat4 projectionMatrices[" + numMultiviewViews + "];",
- "uniform mat4 viewMatrices[" + numMultiviewViews + "];",
- "uniform mat3 normalMatrices[" + numMultiviewViews + "];",
- "#define modelViewMatrix modelViewMatrices[VIEW_ID]",
- "#define projectionMatrix projectionMatrices[VIEW_ID]",
- "#define viewMatrix viewMatrices[VIEW_ID]",
- "#define normalMatrix normalMatrices[VIEW_ID]"
- ].join("\n")
- );
- prefixFragment = prefixFragment.replace(
- "#version 300 es\n",
- [
- "#version 300 es\n",
- "#extension GL_OVR_multiview2 : require",
- "#define VIEW_ID gl_ViewID_OVR"
- ].join("\n")
- );
- prefixFragment = prefixFragment.replace(
- "uniform mat4 viewMatrix;",
- [
- "uniform mat4 viewMatrices[" + numMultiviewViews + "];",
- "#define viewMatrix viewMatrices[VIEW_ID]"
- ].join("\n")
- );
- }
- }
- var vertexGlsl = prefixVertex + vertexShader;
- var fragmentGlsl = prefixFragment + fragmentShader;
- var glVertexShader = WebGLShader(gl, 35633, vertexGlsl);
- var glFragmentShader = WebGLShader(gl, 35632, fragmentGlsl);
- gl.attachShader(program, glVertexShader);
- gl.attachShader(program, glFragmentShader);
- if (parameters.index0AttributeName !== void 0) {
- gl.bindAttribLocation(program, 0, parameters.index0AttributeName);
- } else if (parameters.morphTargets === true) {
- gl.bindAttribLocation(program, 0, "position");
- }
- gl.linkProgram(program);
- if (renderer.debug.checkShaderErrors) {
- var programLog = gl.getProgramInfoLog(program).trim();
- var vertexLog = gl.getShaderInfoLog(glVertexShader).trim();
- var fragmentLog = gl.getShaderInfoLog(glFragmentShader).trim();
- var runnable = true;
- var haveDiagnostics = true;
- if (gl.getProgramParameter(program, 35714) === false) {
- runnable = false;
- var vertexErrors = getShaderErrors(gl, glVertexShader, "vertex");
- var fragmentErrors = getShaderErrors(gl, glFragmentShader, "fragment");
- console.error("THREE.WebGLProgram: shader error: ", gl.getError(), "35715", gl.getProgramParameter(program, 35715), "gl.getProgramInfoLog", programLog, vertexErrors, fragmentErrors);
- } else if (programLog !== "") {
- console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()", programLog);
- } else if (vertexLog === "" || fragmentLog === "") {
- haveDiagnostics = false;
- }
- if (haveDiagnostics) {
- this.diagnostics = {
- runnable,
- programLog,
- vertexShader: {
- log: vertexLog,
- prefix: prefixVertex
- },
- fragmentShader: {
- log: fragmentLog,
- prefix: prefixFragment
- }
- };
- }
- }
- gl.deleteShader(glVertexShader);
- gl.deleteShader(glFragmentShader);
- var cachedUniforms;
- this.getUniforms = function() {
- if (cachedUniforms === void 0) {
- cachedUniforms = new WebGLUniforms(gl, program);
- }
- return cachedUniforms;
- };
- var cachedAttributes;
- this.getAttributes = function() {
- if (cachedAttributes === void 0) {
- cachedAttributes = fetchAttributeLocations(gl, program);
- }
- return cachedAttributes;
- };
- this.destroy = function() {
- gl.deleteProgram(program);
- this.program = void 0;
- };
- this.name = parameters.shaderName;
- this.id = programIdCount++;
- this.cacheKey = cacheKey;
- this.usedTimes = 1;
- this.program = program;
- this.vertexShader = glVertexShader;
- this.fragmentShader = glFragmentShader;
- this.numMultiviewViews = numMultiviewViews;
- return this;
- }
- function WebGLPrograms(renderer, extensions, capabilities) {
- var programs = [];
- var isWebGL2 = capabilities.isWebGL2;
- var logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
- var floatVertexTextures = capabilities.floatVertexTextures;
- var precision = capabilities.precision;
- var maxVertexUniforms = capabilities.maxVertexUniforms;
- var vertexTextures = capabilities.vertexTextures;
- var shaderIDs = {
- MeshDepthMaterial: "depth",
- MeshDistanceMaterial: "distanceRGBA",
- MeshNormalMaterial: "normal",
- MeshBasicMaterial: "basic",
- MeshLambertMaterial: "lambert",
- MeshPhongMaterial: "phong",
- MeshToonMaterial: "toon",
- MeshStandardMaterial: "physical",
- MeshPhysicalMaterial: "physical",
- MeshMatcapMaterial: "matcap",
- LineBasicMaterial: "basic",
- LineDashedMaterial: "dashed",
- PointsMaterial: "points",
- ShadowMaterial: "shadow",
- SpriteMaterial: "sprite"
- };
- var parameterNames = [
- "precision",
- "isWebGL2",
- "supportsVertexTextures",
- "outputEncoding",
- "instancing",
- "numMultiviewViews",
- "map",
- "mapEncoding",
- "matcap",
- "matcapEncoding",
- "envMap",
- "envMapMode",
- "envMapEncoding",
- "envMapCubeUV",
- "lightMap",
- "lightMapEncoding",
- "aoMap",
- "emissiveMap",
- "emissiveMapEncoding",
- "bumpMap",
- "normalMap",
- "objectSpaceNormalMap",
- "tangentSpaceNormalMap",
- "clearcoatNormalMap",
- "displacementMap",
- "specularMap",
- "roughnessMap",
- "metalnessMap",
- "gradientMap",
- "alphaMap",
- "combine",
- "vertexColors",
- "vertexTangents",
- "vertexUvs",
- "uvsVertexOnly",
- "fog",
- "useFog",
- "fogExp2",
- "flatShading",
- "sizeAttenuation",
- "logarithmicDepthBuffer",
- "skinning",
- "maxBones",
- "useVertexTexture",
- "morphTargets",
- "morphNormals",
- "maxMorphTargets",
- "maxMorphNormals",
- "premultipliedAlpha",
- "numDirLights",
- "numPointLights",
- "numSpotLights",
- "numHemiLights",
- "numRectAreaLights",
- "numDirLightShadows",
- "numPointLightShadows",
- "numSpotLightShadows",
- "shadowMapEnabled",
- "shadowMapType",
- "toneMapping",
- "physicallyCorrectLights",
- "alphaTest",
- "doubleSided",
- "flipSided",
- "numClippingPlanes",
- "numClipIntersection",
- "depthPacking",
- "dithering",
- "sheen"
- ];
- function getShaderObject(material, shaderID) {
- var shaderobject;
- if (shaderID) {
- var shader = ShaderLib[shaderID];
- shaderobject = {
- name: material.type,
- uniforms: UniformsUtils.clone(shader.uniforms),
- vertexShader: shader.vertexShader,
- fragmentShader: shader.fragmentShader
- };
- } else {
- shaderobject = {
- name: material.type,
- uniforms: material.uniforms,
- vertexShader: material.vertexShader,
- fragmentShader: material.fragmentShader
- };
- }
- return shaderobject;
- }
- function allocateBones(object) {
- var skeleton = object.skeleton;
- var bones = skeleton.bones;
- if (floatVertexTextures) {
- return 1024;
- } else {
- var nVertexUniforms = maxVertexUniforms;
- var nVertexMatrices = Math.floor((nVertexUniforms - 20) / 4);
- var maxBones = Math.min(nVertexMatrices, bones.length);
- if (maxBones < bones.length) {
- console.warn("THREE.WebGLRenderer: Skeleton has " + bones.length + " bones. This GPU supports " + maxBones + ".");
- return 0;
- }
- return maxBones;
- }
- }
- function getTextureEncodingFromMap(map2) {
- var encoding;
- if (!map2) {
- encoding = LinearEncoding;
- } else if (map2.isTexture) {
- encoding = map2.encoding;
- } else if (map2.isWebGLRenderTarget) {
- console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead.");
- encoding = map2.texture.encoding;
- }
- return encoding;
- }
- this.getParameters = function(material, lights, shadows, scene, nClipPlanes, nClipIntersection, object) {
- var fog = scene.fog;
- var environment = material.isMeshStandardMaterial ? scene.environment : null;
- var envMap = material.envMap || environment;
- var shaderID = shaderIDs[material.type];
- var maxBones = object.isSkinnedMesh ? allocateBones(object) : 0;
- if (material.precision !== null) {
- precision = capabilities.getMaxPrecision(material.precision);
- if (precision !== material.precision) {
- console.warn("THREE.WebGLProgram.getParameters:", material.precision, "not supported, using", precision, "instead.");
- }
- }
- var shaderobject = getShaderObject(material, shaderID);
- material.onBeforeCompile(shaderobject, renderer);
- var currentRenderTarget = renderer.getRenderTarget();
- var numMultiviewViews = currentRenderTarget && currentRenderTarget.isWebGLMultiviewRenderTarget ? currentRenderTarget.numViews : 0;
- var parameters = {
- isWebGL2,
- shaderID,
- shaderName: shaderobject.name,
- uniforms: shaderobject.uniforms,
- vertexShader: shaderobject.vertexShader,
- fragmentShader: shaderobject.fragmentShader,
- defines: material.defines,
- isRawShaderMaterial: material.isRawShaderMaterial,
- isShaderMaterial: material.isShaderMaterial,
- precision,
- instancing: object.isInstancedMesh === true,
- supportsVertexTextures: vertexTextures,
- numMultiviewViews,
- outputEncoding: currentRenderTarget !== null ? getTextureEncodingFromMap(currentRenderTarget.texture) : renderer.outputEncoding,
- map: !!material.map,
- mapEncoding: getTextureEncodingFromMap(material.map),
- matcap: !!material.matcap,
- matcapEncoding: getTextureEncodingFromMap(material.matcap),
- envMap: !!envMap,
- envMapMode: envMap && envMap.mapping,
- envMapEncoding: getTextureEncodingFromMap(envMap),
- envMapCubeUV: !!envMap && (envMap.mapping === CubeUVReflectionMapping || envMap.mapping === CubeUVRefractionMapping),
- lightMap: !!material.lightMap,
- lightMapEncoding: getTextureEncodingFromMap(material.lightMap),
- aoMap: !!material.aoMap,
- emissiveMap: !!material.emissiveMap,
- emissiveMapEncoding: getTextureEncodingFromMap(material.emissiveMap),
- bumpMap: !!material.bumpMap,
- normalMap: !!material.normalMap,
- objectSpaceNormalMap: material.normalMapType === ObjectSpaceNormalMap,
- tangentSpaceNormalMap: material.normalMapType === TangentSpaceNormalMap,
- clearcoatNormalMap: !!material.clearcoatNormalMap,
- displacementMap: !!material.displacementMap,
- roughnessMap: !!material.roughnessMap,
- metalnessMap: !!material.metalnessMap,
- specularMap: !!material.specularMap,
- alphaMap: !!material.alphaMap,
- gradientMap: !!material.gradientMap,
- sheen: !!material.sheen,
- combine: material.combine,
- vertexTangents: material.normalMap && material.vertexTangents,
- vertexColors: material.vertexColors,
- vertexUvs: !!material.map || !!material.bumpMap || !!material.normalMap || !!material.specularMap || !!material.alphaMap || !!material.emissiveMap || !!material.roughnessMap || !!material.metalnessMap || !!material.clearcoatNormalMap || !!material.displacementMap,
- uvsVertexOnly: !(!!material.map || !!material.bumpMap || !!material.normalMap || !!material.specularMap || !!material.alphaMap || !!material.emissiveMap || !!material.roughnessMap || !!material.metalnessMap || !!material.clearcoatNormalMap) && !!material.displacementMap,
- fog: !!fog,
- useFog: material.fog,
- fogExp2: fog && fog.isFogExp2,
- flatShading: material.flatShading,
- sizeAttenuation: material.sizeAttenuation,
- logarithmicDepthBuffer,
- skinning: material.skinning && maxBones > 0,
- maxBones,
- useVertexTexture: floatVertexTextures,
- morphTargets: material.morphTargets,
- morphNormals: material.morphNormals,
- maxMorphTargets: renderer.maxMorphTargets,
- maxMorphNormals: renderer.maxMorphNormals,
- numDirLights: lights.directional.length,
- numPointLights: lights.point.length,
- numSpotLights: lights.spot.length,
- numRectAreaLights: lights.rectArea.length,
- numHemiLights: lights.hemi.length,
- numDirLightShadows: lights.directionalShadowMap.length,
- numPointLightShadows: lights.pointShadowMap.length,
- numSpotLightShadows: lights.spotShadowMap.length,
- numClippingPlanes: nClipPlanes,
- numClipIntersection: nClipIntersection,
- dithering: material.dithering,
- shadowMapEnabled: renderer.shadowMap.enabled && shadows.length > 0,
- shadowMapType: renderer.shadowMap.type,
- toneMapping: material.toneMapped ? renderer.toneMapping : NoToneMapping,
- physicallyCorrectLights: renderer.physicallyCorrectLights,
- premultipliedAlpha: material.premultipliedAlpha,
- alphaTest: material.alphaTest,
- doubleSided: material.side === DoubleSide,
- flipSided: material.side === BackSide,
- depthPacking: material.depthPacking !== void 0 ? material.depthPacking : false,
- index0AttributeName: material.index0AttributeName,
- extensionDerivatives: material.extensions && material.extensions.derivatives,
- extensionFragDepth: material.extensions && material.extensions.frawbuffers,
- extensionDrawbuffers: material.extensions && material.extensions.drawbuffers,
- extensionShaderTextureLOD: material.extensions && material.extensions.shaderTextureLOD,
- rendererExtensionFragDepth: isWebGL2 || extensions.get("EXT_frag_depth") !== null,
- rendererExtensionDrawBuffers: isWebGL2 || extensions.get("WEBGL_draw_buffers") !== null,
- rendererExtensionShaderTextureLod: isWebGL2 || extensions.get("EXT_shader_texture_lod") !== null,
- onBeforeCompile: material.onBeforeCompile
- };
- return parameters;
- };
- this.getProgramCacheKey = function(parameters) {
- var array = [];
- if (parameters.shaderID) {
- array.push(parameters.shaderID);
- } else {
- array.push(parameters.fragmentShader);
- array.push(parameters.vertexShader);
- }
- if (parameters.defines !== void 0) {
- for (var name in parameters.defines) {
- array.push(name);
- array.push(parameters.defines[name]);
- }
- }
- if (parameters.isRawShaderMaterial === void 0) {
- for (var i2 = 0; i2 < parameterNames.length; i2++) {
- array.push(parameters[parameterNames[i2]]);
- }
- array.push(renderer.outputEncoding);
- array.push(renderer.gammaFactor);
- }
- array.push(parameters.onBeforeCompile.toString());
- return array.join();
- };
- this.acquireProgram = function(parameters, cacheKey) {
- var program;
- for (var p = 0, pl = programs.length; p < pl; p++) {
- var preexistingProgram = programs[p];
- if (preexistingProgram.cacheKey === cacheKey) {
- program = preexistingProgram;
- ++program.usedTimes;
- break;
- }
- }
- if (program === void 0) {
- program = new WebGLProgram(renderer, cacheKey, parameters);
- programs.push(program);
- }
- return program;
- };
- this.releaseProgram = function(program) {
- if (--program.usedTimes === 0) {
- var i2 = programs.indexOf(program);
- programs[i2] = programs[programs.length - 1];
- programs.pop();
- program.destroy();
- }
- };
- this.programs = programs;
- }
- function WebGLProperties() {
- var properties = /* @__PURE__ */ new WeakMap();
- function get(object) {
- var map2 = properties.get(object);
- if (map2 === void 0) {
- map2 = {};
- properties.set(object, map2);
- }
- return map2;
- }
- function remove(object) {
- properties.delete(object);
- }
- function update(object, key, value) {
- properties.get(object)[key] = value;
- }
- function dispose() {
- properties = /* @__PURE__ */ new WeakMap();
- }
- return {
- get,
- remove,
- update,
- dispose
- };
- }
- function painterSortStable(a, b) {
- if (a.groupOrder !== b.groupOrder) {
- return a.groupOrder - b.groupOrder;
- } else if (a.renderOrder !== b.renderOrder) {
- return a.renderOrder - b.renderOrder;
- } else if (a.program !== b.program) {
- return a.program.id - b.program.id;
- } else if (a.material.id !== b.material.id) {
- return a.material.id - b.material.id;
- } else if (a.z !== b.z) {
- return a.z - b.z;
- } else {
- return a.id - b.id;
- }
- }
- function reversePainterSortStable(a, b) {
- if (a.groupOrder !== b.groupOrder) {
- return a.groupOrder - b.groupOrder;
- } else if (a.renderOrder !== b.renderOrder) {
- return a.renderOrder - b.renderOrder;
- } else if (a.z !== b.z) {
- return b.z - a.z;
- } else {
- return a.id - b.id;
- }
- }
- function WebGLRenderList() {
- var renderItems = [];
- var renderItemsIndex = 0;
- var opaque = [];
- var transparent = [];
- var defaultProgram = { id: -1 };
- function init2() {
- renderItemsIndex = 0;
- opaque.length = 0;
- transparent.length = 0;
- }
- function getNextRenderItem(object, geometry, material, groupOrder, z, group) {
- var renderItem = renderItems[renderItemsIndex];
- if (renderItem === void 0) {
- renderItem = {
- id: object.id,
- object,
- geometry,
- material,
- program: material.program || defaultProgram,
- groupOrder,
- renderOrder: object.renderOrder,
- z,
- group
- };
- renderItems[renderItemsIndex] = renderItem;
- } else {
- renderItem.id = object.id;
- renderItem.object = object;
- renderItem.geometry = geometry;
- renderItem.material = material;
- renderItem.program = material.program || defaultProgram;
- renderItem.groupOrder = groupOrder;
- renderItem.renderOrder = object.renderOrder;
- renderItem.z = z;
- renderItem.group = group;
- }
- renderItemsIndex++;
- return renderItem;
- }
- function push(object, geometry, material, groupOrder, z, group) {
- var renderItem = getNextRenderItem(object, geometry, material, groupOrder, z, group);
- (material.transparent === true ? transparent : opaque).push(renderItem);
- }
- function unshift(object, geometry, material, groupOrder, z, group) {
- var renderItem = getNextRenderItem(object, geometry, material, groupOrder, z, group);
- (material.transparent === true ? transparent : opaque).unshift(renderItem);
- }
- function sort(customOpaqueSort, customTransparentSort) {
- if (opaque.length > 1)
- opaque.sort(customOpaqueSort || painterSortStable);
- if (transparent.length > 1)
- transparent.sort(customTransparentSort || reversePainterSortStable);
- }
- return {
- opaque,
- transparent,
- init: init2,
- push,
- unshift,
- sort
- };
- }
- function WebGLRenderLists() {
- var lists = /* @__PURE__ */ new WeakMap();
- function onSceneDispose(event) {
- var scene = event.target;
- scene.removeEventListener("dispose", onSceneDispose);
- lists.delete(scene);
- }
- function get(scene, camera) {
- var cameras = lists.get(scene);
- var list;
- if (cameras === void 0) {
- list = new WebGLRenderList();
- lists.set(scene, /* @__PURE__ */ new WeakMap());
- lists.get(scene).set(camera, list);
- scene.addEventListener("dispose", onSceneDispose);
- } else {
- list = cameras.get(camera);
- if (list === void 0) {
- list = new WebGLRenderList();
- cameras.set(camera, list);
- }
- }
- return list;
- }
- function dispose() {
- lists = /* @__PURE__ */ new WeakMap();
- }
- return {
- get,
- dispose
- };
- }
- function UniformsCache() {
- var lights = {};
- return {
- get: function(light) {
- if (lights[light.id] !== void 0) {
- return lights[light.id];
- }
- var uniforms;
- switch (light.type) {
- case "DirectionalLight":
- uniforms = {
- direction: new Vector3(),
- color: new Color(),
- shadow: false,
- shadowBias: 0,
- shadowRadius: 1,
- shadowMapSize: new Vector2()
- };
- break;
- case "SpotLight":
- uniforms = {
- position: new Vector3(),
- direction: new Vector3(),
- color: new Color(),
- distance: 0,
- coneCos: 0,
- penumbraCos: 0,
- decay: 0,
- shadow: false,
- shadowBias: 0,
- shadowRadius: 1,
- shadowMapSize: new Vector2()
- };
- break;
- case "PointLight":
- uniforms = {
- position: new Vector3(),
- color: new Color(),
- distance: 0,
- decay: 0,
- shadow: false,
- shadowBias: 0,
- shadowRadius: 1,
- shadowMapSize: new Vector2(),
- shadowCameraNear: 1,
- shadowCameraFar: 1e3
- };
- break;
- case "HemisphereLight":
- uniforms = {
- direction: new Vector3(),
- skyColor: new Color(),
- groundColor: new Color()
- };
- break;
- case "RectAreaLight":
- uniforms = {
- color: new Color(),
- position: new Vector3(),
- halfWidth: new Vector3(),
- halfHeight: new Vector3()
- // TODO (abelnation): set RectAreaLight shadow uniforms
- };
- break;
- }
- lights[light.id] = uniforms;
- return uniforms;
- }
- };
- }
- var nextVersion = 0;
- function shadowCastingLightsFirst(lightA, lightB) {
- return (lightB.castShadow ? 1 : 0) - (lightA.castShadow ? 1 : 0);
- }
- function WebGLLights() {
- var cache = new UniformsCache();
- var state = {
- version: 0,
- hash: {
- directionalLength: -1,
- pointLength: -1,
- spotLength: -1,
- rectAreaLength: -1,
- hemiLength: -1,
- numDirectionalShadows: -1,
- numPointShadows: -1,
- numSpotShadows: -1
- },
- ambient: [0, 0, 0],
- probe: [],
- directional: [],
- directionalShadowMap: [],
- directionalShadowMatrix: [],
- spot: [],
- spotShadowMap: [],
- spotShadowMatrix: [],
- rectArea: [],
- point: [],
- pointShadowMap: [],
- pointShadowMatrix: [],
- hemi: [],
- numDirectionalShadows: -1,
- numPointShadows: -1,
- numSpotShadows: -1
- };
- for (var i2 = 0; i2 < 9; i2++)
- state.probe.push(new Vector3());
- var vector3 = new Vector3();
- var matrix4 = new Matrix4();
- var matrix42 = new Matrix4();
- function setup(lights, shadows, camera) {
- var r = 0, g = 0, b = 0;
- for (var i3 = 0; i3 < 9; i3++)
- state.probe[i3].set(0, 0, 0);
- var directionalLength = 0;
- var pointLength = 0;
- var spotLength = 0;
- var rectAreaLength = 0;
- var hemiLength = 0;
- var numDirectionalShadows = 0;
- var numPointShadows = 0;
- var numSpotShadows = 0;
- var viewMatrix = camera.matrixWorldInverse;
- lights.sort(shadowCastingLightsFirst);
- for (var i3 = 0, l = lights.length; i3 < l; i3++) {
- var light = lights[i3];
- var color = light.color;
- var intensity = light.intensity;
- var distance = light.distance;
- var shadowMap = light.shadow && light.shadow.map ? light.shadow.map.texture : null;
- if (light.isAmbientLight) {
- r += color.r * intensity;
- g += color.g * intensity;
- b += color.b * intensity;
- } else if (light.isLightProbe) {
- for (var j = 0; j < 9; j++) {
- state.probe[j].addScaledVector(light.sh.coefficients[j], intensity);
- }
- } else if (light.isDirectionalLight) {
- var uniforms = cache.get(light);
- uniforms.color.copy(light.color).multiplyScalar(light.intensity);
- uniforms.direction.setFromMatrixPosition(light.matrixWorld);
- vector3.setFromMatrixPosition(light.target.matrixWorld);
- uniforms.direction.sub(vector3);
- uniforms.direction.transformDirection(viewMatrix);
- uniforms.shadow = light.castShadow;
- if (light.castShadow) {
- var shadow = light.shadow;
- uniforms.shadowBias = shadow.bias;
- uniforms.shadowRadius = shadow.radius;
- uniforms.shadowMapSize = shadow.mapSize;
- state.directionalShadowMap[directionalLength] = shadowMap;
- state.directionalShadowMatrix[directionalLength] = light.shadow.matrix;
- numDirectionalShadows++;
- }
- state.directional[directionalLength] = uniforms;
- directionalLength++;
- } else if (light.isSpotLight) {
- var uniforms = cache.get(light);
- uniforms.position.setFromMatrixPosition(light.matrixWorld);
- uniforms.position.applyMatrix4(viewMatrix);
- uniforms.color.copy(color).multiplyScalar(intensity);
- uniforms.distance = distance;
- uniforms.direction.setFromMatrixPosition(light.matrixWorld);
- vector3.setFromMatrixPosition(light.target.matrixWorld);
- uniforms.direction.sub(vector3);
- uniforms.direction.transformDirection(viewMatrix);
- uniforms.coneCos = Math.cos(light.angle);
- uniforms.penumbraCos = Math.cos(light.angle * (1 - light.penumbra));
- uniforms.decay = light.decay;
- uniforms.shadow = light.castShadow;
- if (light.castShadow) {
- var shadow = light.shadow;
- uniforms.shadowBias = shadow.bias;
- uniforms.shadowRadius = shadow.radius;
- uniforms.shadowMapSize = shadow.mapSize;
- state.spotShadowMap[spotLength] = shadowMap;
- state.spotShadowMatrix[spotLength] = light.shadow.matrix;
- numSpotShadows++;
- }
- state.spot[spotLength] = uniforms;
- spotLength++;
- } else if (light.isRectAreaLight) {
- var uniforms = cache.get(light);
- uniforms.color.copy(color).multiplyScalar(intensity);
- uniforms.position.setFromMatrixPosition(light.matrixWorld);
- uniforms.position.applyMatrix4(viewMatrix);
- matrix42.identity();
- matrix4.copy(light.matrixWorld);
- matrix4.premultiply(viewMatrix);
- matrix42.extractRotation(matrix4);
- uniforms.halfWidth.set(light.width * 0.5, 0, 0);
- uniforms.halfHeight.set(0, light.height * 0.5, 0);
- uniforms.halfWidth.applyMatrix4(matrix42);
- uniforms.halfHeight.applyMatrix4(matrix42);
- state.rectArea[rectAreaLength] = uniforms;
- rectAreaLength++;
- } else if (light.isPointLight) {
- var uniforms = cache.get(light);
- uniforms.position.setFromMatrixPosition(light.matrixWorld);
- uniforms.position.applyMatrix4(viewMatrix);
- uniforms.color.copy(light.color).multiplyScalar(light.intensity);
- uniforms.distance = light.distance;
- uniforms.decay = light.decay;
- uniforms.shadow = light.castShadow;
- if (light.castShadow) {
- var shadow = light.shadow;
- uniforms.shadowBias = shadow.bias;
- uniforms.shadowRadius = shadow.radius;
- uniforms.shadowMapSize = shadow.mapSize;
- uniforms.shadowCameraNear = shadow.camera.near;
- uniforms.shadowCameraFar = shadow.camera.far;
- state.pointShadowMap[pointLength] = shadowMap;
- state.pointShadowMatrix[pointLength] = light.shadow.matrix;
- numPointShadows++;
- }
- state.point[pointLength] = uniforms;
- pointLength++;
- } else if (light.isHemisphereLight) {
- var uniforms = cache.get(light);
- uniforms.direction.setFromMatrixPosition(light.matrixWorld);
- uniforms.direction.transformDirection(viewMatrix);
- uniforms.direction.normalize();
- uniforms.skyColor.copy(light.color).multiplyScalar(intensity);
- uniforms.groundColor.copy(light.groundColor).multiplyScalar(intensity);
- state.hemi[hemiLength] = uniforms;
- hemiLength++;
- }
- }
- state.ambient[0] = r;
- state.ambient[1] = g;
- state.ambient[2] = b;
- var hash = state.hash;
- 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) {
- state.directional.length = directionalLength;
- state.spot.length = spotLength;
- state.rectArea.length = rectAreaLength;
- state.point.length = pointLength;
- state.hemi.length = hemiLength;
- state.directionalShadowMap.length = numDirectionalShadows;
- state.pointShadowMap.length = numPointShadows;
- state.spotShadowMap.length = numSpotShadows;
- state.directionalShadowMatrix.length = numDirectionalShadows;
- state.pointShadowMatrix.length = numPointShadows;
- state.spotShadowMatrix.length = numSpotShadows;
- hash.directionalLength = directionalLength;
- hash.pointLength = pointLength;
- hash.spotLength = spotLength;
- hash.rectAreaLength = rectAreaLength;
- hash.hemiLength = hemiLength;
- hash.numDirectionalShadows = numDirectionalShadows;
- hash.numPointShadows = numPointShadows;
- hash.numSpotShadows = numSpotShadows;
- state.version = nextVersion++;
- }
- }
- return {
- setup,
- state
- };
- }
- function WebGLRenderState() {
- var lights = new WebGLLights();
- var lightsArray = [];
- var shadowsArray = [];
- function init2() {
- lightsArray.length = 0;
- shadowsArray.length = 0;
- }
- function pushLight(light) {
- lightsArray.push(light);
- }
- function pushShadow(shadowLight) {
- shadowsArray.push(shadowLight);
- }
- function setupLights(camera) {
- lights.setup(lightsArray, shadowsArray, camera);
- }
- var state = {
- lightsArray,
- shadowsArray,
- lights
- };
- return {
- init: init2,
- state,
- setupLights,
- pushLight,
- pushShadow
- };
- }
- function WebGLRenderStates() {
- var renderStates = /* @__PURE__ */ new WeakMap();
- function onSceneDispose(event) {
- var scene = event.target;
- scene.removeEventListener("dispose", onSceneDispose);
- renderStates.delete(scene);
- }
- function get(scene, camera) {
- var renderState;
- if (renderStates.has(scene) === false) {
- renderState = new WebGLRenderState();
- renderStates.set(scene, /* @__PURE__ */ new WeakMap());
- renderStates.get(scene).set(camera, renderState);
- scene.addEventListener("dispose", onSceneDispose);
- } else {
- if (renderStates.get(scene).has(camera) === false) {
- renderState = new WebGLRenderState();
- renderStates.get(scene).set(camera, renderState);
- } else {
- renderState = renderStates.get(scene).get(camera);
- }
- }
- return renderState;
- }
- function dispose() {
- renderStates = /* @__PURE__ */ new WeakMap();
- }
- return {
- get,
- dispose
- };
- }
- function MeshDepthMaterial(parameters) {
- Material.call(this);
- this.type = "MeshDepthMaterial";
- this.depthPacking = BasicDepthPacking;
- this.skinning = false;
- this.morphTargets = false;
- this.map = null;
- this.alphaMap = null;
- this.displacementMap = null;
- this.displacementScale = 1;
- this.displacementBias = 0;
- this.wireframe = false;
- this.wireframeLinewidth = 1;
- this.fog = false;
- this.setValues(parameters);
- }
- MeshDepthMaterial.prototype = Object.create(Material.prototype);
- MeshDepthMaterial.prototype.constructor = MeshDepthMaterial;
- MeshDepthMaterial.prototype.isMeshDepthMaterial = true;
- MeshDepthMaterial.prototype.copy = function(source) {
- Material.prototype.copy.call(this, source);
- this.depthPacking = source.depthPacking;
- this.skinning = source.skinning;
- this.morphTargets = source.morphTargets;
- this.map = source.map;
- this.alphaMap = source.alphaMap;
- this.displacementMap = source.displacementMap;
- this.displacementScale = source.displacementScale;
- this.displacementBias = source.displacementBias;
- this.wireframe = source.wireframe;
- this.wireframeLinewidth = source.wireframeLinewidth;
- return this;
- };
- function MeshDistanceMaterial(parameters) {
- Material.call(this);
- this.type = "MeshDistanceMaterial";
- this.referencePosition = new Vector3();
- this.nearDistance = 1;
- this.farDistance = 1e3;
- this.skinning = false;
- this.morphTargets = false;
- this.map = null;
- this.alphaMap = null;
- this.displacementMap = null;
- this.displacementScale = 1;
- this.displacementBias = 0;
- this.fog = false;
- this.setValues(parameters);
- }
- MeshDistanceMaterial.prototype = Object.create(Material.prototype);
- MeshDistanceMaterial.prototype.constructor = MeshDistanceMaterial;
- MeshDistanceMaterial.prototype.isMeshDistanceMaterial = true;
- MeshDistanceMaterial.prototype.copy = function(source) {
- Material.prototype.copy.call(this, source);
- this.referencePosition.copy(source.referencePosition);
- this.nearDistance = source.nearDistance;
- this.farDistance = source.farDistance;
- this.skinning = source.skinning;
- this.morphTargets = source.morphTargets;
- this.map = source.map;
- this.alphaMap = source.alphaMap;
- this.displacementMap = source.displacementMap;
- this.displacementScale = source.displacementScale;
- this.displacementBias = source.displacementBias;
- return this;
- };
- 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}";
- var vsm_vert = "void main() {\n gl_Position = vec4( position, 1.0 );\n}";
- function WebGLShadowMap(_renderer2, _objects, maxTextureSize) {
- var _frustum = new Frustum(), _shadowMapSize = new Vector2(), _viewportSize = new Vector2(), _viewport = new Vector4(), _depthMaterials = [], _distanceMaterials = [], _materialCache = {};
- var shadowSide = { 0: BackSide, 1: FrontSide, 2: DoubleSide };
- var shadowMaterialVertical = new ShaderMaterial({
- defines: {
- SAMPLE_RATE: 2 / 8,
- HALF_SAMPLE_RATE: 1 / 8
- },
- uniforms: {
- shadow_pass: { value: null },
- resolution: { value: new Vector2() },
- radius: { value: 4 }
- },
- vertexShader: vsm_vert,
- fragmentShader: vsm_frag
- });
- var shadowMaterialHorizonal = shadowMaterialVertical.clone();
- shadowMaterialHorizonal.defines.HORIZONAL_PASS = 1;
- var fullScreenTri = new BufferGeometry();
- fullScreenTri.setAttribute(
- "position",
- new BufferAttribute(
- new Float32Array([-1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5]),
- 3
- )
- );
- var fullScreenMesh = new Mesh(fullScreenTri, shadowMaterialVertical);
- var scope = this;
- this.enabled = false;
- this.autoUpdate = true;
- this.needsUpdate = false;
- this.type = PCFShadowMap;
- this.render = function(lights, scene, camera) {
- if (scope.enabled === false)
- return;
- if (scope.autoUpdate === false && scope.needsUpdate === false)
- return;
- if (lights.length === 0)
- return;
- var currentRenderTarget = _renderer2.getRenderTarget();
- var activeCubeFace = _renderer2.getActiveCubeFace();
- var activeMipmapLevel = _renderer2.getActiveMipmapLevel();
- var _state = _renderer2.state;
- _state.setBlending(NoBlending);
- _state.buffers.color.setClear(1, 1, 1, 1);
- _state.buffers.depth.setTest(true);
- _state.setScissorTest(false);
- for (var i2 = 0, il = lights.length; i2 < il; i2++) {
- var light = lights[i2];
- var shadow = light.shadow;
- if (shadow === void 0) {
- console.warn("THREE.WebGLShadowMap:", light, "has no shadow.");
- continue;
- }
- _shadowMapSize.copy(shadow.mapSize);
- var shadowFrameExtents = shadow.getFrameExtents();
- _shadowMapSize.multiply(shadowFrameExtents);
- _viewportSize.copy(shadow.mapSize);
- if (_shadowMapSize.x > maxTextureSize || _shadowMapSize.y > maxTextureSize) {
- console.warn("THREE.WebGLShadowMap:", light, "has shadow exceeding max texture size, reducing");
- if (_shadowMapSize.x > maxTextureSize) {
- _viewportSize.x = Math.floor(maxTextureSize / shadowFrameExtents.x);
- _shadowMapSize.x = _viewportSize.x * shadowFrameExtents.x;
- shadow.mapSize.x = _viewportSize.x;
- }
- if (_shadowMapSize.y > maxTextureSize) {
- _viewportSize.y = Math.floor(maxTextureSize / shadowFrameExtents.y);
- _shadowMapSize.y = _viewportSize.y * shadowFrameExtents.y;
- shadow.mapSize.y = _viewportSize.y;
- }
- }
- if (shadow.map === null && !shadow.isPointLightShadow && this.type === VSMShadowMap) {
- var pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat };
- shadow.map = new WebGLRenderTarget(_shadowMapSize.x, _shadowMapSize.y, pars);
- shadow.map.texture.name = light.name + ".shadowMap";
- shadow.mapPass = new WebGLRenderTarget(_shadowMapSize.x, _shadowMapSize.y, pars);
- shadow.camera.updateProjectionMatrix();
- }
- if (shadow.map === null) {
- var pars = { minFilter: NearestFilter, magFilter: NearestFilter, format: RGBAFormat };
- shadow.map = new WebGLRenderTarget(_shadowMapSize.x, _shadowMapSize.y, pars);
- shadow.map.texture.name = light.name + ".shadowMap";
- shadow.camera.updateProjectionMatrix();
- }
- _renderer2.setRenderTarget(shadow.map);
- _renderer2.clear();
- var viewportCount = shadow.getViewportCount();
- for (var vp = 0; vp < viewportCount; vp++) {
- var viewport = shadow.getViewport(vp);
- _viewport.set(
- _viewportSize.x * viewport.x,
- _viewportSize.y * viewport.y,
- _viewportSize.x * viewport.z,
- _viewportSize.y * viewport.w
- );
- _state.viewport(_viewport);
- shadow.updateMatrices(light, vp);
- _frustum = shadow.getFrustum();
- renderObject(scene, camera, shadow.camera, light, this.type);
- }
- if (!shadow.isPointLightShadow && this.type === VSMShadowMap) {
- VSMPass(shadow, camera);
- }
- }
- scope.needsUpdate = false;
- _renderer2.setRenderTarget(currentRenderTarget, activeCubeFace, activeMipmapLevel);
- };
- function VSMPass(shadow, camera) {
- var geometry = _objects.update(fullScreenMesh);
- shadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture;
- shadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;
- shadowMaterialVertical.uniforms.radius.value = shadow.radius;
- _renderer2.setRenderTarget(shadow.mapPass);
- _renderer2.clear();
- _renderer2.renderBufferDirect(camera, null, geometry, shadowMaterialVertical, fullScreenMesh, null);
- shadowMaterialHorizonal.uniforms.shadow_pass.value = shadow.mapPass.texture;
- shadowMaterialHorizonal.uniforms.resolution.value = shadow.mapSize;
- shadowMaterialHorizonal.uniforms.radius.value = shadow.radius;
- _renderer2.setRenderTarget(shadow.map);
- _renderer2.clear();
- _renderer2.renderBufferDirect(camera, null, geometry, shadowMaterialHorizonal, fullScreenMesh, null);
- }
- function getDepthMaterialVariant(useMorphing, useSkinning, useInstancing) {
- var index = useMorphing << 0 | useSkinning << 1 | useInstancing << 2;
- var material = _depthMaterials[index];
- if (material === void 0) {
- material = new MeshDepthMaterial({
- depthPacking: RGBADepthPacking,
- morphTargets: useMorphing,
- skinning: useSkinning
- });
- _depthMaterials[index] = material;
- }
- return material;
- }
- function getDistanceMaterialVariant(useMorphing, useSkinning, useInstancing) {
- var index = useMorphing << 0 | useSkinning << 1 | useInstancing << 2;
- var material = _distanceMaterials[index];
- if (material === void 0) {
- material = new MeshDistanceMaterial({
- morphTargets: useMorphing,
- skinning: useSkinning
- });
- _distanceMaterials[index] = material;
- }
- return material;
- }
- function getDepthMaterial(object, material, light, shadowCameraNear, shadowCameraFar, type) {
- var geometry = object.geometry;
- var result = null;
- var getMaterialVariant = getDepthMaterialVariant;
- var customMaterial = object.customDepthMaterial;
- if (light.isPointLight === true) {
- getMaterialVariant = getDistanceMaterialVariant;
- customMaterial = object.customDistanceMaterial;
- }
- if (customMaterial === void 0) {
- var useMorphing = false;
- if (material.morphTargets === true) {
- if (geometry.isBufferGeometry === true) {
- useMorphing = geometry.morphAttributes && geometry.morphAttributes.position && geometry.morphAttributes.position.length > 0;
- } else if (geometry.isGeometry === true) {
- useMorphing = geometry.morphTargets && geometry.morphTargets.length > 0;
- }
- }
- var useSkinning = false;
- if (object.isSkinnedMesh === true) {
- if (material.skinning === true) {
- useSkinning = true;
- } else {
- console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:", object);
- }
- }
- var useInstancing = object.isInstancedMesh === true;
- result = getMaterialVariant(useMorphing, useSkinning, useInstancing);
- } else {
- result = customMaterial;
- }
- if (_renderer2.localClippingEnabled && material.clipShadows === true && material.clippingPlanes.length !== 0) {
- var keyA = result.uuid, keyB = material.uuid;
- var materialsForVariant = _materialCache[keyA];
- if (materialsForVariant === void 0) {
- materialsForVariant = {};
- _materialCache[keyA] = materialsForVariant;
- }
- var cachedMaterial = materialsForVariant[keyB];
- if (cachedMaterial === void 0) {
- cachedMaterial = result.clone();
- materialsForVariant[keyB] = cachedMaterial;
- }
- result = cachedMaterial;
- }
- result.visible = material.visible;
- result.wireframe = material.wireframe;
- if (type === VSMShadowMap) {
- result.side = material.shadowSide !== null ? material.shadowSide : material.side;
- } else {
- result.side = material.shadowSide !== null ? material.shadowSide : shadowSide[material.side];
- }
- result.clipShadows = material.clipShadows;
- result.clippingPlanes = material.clippingPlanes;
- result.clipIntersection = material.clipIntersection;
- result.wireframeLinewidth = material.wireframeLinewidth;
- result.linewidth = material.linewidth;
- if (light.isPointLight === true && result.isMeshDistanceMaterial === true) {
- result.referencePosition.setFromMatrixPosition(light.matrixWorld);
- result.nearDistance = shadowCameraNear;
- result.farDistance = shadowCameraFar;
- }
- return result;
- }
- function renderObject(object, camera, shadowCamera, light, type) {
- if (object.visible === false)
- return;
- var visible = object.layers.test(camera.layers);
- if (visible && (object.isMesh || object.isLine || object.isPoints)) {
- if ((object.castShadow || object.receiveShadow && type === VSMShadowMap) && (!object.frustumCulled || _frustum.intersectsObject(object))) {
- object.modelViewMatrix.multiplyMatrices(shadowCamera.matrixWorldInverse, object.matrixWorld);
- var geometry = _objects.update(object);
- var material = object.material;
- if (Array.isArray(material)) {
- var groups = geometry.groups;
- for (var k = 0, kl = groups.length; k < kl; k++) {
- var group = groups[k];
- var groupMaterial = material[group.materialIndex];
- if (groupMaterial && groupMaterial.visible) {
- var depthMaterial = getDepthMaterial(object, groupMaterial, light, shadowCamera.near, shadowCamera.far, type);
- _renderer2.renderBufferDirect(shadowCamera, null, geometry, depthMaterial, object, group);
- }
- }
- } else if (material.visible) {
- var depthMaterial = getDepthMaterial(object, material, light, shadowCamera.near, shadowCamera.far, type);
- _renderer2.renderBufferDirect(shadowCamera, null, geometry, depthMaterial, object, null);
- }
- }
- }
- var children = object.children;
- for (var i2 = 0, l = children.length; i2 < l; i2++) {
- renderObject(children[i2], camera, shadowCamera, light, type);
- }
- }
- }
- function WebGLState(gl, extensions, capabilities) {
- var isWebGL2 = capabilities.isWebGL2;
- function ColorBuffer() {
- var locked = false;
- var color = new Vector4();
- var currentColorMask = null;
- var currentColorClear = new Vector4(0, 0, 0, 0);
- return {
- setMask: function(colorMask) {
- if (currentColorMask !== colorMask && !locked) {
- gl.colorMask(colorMask, colorMask, colorMask, colorMask);
- currentColorMask = colorMask;
- }
- },
- setLocked: function(lock) {
- locked = lock;
- },
- setClear: function(r, g, b, a, premultipliedAlpha) {
- if (premultipliedAlpha === true) {
- r *= a;
- g *= a;
- b *= a;
- }
- color.set(r, g, b, a);
- if (currentColorClear.equals(color) === false) {
- gl.clearColor(r, g, b, a);
- currentColorClear.copy(color);
- }
- },
- reset: function() {
- locked = false;
- currentColorMask = null;
- currentColorClear.set(-1, 0, 0, 0);
- }
- };
- }
- function DepthBuffer() {
- var locked = false;
- var currentDepthMask = null;
- var currentDepthFunc = null;
- var currentDepthClear = null;
- return {
- setTest: function(depthTest) {
- if (depthTest) {
- enable(2929);
- } else {
- disable(2929);
- }
- },
- setMask: function(depthMask) {
- if (currentDepthMask !== depthMask && !locked) {
- gl.depthMask(depthMask);
- currentDepthMask = depthMask;
- }
- },
- setFunc: function(depthFunc) {
- if (currentDepthFunc !== depthFunc) {
- if (depthFunc) {
- switch (depthFunc) {
- case NeverDepth:
- gl.depthFunc(512);
- break;
- case AlwaysDepth:
- gl.depthFunc(519);
- break;
- case LessDepth:
- gl.depthFunc(513);
- break;
- case LessEqualDepth:
- gl.depthFunc(515);
- break;
- case EqualDepth:
- gl.depthFunc(514);
- break;
- case GreaterEqualDepth:
- gl.depthFunc(518);
- break;
- case GreaterDepth:
- gl.depthFunc(516);
- break;
- case NotEqualDepth:
- gl.depthFunc(517);
- break;
- default:
- gl.depthFunc(515);
- }
- } else {
- gl.depthFunc(515);
- }
- currentDepthFunc = depthFunc;
- }
- },
- setLocked: function(lock) {
- locked = lock;
- },
- setClear: function(depth) {
- if (currentDepthClear !== depth) {
- gl.clearDepth(depth);
- currentDepthClear = depth;
- }
- },
- reset: function() {
- locked = false;
- currentDepthMask = null;
- currentDepthFunc = null;
- currentDepthClear = null;
- }
- };
- }
- function StencilBuffer() {
- var locked = false;
- var currentStencilMask = null;
- var currentStencilFunc = null;
- var currentStencilRef = null;
- var currentStencilFuncMask = null;
- var currentStencilFail = null;
- var currentStencilZFail = null;
- var currentStencilZPass = null;
- var currentStencilClear = null;
- return {
- setTest: function(stencilTest) {
- if (!locked) {
- if (stencilTest) {
- enable(2960);
- } else {
- disable(2960);
- }
- }
- },
- setMask: function(stencilMask) {
- if (currentStencilMask !== stencilMask && !locked) {
- gl.stencilMask(stencilMask);
- currentStencilMask = stencilMask;
- }
- },
- setFunc: function(stencilFunc, stencilRef, stencilMask) {
- if (currentStencilFunc !== stencilFunc || currentStencilRef !== stencilRef || currentStencilFuncMask !== stencilMask) {
- gl.stencilFunc(stencilFunc, stencilRef, stencilMask);
- currentStencilFunc = stencilFunc;
- currentStencilRef = stencilRef;
- currentStencilFuncMask = stencilMask;
- }
- },
- setOp: function(stencilFail, stencilZFail, stencilZPass) {
- if (currentStencilFail !== stencilFail || currentStencilZFail !== stencilZFail || currentStencilZPass !== stencilZPass) {
- gl.stencilOp(stencilFail, stencilZFail, stencilZPass);
- currentStencilFail = stencilFail;
- currentStencilZFail = stencilZFail;
- currentStencilZPass = stencilZPass;
- }
- },
- setLocked: function(lock) {
- locked = lock;
- },
- setClear: function(stencil) {
- if (currentStencilClear !== stencil) {
- gl.clearStencil(stencil);
- currentStencilClear = stencil;
- }
- },
- reset: function() {
- locked = false;
- currentStencilMask = null;
- currentStencilFunc = null;
- currentStencilRef = null;
- currentStencilFuncMask = null;
- currentStencilFail = null;
- currentStencilZFail = null;
- currentStencilZPass = null;
- currentStencilClear = null;
- }
- };
- }
- var colorBuffer = new ColorBuffer();
- var depthBuffer = new DepthBuffer();
- var stencilBuffer = new StencilBuffer();
- var maxVertexAttributes = gl.getParameter(34921);
- var newAttributes = new Uint8Array(maxVertexAttributes);
- var enabledAttributes = new Uint8Array(maxVertexAttributes);
- var attributeDivisors = new Uint8Array(maxVertexAttributes);
- var enabledCapabilities = {};
- var currentProgram = null;
- var currentBlendingEnabled = null;
- var currentBlending = null;
- var currentBlendEquation = null;
- var currentBlendSrc = null;
- var currentBlendDst = null;
- var currentBlendEquationAlpha = null;
- var currentBlendSrcAlpha = null;
- var currentBlendDstAlpha = null;
- var currentPremultipledAlpha = false;
- var currentFlipSided = null;
- var currentCullFace = null;
- var currentLineWidth = null;
- var currentPolygonOffsetFactor = null;
- var currentPolygonOffsetUnits = null;
- var maxTextures = gl.getParameter(35661);
- var lineWidthAvailable = false;
- var version = 0;
- var glVersion = gl.getParameter(7938);
- if (glVersion.indexOf("WebGL") !== -1) {
- version = parseFloat(/^WebGL\ ([0-9])/.exec(glVersion)[1]);
- lineWidthAvailable = version >= 1;
- } else if (glVersion.indexOf("OpenGL ES") !== -1) {
- version = parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(glVersion)[1]);
- lineWidthAvailable = version >= 2;
- }
- var currentTextureSlot = null;
- var currentBoundTextures = {};
- var currentScissor = new Vector4();
- var currentViewport = new Vector4();
- function createTexture(type, target, count) {
- var data = new Uint8Array(4);
- var texture = gl.createTexture();
- gl.bindTexture(type, texture);
- gl.texParameteri(type, 10241, 9728);
- gl.texParameteri(type, 10240, 9728);
- for (var i2 = 0; i2 < count; i2++) {
- gl.texImage2D(target + i2, 0, 6408, 1, 1, 0, 6408, 5121, data);
- }
- return texture;
- }
- var emptyTextures = {};
- emptyTextures[3553] = createTexture(3553, 3553, 1);
- emptyTextures[34067] = createTexture(34067, 34069, 6);
- colorBuffer.setClear(0, 0, 0, 1);
- depthBuffer.setClear(1);
- stencilBuffer.setClear(0);
- enable(2929);
- depthBuffer.setFunc(LessEqualDepth);
- setFlipSided(false);
- setCullFace(CullFaceBack);
- enable(2884);
- setBlending(NoBlending);
- function initAttributes() {
- for (var i2 = 0, l = newAttributes.length; i2 < l; i2++) {
- newAttributes[i2] = 0;
- }
- }
- function enableAttribute(attribute) {
- enableAttributeAndDivisor(attribute, 0);
- }
- function enableAttributeAndDivisor(attribute, meshPerAttribute) {
- newAttributes[attribute] = 1;
- if (enabledAttributes[attribute] === 0) {
- gl.enableVertexAttribArray(attribute);
- enabledAttributes[attribute] = 1;
- }
- if (attributeDivisors[attribute] !== meshPerAttribute) {
- var extension2 = isWebGL2 ? gl : extensions.get("ANGLE_instanced_arrays");
- extension2[isWebGL2 ? "vertexAttribDivisor" : "vertexAttribDivisorANGLE"](attribute, meshPerAttribute);
- attributeDivisors[attribute] = meshPerAttribute;
- }
- }
- function disableUnusedAttributes() {
- for (var i2 = 0, l = enabledAttributes.length; i2 !== l; ++i2) {
- if (enabledAttributes[i2] !== newAttributes[i2]) {
- gl.disableVertexAttribArray(i2);
- enabledAttributes[i2] = 0;
- }
- }
- }
- function enable(id) {
- if (enabledCapabilities[id] !== true) {
- gl.enable(id);
- enabledCapabilities[id] = true;
- }
- }
- function disable(id) {
- if (enabledCapabilities[id] !== false) {
- gl.disable(id);
- enabledCapabilities[id] = false;
- }
- }
- function useProgram(program) {
- if (currentProgram !== program) {
- gl.useProgram(program);
- currentProgram = program;
- return true;
- }
- return false;
- }
- var equationToGL = {
- [AddEquation]: 32774,
- [SubtractEquation]: 32778,
- [ReverseSubtractEquation]: 32779
- };
- if (isWebGL2) {
- equationToGL[MinEquation] = 32775;
- equationToGL[MaxEquation] = 32776;
- } else {
- var extension = extensions.get("EXT_blend_minmax");
- if (extension !== null) {
- equationToGL[MinEquation] = extension.MIN_EXT;
- equationToGL[MaxEquation] = extension.MAX_EXT;
- }
- }
- var factorToGL = {
- [ZeroFactor]: 0,
- [OneFactor]: 1,
- [SrcColorFactor]: 768,
- [SrcAlphaFactor]: 770,
- [SrcAlphaSaturateFactor]: 776,
- [DstColorFactor]: 774,
- [DstAlphaFactor]: 772,
- [OneMinusSrcColorFactor]: 769,
- [OneMinusSrcAlphaFactor]: 771,
- [OneMinusDstColorFactor]: 775,
- [OneMinusDstAlphaFactor]: 773
- };
- function setBlending(blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha) {
- if (blending === NoBlending) {
- if (currentBlendingEnabled) {
- disable(3042);
- currentBlendingEnabled = false;
- }
- return;
- }
- if (!currentBlendingEnabled) {
- enable(3042);
- currentBlendingEnabled = true;
- }
- if (blending !== CustomBlending) {
- if (blending !== currentBlending || premultipliedAlpha !== currentPremultipledAlpha) {
- if (currentBlendEquation !== AddEquation || currentBlendEquationAlpha !== AddEquation) {
- gl.blendEquation(32774);
- currentBlendEquation = AddEquation;
- currentBlendEquationAlpha = AddEquation;
- }
- if (premultipliedAlpha) {
- switch (blending) {
- case NormalBlending:
- gl.blendFuncSeparate(1, 771, 1, 771);
- break;
- case AdditiveBlending:
- gl.blendFunc(1, 1);
- break;
- case SubtractiveBlending:
- gl.blendFuncSeparate(0, 0, 769, 771);
- break;
- case MultiplyBlending:
- gl.blendFuncSeparate(0, 768, 0, 770);
- break;
- default:
- console.error("THREE.WebGLState: Invalid blending: ", blending);
- break;
- }
- } else {
- switch (blending) {
- case NormalBlending:
- gl.blendFuncSeparate(770, 771, 1, 771);
- break;
- case AdditiveBlending:
- gl.blendFunc(770, 1);
- break;
- case SubtractiveBlending:
- gl.blendFunc(0, 769);
- break;
- case MultiplyBlending:
- gl.blendFunc(0, 768);
- break;
- default:
- console.error("THREE.WebGLState: Invalid blending: ", blending);
- break;
- }
- }
- currentBlendSrc = null;
- currentBlendDst = null;
- currentBlendSrcAlpha = null;
- currentBlendDstAlpha = null;
- currentBlending = blending;
- currentPremultipledAlpha = premultipliedAlpha;
- }
- return;
- }
- blendEquationAlpha = blendEquationAlpha || blendEquation;
- blendSrcAlpha = blendSrcAlpha || blendSrc;
- blendDstAlpha = blendDstAlpha || blendDst;
- if (blendEquation !== currentBlendEquation || blendEquationAlpha !== currentBlendEquationAlpha) {
- gl.blendEquationSeparate(equationToGL[blendEquation], equationToGL[blendEquationAlpha]);
- currentBlendEquation = blendEquation;
- currentBlendEquationAlpha = blendEquationAlpha;
- }
- if (blendSrc !== currentBlendSrc || blendDst !== currentBlendDst || blendSrcAlpha !== currentBlendSrcAlpha || blendDstAlpha !== currentBlendDstAlpha) {
- gl.blendFuncSeparate(factorToGL[blendSrc], factorToGL[blendDst], factorToGL[blendSrcAlpha], factorToGL[blendDstAlpha]);
- currentBlendSrc = blendSrc;
- currentBlendDst = blendDst;
- currentBlendSrcAlpha = blendSrcAlpha;
- currentBlendDstAlpha = blendDstAlpha;
- }
- currentBlending = blending;
- currentPremultipledAlpha = null;
- }
- function setMaterial(material, frontFaceCW) {
- material.side === DoubleSide ? disable(2884) : enable(2884);
- var flipSided = material.side === BackSide;
- if (frontFaceCW)
- flipSided = !flipSided;
- setFlipSided(flipSided);
- 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);
- depthBuffer.setFunc(material.depthFunc);
- depthBuffer.setTest(material.depthTest);
- depthBuffer.setMask(material.depthWrite);
- colorBuffer.setMask(material.colorWrite);
- var stencilWrite = material.stencilWrite;
- stencilBuffer.setTest(stencilWrite);
- if (stencilWrite) {
- stencilBuffer.setMask(material.stencilWriteMask);
- stencilBuffer.setFunc(material.stencilFunc, material.stencilRef, material.stencilFuncMask);
- stencilBuffer.setOp(material.stencilFail, material.stencilZFail, material.stencilZPass);
- }
- setPolygonOffset(material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits);
- }
- function setFlipSided(flipSided) {
- if (currentFlipSided !== flipSided) {
- if (flipSided) {
- gl.frontFace(2304);
- } else {
- gl.frontFace(2305);
- }
- currentFlipSided = flipSided;
- }
- }
- function setCullFace(cullFace) {
- if (cullFace !== CullFaceNone) {
- enable(2884);
- if (cullFace !== currentCullFace) {
- if (cullFace === CullFaceBack) {
- gl.cullFace(1029);
- } else if (cullFace === CullFaceFront) {
- gl.cullFace(1028);
- } else {
- gl.cullFace(1032);
- }
- }
- } else {
- disable(2884);
- }
- currentCullFace = cullFace;
- }
- function setLineWidth(width) {
- if (width !== currentLineWidth) {
- if (lineWidthAvailable)
- gl.lineWidth(width);
- currentLineWidth = width;
- }
- }
- function setPolygonOffset(polygonOffset, factor, units) {
- if (polygonOffset) {
- enable(32823);
- if (currentPolygonOffsetFactor !== factor || currentPolygonOffsetUnits !== units) {
- gl.polygonOffset(factor, units);
- currentPolygonOffsetFactor = factor;
- currentPolygonOffsetUnits = units;
- }
- } else {
- disable(32823);
- }
- }
- function setScissorTest(scissorTest) {
- if (scissorTest) {
- enable(3089);
- } else {
- disable(3089);
- }
- }
- function activeTexture(webglSlot) {
- if (webglSlot === void 0)
- webglSlot = 33984 + maxTextures - 1;
- if (currentTextureSlot !== webglSlot) {
- gl.activeTexture(webglSlot);
- currentTextureSlot = webglSlot;
- }
- }
- function bindTexture(webglType, webglTexture) {
- if (currentTextureSlot === null) {
- activeTexture();
- }
- var boundTexture = currentBoundTextures[currentTextureSlot];
- if (boundTexture === void 0) {
- boundTexture = { type: void 0, texture: void 0 };
- currentBoundTextures[currentTextureSlot] = boundTexture;
- }
- if (boundTexture.type !== webglType || boundTexture.texture !== webglTexture) {
- gl.bindTexture(webglType, webglTexture || emptyTextures[webglType]);
- boundTexture.type = webglType;
- boundTexture.texture = webglTexture;
- }
- }
- function unbindTexture() {
- var boundTexture = currentBoundTextures[currentTextureSlot];
- if (boundTexture !== void 0 && boundTexture.type !== void 0) {
- gl.bindTexture(boundTexture.type, null);
- boundTexture.type = void 0;
- boundTexture.texture = void 0;
- }
- }
- function compressedTexImage2D() {
- try {
- gl.compressedTexImage2D.apply(gl, arguments);
- } catch (error) {
- console.error("THREE.WebGLState:", error);
- }
- }
- function texImage2D() {
- try {
- gl.texImage2D.apply(gl, arguments);
- } catch (error) {
- console.error("THREE.WebGLState:", error);
- }
- }
- function texImage3D() {
- try {
- gl.texImage3D.apply(gl, arguments);
- } catch (error) {
- console.error("THREE.WebGLState:", error);
- }
- }
- function scissor(scissor2) {
- if (currentScissor.equals(scissor2) === false) {
- gl.scissor(scissor2.x, scissor2.y, scissor2.z, scissor2.w);
- currentScissor.copy(scissor2);
- }
- }
- function viewport(viewport2) {
- if (currentViewport.equals(viewport2) === false) {
- gl.viewport(viewport2.x, viewport2.y, viewport2.z, viewport2.w);
- currentViewport.copy(viewport2);
- }
- }
- function reset() {
- for (var i2 = 0; i2 < enabledAttributes.length; i2++) {
- if (enabledAttributes[i2] === 1) {
- gl.disableVertexAttribArray(i2);
- enabledAttributes[i2] = 0;
- }
- }
- enabledCapabilities = {};
- currentTextureSlot = null;
- currentBoundTextures = {};
- currentProgram = null;
- currentBlending = null;
- currentFlipSided = null;
- currentCullFace = null;
- colorBuffer.reset();
- depthBuffer.reset();
- stencilBuffer.reset();
- }
- return {
- buffers: {
- color: colorBuffer,
- depth: depthBuffer,
- stencil: stencilBuffer
- },
- initAttributes,
- enableAttribute,
- enableAttributeAndDivisor,
- disableUnusedAttributes,
- enable,
- disable,
- useProgram,
- setBlending,
- setMaterial,
- setFlipSided,
- setCullFace,
- setLineWidth,
- setPolygonOffset,
- setScissorTest,
- activeTexture,
- bindTexture,
- unbindTexture,
- compressedTexImage2D,
- texImage2D,
- texImage3D,
- scissor,
- viewport,
- reset
- };
- }
- function WebGLTextures(_gl, extensions, state, properties, capabilities, utils, info) {
- var isWebGL2 = capabilities.isWebGL2;
- var maxTextures = capabilities.maxTextures;
- var maxCubemapSize = capabilities.maxCubemapSize;
- var maxTextureSize = capabilities.maxTextureSize;
- var maxSamples = capabilities.maxSamples;
- var _videoTextures = /* @__PURE__ */ new WeakMap();
- var _canvas2;
- var useOffscreenCanvas = false;
- try {
- useOffscreenCanvas = typeof OffscreenCanvas !== "undefined" && new OffscreenCanvas(1, 1).getContext("2d") !== null;
- } catch (err) {
- }
- function createCanvas(width, height) {
- return useOffscreenCanvas ? new OffscreenCanvas(width, height) : document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
- }
- function resizeImage(image, needsPowerOfTwo, needsNewCanvas, maxSize) {
- var scale = 1;
- if (image.width > maxSize || image.height > maxSize) {
- scale = maxSize / Math.max(image.width, image.height);
- }
- if (scale < 1 || needsPowerOfTwo === true) {
- if (typeof HTMLImageElement !== "undefined" && image instanceof HTMLImageElement || typeof HTMLCanvasElement !== "undefined" && image instanceof HTMLCanvasElement || typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) {
- var floor = needsPowerOfTwo ? MathUtils.floorPowerOfTwo : Math.floor;
- var width = floor(scale * image.width);
- var height = floor(scale * image.height);
- if (_canvas2 === void 0)
- _canvas2 = createCanvas(width, height);
- var canvas = needsNewCanvas ? createCanvas(width, height) : _canvas2;
- canvas.width = width;
- canvas.height = height;
- var context = canvas.getContext("2d");
- context.drawImage(image, 0, 0, width, height);
- console.warn("THREE.WebGLRenderer: Texture has been resized from (" + image.width + "x" + image.height + ") to (" + width + "x" + height + ").");
- return canvas;
- } else {
- if ("data" in image) {
- console.warn("THREE.WebGLRenderer: Image in DataTexture is too big (" + image.width + "x" + image.height + ").");
- }
- return image;
- }
- }
- return image;
- }
- function isPowerOfTwo(image) {
- return MathUtils.isPowerOfTwo(image.width) && MathUtils.isPowerOfTwo(image.height);
- }
- function textureNeedsPowerOfTwo(texture) {
- if (isWebGL2)
- return false;
- return texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping || texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
- }
- function textureNeedsGenerateMipmaps(texture, supportsMips) {
- return texture.generateMipmaps && supportsMips && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
- }
- function generateMipmap(target, texture, width, height) {
- _gl.generateMipmap(target);
- var textureProperties = properties.get(texture);
- textureProperties.__maxMipLevel = Math.log(Math.max(width, height)) * Math.LOG2E;
- }
- function getInternalFormat(internalFormatName, glFormat, glType) {
- if (isWebGL2 === false)
- return glFormat;
- if (internalFormatName !== null) {
- if (_gl[internalFormatName] !== void 0)
- return _gl[internalFormatName];
- console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '" + internalFormatName + "'");
- }
- var internalFormat = glFormat;
- if (glFormat === 6403) {
- if (glType === 5126)
- internalFormat = 33326;
- if (glType === 5131)
- internalFormat = 33325;
- if (glType === 5121)
- internalFormat = 33321;
- }
- if (glFormat === 6407) {
- if (glType === 5126)
- internalFormat = 34837;
- if (glType === 5131)
- internalFormat = 34843;
- if (glType === 5121)
- internalFormat = 32849;
- }
- if (glFormat === 6408) {
- if (glType === 5126)
- internalFormat = 34836;
- if (glType === 5131)
- internalFormat = 34842;
- if (glType === 5121)
- internalFormat = 32856;
- }
- if (internalFormat === 33325 || internalFormat === 33326 || internalFormat === 34842 || internalFormat === 34836) {
- extensions.get("EXT_color_buffer_float");
- } else if (internalFormat === 34843 || internalFormat === 34837) {
- console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead.");
- }
- return internalFormat;
- }
- function filterFallback(f) {
- if (f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter) {
- return 9728;
- }
- return 9729;
- }
- function onTextureDispose(event) {
- var texture = event.target;
- texture.removeEventListener("dispose", onTextureDispose);
- deallocateTexture(texture);
- if (texture.isVideoTexture) {
- _videoTextures.delete(texture);
- }
- info.memory.textures--;
- }
- function onRenderTargetDispose(event) {
- var renderTarget = event.target;
- renderTarget.removeEventListener("dispose", onRenderTargetDispose);
- deallocateRenderTarget(renderTarget);
- info.memory.textures--;
- }
- function deallocateTexture(texture) {
- var textureProperties = properties.get(texture);
- if (textureProperties.__webglInit === void 0)
- return;
- _gl.deleteTexture(textureProperties.__webglTexture);
- properties.remove(texture);
- }
- function deallocateRenderTarget(renderTarget) {
- var renderTargetProperties = properties.get(renderTarget);
- var textureProperties = properties.get(renderTarget.texture);
- if (!renderTarget)
- return;
- if (textureProperties.__webglTexture !== void 0) {
- _gl.deleteTexture(textureProperties.__webglTexture);
- }
- if (renderTarget.depthTexture) {
- renderTarget.depthTexture.dispose();
- }
- if (renderTarget.isWebGLCubeRenderTarget) {
- for (var i2 = 0; i2 < 6; i2++) {
- _gl.deleteFramebuffer(renderTargetProperties.__webglFramebuffer[i2]);
- if (renderTargetProperties.__webglDepthbuffer)
- _gl.deleteRenderbuffer(renderTargetProperties.__webglDepthbuffer[i2]);
- }
- } else {
- _gl.deleteFramebuffer(renderTargetProperties.__webglFramebuffer);
- if (renderTargetProperties.__webglDepthbuffer)
- _gl.deleteRenderbuffer(renderTargetProperties.__webglDepthbuffer);
- }
- if (renderTarget.isWebGLMultiviewRenderTarget) {
- _gl.deleteTexture(renderTargetProperties.__webglColorTexture);
- _gl.deleteTexture(renderTargetProperties.__webglDepthStencilTexture);
- info.memory.textures -= 2;
- for (var i2 = 0, il = renderTargetProperties.__webglViewFramebuffers.length; i2 < il; i2++) {
- _gl.deleteFramebuffer(renderTargetProperties.__webglViewFramebuffers[i2]);
- }
- }
- properties.remove(renderTarget.texture);
- properties.remove(renderTarget);
- }
- var textureUnits = 0;
- function resetTextureUnits() {
- textureUnits = 0;
- }
- function allocateTextureUnit() {
- var textureUnit = textureUnits;
- if (textureUnit >= maxTextures) {
- console.warn("THREE.WebGLTextures: Trying to use " + textureUnit + " texture units while this GPU supports only " + maxTextures);
- }
- textureUnits += 1;
- return textureUnit;
- }
- function setTexture2D(texture, slot) {
- var textureProperties = properties.get(texture);
- if (texture.isVideoTexture)
- updateVideoTexture(texture);
- if (texture.version > 0 && textureProperties.__version !== texture.version) {
- var image = texture.image;
- if (image === void 0) {
- console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");
- } else if (image.complete === false) {
- console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");
- } else {
- uploadTexture(textureProperties, texture, slot);
- return;
- }
- }
- state.activeTexture(33984 + slot);
- state.bindTexture(3553, textureProperties.__webglTexture);
- }
- function setTexture2DArray(texture, slot) {
- var textureProperties = properties.get(texture);
- if (texture.version > 0 && textureProperties.__version !== texture.version) {
- uploadTexture(textureProperties, texture, slot);
- return;
- }
- state.activeTexture(33984 + slot);
- state.bindTexture(35866, textureProperties.__webglTexture);
- }
- function setTexture3D(texture, slot) {
- var textureProperties = properties.get(texture);
- if (texture.version > 0 && textureProperties.__version !== texture.version) {
- uploadTexture(textureProperties, texture, slot);
- return;
- }
- state.activeTexture(33984 + slot);
- state.bindTexture(32879, textureProperties.__webglTexture);
- }
- function setTextureCube(texture, slot) {
- if (texture.image.length !== 6)
- return;
- var textureProperties = properties.get(texture);
- if (texture.version > 0 && textureProperties.__version !== texture.version) {
- initTexture(textureProperties, texture);
- state.activeTexture(33984 + slot);
- state.bindTexture(34067, textureProperties.__webglTexture);
- _gl.pixelStorei(37440, texture.flipY);
- var isCompressed = texture && (texture.isCompressedTexture || texture.image[0].isCompressedTexture);
- var isDataTexture = texture.image[0] && texture.image[0].isDataTexture;
- var cubeImage = [];
- for (var i2 = 0; i2 < 6; i2++) {
- if (!isCompressed && !isDataTexture) {
- cubeImage[i2] = resizeImage(texture.image[i2], false, true, maxCubemapSize);
- } else {
- cubeImage[i2] = isDataTexture ? texture.image[i2].image : texture.image[i2];
- }
- }
- var image = cubeImage[0], supportsMips = isPowerOfTwo(image) || isWebGL2, glFormat = utils.convert(texture.format), glType = utils.convert(texture.type), glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType);
- setTextureParameters(34067, texture, supportsMips);
- var mipmaps;
- if (isCompressed) {
- for (var i2 = 0; i2 < 6; i2++) {
- mipmaps = cubeImage[i2].mipmaps;
- for (var j = 0; j < mipmaps.length; j++) {
- var mipmap = mipmaps[j];
- if (texture.format !== RGBAFormat && texture.format !== RGBFormat) {
- if (glFormat !== null) {
- state.compressedTexImage2D(34069 + i2, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
- } else {
- console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");
- }
- } else {
- state.texImage2D(34069 + i2, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
- }
- }
- }
- textureProperties.__maxMipLevel = mipmaps.length - 1;
- } else {
- mipmaps = texture.mipmaps;
- for (var i2 = 0; i2 < 6; i2++) {
- if (isDataTexture) {
- state.texImage2D(34069 + i2, 0, glInternalFormat, cubeImage[i2].width, cubeImage[i2].height, 0, glFormat, glType, cubeImage[i2].data);
- for (var j = 0; j < mipmaps.length; j++) {
- var mipmap = mipmaps[j];
- var mipmapImage = mipmap.image[i2].image;
- state.texImage2D(34069 + i2, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data);
- }
- } else {
- state.texImage2D(34069 + i2, 0, glInternalFormat, glFormat, glType, cubeImage[i2]);
- for (var j = 0; j < mipmaps.length; j++) {
- var mipmap = mipmaps[j];
- state.texImage2D(34069 + i2, j + 1, glInternalFormat, glFormat, glType, mipmap.image[i2]);
- }
- }
- }
- textureProperties.__maxMipLevel = mipmaps.length;
- }
- if (textureNeedsGenerateMipmaps(texture, supportsMips)) {
- generateMipmap(34067, texture, image.width, image.height);
- }
- textureProperties.__version = texture.version;
- if (texture.onUpdate)
- texture.onUpdate(texture);
- } else {
- state.activeTexture(33984 + slot);
- state.bindTexture(34067, textureProperties.__webglTexture);
- }
- }
- function setTextureCubeDynamic(texture, slot) {
- state.activeTexture(33984 + slot);
- state.bindTexture(34067, properties.get(texture).__webglTexture);
- }
- var wrappingToGL = {
- [RepeatWrapping]: 10497,
- [ClampToEdgeWrapping]: 33071,
- [MirroredRepeatWrapping]: 33648
- };
- var filterToGL = {
- [NearestFilter]: 9728,
- [NearestMipmapNearestFilter]: 9984,
- [NearestMipmapLinearFilter]: 9986,
- [LinearFilter]: 9729,
- [LinearMipmapNearestFilter]: 9985,
- [LinearMipmapLinearFilter]: 9987
- };
- function setTextureParameters(textureType, texture, supportsMips) {
- if (supportsMips) {
- _gl.texParameteri(textureType, 10242, wrappingToGL[texture.wrapS]);
- _gl.texParameteri(textureType, 10243, wrappingToGL[texture.wrapT]);
- if (textureType === 32879 || textureType === 35866) {
- _gl.texParameteri(textureType, 32882, wrappingToGL[texture.wrapR]);
- }
- _gl.texParameteri(textureType, 10240, filterToGL[texture.magFilter]);
- _gl.texParameteri(textureType, 10241, filterToGL[texture.minFilter]);
- } else {
- _gl.texParameteri(textureType, 10242, 33071);
- _gl.texParameteri(textureType, 10243, 33071);
- if (textureType === 32879 || textureType === 35866) {
- _gl.texParameteri(textureType, 32882, 33071);
- }
- if (texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping) {
- console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.");
- }
- _gl.texParameteri(textureType, 10240, filterFallback(texture.magFilter));
- _gl.texParameteri(textureType, 10241, filterFallback(texture.minFilter));
- if (texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter) {
- console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.");
- }
- }
- var extension = extensions.get("EXT_texture_filter_anisotropic");
- if (extension) {
- if (texture.type === FloatType && extensions.get("OES_texture_float_linear") === null)
- return;
- if (texture.type === HalfFloatType && (isWebGL2 || extensions.get("OES_texture_half_float_linear")) === null)
- return;
- if (texture.anisotropy > 1 || properties.get(texture).__currentAnisotropy) {
- _gl.texParameterf(textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(texture.anisotropy, capabilities.getMaxAnisotropy()));
- properties.get(texture).__currentAnisotropy = texture.anisotropy;
- }
- }
- }
- function initTexture(textureProperties, texture) {
- if (textureProperties.__webglInit === void 0) {
- textureProperties.__webglInit = true;
- texture.addEventListener("dispose", onTextureDispose);
- textureProperties.__webglTexture = _gl.createTexture();
- info.memory.textures++;
- }
- }
- function uploadTexture(textureProperties, texture, slot) {
- var textureType = 3553;
- if (texture.isDataTexture2DArray)
- textureType = 35866;
- if (texture.isDataTexture3D)
- textureType = 32879;
- initTexture(textureProperties, texture);
- state.activeTexture(33984 + slot);
- state.bindTexture(textureType, textureProperties.__webglTexture);
- _gl.pixelStorei(37440, texture.flipY);
- _gl.pixelStorei(37441, texture.premultiplyAlpha);
- _gl.pixelStorei(3317, texture.unpackAlignment);
- var needsPowerOfTwo = textureNeedsPowerOfTwo(texture) && isPowerOfTwo(texture.image) === false;
- var image = resizeImage(texture.image, needsPowerOfTwo, false, maxTextureSize);
- var supportsMips = isPowerOfTwo(image) || isWebGL2, glFormat = utils.convert(texture.format), glType = utils.convert(texture.type), glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType);
- setTextureParameters(textureType, texture, supportsMips);
- var mipmap, mipmaps = texture.mipmaps;
- if (texture.isDepthTexture) {
- glInternalFormat = 6402;
- if (texture.type === FloatType) {
- if (isWebGL2 === false)
- throw new Error("Float Depth Texture only supported in WebGL2.0");
- glInternalFormat = 36012;
- } else if (isWebGL2) {
- glInternalFormat = 33189;
- }
- if (texture.format === DepthFormat && glInternalFormat === 6402) {
- if (texture.type !== UnsignedShortType && texture.type !== UnsignedIntType) {
- console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.");
- texture.type = UnsignedShortType;
- glType = utils.convert(texture.type);
- }
- }
- if (texture.format === DepthStencilFormat) {
- glInternalFormat = 34041;
- if (texture.type !== UnsignedInt248Type) {
- console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.");
- texture.type = UnsignedInt248Type;
- glType = utils.convert(texture.type);
- }
- }
- state.texImage2D(3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null);
- } else if (texture.isDataTexture) {
- if (mipmaps.length > 0 && supportsMips) {
- for (var i2 = 0, il = mipmaps.length; i2 < il; i2++) {
- mipmap = mipmaps[i2];
- state.texImage2D(3553, i2, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
- }
- texture.generateMipmaps = false;
- textureProperties.__maxMipLevel = mipmaps.length - 1;
- } else {
- state.texImage2D(3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data);
- textureProperties.__maxMipLevel = 0;
- }
- } else if (texture.isCompressedTexture) {
- for (var i2 = 0, il = mipmaps.length; i2 < il; i2++) {
- mipmap = mipmaps[i2];
- if (texture.format !== RGBAFormat && texture.format !== RGBFormat) {
- if (glFormat !== null) {
- state.compressedTexImage2D(3553, i2, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
- } else {
- console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");
- }
- } else {
- state.texImage2D(3553, i2, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
- }
- }
- textureProperties.__maxMipLevel = mipmaps.length - 1;
- } else if (texture.isDataTexture2DArray) {
- state.texImage3D(35866, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
- textureProperties.__maxMipLevel = 0;
- } else if (texture.isDataTexture3D) {
- state.texImage3D(32879, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
- textureProperties.__maxMipLevel = 0;
- } else {
- if (mipmaps.length > 0 && supportsMips) {
- for (var i2 = 0, il = mipmaps.length; i2 < il; i2++) {
- mipmap = mipmaps[i2];
- state.texImage2D(3553, i2, glInternalFormat, glFormat, glType, mipmap);
- }
- texture.generateMipmaps = false;
- textureProperties.__maxMipLevel = mipmaps.length - 1;
- } else {
- state.texImage2D(3553, 0, glInternalFormat, glFormat, glType, image);
- textureProperties.__maxMipLevel = 0;
- }
- }
- if (textureNeedsGenerateMipmaps(texture, supportsMips)) {
- generateMipmap(textureType, texture, image.width, image.height);
- }
- textureProperties.__version = texture.version;
- if (texture.onUpdate)
- texture.onUpdate(texture);
- }
- function setupFrameBufferTexture(framebuffer, renderTarget, attachment, textureTarget) {
- var glFormat = utils.convert(renderTarget.texture.format);
- var glType = utils.convert(renderTarget.texture.type);
- var glInternalFormat = getInternalFormat(renderTarget.texture.internalFormat, glFormat, glType);
- state.texImage2D(textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null);
- _gl.bindFramebuffer(36160, framebuffer);
- _gl.framebufferTexture2D(36160, attachment, textureTarget, properties.get(renderTarget.texture).__webglTexture, 0);
- _gl.bindFramebuffer(36160, null);
- }
- function setupRenderBufferStorage(renderbuffer, renderTarget, isMultisample) {
- _gl.bindRenderbuffer(36161, renderbuffer);
- if (renderTarget.depthBuffer && !renderTarget.stencilBuffer) {
- if (isMultisample) {
- var samples = getRenderTargetSamples(renderTarget);
- _gl.renderbufferStorageMultisample(36161, samples, 33189, renderTarget.width, renderTarget.height);
- } else {
- _gl.renderbufferStorage(36161, 33189, renderTarget.width, renderTarget.height);
- }
- _gl.framebufferRenderbuffer(36160, 36096, 36161, renderbuffer);
- } else if (renderTarget.depthBuffer && renderTarget.stencilBuffer) {
- if (isMultisample) {
- var samples = getRenderTargetSamples(renderTarget);
- _gl.renderbufferStorageMultisample(36161, samples, 35056, renderTarget.width, renderTarget.height);
- } else {
- _gl.renderbufferStorage(36161, 34041, renderTarget.width, renderTarget.height);
- }
- _gl.framebufferRenderbuffer(36160, 33306, 36161, renderbuffer);
- } else {
- var glFormat = utils.convert(renderTarget.texture.format);
- var glType = utils.convert(renderTarget.texture.type);
- var glInternalFormat = getInternalFormat(renderTarget.texture.internalFormat, glFormat, glType);
- if (isMultisample) {
- var samples = getRenderTargetSamples(renderTarget);
- _gl.renderbufferStorageMultisample(36161, samples, glInternalFormat, renderTarget.width, renderTarget.height);
- } else {
- _gl.renderbufferStorage(36161, glInternalFormat, renderTarget.width, renderTarget.height);
- }
- }
- _gl.bindRenderbuffer(36161, null);
- }
- function setupDepthTexture(framebuffer, renderTarget) {
- var isCube = renderTarget && renderTarget.isWebGLCubeRenderTarget;
- if (isCube)
- throw new Error("Depth Texture with cube render targets is not supported");
- _gl.bindFramebuffer(36160, framebuffer);
- if (!(renderTarget.depthTexture && renderTarget.depthTexture.isDepthTexture)) {
- throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");
- }
- if (!properties.get(renderTarget.depthTexture).__webglTexture || renderTarget.depthTexture.image.width !== renderTarget.width || renderTarget.depthTexture.image.height !== renderTarget.height) {
- renderTarget.depthTexture.image.width = renderTarget.width;
- renderTarget.depthTexture.image.height = renderTarget.height;
- renderTarget.depthTexture.needsUpdate = true;
- }
- setTexture2D(renderTarget.depthTexture, 0);
- var webglDepthTexture = properties.get(renderTarget.depthTexture).__webglTexture;
- if (renderTarget.depthTexture.format === DepthFormat) {
- _gl.framebufferTexture2D(36160, 36096, 3553, webglDepthTexture, 0);
- } else if (renderTarget.depthTexture.format === DepthStencilFormat) {
- _gl.framebufferTexture2D(36160, 33306, 3553, webglDepthTexture, 0);
- } else {
- throw new Error("Unknown depthTexture format");
- }
- }
- function setupDepthRenderbuffer(renderTarget) {
- var renderTargetProperties = properties.get(renderTarget);
- var isCube = renderTarget.isWebGLCubeRenderTarget === true;
- if (renderTarget.depthTexture) {
- if (isCube)
- throw new Error("target.depthTexture not supported in Cube render targets");
- setupDepthTexture(renderTargetProperties.__webglFramebuffer, renderTarget);
- } else {
- if (isCube) {
- renderTargetProperties.__webglDepthbuffer = [];
- for (var i2 = 0; i2 < 6; i2++) {
- _gl.bindFramebuffer(36160, renderTargetProperties.__webglFramebuffer[i2]);
- renderTargetProperties.__webglDepthbuffer[i2] = _gl.createRenderbuffer();
- setupRenderBufferStorage(renderTargetProperties.__webglDepthbuffer[i2], renderTarget);
- }
- } else {
- _gl.bindFramebuffer(36160, renderTargetProperties.__webglFramebuffer);
- renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();
- setupRenderBufferStorage(renderTargetProperties.__webglDepthbuffer, renderTarget);
- }
- }
- _gl.bindFramebuffer(36160, null);
- }
- function setupRenderTarget(renderTarget) {
- var renderTargetProperties = properties.get(renderTarget);
- var textureProperties = properties.get(renderTarget.texture);
- renderTarget.addEventListener("dispose", onRenderTargetDispose);
- textureProperties.__webglTexture = _gl.createTexture();
- info.memory.textures++;
- var isCube = renderTarget.isWebGLCubeRenderTarget === true;
- var isMultisample = renderTarget.isWebGLMultisampleRenderTarget === true;
- var isMultiview = renderTarget.isWebGLMultiviewRenderTarget === true;
- var supportsMips = isPowerOfTwo(renderTarget) || isWebGL2;
- if (isCube) {
- renderTargetProperties.__webglFramebuffer = [];
- for (var i2 = 0; i2 < 6; i2++) {
- renderTargetProperties.__webglFramebuffer[i2] = _gl.createFramebuffer();
- }
- } else {
- renderTargetProperties.__webglFramebuffer = _gl.createFramebuffer();
- if (isMultisample) {
- if (isWebGL2) {
- renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
- renderTargetProperties.__webglColorRenderbuffer = _gl.createRenderbuffer();
- _gl.bindRenderbuffer(36161, renderTargetProperties.__webglColorRenderbuffer);
- var glFormat = utils.convert(renderTarget.texture.format);
- var glType = utils.convert(renderTarget.texture.type);
- var glInternalFormat = getInternalFormat(renderTarget.texture.internalFormat, glFormat, glType);
- var samples = getRenderTargetSamples(renderTarget);
- _gl.renderbufferStorageMultisample(36161, samples, glInternalFormat, renderTarget.width, renderTarget.height);
- _gl.bindFramebuffer(36160, renderTargetProperties.__webglMultisampledFramebuffer);
- _gl.framebufferRenderbuffer(36160, 36064, 36161, renderTargetProperties.__webglColorRenderbuffer);
- _gl.bindRenderbuffer(36161, null);
- if (renderTarget.depthBuffer) {
- renderTargetProperties.__webglDepthRenderbuffer = _gl.createRenderbuffer();
- setupRenderBufferStorage(renderTargetProperties.__webglDepthRenderbuffer, renderTarget, true);
- }
- _gl.bindFramebuffer(36160, null);
- } else {
- console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");
- }
- } else if (isMultiview) {
- var width = renderTarget.width;
- var height = renderTarget.height;
- var numViews = renderTarget.numViews;
- _gl.bindFramebuffer(36160, renderTargetProperties.__webglFramebuffer);
- var ext = extensions.get("OVR_multiview2");
- info.memory.textures += 2;
- var colorTexture = _gl.createTexture();
- _gl.bindTexture(35866, colorTexture);
- _gl.texParameteri(35866, 10240, 9728);
- _gl.texParameteri(35866, 10241, 9728);
- _gl.texImage3D(35866, 0, 32856, width, height, numViews, 0, 6408, 5121, null);
- ext.framebufferTextureMultiviewOVR(36160, 36064, colorTexture, 0, 0, numViews);
- var depthStencilTexture = _gl.createTexture();
- _gl.bindTexture(35866, depthStencilTexture);
- _gl.texParameteri(35866, 10240, 9728);
- _gl.texParameteri(35866, 10241, 9728);
- _gl.texImage3D(35866, 0, 35056, width, height, numViews, 0, 34041, 34042, null);
- ext.framebufferTextureMultiviewOVR(36160, 33306, depthStencilTexture, 0, 0, numViews);
- var viewFramebuffers = new Array(numViews);
- for (var i2 = 0; i2 < numViews; ++i2) {
- viewFramebuffers[i2] = _gl.createFramebuffer();
- _gl.bindFramebuffer(36160, viewFramebuffers[i2]);
- _gl.framebufferTextureLayer(36160, 36064, colorTexture, 0, i2);
- }
- renderTargetProperties.__webglColorTexture = colorTexture;
- renderTargetProperties.__webglDepthStencilTexture = depthStencilTexture;
- renderTargetProperties.__webglViewFramebuffers = viewFramebuffers;
- _gl.bindFramebuffer(36160, null);
- _gl.bindTexture(35866, null);
- }
- }
- if (isCube) {
- state.bindTexture(34067, textureProperties.__webglTexture);
- setTextureParameters(34067, renderTarget.texture, supportsMips);
- for (var i2 = 0; i2 < 6; i2++) {
- setupFrameBufferTexture(renderTargetProperties.__webglFramebuffer[i2], renderTarget, 36064, 34069 + i2);
- }
- if (textureNeedsGenerateMipmaps(renderTarget.texture, supportsMips)) {
- generateMipmap(34067, renderTarget.texture, renderTarget.width, renderTarget.height);
- }
- state.bindTexture(34067, null);
- } else if (!isMultiview) {
- state.bindTexture(3553, textureProperties.__webglTexture);
- setTextureParameters(3553, renderTarget.texture, supportsMips);
- setupFrameBufferTexture(renderTargetProperties.__webglFramebuffer, renderTarget, 36064, 3553);
- if (textureNeedsGenerateMipmaps(renderTarget.texture, supportsMips)) {
- generateMipmap(3553, renderTarget.texture, renderTarget.width, renderTarget.height);
- }
- state.bindTexture(3553, null);
- }
- if (renderTarget.depthBuffer) {
- setupDepthRenderbuffer(renderTarget);
- }
- }
- function updateRenderTargetMipmap(renderTarget) {
- var texture = renderTarget.texture;
- var supportsMips = isPowerOfTwo(renderTarget) || isWebGL2;
- if (textureNeedsGenerateMipmaps(texture, supportsMips)) {
- var target = renderTarget.isWebGLCubeRenderTarget ? 34067 : 3553;
- var webglTexture = properties.get(texture).__webglTexture;
- state.bindTexture(target, webglTexture);
- generateMipmap(target, texture, renderTarget.width, renderTarget.height);
- state.bindTexture(target, null);
- }
- }
- function updateMultisampleRenderTarget(renderTarget) {
- if (renderTarget.isWebGLMultisampleRenderTarget) {
- if (isWebGL2) {
- var renderTargetProperties = properties.get(renderTarget);
- _gl.bindFramebuffer(36008, renderTargetProperties.__webglMultisampledFramebuffer);
- _gl.bindFramebuffer(36009, renderTargetProperties.__webglFramebuffer);
- var width = renderTarget.width;
- var height = renderTarget.height;
- var mask = 16384;
- if (renderTarget.depthBuffer)
- mask |= 256;
- if (renderTarget.stencilBuffer)
- mask |= 1024;
- _gl.blitFramebuffer(0, 0, width, height, 0, 0, width, height, mask, 9728);
- } else {
- console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");
- }
- }
- }
- function getRenderTargetSamples(renderTarget) {
- return isWebGL2 && renderTarget.isWebGLMultisampleRenderTarget ? Math.min(maxSamples, renderTarget.samples) : 0;
- }
- function updateVideoTexture(texture) {
- var frame = info.render.frame;
- if (_videoTextures.get(texture) !== frame) {
- _videoTextures.set(texture, frame);
- texture.update();
- }
- }
- var warnedTexture2D = false;
- var warnedTextureCube = false;
- function safeSetTexture2D(texture, slot) {
- if (texture && texture.isWebGLRenderTarget) {
- if (warnedTexture2D === false) {
- console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead.");
- warnedTexture2D = true;
- }
- texture = texture.texture;
- }
- setTexture2D(texture, slot);
- }
- function safeSetTextureCube(texture, slot) {
- if (texture && texture.isWebGLCubeRenderTarget) {
- if (warnedTextureCube === false) {
- console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead.");
- warnedTextureCube = true;
- }
- texture = texture.texture;
- }
- if (texture && texture.isCubeTexture || Array.isArray(texture.image) && texture.image.length === 6) {
- setTextureCube(texture, slot);
- } else {
- setTextureCubeDynamic(texture, slot);
- }
- }
- this.allocateTextureUnit = allocateTextureUnit;
- this.resetTextureUnits = resetTextureUnits;
- this.setTexture2D = setTexture2D;
- this.setTexture2DArray = setTexture2DArray;
- this.setTexture3D = setTexture3D;
- this.setTextureCube = setTextureCube;
- this.setTextureCubeDynamic = setTextureCubeDynamic;
- this.setupRenderTarget = setupRenderTarget;
- this.updateRenderTargetMipmap = updateRenderTargetMipmap;
- this.updateMultisampleRenderTarget = updateMultisampleRenderTarget;
- this.safeSetTexture2D = safeSetTexture2D;
- this.safeSetTextureCube = safeSetTextureCube;
- }
- function WebGLUtils(gl, extensions, capabilities) {
- var isWebGL2 = capabilities.isWebGL2;
- function convert(p) {
- var extension;
- if (p === UnsignedByteType)
- return 5121;
- if (p === UnsignedShort4444Type)
- return 32819;
- if (p === UnsignedShort5551Type)
- return 32820;
- if (p === UnsignedShort565Type)
- return 33635;
- if (p === ByteType)
- return 5120;
- if (p === ShortType)
- return 5122;
- if (p === UnsignedShortType)
- return 5123;
- if (p === IntType)
- return 5124;
- if (p === UnsignedIntType)
- return 5125;
- if (p === FloatType)
- return 5126;
- if (p === HalfFloatType) {
- if (isWebGL2)
- return 5131;
- extension = extensions.get("OES_texture_half_float");
- if (extension !== null) {
- return extension.HALF_FLOAT_OES;
- } else {
- return null;
- }
- }
- if (p === AlphaFormat)
- return 6406;
- if (p === RGBFormat)
- return 6407;
- if (p === RGBAFormat)
- return 6408;
- if (p === LuminanceFormat)
- return 6409;
- if (p === LuminanceAlphaFormat)
- return 6410;
- if (p === DepthFormat)
- return 6402;
- if (p === DepthStencilFormat)
- return 34041;
- if (p === RedFormat)
- return 6403;
- if (p === RedIntegerFormat)
- return 36244;
- if (p === RGFormat)
- return 33319;
- if (p === RGIntegerFormat)
- return 33320;
- if (p === RGBIntegerFormat)
- return 36248;
- if (p === RGBAIntegerFormat)
- return 36249;
- if (p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format || p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format) {
- extension = extensions.get("WEBGL_compressed_texture_s3tc");
- if (extension !== null) {
- if (p === RGB_S3TC_DXT1_Format)
- return extension.COMPRESSED_RGB_S3TC_DXT1_EXT;
- if (p === RGBA_S3TC_DXT1_Format)
- return extension.COMPRESSED_RGBA_S3TC_DXT1_EXT;
- if (p === RGBA_S3TC_DXT3_Format)
- return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT;
- if (p === RGBA_S3TC_DXT5_Format)
- return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT;
- } else {
- return null;
- }
- }
- if (p === RGB_PVRTC_4BPPV1_Format || p === RGB_PVRTC_2BPPV1_Format || p === RGBA_PVRTC_4BPPV1_Format || p === RGBA_PVRTC_2BPPV1_Format) {
- extension = extensions.get("WEBGL_compressed_texture_pvrtc");
- if (extension !== null) {
- if (p === RGB_PVRTC_4BPPV1_Format)
- return extension.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
- if (p === RGB_PVRTC_2BPPV1_Format)
- return extension.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
- if (p === RGBA_PVRTC_4BPPV1_Format)
- return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
- if (p === RGBA_PVRTC_2BPPV1_Format)
- return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
- } else {
- return null;
- }
- }
- if (p === RGB_ETC1_Format) {
- extension = extensions.get("WEBGL_compressed_texture_etc1");
- if (extension !== null) {
- return extension.COMPRESSED_RGB_ETC1_WEBGL;
- } else {
- return null;
- }
- }
- 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) {
- extension = extensions.get("WEBGL_compressed_texture_astc");
- if (extension !== null) {
- return p;
- } else {
- return null;
- }
- }
- if (p === UnsignedInt248Type) {
- if (isWebGL2)
- return 34042;
- extension = extensions.get("WEBGL_depth_texture");
- if (extension !== null) {
- return extension.UNSIGNED_INT_24_8_WEBGL;
- } else {
- return null;
- }
- }
- }
- return { convert };
- }
- function WebGLMultiviewRenderTarget(width, height, numViews, options) {
- WebGLRenderTarget.call(this, width, height, options);
- this.depthBuffer = false;
- this.stencilBuffer = false;
- this.numViews = numViews;
- }
- WebGLMultiviewRenderTarget.prototype = Object.assign(Object.create(WebGLRenderTarget.prototype), {
- constructor: WebGLMultiviewRenderTarget,
- isWebGLMultiviewRenderTarget: true,
- copy: function(source) {
- WebGLRenderTarget.prototype.copy.call(this, source);
- this.numViews = source.numViews;
- return this;
- },
- setNumViews: function(numViews) {
- if (this.numViews !== numViews) {
- this.numViews = numViews;
- this.dispose();
- }
- return this;
- }
- });
- function WebGLMultiview(renderer, gl) {
- var DEFAULT_NUMVIEWS = 2;
- var extensions = renderer.extensions;
- var properties = renderer.properties;
- var renderTarget, currentRenderTarget;
- var mat3, mat4, cameraArray, renderSize;
- var available;
- var maxNumViews = 0;
- function isAvailable() {
- if (available === void 0) {
- var extension = extensions.get("OVR_multiview2");
- available = extension !== null && gl.getContextAttributes().antialias === false;
- if (available) {
- maxNumViews = gl.getParameter(extension.MAX_VIEWS_OVR);
- renderTarget = new WebGLMultiviewRenderTarget(0, 0, DEFAULT_NUMVIEWS);
- renderSize = new Vector2();
- mat4 = [];
- mat3 = [];
- cameraArray = [];
- for (var i2 = 0; i2 < maxNumViews; i2++) {
- mat4[i2] = new Matrix4();
- mat3[i2] = new Matrix3();
- }
- }
- }
- return available;
- }
- function getCameraArray(camera) {
- if (camera.isArrayCamera)
- return camera.cameras;
- cameraArray[0] = camera;
- return cameraArray;
- }
- function updateCameraProjectionMatricesUniform(camera, uniforms) {
- var cameras = getCameraArray(camera);
- for (var i2 = 0; i2 < cameras.length; i2++) {
- mat4[i2].copy(cameras[i2].projectionMatrix);
- }
- uniforms.setValue(gl, "projectionMatrices", mat4);
- }
- function updateCameraViewMatricesUniform(camera, uniforms) {
- var cameras = getCameraArray(camera);
- for (var i2 = 0; i2 < cameras.length; i2++) {
- mat4[i2].copy(cameras[i2].matrixWorldInverse);
- }
- uniforms.setValue(gl, "viewMatrices", mat4);
- }
- function updateObjectMatricesUniforms(object, camera, uniforms) {
- var cameras = getCameraArray(camera);
- for (var i2 = 0; i2 < cameras.length; i2++) {
- mat4[i2].multiplyMatrices(cameras[i2].matrixWorldInverse, object.matrixWorld);
- mat3[i2].getNormalMatrix(mat4[i2]);
- }
- uniforms.setValue(gl, "modelViewMatrices", mat4);
- uniforms.setValue(gl, "normalMatrices", mat3);
- }
- function isMultiviewCompatible(camera) {
- if (camera.isArrayCamera === void 0)
- return true;
- var cameras = camera.cameras;
- if (cameras.length > maxNumViews)
- return false;
- for (var i2 = 1, il = cameras.length; i2 < il; i2++) {
- if (cameras[0].viewport.z !== cameras[i2].viewport.z || cameras[0].viewport.w !== cameras[i2].viewport.w)
- return false;
- }
- return true;
- }
- function resizeRenderTarget(camera) {
- if (currentRenderTarget) {
- renderSize.set(currentRenderTarget.width, currentRenderTarget.height);
- } else {
- renderer.getDrawingBufferSize(renderSize);
- }
- if (camera.isArrayCamera) {
- var viewport = camera.cameras[0].viewport;
- renderTarget.setSize(viewport.z, viewport.w);
- renderTarget.setNumViews(camera.cameras.length);
- } else {
- renderTarget.setSize(renderSize.x, renderSize.y);
- renderTarget.setNumViews(DEFAULT_NUMVIEWS);
- }
- }
- function attachCamera(camera) {
- if (isMultiviewCompatible(camera) === false)
- return;
- currentRenderTarget = renderer.getRenderTarget();
- resizeRenderTarget(camera);
- renderer.setRenderTarget(renderTarget);
- }
- function detachCamera(camera) {
- if (renderTarget !== renderer.getRenderTarget())
- return;
- renderer.setRenderTarget(currentRenderTarget);
- flush(camera);
- }
- function flush(camera) {
- var srcRenderTarget = renderTarget;
- var numViews = srcRenderTarget.numViews;
- var srcFramebuffers = properties.get(srcRenderTarget).__webglViewFramebuffers;
- var viewWidth = srcRenderTarget.width;
- var viewHeight = srcRenderTarget.height;
- if (camera.isArrayCamera) {
- for (var i2 = 0; i2 < numViews; i2++) {
- var viewport = camera.cameras[i2].viewport;
- var x1 = viewport.x;
- var y1 = viewport.y;
- var x2 = x1 + viewport.z;
- var y2 = y1 + viewport.w;
- gl.bindFramebuffer(36008, srcFramebuffers[i2]);
- gl.blitFramebuffer(0, 0, viewWidth, viewHeight, x1, y1, x2, y2, 16384, 9728);
- }
- } else {
- gl.bindFramebuffer(36008, srcFramebuffers[0]);
- gl.blitFramebuffer(0, 0, viewWidth, viewHeight, 0, 0, renderSize.x, renderSize.y, 16384, 9728);
- }
- }
- this.isAvailable = isAvailable;
- this.attachCamera = attachCamera;
- this.detachCamera = detachCamera;
- this.updateCameraProjectionMatricesUniform = updateCameraProjectionMatricesUniform;
- this.updateCameraViewMatricesUniform = updateCameraViewMatricesUniform;
- this.updateObjectMatricesUniforms = updateObjectMatricesUniforms;
- }
- function ArrayCamera(array) {
- PerspectiveCamera.call(this);
- this.cameras = array || [];
- }
- ArrayCamera.prototype = Object.assign(Object.create(PerspectiveCamera.prototype), {
- constructor: ArrayCamera,
- isArrayCamera: true
- });
- function Group() {
- Object3D.call(this);
- this.type = "Group";
- }
- Group.prototype = Object.assign(Object.create(Object3D.prototype), {
- constructor: Group,
- isGroup: true
- });
- function WebXRManager(renderer, gl) {
- var scope = this;
- var session = null;
- var referenceSpace = null;
- var referenceSpaceType = "local-floor";
- var pose = null;
- var controllers = [];
- var inputSourcesMap = /* @__PURE__ */ new Map();
- var cameraL = new PerspectiveCamera();
- cameraL.layers.enable(1);
- cameraL.viewport = new Vector4();
- var cameraR = new PerspectiveCamera();
- cameraR.layers.enable(2);
- cameraR.viewport = new Vector4();
- var cameraVR = new ArrayCamera([cameraL, cameraR]);
- cameraVR.layers.enable(1);
- cameraVR.layers.enable(2);
- var _currentDepthNear = null;
- var _currentDepthFar = null;
- this.enabled = false;
- this.isPresenting = false;
- this.getController = function(id) {
- var controller = controllers[id];
- if (controller === void 0) {
- controller = {};
- controllers[id] = controller;
- }
- if (controller.targetRay === void 0) {
- controller.targetRay = new Group();
- controller.targetRay.matrixAutoUpdate = false;
- controller.targetRay.visible = false;
- }
- return controller.targetRay;
- };
- this.getControllerGrip = function(id) {
- var controller = controllers[id];
- if (controller === void 0) {
- controller = {};
- controllers[id] = controller;
- }
- if (controller.grip === void 0) {
- controller.grip = new Group();
- controller.grip.matrixAutoUpdate = false;
- controller.grip.visible = false;
- }
- return controller.grip;
- };
- function onSessionEvent(event) {
- var controller = inputSourcesMap.get(event.inputSource);
- if (controller) {
- if (controller.targetRay) {
- controller.targetRay.dispatchEvent({ type: event.type });
- }
- if (controller.grip) {
- controller.grip.dispatchEvent({ type: event.type });
- }
- }
- }
- function onSessionEnd() {
- inputSourcesMap.forEach(function(controller, inputSource) {
- if (controller.targetRay) {
- controller.targetRay.dispatchEvent({ type: "disconnected", data: inputSource });
- controller.targetRay.visible = false;
- }
- if (controller.grip) {
- controller.grip.dispatchEvent({ type: "disconnected", data: inputSource });
- controller.grip.visible = false;
- }
- });
- inputSourcesMap.clear();
- renderer.setFramebuffer(null);
- renderer.setRenderTarget(renderer.getRenderTarget());
- animation.stop();
- scope.isPresenting = false;
- scope.dispatchEvent({ type: "sessionend" });
- }
- function onRequestReferenceSpace(value) {
- referenceSpace = value;
- animation.setContext(session);
- animation.start();
- scope.isPresenting = true;
- scope.dispatchEvent({ type: "sessionstart" });
- }
- this.setFramebufferScaleFactor = function() {
- };
- this.setReferenceSpaceType = function(value) {
- referenceSpaceType = value;
- };
- this.getReferenceSpace = function() {
- return referenceSpace;
- };
- this.getSession = function() {
- return session;
- };
- this.setSession = function(value) {
- session = value;
- if (session !== null) {
- session.addEventListener("select", onSessionEvent);
- session.addEventListener("selectstart", onSessionEvent);
- session.addEventListener("selectend", onSessionEvent);
- session.addEventListener("squeeze", onSessionEvent);
- session.addEventListener("squeezestart", onSessionEvent);
- session.addEventListener("squeezeend", onSessionEvent);
- session.addEventListener("end", onSessionEnd);
- var attributes = gl.getContextAttributes();
- var layerInit = {
- antialias: attributes.antialias,
- alpha: attributes.alpha,
- depth: attributes.depth,
- stencil: attributes.stencil
- };
- var baseLayer = new XRWebGLLayer(session, gl, layerInit);
- session.updateRenderState({ baseLayer });
- session.requestReferenceSpace(referenceSpaceType).then(onRequestReferenceSpace);
- session.addEventListener("inputsourceschange", updateInputSources);
- }
- };
- function updateInputSources(event) {
- var inputSources = session.inputSources;
- for (var i2 = 0; i2 < controllers.length; i2++) {
- inputSourcesMap.set(inputSources[i2], controllers[i2]);
- }
- for (var i2 = 0; i2 < event.removed.length; i2++) {
- var inputSource = event.removed[i2];
- var controller = inputSourcesMap.get(inputSource);
- if (controller) {
- if (controller.targetRay) {
- controller.targetRay.dispatchEvent({ type: "disconnected", data: inputSource });
- }
- if (controller.grip) {
- controller.grip.dispatchEvent({ type: "disconnected", data: inputSource });
- }
- inputSourcesMap.delete(inputSource);
- }
- }
- for (var i2 = 0; i2 < event.added.length; i2++) {
- var inputSource = event.added[i2];
- var controller = inputSourcesMap.get(inputSource);
- if (controller) {
- if (controller.targetRay) {
- controller.targetRay.dispatchEvent({ type: "connected", data: inputSource });
- }
- if (controller.grip) {
- controller.grip.dispatchEvent({ type: "connected", data: inputSource });
- }
- }
- }
- }
- var cameraLPos = new Vector3();
- var cameraRPos = new Vector3();
- function setProjectionFromUnion(camera, cameraL2, cameraR2) {
- cameraLPos.setFromMatrixPosition(cameraL2.matrixWorld);
- cameraRPos.setFromMatrixPosition(cameraR2.matrixWorld);
- var ipd = cameraLPos.distanceTo(cameraRPos);
- var projL = cameraL2.projectionMatrix.elements;
- var projR = cameraR2.projectionMatrix.elements;
- var near = projL[14] / (projL[10] - 1);
- var far = projL[14] / (projL[10] + 1);
- var topFov = (projL[9] + 1) / projL[5];
- var bottomFov = (projL[9] - 1) / projL[5];
- var leftFov = (projL[8] - 1) / projL[0];
- var rightFov = (projR[8] + 1) / projR[0];
- var left = near * leftFov;
- var right = near * rightFov;
- var zOffset = ipd / (-leftFov + rightFov);
- var xOffset = zOffset * -leftFov;
- cameraL2.matrixWorld.decompose(camera.position, camera.quaternion, camera.scale);
- camera.translateX(xOffset);
- camera.translateZ(zOffset);
- camera.matrixWorld.compose(camera.position, camera.quaternion, camera.scale);
- camera.matrixWorldInverse.getInverse(camera.matrixWorld);
- var near2 = near + zOffset;
- var far2 = far + zOffset;
- var left2 = left - xOffset;
- var right2 = right + (ipd - xOffset);
- var top2 = topFov * far / far2 * near2;
- var bottom2 = bottomFov * far / far2 * near2;
- camera.projectionMatrix.makePerspective(left2, right2, top2, bottom2, near2, far2);
- }
- function updateCamera(camera, parent) {
- if (parent === null) {
- camera.matrixWorld.copy(camera.matrix);
- } else {
- camera.matrixWorld.multiplyMatrices(parent.matrixWorld, camera.matrix);
- }
- camera.matrixWorldInverse.getInverse(camera.matrixWorld);
- }
- this.getCamera = function(camera) {
- cameraVR.near = cameraR.near = cameraL.near = camera.near;
- cameraVR.far = cameraR.far = cameraL.far = camera.far;
- if (_currentDepthNear !== cameraVR.near || _currentDepthFar !== cameraVR.far) {
- session.updateRenderState({
- depthNear: cameraVR.near,
- depthFar: cameraVR.far
- });
- _currentDepthNear = cameraVR.near;
- _currentDepthFar = cameraVR.far;
- }
- var parent = camera.parent;
- var cameras = cameraVR.cameras;
- updateCamera(cameraVR, parent);
- for (var i2 = 0; i2 < cameras.length; i2++) {
- updateCamera(cameras[i2], parent);
- }
- camera.matrixWorld.copy(cameraVR.matrixWorld);
- var children = camera.children;
- for (var i2 = 0, l = children.length; i2 < l; i2++) {
- children[i2].updateMatrixWorld(true);
- }
- setProjectionFromUnion(cameraVR, cameraL, cameraR);
- return cameraVR;
- };
- var onAnimationFrameCallback = null;
- function onAnimationFrame(time, frame) {
- pose = frame.getViewerPose(referenceSpace);
- if (pose !== null) {
- var views = pose.views;
- var baseLayer = session.renderState.baseLayer;
- renderer.setFramebuffer(baseLayer.framebuffer);
- for (var i2 = 0; i2 < views.length; i2++) {
- var view = views[i2];
- var viewport = baseLayer.getViewport(view);
- var camera = cameraVR.cameras[i2];
- camera.matrix.fromArray(view.transform.matrix);
- camera.projectionMatrix.fromArray(view.projectionMatrix);
- camera.viewport.set(viewport.x, viewport.y, viewport.width, viewport.height);
- if (i2 === 0) {
- cameraVR.matrix.copy(camera.matrix);
- }
- }
- }
- var inputSources = session.inputSources;
- for (var i2 = 0; i2 < controllers.length; i2++) {
- var controller = controllers[i2];
- var inputSource = inputSources[i2];
- var inputPose = null;
- var gripPose = null;
- if (inputSource) {
- if (controller.targetRay) {
- inputPose = frame.getPose(inputSource.targetRaySpace, referenceSpace);
- if (inputPose !== null) {
- controller.targetRay.matrix.fromArray(inputPose.transform.matrix);
- controller.targetRay.matrix.decompose(controller.targetRay.position, controller.targetRay.rotation, controller.targetRay.scale);
- }
- }
- if (controller.grip && inputSource.gripSpace) {
- gripPose = frame.getPose(inputSource.gripSpace, referenceSpace);
- if (gripPose !== null) {
- controller.grip.matrix.fromArray(gripPose.transform.matrix);
- controller.grip.matrix.decompose(controller.grip.position, controller.grip.rotation, controller.grip.scale);
- }
- }
- }
- if (controller.targetRay) {
- controller.targetRay.visible = inputPose !== null;
- }
- if (controller.grip) {
- controller.grip.visible = gripPose !== null;
- }
- }
- if (onAnimationFrameCallback)
- onAnimationFrameCallback(time, frame);
- }
- var animation = new WebGLAnimation();
- animation.setAnimationLoop(onAnimationFrame);
- this.setAnimationLoop = function(callback) {
- onAnimationFrameCallback = callback;
- };
- this.dispose = function() {
- };
- }
- Object.assign(WebXRManager.prototype, EventDispatcher.prototype);
- function WebGLRenderer(parameters) {
- parameters = parameters || {};
- 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;
- var currentRenderList = null;
- var currentRenderState = null;
- this.domElement = _canvas2;
- this.debug = {
- /**
- * Enables error checking and reporting when shader programs are being compiled
- * @type {boolean}
- */
- checkShaderErrors: true
- };
- this.autoClear = true;
- this.autoClearColor = true;
- this.autoClearDepth = true;
- this.autoClearStencil = true;
- this.sortObjects = true;
- this.clippingPlanes = [];
- this.localClippingEnabled = false;
- this.gammaFactor = 2;
- this.outputEncoding = LinearEncoding;
- this.physicallyCorrectLights = false;
- this.toneMapping = LinearToneMapping;
- this.toneMappingExposure = 1;
- this.toneMappingWhitePoint = 1;
- this.maxMorphTargets = 8;
- this.maxMorphNormals = 4;
- var _this = this, _isContextLost = false, _framebuffer = null, _currentActiveCubeFace = 0, _currentActiveMipmapLevel = 0, _currentRenderTarget = null, _currentFramebuffer = null, _currentMaterialId = -1, _currentGeometryProgram = {
- geometry: null,
- program: null,
- wireframe: false
- }, _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();
- function getTargetPixelRatio() {
- return _currentRenderTarget === null ? _pixelRatio : 1;
- }
- var _gl;
- try {
- var contextAttributes = {
- alpha: _alpha,
- depth: _depth,
- stencil: _stencil,
- antialias: _antialias,
- premultipliedAlpha: _premultipliedAlpha,
- preserveDrawingBuffer: _preserveDrawingBuffer,
- powerPreference: _powerPreference,
- failIfMajorPerformanceCaveat: _failIfMajorPerformanceCaveat,
- xrCompatible: true
- };
- _canvas2.addEventListener("webglcontextlost", onContextLost, false);
- _canvas2.addEventListener("webglcontextrestored", onContextRestore, false);
- _gl = _context2 || _canvas2.getContext("webgl", contextAttributes) || _canvas2.getContext("experimental-webgl", contextAttributes);
- if (_gl === null) {
- if (_canvas2.getContext("webgl") !== null) {
- throw new Error("Error creating WebGL context with your selected attributes.");
- } else {
- throw new Error("Error creating WebGL context.");
- }
- }
- if (_gl.getShaderPrecisionFormat === void 0) {
- _gl.getShaderPrecisionFormat = function() {
- return { "rangeMin": 1, "rangeMax": 1, "precision": 1 };
- };
- }
- } catch (error) {
- console.error("THREE.WebGLRenderer: " + error.message);
- throw error;
- }
- var extensions, capabilities, state, info;
- var properties, textures, attributes, geometries, objects;
- var programCache, renderLists, renderStates;
- var background, morphtargets, bufferRenderer, indexedBufferRenderer;
- var utils;
- function initGLContext() {
- extensions = new WebGLExtensions(_gl);
- capabilities = new WebGLCapabilities(_gl, extensions, parameters);
- if (capabilities.isWebGL2 === false) {
- extensions.get("WEBGL_depth_texture");
- extensions.get("OES_texture_float");
- extensions.get("OES_texture_half_float");
- extensions.get("OES_texture_half_float_linear");
- extensions.get("OES_standard_derivatives");
- extensions.get("OES_element_index_uint");
- extensions.get("ANGLE_instanced_arrays");
- }
- extensions.get("OES_texture_float_linear");
- utils = new WebGLUtils(_gl, extensions, capabilities);
- state = new WebGLState(_gl, extensions, capabilities);
- state.scissor(_currentScissor.copy(_scissor).multiplyScalar(_pixelRatio).floor());
- state.viewport(_currentViewport.copy(_viewport).multiplyScalar(_pixelRatio).floor());
- info = new WebGLInfo();
- properties = new WebGLProperties();
- textures = new WebGLTextures(_gl, extensions, state, properties, capabilities, utils, info);
- attributes = new WebGLAttributes(_gl, capabilities);
- geometries = new WebGLGeometries(_gl, attributes, info);
- objects = new WebGLObjects(_gl, geometries, attributes, info);
- morphtargets = new WebGLMorphtargets(_gl);
- programCache = new WebGLPrograms(_this, extensions, capabilities);
- renderLists = new WebGLRenderLists();
- renderStates = new WebGLRenderStates();
- background = new WebGLBackground(_this, state, objects, _premultipliedAlpha);
- bufferRenderer = new WebGLBufferRenderer(_gl, extensions, info, capabilities);
- indexedBufferRenderer = new WebGLIndexedBufferRenderer(_gl, extensions, info, capabilities);
- info.programs = programCache.programs;
- _this.capabilities = capabilities;
- _this.extensions = extensions;
- _this.properties = properties;
- _this.renderLists = renderLists;
- _this.state = state;
- _this.info = info;
- }
- initGLContext();
- var xr = new WebXRManager(_this, _gl);
- this.xr = xr;
- var multiview = new WebGLMultiview(_this, _gl);
- var shadowMap = new WebGLShadowMap(_this, objects, capabilities.maxTextureSize);
- this.shadowMap = shadowMap;
- this.getContext = function() {
- return _gl;
- };
- this.getContextAttributes = function() {
- return _gl.getContextAttributes();
- };
- this.forceContextLoss = function() {
- var extension = extensions.get("WEBGL_lose_context");
- if (extension)
- extension.loseContext();
- };
- this.forceContextRestore = function() {
- var extension = extensions.get("WEBGL_lose_context");
- if (extension)
- extension.restoreContext();
- };
- this.getPixelRatio = function() {
- return _pixelRatio;
- };
- this.setPixelRatio = function(value) {
- if (value === void 0)
- return;
- _pixelRatio = value;
- this.setSize(_width, _height, false);
- };
- this.getSize = function(target) {
- if (target === void 0) {
- console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument");
- target = new Vector2();
- }
- return target.set(_width, _height);
- };
- this.setSize = function(width, height, updateStyle) {
- if (xr.isPresenting) {
- console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");
- return;
- }
- _width = width;
- _height = height;
- _canvas2.width = Math.floor(width * _pixelRatio);
- _canvas2.height = Math.floor(height * _pixelRatio);
- if (updateStyle !== false) {
- _canvas2.style.width = width + "px";
- _canvas2.style.height = height + "px";
- }
- this.setViewport(0, 0, width, height);
- };
- this.getDrawingBufferSize = function(target) {
- if (target === void 0) {
- console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument");
- target = new Vector2();
- }
- return target.set(_width * _pixelRatio, _height * _pixelRatio).floor();
- };
- this.setDrawingBufferSize = function(width, height, pixelRatio) {
- _width = width;
- _height = height;
- _pixelRatio = pixelRatio;
- _canvas2.width = Math.floor(width * pixelRatio);
- _canvas2.height = Math.floor(height * pixelRatio);
- this.setViewport(0, 0, width, height);
- };
- this.getCurrentViewport = function(target) {
- if (target === void 0) {
- console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument");
- target = new Vector4();
- }
- return target.copy(_currentViewport);
- };
- this.getViewport = function(target) {
- return target.copy(_viewport);
- };
- this.setViewport = function(x, y, width, height) {
- if (x.isVector4) {
- _viewport.set(x.x, x.y, x.z, x.w);
- } else {
- _viewport.set(x, y, width, height);
- }
- state.viewport(_currentViewport.copy(_viewport).multiplyScalar(_pixelRatio).floor());
- };
- this.getScissor = function(target) {
- return target.copy(_scissor);
- };
- this.setScissor = function(x, y, width, height) {
- if (x.isVector4) {
- _scissor.set(x.x, x.y, x.z, x.w);
- } else {
- _scissor.set(x, y, width, height);
- }
- state.scissor(_currentScissor.copy(_scissor).multiplyScalar(_pixelRatio).floor());
- };
- this.getScissorTest = function() {
- return _scissorTest;
- };
- this.setScissorTest = function(boolean) {
- state.setScissorTest(_scissorTest = boolean);
- };
- this.setOpaqueSort = function(method) {
- _opaqueSort = method;
- };
- this.setTransparentSort = function(method) {
- _transparentSort = method;
- };
- this.getClearColor = function() {
- return background.getClearColor();
- };
- this.setClearColor = function() {
- background.setClearColor.apply(background, arguments);
- };
- this.getClearAlpha = function() {
- return background.getClearAlpha();
- };
- this.setClearAlpha = function() {
- background.setClearAlpha.apply(background, arguments);
- };
- this.clear = function(color, depth, stencil) {
- var bits = 0;
- if (color === void 0 || color)
- bits |= 16384;
- if (depth === void 0 || depth)
- bits |= 256;
- if (stencil === void 0 || stencil)
- bits |= 1024;
- _gl.clear(bits);
- };
- this.clearColor = function() {
- this.clear(true, false, false);
- };
- this.clearDepth = function() {
- this.clear(false, true, false);
- };
- this.clearStencil = function() {
- this.clear(false, false, true);
- };
- this.dispose = function() {
- _canvas2.removeEventListener("webglcontextlost", onContextLost, false);
- _canvas2.removeEventListener("webglcontextrestored", onContextRestore, false);
- renderLists.dispose();
- renderStates.dispose();
- properties.dispose();
- objects.dispose();
- xr.dispose();
- animation.stop();
- };
- function onContextLost(event) {
- event.preventDefault();
- console.log("THREE.WebGLRenderer: Context Lost.");
- _isContextLost = true;
- }
- function onContextRestore() {
- console.log("THREE.WebGLRenderer: Context Restored.");
- _isContextLost = false;
- initGLContext();
- }
- function onMaterialDispose(event) {
- var material = event.target;
- material.removeEventListener("dispose", onMaterialDispose);
- deallocateMaterial(material);
- }
- function deallocateMaterial(material) {
- releaseMaterialProgramReference(material);
- properties.remove(material);
- }
- function releaseMaterialProgramReference(material) {
- var programInfo = properties.get(material).program;
- material.program = void 0;
- if (programInfo !== void 0) {
- programCache.releaseProgram(programInfo);
- }
- }
- function renderObjectImmediate(object, program) {
- object.render(function(object2) {
- _this.renderBufferImmediate(object2, program);
- });
- }
- this.renderBufferImmediate = function(object, program) {
- state.initAttributes();
- var buffers = properties.get(object);
- if (object.hasPositions && !buffers.position)
- buffers.position = _gl.createBuffer();
- if (object.hasNormals && !buffers.normal)
- buffers.normal = _gl.createBuffer();
- if (object.hasUvs && !buffers.uv)
- buffers.uv = _gl.createBuffer();
- if (object.hasColors && !buffers.color)
- buffers.color = _gl.createBuffer();
- var programAttributes = program.getAttributes();
- if (object.hasPositions) {
- _gl.bindBuffer(34962, buffers.position);
- _gl.bufferData(34962, object.positionArray, 35048);
- state.enableAttribute(programAttributes.position);
- _gl.vertexAttribPointer(programAttributes.position, 3, 5126, false, 0, 0);
- }
- if (object.hasNormals) {
- _gl.bindBuffer(34962, buffers.normal);
- _gl.bufferData(34962, object.normalArray, 35048);
- state.enableAttribute(programAttributes.normal);
- _gl.vertexAttribPointer(programAttributes.normal, 3, 5126, false, 0, 0);
- }
- if (object.hasUvs) {
- _gl.bindBuffer(34962, buffers.uv);
- _gl.bufferData(34962, object.uvArray, 35048);
- state.enableAttribute(programAttributes.uv);
- _gl.vertexAttribPointer(programAttributes.uv, 2, 5126, false, 0, 0);
- }
- if (object.hasColors) {
- _gl.bindBuffer(34962, buffers.color);
- _gl.bufferData(34962, object.colorArray, 35048);
- state.enableAttribute(programAttributes.color);
- _gl.vertexAttribPointer(programAttributes.color, 3, 5126, false, 0, 0);
- }
- state.disableUnusedAttributes();
- _gl.drawArrays(4, 0, object.count);
- object.count = 0;
- };
- var tempScene = new Scene();
- this.renderBufferDirect = function(camera, scene, geometry, material, object, group) {
- if (scene === null)
- scene = tempScene;
- var frontFaceCW = object.isMesh && object.matrixWorld.determinant() < 0;
- var program = setProgram(camera, scene, material, object);
- state.setMaterial(material, frontFaceCW);
- var updateBuffers = false;
- if (_currentGeometryProgram.geometry !== geometry.id || _currentGeometryProgram.program !== program.id || _currentGeometryProgram.wireframe !== (material.wireframe === true)) {
- _currentGeometryProgram.geometry = geometry.id;
- _currentGeometryProgram.program = program.id;
- _currentGeometryProgram.wireframe = material.wireframe === true;
- updateBuffers = true;
- }
- if (material.morphTargets || material.morphNormals) {
- morphtargets.update(object, geometry, material, program);
- updateBuffers = true;
- }
- var index = geometry.index;
- var position = geometry.attributes.position;
- if (index === null) {
- if (position === void 0 || position.count === 0)
- return;
- } else if (index.count === 0) {
- return;
- }
- var rangeFactor = 1;
- if (material.wireframe === true) {
- index = geometries.getWireframeAttribute(geometry);
- rangeFactor = 2;
- }
- var attribute;
- var renderer = bufferRenderer;
- if (index !== null) {
- attribute = attributes.get(index);
- renderer = indexedBufferRenderer;
- renderer.setIndex(attribute);
- }
- if (updateBuffers) {
- setupVertexAttributes(object, geometry, material, program);
- if (index !== null) {
- _gl.bindBuffer(34963, attribute.buffer);
- }
- }
- var dataCount = index !== null ? index.count : position.count;
- var rangeStart = geometry.drawRange.start * rangeFactor;
- var rangeCount = geometry.drawRange.count * rangeFactor;
- var groupStart = group !== null ? group.start * rangeFactor : 0;
- var groupCount = group !== null ? group.count * rangeFactor : Infinity;
- var drawStart = Math.max(rangeStart, groupStart);
- var drawEnd = Math.min(dataCount, rangeStart + rangeCount, groupStart + groupCount) - 1;
- var drawCount = Math.max(0, drawEnd - drawStart + 1);
- if (drawCount === 0)
- return;
- if (object.isMesh) {
- if (material.wireframe === true) {
- state.setLineWidth(material.wireframeLinewidth * getTargetPixelRatio());
- renderer.setMode(1);
- } else {
- renderer.setMode(4);
- }
- } else if (object.isLine) {
- var lineWidth = material.linewidth;
- if (lineWidth === void 0)
- lineWidth = 1;
- state.setLineWidth(lineWidth * getTargetPixelRatio());
- if (object.isLineSegments) {
- renderer.setMode(1);
- } else if (object.isLineLoop) {
- renderer.setMode(2);
- } else {
- renderer.setMode(3);
- }
- } else if (object.isPoints) {
- renderer.setMode(0);
- } else if (object.isSprite) {
- renderer.setMode(4);
- }
- if (object.isInstancedMesh) {
- renderer.renderInstances(geometry, drawStart, drawCount, object.count);
- } else if (geometry.isInstancedBufferGeometry) {
- renderer.renderInstances(geometry, drawStart, drawCount, geometry.maxInstancedCount);
- } else {
- renderer.render(drawStart, drawCount);
- }
- };
- function setupVertexAttributes(object, geometry, material, program) {
- if (capabilities.isWebGL2 === false && (object.isInstancedMesh || geometry.isInstancedBufferGeometry)) {
- if (extensions.get("ANGLE_instanced_arrays") === null)
- return;
- }
- state.initAttributes();
- var geometryAttributes = geometry.attributes;
- var programAttributes = program.getAttributes();
- var materialDefaultAttributeValues = material.defaultAttributeValues;
- for (var name in programAttributes) {
- var programAttribute = programAttributes[name];
- if (programAttribute >= 0) {
- var geometryAttribute = geometryAttributes[name];
- if (geometryAttribute !== void 0) {
- var normalized = geometryAttribute.normalized;
- var size = geometryAttribute.itemSize;
- var attribute = attributes.get(geometryAttribute);
- if (attribute === void 0)
- continue;
- var buffer = attribute.buffer;
- var type = attribute.type;
- var bytesPerElement = attribute.bytesPerElement;
- if (geometryAttribute.isInterleavedBufferAttribute) {
- var data = geometryAttribute.data;
- var stride = data.stride;
- var offset = geometryAttribute.offset;
- if (data && data.isInstancedInterleavedBuffer) {
- state.enableAttributeAndDivisor(programAttribute, data.meshPerAttribute);
- if (geometry.maxInstancedCount === void 0) {
- geometry.maxInstancedCount = data.meshPerAttribute * data.count;
- }
- } else {
- state.enableAttribute(programAttribute);
- }
- _gl.bindBuffer(34962, buffer);
- _gl.vertexAttribPointer(programAttribute, size, type, normalized, stride * bytesPerElement, offset * bytesPerElement);
- } else {
- if (geometryAttribute.isInstancedBufferAttribute) {
- state.enableAttributeAndDivisor(programAttribute, geometryAttribute.meshPerAttribute);
- if (geometry.maxInstancedCount === void 0) {
- geometry.maxInstancedCount = geometryAttribute.meshPerAttribute * geometryAttribute.count;
- }
- } else {
- state.enableAttribute(programAttribute);
- }
- _gl.bindBuffer(34962, buffer);
- _gl.vertexAttribPointer(programAttribute, size, type, normalized, 0, 0);
- }
- } else if (name === "instanceMatrix") {
- var attribute = attributes.get(object.instanceMatrix);
- if (attribute === void 0)
- continue;
- var buffer = attribute.buffer;
- var type = attribute.type;
- state.enableAttributeAndDivisor(programAttribute + 0, 1);
- state.enableAttributeAndDivisor(programAttribute + 1, 1);
- state.enableAttributeAndDivisor(programAttribute + 2, 1);
- state.enableAttributeAndDivisor(programAttribute + 3, 1);
- _gl.bindBuffer(34962, buffer);
- _gl.vertexAttribPointer(programAttribute + 0, 4, type, false, 64, 0);
- _gl.vertexAttribPointer(programAttribute + 1, 4, type, false, 64, 16);
- _gl.vertexAttribPointer(programAttribute + 2, 4, type, false, 64, 32);
- _gl.vertexAttribPointer(programAttribute + 3, 4, type, false, 64, 48);
- } else if (materialDefaultAttributeValues !== void 0) {
- var value = materialDefaultAttributeValues[name];
- if (value !== void 0) {
- switch (value.length) {
- case 2:
- _gl.vertexAttrib2fv(programAttribute, value);
- break;
- case 3:
- _gl.vertexAttrib3fv(programAttribute, value);
- break;
- case 4:
- _gl.vertexAttrib4fv(programAttribute, value);
- break;
- default:
- _gl.vertexAttrib1fv(programAttribute, value);
- }
- }
- }
- }
- }
- state.disableUnusedAttributes();
- }
- this.compile = function(scene, camera) {
- currentRenderState = renderStates.get(scene, camera);
- currentRenderState.init();
- scene.traverse(function(object) {
- if (object.isLight) {
- currentRenderState.pushLight(object);
- if (object.castShadow) {
- currentRenderState.pushShadow(object);
- }
- }
- });
- currentRenderState.setupLights(camera);
- var compiled = {};
- scene.traverse(function(object) {
- if (object.material) {
- if (Array.isArray(object.material)) {
- for (var i2 = 0; i2 < object.material.length; i2++) {
- if (object.material[i2].uuid in compiled === false) {
- initMaterial(object.material[i2], scene, object);
- compiled[object.material[i2].uuid] = true;
- }
- }
- } else if (object.material.uuid in compiled === false) {
- initMaterial(object.material, scene, object);
- compiled[object.material.uuid] = true;
- }
- }
- });
- };
- var onAnimationFrameCallback = null;
- function onAnimationFrame(time) {
- if (xr.isPresenting)
- return;
- if (onAnimationFrameCallback)
- onAnimationFrameCallback(time);
- }
- var animation = new WebGLAnimation();
- animation.setAnimationLoop(onAnimationFrame);
- if (typeof window !== "undefined")
- animation.setContext(window);
- this.setAnimationLoop = function(callback) {
- onAnimationFrameCallback = callback;
- xr.setAnimationLoop(callback);
- animation.start();
- };
- this.render = function(scene, camera) {
- var renderTarget, forceClear;
- if (arguments[2] !== void 0) {
- console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead.");
- renderTarget = arguments[2];
- }
- if (arguments[3] !== void 0) {
- console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead.");
- forceClear = arguments[3];
- }
- if (!(camera && camera.isCamera)) {
- console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");
- return;
- }
- if (_isContextLost)
- return;
- _currentGeometryProgram.geometry = null;
- _currentGeometryProgram.program = null;
- _currentGeometryProgram.wireframe = false;
- _currentMaterialId = -1;
- _currentCamera = null;
- if (scene.autoUpdate === true)
- scene.updateMatrixWorld();
- if (camera.parent === null)
- camera.updateMatrixWorld();
- if (xr.enabled && xr.isPresenting) {
- camera = xr.getCamera(camera);
- }
- currentRenderState = renderStates.get(scene, camera);
- currentRenderState.init();
- scene.onBeforeRender(_this, scene, camera, renderTarget || _currentRenderTarget);
- _projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
- _frustum.setFromProjectionMatrix(_projScreenMatrix);
- _localClippingEnabled = this.localClippingEnabled;
- _clippingEnabled = _clipping.init(this.clippingPlanes, _localClippingEnabled, camera);
- currentRenderList = renderLists.get(scene, camera);
- currentRenderList.init();
- projectObject(scene, camera, 0, _this.sortObjects);
- if (_this.sortObjects === true) {
- currentRenderList.sort(_opaqueSort, _transparentSort);
- }
- if (_clippingEnabled)
- _clipping.beginShadows();
- var shadowsArray = currentRenderState.state.shadowsArray;
- shadowMap.render(shadowsArray, scene, camera);
- currentRenderState.setupLights(camera);
- if (_clippingEnabled)
- _clipping.endShadows();
- if (this.info.autoReset)
- this.info.reset();
- if (renderTarget !== void 0) {
- this.setRenderTarget(renderTarget);
- }
- if (xr.enabled && multiview.isAvailable()) {
- multiview.attachCamera(camera);
- }
- background.render(currentRenderList, scene, camera, forceClear);
- var opaqueObjects = currentRenderList.opaque;
- var transparentObjects = currentRenderList.transparent;
- if (scene.overrideMaterial) {
- var overrideMaterial = scene.overrideMaterial;
- if (opaqueObjects.length)
- renderObjects(opaqueObjects, scene, camera, overrideMaterial);
- if (transparentObjects.length)
- renderObjects(transparentObjects, scene, camera, overrideMaterial);
- } else {
- if (opaqueObjects.length)
- renderObjects(opaqueObjects, scene, camera);
- if (transparentObjects.length)
- renderObjects(transparentObjects, scene, camera);
- }
- scene.onAfterRender(_this, scene, camera);
- if (_currentRenderTarget !== null) {
- textures.updateRenderTargetMipmap(_currentRenderTarget);
- textures.updateMultisampleRenderTarget(_currentRenderTarget);
- }
- state.buffers.depth.setTest(true);
- state.buffers.depth.setMask(true);
- state.buffers.color.setMask(true);
- state.setPolygonOffset(false);
- if (xr.enabled) {
- if (multiview.isAvailable()) {
- multiview.detachCamera(camera);
- }
- }
- currentRenderList = null;
- currentRenderState = null;
- };
- function projectObject(object, camera, groupOrder, sortObjects) {
- if (object.visible === false)
- return;
- var visible = object.layers.test(camera.layers);
- if (visible) {
- if (object.isGroup) {
- groupOrder = object.renderOrder;
- } else if (object.isLOD) {
- if (object.autoUpdate === true)
- object.update(camera);
- } else if (object.isLight) {
- currentRenderState.pushLight(object);
- if (object.castShadow) {
- currentRenderState.pushShadow(object);
- }
- } else if (object.isSprite) {
- if (!object.frustumCulled || _frustum.intersectsSprite(object)) {
- if (sortObjects) {
- _vector3.setFromMatrixPosition(object.matrixWorld).applyMatrix4(_projScreenMatrix);
- }
- var geometry = objects.update(object);
- var material = object.material;
- if (material.visible) {
- currentRenderList.push(object, geometry, material, groupOrder, _vector3.z, null);
- }
- }
- } else if (object.isImmediateRenderObject) {
- if (sortObjects) {
- _vector3.setFromMatrixPosition(object.matrixWorld).applyMatrix4(_projScreenMatrix);
- }
- currentRenderList.push(object, null, object.material, groupOrder, _vector3.z, null);
- } else if (object.isMesh || object.isLine || object.isPoints) {
- if (object.isSkinnedMesh) {
- if (object.skeleton.frame !== info.render.frame) {
- object.skeleton.update();
- object.skeleton.frame = info.render.frame;
- }
- }
- if (!object.frustumCulled || _frustum.intersectsObject(object)) {
- if (sortObjects) {
- _vector3.setFromMatrixPosition(object.matrixWorld).applyMatrix4(_projScreenMatrix);
- }
- var geometry = objects.update(object);
- var material = object.material;
- if (Array.isArray(material)) {
- var groups = geometry.groups;
- for (var i2 = 0, l = groups.length; i2 < l; i2++) {
- var group = groups[i2];
- var groupMaterial = material[group.materialIndex];
- if (groupMaterial && groupMaterial.visible) {
- currentRenderList.push(object, geometry, groupMaterial, groupOrder, _vector3.z, group);
- }
- }
- } else if (material.visible) {
- currentRenderList.push(object, geometry, material, groupOrder, _vector3.z, null);
- }
- }
- }
- }
- var children = object.children;
- for (var i2 = 0, l = children.length; i2 < l; i2++) {
- projectObject(children[i2], camera, groupOrder, sortObjects);
- }
- }
- function renderObjects(renderList, scene, camera, overrideMaterial) {
- for (var i2 = 0, l = renderList.length; i2 < l; i2++) {
- var renderItem = renderList[i2];
- var object = renderItem.object;
- var geometry = renderItem.geometry;
- var material = overrideMaterial === void 0 ? renderItem.material : overrideMaterial;
- var group = renderItem.group;
- if (camera.isArrayCamera) {
- _currentArrayCamera = camera;
- if (xr.enabled && multiview.isAvailable()) {
- renderObject(object, scene, camera, geometry, material, group);
- } else {
- var cameras = camera.cameras;
- for (var j = 0, jl = cameras.length; j < jl; j++) {
- var camera2 = cameras[j];
- if (object.layers.test(camera2.layers)) {
- state.viewport(_currentViewport.copy(camera2.viewport));
- currentRenderState.setupLights(camera2);
- renderObject(object, scene, camera2, geometry, material, group);
- }
- }
- }
- } else {
- _currentArrayCamera = null;
- renderObject(object, scene, camera, geometry, material, group);
- }
- }
- }
- function renderObject(object, scene, camera, geometry, material, group) {
- object.onBeforeRender(_this, scene, camera, geometry, material, group);
- currentRenderState = renderStates.get(scene, _currentArrayCamera || camera);
- object.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, object.matrixWorld);
- object.normalMatrix.getNormalMatrix(object.modelViewMatrix);
- if (object.isImmediateRenderObject) {
- var program = setProgram(camera, scene, material, object);
- state.setMaterial(material);
- _currentGeometryProgram.geometry = null;
- _currentGeometryProgram.program = null;
- _currentGeometryProgram.wireframe = false;
- renderObjectImmediate(object, program);
- } else {
- _this.renderBufferDirect(camera, scene, geometry, material, object, group);
- }
- object.onAfterRender(_this, scene, camera, geometry, material, group);
- currentRenderState = renderStates.get(scene, _currentArrayCamera || camera);
- }
- function initMaterial(material, scene, object) {
- var materialProperties = properties.get(material);
- var lights = currentRenderState.state.lights;
- var shadowsArray = currentRenderState.state.shadowsArray;
- var lightsStateVersion = lights.state.version;
- var parameters2 = programCache.getParameters(material, lights.state, shadowsArray, scene, _clipping.numPlanes, _clipping.numIntersection, object);
- var programCacheKey = programCache.getProgramCacheKey(parameters2);
- var program = materialProperties.program;
- var programChange = true;
- if (program === void 0) {
- material.addEventListener("dispose", onMaterialDispose);
- } else if (program.cacheKey !== programCacheKey) {
- releaseMaterialProgramReference(material);
- } else if (materialProperties.lightsStateVersion !== lightsStateVersion) {
- materialProperties.lightsStateVersion = lightsStateVersion;
- programChange = false;
- } else if (parameters2.shaderID !== void 0) {
- return;
- } else {
- programChange = false;
- }
- if (programChange) {
- program = programCache.acquireProgram(parameters2, programCacheKey);
- materialProperties.program = program;
- materialProperties.uniforms = parameters2.uniforms;
- materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;
- materialProperties.outputEncoding = _this.outputEncoding;
- material.program = program;
- }
- var programAttributes = program.getAttributes();
- if (material.morphTargets) {
- material.numSupportedMorphTargets = 0;
- for (var i2 = 0; i2 < _this.maxMorphTargets; i2++) {
- if (programAttributes["morphTarget" + i2] >= 0) {
- material.numSupportedMorphTargets++;
- }
- }
- }
- if (material.morphNormals) {
- material.numSupportedMorphNormals = 0;
- for (var i2 = 0; i2 < _this.maxMorphNormals; i2++) {
- if (programAttributes["morphNormal" + i2] >= 0) {
- material.numSupportedMorphNormals++;
- }
- }
- }
- var uniforms = materialProperties.uniforms;
- if (!material.isShaderMaterial && !material.isRawShaderMaterial || material.clipping === true) {
- materialProperties.numClippingPlanes = _clipping.numPlanes;
- materialProperties.numIntersection = _clipping.numIntersection;
- uniforms.clippingPlanes = _clipping.uniform;
- }
- materialProperties.fog = scene.fog;
- materialProperties.needsLights = materialNeedsLights(material);
- materialProperties.lightsStateVersion = lightsStateVersion;
- if (materialProperties.needsLights) {
- uniforms.ambientLightColor.value = lights.state.ambient;
- uniforms.lightProbe.value = lights.state.probe;
- uniforms.directionalLights.value = lights.state.directional;
- uniforms.spotLights.value = lights.state.spot;
- uniforms.rectAreaLights.value = lights.state.rectArea;
- uniforms.pointLights.value = lights.state.point;
- uniforms.hemisphereLights.value = lights.state.hemi;
- uniforms.directionalShadowMap.value = lights.state.directionalShadowMap;
- uniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix;
- uniforms.spotShadowMap.value = lights.state.spotShadowMap;
- uniforms.spotShadowMatrix.value = lights.state.spotShadowMatrix;
- uniforms.pointShadowMap.value = lights.state.pointShadowMap;
- uniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;
- }
- var progUniforms = materialProperties.program.getUniforms(), uniformsList = WebGLUniforms.seqWithValue(progUniforms.seq, uniforms);
- materialProperties.uniformsList = uniformsList;
- }
- function setProgram(camera, scene, material, object) {
- textures.resetTextureUnits();
- var fog = scene.fog;
- var environment = material.isMeshStandardMaterial ? scene.environment : null;
- var materialProperties = properties.get(material);
- var lights = currentRenderState.state.lights;
- if (_clippingEnabled) {
- if (_localClippingEnabled || camera !== _currentCamera) {
- var useCache = camera === _currentCamera && material.id === _currentMaterialId;
- _clipping.setState(
- material.clippingPlanes,
- material.clipIntersection,
- material.clipShadows,
- camera,
- materialProperties,
- useCache
- );
- }
- }
- if (material.version === materialProperties.__version) {
- if (materialProperties.program === void 0) {
- initMaterial(material, scene, object);
- } else if (material.fog && materialProperties.fog !== fog) {
- initMaterial(material, scene, object);
- } else if (materialProperties.environment !== environment) {
- initMaterial(material, scene, object);
- } else if (materialProperties.needsLights && materialProperties.lightsStateVersion !== lights.state.version) {
- initMaterial(material, scene, object);
- } else if (materialProperties.numClippingPlanes !== void 0 && (materialProperties.numClippingPlanes !== _clipping.numPlanes || materialProperties.numIntersection !== _clipping.numIntersection)) {
- initMaterial(material, scene, object);
- } else if (materialProperties.outputEncoding !== _this.outputEncoding) {
- initMaterial(material, scene, object);
- }
- } else {
- initMaterial(material, scene, object);
- materialProperties.__version = material.version;
- }
- var refreshProgram = false;
- var refreshMaterial = false;
- var refreshLights = false;
- var program = materialProperties.program, p_uniforms = program.getUniforms(), m_uniforms = materialProperties.uniforms;
- if (state.useProgram(program.program)) {
- refreshProgram = true;
- refreshMaterial = true;
- refreshLights = true;
- }
- if (material.id !== _currentMaterialId) {
- _currentMaterialId = material.id;
- refreshMaterial = true;
- }
- if (refreshProgram || _currentCamera !== camera) {
- if (program.numMultiviewViews > 0) {
- multiview.updateCameraProjectionMatricesUniform(camera, p_uniforms);
- } else {
- p_uniforms.setValue(_gl, "projectionMatrix", camera.projectionMatrix);
- }
- if (capabilities.logarithmicDepthBuffer) {
- p_uniforms.setValue(
- _gl,
- "logDepthBufFC",
- 2 / (Math.log(camera.far + 1) / Math.LN2)
- );
- }
- if (_currentCamera !== camera) {
- _currentCamera = camera;
- refreshMaterial = true;
- refreshLights = true;
- }
- if (material.isShaderMaterial || material.isMeshPhongMaterial || material.isMeshToonMaterial || material.isMeshStandardMaterial || material.envMap) {
- var uCamPos = p_uniforms.map.cameraPosition;
- if (uCamPos !== void 0) {
- uCamPos.setValue(
- _gl,
- _vector3.setFromMatrixPosition(camera.matrixWorld)
- );
- }
- }
- if (material.isMeshPhongMaterial || material.isMeshToonMaterial || material.isMeshLambertMaterial || material.isMeshBasicMaterial || material.isMeshStandardMaterial || material.isShaderMaterial) {
- p_uniforms.setValue(_gl, "isOrthographic", camera.isOrthographicCamera === true);
- }
- if (material.isMeshPhongMaterial || material.isMeshToonMaterial || material.isMeshLambertMaterial || material.isMeshBasicMaterial || material.isMeshStandardMaterial || material.isShaderMaterial || material.skinning) {
- if (program.numMultiviewViews > 0) {
- multiview.updateCameraViewMatricesUniform(camera, p_uniforms);
- } else {
- p_uniforms.setValue(_gl, "viewMatrix", camera.matrixWorldInverse);
- }
- }
- }
- if (material.skinning) {
- p_uniforms.setOptional(_gl, object, "bindMatrix");
- p_uniforms.setOptional(_gl, object, "bindMatrixInverse");
- var skeleton = object.skeleton;
- if (skeleton) {
- var bones = skeleton.bones;
- if (capabilities.floatVertexTextures) {
- if (skeleton.boneTexture === void 0) {
- var size = Math.sqrt(bones.length * 4);
- size = MathUtils.ceilPowerOfTwo(size);
- size = Math.max(size, 4);
- var boneMatrices = new Float32Array(size * size * 4);
- boneMatrices.set(skeleton.boneMatrices);
- var boneTexture = new DataTexture(boneMatrices, size, size, RGBAFormat, FloatType);
- skeleton.boneMatrices = boneMatrices;
- skeleton.boneTexture = boneTexture;
- skeleton.boneTextureSize = size;
- }
- p_uniforms.setValue(_gl, "boneTexture", skeleton.boneTexture, textures);
- p_uniforms.setValue(_gl, "boneTextureSize", skeleton.boneTextureSize);
- } else {
- p_uniforms.setOptional(_gl, skeleton, "boneMatrices");
- }
- }
- }
- if (refreshMaterial || materialProperties.receiveShadow !== object.receiveShadow) {
- materialProperties.receiveShadow = object.receiveShadow;
- p_uniforms.setValue(_gl, "receiveShadow", object.receiveShadow);
- }
- if (refreshMaterial) {
- p_uniforms.setValue(_gl, "toneMappingExposure", _this.toneMappingExposure);
- p_uniforms.setValue(_gl, "toneMappingWhitePoint", _this.toneMappingWhitePoint);
- if (materialProperties.needsLights) {
- markUniformsLightsNeedsUpdate(m_uniforms, refreshLights);
- }
- if (fog && material.fog) {
- refreshUniformsFog(m_uniforms, fog);
- }
- if (material.isMeshBasicMaterial) {
- refreshUniformsCommon(m_uniforms, material);
- } else if (material.isMeshLambertMaterial) {
- refreshUniformsCommon(m_uniforms, material);
- refreshUniformsLambert(m_uniforms, material);
- } else if (material.isMeshToonMaterial) {
- refreshUniformsCommon(m_uniforms, material);
- refreshUniformsToon(m_uniforms, material);
- } else if (material.isMeshPhongMaterial) {
- refreshUniformsCommon(m_uniforms, material);
- refreshUniformsPhong(m_uniforms, material);
- } else if (material.isMeshStandardMaterial) {
- refreshUniformsCommon(m_uniforms, material, environment);
- if (material.isMeshPhysicalMaterial) {
- refreshUniformsPhysical(m_uniforms, material, environment);
- } else {
- refreshUniformsStandard(m_uniforms, material, environment);
- }
- } else if (material.isMeshMatcapMaterial) {
- refreshUniformsCommon(m_uniforms, material);
- refreshUniformsMatcap(m_uniforms, material);
- } else if (material.isMeshDepthMaterial) {
- refreshUniformsCommon(m_uniforms, material);
- refreshUniformsDepth(m_uniforms, material);
- } else if (material.isMeshDistanceMaterial) {
- refreshUniformsCommon(m_uniforms, material);
- refreshUniformsDistance(m_uniforms, material);
- } else if (material.isMeshNormalMaterial) {
- refreshUniformsCommon(m_uniforms, material);
- refreshUniformsNormal(m_uniforms, material);
- } else if (material.isLineBasicMaterial) {
- refreshUniformsLine(m_uniforms, material);
- if (material.isLineDashedMaterial) {
- refreshUniformsDash(m_uniforms, material);
- }
- } else if (material.isPointsMaterial) {
- refreshUniformsPoints(m_uniforms, material);
- } else if (material.isSpriteMaterial) {
- refreshUniformsSprites(m_uniforms, material);
- } else if (material.isShadowMaterial) {
- m_uniforms.color.value.copy(material.color);
- m_uniforms.opacity.value = material.opacity;
- }
- if (m_uniforms.ltc_1 !== void 0)
- m_uniforms.ltc_1.value = UniformsLib.LTC_1;
- if (m_uniforms.ltc_2 !== void 0)
- m_uniforms.ltc_2.value = UniformsLib.LTC_2;
- WebGLUniforms.upload(_gl, materialProperties.uniformsList, m_uniforms, textures);
- if (material.isShaderMaterial) {
- material.uniformsNeedUpdate = false;
- }
- }
- if (material.isShaderMaterial && material.uniformsNeedUpdate === true) {
- WebGLUniforms.upload(_gl, materialProperties.uniformsList, m_uniforms, textures);
- material.uniformsNeedUpdate = false;
- }
- if (material.isSpriteMaterial) {
- p_uniforms.setValue(_gl, "center", object.center);
- }
- if (program.numMultiviewViews > 0) {
- multiview.updateObjectMatricesUniforms(object, camera, p_uniforms);
- } else {
- p_uniforms.setValue(_gl, "modelViewMatrix", object.modelViewMatrix);
- p_uniforms.setValue(_gl, "normalMatrix", object.normalMatrix);
- }
- p_uniforms.setValue(_gl, "modelMatrix", object.matrixWorld);
- return program;
- }
- function refreshUniformsCommon(uniforms, material, environment) {
- uniforms.opacity.value = material.opacity;
- if (material.color) {
- uniforms.diffuse.value.copy(material.color);
- }
- if (material.emissive) {
- uniforms.emissive.value.copy(material.emissive).multiplyScalar(material.emissiveIntensity);
- }
- if (material.map) {
- uniforms.map.value = material.map;
- }
- if (material.alphaMap) {
- uniforms.alphaMap.value = material.alphaMap;
- }
- if (material.specularMap) {
- uniforms.specularMap.value = material.specularMap;
- }
- var envMap = material.envMap || environment;
- if (envMap) {
- uniforms.envMap.value = envMap;
- uniforms.flipEnvMap.value = envMap.isCubeTexture ? -1 : 1;
- uniforms.reflectivity.value = material.reflectivity;
- uniforms.refractionRatio.value = material.refractionRatio;
- uniforms.maxMipLevel.value = properties.get(envMap).__maxMipLevel;
- }
- if (material.lightMap) {
- uniforms.lightMap.value = material.lightMap;
- uniforms.lightMapIntensity.value = material.lightMapIntensity;
- }
- if (material.aoMap) {
- uniforms.aoMap.value = material.aoMap;
- uniforms.aoMapIntensity.value = material.aoMapIntensity;
- }
- var uvScaleMap;
- if (material.map) {
- uvScaleMap = material.map;
- } else if (material.specularMap) {
- uvScaleMap = material.specularMap;
- } else if (material.displacementMap) {
- uvScaleMap = material.displacementMap;
- } else if (material.normalMap) {
- uvScaleMap = material.normalMap;
- } else if (material.bumpMap) {
- uvScaleMap = material.bumpMap;
- } else if (material.roughnessMap) {
- uvScaleMap = material.roughnessMap;
- } else if (material.metalnessMap) {
- uvScaleMap = material.metalnessMap;
- } else if (material.alphaMap) {
- uvScaleMap = material.alphaMap;
- } else if (material.emissiveMap) {
- uvScaleMap = material.emissiveMap;
- }
- if (uvScaleMap !== void 0) {
- if (uvScaleMap.isWebGLRenderTarget) {
- uvScaleMap = uvScaleMap.texture;
- }
- if (uvScaleMap.matrixAutoUpdate === true) {
- uvScaleMap.updateMatrix();
- }
- uniforms.uvTransform.value.copy(uvScaleMap.matrix);
- }
- var uv2ScaleMap;
- if (material.aoMap) {
- uv2ScaleMap = material.aoMap;
- } else if (material.lightMap) {
- uv2ScaleMap = material.lightMap;
- }
- if (uv2ScaleMap !== void 0) {
- if (uv2ScaleMap.isWebGLRenderTarget) {
- uv2ScaleMap = uv2ScaleMap.texture;
- }
- if (uv2ScaleMap.matrixAutoUpdate === true) {
- uv2ScaleMap.updateMatrix();
- }
- uniforms.uv2Transform.value.copy(uv2ScaleMap.matrix);
- }
- }
- function refreshUniformsLine(uniforms, material) {
- uniforms.diffuse.value.copy(material.color);
- uniforms.opacity.value = material.opacity;
- }
- function refreshUniformsDash(uniforms, material) {
- uniforms.dashSize.value = material.dashSize;
- uniforms.totalSize.value = material.dashSize + material.gapSize;
- uniforms.scale.value = material.scale;
- }
- function refreshUniformsPoints(uniforms, material) {
- uniforms.diffuse.value.copy(material.color);
- uniforms.opacity.value = material.opacity;
- uniforms.size.value = material.size * _pixelRatio;
- uniforms.scale.value = _height * 0.5;
- if (material.map) {
- uniforms.map.value = material.map;
- }
- if (material.alphaMap) {
- uniforms.alphaMap.value = material.alphaMap;
- }
- var uvScaleMap;
- if (material.map) {
- uvScaleMap = material.map;
- } else if (material.alphaMap) {
- uvScaleMap = material.alphaMap;
- }
- if (uvScaleMap !== void 0) {
- if (uvScaleMap.matrixAutoUpdate === true) {
- uvScaleMap.updateMatrix();
- }
- uniforms.uvTransform.value.copy(uvScaleMap.matrix);
- }
- }
- function refreshUniformsSprites(uniforms, material) {
- uniforms.diffuse.value.copy(material.color);
- uniforms.opacity.value = material.opacity;
- uniforms.rotation.value = material.rotation;
- if (material.map) {
- uniforms.map.value = material.map;
- }
- if (material.alphaMap) {
- uniforms.alphaMap.value = material.alphaMap;
- }
- var uvScaleMap;
- if (material.map) {
- uvScaleMap = material.map;
- } else if (material.alphaMap) {
- uvScaleMap = material.alphaMap;
- }
- if (uvScaleMap !== void 0) {
- if (uvScaleMap.matrixAutoUpdate === true) {
- uvScaleMap.updateMatrix();
- }
- uniforms.uvTransform.value.copy(uvScaleMap.matrix);
- }
- }
- function refreshUniformsFog(uniforms, fog) {
- uniforms.fogColor.value.copy(fog.color);
- if (fog.isFog) {
- uniforms.fogNear.value = fog.near;
- uniforms.fogFar.value = fog.far;
- } else if (fog.isFogExp2) {
- uniforms.fogDensity.value = fog.density;
- }
- }
- function refreshUniformsLambert(uniforms, material) {
- if (material.emissiveMap) {
- uniforms.emissiveMap.value = material.emissiveMap;
- }
- }
- function refreshUniformsPhong(uniforms, material) {
- uniforms.specular.value.copy(material.specular);
- uniforms.shininess.value = Math.max(material.shininess, 1e-4);
- if (material.emissiveMap) {
- uniforms.emissiveMap.value = material.emissiveMap;
- }
- if (material.bumpMap) {
- uniforms.bumpMap.value = material.bumpMap;
- uniforms.bumpScale.value = material.bumpScale;
- if (material.side === BackSide)
- uniforms.bumpScale.value *= -1;
- }
- if (material.normalMap) {
- uniforms.normalMap.value = material.normalMap;
- uniforms.normalScale.value.copy(material.normalScale);
- if (material.side === BackSide)
- uniforms.normalScale.value.negate();
- }
- if (material.displacementMap) {
- uniforms.displacementMap.value = material.displacementMap;
- uniforms.displacementScale.value = material.displacementScale;
- uniforms.displacementBias.value = material.displacementBias;
- }
- }
- function refreshUniformsToon(uniforms, material) {
- uniforms.specular.value.copy(material.specular);
- uniforms.shininess.value = Math.max(material.shininess, 1e-4);
- if (material.gradientMap) {
- uniforms.gradientMap.value = material.gradientMap;
- }
- if (material.emissiveMap) {
- uniforms.emissiveMap.value = material.emissiveMap;
- }
- if (material.bumpMap) {
- uniforms.bumpMap.value = material.bumpMap;
- uniforms.bumpScale.value = material.bumpScale;
- if (material.side === BackSide)
- uniforms.bumpScale.value *= -1;
- }
- if (material.normalMap) {
- uniforms.normalMap.value = material.normalMap;
- uniforms.normalScale.value.copy(material.normalScale);
- if (material.side === BackSide)
- uniforms.normalScale.value.negate();
- }
- if (material.displacementMap) {
- uniforms.displacementMap.value = material.displacementMap;
- uniforms.displacementScale.value = material.displacementScale;
- uniforms.displacementBias.value = material.displacementBias;
- }
- }
- function refreshUniformsStandard(uniforms, material, environment) {
- uniforms.roughness.value = material.roughness;
- uniforms.metalness.value = material.metalness;
- if (material.roughnessMap) {
- uniforms.roughnessMap.value = material.roughnessMap;
- }
- if (material.metalnessMap) {
- uniforms.metalnessMap.value = material.metalnessMap;
- }
- if (material.emissiveMap) {
- uniforms.emissiveMap.value = material.emissiveMap;
- }
- if (material.bumpMap) {
- uniforms.bumpMap.value = material.bumpMap;
- uniforms.bumpScale.value = material.bumpScale;
- if (material.side === BackSide)
- uniforms.bumpScale.value *= -1;
- }
- if (material.normalMap) {
- uniforms.normalMap.value = material.normalMap;
- uniforms.normalScale.value.copy(material.normalScale);
- if (material.side === BackSide)
- uniforms.normalScale.value.negate();
- }
- if (material.displacementMap) {
- uniforms.displacementMap.value = material.displacementMap;
- uniforms.displacementScale.value = material.displacementScale;
- uniforms.displacementBias.value = material.displacementBias;
- }
- if (material.envMap || environment) {
- uniforms.envMapIntensity.value = material.envMapIntensity;
- }
- }
- function refreshUniformsPhysical(uniforms, material, environment) {
- refreshUniformsStandard(uniforms, material, environment);
- uniforms.reflectivity.value = material.reflectivity;
- uniforms.clearcoat.value = material.clearcoat;
- uniforms.clearcoatRoughness.value = material.clearcoatRoughness;
- if (material.sheen)
- uniforms.sheen.value.copy(material.sheen);
- if (material.clearcoatNormalMap) {
- uniforms.clearcoatNormalScale.value.copy(material.clearcoatNormalScale);
- uniforms.clearcoatNormalMap.value = material.clearcoatNormalMap;
- if (material.side === BackSide) {
- uniforms.clearcoatNormalScale.value.negate();
- }
- }
- uniforms.transparency.value = material.transparency;
- }
- function refreshUniformsMatcap(uniforms, material) {
- if (material.matcap) {
- uniforms.matcap.value = material.matcap;
- }
- if (material.bumpMap) {
- uniforms.bumpMap.value = material.bumpMap;
- uniforms.bumpScale.value = material.bumpScale;
- if (material.side === BackSide)
- uniforms.bumpScale.value *= -1;
- }
- if (material.normalMap) {
- uniforms.normalMap.value = material.normalMap;
- uniforms.normalScale.value.copy(material.normalScale);
- if (material.side === BackSide)
- uniforms.normalScale.value.negate();
- }
- if (material.displacementMap) {
- uniforms.displacementMap.value = material.displacementMap;
- uniforms.displacementScale.value = material.displacementScale;
- uniforms.displacementBias.value = material.displacementBias;
- }
- }
- function refreshUniformsDepth(uniforms, material) {
- if (material.displacementMap) {
- uniforms.displacementMap.value = material.displacementMap;
- uniforms.displacementScale.value = material.displacementScale;
- uniforms.displacementBias.value = material.displacementBias;
- }
- }
- function refreshUniformsDistance(uniforms, material) {
- if (material.displacementMap) {
- uniforms.displacementMap.value = material.displacementMap;
- uniforms.displacementScale.value = material.displacementScale;
- uniforms.displacementBias.value = material.displacementBias;
- }
- uniforms.referencePosition.value.copy(material.referencePosition);
- uniforms.nearDistance.value = material.nearDistance;
- uniforms.farDistance.value = material.farDistance;
- }
- function refreshUniformsNormal(uniforms, material) {
- if (material.bumpMap) {
- uniforms.bumpMap.value = material.bumpMap;
- uniforms.bumpScale.value = material.bumpScale;
- if (material.side === BackSide)
- uniforms.bumpScale.value *= -1;
- }
- if (material.normalMap) {
- uniforms.normalMap.value = material.normalMap;
- uniforms.normalScale.value.copy(material.normalScale);
- if (material.side === BackSide)
- uniforms.normalScale.value.negate();
- }
- if (material.displacementMap) {
- uniforms.displacementMap.value = material.displacementMap;
- uniforms.displacementScale.value = material.displacementScale;
- uniforms.displacementBias.value = material.displacementBias;
- }
- }
- function markUniformsLightsNeedsUpdate(uniforms, value) {
- uniforms.ambientLightColor.needsUpdate = value;
- uniforms.lightProbe.needsUpdate = value;
- uniforms.directionalLights.needsUpdate = value;
- uniforms.pointLights.needsUpdate = value;
- uniforms.spotLights.needsUpdate = value;
- uniforms.rectAreaLights.needsUpdate = value;
- uniforms.hemisphereLights.needsUpdate = value;
- }
- function materialNeedsLights(material) {
- return material.isMeshLambertMaterial || material.isMeshToonMaterial || material.isMeshPhongMaterial || material.isMeshStandardMaterial || material.isShadowMaterial || material.isShaderMaterial && material.lights === true;
- }
- this.setFramebuffer = function(value) {
- if (_framebuffer !== value && _currentRenderTarget === null)
- _gl.bindFramebuffer(36160, value);
- _framebuffer = value;
- };
- this.getActiveCubeFace = function() {
- return _currentActiveCubeFace;
- };
- this.getActiveMipmapLevel = function() {
- return _currentActiveMipmapLevel;
- };
- this.getRenderTarget = function() {
- return _currentRenderTarget;
- };
- this.setRenderTarget = function(renderTarget, activeCubeFace, activeMipmapLevel) {
- _currentRenderTarget = renderTarget;
- _currentActiveCubeFace = activeCubeFace;
- _currentActiveMipmapLevel = activeMipmapLevel;
- if (renderTarget && properties.get(renderTarget).__webglFramebuffer === void 0) {
- textures.setupRenderTarget(renderTarget);
- }
- var framebuffer = _framebuffer;
- var isCube = false;
- if (renderTarget) {
- var __webglFramebuffer = properties.get(renderTarget).__webglFramebuffer;
- if (renderTarget.isWebGLCubeRenderTarget) {
- framebuffer = __webglFramebuffer[activeCubeFace || 0];
- isCube = true;
- } else if (renderTarget.isWebGLMultisampleRenderTarget) {
- framebuffer = properties.get(renderTarget).__webglMultisampledFramebuffer;
- } else {
- framebuffer = __webglFramebuffer;
- }
- _currentViewport.copy(renderTarget.viewport);
- _currentScissor.copy(renderTarget.scissor);
- _currentScissorTest = renderTarget.scissorTest;
- } else {
- _currentViewport.copy(_viewport).multiplyScalar(_pixelRatio).floor();
- _currentScissor.copy(_scissor).multiplyScalar(_pixelRatio).floor();
- _currentScissorTest = _scissorTest;
- }
- if (_currentFramebuffer !== framebuffer) {
- _gl.bindFramebuffer(36160, framebuffer);
- _currentFramebuffer = framebuffer;
- }
- state.viewport(_currentViewport);
- state.scissor(_currentScissor);
- state.setScissorTest(_currentScissorTest);
- if (isCube) {
- var textureProperties = properties.get(renderTarget.texture);
- _gl.framebufferTexture2D(36160, 36064, 34069 + (activeCubeFace || 0), textureProperties.__webglTexture, activeMipmapLevel || 0);
- }
- };
- this.readRenderTargetPixels = function(renderTarget, x, y, width, height, buffer, activeCubeFaceIndex) {
- if (!(renderTarget && renderTarget.isWebGLRenderTarget)) {
- console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
- return;
- }
- var framebuffer = properties.get(renderTarget).__webglFramebuffer;
- if (renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== void 0) {
- framebuffer = framebuffer[activeCubeFaceIndex];
- }
- if (framebuffer) {
- var restore = false;
- if (framebuffer !== _currentFramebuffer) {
- _gl.bindFramebuffer(36160, framebuffer);
- restore = true;
- }
- try {
- var texture = renderTarget.texture;
- var textureFormat = texture.format;
- var textureType = texture.type;
- if (textureFormat !== RGBAFormat && utils.convert(textureFormat) !== _gl.getParameter(35739)) {
- console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");
- return;
- }
- if (textureType !== UnsignedByteType && utils.convert(textureType) !== _gl.getParameter(35738) && // IE11, Edge and Chrome Mac < 52 (#9513)
- !(textureType === FloatType && (capabilities.isWebGL2 || extensions.get("OES_texture_float") || extensions.get("WEBGL_color_buffer_float"))) && // Chrome Mac >= 52 and Firefox
- !(textureType === HalfFloatType && (capabilities.isWebGL2 ? extensions.get("EXT_color_buffer_float") : extensions.get("EXT_color_buffer_half_float")))) {
- console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");
- return;
- }
- if (_gl.checkFramebufferStatus(36160) === 36053) {
- if (x >= 0 && x <= renderTarget.width - width && (y >= 0 && y <= renderTarget.height - height)) {
- _gl.readPixels(x, y, width, height, utils.convert(textureFormat), utils.convert(textureType), buffer);
- }
- } else {
- console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.");
- }
- } finally {
- if (restore) {
- _gl.bindFramebuffer(36160, _currentFramebuffer);
- }
- }
- }
- };
- this.copyFramebufferToTexture = function(position, texture, level) {
- if (level === void 0)
- level = 0;
- var levelScale = Math.pow(2, -level);
- var width = Math.floor(texture.image.width * levelScale);
- var height = Math.floor(texture.image.height * levelScale);
- var glFormat = utils.convert(texture.format);
- textures.setTexture2D(texture, 0);
- _gl.copyTexImage2D(3553, level, glFormat, position.x, position.y, width, height, 0);
- state.unbindTexture();
- };
- this.copyTextureToTexture = function(position, srcTexture, dstTexture, level) {
- var width = srcTexture.image.width;
- var height = srcTexture.image.height;
- var glFormat = utils.convert(dstTexture.format);
- var glType = utils.convert(dstTexture.type);
- textures.setTexture2D(dstTexture, 0);
- if (srcTexture.isDataTexture) {
- _gl.texSubImage2D(3553, level || 0, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data);
- } else {
- _gl.texSubImage2D(3553, level || 0, position.x, position.y, glFormat, glType, srcTexture.image);
- }
- state.unbindTexture();
- };
- this.initTexture = function(texture) {
- textures.setTexture2D(texture, 0);
- state.unbindTexture();
- };
- if (typeof __THREE_DEVTOOLS__ !== "undefined") {
- __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
- }
- }
- function FogExp2(color, density) {
- this.name = "";
- this.color = new Color(color);
- this.density = density !== void 0 ? density : 25e-5;
- }
- Object.assign(FogExp2.prototype, {
- isFogExp2: true,
- clone: function() {
- return new FogExp2(this.color, this.density);
- },
- toJSON: function() {
- return {
- type: "FogExp2",
- color: this.color.getHex(),
- density: this.density
- };
- }
- });
- function Fog(color, near, far) {
- this.name = "";
- this.color = new Color(color);
- this.near = near !== void 0 ? near : 1;
- this.far = far !== void 0 ? far : 1e3;
- }
- Object.assign(Fog.prototype, {
- isFog: true,
- clone: function() {
- return new Fog(this.color, this.near, this.far);
- },
- toJSON: function() {
- return {
- type: "Fog",
- color: this.color.getHex(),
- near: this.near,
- far: this.far
- };
- }
- });
- function InterleavedBuffer(array, stride) {
- this.array = array;
- this.stride = stride;
- this.count = array !== void 0 ? array.length / stride : 0;
- this.usage = StaticDrawUsage;
- this.updateRange = { offset: 0, count: -1 };
- this.version = 0;
- }
- Object.defineProperty(InterleavedBuffer.prototype, "needsUpdate", {
- set: function(value) {
- if (value === true)
- this.version++;
- }
- });
- Object.assign(InterleavedBuffer.prototype, {
- isInterleavedBuffer: true,
- onUploadCallback: function() {
- },
- setUsage: function(value) {
- this.usage = value;
- return this;
- },
- copy: function(source) {
- this.array = new source.array.constructor(source.array);
- this.count = source.count;
- this.stride = source.stride;
- this.usage = source.usage;
- return this;
- },
- copyAt: function(index1, attribute, index2) {
- index1 *= this.stride;
- index2 *= attribute.stride;
- for (var i2 = 0, l = this.stride; i2 < l; i2++) {
- this.array[index1 + i2] = attribute.array[index2 + i2];
- }
- return this;
- },
- set: function(value, offset) {
- if (offset === void 0)
- offset = 0;
- this.array.set(value, offset);
- return this;
- },
- clone: function() {
- return new this.constructor().copy(this);
- },
- onUpload: function(callback) {
- this.onUploadCallback = callback;
- return this;
- }
- });
- var _vector$6 = new Vector3();
- function InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, normalized) {
- this.data = interleavedBuffer;
- this.itemSize = itemSize;
- this.offset = offset;
- this.normalized = normalized === true;
- }
- Object.defineProperties(InterleavedBufferAttribute.prototype, {
- count: {
- get: function() {
- return this.data.count;
- }
- },
- array: {
- get: function() {
- return this.data.array;
- }
- }
- });
- Object.assign(InterleavedBufferAttribute.prototype, {
- isInterleavedBufferAttribute: true,
- applyMatrix4: function(m) {
- for (var i2 = 0, l = this.data.count; i2 < l; i2++) {
- _vector$6.x = this.getX(i2);
- _vector$6.y = this.getY(i2);
- _vector$6.z = this.getZ(i2);
- _vector$6.applyMatrix4(m);
- this.setXYZ(i2, _vector$6.x, _vector$6.y, _vector$6.z);
- }
- return this;
- },
- setX: function(index, x) {
- this.data.array[index * this.data.stride + this.offset] = x;
- return this;
- },
- setY: function(index, y) {
- this.data.array[index * this.data.stride + this.offset + 1] = y;
- return this;
- },
- setZ: function(index, z) {
- this.data.array[index * this.data.stride + this.offset + 2] = z;
- return this;
- },
- setW: function(index, w) {
- this.data.array[index * this.data.stride + this.offset + 3] = w;
- return this;
- },
- getX: function(index) {
- return this.data.array[index * this.data.stride + this.offset];
- },
- getY: function(index) {
- return this.data.array[index * this.data.stride + this.offset + 1];
- },
- getZ: function(index) {
- return this.data.array[index * this.data.stride + this.offset + 2];
- },
- getW: function(index) {
- return this.data.array[index * this.data.stride + this.offset + 3];
- },
- setXY: function(index, x, y) {
- index = index * this.data.stride + this.offset;
- this.data.array[index + 0] = x;
- this.data.array[index + 1] = y;
- return this;
- },
- setXYZ: function(index, x, y, z) {
- index = index * this.data.stride + this.offset;
- this.data.array[index + 0] = x;
- this.data.array[index + 1] = y;
- this.data.array[index + 2] = z;
- return this;
- },
- setXYZW: function(index, x, y, z, w) {
- index = index * this.data.stride + this.offset;
- this.data.array[index + 0] = x;
- this.data.array[index + 1] = y;
- this.data.array[index + 2] = z;
- this.data.array[index + 3] = w;
- return this;
- }
- });
- function SpriteMaterial(parameters) {
- Material.call(this);
- this.type = "SpriteMaterial";
- this.color = new Color(16777215);
- this.map = null;
- this.alphaMap = null;
- this.rotation = 0;
- this.sizeAttenuation = true;
- this.transparent = true;
- this.setValues(parameters);
- }
- SpriteMaterial.prototype = Object.create(Material.prototype);
- SpriteMaterial.prototype.constructor = SpriteMaterial;
- SpriteMaterial.prototype.isSpriteMaterial = true;
- SpriteMaterial.prototype.copy = function(source) {
- Material.prototype.copy.call(this, source);
- this.color.copy(source.color);
- this.map = source.map;
- this.alphaMap = source.alphaMap;
- this.rotation = source.rotation;
- this.sizeAttenuation = source.sizeAttenuation;
- return this;
- };
- var _geometry;
- var _intersectPoint = new Vector3();
- var _worldScale = new Vector3();
- var _mvPosition = new Vector3();
- var _alignedPosition = new Vector2();
- var _rotatedPosition = new Vector2();
- var _viewWorldMatrix = new Matrix4();
- var _vA$1 = new Vector3();
- var _vB$1 = new Vector3();
- var _vC$1 = new Vector3();
- var _uvA$1 = new Vector2();
- var _uvB$1 = new Vector2();
- var _uvC$1 = new Vector2();
- function Sprite(material) {
- Object3D.call(this);
- this.type = "Sprite";
- if (_geometry === void 0) {
- _geometry = new BufferGeometry();
- var float32Array = new Float32Array([
- -0.5,
- -0.5,
- 0,
- 0,
- 0,
- 0.5,
- -0.5,
- 0,
- 1,
- 0,
- 0.5,
- 0.5,
- 0,
- 1,
- 1,
- -0.5,
- 0.5,
- 0,
- 0,
- 1
- ]);
- var interleavedBuffer = new InterleavedBuffer(float32Array, 5);
- _geometry.setIndex([0, 1, 2, 0, 2, 3]);
- _geometry.setAttribute("position", new InterleavedBufferAttribute(interleavedBuffer, 3, 0, false));
- _geometry.setAttribute("uv", new InterleavedBufferAttribute(interleavedBuffer, 2, 3, false));
- }
- this.geometry = _geometry;
- this.material = material !== void 0 ? material : new SpriteMaterial();
- this.center = new Vector2(0.5, 0.5);
- }
- Sprite.prototype = Object.assign(Object.create(Object3D.prototype), {
- constructor: Sprite,
- isSprite: true,
- raycast: function(raycaster, intersects2) {
- if (raycaster.camera === null) {
- console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.');
- }
- _worldScale.setFromMatrixScale(this.matrixWorld);
- _viewWorldMatrix.copy(raycaster.camera.matrixWorld);
- this.modelViewMatrix.multiplyMatrices(raycaster.camera.matrixWorldInverse, this.matrixWorld);
- _mvPosition.setFromMatrixPosition(this.modelViewMatrix);
- if (raycaster.camera.isPerspectiveCamera && this.material.sizeAttenuation === false) {
- _worldScale.multiplyScalar(-_mvPosition.z);
- }
- var rotation = this.material.rotation;
- var sin, cos;
- if (rotation !== 0) {
- cos = Math.cos(rotation);
- sin = Math.sin(rotation);
- }
- var center = this.center;
- transformVertex(_vA$1.set(-0.5, -0.5, 0), _mvPosition, center, _worldScale, sin, cos);
- transformVertex(_vB$1.set(0.5, -0.5, 0), _mvPosition, center, _worldScale, sin, cos);
- transformVertex(_vC$1.set(0.5, 0.5, 0), _mvPosition, center, _worldScale, sin, cos);
- _uvA$1.set(0, 0);
- _uvB$1.set(1, 0);
- _uvC$1.set(1, 1);
- var intersect = raycaster.ray.intersectTriangle(_vA$1, _vB$1, _vC$1, false, _intersectPoint);
- if (intersect === null) {
- transformVertex(_vB$1.set(-0.5, 0.5, 0), _mvPosition, center, _worldScale, sin, cos);
- _uvB$1.set(0, 1);
- intersect = raycaster.ray.intersectTriangle(_vA$1, _vC$1, _vB$1, false, _intersectPoint);
- if (intersect === null) {
- return;
- }
- }
- var distance = raycaster.ray.origin.distanceTo(_intersectPoint);
- if (distance < raycaster.near || distance > raycaster.far)
- return;
- intersects2.push({
- distance,
- point: _intersectPoint.clone(),
- uv: Triangle.getUV(_intersectPoint, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2()),
- face: null,
- object: this
- });
- },
- clone: function() {
- return new this.constructor(this.material).copy(this);
- },
- copy: function(source) {
- Object3D.prototype.copy.call(this, source);
- if (source.center !== void 0)
- this.center.copy(source.center);
- return this;
- }
- });
- function transformVertex(vertexPosition, mvPosition, center, scale, sin, cos) {
- _alignedPosition.subVectors(vertexPosition, center).addScalar(0.5).multiply(scale);
- if (sin !== void 0) {
- _rotatedPosition.x = cos * _alignedPosition.x - sin * _alignedPosition.y;
- _rotatedPosition.y = sin * _alignedPosition.x + cos * _alignedPosition.y;
- } else {
- _rotatedPosition.copy(_alignedPosition);
- }
- vertexPosition.copy(mvPosition);
- vertexPosition.x += _rotatedPosition.x;
- vertexPosition.y += _rotatedPosition.y;
- vertexPosition.applyMatrix4(_viewWorldMatrix);
- }
- var _v1$4 = new Vector3();
- var _v2$2 = new Vector3();
- function LOD() {
- Object3D.call(this);
- this.type = "LOD";
- Object.defineProperties(this, {
- levels: {
- enumerable: true,
- value: []
- }
- });
- this.autoUpdate = true;
- }
- LOD.prototype = Object.assign(Object.create(Object3D.prototype), {
- constructor: LOD,
- isLOD: true,
- copy: function(source) {
- Object3D.prototype.copy.call(this, source, false);
- var levels = source.levels;
- for (var i2 = 0, l = levels.length; i2 < l; i2++) {
- var level = levels[i2];
- this.addLevel(level.object.clone(), level.distance);
- }
- this.autoUpdate = source.autoUpdate;
- return this;
- },
- addLevel: function(object, distance) {
- if (distance === void 0)
- distance = 0;
- distance = Math.abs(distance);
- var levels = this.levels;
- for (var l = 0; l < levels.length; l++) {
- if (distance < levels[l].distance) {
- break;
- }
- }
- levels.splice(l, 0, { distance, object });
- this.add(object);
- return this;
- },
- getObjectForDistance: function(distance) {
- var levels = this.levels;
- if (levels.length > 0) {
- for (var i2 = 1, l = levels.length; i2 < l; i2++) {
- if (distance < levels[i2].distance) {
- break;
- }
- }
- return levels[i2 - 1].object;
- }
- return null;
- },
- raycast: function(raycaster, intersects2) {
- var levels = this.levels;
- if (levels.length > 0) {
- _v1$4.setFromMatrixPosition(this.matrixWorld);
- var distance = raycaster.ray.origin.distanceTo(_v1$4);
- this.getObjectForDistance(distance).raycast(raycaster, intersects2);
- }
- },
- update: function(camera) {
- var levels = this.levels;
- if (levels.length > 1) {
- _v1$4.setFromMatrixPosition(camera.matrixWorld);
- _v2$2.setFromMatrixPosition(this.matrixWorld);
- var distance = _v1$4.distanceTo(_v2$2);
- levels[0].object.visible = true;
- for (var i2 = 1, l = levels.length; i2 < l; i2++) {
- if (distance >= levels[i2].distance) {
- levels[i2 - 1].object.visible = false;
- levels[i2].object.visible = true;
- } else {
- break;
- }
- }
- for (; i2 < l; i2++) {
- levels[i2].object.visible = false;
- }
- }
- },
- toJSON: function(meta) {
- var data = Object3D.prototype.toJSON.call(this, meta);
- if (this.autoUpdate === false)
- data.object.autoUpdate = false;
- data.object.levels = [];
- var levels = this.levels;
- for (var i2 = 0, l = levels.length; i2 < l; i2++) {
- var level = levels[i2];
- data.object.levels.push({
- object: level.object.uuid,
- distance: level.distance
- });
- }
- return data;
- }
- });
- function SkinnedMesh(geometry, material) {
- if (geometry && geometry.isGeometry) {
- console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");
- }
- Mesh.call(this, geometry, material);
- this.type = "SkinnedMesh";
- this.bindMode = "attached";
- this.bindMatrix = new Matrix4();
- this.bindMatrixInverse = new Matrix4();
- }
- SkinnedMesh.prototype = Object.assign(Object.create(Mesh.prototype), {
- constructor: SkinnedMesh,
- isSkinnedMesh: true,
- bind: function(skeleton, bindMatrix) {
- this.skeleton = skeleton;
- if (bindMatrix === void 0) {
- this.updateMatrixWorld(true);
- this.skeleton.calculateInverses();
- bindMatrix = this.matrixWorld;
- }
- this.bindMatrix.copy(bindMatrix);
- this.bindMatrixInverse.getInverse(bindMatrix);
- },
- pose: function() {
- this.skeleton.pose();
- },
- normalizeSkinWeights: function() {
- var vector = new Vector4();
- var skinWeight = this.geometry.attributes.skinWeight;
- for (var i2 = 0, l = skinWeight.count; i2 < l; i2++) {
- vector.x = skinWeight.getX(i2);
- vector.y = skinWeight.getY(i2);
- vector.z = skinWeight.getZ(i2);
- vector.w = skinWeight.getW(i2);
- var scale = 1 / vector.manhattanLength();
- if (scale !== Infinity) {
- vector.multiplyScalar(scale);
- } else {
- vector.set(1, 0, 0, 0);
- }
- skinWeight.setXYZW(i2, vector.x, vector.y, vector.z, vector.w);
- }
- },
- updateMatrixWorld: function(force) {
- Mesh.prototype.updateMatrixWorld.call(this, force);
- if (this.bindMode === "attached") {
- this.bindMatrixInverse.getInverse(this.matrixWorld);
- } else if (this.bindMode === "detached") {
- this.bindMatrixInverse.getInverse(this.bindMatrix);
- } else {
- console.warn("THREE.SkinnedMesh: Unrecognized bindMode: " + this.bindMode);
- }
- },
- clone: function() {
- return new this.constructor(this.geometry, this.material).copy(this);
- }
- });
- var _offsetMatrix = new Matrix4();
- var _identityMatrix = new Matrix4();
- function Skeleton(bones, boneInverses) {
- bones = bones || [];
- this.bones = bones.slice(0);
- this.boneMatrices = new Float32Array(this.bones.length * 16);
- this.frame = -1;
- if (boneInverses === void 0) {
- this.calculateInverses();
- } else {
- if (this.bones.length === boneInverses.length) {
- this.boneInverses = boneInverses.slice(0);
- } else {
- console.warn("THREE.Skeleton boneInverses is the wrong length.");
- this.boneInverses = [];
- for (var i2 = 0, il = this.bones.length; i2 < il; i2++) {
- this.boneInverses.push(new Matrix4());
- }
- }
- }
- }
- Object.assign(Skeleton.prototype, {
- calculateInverses: function() {
- this.boneInverses = [];
- for (var i2 = 0, il = this.bones.length; i2 < il; i2++) {
- var inverse = new Matrix4();
- if (this.bones[i2]) {
- inverse.getInverse(this.bones[i2].matrixWorld);
- }
- this.boneInverses.push(inverse);
- }
- },
- pose: function() {
- var bone, i2, il;
- for (i2 = 0, il = this.bones.length; i2 < il; i2++) {
- bone = this.bones[i2];
- if (bone) {
- bone.matrixWorld.getInverse(this.boneInverses[i2]);
- }
- }
- for (i2 = 0, il = this.bones.length; i2 < il; i2++) {
- bone = this.bones[i2];
- if (bone) {
- if (bone.parent && bone.parent.isBone) {
- bone.matrix.getInverse(bone.parent.matrixWorld);
- bone.matrix.multiply(bone.matrixWorld);
- } else {
- bone.matrix.copy(bone.matrixWorld);
- }
- bone.matrix.decompose(bone.position, bone.quaternion, bone.scale);
- }
- }
- },
- update: function() {
- var bones = this.bones;
- var boneInverses = this.boneInverses;
- var boneMatrices = this.boneMatrices;
- var boneTexture = this.boneTexture;
- for (var i2 = 0, il = bones.length; i2 < il; i2++) {
- var matrix = bones[i2] ? bones[i2].matrixWorld : _identityMatrix;
- _offsetMatrix.multiplyMatrices(matrix, boneInverses[i2]);
- _offsetMatrix.toArray(boneMatrices, i2 * 16);
- }
- if (boneTexture !== void 0) {
- boneTexture.needsUpdate = true;
- }
- },
- clone: function() {
- return new Skeleton(this.bones, this.boneInverses);
- },
- getBoneByName: function(name) {
- for (var i2 = 0, il = this.bones.length; i2 < il; i2++) {
- var bone = this.bones[i2];
- if (bone.name === name) {
- return bone;
- }
- }
- return void 0;
- }
- });
- function Bone() {
- Object3D.call(this);
- this.type = "Bone";
- }
- Bone.prototype = Object.assign(Object.create(Object3D.prototype), {
- constructor: Bone,
- isBone: true
- });
- var _instanceLocalMatrix = new Matrix4();
- var _instanceWorldMatrix = new Matrix4();
- var _instanceIntersects = [];
- var _mesh = new Mesh();
- function InstancedMesh(geometry, material, count) {
- Mesh.call(this, geometry, material);
- this.instanceMatrix = new BufferAttribute(new Float32Array(count * 16), 16);
- this.count = count;
- this.frustumCulled = false;
- }
- InstancedMesh.prototype = Object.assign(Object.create(Mesh.prototype), {
- constructor: InstancedMesh,
- isInstancedMesh: true,
- getMatrixAt: function(index, matrix) {
- matrix.fromArray(this.instanceMatrix.array, index * 16);
- },
- raycast: function(raycaster, intersects2) {
- var matrixWorld = this.matrixWorld;
- var raycastTimes = this.count;
- _mesh.geometry = this.geometry;
- _mesh.material = this.material;
- if (_mesh.material === void 0)
- return;
- for (var instanceId = 0; instanceId < raycastTimes; instanceId++) {
- this.getMatrixAt(instanceId, _instanceLocalMatrix);
- _instanceWorldMatrix.multiplyMatrices(matrixWorld, _instanceLocalMatrix);
- _mesh.matrixWorld = _instanceWorldMatrix;
- _mesh.raycast(raycaster, _instanceIntersects);
- if (_instanceIntersects.length > 0) {
- _instanceIntersects[0].instanceId = instanceId;
- _instanceIntersects[0].object = this;
- intersects2.push(_instanceIntersects[0]);
- _instanceIntersects.length = 0;
- }
- }
- },
- setMatrixAt: function(index, matrix) {
- matrix.toArray(this.instanceMatrix.array, index * 16);
- },
- updateMorphTargets: function() {
- }
- });
- function LineBasicMaterial(parameters) {
- Material.call(this);
- this.type = "LineBasicMaterial";
- this.color = new Color(16777215);
- this.linewidth = 1;
- this.linecap = "round";
- this.linejoin = "round";
- this.setValues(parameters);
- }
- LineBasicMaterial.prototype = Object.create(Material.prototype);
- LineBasicMaterial.prototype.constructor = LineBasicMaterial;
- LineBasicMaterial.prototype.isLineBasicMaterial = true;
- LineBasicMaterial.prototype.copy = function(source) {
- Material.prototype.copy.call(this, source);
- this.color.copy(source.color);
- this.linewidth = source.linewidth;
- this.linecap = source.linecap;
- this.linejoin = source.linejoin;
- return this;
- };
- var _start = new Vector3();
- var _end = new Vector3();
- var _inverseMatrix$1 = new Matrix4();
- var _ray$1 = new Ray();
- var _sphere$2 = new Sphere();
- function Line(geometry, material, mode) {
- if (mode === 1) {
- console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead.");
- }
- Object3D.call(this);
- this.type = "Line";
- this.geometry = geometry !== void 0 ? geometry : new BufferGeometry();
- this.material = material !== void 0 ? material : new LineBasicMaterial();
- }
- Line.prototype = Object.assign(Object.create(Object3D.prototype), {
- constructor: Line,
- isLine: true,
- computeLineDistances: function() {
- var geometry = this.geometry;
- if (geometry.isBufferGeometry) {
- if (geometry.index === null) {
- var positionAttribute = geometry.attributes.position;
- var lineDistances = [0];
- for (var i2 = 1, l = positionAttribute.count; i2 < l; i2++) {
- _start.fromBufferAttribute(positionAttribute, i2 - 1);
- _end.fromBufferAttribute(positionAttribute, i2);
- lineDistances[i2] = lineDistances[i2 - 1];
- lineDistances[i2] += _start.distanceTo(_end);
- }
- geometry.setAttribute("lineDistance", new Float32BufferAttribute(lineDistances, 1));
- } else {
- console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");
- }
- } else if (geometry.isGeometry) {
- var vertices = geometry.vertices;
- var lineDistances = geometry.lineDistances;
- lineDistances[0] = 0;
- for (var i2 = 1, l = vertices.length; i2 < l; i2++) {
- lineDistances[i2] = lineDistances[i2 - 1];
- lineDistances[i2] += vertices[i2 - 1].distanceTo(vertices[i2]);
- }
- }
- return this;
- },
- raycast: function(raycaster, intersects2) {
- var precision = raycaster.linePrecision;
- var geometry = this.geometry;
- var matrixWorld = this.matrixWorld;
- if (geometry.boundingSphere === null)
- geometry.computeBoundingSphere();
- _sphere$2.copy(geometry.boundingSphere);
- _sphere$2.applyMatrix4(matrixWorld);
- _sphere$2.radius += precision;
- if (raycaster.ray.intersectsSphere(_sphere$2) === false)
- return;
- _inverseMatrix$1.getInverse(matrixWorld);
- _ray$1.copy(raycaster.ray).applyMatrix4(_inverseMatrix$1);
- var localPrecision = precision / ((this.scale.x + this.scale.y + this.scale.z) / 3);
- var localPrecisionSq = localPrecision * localPrecision;
- var vStart = new Vector3();
- var vEnd = new Vector3();
- var interSegment = new Vector3();
- var interRay = new Vector3();
- var step = this && this.isLineSegments ? 2 : 1;
- if (geometry.isBufferGeometry) {
- var index = geometry.index;
- var attributes = geometry.attributes;
- var positions = attributes.position.array;
- if (index !== null) {
- var indices = index.array;
- for (var i2 = 0, l = indices.length - 1; i2 < l; i2 += step) {
- var a = indices[i2];
- var b = indices[i2 + 1];
- vStart.fromArray(positions, a * 3);
- vEnd.fromArray(positions, b * 3);
- var distSq = _ray$1.distanceSqToSegment(vStart, vEnd, interRay, interSegment);
- if (distSq > localPrecisionSq)
- continue;
- interRay.applyMatrix4(this.matrixWorld);
- var distance = raycaster.ray.origin.distanceTo(interRay);
- if (distance < raycaster.near || distance > raycaster.far)
- continue;
- intersects2.push({
- distance,
- // What do we want? intersection point on the ray or on the segment??
- // point: raycaster.ray.at( distance ),
- point: interSegment.clone().applyMatrix4(this.matrixWorld),
- index: i2,
- face: null,
- faceIndex: null,
- object: this
- });
- }
- } else {
- for (var i2 = 0, l = positions.length / 3 - 1; i2 < l; i2 += step) {
- vStart.fromArray(positions, 3 * i2);
- vEnd.fromArray(positions, 3 * i2 + 3);
- var distSq = _ray$1.distanceSqToSegment(vStart, vEnd, interRay, interSegment);
- if (distSq > localPrecisionSq)
- continue;
- interRay.applyMatrix4(this.matrixWorld);
- var distance = raycaster.ray.origin.distanceTo(interRay);
- if (distance < raycaster.near || distance > raycaster.far)
- continue;
- intersects2.push({
- distance,
- // What do we want? intersection point on the ray or on the segment??
- // point: raycaster.ray.at( distance ),
- point: interSegment.clone().applyMatrix4(this.matrixWorld),
- index: i2,
- face: null,
- faceIndex: null,
- object: this
- });
- }
- }
- } else if (geometry.isGeometry) {
- var vertices = geometry.vertices;
- var nbVertices = vertices.length;
- for (var i2 = 0; i2 < nbVertices - 1; i2 += step) {
- var distSq = _ray$1.distanceSqToSegment(vertices[i2], vertices[i2 + 1], interRay, interSegment);
- if (distSq > localPrecisionSq)
- continue;
- interRay.applyMatrix4(this.matrixWorld);
- var distance = raycaster.ray.origin.distanceTo(interRay);
- if (distance < raycaster.near || distance > raycaster.far)
- continue;
- intersects2.push({
- distance,
- // What do we want? intersection point on the ray or on the segment??
- // point: raycaster.ray.at( distance ),
- point: interSegment.clone().applyMatrix4(this.matrixWorld),
- index: i2,
- face: null,
- faceIndex: null,
- object: this
- });
- }
- }
- },
- clone: function() {
- return new this.constructor(this.geometry, this.material).copy(this);
- }
- });
- var _start$1 = new Vector3();
- var _end$1 = new Vector3();
- function LineSegments(geometry, material) {
- Line.call(this, geometry, material);
- this.type = "LineSegments";
- }
- LineSegments.prototype = Object.assign(Object.create(Line.prototype), {
- constructor: LineSegments,
- isLineSegments: true,
- computeLineDistances: function() {
- var geometry = this.geometry;
- if (geometry.isBufferGeometry) {
- if (geometry.index === null) {
- var positionAttribute = geometry.attributes.position;
- var lineDistances = [];
- for (var i2 = 0, l = positionAttribute.count; i2 < l; i2 += 2) {
- _start$1.fromBufferAttribute(positionAttribute, i2);
- _end$1.fromBufferAttribute(positionAttribute, i2 + 1);
- lineDistances[i2] = i2 === 0 ? 0 : lineDistances[i2 - 1];
- lineDistances[i2 + 1] = lineDistances[i2] + _start$1.distanceTo(_end$1);
- }
- geometry.setAttribute("lineDistance", new Float32BufferAttribute(lineDistances, 1));
- } else {
- console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");
- }
- } else if (geometry.isGeometry) {
- var vertices = geometry.vertices;
- var lineDistances = geometry.lineDistances;
- for (var i2 = 0, l = vertices.length; i2 < l; i2 += 2) {
- _start$1.copy(vertices[i2]);
- _end$1.copy(vertices[i2 + 1]);
- lineDistances[i2] = i2 === 0 ? 0 : lineDistances[i2 - 1];
- lineDistances[i2 + 1] = lineDistances[i2] + _start$1.distanceTo(_end$1);
- }
- }
- return this;
- }
- });
- function LineLoop(geometry, material) {
- Line.call(this, geometry, material);
- this.type = "LineLoop";
- }
- LineLoop.prototype = Object.assign(Object.create(Line.prototype), {
- constructor: LineLoop,
- isLineLoop: true
- });
- function PointsMaterial(parameters) {
- Material.call(this);
- this.type = "PointsMaterial";
- this.color = new Color(16777215);
- this.map = null;
- this.alphaMap = null;
- this.size = 1;
- this.sizeAttenuation = true;
- this.morphTargets = false;
- this.setValues(parameters);
- }
- PointsMaterial.prototype = Object.create(Material.prototype);
- PointsMaterial.prototype.constructor = PointsMaterial;
- PointsMaterial.prototype.isPointsMaterial = true;
- PointsMaterial.prototype.copy = function(source) {
- Material.prototype.copy.call(this, source);
- this.color.copy(source.color);
- this.map = source.map;
- this.alphaMap = source.alphaMap;
- this.size = source.size;
- this.sizeAttenuation = source.sizeAttenuation;
- this.morphTargets = source.morphTargets;
- return this;
- };
- var _inverseMatrix$2 = new Matrix4();
- var _ray$2 = new Ray();
- var _sphere$3 = new Sphere();
- var _position$1 = new Vector3();
- function Points(geometry, material) {
- Object3D.call(this);
- this.type = "Points";
- this.geometry = geometry !== void 0 ? geometry : new BufferGeometry();
- this.material = material !== void 0 ? material : new PointsMaterial();
- this.updateMorphTargets();
- }
- Points.prototype = Object.assign(Object.create(Object3D.prototype), {
- constructor: Points,
- isPoints: true,
- raycast: function(raycaster, intersects2) {
- var geometry = this.geometry;
- var matrixWorld = this.matrixWorld;
- var threshold = raycaster.params.Points.threshold;
- if (geometry.boundingSphere === null)
- geometry.computeBoundingSphere();
- _sphere$3.copy(geometry.boundingSphere);
- _sphere$3.applyMatrix4(matrixWorld);
- _sphere$3.radius += threshold;
- if (raycaster.ray.intersectsSphere(_sphere$3) === false)
- return;
- _inverseMatrix$2.getInverse(matrixWorld);
- _ray$2.copy(raycaster.ray).applyMatrix4(_inverseMatrix$2);
- var localThreshold = threshold / ((this.scale.x + this.scale.y + this.scale.z) / 3);
- var localThresholdSq = localThreshold * localThreshold;
- if (geometry.isBufferGeometry) {
- var index = geometry.index;
- var attributes = geometry.attributes;
- var positions = attributes.position.array;
- if (index !== null) {
- var indices = index.array;
- for (var i2 = 0, il = indices.length; i2 < il; i2++) {
- var a = indices[i2];
- _position$1.fromArray(positions, a * 3);
- testPoint(_position$1, a, localThresholdSq, matrixWorld, raycaster, intersects2, this);
- }
- } else {
- for (var i2 = 0, l = positions.length / 3; i2 < l; i2++) {
- _position$1.fromArray(positions, i2 * 3);
- testPoint(_position$1, i2, localThresholdSq, matrixWorld, raycaster, intersects2, this);
- }
- }
- } else {
- var vertices = geometry.vertices;
- for (var i2 = 0, l = vertices.length; i2 < l; i2++) {
- testPoint(vertices[i2], i2, localThresholdSq, matrixWorld, raycaster, intersects2, this);
- }
- }
- },
- updateMorphTargets: function() {
- var geometry = this.geometry;
- var m, ml, name;
- if (geometry.isBufferGeometry) {
- var morphAttributes = geometry.morphAttributes;
- var keys = Object.keys(morphAttributes);
- if (keys.length > 0) {
- var morphAttribute = morphAttributes[keys[0]];
- if (morphAttribute !== void 0) {
- this.morphTargetInfluences = [];
- this.morphTargetDictionary = {};
- for (m = 0, ml = morphAttribute.length; m < ml; m++) {
- name = morphAttribute[m].name || String(m);
- this.morphTargetInfluences.push(0);
- this.morphTargetDictionary[name] = m;
- }
- }
- }
- } else {
- var morphTargets = geometry.morphTargets;
- if (morphTargets !== void 0 && morphTargets.length > 0) {
- console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.");
- }
- }
- },
- clone: function() {
- return new this.constructor(this.geometry, this.material).copy(this);
- }
- });
- function testPoint(point, index, localThresholdSq, matrixWorld, raycaster, intersects2, object) {
- var rayPointDistanceSq = _ray$2.distanceSqToPoint(point);
- if (rayPointDistanceSq < localThresholdSq) {
- var intersectPoint = new Vector3();
- _ray$2.closestPointToPoint(point, intersectPoint);
- intersectPoint.applyMatrix4(matrixWorld);
- var distance = raycaster.ray.origin.distanceTo(intersectPoint);
- if (distance < raycaster.near || distance > raycaster.far)
- return;
- intersects2.push({
- distance,
- distanceToRay: Math.sqrt(rayPointDistanceSq),
- point: intersectPoint,
- index,
- face: null,
- object
- });
- }
- }
- function VideoTexture(video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy) {
- Texture.call(this, video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);
- this.format = format !== void 0 ? format : RGBFormat;
- this.minFilter = minFilter !== void 0 ? minFilter : LinearFilter;
- this.magFilter = magFilter !== void 0 ? magFilter : LinearFilter;
- this.generateMipmaps = false;
- }
- VideoTexture.prototype = Object.assign(Object.create(Texture.prototype), {
- constructor: VideoTexture,
- isVideoTexture: true,
- update: function() {
- var video = this.image;
- if (video.readyState >= video.HAVE_CURRENT_DATA) {
- this.needsUpdate = true;
- }
- }
- });
- function CompressedTexture(mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding) {
- Texture.call(this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);
- this.image = { width, height };
- this.mipmaps = mipmaps;
- this.flipY = false;
- this.generateMipmaps = false;
- }
- CompressedTexture.prototype = Object.create(Texture.prototype);
- CompressedTexture.prototype.constructor = CompressedTexture;
- CompressedTexture.prototype.isCompressedTexture = true;
- function CanvasTexture(canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy) {
- Texture.call(this, canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);
- this.needsUpdate = true;
- }
- CanvasTexture.prototype = Object.create(Texture.prototype);
- CanvasTexture.prototype.constructor = CanvasTexture;
- CanvasTexture.prototype.isCanvasTexture = true;
- function DepthTexture(width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format) {
- format = format !== void 0 ? format : DepthFormat;
- if (format !== DepthFormat && format !== DepthStencilFormat) {
- throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");
- }
- if (type === void 0 && format === DepthFormat)
- type = UnsignedShortType;
- if (type === void 0 && format === DepthStencilFormat)
- type = UnsignedInt248Type;
- Texture.call(this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);
- this.image = { width, height };
- this.magFilter = magFilter !== void 0 ? magFilter : NearestFilter;
- this.minFilter = minFilter !== void 0 ? minFilter : NearestFilter;
- this.flipY = false;
- this.generateMipmaps = false;
- }
- DepthTexture.prototype = Object.create(Texture.prototype);
- DepthTexture.prototype.constructor = DepthTexture;
- DepthTexture.prototype.isDepthTexture = true;
- function WireframeGeometry(geometry) {
- BufferGeometry.call(this);
- this.type = "WireframeGeometry";
- var vertices = [];
- var i2, j, l, o, ol;
- var edge = [0, 0], edges = {}, e, edge1, edge2;
- var key, keys = ["a", "b", "c"];
- var vertex;
- if (geometry && geometry.isGeometry) {
- var faces = geometry.faces;
- for (i2 = 0, l = faces.length; i2 < l; i2++) {
- var face = faces[i2];
- for (j = 0; j < 3; j++) {
- edge1 = face[keys[j]];
- edge2 = face[keys[(j + 1) % 3]];
- edge[0] = Math.min(edge1, edge2);
- edge[1] = Math.max(edge1, edge2);
- key = edge[0] + "," + edge[1];
- if (edges[key] === void 0) {
- edges[key] = { index1: edge[0], index2: edge[1] };
- }
- }
- }
- for (key in edges) {
- e = edges[key];
- vertex = geometry.vertices[e.index1];
- vertices.push(vertex.x, vertex.y, vertex.z);
- vertex = geometry.vertices[e.index2];
- vertices.push(vertex.x, vertex.y, vertex.z);
- }
- } else if (geometry && geometry.isBufferGeometry) {
- var position, indices, groups;
- var group, start, count;
- var index1, index2;
- vertex = new Vector3();
- if (geometry.index !== null) {
- position = geometry.attributes.position;
- indices = geometry.index;
- groups = geometry.groups;
- if (groups.length === 0) {
- groups = [{ start: 0, count: indices.count, materialIndex: 0 }];
- }
- for (o = 0, ol = groups.length; o < ol; ++o) {
- group = groups[o];
- start = group.start;
- count = group.count;
- for (i2 = start, l = start + count; i2 < l; i2 += 3) {
- for (j = 0; j < 3; j++) {
- edge1 = indices.getX(i2 + j);
- edge2 = indices.getX(i2 + (j + 1) % 3);
- edge[0] = Math.min(edge1, edge2);
- edge[1] = Math.max(edge1, edge2);
- key = edge[0] + "," + edge[1];
- if (edges[key] === void 0) {
- edges[key] = { index1: edge[0], index2: edge[1] };
- }
- }
- }
- }
- for (key in edges) {
- e = edges[key];
- vertex.fromBufferAttribute(position, e.index1);
- vertices.push(vertex.x, vertex.y, vertex.z);
- vertex.fromBufferAttribute(position, e.index2);
- vertices.push(vertex.x, vertex.y, vertex.z);
- }
- } else {
- position = geometry.attributes.position;
- for (i2 = 0, l = position.count / 3; i2 < l; i2++) {
- for (j = 0; j < 3; j++) {
- index1 = 3 * i2 + j;
- vertex.fromBufferAttribute(position, index1);
- vertices.push(vertex.x, vertex.y, vertex.z);
- index2 = 3 * i2 + (j + 1) % 3;
- vertex.fromBufferAttribute(position, index2);
- vertices.push(vertex.x, vertex.y, vertex.z);
- }
- }
- }
- }
- this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- }
- WireframeGeometry.prototype = Object.create(BufferGeometry.prototype);
- WireframeGeometry.prototype.constructor = WireframeGeometry;
- function ParametricGeometry(func, slices, stacks) {
- Geometry.call(this);
- this.type = "ParametricGeometry";
- this.parameters = {
- func,
- slices,
- stacks
- };
- this.fromBufferGeometry(new ParametricBufferGeometry(func, slices, stacks));
- this.mergeVertices();
- }
- ParametricGeometry.prototype = Object.create(Geometry.prototype);
- ParametricGeometry.prototype.constructor = ParametricGeometry;
- function ParametricBufferGeometry(func, slices, stacks) {
- BufferGeometry.call(this);
- this.type = "ParametricBufferGeometry";
- this.parameters = {
- func,
- slices,
- stacks
- };
- var indices = [];
- var vertices = [];
- var normals = [];
- var uvs = [];
- var EPS = 1e-5;
- var normal = new Vector3();
- var p0 = new Vector3(), p1 = new Vector3();
- var pu = new Vector3(), pv = new Vector3();
- var i2, j;
- if (func.length < 3) {
- console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");
- }
- var sliceCount = slices + 1;
- for (i2 = 0; i2 <= stacks; i2++) {
- var v = i2 / stacks;
- for (j = 0; j <= slices; j++) {
- var u = j / slices;
- func(u, v, p0);
- vertices.push(p0.x, p0.y, p0.z);
- if (u - EPS >= 0) {
- func(u - EPS, v, p1);
- pu.subVectors(p0, p1);
- } else {
- func(u + EPS, v, p1);
- pu.subVectors(p1, p0);
- }
- if (v - EPS >= 0) {
- func(u, v - EPS, p1);
- pv.subVectors(p0, p1);
- } else {
- func(u, v + EPS, p1);
- pv.subVectors(p1, p0);
- }
- normal.crossVectors(pu, pv).normalize();
- normals.push(normal.x, normal.y, normal.z);
- uvs.push(u, v);
- }
- }
- for (i2 = 0; i2 < stacks; i2++) {
- for (j = 0; j < slices; j++) {
- var a = i2 * sliceCount + j;
- var b = i2 * sliceCount + j + 1;
- var c = (i2 + 1) * sliceCount + j + 1;
- var d = (i2 + 1) * sliceCount + j;
- indices.push(a, b, d);
- indices.push(b, c, d);
- }
- }
- this.setIndex(indices);
- this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
- this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
- }
- ParametricBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
- ParametricBufferGeometry.prototype.constructor = ParametricBufferGeometry;
- function PolyhedronGeometry(vertices, indices, radius, detail) {
- Geometry.call(this);
- this.type = "PolyhedronGeometry";
- this.parameters = {
- vertices,
- indices,
- radius,
- detail
- };
- this.fromBufferGeometry(new PolyhedronBufferGeometry(vertices, indices, radius, detail));
- this.mergeVertices();
- }
- PolyhedronGeometry.prototype = Object.create(Geometry.prototype);
- PolyhedronGeometry.prototype.constructor = PolyhedronGeometry;
- function PolyhedronBufferGeometry(vertices, indices, radius, detail) {
- BufferGeometry.call(this);
- this.type = "PolyhedronBufferGeometry";
- this.parameters = {
- vertices,
- indices,
- radius,
- detail
- };
- radius = radius || 1;
- detail = detail || 0;
- var vertexBuffer = [];
- var uvBuffer = [];
- subdivide(detail);
- applyRadius(radius);
- generateUVs();
- this.setAttribute("position", new Float32BufferAttribute(vertexBuffer, 3));
- this.setAttribute("normal", new Float32BufferAttribute(vertexBuffer.slice(), 3));
- this.setAttribute("uv", new Float32BufferAttribute(uvBuffer, 2));
- if (detail === 0) {
- this.computeVertexNormals();
- } else {
- this.normalizeNormals();
- }
- function subdivide(detail2) {
- var a = new Vector3();
- var b = new Vector3();
- var c = new Vector3();
- for (var i2 = 0; i2 < indices.length; i2 += 3) {
- getVertexByIndex(indices[i2 + 0], a);
- getVertexByIndex(indices[i2 + 1], b);
- getVertexByIndex(indices[i2 + 2], c);
- subdivideFace(a, b, c, detail2);
- }
- }
- function subdivideFace(a, b, c, detail2) {
- var cols = Math.pow(2, detail2);
- var v = [];
- var i2, j;
- for (i2 = 0; i2 <= cols; i2++) {
- v[i2] = [];
- var aj = a.clone().lerp(c, i2 / cols);
- var bj = b.clone().lerp(c, i2 / cols);
- var rows = cols - i2;
- for (j = 0; j <= rows; j++) {
- if (j === 0 && i2 === cols) {
- v[i2][j] = aj;
- } else {
- v[i2][j] = aj.clone().lerp(bj, j / rows);
- }
- }
- }
- for (i2 = 0; i2 < cols; i2++) {
- for (j = 0; j < 2 * (cols - i2) - 1; j++) {
- var k = Math.floor(j / 2);
- if (j % 2 === 0) {
- pushVertex(v[i2][k + 1]);
- pushVertex(v[i2 + 1][k]);
- pushVertex(v[i2][k]);
- } else {
- pushVertex(v[i2][k + 1]);
- pushVertex(v[i2 + 1][k + 1]);
- pushVertex(v[i2 + 1][k]);
- }
- }
- }
- }
- function applyRadius(radius2) {
- var vertex = new Vector3();
- for (var i2 = 0; i2 < vertexBuffer.length; i2 += 3) {
- vertex.x = vertexBuffer[i2 + 0];
- vertex.y = vertexBuffer[i2 + 1];
- vertex.z = vertexBuffer[i2 + 2];
- vertex.normalize().multiplyScalar(radius2);
- vertexBuffer[i2 + 0] = vertex.x;
- vertexBuffer[i2 + 1] = vertex.y;
- vertexBuffer[i2 + 2] = vertex.z;
- }
- }
- function generateUVs() {
- var vertex = new Vector3();
- for (var i2 = 0; i2 < vertexBuffer.length; i2 += 3) {
- vertex.x = vertexBuffer[i2 + 0];
- vertex.y = vertexBuffer[i2 + 1];
- vertex.z = vertexBuffer[i2 + 2];
- var u = azimuth(vertex) / 2 / Math.PI + 0.5;
- var v = inclination(vertex) / Math.PI + 0.5;
- uvBuffer.push(u, 1 - v);
- }
- correctUVs();
- correctSeam();
- }
- function correctSeam() {
- for (var i2 = 0; i2 < uvBuffer.length; i2 += 6) {
- var x0 = uvBuffer[i2 + 0];
- var x1 = uvBuffer[i2 + 2];
- var x2 = uvBuffer[i2 + 4];
- var max = Math.max(x0, x1, x2);
- var min = Math.min(x0, x1, x2);
- if (max > 0.9 && min < 0.1) {
- if (x0 < 0.2)
- uvBuffer[i2 + 0] += 1;
- if (x1 < 0.2)
- uvBuffer[i2 + 2] += 1;
- if (x2 < 0.2)
- uvBuffer[i2 + 4] += 1;
- }
- }
- }
- function pushVertex(vertex) {
- vertexBuffer.push(vertex.x, vertex.y, vertex.z);
- }
- function getVertexByIndex(index, vertex) {
- var stride = index * 3;
- vertex.x = vertices[stride + 0];
- vertex.y = vertices[stride + 1];
- vertex.z = vertices[stride + 2];
- }
- function correctUVs() {
- var a = new Vector3();
- var b = new Vector3();
- var c = new Vector3();
- var centroid = new Vector3();
- var uvA = new Vector2();
- var uvB = new Vector2();
- var uvC = new Vector2();
- for (var i2 = 0, j = 0; i2 < vertexBuffer.length; i2 += 9, j += 6) {
- a.set(vertexBuffer[i2 + 0], vertexBuffer[i2 + 1], vertexBuffer[i2 + 2]);
- b.set(vertexBuffer[i2 + 3], vertexBuffer[i2 + 4], vertexBuffer[i2 + 5]);
- c.set(vertexBuffer[i2 + 6], vertexBuffer[i2 + 7], vertexBuffer[i2 + 8]);
- uvA.set(uvBuffer[j + 0], uvBuffer[j + 1]);
- uvB.set(uvBuffer[j + 2], uvBuffer[j + 3]);
- uvC.set(uvBuffer[j + 4], uvBuffer[j + 5]);
- centroid.copy(a).add(b).add(c).divideScalar(3);
- var azi = azimuth(centroid);
- correctUV(uvA, j + 0, a, azi);
- correctUV(uvB, j + 2, b, azi);
- correctUV(uvC, j + 4, c, azi);
- }
- }
- function correctUV(uv, stride, vector, azimuth2) {
- if (azimuth2 < 0 && uv.x === 1) {
- uvBuffer[stride] = uv.x - 1;
- }
- if (vector.x === 0 && vector.z === 0) {
- uvBuffer[stride] = azimuth2 / 2 / Math.PI + 0.5;
- }
- }
- function azimuth(vector) {
- return Math.atan2(vector.z, -vector.x);
- }
- function inclination(vector) {
- return Math.atan2(-vector.y, Math.sqrt(vector.x * vector.x + vector.z * vector.z));
- }
- }
- PolyhedronBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
- PolyhedronBufferGeometry.prototype.constructor = PolyhedronBufferGeometry;
- function TetrahedronGeometry(radius, detail) {
- Geometry.call(this);
- this.type = "TetrahedronGeometry";
- this.parameters = {
- radius,
- detail
- };
- this.fromBufferGeometry(new TetrahedronBufferGeometry(radius, detail));
- this.mergeVertices();
- }
- TetrahedronGeometry.prototype = Object.create(Geometry.prototype);
- TetrahedronGeometry.prototype.constructor = TetrahedronGeometry;
- function TetrahedronBufferGeometry(radius, detail) {
- var vertices = [
- 1,
- 1,
- 1,
- -1,
- -1,
- 1,
- -1,
- 1,
- -1,
- 1,
- -1,
- -1
- ];
- var indices = [
- 2,
- 1,
- 0,
- 0,
- 3,
- 2,
- 1,
- 3,
- 0,
- 2,
- 3,
- 1
- ];
- PolyhedronBufferGeometry.call(this, vertices, indices, radius, detail);
- this.type = "TetrahedronBufferGeometry";
- this.parameters = {
- radius,
- detail
- };
- }
- TetrahedronBufferGeometry.prototype = Object.create(PolyhedronBufferGeometry.prototype);
- TetrahedronBufferGeometry.prototype.constructor = TetrahedronBufferGeometry;
- function OctahedronGeometry(radius, detail) {
- Geometry.call(this);
- this.type = "OctahedronGeometry";
- this.parameters = {
- radius,
- detail
- };
- this.fromBufferGeometry(new OctahedronBufferGeometry(radius, detail));
- this.mergeVertices();
- }
- OctahedronGeometry.prototype = Object.create(Geometry.prototype);
- OctahedronGeometry.prototype.constructor = OctahedronGeometry;
- function OctahedronBufferGeometry(radius, detail) {
- var vertices = [
- 1,
- 0,
- 0,
- -1,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- -1,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- -1
- ];
- var indices = [
- 0,
- 2,
- 4,
- 0,
- 4,
- 3,
- 0,
- 3,
- 5,
- 0,
- 5,
- 2,
- 1,
- 2,
- 5,
- 1,
- 5,
- 3,
- 1,
- 3,
- 4,
- 1,
- 4,
- 2
- ];
- PolyhedronBufferGeometry.call(this, vertices, indices, radius, detail);
- this.type = "OctahedronBufferGeometry";
- this.parameters = {
- radius,
- detail
- };
- }
- OctahedronBufferGeometry.prototype = Object.create(PolyhedronBufferGeometry.prototype);
- OctahedronBufferGeometry.prototype.constructor = OctahedronBufferGeometry;
- function IcosahedronGeometry(radius, detail) {
- Geometry.call(this);
- this.type = "IcosahedronGeometry";
- this.parameters = {
- radius,
- detail
- };
- this.fromBufferGeometry(new IcosahedronBufferGeometry(radius, detail));
- this.mergeVertices();
- }
- IcosahedronGeometry.prototype = Object.create(Geometry.prototype);
- IcosahedronGeometry.prototype.constructor = IcosahedronGeometry;
- function IcosahedronBufferGeometry(radius, detail) {
- var t = (1 + Math.sqrt(5)) / 2;
- var vertices = [
- -1,
- t,
- 0,
- 1,
- t,
- 0,
- -1,
- -t,
- 0,
- 1,
- -t,
- 0,
- 0,
- -1,
- t,
- 0,
- 1,
- t,
- 0,
- -1,
- -t,
- 0,
- 1,
- -t,
- t,
- 0,
- -1,
- t,
- 0,
- 1,
- -t,
- 0,
- -1,
- -t,
- 0,
- 1
- ];
- var indices = [
- 0,
- 11,
- 5,
- 0,
- 5,
- 1,
- 0,
- 1,
- 7,
- 0,
- 7,
- 10,
- 0,
- 10,
- 11,
- 1,
- 5,
- 9,
- 5,
- 11,
- 4,
- 11,
- 10,
- 2,
- 10,
- 7,
- 6,
- 7,
- 1,
- 8,
- 3,
- 9,
- 4,
- 3,
- 4,
- 2,
- 3,
- 2,
- 6,
- 3,
- 6,
- 8,
- 3,
- 8,
- 9,
- 4,
- 9,
- 5,
- 2,
- 4,
- 11,
- 6,
- 2,
- 10,
- 8,
- 6,
- 7,
- 9,
- 8,
- 1
- ];
- PolyhedronBufferGeometry.call(this, vertices, indices, radius, detail);
- this.type = "IcosahedronBufferGeometry";
- this.parameters = {
- radius,
- detail
- };
- }
- IcosahedronBufferGeometry.prototype = Object.create(PolyhedronBufferGeometry.prototype);
- IcosahedronBufferGeometry.prototype.constructor = IcosahedronBufferGeometry;
- function DodecahedronGeometry(radius, detail) {
- Geometry.call(this);
- this.type = "DodecahedronGeometry";
- this.parameters = {
- radius,
- detail
- };
- this.fromBufferGeometry(new DodecahedronBufferGeometry(radius, detail));
- this.mergeVertices();
- }
- DodecahedronGeometry.prototype = Object.create(Geometry.prototype);
- DodecahedronGeometry.prototype.constructor = DodecahedronGeometry;
- function DodecahedronBufferGeometry(radius, detail) {
- var t = (1 + Math.sqrt(5)) / 2;
- var r = 1 / t;
- var vertices = [
- // (±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,
- // (0, ±1/φ, ±φ)
- 0,
- -r,
- -t,
- 0,
- -r,
- t,
- 0,
- r,
- -t,
- 0,
- r,
- t,
- // (±1/φ, ±φ, 0)
- -r,
- -t,
- 0,
- -r,
- t,
- 0,
- r,
- -t,
- 0,
- r,
- t,
- 0,
- // (±φ, 0, ±1/φ)
- -t,
- 0,
- -r,
- t,
- 0,
- -r,
- -t,
- 0,
- r,
- t,
- 0,
- r
- ];
- var indices = [
- 3,
- 11,
- 7,
- 3,
- 7,
- 15,
- 3,
- 15,
- 13,
- 7,
- 19,
- 17,
- 7,
- 17,
- 6,
- 7,
- 6,
- 15,
- 17,
- 4,
- 8,
- 17,
- 8,
- 10,
- 17,
- 10,
- 6,
- 8,
- 0,
- 16,
- 8,
- 16,
- 2,
- 8,
- 2,
- 10,
- 0,
- 12,
- 1,
- 0,
- 1,
- 18,
- 0,
- 18,
- 16,
- 6,
- 10,
- 2,
- 6,
- 2,
- 13,
- 6,
- 13,
- 15,
- 2,
- 16,
- 18,
- 2,
- 18,
- 3,
- 2,
- 3,
- 13,
- 18,
- 1,
- 9,
- 18,
- 9,
- 11,
- 18,
- 11,
- 3,
- 4,
- 14,
- 12,
- 4,
- 12,
- 0,
- 4,
- 0,
- 8,
- 11,
- 9,
- 5,
- 11,
- 5,
- 19,
- 11,
- 19,
- 7,
- 19,
- 5,
- 14,
- 19,
- 14,
- 4,
- 19,
- 4,
- 17,
- 1,
- 12,
- 14,
- 1,
- 14,
- 5,
- 1,
- 5,
- 9
- ];
- PolyhedronBufferGeometry.call(this, vertices, indices, radius, detail);
- this.type = "DodecahedronBufferGeometry";
- this.parameters = {
- radius,
- detail
- };
- }
- DodecahedronBufferGeometry.prototype = Object.create(PolyhedronBufferGeometry.prototype);
- DodecahedronBufferGeometry.prototype.constructor = DodecahedronBufferGeometry;
- function TubeGeometry(path, tubularSegments, radius, radialSegments, closed, taper) {
- Geometry.call(this);
- this.type = "TubeGeometry";
- this.parameters = {
- path,
- tubularSegments,
- radius,
- radialSegments,
- closed
- };
- if (taper !== void 0)
- console.warn("THREE.TubeGeometry: taper has been removed.");
- var bufferGeometry = new TubeBufferGeometry(path, tubularSegments, radius, radialSegments, closed);
- this.tangents = bufferGeometry.tangents;
- this.normals = bufferGeometry.normals;
- this.binormals = bufferGeometry.binormals;
- this.fromBufferGeometry(bufferGeometry);
- this.mergeVertices();
- }
- TubeGeometry.prototype = Object.create(Geometry.prototype);
- TubeGeometry.prototype.constructor = TubeGeometry;
- function TubeBufferGeometry(path, tubularSegments, radius, radialSegments, closed) {
- BufferGeometry.call(this);
- this.type = "TubeBufferGeometry";
- this.parameters = {
- path,
- tubularSegments,
- radius,
- radialSegments,
- closed
- };
- tubularSegments = tubularSegments || 64;
- radius = radius || 1;
- radialSegments = radialSegments || 8;
- closed = closed || false;
- var frames = path.computeFrenetFrames(tubularSegments, closed);
- this.tangents = frames.tangents;
- this.normals = frames.normals;
- this.binormals = frames.binormals;
- var vertex = new Vector3();
- var normal = new Vector3();
- var uv = new Vector2();
- var P = new Vector3();
- var i2, j;
- var vertices = [];
- var normals = [];
- var uvs = [];
- var indices = [];
- generateBufferData();
- this.setIndex(indices);
- this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
- this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
- function generateBufferData() {
- for (i2 = 0; i2 < tubularSegments; i2++) {
- generateSegment(i2);
- }
- generateSegment(closed === false ? tubularSegments : 0);
- generateUVs();
- generateIndices();
- }
- function generateSegment(i3) {
- P = path.getPointAt(i3 / tubularSegments, P);
- var N = frames.normals[i3];
- var B = frames.binormals[i3];
- for (j = 0; j <= radialSegments; j++) {
- var v = j / radialSegments * Math.PI * 2;
- var sin = Math.sin(v);
- var cos = -Math.cos(v);
- normal.x = cos * N.x + sin * B.x;
- normal.y = cos * N.y + sin * B.y;
- normal.z = cos * N.z + sin * B.z;
- normal.normalize();
- normals.push(normal.x, normal.y, normal.z);
- vertex.x = P.x + radius * normal.x;
- vertex.y = P.y + radius * normal.y;
- vertex.z = P.z + radius * normal.z;
- vertices.push(vertex.x, vertex.y, vertex.z);
- }
- }
- function generateIndices() {
- for (j = 1; j <= tubularSegments; j++) {
- for (i2 = 1; i2 <= radialSegments; i2++) {
- var a = (radialSegments + 1) * (j - 1) + (i2 - 1);
- var b = (radialSegments + 1) * j + (i2 - 1);
- var c = (radialSegments + 1) * j + i2;
- var d = (radialSegments + 1) * (j - 1) + i2;
- indices.push(a, b, d);
- indices.push(b, c, d);
- }
- }
- }
- function generateUVs() {
- for (i2 = 0; i2 <= tubularSegments; i2++) {
- for (j = 0; j <= radialSegments; j++) {
- uv.x = i2 / tubularSegments;
- uv.y = j / radialSegments;
- uvs.push(uv.x, uv.y);
- }
- }
- }
- }
- TubeBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
- TubeBufferGeometry.prototype.constructor = TubeBufferGeometry;
- TubeBufferGeometry.prototype.toJSON = function() {
- var data = BufferGeometry.prototype.toJSON.call(this);
- data.path = this.parameters.path.toJSON();
- return data;
- };
- function TorusKnotGeometry(radius, tube, tubularSegments, radialSegments, p, q, heightScale) {
- Geometry.call(this);
- this.type = "TorusKnotGeometry";
- this.parameters = {
- radius,
- tube,
- tubularSegments,
- radialSegments,
- p,
- q
- };
- if (heightScale !== void 0)
- console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead.");
- this.fromBufferGeometry(new TorusKnotBufferGeometry(radius, tube, tubularSegments, radialSegments, p, q));
- this.mergeVertices();
- }
- TorusKnotGeometry.prototype = Object.create(Geometry.prototype);
- TorusKnotGeometry.prototype.constructor = TorusKnotGeometry;
- function TorusKnotBufferGeometry(radius, tube, tubularSegments, radialSegments, p, q) {
- BufferGeometry.call(this);
- this.type = "TorusKnotBufferGeometry";
- this.parameters = {
- radius,
- tube,
- tubularSegments,
- radialSegments,
- p,
- q
- };
- radius = radius || 1;
- tube = tube || 0.4;
- tubularSegments = Math.floor(tubularSegments) || 64;
- radialSegments = Math.floor(radialSegments) || 8;
- p = p || 2;
- q = q || 3;
- var indices = [];
- var vertices = [];
- var normals = [];
- var uvs = [];
- var i2, j;
- var vertex = new Vector3();
- var normal = new Vector3();
- var P1 = new Vector3();
- var P2 = new Vector3();
- var B = new Vector3();
- var T = new Vector3();
- var N = new Vector3();
- for (i2 = 0; i2 <= tubularSegments; ++i2) {
- var u = i2 / tubularSegments * p * Math.PI * 2;
- calculatePositionOnCurve(u, p, q, radius, P1);
- calculatePositionOnCurve(u + 0.01, p, q, radius, P2);
- T.subVectors(P2, P1);
- N.addVectors(P2, P1);
- B.crossVectors(T, N);
- N.crossVectors(B, T);
- B.normalize();
- N.normalize();
- for (j = 0; j <= radialSegments; ++j) {
- var v = j / radialSegments * Math.PI * 2;
- var cx = -tube * Math.cos(v);
- var cy = tube * Math.sin(v);
- vertex.x = P1.x + (cx * N.x + cy * B.x);
- vertex.y = P1.y + (cx * N.y + cy * B.y);
- vertex.z = P1.z + (cx * N.z + cy * B.z);
- vertices.push(vertex.x, vertex.y, vertex.z);
- normal.subVectors(vertex, P1).normalize();
- normals.push(normal.x, normal.y, normal.z);
- uvs.push(i2 / tubularSegments);
- uvs.push(j / radialSegments);
- }
- }
- for (j = 1; j <= tubularSegments; j++) {
- for (i2 = 1; i2 <= radialSegments; i2++) {
- var a = (radialSegments + 1) * (j - 1) + (i2 - 1);
- var b = (radialSegments + 1) * j + (i2 - 1);
- var c = (radialSegments + 1) * j + i2;
- var d = (radialSegments + 1) * (j - 1) + i2;
- indices.push(a, b, d);
- indices.push(b, c, d);
- }
- }
- this.setIndex(indices);
- this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
- this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
- function calculatePositionOnCurve(u2, p2, q2, radius2, position) {
- var cu = Math.cos(u2);
- var su = Math.sin(u2);
- var quOverP = q2 / p2 * u2;
- var cs = Math.cos(quOverP);
- position.x = radius2 * (2 + cs) * 0.5 * cu;
- position.y = radius2 * (2 + cs) * su * 0.5;
- position.z = radius2 * Math.sin(quOverP) * 0.5;
- }
- }
- TorusKnotBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
- TorusKnotBufferGeometry.prototype.constructor = TorusKnotBufferGeometry;
- function TorusGeometry(radius, tube, radialSegments, tubularSegments, arc) {
- Geometry.call(this);
- this.type = "TorusGeometry";
- this.parameters = {
- radius,
- tube,
- radialSegments,
- tubularSegments,
- arc
- };
- this.fromBufferGeometry(new TorusBufferGeometry(radius, tube, radialSegments, tubularSegments, arc));
- this.mergeVertices();
- }
- TorusGeometry.prototype = Object.create(Geometry.prototype);
- TorusGeometry.prototype.constructor = TorusGeometry;
- function TorusBufferGeometry(radius, tube, radialSegments, tubularSegments, arc) {
- BufferGeometry.call(this);
- this.type = "TorusBufferGeometry";
- this.parameters = {
- radius,
- tube,
- radialSegments,
- tubularSegments,
- arc
- };
- radius = radius || 1;
- tube = tube || 0.4;
- radialSegments = Math.floor(radialSegments) || 8;
- tubularSegments = Math.floor(tubularSegments) || 6;
- arc = arc || Math.PI * 2;
- var indices = [];
- var vertices = [];
- var normals = [];
- var uvs = [];
- var center = new Vector3();
- var vertex = new Vector3();
- var normal = new Vector3();
- var j, i2;
- for (j = 0; j <= radialSegments; j++) {
- for (i2 = 0; i2 <= tubularSegments; i2++) {
- var u = i2 / tubularSegments * arc;
- var v = j / radialSegments * Math.PI * 2;
- vertex.x = (radius + tube * Math.cos(v)) * Math.cos(u);
- vertex.y = (radius + tube * Math.cos(v)) * Math.sin(u);
- vertex.z = tube * Math.sin(v);
- vertices.push(vertex.x, vertex.y, vertex.z);
- center.x = radius * Math.cos(u);
- center.y = radius * Math.sin(u);
- normal.subVectors(vertex, center).normalize();
- normals.push(normal.x, normal.y, normal.z);
- uvs.push(i2 / tubularSegments);
- uvs.push(j / radialSegments);
- }
- }
- for (j = 1; j <= radialSegments; j++) {
- for (i2 = 1; i2 <= tubularSegments; i2++) {
- var a = (tubularSegments + 1) * j + i2 - 1;
- var b = (tubularSegments + 1) * (j - 1) + i2 - 1;
- var c = (tubularSegments + 1) * (j - 1) + i2;
- var d = (tubularSegments + 1) * j + i2;
- indices.push(a, b, d);
- indices.push(b, c, d);
- }
- }
- this.setIndex(indices);
- this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
- this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
- }
- TorusBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
- TorusBufferGeometry.prototype.constructor = TorusBufferGeometry;
- var Earcut = {
- triangulate: function(data, holeIndices, dim) {
- dim = dim || 2;
- var hasHoles = holeIndices && holeIndices.length, outerLen = hasHoles ? holeIndices[0] * dim : data.length, outerNode = linkedList(data, 0, outerLen, dim, true), triangles = [];
- if (!outerNode || outerNode.next === outerNode.prev)
- return triangles;
- var minX, minY, maxX, maxY, x, y, invSize;
- if (hasHoles)
- outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
- if (data.length > 80 * dim) {
- minX = maxX = data[0];
- minY = maxY = data[1];
- for (var i2 = dim; i2 < outerLen; i2 += dim) {
- x = data[i2];
- y = data[i2 + 1];
- if (x < minX)
- minX = x;
- if (y < minY)
- minY = y;
- if (x > maxX)
- maxX = x;
- if (y > maxY)
- maxY = y;
- }
- invSize = Math.max(maxX - minX, maxY - minY);
- invSize = invSize !== 0 ? 1 / invSize : 0;
- }
- earcutLinked(outerNode, triangles, dim, minX, minY, invSize);
- return triangles;
- }
- };
- function linkedList(data, start, end, dim, clockwise) {
- var i2, last;
- if (clockwise === signedArea(data, start, end, dim) > 0) {
- for (i2 = start; i2 < end; i2 += dim)
- last = insertNode(i2, data[i2], data[i2 + 1], last);
- } else {
- for (i2 = end - dim; i2 >= start; i2 -= dim)
- last = insertNode(i2, data[i2], data[i2 + 1], last);
- }
- if (last && equals(last, last.next)) {
- removeNode(last);
- last = last.next;
- }
- return last;
- }
- function filterPoints(start, end) {
- if (!start)
- return start;
- if (!end)
- end = start;
- var p = start, again;
- do {
- again = false;
- if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
- removeNode(p);
- p = end = p.prev;
- if (p === p.next)
- break;
- again = true;
- } else {
- p = p.next;
- }
- } while (again || p !== end);
- return end;
- }
- function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
- if (!ear)
- return;
- if (!pass && invSize)
- indexCurve(ear, minX, minY, invSize);
- var stop = ear, prev, next;
- while (ear.prev !== ear.next) {
- prev = ear.prev;
- next = ear.next;
- if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
- triangles.push(prev.i / dim);
- triangles.push(ear.i / dim);
- triangles.push(next.i / dim);
- removeNode(ear);
- ear = next.next;
- stop = next.next;
- continue;
- }
- ear = next;
- if (ear === stop) {
- if (!pass) {
- earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
- } else if (pass === 1) {
- ear = cureLocalIntersections(ear, triangles, dim);
- earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
- } else if (pass === 2) {
- splitEarcut(ear, triangles, dim, minX, minY, invSize);
- }
- break;
- }
- }
- }
- function isEar(ear) {
- var a = ear.prev, b = ear, c = ear.next;
- if (area(a, b, c) >= 0)
- return false;
- var p = ear.next.next;
- while (p !== ear.prev) {
- 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)
- return false;
- p = p.next;
- }
- return true;
- }
- function isEarHashed(ear, minX, minY, invSize) {
- var a = ear.prev, b = ear, c = ear.next;
- if (area(a, b, c) >= 0)
- return false;
- 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;
- var minZ = zOrder(minTX, minTY, minX, minY, invSize), maxZ = zOrder(maxTX, maxTY, minX, minY, invSize);
- var p = ear.prevZ, n = ear.nextZ;
- while (p && p.z >= minZ && n && n.z <= maxZ) {
- 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)
- return false;
- p = p.prevZ;
- 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)
- return false;
- n = n.nextZ;
- }
- while (p && p.z >= minZ) {
- 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)
- return false;
- p = p.prevZ;
- }
- while (n && n.z <= maxZ) {
- 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)
- return false;
- n = n.nextZ;
- }
- return true;
- }
- function cureLocalIntersections(start, triangles, dim) {
- var p = start;
- do {
- var a = p.prev, b = p.next.next;
- if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
- triangles.push(a.i / dim);
- triangles.push(p.i / dim);
- triangles.push(b.i / dim);
- removeNode(p);
- removeNode(p.next);
- p = start = b;
- }
- p = p.next;
- } while (p !== start);
- return p;
- }
- function splitEarcut(start, triangles, dim, minX, minY, invSize) {
- var a = start;
- do {
- var b = a.next.next;
- while (b !== a.prev) {
- if (a.i !== b.i && isValidDiagonal(a, b)) {
- var c = splitPolygon(a, b);
- a = filterPoints(a, a.next);
- c = filterPoints(c, c.next);
- earcutLinked(a, triangles, dim, minX, minY, invSize);
- earcutLinked(c, triangles, dim, minX, minY, invSize);
- return;
- }
- b = b.next;
- }
- a = a.next;
- } while (a !== start);
- }
- function eliminateHoles(data, holeIndices, outerNode, dim) {
- var queue = [], i2, len, start, end, list;
- for (i2 = 0, len = holeIndices.length; i2 < len; i2++) {
- start = holeIndices[i2] * dim;
- end = i2 < len - 1 ? holeIndices[i2 + 1] * dim : data.length;
- list = linkedList(data, start, end, dim, false);
- if (list === list.next)
- list.steiner = true;
- queue.push(getLeftmost(list));
- }
- queue.sort(compareX);
- for (i2 = 0; i2 < queue.length; i2++) {
- eliminateHole(queue[i2], outerNode);
- outerNode = filterPoints(outerNode, outerNode.next);
- }
- return outerNode;
- }
- function compareX(a, b) {
- return a.x - b.x;
- }
- function eliminateHole(hole, outerNode) {
- outerNode = findHoleBridge(hole, outerNode);
- if (outerNode) {
- var b = splitPolygon(outerNode, hole);
- filterPoints(b, b.next);
- }
- }
- function findHoleBridge(hole, outerNode) {
- var p = outerNode, hx = hole.x, hy = hole.y, qx = -Infinity, m;
- do {
- if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
- var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
- if (x <= hx && x > qx) {
- qx = x;
- if (x === hx) {
- if (hy === p.y)
- return p;
- if (hy === p.next.y)
- return p.next;
- }
- m = p.x < p.next.x ? p : p.next;
- }
- }
- p = p.next;
- } while (p !== outerNode);
- if (!m)
- return null;
- if (hx === qx)
- return m.prev;
- var stop = m, mx = m.x, my = m.y, tanMin = Infinity, tan;
- p = m.next;
- while (p !== stop) {
- 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)) {
- tan = Math.abs(hy - p.y) / (hx - p.x);
- if ((tan < tanMin || tan === tanMin && p.x > m.x) && locallyInside(p, hole)) {
- m = p;
- tanMin = tan;
- }
- }
- p = p.next;
- }
- return m;
- }
- function indexCurve(start, minX, minY, invSize) {
- var p = start;
- do {
- if (p.z === null)
- p.z = zOrder(p.x, p.y, minX, minY, invSize);
- p.prevZ = p.prev;
- p.nextZ = p.next;
- p = p.next;
- } while (p !== start);
- p.prevZ.nextZ = null;
- p.prevZ = null;
- sortLinked(p);
- }
- function sortLinked(list) {
- var i2, p, q, e, tail, numMerges, pSize, qSize, inSize = 1;
- do {
- p = list;
- list = null;
- tail = null;
- numMerges = 0;
- while (p) {
- numMerges++;
- q = p;
- pSize = 0;
- for (i2 = 0; i2 < inSize; i2++) {
- pSize++;
- q = q.nextZ;
- if (!q)
- break;
- }
- qSize = inSize;
- while (pSize > 0 || qSize > 0 && q) {
- if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
- e = p;
- p = p.nextZ;
- pSize--;
- } else {
- e = q;
- q = q.nextZ;
- qSize--;
- }
- if (tail)
- tail.nextZ = e;
- else
- list = e;
- e.prevZ = tail;
- tail = e;
- }
- p = q;
- }
- tail.nextZ = null;
- inSize *= 2;
- } while (numMerges > 1);
- return list;
- }
- function zOrder(x, y, minX, minY, invSize) {
- x = 32767 * (x - minX) * invSize;
- y = 32767 * (y - minY) * invSize;
- x = (x | x << 8) & 16711935;
- x = (x | x << 4) & 252645135;
- x = (x | x << 2) & 858993459;
- x = (x | x << 1) & 1431655765;
- y = (y | y << 8) & 16711935;
- y = (y | y << 4) & 252645135;
- y = (y | y << 2) & 858993459;
- y = (y | y << 1) & 1431655765;
- return x | y << 1;
- }
- function getLeftmost(start) {
- var p = start, leftmost = start;
- do {
- if (p.x < leftmost.x || p.x === leftmost.x && p.y < leftmost.y)
- leftmost = p;
- p = p.next;
- } while (p !== start);
- return leftmost;
- }
- function pointInTriangle(ax, ay, bx, by, cx, cy, px2, py2) {
- 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;
- }
- function isValidDiagonal(a, b) {
- return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b);
- }
- function area(p, q, r) {
- return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
- }
- function equals(p1, p2) {
- return p1.x === p2.x && p1.y === p2.y;
- }
- function intersects(p1, q1, p2, q2) {
- if (equals(p1, p2) && equals(q1, q2) || equals(p1, q2) && equals(p2, q1))
- return true;
- return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0;
- }
- function intersectsPolygon(a, b) {
- var p = a;
- do {
- 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))
- return true;
- p = p.next;
- } while (p !== a);
- return false;
- }
- function locallyInside(a, b) {
- 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;
- }
- function middleInside(a, b) {
- var p = a, inside = false, px2 = (a.x + b.x) / 2, py2 = (a.y + b.y) / 2;
- do {
- 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)
- inside = !inside;
- p = p.next;
- } while (p !== a);
- return inside;
- }
- function splitPolygon(a, b) {
- 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;
- a.next = b;
- b.prev = a;
- a2.next = an;
- an.prev = a2;
- b2.next = a2;
- a2.prev = b2;
- bp.next = b2;
- b2.prev = bp;
- return b2;
- }
- function insertNode(i2, x, y, last) {
- var p = new Node(i2, x, y);
- if (!last) {
- p.prev = p;
- p.next = p;
- } else {
- p.next = last.next;
- p.prev = last;
- last.next.prev = p;
- last.next = p;
- }
- return p;
- }
- function removeNode(p) {
- p.next.prev = p.prev;
- p.prev.next = p.next;
- if (p.prevZ)
- p.prevZ.nextZ = p.nextZ;
- if (p.nextZ)
- p.nextZ.prevZ = p.prevZ;
- }
- function Node(i2, x, y) {
- this.i = i2;
- this.x = x;
- this.y = y;
- this.prev = null;
- this.next = null;
- this.z = null;
- this.prevZ = null;
- this.nextZ = null;
- this.steiner = false;
- }
- function signedArea(data, start, end, dim) {
- var sum = 0;
- for (var i2 = start, j = end - dim; i2 < end; i2 += dim) {
- sum += (data[j] - data[i2]) * (data[i2 + 1] + data[j + 1]);
- j = i2;
- }
- return sum;
- }
- var ShapeUtils = {
- // calculate area of the contour polygon
- area: function(contour) {
- var n = contour.length;
- var a = 0;
- for (var p = n - 1, q = 0; q < n; p = q++) {
- a += contour[p].x * contour[q].y - contour[q].x * contour[p].y;
- }
- return a * 0.5;
- },
- isClockWise: function(pts) {
- return ShapeUtils.area(pts) < 0;
- },
- triangulateShape: function(contour, holes) {
- var vertices = [];
- var holeIndices = [];
- var faces = [];
- removeDupEndPts(contour);
- addContour(vertices, contour);
- var holeIndex = contour.length;
- holes.forEach(removeDupEndPts);
- for (var i2 = 0; i2 < holes.length; i2++) {
- holeIndices.push(holeIndex);
- holeIndex += holes[i2].length;
- addContour(vertices, holes[i2]);
- }
- var triangles = Earcut.triangulate(vertices, holeIndices);
- for (var i2 = 0; i2 < triangles.length; i2 += 3) {
- faces.push(triangles.slice(i2, i2 + 3));
- }
- return faces;
- }
- };
- function removeDupEndPts(points) {
- var l = points.length;
- if (l > 2 && points[l - 1].equals(points[0])) {
- points.pop();
- }
- }
- function addContour(vertices, contour) {
- for (var i2 = 0; i2 < contour.length; i2++) {
- vertices.push(contour[i2].x);
- vertices.push(contour[i2].y);
- }
- }
- function ExtrudeGeometry(shapes, options) {
- Geometry.call(this);
- this.type = "ExtrudeGeometry";
- this.parameters = {
- shapes,
- options
- };
- this.fromBufferGeometry(new ExtrudeBufferGeometry(shapes, options));
- this.mergeVertices();
- }
- ExtrudeGeometry.prototype = Object.create(Geometry.prototype);
- ExtrudeGeometry.prototype.constructor = ExtrudeGeometry;
- ExtrudeGeometry.prototype.toJSON = function() {
- var data = Geometry.prototype.toJSON.call(this);
- var shapes = this.parameters.shapes;
- var options = this.parameters.options;
- return toJSON(shapes, options, data);
- };
- function ExtrudeBufferGeometry(shapes, options) {
- BufferGeometry.call(this);
- this.type = "ExtrudeBufferGeometry";
- this.parameters = {
- shapes,
- options
- };
- shapes = Array.isArray(shapes) ? shapes : [shapes];
- var scope = this;
- var verticesArray = [];
- var uvArray = [];
- for (var i2 = 0, l = shapes.length; i2 < l; i2++) {
- var shape = shapes[i2];
- addShape(shape);
- }
- this.setAttribute("position", new Float32BufferAttribute(verticesArray, 3));
- this.setAttribute("uv", new Float32BufferAttribute(uvArray, 2));
- this.computeVertexNormals();
- function addShape(shape2) {
- var placeholder = [];
- var curveSegments = options.curveSegments !== void 0 ? options.curveSegments : 12;
- var steps = options.steps !== void 0 ? options.steps : 1;
- var depth = options.depth !== void 0 ? options.depth : 100;
- var bevelEnabled = options.bevelEnabled !== void 0 ? options.bevelEnabled : true;
- var bevelThickness = options.bevelThickness !== void 0 ? options.bevelThickness : 6;
- var bevelSize = options.bevelSize !== void 0 ? options.bevelSize : bevelThickness - 2;
- var bevelOffset = options.bevelOffset !== void 0 ? options.bevelOffset : 0;
- var bevelSegments = options.bevelSegments !== void 0 ? options.bevelSegments : 3;
- var extrudePath = options.extrudePath;
- var uvgen = options.UVGenerator !== void 0 ? options.UVGenerator : WorldUVGenerator;
- if (options.amount !== void 0) {
- console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth.");
- depth = options.amount;
- }
- var extrudePts, extrudeByPath = false;
- var splineTube, binormal, normal, position2;
- if (extrudePath) {
- extrudePts = extrudePath.getSpacedPoints(steps);
- extrudeByPath = true;
- bevelEnabled = false;
- splineTube = extrudePath.computeFrenetFrames(steps, false);
- binormal = new Vector3();
- normal = new Vector3();
- position2 = new Vector3();
- }
- if (!bevelEnabled) {
- bevelSegments = 0;
- bevelThickness = 0;
- bevelSize = 0;
- bevelOffset = 0;
- }
- var ahole, h, hl;
- var shapePoints = shape2.extractPoints(curveSegments);
- var vertices = shapePoints.shape;
- var holes = shapePoints.holes;
- var reverse = !ShapeUtils.isClockWise(vertices);
- if (reverse) {
- vertices = vertices.reverse();
- for (h = 0, hl = holes.length; h < hl; h++) {
- ahole = holes[h];
- if (ShapeUtils.isClockWise(ahole)) {
- holes[h] = ahole.reverse();
- }
- }
- }
- var faces = ShapeUtils.triangulateShape(vertices, holes);
- var contour = vertices;
- for (h = 0, hl = holes.length; h < hl; h++) {
- ahole = holes[h];
- vertices = vertices.concat(ahole);
- }
- function scalePt2(pt, vec, size) {
- if (!vec)
- console.error("THREE.ExtrudeGeometry: vec does not exist");
- return vec.clone().multiplyScalar(size).add(pt);
- }
- var b, bs, t, z, vert, vlen = vertices.length, face, flen = faces.length;
- function getBevelVec(inPt, inPrev, inNext) {
- var v_trans_x, v_trans_y, shrink_by;
- var v_prev_x = inPt.x - inPrev.x, v_prev_y = inPt.y - inPrev.y;
- var v_next_x = inNext.x - inPt.x, v_next_y = inNext.y - inPt.y;
- var v_prev_lensq = v_prev_x * v_prev_x + v_prev_y * v_prev_y;
- var collinear0 = v_prev_x * v_next_y - v_prev_y * v_next_x;
- if (Math.abs(collinear0) > Number.EPSILON) {
- var v_prev_len = Math.sqrt(v_prev_lensq);
- var v_next_len = Math.sqrt(v_next_x * v_next_x + v_next_y * v_next_y);
- var ptPrevShift_x = inPrev.x - v_prev_y / v_prev_len;
- var ptPrevShift_y = inPrev.y + v_prev_x / v_prev_len;
- var ptNextShift_x = inNext.x - v_next_y / v_next_len;
- var ptNextShift_y = inNext.y + v_next_x / v_next_len;
- 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);
- v_trans_x = ptPrevShift_x + v_prev_x * sf - inPt.x;
- v_trans_y = ptPrevShift_y + v_prev_y * sf - inPt.y;
- var v_trans_lensq = v_trans_x * v_trans_x + v_trans_y * v_trans_y;
- if (v_trans_lensq <= 2) {
- return new Vector2(v_trans_x, v_trans_y);
- } else {
- shrink_by = Math.sqrt(v_trans_lensq / 2);
- }
- } else {
- var direction_eq = false;
- if (v_prev_x > Number.EPSILON) {
- if (v_next_x > Number.EPSILON) {
- direction_eq = true;
- }
- } else {
- if (v_prev_x < -Number.EPSILON) {
- if (v_next_x < -Number.EPSILON) {
- direction_eq = true;
- }
- } else {
- if (Math.sign(v_prev_y) === Math.sign(v_next_y)) {
- direction_eq = true;
- }
- }
- }
- if (direction_eq) {
- v_trans_x = -v_prev_y;
- v_trans_y = v_prev_x;
- shrink_by = Math.sqrt(v_prev_lensq);
- } else {
- v_trans_x = v_prev_x;
- v_trans_y = v_prev_y;
- shrink_by = Math.sqrt(v_prev_lensq / 2);
- }
- }
- return new Vector2(v_trans_x / shrink_by, v_trans_y / shrink_by);
- }
- var contourMovements = [];
- for (var i3 = 0, il = contour.length, j = il - 1, k = i3 + 1; i3 < il; i3++, j++, k++) {
- if (j === il)
- j = 0;
- if (k === il)
- k = 0;
- contourMovements[i3] = getBevelVec(contour[i3], contour[j], contour[k]);
- }
- var holesMovements = [], oneHoleMovements, verticesMovements = contourMovements.concat();
- for (h = 0, hl = holes.length; h < hl; h++) {
- ahole = holes[h];
- oneHoleMovements = [];
- for (i3 = 0, il = ahole.length, j = il - 1, k = i3 + 1; i3 < il; i3++, j++, k++) {
- if (j === il)
- j = 0;
- if (k === il)
- k = 0;
- oneHoleMovements[i3] = getBevelVec(ahole[i3], ahole[j], ahole[k]);
- }
- holesMovements.push(oneHoleMovements);
- verticesMovements = verticesMovements.concat(oneHoleMovements);
- }
- for (b = 0; b < bevelSegments; b++) {
- t = b / bevelSegments;
- z = bevelThickness * Math.cos(t * Math.PI / 2);
- bs = bevelSize * Math.sin(t * Math.PI / 2) + bevelOffset;
- for (i3 = 0, il = contour.length; i3 < il; i3++) {
- vert = scalePt2(contour[i3], contourMovements[i3], bs);
- v(vert.x, vert.y, -z);
- }
- for (h = 0, hl = holes.length; h < hl; h++) {
- ahole = holes[h];
- oneHoleMovements = holesMovements[h];
- for (i3 = 0, il = ahole.length; i3 < il; i3++) {
- vert = scalePt2(ahole[i3], oneHoleMovements[i3], bs);
- v(vert.x, vert.y, -z);
- }
- }
- }
- bs = bevelSize + bevelOffset;
- for (i3 = 0; i3 < vlen; i3++) {
- vert = bevelEnabled ? scalePt2(vertices[i3], verticesMovements[i3], bs) : vertices[i3];
- if (!extrudeByPath) {
- v(vert.x, vert.y, 0);
- } else {
- normal.copy(splineTube.normals[0]).multiplyScalar(vert.x);
- binormal.copy(splineTube.binormals[0]).multiplyScalar(vert.y);
- position2.copy(extrudePts[0]).add(normal).add(binormal);
- v(position2.x, position2.y, position2.z);
- }
- }
- var s;
- for (s = 1; s <= steps; s++) {
- for (i3 = 0; i3 < vlen; i3++) {
- vert = bevelEnabled ? scalePt2(vertices[i3], verticesMovements[i3], bs) : vertices[i3];
- if (!extrudeByPath) {
- v(vert.x, vert.y, depth / steps * s);
- } else {
- normal.copy(splineTube.normals[s]).multiplyScalar(vert.x);
- binormal.copy(splineTube.binormals[s]).multiplyScalar(vert.y);
- position2.copy(extrudePts[s]).add(normal).add(binormal);
- v(position2.x, position2.y, position2.z);
- }
- }
- }
- for (b = bevelSegments - 1; b >= 0; b--) {
- t = b / bevelSegments;
- z = bevelThickness * Math.cos(t * Math.PI / 2);
- bs = bevelSize * Math.sin(t * Math.PI / 2) + bevelOffset;
- for (i3 = 0, il = contour.length; i3 < il; i3++) {
- vert = scalePt2(contour[i3], contourMovements[i3], bs);
- v(vert.x, vert.y, depth + z);
- }
- for (h = 0, hl = holes.length; h < hl; h++) {
- ahole = holes[h];
- oneHoleMovements = holesMovements[h];
- for (i3 = 0, il = ahole.length; i3 < il; i3++) {
- vert = scalePt2(ahole[i3], oneHoleMovements[i3], bs);
- if (!extrudeByPath) {
- v(vert.x, vert.y, depth + z);
- } else {
- v(vert.x, vert.y + extrudePts[steps - 1].y, extrudePts[steps - 1].x + z);
- }
- }
- }
- }
- buildLidFaces();
- buildSideFaces();
- function buildLidFaces() {
- var start = verticesArray.length / 3;
- if (bevelEnabled) {
- var layer = 0;
- var offset = vlen * layer;
- for (i3 = 0; i3 < flen; i3++) {
- face = faces[i3];
- f3(face[2] + offset, face[1] + offset, face[0] + offset);
- }
- layer = steps + bevelSegments * 2;
- offset = vlen * layer;
- for (i3 = 0; i3 < flen; i3++) {
- face = faces[i3];
- f3(face[0] + offset, face[1] + offset, face[2] + offset);
- }
- } else {
- for (i3 = 0; i3 < flen; i3++) {
- face = faces[i3];
- f3(face[2], face[1], face[0]);
- }
- for (i3 = 0; i3 < flen; i3++) {
- face = faces[i3];
- f3(face[0] + vlen * steps, face[1] + vlen * steps, face[2] + vlen * steps);
- }
- }
- scope.addGroup(start, verticesArray.length / 3 - start, 0);
- }
- function buildSideFaces() {
- var start = verticesArray.length / 3;
- var layeroffset = 0;
- sidewalls(contour, layeroffset);
- layeroffset += contour.length;
- for (h = 0, hl = holes.length; h < hl; h++) {
- ahole = holes[h];
- sidewalls(ahole, layeroffset);
- layeroffset += ahole.length;
- }
- scope.addGroup(start, verticesArray.length / 3 - start, 1);
- }
- function sidewalls(contour2, layeroffset) {
- var j2, k2;
- i3 = contour2.length;
- while (--i3 >= 0) {
- j2 = i3;
- k2 = i3 - 1;
- if (k2 < 0)
- k2 = contour2.length - 1;
- var s2 = 0, sl = steps + bevelSegments * 2;
- for (s2 = 0; s2 < sl; s2++) {
- var slen1 = vlen * s2;
- var slen2 = vlen * (s2 + 1);
- var a = layeroffset + j2 + slen1, b2 = layeroffset + k2 + slen1, c = layeroffset + k2 + slen2, d = layeroffset + j2 + slen2;
- f4(a, b2, c, d);
- }
- }
- }
- function v(x, y, z2) {
- placeholder.push(x);
- placeholder.push(y);
- placeholder.push(z2);
- }
- function f3(a, b2, c) {
- addVertex(a);
- addVertex(b2);
- addVertex(c);
- var nextIndex = verticesArray.length / 3;
- var uvs = uvgen.generateTopUV(scope, verticesArray, nextIndex - 3, nextIndex - 2, nextIndex - 1);
- addUV(uvs[0]);
- addUV(uvs[1]);
- addUV(uvs[2]);
- }
- function f4(a, b2, c, d) {
- addVertex(a);
- addVertex(b2);
- addVertex(d);
- addVertex(b2);
- addVertex(c);
- addVertex(d);
- var nextIndex = verticesArray.length / 3;
- var uvs = uvgen.generateSideWallUV(scope, verticesArray, nextIndex - 6, nextIndex - 3, nextIndex - 2, nextIndex - 1);
- addUV(uvs[0]);
- addUV(uvs[1]);
- addUV(uvs[3]);
- addUV(uvs[1]);
- addUV(uvs[2]);
- addUV(uvs[3]);
- }
- function addVertex(index) {
- verticesArray.push(placeholder[index * 3 + 0]);
- verticesArray.push(placeholder[index * 3 + 1]);
- verticesArray.push(placeholder[index * 3 + 2]);
- }
- function addUV(vector2) {
- uvArray.push(vector2.x);
- uvArray.push(vector2.y);
- }
- }
- }
- ExtrudeBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
- ExtrudeBufferGeometry.prototype.constructor = ExtrudeBufferGeometry;
- ExtrudeBufferGeometry.prototype.toJSON = function() {
- var data = BufferGeometry.prototype.toJSON.call(this);
- var shapes = this.parameters.shapes;
- var options = this.parameters.options;
- return toJSON(shapes, options, data);
- };
- var WorldUVGenerator = {
- generateTopUV: function(geometry, vertices, indexA, indexB, indexC) {
- var a_x = vertices[indexA * 3];
- var a_y = vertices[indexA * 3 + 1];
- var b_x = vertices[indexB * 3];
- var b_y = vertices[indexB * 3 + 1];
- var c_x = vertices[indexC * 3];
- var c_y = vertices[indexC * 3 + 1];
- return [
- new Vector2(a_x, a_y),
- new Vector2(b_x, b_y),
- new Vector2(c_x, c_y)
- ];
- },
- generateSideWallUV: function(geometry, vertices, indexA, indexB, indexC, indexD) {
- var a_x = vertices[indexA * 3];
- var a_y = vertices[indexA * 3 + 1];
- var a_z = vertices[indexA * 3 + 2];
- var b_x = vertices[indexB * 3];
- var b_y = vertices[indexB * 3 + 1];
- var b_z = vertices[indexB * 3 + 2];
- var c_x = vertices[indexC * 3];
- var c_y = vertices[indexC * 3 + 1];
- var c_z = vertices[indexC * 3 + 2];
- var d_x = vertices[indexD * 3];
- var d_y = vertices[indexD * 3 + 1];
- var d_z = vertices[indexD * 3 + 2];
- if (Math.abs(a_y - b_y) < 0.01) {
- return [
- new Vector2(a_x, 1 - a_z),
- new Vector2(b_x, 1 - b_z),
- new Vector2(c_x, 1 - c_z),
- new Vector2(d_x, 1 - d_z)
- ];
- } else {
- return [
- new Vector2(a_y, 1 - a_z),
- new Vector2(b_y, 1 - b_z),
- new Vector2(c_y, 1 - c_z),
- new Vector2(d_y, 1 - d_z)
- ];
- }
- }
- };
- function toJSON(shapes, options, data) {
- data.shapes = [];
- if (Array.isArray(shapes)) {
- for (var i2 = 0, l = shapes.length; i2 < l; i2++) {
- var shape = shapes[i2];
- data.shapes.push(shape.uuid);
- }
- } else {
- data.shapes.push(shapes.uuid);
- }
- if (options.extrudePath !== void 0)
- data.options.extrudePath = options.extrudePath.toJSON();
- return data;
- }
- function TextGeometry(text, parameters) {
- Geometry.call(this);
- this.type = "TextGeometry";
- this.parameters = {
- text,
- parameters
- };
- this.fromBufferGeometry(new TextBufferGeometry(text, parameters));
- this.mergeVertices();
- }
- TextGeometry.prototype = Object.create(Geometry.prototype);
- TextGeometry.prototype.constructor = TextGeometry;
- function TextBufferGeometry(text, parameters) {
- parameters = parameters || {};
- var font = parameters.font;
- if (!(font && font.isFont)) {
- console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font.");
- return new Geometry();
- }
- var shapes = font.generateShapes(text, parameters.size);
- parameters.depth = parameters.height !== void 0 ? parameters.height : 50;
- if (parameters.bevelThickness === void 0)
- parameters.bevelThickness = 10;
- if (parameters.bevelSize === void 0)
- parameters.bevelSize = 8;
- if (parameters.bevelEnabled === void 0)
- parameters.bevelEnabled = false;
- ExtrudeBufferGeometry.call(this, shapes, parameters);
- this.type = "TextBufferGeometry";
- }
- TextBufferGeometry.prototype = Object.create(ExtrudeBufferGeometry.prototype);
- TextBufferGeometry.prototype.constructor = TextBufferGeometry;
- function SphereGeometry(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength) {
- Geometry.call(this);
- this.type = "SphereGeometry";
- this.parameters = {
- radius,
- widthSegments,
- heightSegments,
- phiStart,
- phiLength,
- thetaStart,
- thetaLength
- };
- this.fromBufferGeometry(new SphereBufferGeometry(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength));
- this.mergeVertices();
- }
- SphereGeometry.prototype = Object.create(Geometry.prototype);
- SphereGeometry.prototype.constructor = SphereGeometry;
- function SphereBufferGeometry(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength) {
- BufferGeometry.call(this);
- this.type = "SphereBufferGeometry";
- this.parameters = {
- radius,
- widthSegments,
- heightSegments,
- phiStart,
- phiLength,
- thetaStart,
- thetaLength
- };
- radius = radius || 1;
- widthSegments = Math.max(3, Math.floor(widthSegments) || 8);
- heightSegments = Math.max(2, Math.floor(heightSegments) || 6);
- phiStart = phiStart !== void 0 ? phiStart : 0;
- phiLength = phiLength !== void 0 ? phiLength : Math.PI * 2;
- thetaStart = thetaStart !== void 0 ? thetaStart : 0;
- thetaLength = thetaLength !== void 0 ? thetaLength : Math.PI;
- var thetaEnd = Math.min(thetaStart + thetaLength, Math.PI);
- var ix, iy;
- var index = 0;
- var grid = [];
- var vertex = new Vector3();
- var normal = new Vector3();
- var indices = [];
- var vertices = [];
- var normals = [];
- var uvs = [];
- for (iy = 0; iy <= heightSegments; iy++) {
- var verticesRow = [];
- var v = iy / heightSegments;
- var uOffset = 0;
- if (iy == 0 && thetaStart == 0) {
- uOffset = 0.5 / widthSegments;
- } else if (iy == heightSegments && thetaEnd == Math.PI) {
- uOffset = -0.5 / widthSegments;
- }
- for (ix = 0; ix <= widthSegments; ix++) {
- var u = ix / widthSegments;
- vertex.x = -radius * Math.cos(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength);
- vertex.y = radius * Math.cos(thetaStart + v * thetaLength);
- vertex.z = radius * Math.sin(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength);
- vertices.push(vertex.x, vertex.y, vertex.z);
- normal.copy(vertex).normalize();
- normals.push(normal.x, normal.y, normal.z);
- uvs.push(u + uOffset, 1 - v);
- verticesRow.push(index++);
- }
- grid.push(verticesRow);
- }
- for (iy = 0; iy < heightSegments; iy++) {
- for (ix = 0; ix < widthSegments; ix++) {
- var a = grid[iy][ix + 1];
- var b = grid[iy][ix];
- var c = grid[iy + 1][ix];
- var d = grid[iy + 1][ix + 1];
- if (iy !== 0 || thetaStart > 0)
- indices.push(a, b, d);
- if (iy !== heightSegments - 1 || thetaEnd < Math.PI)
- indices.push(b, c, d);
- }
- }
- this.setIndex(indices);
- this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
- this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
- }
- SphereBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
- SphereBufferGeometry.prototype.constructor = SphereBufferGeometry;
- function RingGeometry(innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength) {
- Geometry.call(this);
- this.type = "RingGeometry";
- this.parameters = {
- innerRadius,
- outerRadius,
- thetaSegments,
- phiSegments,
- thetaStart,
- thetaLength
- };
- this.fromBufferGeometry(new RingBufferGeometry(innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength));
- this.mergeVertices();
- }
- RingGeometry.prototype = Object.create(Geometry.prototype);
- RingGeometry.prototype.constructor = RingGeometry;
- function RingBufferGeometry(innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength) {
- BufferGeometry.call(this);
- this.type = "RingBufferGeometry";
- this.parameters = {
- innerRadius,
- outerRadius,
- thetaSegments,
- phiSegments,
- thetaStart,
- thetaLength
- };
- innerRadius = innerRadius || 0.5;
- outerRadius = outerRadius || 1;
- thetaStart = thetaStart !== void 0 ? thetaStart : 0;
- thetaLength = thetaLength !== void 0 ? thetaLength : Math.PI * 2;
- thetaSegments = thetaSegments !== void 0 ? Math.max(3, thetaSegments) : 8;
- phiSegments = phiSegments !== void 0 ? Math.max(1, phiSegments) : 1;
- var indices = [];
- var vertices = [];
- var normals = [];
- var uvs = [];
- var segment;
- var radius = innerRadius;
- var radiusStep = (outerRadius - innerRadius) / phiSegments;
- var vertex = new Vector3();
- var uv = new Vector2();
- var j, i2;
- for (j = 0; j <= phiSegments; j++) {
- for (i2 = 0; i2 <= thetaSegments; i2++) {
- segment = thetaStart + i2 / thetaSegments * thetaLength;
- vertex.x = radius * Math.cos(segment);
- vertex.y = radius * Math.sin(segment);
- vertices.push(vertex.x, vertex.y, vertex.z);
- normals.push(0, 0, 1);
- uv.x = (vertex.x / outerRadius + 1) / 2;
- uv.y = (vertex.y / outerRadius + 1) / 2;
- uvs.push(uv.x, uv.y);
- }
- radius += radiusStep;
- }
- for (j = 0; j < phiSegments; j++) {
- var thetaSegmentLevel = j * (thetaSegments + 1);
- for (i2 = 0; i2 < thetaSegments; i2++) {
- segment = i2 + thetaSegmentLevel;
- var a = segment;
- var b = segment + thetaSegments + 1;
- var c = segment + thetaSegments + 2;
- var d = segment + 1;
- indices.push(a, b, d);
- indices.push(b, c, d);
- }
- }
- this.setIndex(indices);
- this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
- this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
- }
- RingBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
- RingBufferGeometry.prototype.constructor = RingBufferGeometry;
- function LatheGeometry(points, segments, phiStart, phiLength) {
- Geometry.call(this);
- this.type = "LatheGeometry";
- this.parameters = {
- points,
- segments,
- phiStart,
- phiLength
- };
- this.fromBufferGeometry(new LatheBufferGeometry(points, segments, phiStart, phiLength));
- this.mergeVertices();
- }
- LatheGeometry.prototype = Object.create(Geometry.prototype);
- LatheGeometry.prototype.constructor = LatheGeometry;
- function LatheBufferGeometry(points, segments, phiStart, phiLength) {
- BufferGeometry.call(this);
- this.type = "LatheBufferGeometry";
- this.parameters = {
- points,
- segments,
- phiStart,
- phiLength
- };
- segments = Math.floor(segments) || 12;
- phiStart = phiStart || 0;
- phiLength = phiLength || Math.PI * 2;
- phiLength = MathUtils.clamp(phiLength, 0, Math.PI * 2);
- var indices = [];
- var vertices = [];
- var uvs = [];
- var base;
- var inverseSegments = 1 / segments;
- var vertex = new Vector3();
- var uv = new Vector2();
- var i2, j;
- for (i2 = 0; i2 <= segments; i2++) {
- var phi = phiStart + i2 * inverseSegments * phiLength;
- var sin = Math.sin(phi);
- var cos = Math.cos(phi);
- for (j = 0; j <= points.length - 1; j++) {
- vertex.x = points[j].x * sin;
- vertex.y = points[j].y;
- vertex.z = points[j].x * cos;
- vertices.push(vertex.x, vertex.y, vertex.z);
- uv.x = i2 / segments;
- uv.y = j / (points.length - 1);
- uvs.push(uv.x, uv.y);
- }
- }
- for (i2 = 0; i2 < segments; i2++) {
- for (j = 0; j < points.length - 1; j++) {
- base = j + i2 * points.length;
- var a = base;
- var b = base + points.length;
- var c = base + points.length + 1;
- var d = base + 1;
- indices.push(a, b, d);
- indices.push(b, c, d);
- }
- }
- this.setIndex(indices);
- this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
- this.computeVertexNormals();
- if (phiLength === Math.PI * 2) {
- var normals = this.attributes.normal.array;
- var n1 = new Vector3();
- var n2 = new Vector3();
- var n = new Vector3();
- base = segments * points.length * 3;
- for (i2 = 0, j = 0; i2 < points.length; i2++, j += 3) {
- n1.x = normals[j + 0];
- n1.y = normals[j + 1];
- n1.z = normals[j + 2];
- n2.x = normals[base + j + 0];
- n2.y = normals[base + j + 1];
- n2.z = normals[base + j + 2];
- n.addVectors(n1, n2).normalize();
- normals[j + 0] = normals[base + j + 0] = n.x;
- normals[j + 1] = normals[base + j + 1] = n.y;
- normals[j + 2] = normals[base + j + 2] = n.z;
- }
- }
- }
- LatheBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
- LatheBufferGeometry.prototype.constructor = LatheBufferGeometry;
- function ShapeGeometry(shapes, curveSegments) {
- Geometry.call(this);
- this.type = "ShapeGeometry";
- if (typeof curveSegments === "object") {
- console.warn("THREE.ShapeGeometry: Options parameter has been removed.");
- curveSegments = curveSegments.curveSegments;
- }
- this.parameters = {
- shapes,
- curveSegments
- };
- this.fromBufferGeometry(new ShapeBufferGeometry(shapes, curveSegments));
- this.mergeVertices();
- }
- ShapeGeometry.prototype = Object.create(Geometry.prototype);
- ShapeGeometry.prototype.constructor = ShapeGeometry;
- ShapeGeometry.prototype.toJSON = function() {
- var data = Geometry.prototype.toJSON.call(this);
- var shapes = this.parameters.shapes;
- return toJSON$1(shapes, data);
- };
- function ShapeBufferGeometry(shapes, curveSegments) {
- BufferGeometry.call(this);
- this.type = "ShapeBufferGeometry";
- this.parameters = {
- shapes,
- curveSegments
- };
- curveSegments = curveSegments || 12;
- var indices = [];
- var vertices = [];
- var normals = [];
- var uvs = [];
- var groupStart = 0;
- var groupCount = 0;
- if (Array.isArray(shapes) === false) {
- addShape(shapes);
- } else {
- for (var i2 = 0; i2 < shapes.length; i2++) {
- addShape(shapes[i2]);
- this.addGroup(groupStart, groupCount, i2);
- groupStart += groupCount;
- groupCount = 0;
- }
- }
- this.setIndex(indices);
- this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
- this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
- function addShape(shape) {
- var i3, l, shapeHole;
- var indexOffset = vertices.length / 3;
- var points = shape.extractPoints(curveSegments);
- var shapeVertices = points.shape;
- var shapeHoles = points.holes;
- if (ShapeUtils.isClockWise(shapeVertices) === false) {
- shapeVertices = shapeVertices.reverse();
- }
- for (i3 = 0, l = shapeHoles.length; i3 < l; i3++) {
- shapeHole = shapeHoles[i3];
- if (ShapeUtils.isClockWise(shapeHole) === true) {
- shapeHoles[i3] = shapeHole.reverse();
- }
- }
- var faces = ShapeUtils.triangulateShape(shapeVertices, shapeHoles);
- for (i3 = 0, l = shapeHoles.length; i3 < l; i3++) {
- shapeHole = shapeHoles[i3];
- shapeVertices = shapeVertices.concat(shapeHole);
- }
- for (i3 = 0, l = shapeVertices.length; i3 < l; i3++) {
- var vertex = shapeVertices[i3];
- vertices.push(vertex.x, vertex.y, 0);
- normals.push(0, 0, 1);
- uvs.push(vertex.x, vertex.y);
- }
- for (i3 = 0, l = faces.length; i3 < l; i3++) {
- var face = faces[i3];
- var a = face[0] + indexOffset;
- var b = face[1] + indexOffset;
- var c = face[2] + indexOffset;
- indices.push(a, b, c);
- groupCount += 3;
- }
- }
- }
- ShapeBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
- ShapeBufferGeometry.prototype.constructor = ShapeBufferGeometry;
- ShapeBufferGeometry.prototype.toJSON = function() {
- var data = BufferGeometry.prototype.toJSON.call(this);
- var shapes = this.parameters.shapes;
- return toJSON$1(shapes, data);
- };
- function toJSON$1(shapes, data) {
- data.shapes = [];
- if (Array.isArray(shapes)) {
- for (var i2 = 0, l = shapes.length; i2 < l; i2++) {
- var shape = shapes[i2];
- data.shapes.push(shape.uuid);
- }
- } else {
- data.shapes.push(shapes.uuid);
- }
- return data;
- }
- function EdgesGeometry(geometry, thresholdAngle) {
- BufferGeometry.call(this);
- this.type = "EdgesGeometry";
- this.parameters = {
- thresholdAngle
- };
- thresholdAngle = thresholdAngle !== void 0 ? thresholdAngle : 1;
- var vertices = [];
- var thresholdDot = Math.cos(MathUtils.DEG2RAD * thresholdAngle);
- var edge = [0, 0], edges = {}, edge1, edge2;
- var key, keys = ["a", "b", "c"];
- var geometry2;
- if (geometry.isBufferGeometry) {
- geometry2 = new Geometry();
- geometry2.fromBufferGeometry(geometry);
- } else {
- geometry2 = geometry.clone();
- }
- geometry2.mergeVertices();
- geometry2.computeFaceNormals();
- var sourceVertices = geometry2.vertices;
- var faces = geometry2.faces;
- for (var i2 = 0, l = faces.length; i2 < l; i2++) {
- var face = faces[i2];
- for (var j = 0; j < 3; j++) {
- edge1 = face[keys[j]];
- edge2 = face[keys[(j + 1) % 3]];
- edge[0] = Math.min(edge1, edge2);
- edge[1] = Math.max(edge1, edge2);
- key = edge[0] + "," + edge[1];
- if (edges[key] === void 0) {
- edges[key] = { index1: edge[0], index2: edge[1], face1: i2, face2: void 0 };
- } else {
- edges[key].face2 = i2;
- }
- }
- }
- for (key in edges) {
- var e = edges[key];
- if (e.face2 === void 0 || faces[e.face1].normal.dot(faces[e.face2].normal) <= thresholdDot) {
- var vertex = sourceVertices[e.index1];
- vertices.push(vertex.x, vertex.y, vertex.z);
- vertex = sourceVertices[e.index2];
- vertices.push(vertex.x, vertex.y, vertex.z);
- }
- }
- this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- }
- EdgesGeometry.prototype = Object.create(BufferGeometry.prototype);
- EdgesGeometry.prototype.constructor = EdgesGeometry;
- function CylinderGeometry(radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength) {
- Geometry.call(this);
- this.type = "CylinderGeometry";
- this.parameters = {
- radiusTop,
- radiusBottom,
- height,
- radialSegments,
- heightSegments,
- openEnded,
- thetaStart,
- thetaLength
- };
- this.fromBufferGeometry(new CylinderBufferGeometry(radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength));
- this.mergeVertices();
- }
- CylinderGeometry.prototype = Object.create(Geometry.prototype);
- CylinderGeometry.prototype.constructor = CylinderGeometry;
- function CylinderBufferGeometry(radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength) {
- BufferGeometry.call(this);
- this.type = "CylinderBufferGeometry";
- this.parameters = {
- radiusTop,
- radiusBottom,
- height,
- radialSegments,
- heightSegments,
- openEnded,
- thetaStart,
- thetaLength
- };
- var scope = this;
- radiusTop = radiusTop !== void 0 ? radiusTop : 1;
- radiusBottom = radiusBottom !== void 0 ? radiusBottom : 1;
- height = height || 1;
- radialSegments = Math.floor(radialSegments) || 8;
- heightSegments = Math.floor(heightSegments) || 1;
- openEnded = openEnded !== void 0 ? openEnded : false;
- thetaStart = thetaStart !== void 0 ? thetaStart : 0;
- thetaLength = thetaLength !== void 0 ? thetaLength : Math.PI * 2;
- var indices = [];
- var vertices = [];
- var normals = [];
- var uvs = [];
- var index = 0;
- var indexArray = [];
- var halfHeight = height / 2;
- var groupStart = 0;
- generateTorso();
- if (openEnded === false) {
- if (radiusTop > 0)
- generateCap(true);
- if (radiusBottom > 0)
- generateCap(false);
- }
- this.setIndex(indices);
- this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
- this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
- function generateTorso() {
- var x, y;
- var normal = new Vector3();
- var vertex = new Vector3();
- var groupCount = 0;
- var slope = (radiusBottom - radiusTop) / height;
- for (y = 0; y <= heightSegments; y++) {
- var indexRow = [];
- var v = y / heightSegments;
- var radius = v * (radiusBottom - radiusTop) + radiusTop;
- for (x = 0; x <= radialSegments; x++) {
- var u = x / radialSegments;
- var theta = u * thetaLength + thetaStart;
- var sinTheta = Math.sin(theta);
- var cosTheta = Math.cos(theta);
- vertex.x = radius * sinTheta;
- vertex.y = -v * height + halfHeight;
- vertex.z = radius * cosTheta;
- vertices.push(vertex.x, vertex.y, vertex.z);
- normal.set(sinTheta, slope, cosTheta).normalize();
- normals.push(normal.x, normal.y, normal.z);
- uvs.push(u, 1 - v);
- indexRow.push(index++);
- }
- indexArray.push(indexRow);
- }
- for (x = 0; x < radialSegments; x++) {
- for (y = 0; y < heightSegments; y++) {
- var a = indexArray[y][x];
- var b = indexArray[y + 1][x];
- var c = indexArray[y + 1][x + 1];
- var d = indexArray[y][x + 1];
- indices.push(a, b, d);
- indices.push(b, c, d);
- groupCount += 6;
- }
- }
- scope.addGroup(groupStart, groupCount, 0);
- groupStart += groupCount;
- }
- function generateCap(top2) {
- var x, centerIndexStart, centerIndexEnd;
- var uv = new Vector2();
- var vertex = new Vector3();
- var groupCount = 0;
- var radius = top2 === true ? radiusTop : radiusBottom;
- var sign = top2 === true ? 1 : -1;
- centerIndexStart = index;
- for (x = 1; x <= radialSegments; x++) {
- vertices.push(0, halfHeight * sign, 0);
- normals.push(0, sign, 0);
- uvs.push(0.5, 0.5);
- index++;
- }
- centerIndexEnd = index;
- for (x = 0; x <= radialSegments; x++) {
- var u = x / radialSegments;
- var theta = u * thetaLength + thetaStart;
- var cosTheta = Math.cos(theta);
- var sinTheta = Math.sin(theta);
- vertex.x = radius * sinTheta;
- vertex.y = halfHeight * sign;
- vertex.z = radius * cosTheta;
- vertices.push(vertex.x, vertex.y, vertex.z);
- normals.push(0, sign, 0);
- uv.x = cosTheta * 0.5 + 0.5;
- uv.y = sinTheta * 0.5 * sign + 0.5;
- uvs.push(uv.x, uv.y);
- index++;
- }
- for (x = 0; x < radialSegments; x++) {
- var c = centerIndexStart + x;
- var i2 = centerIndexEnd + x;
- if (top2 === true) {
- indices.push(i2, i2 + 1, c);
- } else {
- indices.push(i2 + 1, i2, c);
- }
- groupCount += 3;
- }
- scope.addGroup(groupStart, groupCount, top2 === true ? 1 : 2);
- groupStart += groupCount;
- }
- }
- CylinderBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
- CylinderBufferGeometry.prototype.constructor = CylinderBufferGeometry;
- function ConeGeometry(radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength) {
- CylinderGeometry.call(this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength);
- this.type = "ConeGeometry";
- this.parameters = {
- radius,
- height,
- radialSegments,
- heightSegments,
- openEnded,
- thetaStart,
- thetaLength
- };
- }
- ConeGeometry.prototype = Object.create(CylinderGeometry.prototype);
- ConeGeometry.prototype.constructor = ConeGeometry;
- function ConeBufferGeometry(radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength) {
- CylinderBufferGeometry.call(this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength);
- this.type = "ConeBufferGeometry";
- this.parameters = {
- radius,
- height,
- radialSegments,
- heightSegments,
- openEnded,
- thetaStart,
- thetaLength
- };
- }
- ConeBufferGeometry.prototype = Object.create(CylinderBufferGeometry.prototype);
- ConeBufferGeometry.prototype.constructor = ConeBufferGeometry;
- function CircleGeometry(radius, segments, thetaStart, thetaLength) {
- Geometry.call(this);
- this.type = "CircleGeometry";
- this.parameters = {
- radius,
- segments,
- thetaStart,
- thetaLength
- };
- this.fromBufferGeometry(new CircleBufferGeometry(radius, segments, thetaStart, thetaLength));
- this.mergeVertices();
- }
- CircleGeometry.prototype = Object.create(Geometry.prototype);
- CircleGeometry.prototype.constructor = CircleGeometry;
- function CircleBufferGeometry(radius, segments, thetaStart, thetaLength) {
- BufferGeometry.call(this);
- this.type = "CircleBufferGeometry";
- this.parameters = {
- radius,
- segments,
- thetaStart,
- thetaLength
- };
- radius = radius || 1;
- segments = segments !== void 0 ? Math.max(3, segments) : 8;
- thetaStart = thetaStart !== void 0 ? thetaStart : 0;
- thetaLength = thetaLength !== void 0 ? thetaLength : Math.PI * 2;
- var indices = [];
- var vertices = [];
- var normals = [];
- var uvs = [];
- var i2, s;
- var vertex = new Vector3();
- var uv = new Vector2();
- vertices.push(0, 0, 0);
- normals.push(0, 0, 1);
- uvs.push(0.5, 0.5);
- for (s = 0, i2 = 3; s <= segments; s++, i2 += 3) {
- var segment = thetaStart + s / segments * thetaLength;
- vertex.x = radius * Math.cos(segment);
- vertex.y = radius * Math.sin(segment);
- vertices.push(vertex.x, vertex.y, vertex.z);
- normals.push(0, 0, 1);
- uv.x = (vertices[i2] / radius + 1) / 2;
- uv.y = (vertices[i2 + 1] / radius + 1) / 2;
- uvs.push(uv.x, uv.y);
- }
- for (i2 = 1; i2 <= segments; i2++) {
- indices.push(i2, i2 + 1, 0);
- }
- this.setIndex(indices);
- this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
- this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
- }
- CircleBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
- CircleBufferGeometry.prototype.constructor = CircleBufferGeometry;
- var Geometries = /* @__PURE__ */ Object.freeze({
- __proto__: null,
- WireframeGeometry,
- ParametricGeometry,
- ParametricBufferGeometry,
- TetrahedronGeometry,
- TetrahedronBufferGeometry,
- OctahedronGeometry,
- OctahedronBufferGeometry,
- IcosahedronGeometry,
- IcosahedronBufferGeometry,
- DodecahedronGeometry,
- DodecahedronBufferGeometry,
- PolyhedronGeometry,
- PolyhedronBufferGeometry,
- TubeGeometry,
- TubeBufferGeometry,
- TorusKnotGeometry,
- TorusKnotBufferGeometry,
- TorusGeometry,
- TorusBufferGeometry,
- TextGeometry,
- TextBufferGeometry,
- SphereGeometry,
- SphereBufferGeometry,
- RingGeometry,
- RingBufferGeometry,
- PlaneGeometry,
- PlaneBufferGeometry,
- LatheGeometry,
- LatheBufferGeometry,
- ShapeGeometry,
- ShapeBufferGeometry,
- ExtrudeGeometry,
- ExtrudeBufferGeometry,
- EdgesGeometry,
- ConeGeometry,
- ConeBufferGeometry,
- CylinderGeometry,
- CylinderBufferGeometry,
- CircleGeometry,
- CircleBufferGeometry,
- BoxGeometry,
- BoxBufferGeometry
- });
- function ShadowMaterial(parameters) {
- Material.call(this);
- this.type = "ShadowMaterial";
- this.color = new Color(0);
- this.transparent = true;
- this.setValues(parameters);
- }
- ShadowMaterial.prototype = Object.create(Material.prototype);
- ShadowMaterial.prototype.constructor = ShadowMaterial;
- ShadowMaterial.prototype.isShadowMaterial = true;
- ShadowMaterial.prototype.copy = function(source) {
- Material.prototype.copy.call(this, source);
- this.color.copy(source.color);
- return this;
- };
- function RawShaderMaterial(parameters) {
- ShaderMaterial.call(this, parameters);
- this.type = "RawShaderMaterial";
- }
- RawShaderMaterial.prototype = Object.create(ShaderMaterial.prototype);
- RawShaderMaterial.prototype.constructor = RawShaderMaterial;
- RawShaderMaterial.prototype.isRawShaderMaterial = true;
- function MeshStandardMaterial(parameters) {
- Material.call(this);
- this.defines = { "STANDARD": "" };
- this.type = "MeshStandardMaterial";
- this.color = new Color(16777215);
- this.roughness = 1;
- this.metalness = 0;
- this.map = null;
- this.lightMap = null;
- this.lightMapIntensity = 1;
- this.aoMap = null;
- this.aoMapIntensity = 1;
- this.emissive = new Color(0);
- this.emissiveIntensity = 1;
- this.emissiveMap = null;
- this.bumpMap = null;
- this.bumpScale = 1;
- this.normalMap = null;
- this.normalMapType = TangentSpaceNormalMap;
- this.normalScale = new Vector2(1, 1);
- this.displacementMap = null;
- this.displacementScale = 1;
- this.displacementBias = 0;
- this.roughnessMap = null;
- this.metalnessMap = null;
- this.alphaMap = null;
- this.envMap = null;
- this.envMapIntensity = 1;
- this.refractionRatio = 0.98;
- this.wireframe = false;
- this.wireframeLinewidth = 1;
- this.wireframeLinecap = "round";
- this.wireframeLinejoin = "round";
- this.skinning = false;
- this.morphTargets = false;
- this.morphNormals = false;
- this.setValues(parameters);
- }
- MeshStandardMaterial.prototype = Object.create(Material.prototype);
- MeshStandardMaterial.prototype.constructor = MeshStandardMaterial;
- MeshStandardMaterial.prototype.isMeshStandardMaterial = true;
- MeshStandardMaterial.prototype.copy = function(source) {
- Material.prototype.copy.call(this, source);
- this.defines = { "STANDARD": "" };
- this.color.copy(source.color);
- this.roughness = source.roughness;
- this.metalness = source.metalness;
- this.map = source.map;
- this.lightMap = source.lightMap;
- this.lightMapIntensity = source.lightMapIntensity;
- this.aoMap = source.aoMap;
- this.aoMapIntensity = source.aoMapIntensity;
- this.emissive.copy(source.emissive);
- this.emissiveMap = source.emissiveMap;
- this.emissiveIntensity = source.emissiveIntensity;
- this.bumpMap = source.bumpMap;
- this.bumpScale = source.bumpScale;
- this.normalMap = source.normalMap;
- this.normalMapType = source.normalMapType;
- this.normalScale.copy(source.normalScale);
- this.displacementMap = source.displacementMap;
- this.displacementScale = source.displacementScale;
- this.displacementBias = source.displacementBias;
- this.roughnessMap = source.roughnessMap;
- this.metalnessMap = source.metalnessMap;
- this.alphaMap = source.alphaMap;
- this.envMap = source.envMap;
- this.envMapIntensity = source.envMapIntensity;
- this.refractionRatio = source.refractionRatio;
- this.wireframe = source.wireframe;
- this.wireframeLinewidth = source.wireframeLinewidth;
- this.wireframeLinecap = source.wireframeLinecap;
- this.wireframeLinejoin = source.wireframeLinejoin;
- this.skinning = source.skinning;
- this.morphTargets = source.morphTargets;
- this.morphNormals = source.morphNormals;
- return this;
- };
- function MeshPhysicalMaterial(parameters) {
- MeshStandardMaterial.call(this);
- this.defines = {
- "STANDARD": "",
- "PHYSICAL": ""
- };
- this.type = "MeshPhysicalMaterial";
- this.reflectivity = 0.5;
- this.clearcoat = 0;
- this.clearcoatRoughness = 0;
- this.sheen = null;
- this.clearcoatNormalScale = new Vector2(1, 1);
- this.clearcoatNormalMap = null;
- this.transparency = 0;
- this.setValues(parameters);
- }
- MeshPhysicalMaterial.prototype = Object.create(MeshStandardMaterial.prototype);
- MeshPhysicalMaterial.prototype.constructor = MeshPhysicalMaterial;
- MeshPhysicalMaterial.prototype.isMeshPhysicalMaterial = true;
- MeshPhysicalMaterial.prototype.copy = function(source) {
- MeshStandardMaterial.prototype.copy.call(this, source);
- this.defines = {
- "STANDARD": "",
- "PHYSICAL": ""
- };
- this.reflectivity = source.reflectivity;
- this.clearcoat = source.clearcoat;
- this.clearcoatRoughness = source.clearcoatRoughness;
- if (source.sheen)
- this.sheen = (this.sheen || new Color()).copy(source.sheen);
- else
- this.sheen = null;
- this.clearcoatNormalMap = source.clearcoatNormalMap;
- this.clearcoatNormalScale.copy(source.clearcoatNormalScale);
- this.transparency = source.transparency;
- return this;
- };
- function MeshPhongMaterial(parameters) {
- Material.call(this);
- this.type = "MeshPhongMaterial";
- this.color = new Color(16777215);
- this.specular = new Color(1118481);
- this.shininess = 30;
- this.map = null;
- this.lightMap = null;
- this.lightMapIntensity = 1;
- this.aoMap = null;
- this.aoMapIntensity = 1;
- this.emissive = new Color(0);
- this.emissiveIntensity = 1;
- this.emissiveMap = null;
- this.bumpMap = null;
- this.bumpScale = 1;
- this.normalMap = null;
- this.normalMapType = TangentSpaceNormalMap;
- this.normalScale = new Vector2(1, 1);
- this.displacementMap = null;
- this.displacementScale = 1;
- this.displacementBias = 0;
- this.specularMap = null;
- this.alphaMap = null;
- this.envMap = null;
- this.combine = MultiplyOperation;
- this.reflectivity = 1;
- this.refractionRatio = 0.98;
- this.wireframe = false;
- this.wireframeLinewidth = 1;
- this.wireframeLinecap = "round";
- this.wireframeLinejoin = "round";
- this.skinning = false;
- this.morphTargets = false;
- this.morphNormals = false;
- this.setValues(parameters);
- }
- MeshPhongMaterial.prototype = Object.create(Material.prototype);
- MeshPhongMaterial.prototype.constructor = MeshPhongMaterial;
- MeshPhongMaterial.prototype.isMeshPhongMaterial = true;
- MeshPhongMaterial.prototype.copy = function(source) {
- Material.prototype.copy.call(this, source);
- this.color.copy(source.color);
- this.specular.copy(source.specular);
- this.shininess = source.shininess;
- this.map = source.map;
- this.lightMap = source.lightMap;
- this.lightMapIntensity = source.lightMapIntensity;
- this.aoMap = source.aoMap;
- this.aoMapIntensity = source.aoMapIntensity;
- this.emissive.copy(source.emissive);
- this.emissiveMap = source.emissiveMap;
- this.emissiveIntensity = source.emissiveIntensity;
- this.bumpMap = source.bumpMap;
- this.bumpScale = source.bumpScale;
- this.normalMap = source.normalMap;
- this.normalMapType = source.normalMapType;
- this.normalScale.copy(source.normalScale);
- this.displacementMap = source.displacementMap;
- this.displacementScale = source.displacementScale;
- this.displacementBias = source.displacementBias;
- this.specularMap = source.specularMap;
- this.alphaMap = source.alphaMap;
- this.envMap = source.envMap;
- this.combine = source.combine;
- this.reflectivity = source.reflectivity;
- this.refractionRatio = source.refractionRatio;
- this.wireframe = source.wireframe;
- this.wireframeLinewidth = source.wireframeLinewidth;
- this.wireframeLinecap = source.wireframeLinecap;
- this.wireframeLinejoin = source.wireframeLinejoin;
- this.skinning = source.skinning;
- this.morphTargets = source.morphTargets;
- this.morphNormals = source.morphNormals;
- return this;
- };
- function MeshToonMaterial(parameters) {
- Material.call(this);
- this.defines = { "TOON": "" };
- this.type = "MeshToonMaterial";
- this.color = new Color(16777215);
- this.specular = new Color(1118481);
- this.shininess = 30;
- this.map = null;
- this.gradientMap = null;
- this.lightMap = null;
- this.lightMapIntensity = 1;
- this.aoMap = null;
- this.aoMapIntensity = 1;
- this.emissive = new Color(0);
- this.emissiveIntensity = 1;
- this.emissiveMap = null;
- this.bumpMap = null;
- this.bumpScale = 1;
- this.normalMap = null;
- this.normalMapType = TangentSpaceNormalMap;
- this.normalScale = new Vector2(1, 1);
- this.displacementMap = null;
- this.displacementScale = 1;
- this.displacementBias = 0;
- this.specularMap = null;
- this.alphaMap = null;
- this.wireframe = false;
- this.wireframeLinewidth = 1;
- this.wireframeLinecap = "round";
- this.wireframeLinejoin = "round";
- this.skinning = false;
- this.morphTargets = false;
- this.morphNormals = false;
- this.setValues(parameters);
- }
- MeshToonMaterial.prototype = Object.create(Material.prototype);
- MeshToonMaterial.prototype.constructor = MeshToonMaterial;
- MeshToonMaterial.prototype.isMeshToonMaterial = true;
- MeshToonMaterial.prototype.copy = function(source) {
- Material.prototype.copy.call(this, source);
- this.color.copy(source.color);
- this.specular.copy(source.specular);
- this.shininess = source.shininess;
- this.map = source.map;
- this.gradientMap = source.gradientMap;
- this.lightMap = source.lightMap;
- this.lightMapIntensity = source.lightMapIntensity;
- this.aoMap = source.aoMap;
- this.aoMapIntensity = source.aoMapIntensity;
- this.emissive.copy(source.emissive);
- this.emissiveMap = source.emissiveMap;
- this.emissiveIntensity = source.emissiveIntensity;
- this.bumpMap = source.bumpMap;
- this.bumpScale = source.bumpScale;
- this.normalMap = source.normalMap;
- this.normalMapType = source.normalMapType;
- this.normalScale.copy(source.normalScale);
- this.displacementMap = source.displacementMap;
- this.displacementScale = source.displacementScale;
- this.displacementBias = source.displacementBias;
- this.specularMap = source.specularMap;
- this.alphaMap = source.alphaMap;
- this.wireframe = source.wireframe;
- this.wireframeLinewidth = source.wireframeLinewidth;
- this.wireframeLinecap = source.wireframeLinecap;
- this.wireframeLinejoin = source.wireframeLinejoin;
- this.skinning = source.skinning;
- this.morphTargets = source.morphTargets;
- this.morphNormals = source.morphNormals;
- return this;
- };
- function MeshNormalMaterial(parameters) {
- Material.call(this);
- this.type = "MeshNormalMaterial";
- this.bumpMap = null;
- this.bumpScale = 1;
- this.normalMap = null;
- this.normalMapType = TangentSpaceNormalMap;
- this.normalScale = new Vector2(1, 1);
- this.displacementMap = null;
- this.displacementScale = 1;
- this.displacementBias = 0;
- this.wireframe = false;
- this.wireframeLinewidth = 1;
- this.fog = false;
- this.skinning = false;
- this.morphTargets = false;
- this.morphNormals = false;
- this.setValues(parameters);
- }
- MeshNormalMaterial.prototype = Object.create(Material.prototype);
- MeshNormalMaterial.prototype.constructor = MeshNormalMaterial;
- MeshNormalMaterial.prototype.isMeshNormalMaterial = true;
- MeshNormalMaterial.prototype.copy = function(source) {
- Material.prototype.copy.call(this, source);
- this.bumpMap = source.bumpMap;
- this.bumpScale = source.bumpScale;
- this.normalMap = source.normalMap;
- this.normalMapType = source.normalMapType;
- this.normalScale.copy(source.normalScale);
- this.displacementMap = source.displacementMap;
- this.displacementScale = source.displacementScale;
- this.displacementBias = source.displacementBias;
- this.wireframe = source.wireframe;
- this.wireframeLinewidth = source.wireframeLinewidth;
- this.skinning = source.skinning;
- this.morphTargets = source.morphTargets;
- this.morphNormals = source.morphNormals;
- return this;
- };
- function MeshLambertMaterial(parameters) {
- Material.call(this);
- this.type = "MeshLambertMaterial";
- this.color = new Color(16777215);
- this.map = null;
- this.lightMap = null;
- this.lightMapIntensity = 1;
- this.aoMap = null;
- this.aoMapIntensity = 1;
- this.emissive = new Color(0);
- this.emissiveIntensity = 1;
- this.emissiveMap = null;
- this.specularMap = null;
- this.alphaMap = null;
- this.envMap = null;
- this.combine = MultiplyOperation;
- this.reflectivity = 1;
- this.refractionRatio = 0.98;
- this.wireframe = false;
- this.wireframeLinewidth = 1;
- this.wireframeLinecap = "round";
- this.wireframeLinejoin = "round";
- this.skinning = false;
- this.morphTargets = false;
- this.morphNormals = false;
- this.setValues(parameters);
- }
- MeshLambertMaterial.prototype = Object.create(Material.prototype);
- MeshLambertMaterial.prototype.constructor = MeshLambertMaterial;
- MeshLambertMaterial.prototype.isMeshLambertMaterial = true;
- MeshLambertMaterial.prototype.copy = function(source) {
- Material.prototype.copy.call(this, source);
- this.color.copy(source.color);
- this.map = source.map;
- this.lightMap = source.lightMap;
- this.lightMapIntensity = source.lightMapIntensity;
- this.aoMap = source.aoMap;
- this.aoMapIntensity = source.aoMapIntensity;
- this.emissive.copy(source.emissive);
- this.emissiveMap = source.emissiveMap;
- this.emissiveIntensity = source.emissiveIntensity;
- this.specularMap = source.specularMap;
- this.alphaMap = source.alphaMap;
- this.envMap = source.envMap;
- this.combine = source.combine;
- this.reflectivity = source.reflectivity;
- this.refractionRatio = source.refractionRatio;
- this.wireframe = source.wireframe;
- this.wireframeLinewidth = source.wireframeLinewidth;
- this.wireframeLinecap = source.wireframeLinecap;
- this.wireframeLinejoin = source.wireframeLinejoin;
- this.skinning = source.skinning;
- this.morphTargets = source.morphTargets;
- this.morphNormals = source.morphNormals;
- return this;
- };
- function MeshMatcapMaterial(parameters) {
- Material.call(this);
- this.defines = { "MATCAP": "" };
- this.type = "MeshMatcapMaterial";
- this.color = new Color(16777215);
- this.matcap = null;
- this.map = null;
- this.bumpMap = null;
- this.bumpScale = 1;
- this.normalMap = null;
- this.normalMapType = TangentSpaceNormalMap;
- this.normalScale = new Vector2(1, 1);
- this.displacementMap = null;
- this.displacementScale = 1;
- this.displacementBias = 0;
- this.alphaMap = null;
- this.skinning = false;
- this.morphTargets = false;
- this.morphNormals = false;
- this.setValues(parameters);
- }
- MeshMatcapMaterial.prototype = Object.create(Material.prototype);
- MeshMatcapMaterial.prototype.constructor = MeshMatcapMaterial;
- MeshMatcapMaterial.prototype.isMeshMatcapMaterial = true;
- MeshMatcapMaterial.prototype.copy = function(source) {
- Material.prototype.copy.call(this, source);
- this.defines = { "MATCAP": "" };
- this.color.copy(source.color);
- this.matcap = source.matcap;
- this.map = source.map;
- this.bumpMap = source.bumpMap;
- this.bumpScale = source.bumpScale;
- this.normalMap = source.normalMap;
- this.normalMapType = source.normalMapType;
- this.normalScale.copy(source.normalScale);
- this.displacementMap = source.displacementMap;
- this.displacementScale = source.displacementScale;
- this.displacementBias = source.displacementBias;
- this.alphaMap = source.alphaMap;
- this.skinning = source.skinning;
- this.morphTargets = source.morphTargets;
- this.morphNormals = source.morphNormals;
- return this;
- };
- function LineDashedMaterial(parameters) {
- LineBasicMaterial.call(this);
- this.type = "LineDashedMaterial";
- this.scale = 1;
- this.dashSize = 3;
- this.gapSize = 1;
- this.setValues(parameters);
- }
- LineDashedMaterial.prototype = Object.create(LineBasicMaterial.prototype);
- LineDashedMaterial.prototype.constructor = LineDashedMaterial;
- LineDashedMaterial.prototype.isLineDashedMaterial = true;
- LineDashedMaterial.prototype.copy = function(source) {
- LineBasicMaterial.prototype.copy.call(this, source);
- this.scale = source.scale;
- this.dashSize = source.dashSize;
- this.gapSize = source.gapSize;
- return this;
- };
- var Materials = /* @__PURE__ */ Object.freeze({
- __proto__: null,
- ShadowMaterial,
- SpriteMaterial,
- RawShaderMaterial,
- ShaderMaterial,
- PointsMaterial,
- MeshPhysicalMaterial,
- MeshStandardMaterial,
- MeshPhongMaterial,
- MeshToonMaterial,
- MeshNormalMaterial,
- MeshLambertMaterial,
- MeshDepthMaterial,
- MeshDistanceMaterial,
- MeshBasicMaterial,
- MeshMatcapMaterial,
- LineDashedMaterial,
- LineBasicMaterial,
- Material
- });
- var AnimationUtils = {
- // same as Array.prototype.slice, but also works on typed arrays
- arraySlice: function(array, from, to) {
- if (AnimationUtils.isTypedArray(array)) {
- return new array.constructor(array.subarray(from, to !== void 0 ? to : array.length));
- }
- return array.slice(from, to);
- },
- // converts an array to a specific type
- convertArray: function(array, type, forceClone) {
- if (!array || // let 'undefined' and 'null' pass
- !forceClone && array.constructor === type)
- return array;
- if (typeof type.BYTES_PER_ELEMENT === "number") {
- return new type(array);
- }
- return Array.prototype.slice.call(array);
- },
- isTypedArray: function(object) {
- return ArrayBuffer.isView(object) && !(object instanceof DataView);
- },
- // returns an array by which times and values can be sorted
- getKeyframeOrder: function(times) {
- function compareTime(i3, j) {
- return times[i3] - times[j];
- }
- var n = times.length;
- var result = new Array(n);
- for (var i2 = 0; i2 !== n; ++i2)
- result[i2] = i2;
- result.sort(compareTime);
- return result;
- },
- // uses the array previously returned by 'getKeyframeOrder' to sort data
- sortedArray: function(values, stride, order) {
- var nValues = values.length;
- var result = new values.constructor(nValues);
- for (var i2 = 0, dstOffset = 0; dstOffset !== nValues; ++i2) {
- var srcOffset = order[i2] * stride;
- for (var j = 0; j !== stride; ++j) {
- result[dstOffset++] = values[srcOffset + j];
- }
- }
- return result;
- },
- // function for parsing AOS keyframe formats
- flattenJSON: function(jsonKeys, times, values, valuePropertyName) {
- var i2 = 1, key = jsonKeys[0];
- while (key !== void 0 && key[valuePropertyName] === void 0) {
- key = jsonKeys[i2++];
- }
- if (key === void 0)
- return;
- var value = key[valuePropertyName];
- if (value === void 0)
- return;
- if (Array.isArray(value)) {
- do {
- value = key[valuePropertyName];
- if (value !== void 0) {
- times.push(key.time);
- values.push.apply(values, value);
- }
- key = jsonKeys[i2++];
- } while (key !== void 0);
- } else if (value.toArray !== void 0) {
- do {
- value = key[valuePropertyName];
- if (value !== void 0) {
- times.push(key.time);
- value.toArray(values, values.length);
- }
- key = jsonKeys[i2++];
- } while (key !== void 0);
- } else {
- do {
- value = key[valuePropertyName];
- if (value !== void 0) {
- times.push(key.time);
- values.push(value);
- }
- key = jsonKeys[i2++];
- } while (key !== void 0);
- }
- },
- subclip: function(sourceClip, name, startFrame, endFrame, fps) {
- fps = fps || 30;
- var clip = sourceClip.clone();
- clip.name = name;
- var tracks = [];
- for (var i2 = 0; i2 < clip.tracks.length; ++i2) {
- var track = clip.tracks[i2];
- var valueSize = track.getValueSize();
- var times = [];
- var values = [];
- for (var j = 0; j < track.times.length; ++j) {
- var frame = track.times[j] * fps;
- if (frame < startFrame || frame >= endFrame)
- continue;
- times.push(track.times[j]);
- for (var k = 0; k < valueSize; ++k) {
- values.push(track.values[j * valueSize + k]);
- }
- }
- if (times.length === 0)
- continue;
- track.times = AnimationUtils.convertArray(times, track.times.constructor);
- track.values = AnimationUtils.convertArray(values, track.values.constructor);
- tracks.push(track);
- }
- clip.tracks = tracks;
- var minStartTime = Infinity;
- for (var i2 = 0; i2 < clip.tracks.length; ++i2) {
- if (minStartTime > clip.tracks[i2].times[0]) {
- minStartTime = clip.tracks[i2].times[0];
- }
- }
- for (var i2 = 0; i2 < clip.tracks.length; ++i2) {
- clip.tracks[i2].shift(-1 * minStartTime);
- }
- clip.resetDuration();
- return clip;
- }
- };
- function Interpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {
- this.parameterPositions = parameterPositions;
- this._cachedIndex = 0;
- this.resultBuffer = resultBuffer !== void 0 ? resultBuffer : new sampleValues.constructor(sampleSize);
- this.sampleValues = sampleValues;
- this.valueSize = sampleSize;
- }
- Object.assign(Interpolant.prototype, {
- evaluate: function(t) {
- var pp = this.parameterPositions, i1 = this._cachedIndex, t1 = pp[i1], t0 = pp[i1 - 1];
- validate_interval: {
- seek: {
- var right;
- linear_scan: {
- forward_scan:
- if (!(t < t1)) {
- for (var giveUpAt = i1 + 2; ; ) {
- if (t1 === void 0) {
- if (t < t0)
- break forward_scan;
- i1 = pp.length;
- this._cachedIndex = i1;
- return this.afterEnd_(i1 - 1, t, t0);
- }
- if (i1 === giveUpAt)
- break;
- t0 = t1;
- t1 = pp[++i1];
- if (t < t1) {
- break seek;
- }
- }
- right = pp.length;
- break linear_scan;
- }
- if (!(t >= t0)) {
- var t1global = pp[1];
- if (t < t1global) {
- i1 = 2;
- t0 = t1global;
- }
- for (var giveUpAt = i1 - 2; ; ) {
- if (t0 === void 0) {
- this._cachedIndex = 0;
- return this.beforeStart_(0, t, t1);
- }
- if (i1 === giveUpAt)
- break;
- t1 = t0;
- t0 = pp[--i1 - 1];
- if (t >= t0) {
- break seek;
- }
- }
- right = i1;
- i1 = 0;
- break linear_scan;
- }
- break validate_interval;
- }
- while (i1 < right) {
- var mid = i1 + right >>> 1;
- if (t < pp[mid]) {
- right = mid;
- } else {
- i1 = mid + 1;
- }
- }
- t1 = pp[i1];
- t0 = pp[i1 - 1];
- if (t0 === void 0) {
- this._cachedIndex = 0;
- return this.beforeStart_(0, t, t1);
- }
- if (t1 === void 0) {
- i1 = pp.length;
- this._cachedIndex = i1;
- return this.afterEnd_(i1 - 1, t0, t);
- }
- }
- this._cachedIndex = i1;
- this.intervalChanged_(i1, t0, t1);
- }
- return this.interpolate_(i1, t0, t, t1);
- },
- settings: null,
- // optional, subclass-specific settings structure
- // Note: The indirection allows central control of many interpolants.
- // --- Protected interface
- DefaultSettings_: {},
- getSettings_: function() {
- return this.settings || this.DefaultSettings_;
- },
- copySampleValue_: function(index) {
- var result = this.resultBuffer, values = this.sampleValues, stride = this.valueSize, offset = index * stride;
- for (var i2 = 0; i2 !== stride; ++i2) {
- result[i2] = values[offset + i2];
- }
- return result;
- },
- // Template methods for derived classes:
- interpolate_: function() {
- throw new Error("call to abstract method");
- },
- intervalChanged_: function() {
- }
- });
- //!\ DECLARE ALIAS AFTER assign prototype !
- Object.assign(Interpolant.prototype, {
- //( 0, t, t0 ), returns this.resultBuffer
- beforeStart_: Interpolant.prototype.copySampleValue_,
- //( N-1, tN-1, t ), returns this.resultBuffer
- afterEnd_: Interpolant.prototype.copySampleValue_
- });
- function CubicInterpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {
- Interpolant.call(this, parameterPositions, sampleValues, sampleSize, resultBuffer);
- this._weightPrev = -0;
- this._offsetPrev = -0;
- this._weightNext = -0;
- this._offsetNext = -0;
- }
- CubicInterpolant.prototype = Object.assign(Object.create(Interpolant.prototype), {
- constructor: CubicInterpolant,
- DefaultSettings_: {
- endingStart: ZeroCurvatureEnding,
- endingEnd: ZeroCurvatureEnding
- },
- intervalChanged_: function(i1, t0, t1) {
- var pp = this.parameterPositions, iPrev = i1 - 2, iNext = i1 + 1, tPrev = pp[iPrev], tNext = pp[iNext];
- if (tPrev === void 0) {
- switch (this.getSettings_().endingStart) {
- case ZeroSlopeEnding:
- iPrev = i1;
- tPrev = 2 * t0 - t1;
- break;
- case WrapAroundEnding:
- iPrev = pp.length - 2;
- tPrev = t0 + pp[iPrev] - pp[iPrev + 1];
- break;
- default:
- iPrev = i1;
- tPrev = t1;
- }
- }
- if (tNext === void 0) {
- switch (this.getSettings_().endingEnd) {
- case ZeroSlopeEnding:
- iNext = i1;
- tNext = 2 * t1 - t0;
- break;
- case WrapAroundEnding:
- iNext = 1;
- tNext = t1 + pp[1] - pp[0];
- break;
- default:
- iNext = i1 - 1;
- tNext = t0;
- }
- }
- var halfDt = (t1 - t0) * 0.5, stride = this.valueSize;
- this._weightPrev = halfDt / (t0 - tPrev);
- this._weightNext = halfDt / (tNext - t1);
- this._offsetPrev = iPrev * stride;
- this._offsetNext = iNext * stride;
- },
- interpolate_: function(i1, t0, t, t1) {
- 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;
- var sP = -wP * ppp + 2 * wP * pp - wP * p;
- var s0 = (1 + wP) * ppp + (-1.5 - 2 * wP) * pp + (-0.5 + wP) * p + 1;
- var s1 = (-1 - wN) * ppp + (1.5 + wN) * pp + 0.5 * p;
- var sN = wN * ppp - wN * pp;
- for (var i2 = 0; i2 !== stride; ++i2) {
- result[i2] = sP * values[oP + i2] + s0 * values[o0 + i2] + s1 * values[o1 + i2] + sN * values[oN + i2];
- }
- return result;
- }
- });
- function LinearInterpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {
- Interpolant.call(this, parameterPositions, sampleValues, sampleSize, resultBuffer);
- }
- LinearInterpolant.prototype = Object.assign(Object.create(Interpolant.prototype), {
- constructor: LinearInterpolant,
- interpolate_: function(i1, t0, t, t1) {
- var result = this.resultBuffer, values = this.sampleValues, stride = this.valueSize, offset1 = i1 * stride, offset0 = offset1 - stride, weight1 = (t - t0) / (t1 - t0), weight0 = 1 - weight1;
- for (var i2 = 0; i2 !== stride; ++i2) {
- result[i2] = values[offset0 + i2] * weight0 + values[offset1 + i2] * weight1;
- }
- return result;
- }
- });
- function DiscreteInterpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {
- Interpolant.call(this, parameterPositions, sampleValues, sampleSize, resultBuffer);
- }
- DiscreteInterpolant.prototype = Object.assign(Object.create(Interpolant.prototype), {
- constructor: DiscreteInterpolant,
- interpolate_: function(i1) {
- return this.copySampleValue_(i1 - 1);
- }
- });
- function KeyframeTrack(name, times, values, interpolation) {
- if (name === void 0)
- throw new Error("THREE.KeyframeTrack: track name is undefined");
- if (times === void 0 || times.length === 0)
- throw new Error("THREE.KeyframeTrack: no keyframes in track named " + name);
- this.name = name;
- this.times = AnimationUtils.convertArray(times, this.TimeBufferType);
- this.values = AnimationUtils.convertArray(values, this.ValueBufferType);
- this.setInterpolation(interpolation || this.DefaultInterpolation);
- }
- Object.assign(KeyframeTrack, {
- // Serialization (in static context, because of constructor invocation
- // and automatic invocation of .toJSON):
- toJSON: function(track) {
- var trackType = track.constructor;
- var json;
- if (trackType.toJSON !== void 0) {
- json = trackType.toJSON(track);
- } else {
- json = {
- "name": track.name,
- "times": AnimationUtils.convertArray(track.times, Array),
- "values": AnimationUtils.convertArray(track.values, Array)
- };
- var interpolation = track.getInterpolation();
- if (interpolation !== track.DefaultInterpolation) {
- json.interpolation = interpolation;
- }
- }
- json.type = track.ValueTypeName;
- return json;
- }
- });
- Object.assign(KeyframeTrack.prototype, {
- constructor: KeyframeTrack,
- TimeBufferType: Float32Array,
- ValueBufferType: Float32Array,
- DefaultInterpolation: InterpolateLinear,
- InterpolantFactoryMethodDiscrete: function(result) {
- return new DiscreteInterpolant(this.times, this.values, this.getValueSize(), result);
- },
- InterpolantFactoryMethodLinear: function(result) {
- return new LinearInterpolant(this.times, this.values, this.getValueSize(), result);
- },
- InterpolantFactoryMethodSmooth: function(result) {
- return new CubicInterpolant(this.times, this.values, this.getValueSize(), result);
- },
- setInterpolation: function(interpolation) {
- var factoryMethod;
- switch (interpolation) {
- case InterpolateDiscrete:
- factoryMethod = this.InterpolantFactoryMethodDiscrete;
- break;
- case InterpolateLinear:
- factoryMethod = this.InterpolantFactoryMethodLinear;
- break;
- case InterpolateSmooth:
- factoryMethod = this.InterpolantFactoryMethodSmooth;
- break;
- }
- if (factoryMethod === void 0) {
- var message = "unsupported interpolation for " + this.ValueTypeName + " keyframe track named " + this.name;
- if (this.createInterpolant === void 0) {
- if (interpolation !== this.DefaultInterpolation) {
- this.setInterpolation(this.DefaultInterpolation);
- } else {
- throw new Error(message);
- }
- }
- console.warn("THREE.KeyframeTrack:", message);
- return this;
- }
- this.createInterpolant = factoryMethod;
- return this;
- },
- getInterpolation: function() {
- switch (this.createInterpolant) {
- case this.InterpolantFactoryMethodDiscrete:
- return InterpolateDiscrete;
- case this.InterpolantFactoryMethodLinear:
- return InterpolateLinear;
- case this.InterpolantFactoryMethodSmooth:
- return InterpolateSmooth;
- }
- },
- getValueSize: function() {
- return this.values.length / this.times.length;
- },
- // move all keyframes either forwards or backwards in time
- shift: function(timeOffset) {
- if (timeOffset !== 0) {
- var times = this.times;
- for (var i2 = 0, n = times.length; i2 !== n; ++i2) {
- times[i2] += timeOffset;
- }
- }
- return this;
- },
- // scale all keyframe times by a factor (useful for frame <-> seconds conversions)
- scale: function(timeScale) {
- if (timeScale !== 1) {
- var times = this.times;
- for (var i2 = 0, n = times.length; i2 !== n; ++i2) {
- times[i2] *= timeScale;
- }
- }
- return this;
- },
- // removes keyframes before and after animation without changing any values within the range [startTime, endTime].
- // IMPORTANT: We do not shift around keys to the start of the track time, because for interpolated keys this will change their values
- trim: function(startTime, endTime) {
- var times = this.times, nKeys = times.length, from = 0, to = nKeys - 1;
- while (from !== nKeys && times[from] < startTime) {
- ++from;
- }
- while (to !== -1 && times[to] > endTime) {
- --to;
- }
- ++to;
- if (from !== 0 || to !== nKeys) {
- if (from >= to)
- to = Math.max(to, 1), from = to - 1;
- var stride = this.getValueSize();
- this.times = AnimationUtils.arraySlice(times, from, to);
- this.values = AnimationUtils.arraySlice(this.values, from * stride, to * stride);
- }
- return this;
- },
- // ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable
- validate: function() {
- var valid = true;
- var valueSize = this.getValueSize();
- if (valueSize - Math.floor(valueSize) !== 0) {
- console.error("THREE.KeyframeTrack: Invalid value size in track.", this);
- valid = false;
- }
- var times = this.times, values = this.values, nKeys = times.length;
- if (nKeys === 0) {
- console.error("THREE.KeyframeTrack: Track is empty.", this);
- valid = false;
- }
- var prevTime = null;
- for (var i2 = 0; i2 !== nKeys; i2++) {
- var currTime = times[i2];
- if (typeof currTime === "number" && isNaN(currTime)) {
- console.error("THREE.KeyframeTrack: Time is not a valid number.", this, i2, currTime);
- valid = false;
- break;
- }
- if (prevTime !== null && prevTime > currTime) {
- console.error("THREE.KeyframeTrack: Out of order keys.", this, i2, currTime, prevTime);
- valid = false;
- break;
- }
- prevTime = currTime;
- }
- if (values !== void 0) {
- if (AnimationUtils.isTypedArray(values)) {
- for (var i2 = 0, n = values.length; i2 !== n; ++i2) {
- var value = values[i2];
- if (isNaN(value)) {
- console.error("THREE.KeyframeTrack: Value is not a valid number.", this, i2, value);
- valid = false;
- break;
- }
- }
- }
- }
- return valid;
- },
- // removes equivalent sequential keys as common in morph target sequences
- // (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --> (0,0,1,1,0,0)
- optimize: function() {
- var times = AnimationUtils.arraySlice(this.times), values = AnimationUtils.arraySlice(this.values), stride = this.getValueSize(), smoothInterpolation = this.getInterpolation() === InterpolateSmooth, writeIndex = 1, lastIndex = times.length - 1;
- for (var i2 = 1; i2 < lastIndex; ++i2) {
- var keep = false;
- var time = times[i2];
- var timeNext = times[i2 + 1];
- if (time !== timeNext && (i2 !== 1 || time !== time[0])) {
- if (!smoothInterpolation) {
- var offset = i2 * stride, offsetP = offset - stride, offsetN = offset + stride;
- for (var j = 0; j !== stride; ++j) {
- var value = values[offset + j];
- if (value !== values[offsetP + j] || value !== values[offsetN + j]) {
- keep = true;
- break;
- }
- }
- } else {
- keep = true;
- }
- }
- if (keep) {
- if (i2 !== writeIndex) {
- times[writeIndex] = times[i2];
- var readOffset = i2 * stride, writeOffset = writeIndex * stride;
- for (var j = 0; j !== stride; ++j) {
- values[writeOffset + j] = values[readOffset + j];
- }
- }
- ++writeIndex;
- }
- }
- if (lastIndex > 0) {
- times[writeIndex] = times[lastIndex];
- for (var readOffset = lastIndex * stride, writeOffset = writeIndex * stride, j = 0; j !== stride; ++j) {
- values[writeOffset + j] = values[readOffset + j];
- }
- ++writeIndex;
- }
- if (writeIndex !== times.length) {
- this.times = AnimationUtils.arraySlice(times, 0, writeIndex);
- this.values = AnimationUtils.arraySlice(values, 0, writeIndex * stride);
- } else {
- this.times = times;
- this.values = values;
- }
- return this;
- },
- clone: function() {
- var times = AnimationUtils.arraySlice(this.times, 0);
- var values = AnimationUtils.arraySlice(this.values, 0);
- var TypedKeyframeTrack = this.constructor;
- var track = new TypedKeyframeTrack(this.name, times, values);
- track.createInterpolant = this.createInterpolant;
- return track;
- }
- });
- function BooleanKeyframeTrack(name, times, values) {
- KeyframeTrack.call(this, name, times, values);
- }
- BooleanKeyframeTrack.prototype = Object.assign(Object.create(KeyframeTrack.prototype), {
- constructor: BooleanKeyframeTrack,
- ValueTypeName: "bool",
- ValueBufferType: Array,
- DefaultInterpolation: InterpolateDiscrete,
- InterpolantFactoryMethodLinear: void 0,
- InterpolantFactoryMethodSmooth: void 0
- // Note: Actually this track could have a optimized / compressed
- // representation of a single value and a custom interpolant that
- // computes "firstValue ^ isOdd( index )".
- });
- function ColorKeyframeTrack(name, times, values, interpolation) {
- KeyframeTrack.call(this, name, times, values, interpolation);
- }
- ColorKeyframeTrack.prototype = Object.assign(Object.create(KeyframeTrack.prototype), {
- constructor: ColorKeyframeTrack,
- ValueTypeName: "color"
- // ValueBufferType is inherited
- // DefaultInterpolation is inherited
- // Note: Very basic implementation and nothing special yet.
- // However, this is the place for color space parameterization.
- });
- function NumberKeyframeTrack(name, times, values, interpolation) {
- KeyframeTrack.call(this, name, times, values, interpolation);
- }
- NumberKeyframeTrack.prototype = Object.assign(Object.create(KeyframeTrack.prototype), {
- constructor: NumberKeyframeTrack,
- ValueTypeName: "number"
- // ValueBufferType is inherited
- // DefaultInterpolation is inherited
- });
- function QuaternionLinearInterpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {
- Interpolant.call(this, parameterPositions, sampleValues, sampleSize, resultBuffer);
- }
- QuaternionLinearInterpolant.prototype = Object.assign(Object.create(Interpolant.prototype), {
- constructor: QuaternionLinearInterpolant,
- interpolate_: function(i1, t0, t, t1) {
- var result = this.resultBuffer, values = this.sampleValues, stride = this.valueSize, offset = i1 * stride, alpha = (t - t0) / (t1 - t0);
- for (var end = offset + stride; offset !== end; offset += 4) {
- Quaternion.slerpFlat(result, 0, values, offset - stride, values, offset, alpha);
- }
- return result;
- }
- });
- function QuaternionKeyframeTrack(name, times, values, interpolation) {
- KeyframeTrack.call(this, name, times, values, interpolation);
- }
- QuaternionKeyframeTrack.prototype = Object.assign(Object.create(KeyframeTrack.prototype), {
- constructor: QuaternionKeyframeTrack,
- ValueTypeName: "quaternion",
- // ValueBufferType is inherited
- DefaultInterpolation: InterpolateLinear,
- InterpolantFactoryMethodLinear: function(result) {
- return new QuaternionLinearInterpolant(this.times, this.values, this.getValueSize(), result);
- },
- InterpolantFactoryMethodSmooth: void 0
- // not yet implemented
- });
- function StringKeyframeTrack(name, times, values, interpolation) {
- KeyframeTrack.call(this, name, times, values, interpolation);
- }
- StringKeyframeTrack.prototype = Object.assign(Object.create(KeyframeTrack.prototype), {
- constructor: StringKeyframeTrack,
- ValueTypeName: "string",
- ValueBufferType: Array,
- DefaultInterpolation: InterpolateDiscrete,
- InterpolantFactoryMethodLinear: void 0,
- InterpolantFactoryMethodSmooth: void 0
- });
- function VectorKeyframeTrack(name, times, values, interpolation) {
- KeyframeTrack.call(this, name, times, values, interpolation);
- }
- VectorKeyframeTrack.prototype = Object.assign(Object.create(KeyframeTrack.prototype), {
- constructor: VectorKeyframeTrack,
- ValueTypeName: "vector"
- // ValueBufferType is inherited
- // DefaultInterpolation is inherited
- });
- function AnimationClip(name, duration, tracks) {
- this.name = name;
- this.tracks = tracks;
- this.duration = duration !== void 0 ? duration : -1;
- this.uuid = MathUtils.generateUUID();
- if (this.duration < 0) {
- this.resetDuration();
- }
- }
- function getTrackTypeForValueTypeName(typeName) {
- switch (typeName.toLowerCase()) {
- case "scalar":
- case "double":
- case "float":
- case "number":
- case "integer":
- return NumberKeyframeTrack;
- case "vector":
- case "vector2":
- case "vector3":
- case "vector4":
- return VectorKeyframeTrack;
- case "color":
- return ColorKeyframeTrack;
- case "quaternion":
- return QuaternionKeyframeTrack;
- case "bool":
- case "boolean":
- return BooleanKeyframeTrack;
- case "string":
- return StringKeyframeTrack;
- }
- throw new Error("THREE.KeyframeTrack: Unsupported typeName: " + typeName);
- }
- function parseKeyframeTrack(json) {
- if (json.type === void 0) {
- throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");
- }
- var trackType = getTrackTypeForValueTypeName(json.type);
- if (json.times === void 0) {
- var times = [], values = [];
- AnimationUtils.flattenJSON(json.keys, times, values, "value");
- json.times = times;
- json.values = values;
- }
- if (trackType.parse !== void 0) {
- return trackType.parse(json);
- } else {
- return new trackType(json.name, json.times, json.values, json.interpolation);
- }
- }
- Object.assign(AnimationClip, {
- parse: function(json) {
- var tracks = [], jsonTracks = json.tracks, frameTime = 1 / (json.fps || 1);
- for (var i2 = 0, n = jsonTracks.length; i2 !== n; ++i2) {
- tracks.push(parseKeyframeTrack(jsonTracks[i2]).scale(frameTime));
- }
- return new AnimationClip(json.name, json.duration, tracks);
- },
- toJSON: function(clip) {
- var tracks = [], clipTracks = clip.tracks;
- var json = {
- "name": clip.name,
- "duration": clip.duration,
- "tracks": tracks,
- "uuid": clip.uuid
- };
- for (var i2 = 0, n = clipTracks.length; i2 !== n; ++i2) {
- tracks.push(KeyframeTrack.toJSON(clipTracks[i2]));
- }
- return json;
- },
- CreateFromMorphTargetSequence: function(name, morphTargetSequence, fps, noLoop) {
- var numMorphTargets = morphTargetSequence.length;
- var tracks = [];
- for (var i2 = 0; i2 < numMorphTargets; i2++) {
- var times = [];
- var values = [];
- times.push(
- (i2 + numMorphTargets - 1) % numMorphTargets,
- i2,
- (i2 + 1) % numMorphTargets
- );
- values.push(0, 1, 0);
- var order = AnimationUtils.getKeyframeOrder(times);
- times = AnimationUtils.sortedArray(times, 1, order);
- values = AnimationUtils.sortedArray(values, 1, order);
- if (!noLoop && times[0] === 0) {
- times.push(numMorphTargets);
- values.push(values[0]);
- }
- tracks.push(
- new NumberKeyframeTrack(
- ".morphTargetInfluences[" + morphTargetSequence[i2].name + "]",
- times,
- values
- ).scale(1 / fps)
- );
- }
- return new AnimationClip(name, -1, tracks);
- },
- findByName: function(objectOrClipArray, name) {
- var clipArray = objectOrClipArray;
- if (!Array.isArray(objectOrClipArray)) {
- var o = objectOrClipArray;
- clipArray = o.geometry && o.geometry.animations || o.animations;
- }
- for (var i2 = 0; i2 < clipArray.length; i2++) {
- if (clipArray[i2].name === name) {
- return clipArray[i2];
- }
- }
- return null;
- },
- CreateClipsFromMorphTargetSequences: function(morphTargets, fps, noLoop) {
- var animationToMorphTargets = {};
- var pattern = /^([\w-]*?)([\d]+)$/;
- for (var i2 = 0, il = morphTargets.length; i2 < il; i2++) {
- var morphTarget = morphTargets[i2];
- var parts = morphTarget.name.match(pattern);
- if (parts && parts.length > 1) {
- var name = parts[1];
- var animationMorphTargets = animationToMorphTargets[name];
- if (!animationMorphTargets) {
- animationToMorphTargets[name] = animationMorphTargets = [];
- }
- animationMorphTargets.push(morphTarget);
- }
- }
- var clips = [];
- for (var name in animationToMorphTargets) {
- clips.push(AnimationClip.CreateFromMorphTargetSequence(name, animationToMorphTargets[name], fps, noLoop));
- }
- return clips;
- },
- // parse the animation.hierarchy format
- parseAnimation: function(animation, bones) {
- if (!animation) {
- console.error("THREE.AnimationClip: No animation in JSONLoader data.");
- return null;
- }
- var addNonemptyTrack = function(trackType, trackName, animationKeys2, propertyName, destTracks) {
- if (animationKeys2.length !== 0) {
- var times2 = [];
- var values2 = [];
- AnimationUtils.flattenJSON(animationKeys2, times2, values2, propertyName);
- if (times2.length !== 0) {
- destTracks.push(new trackType(trackName, times2, values2));
- }
- }
- };
- var tracks = [];
- var clipName = animation.name || "default";
- var duration = animation.length || -1;
- var fps = animation.fps || 30;
- var hierarchyTracks = animation.hierarchy || [];
- for (var h = 0; h < hierarchyTracks.length; h++) {
- var animationKeys = hierarchyTracks[h].keys;
- if (!animationKeys || animationKeys.length === 0)
- continue;
- if (animationKeys[0].morphTargets) {
- var morphTargetNames = {};
- for (var k = 0; k < animationKeys.length; k++) {
- if (animationKeys[k].morphTargets) {
- for (var m = 0; m < animationKeys[k].morphTargets.length; m++) {
- morphTargetNames[animationKeys[k].morphTargets[m]] = -1;
- }
- }
- }
- for (var morphTargetName in morphTargetNames) {
- var times = [];
- var values = [];
- for (var m = 0; m !== animationKeys[k].morphTargets.length; ++m) {
- var animationKey = animationKeys[k];
- times.push(animationKey.time);
- values.push(animationKey.morphTarget === morphTargetName ? 1 : 0);
- }
- tracks.push(new NumberKeyframeTrack(".morphTargetInfluence[" + morphTargetName + "]", times, values));
- }
- duration = morphTargetNames.length * (fps || 1);
- } else {
- var boneName = ".bones[" + bones[h].name + "]";
- addNonemptyTrack(
- VectorKeyframeTrack,
- boneName + ".position",
- animationKeys,
- "pos",
- tracks
- );
- addNonemptyTrack(
- QuaternionKeyframeTrack,
- boneName + ".quaternion",
- animationKeys,
- "rot",
- tracks
- );
- addNonemptyTrack(
- VectorKeyframeTrack,
- boneName + ".scale",
- animationKeys,
- "scl",
- tracks
- );
- }
- }
- if (tracks.length === 0) {
- return null;
- }
- var clip = new AnimationClip(clipName, duration, tracks);
- return clip;
- }
- });
- Object.assign(AnimationClip.prototype, {
- resetDuration: function() {
- var tracks = this.tracks, duration = 0;
- for (var i2 = 0, n = tracks.length; i2 !== n; ++i2) {
- var track = this.tracks[i2];
- duration = Math.max(duration, track.times[track.times.length - 1]);
- }
- this.duration = duration;
- return this;
- },
- trim: function() {
- for (var i2 = 0; i2 < this.tracks.length; i2++) {
- this.tracks[i2].trim(0, this.duration);
- }
- return this;
- },
- validate: function() {
- var valid = true;
- for (var i2 = 0; i2 < this.tracks.length; i2++) {
- valid = valid && this.tracks[i2].validate();
- }
- return valid;
- },
- optimize: function() {
- for (var i2 = 0; i2 < this.tracks.length; i2++) {
- this.tracks[i2].optimize();
- }
- return this;
- },
- clone: function() {
- var tracks = [];
- for (var i2 = 0; i2 < this.tracks.length; i2++) {
- tracks.push(this.tracks[i2].clone());
- }
- return new AnimationClip(this.name, this.duration, tracks);
- }
- });
- var Cache = {
- enabled: false,
- files: {},
- add: function(key, file) {
- if (this.enabled === false)
- return;
- this.files[key] = file;
- },
- get: function(key) {
- if (this.enabled === false)
- return;
- return this.files[key];
- },
- remove: function(key) {
- delete this.files[key];
- },
- clear: function() {
- this.files = {};
- }
- };
- function LoadingManager(onLoad, onProgress, onError) {
- var scope = this;
- var isLoading = false;
- var itemsLoaded = 0;
- var itemsTotal = 0;
- var urlModifier = void 0;
- var handlers = [];
- this.onStart = void 0;
- this.onLoad = onLoad;
- this.onProgress = onProgress;
- this.onError = onError;
- this.itemStart = function(url) {
- itemsTotal++;
- if (isLoading === false) {
- if (scope.onStart !== void 0) {
- scope.onStart(url, itemsLoaded, itemsTotal);
- }
- }
- isLoading = true;
- };
- this.itemEnd = function(url) {
- itemsLoaded++;
- if (scope.onProgress !== void 0) {
- scope.onProgress(url, itemsLoaded, itemsTotal);
- }
- if (itemsLoaded === itemsTotal) {
- isLoading = false;
- if (scope.onLoad !== void 0) {
- scope.onLoad();
- }
- }
- };
- this.itemError = function(url) {
- if (scope.onError !== void 0) {
- scope.onError(url);
- }
- };
- this.resolveURL = function(url) {
- if (urlModifier) {
- return urlModifier(url);
- }
- return url;
- };
- this.setURLModifier = function(transform) {
- urlModifier = transform;
- return this;
- };
- this.addHandler = function(regex, loader) {
- handlers.push(regex, loader);
- return this;
- };
- this.removeHandler = function(regex) {
- var index = handlers.indexOf(regex);
- if (index !== -1) {
- handlers.splice(index, 2);
- }
- return this;
- };
- this.getHandler = function(file) {
- for (var i2 = 0, l = handlers.length; i2 < l; i2 += 2) {
- var regex = handlers[i2];
- var loader = handlers[i2 + 1];
- if (regex.global)
- regex.lastIndex = 0;
- if (regex.test(file)) {
- return loader;
- }
- }
- return null;
- };
- }
- var DefaultLoadingManager = new LoadingManager();
- function Loader(manager) {
- this.manager = manager !== void 0 ? manager : DefaultLoadingManager;
- this.crossOrigin = "anonymous";
- this.path = "";
- this.resourcePath = "";
- }
- Object.assign(Loader.prototype, {
- load: function() {
- },
- parse: function() {
- },
- setCrossOrigin: function(crossOrigin) {
- this.crossOrigin = crossOrigin;
- return this;
- },
- setPath: function(path) {
- this.path = path;
- return this;
- },
- setResourcePath: function(resourcePath) {
- this.resourcePath = resourcePath;
- return this;
- }
- });
- var loading = {};
- function FileLoader(manager) {
- Loader.call(this, manager);
- }
- FileLoader.prototype = Object.assign(Object.create(Loader.prototype), {
- constructor: FileLoader,
- load: function(url, onLoad, onProgress, onError) {
- if (url === void 0)
- url = "";
- if (this.path !== void 0)
- url = this.path + url;
- url = this.manager.resolveURL(url);
- var scope = this;
- var cached = Cache.get(url);
- if (cached !== void 0) {
- scope.manager.itemStart(url);
- setTimeout(function() {
- if (onLoad)
- onLoad(cached);
- scope.manager.itemEnd(url);
- }, 0);
- return cached;
- }
- if (loading[url] !== void 0) {
- loading[url].push({
- onLoad,
- onProgress,
- onError
- });
- return;
- }
- var dataUriRegex = /^data:(.*?)(;base64)?,(.*)$/;
- var dataUriRegexResult = url.match(dataUriRegex);
- if (dataUriRegexResult) {
- var mimeType = dataUriRegexResult[1];
- var isBase64 = !!dataUriRegexResult[2];
- var data = dataUriRegexResult[3];
- data = decodeURIComponent(data);
- if (isBase64)
- data = atob(data);
- try {
- var response;
- var responseType = (this.responseType || "").toLowerCase();
- switch (responseType) {
- case "arraybuffer":
- case "blob":
- var view = new Uint8Array(data.length);
- for (var i2 = 0; i2 < data.length; i2++) {
- view[i2] = data.charCodeAt(i2);
- }
- if (responseType === "blob") {
- response = new Blob([view.buffer], { type: mimeType });
- } else {
- response = view.buffer;
- }
- break;
- case "document":
- var parser = new DOMParser();
- response = parser.parseFromString(data, mimeType);
- break;
- case "json":
- response = JSON.parse(data);
- break;
- default:
- response = data;
- break;
- }
- setTimeout(function() {
- if (onLoad)
- onLoad(response);
- scope.manager.itemEnd(url);
- }, 0);
- } catch (error) {
- setTimeout(function() {
- if (onError)
- onError(error);
- scope.manager.itemError(url);
- scope.manager.itemEnd(url);
- }, 0);
- }
- } else {
- loading[url] = [];
- loading[url].push({
- onLoad,
- onProgress,
- onError
- });
- var request = new XMLHttpRequest();
- request.open("GET", url, true);
- request.addEventListener("load", function(event) {
- var response2 = this.response;
- var callbacks = loading[url];
- delete loading[url];
- if (this.status === 200 || this.status === 0) {
- if (this.status === 0)
- console.warn("THREE.FileLoader: HTTP Status 0 received.");
- Cache.add(url, response2);
- for (var i3 = 0, il = callbacks.length; i3 < il; i3++) {
- var callback = callbacks[i3];
- if (callback.onLoad)
- callback.onLoad(response2);
- }
- scope.manager.itemEnd(url);
- } else {
- for (var i3 = 0, il = callbacks.length; i3 < il; i3++) {
- var callback = callbacks[i3];
- if (callback.onError)
- callback.onError(event);
- }
- scope.manager.itemError(url);
- scope.manager.itemEnd(url);
- }
- }, false);
- request.addEventListener("progress", function(event) {
- var callbacks = loading[url];
- for (var i3 = 0, il = callbacks.length; i3 < il; i3++) {
- var callback = callbacks[i3];
- if (callback.onProgress)
- callback.onProgress(event);
- }
- }, false);
- request.addEventListener("error", function(event) {
- var callbacks = loading[url];
- delete loading[url];
- for (var i3 = 0, il = callbacks.length; i3 < il; i3++) {
- var callback = callbacks[i3];
- if (callback.onError)
- callback.onError(event);
- }
- scope.manager.itemError(url);
- scope.manager.itemEnd(url);
- }, false);
- request.addEventListener("abort", function(event) {
- var callbacks = loading[url];
- delete loading[url];
- for (var i3 = 0, il = callbacks.length; i3 < il; i3++) {
- var callback = callbacks[i3];
- if (callback.onError)
- callback.onError(event);
- }
- scope.manager.itemError(url);
- scope.manager.itemEnd(url);
- }, false);
- if (this.responseType !== void 0)
- request.responseType = this.responseType;
- if (this.withCredentials !== void 0)
- request.withCredentials = this.withCredentials;
- if (request.overrideMimeType)
- request.overrideMimeType(this.mimeType !== void 0 ? this.mimeType : "text/plain");
- for (var header in this.requestHeader) {
- request.setRequestHeader(header, this.requestHeader[header]);
- }
- request.send(null);
- }
- scope.manager.itemStart(url);
- return request;
- },
- setResponseType: function(value) {
- this.responseType = value;
- return this;
- },
- setWithCredentials: function(value) {
- this.withCredentials = value;
- return this;
- },
- setMimeType: function(value) {
- this.mimeType = value;
- return this;
- },
- setRequestHeader: function(value) {
- this.requestHeader = value;
- return this;
- }
- });
- function AnimationLoader(manager) {
- Loader.call(this, manager);
- }
- AnimationLoader.prototype = Object.assign(Object.create(Loader.prototype), {
- constructor: AnimationLoader,
- load: function(url, onLoad, onProgress, onError) {
- var scope = this;
- var loader = new FileLoader(scope.manager);
- loader.setPath(scope.path);
- loader.load(url, function(text) {
- onLoad(scope.parse(JSON.parse(text)));
- }, onProgress, onError);
- },
- parse: function(json) {
- var animations = [];
- for (var i2 = 0; i2 < json.length; i2++) {
- var clip = AnimationClip.parse(json[i2]);
- animations.push(clip);
- }
- return animations;
- }
- });
- function CompressedTextureLoader(manager) {
- Loader.call(this, manager);
- }
- CompressedTextureLoader.prototype = Object.assign(Object.create(Loader.prototype), {
- constructor: CompressedTextureLoader,
- load: function(url, onLoad, onProgress, onError) {
- var scope = this;
- var images = [];
- var texture = new CompressedTexture();
- texture.image = images;
- var loader = new FileLoader(this.manager);
- loader.setPath(this.path);
- loader.setResponseType("arraybuffer");
- function loadTexture(i3) {
- loader.load(url[i3], function(buffer) {
- var texDatas = scope.parse(buffer, true);
- images[i3] = {
- width: texDatas.width,
- height: texDatas.height,
- format: texDatas.format,
- mipmaps: texDatas.mipmaps
- };
- loaded += 1;
- if (loaded === 6) {
- if (texDatas.mipmapCount === 1)
- texture.minFilter = LinearFilter;
- texture.format = texDatas.format;
- texture.needsUpdate = true;
- if (onLoad)
- onLoad(texture);
- }
- }, onProgress, onError);
- }
- if (Array.isArray(url)) {
- var loaded = 0;
- for (var i2 = 0, il = url.length; i2 < il; ++i2) {
- loadTexture(i2);
- }
- } else {
- loader.load(url, function(buffer) {
- var texDatas = scope.parse(buffer, true);
- if (texDatas.isCubemap) {
- var faces = texDatas.mipmaps.length / texDatas.mipmapCount;
- for (var f = 0; f < faces; f++) {
- images[f] = { mipmaps: [] };
- for (var i3 = 0; i3 < texDatas.mipmapCount; i3++) {
- images[f].mipmaps.push(texDatas.mipmaps[f * texDatas.mipmapCount + i3]);
- images[f].format = texDatas.format;
- images[f].width = texDatas.width;
- images[f].height = texDatas.height;
- }
- }
- } else {
- texture.image.width = texDatas.width;
- texture.image.height = texDatas.height;
- texture.mipmaps = texDatas.mipmaps;
- }
- if (texDatas.mipmapCount === 1) {
- texture.minFilter = LinearFilter;
- }
- texture.format = texDatas.format;
- texture.needsUpdate = true;
- if (onLoad)
- onLoad(texture);
- }, onProgress, onError);
- }
- return texture;
- }
- });
- function DataTextureLoader(manager) {
- Loader.call(this, manager);
- }
- DataTextureLoader.prototype = Object.assign(Object.create(Loader.prototype), {
- constructor: DataTextureLoader,
- load: function(url, onLoad, onProgress, onError) {
- var scope = this;
- var texture = new DataTexture();
- var loader = new FileLoader(this.manager);
- loader.setResponseType("arraybuffer");
- loader.setPath(this.path);
- loader.load(url, function(buffer) {
- var texData = scope.parse(buffer);
- if (!texData)
- return;
- if (texData.image !== void 0) {
- texture.image = texData.image;
- } else if (texData.data !== void 0) {
- texture.image.width = texData.width;
- texture.image.height = texData.height;
- texture.image.data = texData.data;
- }
- texture.wrapS = texData.wrapS !== void 0 ? texData.wrapS : ClampToEdgeWrapping;
- texture.wrapT = texData.wrapT !== void 0 ? texData.wrapT : ClampToEdgeWrapping;
- texture.magFilter = texData.magFilter !== void 0 ? texData.magFilter : LinearFilter;
- texture.minFilter = texData.minFilter !== void 0 ? texData.minFilter : LinearFilter;
- texture.anisotropy = texData.anisotropy !== void 0 ? texData.anisotropy : 1;
- if (texData.format !== void 0) {
- texture.format = texData.format;
- }
- if (texData.type !== void 0) {
- texture.type = texData.type;
- }
- if (texData.mipmaps !== void 0) {
- texture.mipmaps = texData.mipmaps;
- texture.minFilter = LinearMipmapLinearFilter;
- }
- if (texData.mipmapCount === 1) {
- texture.minFilter = LinearFilter;
- }
- texture.needsUpdate = true;
- if (onLoad)
- onLoad(texture, texData);
- }, onProgress, onError);
- return texture;
- }
- });
- function ImageLoader(manager) {
- Loader.call(this, manager);
- }
- ImageLoader.prototype = Object.assign(Object.create(Loader.prototype), {
- constructor: ImageLoader,
- load: function(url, onLoad, onProgress, onError) {
- if (this.path !== void 0)
- url = this.path + url;
- url = this.manager.resolveURL(url);
- var scope = this;
- var cached = Cache.get(url);
- if (cached !== void 0) {
- scope.manager.itemStart(url);
- setTimeout(function() {
- if (onLoad)
- onLoad(cached);
- scope.manager.itemEnd(url);
- }, 0);
- return cached;
- }
- var image = document.createElementNS("http://www.w3.org/1999/xhtml", "img");
- function onImageLoad() {
- image.removeEventListener("load", onImageLoad, false);
- image.removeEventListener("error", onImageError, false);
- Cache.add(url, this);
- if (onLoad)
- onLoad(this);
- scope.manager.itemEnd(url);
- }
- function onImageError(event) {
- image.removeEventListener("load", onImageLoad, false);
- image.removeEventListener("error", onImageError, false);
- if (onError)
- onError(event);
- scope.manager.itemError(url);
- scope.manager.itemEnd(url);
- }
- image.addEventListener("load", onImageLoad, false);
- image.addEventListener("error", onImageError, false);
- if (url.substr(0, 5) !== "data:") {
- if (this.crossOrigin !== void 0)
- image.crossOrigin = this.crossOrigin;
- }
- scope.manager.itemStart(url);
- image.src = url;
- return image;
- }
- });
- function CubeTextureLoader(manager) {
- Loader.call(this, manager);
- }
- CubeTextureLoader.prototype = Object.assign(Object.create(Loader.prototype), {
- constructor: CubeTextureLoader,
- load: function(urls, onLoad, onProgress, onError) {
- var texture = new CubeTexture();
- var loader = new ImageLoader(this.manager);
- loader.setCrossOrigin(this.crossOrigin);
- loader.setPath(this.path);
- var loaded = 0;
- function loadTexture(i3) {
- loader.load(urls[i3], function(image) {
- texture.images[i3] = image;
- loaded++;
- if (loaded === 6) {
- texture.needsUpdate = true;
- if (onLoad)
- onLoad(texture);
- }
- }, void 0, onError);
- }
- for (var i2 = 0; i2 < urls.length; ++i2) {
- loadTexture(i2);
- }
- return texture;
- }
- });
- function TextureLoader(manager) {
- Loader.call(this, manager);
- }
- TextureLoader.prototype = Object.assign(Object.create(Loader.prototype), {
- constructor: TextureLoader,
- load: function(url, onLoad, onProgress, onError) {
- var texture = new Texture();
- var loader = new ImageLoader(this.manager);
- loader.setCrossOrigin(this.crossOrigin);
- loader.setPath(this.path);
- loader.load(url, function(image) {
- texture.image = image;
- var isJPEG = url.search(/\.jpe?g($|\?)/i) > 0 || url.search(/^data\:image\/jpeg/) === 0;
- texture.format = isJPEG ? RGBFormat : RGBAFormat;
- texture.needsUpdate = true;
- if (onLoad !== void 0) {
- onLoad(texture);
- }
- }, onProgress, onError);
- return texture;
- }
- });
- function Curve() {
- this.type = "Curve";
- this.arcLengthDivisions = 200;
- }
- Object.assign(Curve.prototype, {
- // Virtual base class method to overwrite and implement in subclasses
- // - t [0 .. 1]
- getPoint: function() {
- console.warn("THREE.Curve: .getPoint() not implemented.");
- return null;
- },
- // Get point at relative position in curve according to arc length
- // - u [0 .. 1]
- getPointAt: function(u, optionalTarget) {
- var t = this.getUtoTmapping(u);
- return this.getPoint(t, optionalTarget);
- },
- // Get sequence of points using getPoint( t )
- getPoints: function(divisions) {
- if (divisions === void 0)
- divisions = 5;
- var points = [];
- for (var d = 0; d <= divisions; d++) {
- points.push(this.getPoint(d / divisions));
- }
- return points;
- },
- // Get sequence of points using getPointAt( u )
- getSpacedPoints: function(divisions) {
- if (divisions === void 0)
- divisions = 5;
- var points = [];
- for (var d = 0; d <= divisions; d++) {
- points.push(this.getPointAt(d / divisions));
- }
- return points;
- },
- // Get total curve arc length
- getLength: function() {
- var lengths = this.getLengths();
- return lengths[lengths.length - 1];
- },
- // Get list of cumulative segment lengths
- getLengths: function(divisions) {
- if (divisions === void 0)
- divisions = this.arcLengthDivisions;
- if (this.cacheArcLengths && this.cacheArcLengths.length === divisions + 1 && !this.needsUpdate) {
- return this.cacheArcLengths;
- }
- this.needsUpdate = false;
- var cache = [];
- var current, last = this.getPoint(0);
- var p, sum = 0;
- cache.push(0);
- for (p = 1; p <= divisions; p++) {
- current = this.getPoint(p / divisions);
- sum += current.distanceTo(last);
- cache.push(sum);
- last = current;
- }
- this.cacheArcLengths = cache;
- return cache;
- },
- updateArcLengths: function() {
- this.needsUpdate = true;
- this.getLengths();
- },
- // Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant
- getUtoTmapping: function(u, distance) {
- var arcLengths = this.getLengths();
- var i2 = 0, il = arcLengths.length;
- var targetArcLength;
- if (distance) {
- targetArcLength = distance;
- } else {
- targetArcLength = u * arcLengths[il - 1];
- }
- var low = 0, high = il - 1, comparison;
- while (low <= high) {
- i2 = Math.floor(low + (high - low) / 2);
- comparison = arcLengths[i2] - targetArcLength;
- if (comparison < 0) {
- low = i2 + 1;
- } else if (comparison > 0) {
- high = i2 - 1;
- } else {
- high = i2;
- break;
- }
- }
- i2 = high;
- if (arcLengths[i2] === targetArcLength) {
- return i2 / (il - 1);
- }
- var lengthBefore = arcLengths[i2];
- var lengthAfter = arcLengths[i2 + 1];
- var segmentLength = lengthAfter - lengthBefore;
- var segmentFraction = (targetArcLength - lengthBefore) / segmentLength;
- var t = (i2 + segmentFraction) / (il - 1);
- return t;
- },
- // Returns a unit vector tangent at t
- // In case any sub curve does not implement its tangent derivation,
- // 2 points a small delta apart will be used to find its gradient
- // which seems to give a reasonable approximation
- getTangent: function(t) {
- var delta = 1e-4;
- var t1 = t - delta;
- var t2 = t + delta;
- if (t1 < 0)
- t1 = 0;
- if (t2 > 1)
- t2 = 1;
- var pt1 = this.getPoint(t1);
- var pt2 = this.getPoint(t2);
- var vec = pt2.clone().sub(pt1);
- return vec.normalize();
- },
- getTangentAt: function(u) {
- var t = this.getUtoTmapping(u);
- return this.getTangent(t);
- },
- computeFrenetFrames: function(segments, closed) {
- var normal = new Vector3();
- var tangents = [];
- var normals = [];
- var binormals = [];
- var vec = new Vector3();
- var mat = new Matrix4();
- var i2, u, theta;
- for (i2 = 0; i2 <= segments; i2++) {
- u = i2 / segments;
- tangents[i2] = this.getTangentAt(u);
- tangents[i2].normalize();
- }
- normals[0] = new Vector3();
- binormals[0] = new Vector3();
- var min = Number.MAX_VALUE;
- var tx = Math.abs(tangents[0].x);
- var ty = Math.abs(tangents[0].y);
- var tz = Math.abs(tangents[0].z);
- if (tx <= min) {
- min = tx;
- normal.set(1, 0, 0);
- }
- if (ty <= min) {
- min = ty;
- normal.set(0, 1, 0);
- }
- if (tz <= min) {
- normal.set(0, 0, 1);
- }
- vec.crossVectors(tangents[0], normal).normalize();
- normals[0].crossVectors(tangents[0], vec);
- binormals[0].crossVectors(tangents[0], normals[0]);
- for (i2 = 1; i2 <= segments; i2++) {
- normals[i2] = normals[i2 - 1].clone();
- binormals[i2] = binormals[i2 - 1].clone();
- vec.crossVectors(tangents[i2 - 1], tangents[i2]);
- if (vec.length() > Number.EPSILON) {
- vec.normalize();
- theta = Math.acos(MathUtils.clamp(tangents[i2 - 1].dot(tangents[i2]), -1, 1));
- normals[i2].applyMatrix4(mat.makeRotationAxis(vec, theta));
- }
- binormals[i2].crossVectors(tangents[i2], normals[i2]);
- }
- if (closed === true) {
- theta = Math.acos(MathUtils.clamp(normals[0].dot(normals[segments]), -1, 1));
- theta /= segments;
- if (tangents[0].dot(vec.crossVectors(normals[0], normals[segments])) > 0) {
- theta = -theta;
- }
- for (i2 = 1; i2 <= segments; i2++) {
- normals[i2].applyMatrix4(mat.makeRotationAxis(tangents[i2], theta * i2));
- binormals[i2].crossVectors(tangents[i2], normals[i2]);
- }
- }
- return {
- tangents,
- normals,
- binormals
- };
- },
- clone: function() {
- return new this.constructor().copy(this);
- },
- copy: function(source) {
- this.arcLengthDivisions = source.arcLengthDivisions;
- return this;
- },
- toJSON: function() {
- var data = {
- metadata: {
- version: 4.5,
- type: "Curve",
- generator: "Curve.toJSON"
- }
- };
- data.arcLengthDivisions = this.arcLengthDivisions;
- data.type = this.type;
- return data;
- },
- fromJSON: function(json) {
- this.arcLengthDivisions = json.arcLengthDivisions;
- return this;
- }
- });
- function EllipseCurve(aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation) {
- Curve.call(this);
- this.type = "EllipseCurve";
- this.aX = aX || 0;
- this.aY = aY || 0;
- this.xRadius = xRadius || 1;
- this.yRadius = yRadius || 1;
- this.aStartAngle = aStartAngle || 0;
- this.aEndAngle = aEndAngle || 2 * Math.PI;
- this.aClockwise = aClockwise || false;
- this.aRotation = aRotation || 0;
- }
- EllipseCurve.prototype = Object.create(Curve.prototype);
- EllipseCurve.prototype.constructor = EllipseCurve;
- EllipseCurve.prototype.isEllipseCurve = true;
- EllipseCurve.prototype.getPoint = function(t, optionalTarget) {
- var point = optionalTarget || new Vector2();
- var twoPi = Math.PI * 2;
- var deltaAngle = this.aEndAngle - this.aStartAngle;
- var samePoints = Math.abs(deltaAngle) < Number.EPSILON;
- while (deltaAngle < 0)
- deltaAngle += twoPi;
- while (deltaAngle > twoPi)
- deltaAngle -= twoPi;
- if (deltaAngle < Number.EPSILON) {
- if (samePoints) {
- deltaAngle = 0;
- } else {
- deltaAngle = twoPi;
- }
- }
- if (this.aClockwise === true && !samePoints) {
- if (deltaAngle === twoPi) {
- deltaAngle = -twoPi;
- } else {
- deltaAngle = deltaAngle - twoPi;
- }
- }
- var angle = this.aStartAngle + t * deltaAngle;
- var x = this.aX + this.xRadius * Math.cos(angle);
- var y = this.aY + this.yRadius * Math.sin(angle);
- if (this.aRotation !== 0) {
- var cos = Math.cos(this.aRotation);
- var sin = Math.sin(this.aRotation);
- var tx = x - this.aX;
- var ty = y - this.aY;
- x = tx * cos - ty * sin + this.aX;
- y = tx * sin + ty * cos + this.aY;
- }
- return point.set(x, y);
- };
- EllipseCurve.prototype.copy = function(source) {
- Curve.prototype.copy.call(this, source);
- this.aX = source.aX;
- this.aY = source.aY;
- this.xRadius = source.xRadius;
- this.yRadius = source.yRadius;
- this.aStartAngle = source.aStartAngle;
- this.aEndAngle = source.aEndAngle;
- this.aClockwise = source.aClockwise;
- this.aRotation = source.aRotation;
- return this;
- };
- EllipseCurve.prototype.toJSON = function() {
- var data = Curve.prototype.toJSON.call(this);
- data.aX = this.aX;
- data.aY = this.aY;
- data.xRadius = this.xRadius;
- data.yRadius = this.yRadius;
- data.aStartAngle = this.aStartAngle;
- data.aEndAngle = this.aEndAngle;
- data.aClockwise = this.aClockwise;
- data.aRotation = this.aRotation;
- return data;
- };
- EllipseCurve.prototype.fromJSON = function(json) {
- Curve.prototype.fromJSON.call(this, json);
- this.aX = json.aX;
- this.aY = json.aY;
- this.xRadius = json.xRadius;
- this.yRadius = json.yRadius;
- this.aStartAngle = json.aStartAngle;
- this.aEndAngle = json.aEndAngle;
- this.aClockwise = json.aClockwise;
- this.aRotation = json.aRotation;
- return this;
- };
- function ArcCurve(aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise) {
- EllipseCurve.call(this, aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise);
- this.type = "ArcCurve";
- }
- ArcCurve.prototype = Object.create(EllipseCurve.prototype);
- ArcCurve.prototype.constructor = ArcCurve;
- ArcCurve.prototype.isArcCurve = true;
- function CubicPoly() {
- var c0 = 0, c1 = 0, c2 = 0, c3 = 0;
- function init2(x0, x1, t0, t1) {
- c0 = x0;
- c1 = t0;
- c2 = -3 * x0 + 3 * x1 - 2 * t0 - t1;
- c3 = 2 * x0 - 2 * x1 + t0 + t1;
- }
- return {
- initCatmullRom: function(x0, x1, x2, x3, tension) {
- init2(x1, x2, tension * (x2 - x0), tension * (x3 - x1));
- },
- initNonuniformCatmullRom: function(x0, x1, x2, x3, dt0, dt1, dt2) {
- var t1 = (x1 - x0) / dt0 - (x2 - x0) / (dt0 + dt1) + (x2 - x1) / dt1;
- var t2 = (x2 - x1) / dt1 - (x3 - x1) / (dt1 + dt2) + (x3 - x2) / dt2;
- t1 *= dt1;
- t2 *= dt1;
- init2(x1, x2, t1, t2);
- },
- calc: function(t) {
- var t2 = t * t;
- var t3 = t2 * t;
- return c0 + c1 * t + c2 * t2 + c3 * t3;
- }
- };
- }
- var tmp = new Vector3();
- var px = new CubicPoly(), py = new CubicPoly(), pz = new CubicPoly();
- function CatmullRomCurve3(points, closed, curveType, tension) {
- Curve.call(this);
- this.type = "CatmullRomCurve3";
- this.points = points || [];
- this.closed = closed || false;
- this.curveType = curveType || "centripetal";
- this.tension = tension || 0.5;
- }
- CatmullRomCurve3.prototype = Object.create(Curve.prototype);
- CatmullRomCurve3.prototype.constructor = CatmullRomCurve3;
- CatmullRomCurve3.prototype.isCatmullRomCurve3 = true;
- CatmullRomCurve3.prototype.getPoint = function(t, optionalTarget) {
- var point = optionalTarget || new Vector3();
- var points = this.points;
- var l = points.length;
- var p = (l - (this.closed ? 0 : 1)) * t;
- var intPoint = Math.floor(p);
- var weight = p - intPoint;
- if (this.closed) {
- intPoint += intPoint > 0 ? 0 : (Math.floor(Math.abs(intPoint) / l) + 1) * l;
- } else if (weight === 0 && intPoint === l - 1) {
- intPoint = l - 2;
- weight = 1;
- }
- var p0, p1, p2, p3;
- if (this.closed || intPoint > 0) {
- p0 = points[(intPoint - 1) % l];
- } else {
- tmp.subVectors(points[0], points[1]).add(points[0]);
- p0 = tmp;
- }
- p1 = points[intPoint % l];
- p2 = points[(intPoint + 1) % l];
- if (this.closed || intPoint + 2 < l) {
- p3 = points[(intPoint + 2) % l];
- } else {
- tmp.subVectors(points[l - 1], points[l - 2]).add(points[l - 1]);
- p3 = tmp;
- }
- if (this.curveType === "centripetal" || this.curveType === "chordal") {
- var pow = this.curveType === "chordal" ? 0.5 : 0.25;
- var dt0 = Math.pow(p0.distanceToSquared(p1), pow);
- var dt1 = Math.pow(p1.distanceToSquared(p2), pow);
- var dt2 = Math.pow(p2.distanceToSquared(p3), pow);
- if (dt1 < 1e-4)
- dt1 = 1;
- if (dt0 < 1e-4)
- dt0 = dt1;
- if (dt2 < 1e-4)
- dt2 = dt1;
- px.initNonuniformCatmullRom(p0.x, p1.x, p2.x, p3.x, dt0, dt1, dt2);
- py.initNonuniformCatmullRom(p0.y, p1.y, p2.y, p3.y, dt0, dt1, dt2);
- pz.initNonuniformCatmullRom(p0.z, p1.z, p2.z, p3.z, dt0, dt1, dt2);
- } else if (this.curveType === "catmullrom") {
- px.initCatmullRom(p0.x, p1.x, p2.x, p3.x, this.tension);
- py.initCatmullRom(p0.y, p1.y, p2.y, p3.y, this.tension);
- pz.initCatmullRom(p0.z, p1.z, p2.z, p3.z, this.tension);
- }
- point.set(
- px.calc(weight),
- py.calc(weight),
- pz.calc(weight)
- );
- return point;
- };
- CatmullRomCurve3.prototype.copy = function(source) {
- Curve.prototype.copy.call(this, source);
- this.points = [];
- for (var i2 = 0, l = source.points.length; i2 < l; i2++) {
- var point = source.points[i2];
- this.points.push(point.clone());
- }
- this.closed = source.closed;
- this.curveType = source.curveType;
- this.tension = source.tension;
- return this;
- };
- CatmullRomCurve3.prototype.toJSON = function() {
- var data = Curve.prototype.toJSON.call(this);
- data.points = [];
- for (var i2 = 0, l = this.points.length; i2 < l; i2++) {
- var point = this.points[i2];
- data.points.push(point.toArray());
- }
- data.closed = this.closed;
- data.curveType = this.curveType;
- data.tension = this.tension;
- return data;
- };
- CatmullRomCurve3.prototype.fromJSON = function(json) {
- Curve.prototype.fromJSON.call(this, json);
- this.points = [];
- for (var i2 = 0, l = json.points.length; i2 < l; i2++) {
- var point = json.points[i2];
- this.points.push(new Vector3().fromArray(point));
- }
- this.closed = json.closed;
- this.curveType = json.curveType;
- this.tension = json.tension;
- return this;
- };
- function CatmullRom(t, p0, p1, p2, p3) {
- var v0 = (p2 - p0) * 0.5;
- var v1 = (p3 - p1) * 0.5;
- var t2 = t * t;
- var t3 = t * t2;
- return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
- }
- function QuadraticBezierP0(t, p) {
- var k = 1 - t;
- return k * k * p;
- }
- function QuadraticBezierP1(t, p) {
- return 2 * (1 - t) * t * p;
- }
- function QuadraticBezierP2(t, p) {
- return t * t * p;
- }
- function QuadraticBezier(t, p0, p1, p2) {
- return QuadraticBezierP0(t, p0) + QuadraticBezierP1(t, p1) + QuadraticBezierP2(t, p2);
- }
- function CubicBezierP0(t, p) {
- var k = 1 - t;
- return k * k * k * p;
- }
- function CubicBezierP1(t, p) {
- var k = 1 - t;
- return 3 * k * k * t * p;
- }
- function CubicBezierP2(t, p) {
- return 3 * (1 - t) * t * t * p;
- }
- function CubicBezierP3(t, p) {
- return t * t * t * p;
- }
- function CubicBezier(t, p0, p1, p2, p3) {
- return CubicBezierP0(t, p0) + CubicBezierP1(t, p1) + CubicBezierP2(t, p2) + CubicBezierP3(t, p3);
- }
- function CubicBezierCurve(v0, v1, v2, v3) {
- Curve.call(this);
- this.type = "CubicBezierCurve";
- this.v0 = v0 || new Vector2();
- this.v1 = v1 || new Vector2();
- this.v2 = v2 || new Vector2();
- this.v3 = v3 || new Vector2();
- }
- CubicBezierCurve.prototype = Object.create(Curve.prototype);
- CubicBezierCurve.prototype.constructor = CubicBezierCurve;
- CubicBezierCurve.prototype.isCubicBezierCurve = true;
- CubicBezierCurve.prototype.getPoint = function(t, optionalTarget) {
- var point = optionalTarget || new Vector2();
- var v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3;
- point.set(
- CubicBezier(t, v0.x, v1.x, v2.x, v3.x),
- CubicBezier(t, v0.y, v1.y, v2.y, v3.y)
- );
- return point;
- };
- CubicBezierCurve.prototype.copy = function(source) {
- Curve.prototype.copy.call(this, source);
- this.v0.copy(source.v0);
- this.v1.copy(source.v1);
- this.v2.copy(source.v2);
- this.v3.copy(source.v3);
- return this;
- };
- CubicBezierCurve.prototype.toJSON = function() {
- var data = Curve.prototype.toJSON.call(this);
- data.v0 = this.v0.toArray();
- data.v1 = this.v1.toArray();
- data.v2 = this.v2.toArray();
- data.v3 = this.v3.toArray();
- return data;
- };
- CubicBezierCurve.prototype.fromJSON = function(json) {
- Curve.prototype.fromJSON.call(this, json);
- this.v0.fromArray(json.v0);
- this.v1.fromArray(json.v1);
- this.v2.fromArray(json.v2);
- this.v3.fromArray(json.v3);
- return this;
- };
- function CubicBezierCurve3(v0, v1, v2, v3) {
- Curve.call(this);
- this.type = "CubicBezierCurve3";
- this.v0 = v0 || new Vector3();
- this.v1 = v1 || new Vector3();
- this.v2 = v2 || new Vector3();
- this.v3 = v3 || new Vector3();
- }
- CubicBezierCurve3.prototype = Object.create(Curve.prototype);
- CubicBezierCurve3.prototype.constructor = CubicBezierCurve3;
- CubicBezierCurve3.prototype.isCubicBezierCurve3 = true;
- CubicBezierCurve3.prototype.getPoint = function(t, optionalTarget) {
- var point = optionalTarget || new Vector3();
- var v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3;
- point.set(
- CubicBezier(t, v0.x, v1.x, v2.x, v3.x),
- CubicBezier(t, v0.y, v1.y, v2.y, v3.y),
- CubicBezier(t, v0.z, v1.z, v2.z, v3.z)
- );
- return point;
- };
- CubicBezierCurve3.prototype.copy = function(source) {
- Curve.prototype.copy.call(this, source);
- this.v0.copy(source.v0);
- this.v1.copy(source.v1);
- this.v2.copy(source.v2);
- this.v3.copy(source.v3);
- return this;
- };
- CubicBezierCurve3.prototype.toJSON = function() {
- var data = Curve.prototype.toJSON.call(this);
- data.v0 = this.v0.toArray();
- data.v1 = this.v1.toArray();
- data.v2 = this.v2.toArray();
- data.v3 = this.v3.toArray();
- return data;
- };
- CubicBezierCurve3.prototype.fromJSON = function(json) {
- Curve.prototype.fromJSON.call(this, json);
- this.v0.fromArray(json.v0);
- this.v1.fromArray(json.v1);
- this.v2.fromArray(json.v2);
- this.v3.fromArray(json.v3);
- return this;
- };
- function LineCurve(v1, v2) {
- Curve.call(this);
- this.type = "LineCurve";
- this.v1 = v1 || new Vector2();
- this.v2 = v2 || new Vector2();
- }
- LineCurve.prototype = Object.create(Curve.prototype);
- LineCurve.prototype.constructor = LineCurve;
- LineCurve.prototype.isLineCurve = true;
- LineCurve.prototype.getPoint = function(t, optionalTarget) {
- var point = optionalTarget || new Vector2();
- if (t === 1) {
- point.copy(this.v2);
- } else {
- point.copy(this.v2).sub(this.v1);
- point.multiplyScalar(t).add(this.v1);
- }
- return point;
- };
- LineCurve.prototype.getPointAt = function(u, optionalTarget) {
- return this.getPoint(u, optionalTarget);
- };
- LineCurve.prototype.getTangent = function() {
- var tangent = this.v2.clone().sub(this.v1);
- return tangent.normalize();
- };
- LineCurve.prototype.copy = function(source) {
- Curve.prototype.copy.call(this, source);
- this.v1.copy(source.v1);
- this.v2.copy(source.v2);
- return this;
- };
- LineCurve.prototype.toJSON = function() {
- var data = Curve.prototype.toJSON.call(this);
- data.v1 = this.v1.toArray();
- data.v2 = this.v2.toArray();
- return data;
- };
- LineCurve.prototype.fromJSON = function(json) {
- Curve.prototype.fromJSON.call(this, json);
- this.v1.fromArray(json.v1);
- this.v2.fromArray(json.v2);
- return this;
- };
- function LineCurve3(v1, v2) {
- Curve.call(this);
- this.type = "LineCurve3";
- this.v1 = v1 || new Vector3();
- this.v2 = v2 || new Vector3();
- }
- LineCurve3.prototype = Object.create(Curve.prototype);
- LineCurve3.prototype.constructor = LineCurve3;
- LineCurve3.prototype.isLineCurve3 = true;
- LineCurve3.prototype.getPoint = function(t, optionalTarget) {
- var point = optionalTarget || new Vector3();
- if (t === 1) {
- point.copy(this.v2);
- } else {
- point.copy(this.v2).sub(this.v1);
- point.multiplyScalar(t).add(this.v1);
- }
- return point;
- };
- LineCurve3.prototype.getPointAt = function(u, optionalTarget) {
- return this.getPoint(u, optionalTarget);
- };
- LineCurve3.prototype.copy = function(source) {
- Curve.prototype.copy.call(this, source);
- this.v1.copy(source.v1);
- this.v2.copy(source.v2);
- return this;
- };
- LineCurve3.prototype.toJSON = function() {
- var data = Curve.prototype.toJSON.call(this);
- data.v1 = this.v1.toArray();
- data.v2 = this.v2.toArray();
- return data;
- };
- LineCurve3.prototype.fromJSON = function(json) {
- Curve.prototype.fromJSON.call(this, json);
- this.v1.fromArray(json.v1);
- this.v2.fromArray(json.v2);
- return this;
- };
- function QuadraticBezierCurve(v0, v1, v2) {
- Curve.call(this);
- this.type = "QuadraticBezierCurve";
- this.v0 = v0 || new Vector2();
- this.v1 = v1 || new Vector2();
- this.v2 = v2 || new Vector2();
- }
- QuadraticBezierCurve.prototype = Object.create(Curve.prototype);
- QuadraticBezierCurve.prototype.constructor = QuadraticBezierCurve;
- QuadraticBezierCurve.prototype.isQuadraticBezierCurve = true;
- QuadraticBezierCurve.prototype.getPoint = function(t, optionalTarget) {
- var point = optionalTarget || new Vector2();
- var v0 = this.v0, v1 = this.v1, v2 = this.v2;
- point.set(
- QuadraticBezier(t, v0.x, v1.x, v2.x),
- QuadraticBezier(t, v0.y, v1.y, v2.y)
- );
- return point;
- };
- QuadraticBezierCurve.prototype.copy = function(source) {
- Curve.prototype.copy.call(this, source);
- this.v0.copy(source.v0);
- this.v1.copy(source.v1);
- this.v2.copy(source.v2);
- return this;
- };
- QuadraticBezierCurve.prototype.toJSON = function() {
- var data = Curve.prototype.toJSON.call(this);
- data.v0 = this.v0.toArray();
- data.v1 = this.v1.toArray();
- data.v2 = this.v2.toArray();
- return data;
- };
- QuadraticBezierCurve.prototype.fromJSON = function(json) {
- Curve.prototype.fromJSON.call(this, json);
- this.v0.fromArray(json.v0);
- this.v1.fromArray(json.v1);
- this.v2.fromArray(json.v2);
- return this;
- };
- function QuadraticBezierCurve3(v0, v1, v2) {
- Curve.call(this);
- this.type = "QuadraticBezierCurve3";
- this.v0 = v0 || new Vector3();
- this.v1 = v1 || new Vector3();
- this.v2 = v2 || new Vector3();
- }
- QuadraticBezierCurve3.prototype = Object.create(Curve.prototype);
- QuadraticBezierCurve3.prototype.constructor = QuadraticBezierCurve3;
- QuadraticBezierCurve3.prototype.isQuadraticBezierCurve3 = true;
- QuadraticBezierCurve3.prototype.getPoint = function(t, optionalTarget) {
- var point = optionalTarget || new Vector3();
- var v0 = this.v0, v1 = this.v1, v2 = this.v2;
- point.set(
- QuadraticBezier(t, v0.x, v1.x, v2.x),
- QuadraticBezier(t, v0.y, v1.y, v2.y),
- QuadraticBezier(t, v0.z, v1.z, v2.z)
- );
- return point;
- };
- QuadraticBezierCurve3.prototype.copy = function(source) {
- Curve.prototype.copy.call(this, source);
- this.v0.copy(source.v0);
- this.v1.copy(source.v1);
- this.v2.copy(source.v2);
- return this;
- };
- QuadraticBezierCurve3.prototype.toJSON = function() {
- var data = Curve.prototype.toJSON.call(this);
- data.v0 = this.v0.toArray();
- data.v1 = this.v1.toArray();
- data.v2 = this.v2.toArray();
- return data;
- };
- QuadraticBezierCurve3.prototype.fromJSON = function(json) {
- Curve.prototype.fromJSON.call(this, json);
- this.v0.fromArray(json.v0);
- this.v1.fromArray(json.v1);
- this.v2.fromArray(json.v2);
- return this;
- };
- function SplineCurve(points) {
- Curve.call(this);
- this.type = "SplineCurve";
- this.points = points || [];
- }
- SplineCurve.prototype = Object.create(Curve.prototype);
- SplineCurve.prototype.constructor = SplineCurve;
- SplineCurve.prototype.isSplineCurve = true;
- SplineCurve.prototype.getPoint = function(t, optionalTarget) {
- var point = optionalTarget || new Vector2();
- var points = this.points;
- var p = (points.length - 1) * t;
- var intPoint = Math.floor(p);
- var weight = p - intPoint;
- var p0 = points[intPoint === 0 ? intPoint : intPoint - 1];
- var p1 = points[intPoint];
- var p2 = points[intPoint > points.length - 2 ? points.length - 1 : intPoint + 1];
- var p3 = points[intPoint > points.length - 3 ? points.length - 1 : intPoint + 2];
- point.set(
- CatmullRom(weight, p0.x, p1.x, p2.x, p3.x),
- CatmullRom(weight, p0.y, p1.y, p2.y, p3.y)
- );
- return point;
- };
- SplineCurve.prototype.copy = function(source) {
- Curve.prototype.copy.call(this, source);
- this.points = [];
- for (var i2 = 0, l = source.points.length; i2 < l; i2++) {
- var point = source.points[i2];
- this.points.push(point.clone());
- }
- return this;
- };
- SplineCurve.prototype.toJSON = function() {
- var data = Curve.prototype.toJSON.call(this);
- data.points = [];
- for (var i2 = 0, l = this.points.length; i2 < l; i2++) {
- var point = this.points[i2];
- data.points.push(point.toArray());
- }
- return data;
- };
- SplineCurve.prototype.fromJSON = function(json) {
- Curve.prototype.fromJSON.call(this, json);
- this.points = [];
- for (var i2 = 0, l = json.points.length; i2 < l; i2++) {
- var point = json.points[i2];
- this.points.push(new Vector2().fromArray(point));
- }
- return this;
- };
- var Curves = /* @__PURE__ */ Object.freeze({
- __proto__: null,
- ArcCurve,
- CatmullRomCurve3,
- CubicBezierCurve,
- CubicBezierCurve3,
- EllipseCurve,
- LineCurve,
- LineCurve3,
- QuadraticBezierCurve,
- QuadraticBezierCurve3,
- SplineCurve
- });
- function CurvePath() {
- Curve.call(this);
- this.type = "CurvePath";
- this.curves = [];
- this.autoClose = false;
- }
- CurvePath.prototype = Object.assign(Object.create(Curve.prototype), {
- constructor: CurvePath,
- add: function(curve) {
- this.curves.push(curve);
- },
- closePath: function() {
- var startPoint = this.curves[0].getPoint(0);
- var endPoint = this.curves[this.curves.length - 1].getPoint(1);
- if (!startPoint.equals(endPoint)) {
- this.curves.push(new LineCurve(endPoint, startPoint));
- }
- },
- // To get accurate point with reference to
- // entire path distance at time t,
- // following has to be done:
- // 1. Length of each sub path have to be known
- // 2. Locate and identify type of curve
- // 3. Get t for the curve
- // 4. Return curve.getPointAt(t')
- getPoint: function(t) {
- var d = t * this.getLength();
- var curveLengths = this.getCurveLengths();
- var i2 = 0;
- while (i2 < curveLengths.length) {
- if (curveLengths[i2] >= d) {
- var diff = curveLengths[i2] - d;
- var curve = this.curves[i2];
- var segmentLength = curve.getLength();
- var u = segmentLength === 0 ? 0 : 1 - diff / segmentLength;
- return curve.getPointAt(u);
- }
- i2++;
- }
- return null;
- },
- // We cannot use the default THREE.Curve getPoint() with getLength() because in
- // THREE.Curve, getLength() depends on getPoint() but in THREE.CurvePath
- // getPoint() depends on getLength
- getLength: function() {
- var lens = this.getCurveLengths();
- return lens[lens.length - 1];
- },
- // cacheLengths must be recalculated.
- updateArcLengths: function() {
- this.needsUpdate = true;
- this.cacheLengths = null;
- this.getCurveLengths();
- },
- // Compute lengths and cache them
- // We cannot overwrite getLengths() because UtoT mapping uses it.
- getCurveLengths: function() {
- if (this.cacheLengths && this.cacheLengths.length === this.curves.length) {
- return this.cacheLengths;
- }
- var lengths = [], sums = 0;
- for (var i2 = 0, l = this.curves.length; i2 < l; i2++) {
- sums += this.curves[i2].getLength();
- lengths.push(sums);
- }
- this.cacheLengths = lengths;
- return lengths;
- },
- getSpacedPoints: function(divisions) {
- if (divisions === void 0)
- divisions = 40;
- var points = [];
- for (var i2 = 0; i2 <= divisions; i2++) {
- points.push(this.getPoint(i2 / divisions));
- }
- if (this.autoClose) {
- points.push(points[0]);
- }
- return points;
- },
- getPoints: function(divisions) {
- divisions = divisions || 12;
- var points = [], last;
- for (var i2 = 0, curves = this.curves; i2 < curves.length; i2++) {
- var curve = curves[i2];
- var resolution = curve && curve.isEllipseCurve ? divisions * 2 : curve && (curve.isLineCurve || curve.isLineCurve3) ? 1 : curve && curve.isSplineCurve ? divisions * curve.points.length : divisions;
- var pts = curve.getPoints(resolution);
- for (var j = 0; j < pts.length; j++) {
- var point = pts[j];
- if (last && last.equals(point))
- continue;
- points.push(point);
- last = point;
- }
- }
- if (this.autoClose && points.length > 1 && !points[points.length - 1].equals(points[0])) {
- points.push(points[0]);
- }
- return points;
- },
- copy: function(source) {
- Curve.prototype.copy.call(this, source);
- this.curves = [];
- for (var i2 = 0, l = source.curves.length; i2 < l; i2++) {
- var curve = source.curves[i2];
- this.curves.push(curve.clone());
- }
- this.autoClose = source.autoClose;
- return this;
- },
- toJSON: function() {
- var data = Curve.prototype.toJSON.call(this);
- data.autoClose = this.autoClose;
- data.curves = [];
- for (var i2 = 0, l = this.curves.length; i2 < l; i2++) {
- var curve = this.curves[i2];
- data.curves.push(curve.toJSON());
- }
- return data;
- },
- fromJSON: function(json) {
- Curve.prototype.fromJSON.call(this, json);
- this.autoClose = json.autoClose;
- this.curves = [];
- for (var i2 = 0, l = json.curves.length; i2 < l; i2++) {
- var curve = json.curves[i2];
- this.curves.push(new Curves[curve.type]().fromJSON(curve));
- }
- return this;
- }
- });
- function Path(points) {
- CurvePath.call(this);
- this.type = "Path";
- this.currentPoint = new Vector2();
- if (points) {
- this.setFromPoints(points);
- }
- }
- Path.prototype = Object.assign(Object.create(CurvePath.prototype), {
- constructor: Path,
- setFromPoints: function(points) {
- this.moveTo(points[0].x, points[0].y);
- for (var i2 = 1, l = points.length; i2 < l; i2++) {
- this.lineTo(points[i2].x, points[i2].y);
- }
- return this;
- },
- moveTo: function(x, y) {
- this.currentPoint.set(x, y);
- return this;
- },
- lineTo: function(x, y) {
- var curve = new LineCurve(this.currentPoint.clone(), new Vector2(x, y));
- this.curves.push(curve);
- this.currentPoint.set(x, y);
- return this;
- },
- quadraticCurveTo: function(aCPx, aCPy, aX, aY) {
- var curve = new QuadraticBezierCurve(
- this.currentPoint.clone(),
- new Vector2(aCPx, aCPy),
- new Vector2(aX, aY)
- );
- this.curves.push(curve);
- this.currentPoint.set(aX, aY);
- return this;
- },
- bezierCurveTo: function(aCP1x, aCP1y, aCP2x, aCP2y, aX, aY) {
- var curve = new CubicBezierCurve(
- this.currentPoint.clone(),
- new Vector2(aCP1x, aCP1y),
- new Vector2(aCP2x, aCP2y),
- new Vector2(aX, aY)
- );
- this.curves.push(curve);
- this.currentPoint.set(aX, aY);
- return this;
- },
- splineThru: function(pts) {
- var npts = [this.currentPoint.clone()].concat(pts);
- var curve = new SplineCurve(npts);
- this.curves.push(curve);
- this.currentPoint.copy(pts[pts.length - 1]);
- return this;
- },
- arc: function(aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise) {
- var x0 = this.currentPoint.x;
- var y0 = this.currentPoint.y;
- this.absarc(
- aX + x0,
- aY + y0,
- aRadius,
- aStartAngle,
- aEndAngle,
- aClockwise
- );
- return this;
- },
- absarc: function(aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise) {
- this.absellipse(aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise);
- return this;
- },
- ellipse: function(aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation) {
- var x0 = this.currentPoint.x;
- var y0 = this.currentPoint.y;
- this.absellipse(aX + x0, aY + y0, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation);
- return this;
- },
- absellipse: function(aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation) {
- var curve = new EllipseCurve(aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation);
- if (this.curves.length > 0) {
- var firstPoint = curve.getPoint(0);
- if (!firstPoint.equals(this.currentPoint)) {
- this.lineTo(firstPoint.x, firstPoint.y);
- }
- }
- this.curves.push(curve);
- var lastPoint = curve.getPoint(1);
- this.currentPoint.copy(lastPoint);
- return this;
- },
- copy: function(source) {
- CurvePath.prototype.copy.call(this, source);
- this.currentPoint.copy(source.currentPoint);
- return this;
- },
- toJSON: function() {
- var data = CurvePath.prototype.toJSON.call(this);
- data.currentPoint = this.currentPoint.toArray();
- return data;
- },
- fromJSON: function(json) {
- CurvePath.prototype.fromJSON.call(this, json);
- this.currentPoint.fromArray(json.currentPoint);
- return this;
- }
- });
- function Shape(points) {
- Path.call(this, points);
- this.uuid = MathUtils.generateUUID();
- this.type = "Shape";
- this.holes = [];
- }
- Shape.prototype = Object.assign(Object.create(Path.prototype), {
- constructor: Shape,
- getPointsHoles: function(divisions) {
- var holesPts = [];
- for (var i2 = 0, l = this.holes.length; i2 < l; i2++) {
- holesPts[i2] = this.holes[i2].getPoints(divisions);
- }
- return holesPts;
- },
- // get points of shape and holes (keypoints based on segments parameter)
- extractPoints: function(divisions) {
- return {
- shape: this.getPoints(divisions),
- holes: this.getPointsHoles(divisions)
- };
- },
- copy: function(source) {
- Path.prototype.copy.call(this, source);
- this.holes = [];
- for (var i2 = 0, l = source.holes.length; i2 < l; i2++) {
- var hole = source.holes[i2];
- this.holes.push(hole.clone());
- }
- return this;
- },
- toJSON: function() {
- var data = Path.prototype.toJSON.call(this);
- data.uuid = this.uuid;
- data.holes = [];
- for (var i2 = 0, l = this.holes.length; i2 < l; i2++) {
- var hole = this.holes[i2];
- data.holes.push(hole.toJSON());
- }
- return data;
- },
- fromJSON: function(json) {
- Path.prototype.fromJSON.call(this, json);
- this.uuid = json.uuid;
- this.holes = [];
- for (var i2 = 0, l = json.holes.length; i2 < l; i2++) {
- var hole = json.holes[i2];
- this.holes.push(new Path().fromJSON(hole));
- }
- return this;
- }
- });
- function Light(color, intensity) {
- Object3D.call(this);
- this.type = "Light";
- this.color = new Color(color);
- this.intensity = intensity !== void 0 ? intensity : 1;
- this.receiveShadow = void 0;
- }
- Light.prototype = Object.assign(Object.create(Object3D.prototype), {
- constructor: Light,
- isLight: true,
- copy: function(source) {
- Object3D.prototype.copy.call(this, source);
- this.color.copy(source.color);
- this.intensity = source.intensity;
- return this;
- },
- toJSON: function(meta) {
- var data = Object3D.prototype.toJSON.call(this, meta);
- data.object.color = this.color.getHex();
- data.object.intensity = this.intensity;
- if (this.groundColor !== void 0)
- data.object.groundColor = this.groundColor.getHex();
- if (this.distance !== void 0)
- data.object.distance = this.distance;
- if (this.angle !== void 0)
- data.object.angle = this.angle;
- if (this.decay !== void 0)
- data.object.decay = this.decay;
- if (this.penumbra !== void 0)
- data.object.penumbra = this.penumbra;
- if (this.shadow !== void 0)
- data.object.shadow = this.shadow.toJSON();
- return data;
- }
- });
- function HemisphereLight(skyColor, groundColor, intensity) {
- Light.call(this, skyColor, intensity);
- this.type = "HemisphereLight";
- this.castShadow = void 0;
- this.position.copy(Object3D.DefaultUp);
- this.updateMatrix();
- this.groundColor = new Color(groundColor);
- }
- HemisphereLight.prototype = Object.assign(Object.create(Light.prototype), {
- constructor: HemisphereLight,
- isHemisphereLight: true,
- copy: function(source) {
- Light.prototype.copy.call(this, source);
- this.groundColor.copy(source.groundColor);
- return this;
- }
- });
- function LightShadow(camera) {
- this.camera = camera;
- this.bias = 0;
- this.radius = 1;
- this.mapSize = new Vector2(512, 512);
- this.map = null;
- this.mapPass = null;
- this.matrix = new Matrix4();
- this._frustum = new Frustum();
- this._frameExtents = new Vector2(1, 1);
- this._viewportCount = 1;
- this._viewports = [
- new Vector4(0, 0, 1, 1)
- ];
- }
- Object.assign(LightShadow.prototype, {
- _projScreenMatrix: new Matrix4(),
- _lightPositionWorld: new Vector3(),
- _lookTarget: new Vector3(),
- getViewportCount: function() {
- return this._viewportCount;
- },
- getFrustum: function() {
- return this._frustum;
- },
- updateMatrices: function(light) {
- var shadowCamera = this.camera, shadowMatrix = this.matrix, projScreenMatrix = this._projScreenMatrix, lookTarget = this._lookTarget, lightPositionWorld = this._lightPositionWorld;
- lightPositionWorld.setFromMatrixPosition(light.matrixWorld);
- shadowCamera.position.copy(lightPositionWorld);
- lookTarget.setFromMatrixPosition(light.target.matrixWorld);
- shadowCamera.lookAt(lookTarget);
- shadowCamera.updateMatrixWorld();
- projScreenMatrix.multiplyMatrices(shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse);
- this._frustum.setFromProjectionMatrix(projScreenMatrix);
- shadowMatrix.set(
- 0.5,
- 0,
- 0,
- 0.5,
- 0,
- 0.5,
- 0,
- 0.5,
- 0,
- 0,
- 0.5,
- 0.5,
- 0,
- 0,
- 0,
- 1
- );
- shadowMatrix.multiply(shadowCamera.projectionMatrix);
- shadowMatrix.multiply(shadowCamera.matrixWorldInverse);
- },
- getViewport: function(viewportIndex) {
- return this._viewports[viewportIndex];
- },
- getFrameExtents: function() {
- return this._frameExtents;
- },
- copy: function(source) {
- this.camera = source.camera.clone();
- this.bias = source.bias;
- this.radius = source.radius;
- this.mapSize.copy(source.mapSize);
- return this;
- },
- clone: function() {
- return new this.constructor().copy(this);
- },
- toJSON: function() {
- var object = {};
- if (this.bias !== 0)
- object.bias = this.bias;
- if (this.radius !== 1)
- object.radius = this.radius;
- if (this.mapSize.x !== 512 || this.mapSize.y !== 512)
- object.mapSize = this.mapSize.toArray();
- object.camera = this.camera.toJSON(false).object;
- delete object.camera.matrix;
- return object;
- }
- });
- function SpotLightShadow() {
- LightShadow.call(this, new PerspectiveCamera(50, 1, 0.5, 500));
- }
- SpotLightShadow.prototype = Object.assign(Object.create(LightShadow.prototype), {
- constructor: SpotLightShadow,
- isSpotLightShadow: true,
- updateMatrices: function(light) {
- var camera = this.camera;
- var fov2 = MathUtils.RAD2DEG * 2 * light.angle;
- var aspect2 = this.mapSize.width / this.mapSize.height;
- var far = light.distance || camera.far;
- if (fov2 !== camera.fov || aspect2 !== camera.aspect || far !== camera.far) {
- camera.fov = fov2;
- camera.aspect = aspect2;
- camera.far = far;
- camera.updateProjectionMatrix();
- }
- LightShadow.prototype.updateMatrices.call(this, light);
- }
- });
- function SpotLight(color, intensity, distance, angle, penumbra, decay) {
- Light.call(this, color, intensity);
- this.type = "SpotLight";
- this.position.copy(Object3D.DefaultUp);
- this.updateMatrix();
- this.target = new Object3D();
- Object.defineProperty(this, "power", {
- get: function() {
- return this.intensity * Math.PI;
- },
- set: function(power) {
- this.intensity = power / Math.PI;
- }
- });
- this.distance = distance !== void 0 ? distance : 0;
- this.angle = angle !== void 0 ? angle : Math.PI / 3;
- this.penumbra = penumbra !== void 0 ? penumbra : 0;
- this.decay = decay !== void 0 ? decay : 1;
- this.shadow = new SpotLightShadow();
- }
- SpotLight.prototype = Object.assign(Object.create(Light.prototype), {
- constructor: SpotLight,
- isSpotLight: true,
- copy: function(source) {
- Light.prototype.copy.call(this, source);
- this.distance = source.distance;
- this.angle = source.angle;
- this.penumbra = source.penumbra;
- this.decay = source.decay;
- this.target = source.target.clone();
- this.shadow = source.shadow.clone();
- return this;
- }
- });
- function PointLightShadow() {
- LightShadow.call(this, new PerspectiveCamera(90, 1, 0.5, 500));
- this._frameExtents = new Vector2(4, 2);
- this._viewportCount = 6;
- this._viewports = [
- // These viewports map a cube-map onto a 2D texture with the
- // following orientation:
- //
- // xzXZ
- // y Y
- //
- // X - Positive x direction
- // x - Negative x direction
- // Y - Positive y direction
- // y - Negative y direction
- // Z - Positive z direction
- // z - Negative z direction
- // positive X
- new Vector4(2, 1, 1, 1),
- // negative X
- new Vector4(0, 1, 1, 1),
- // positive Z
- new Vector4(3, 1, 1, 1),
- // negative Z
- new Vector4(1, 1, 1, 1),
- // positive Y
- new Vector4(3, 0, 1, 1),
- // negative Y
- new Vector4(1, 0, 1, 1)
- ];
- this._cubeDirections = [
- new Vector3(1, 0, 0),
- new Vector3(-1, 0, 0),
- new Vector3(0, 0, 1),
- new Vector3(0, 0, -1),
- new Vector3(0, 1, 0),
- new Vector3(0, -1, 0)
- ];
- this._cubeUps = [
- new Vector3(0, 1, 0),
- new Vector3(0, 1, 0),
- new Vector3(0, 1, 0),
- new Vector3(0, 1, 0),
- new Vector3(0, 0, 1),
- new Vector3(0, 0, -1)
- ];
- }
- PointLightShadow.prototype = Object.assign(Object.create(LightShadow.prototype), {
- constructor: PointLightShadow,
- isPointLightShadow: true,
- updateMatrices: function(light, viewportIndex) {
- if (viewportIndex === void 0)
- viewportIndex = 0;
- var camera = this.camera, shadowMatrix = this.matrix, lightPositionWorld = this._lightPositionWorld, lookTarget = this._lookTarget, projScreenMatrix = this._projScreenMatrix;
- lightPositionWorld.setFromMatrixPosition(light.matrixWorld);
- camera.position.copy(lightPositionWorld);
- lookTarget.copy(camera.position);
- lookTarget.add(this._cubeDirections[viewportIndex]);
- camera.up.copy(this._cubeUps[viewportIndex]);
- camera.lookAt(lookTarget);
- camera.updateMatrixWorld();
- shadowMatrix.makeTranslation(-lightPositionWorld.x, -lightPositionWorld.y, -lightPositionWorld.z);
- projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
- this._frustum.setFromProjectionMatrix(projScreenMatrix);
- }
- });
- function PointLight(color, intensity, distance, decay) {
- Light.call(this, color, intensity);
- this.type = "PointLight";
- Object.defineProperty(this, "power", {
- get: function() {
- return this.intensity * 4 * Math.PI;
- },
- set: function(power) {
- this.intensity = power / (4 * Math.PI);
- }
- });
- this.distance = distance !== void 0 ? distance : 0;
- this.decay = decay !== void 0 ? decay : 1;
- this.shadow = new PointLightShadow();
- }
- PointLight.prototype = Object.assign(Object.create(Light.prototype), {
- constructor: PointLight,
- isPointLight: true,
- copy: function(source) {
- Light.prototype.copy.call(this, source);
- this.distance = source.distance;
- this.decay = source.decay;
- this.shadow = source.shadow.clone();
- return this;
- }
- });
- function OrthographicCamera(left, right, top2, bottom, near, far) {
- Camera.call(this);
- this.type = "OrthographicCamera";
- this.zoom = 1;
- this.view = null;
- this.left = left !== void 0 ? left : -1;
- this.right = right !== void 0 ? right : 1;
- this.top = top2 !== void 0 ? top2 : 1;
- this.bottom = bottom !== void 0 ? bottom : -1;
- this.near = near !== void 0 ? near : 0.1;
- this.far = far !== void 0 ? far : 2e3;
- this.updateProjectionMatrix();
- }
- OrthographicCamera.prototype = Object.assign(Object.create(Camera.prototype), {
- constructor: OrthographicCamera,
- isOrthographicCamera: true,
- copy: function(source, recursive) {
- Camera.prototype.copy.call(this, source, recursive);
- this.left = source.left;
- this.right = source.right;
- this.top = source.top;
- this.bottom = source.bottom;
- this.near = source.near;
- this.far = source.far;
- this.zoom = source.zoom;
- this.view = source.view === null ? null : Object.assign({}, source.view);
- return this;
- },
- setViewOffset: function(fullWidth, fullHeight, x, y, width, height) {
- if (this.view === null) {
- this.view = {
- enabled: true,
- fullWidth: 1,
- fullHeight: 1,
- offsetX: 0,
- offsetY: 0,
- width: 1,
- height: 1
- };
- }
- this.view.enabled = true;
- this.view.fullWidth = fullWidth;
- this.view.fullHeight = fullHeight;
- this.view.offsetX = x;
- this.view.offsetY = y;
- this.view.width = width;
- this.view.height = height;
- this.updateProjectionMatrix();
- },
- clearViewOffset: function() {
- if (this.view !== null) {
- this.view.enabled = false;
- }
- this.updateProjectionMatrix();
- },
- updateProjectionMatrix: function() {
- var dx = (this.right - this.left) / (2 * this.zoom);
- var dy = (this.top - this.bottom) / (2 * this.zoom);
- var cx = (this.right + this.left) / 2;
- var cy = (this.top + this.bottom) / 2;
- var left = cx - dx;
- var right = cx + dx;
- var top2 = cy + dy;
- var bottom = cy - dy;
- if (this.view !== null && this.view.enabled) {
- var scaleW = (this.right - this.left) / this.view.fullWidth / this.zoom;
- var scaleH = (this.top - this.bottom) / this.view.fullHeight / this.zoom;
- left += scaleW * this.view.offsetX;
- right = left + scaleW * this.view.width;
- top2 -= scaleH * this.view.offsetY;
- bottom = top2 - scaleH * this.view.height;
- }
- this.projectionMatrix.makeOrthographic(left, right, top2, bottom, this.near, this.far);
- this.projectionMatrixInverse.getInverse(this.projectionMatrix);
- },
- toJSON: function(meta) {
- var data = Object3D.prototype.toJSON.call(this, meta);
- data.object.zoom = this.zoom;
- data.object.left = this.left;
- data.object.right = this.right;
- data.object.top = this.top;
- data.object.bottom = this.bottom;
- data.object.near = this.near;
- data.object.far = this.far;
- if (this.view !== null)
- data.object.view = Object.assign({}, this.view);
- return data;
- }
- });
- function DirectionalLightShadow() {
- LightShadow.call(this, new OrthographicCamera(-5, 5, 5, -5, 0.5, 500));
- }
- DirectionalLightShadow.prototype = Object.assign(Object.create(LightShadow.prototype), {
- constructor: DirectionalLightShadow,
- isDirectionalLightShadow: true,
- updateMatrices: function(light) {
- LightShadow.prototype.updateMatrices.call(this, light);
- }
- });
- function DirectionalLight(color, intensity) {
- Light.call(this, color, intensity);
- this.type = "DirectionalLight";
- this.position.copy(Object3D.DefaultUp);
- this.updateMatrix();
- this.target = new Object3D();
- this.shadow = new DirectionalLightShadow();
- }
- DirectionalLight.prototype = Object.assign(Object.create(Light.prototype), {
- constructor: DirectionalLight,
- isDirectionalLight: true,
- copy: function(source) {
- Light.prototype.copy.call(this, source);
- this.target = source.target.clone();
- this.shadow = source.shadow.clone();
- return this;
- }
- });
- function AmbientLight(color, intensity) {
- Light.call(this, color, intensity);
- this.type = "AmbientLight";
- this.castShadow = void 0;
- }
- AmbientLight.prototype = Object.assign(Object.create(Light.prototype), {
- constructor: AmbientLight,
- isAmbientLight: true
- });
- function RectAreaLight(color, intensity, width, height) {
- Light.call(this, color, intensity);
- this.type = "RectAreaLight";
- this.width = width !== void 0 ? width : 10;
- this.height = height !== void 0 ? height : 10;
- }
- RectAreaLight.prototype = Object.assign(Object.create(Light.prototype), {
- constructor: RectAreaLight,
- isRectAreaLight: true,
- copy: function(source) {
- Light.prototype.copy.call(this, source);
- this.width = source.width;
- this.height = source.height;
- return this;
- },
- toJSON: function(meta) {
- var data = Light.prototype.toJSON.call(this, meta);
- data.object.width = this.width;
- data.object.height = this.height;
- return data;
- }
- });
- function MaterialLoader(manager) {
- Loader.call(this, manager);
- this.textures = {};
- }
- MaterialLoader.prototype = Object.assign(Object.create(Loader.prototype), {
- constructor: MaterialLoader,
- load: function(url, onLoad, onProgress, onError) {
- var scope = this;
- var loader = new FileLoader(scope.manager);
- loader.setPath(scope.path);
- loader.load(url, function(text) {
- onLoad(scope.parse(JSON.parse(text)));
- }, onProgress, onError);
- },
- parse: function(json) {
- var textures = this.textures;
- function getTexture(name2) {
- if (textures[name2] === void 0) {
- console.warn("THREE.MaterialLoader: Undefined texture", name2);
- }
- return textures[name2];
- }
- var material = new Materials[json.type]();
- if (json.uuid !== void 0)
- material.uuid = json.uuid;
- if (json.name !== void 0)
- material.name = json.name;
- if (json.color !== void 0)
- material.color.setHex(json.color);
- if (json.roughness !== void 0)
- material.roughness = json.roughness;
- if (json.metalness !== void 0)
- material.metalness = json.metalness;
- if (json.sheen !== void 0)
- material.sheen = new Color().setHex(json.sheen);
- if (json.emissive !== void 0)
- material.emissive.setHex(json.emissive);
- if (json.specular !== void 0)
- material.specular.setHex(json.specular);
- if (json.shininess !== void 0)
- material.shininess = json.shininess;
- if (json.clearcoat !== void 0)
- material.clearcoat = json.clearcoat;
- if (json.clearcoatRoughness !== void 0)
- material.clearcoatRoughness = json.clearcoatRoughness;
- if (json.vertexColors !== void 0)
- material.vertexColors = json.vertexColors;
- if (json.fog !== void 0)
- material.fog = json.fog;
- if (json.flatShading !== void 0)
- material.flatShading = json.flatShading;
- if (json.blending !== void 0)
- material.blending = json.blending;
- if (json.combine !== void 0)
- material.combine = json.combine;
- if (json.side !== void 0)
- material.side = json.side;
- if (json.opacity !== void 0)
- material.opacity = json.opacity;
- if (json.transparent !== void 0)
- material.transparent = json.transparent;
- if (json.alphaTest !== void 0)
- material.alphaTest = json.alphaTest;
- if (json.depthTest !== void 0)
- material.depthTest = json.depthTest;
- if (json.depthWrite !== void 0)
- material.depthWrite = json.depthWrite;
- if (json.colorWrite !== void 0)
- material.colorWrite = json.colorWrite;
- if (json.stencilWrite !== void 0)
- material.stencilWrite = json.stencilWrite;
- if (json.stencilWriteMask !== void 0)
- material.stencilWriteMask = json.stencilWriteMask;
- if (json.stencilFunc !== void 0)
- material.stencilFunc = json.stencilFunc;
- if (json.stencilRef !== void 0)
- material.stencilRef = json.stencilRef;
- if (json.stencilFuncMask !== void 0)
- material.stencilFuncMask = json.stencilFuncMask;
- if (json.stencilFail !== void 0)
- material.stencilFail = json.stencilFail;
- if (json.stencilZFail !== void 0)
- material.stencilZFail = json.stencilZFail;
- if (json.stencilZPass !== void 0)
- material.stencilZPass = json.stencilZPass;
- if (json.wireframe !== void 0)
- material.wireframe = json.wireframe;
- if (json.wireframeLinewidth !== void 0)
- material.wireframeLinewidth = json.wireframeLinewidth;
- if (json.wireframeLinecap !== void 0)
- material.wireframeLinecap = json.wireframeLinecap;
- if (json.wireframeLinejoin !== void 0)
- material.wireframeLinejoin = json.wireframeLinejoin;
- if (json.rotation !== void 0)
- material.rotation = json.rotation;
- if (json.linewidth !== 1)
- material.linewidth = json.linewidth;
- if (json.dashSize !== void 0)
- material.dashSize = json.dashSize;
- if (json.gapSize !== void 0)
- material.gapSize = json.gapSize;
- if (json.scale !== void 0)
- material.scale = json.scale;
- if (json.polygonOffset !== void 0)
- material.polygonOffset = json.polygonOffset;
- if (json.polygonOffsetFactor !== void 0)
- material.polygonOffsetFactor = json.polygonOffsetFactor;
- if (json.polygonOffsetUnits !== void 0)
- material.polygonOffsetUnits = json.polygonOffsetUnits;
- if (json.skinning !== void 0)
- material.skinning = json.skinning;
- if (json.morphTargets !== void 0)
- material.morphTargets = json.morphTargets;
- if (json.morphNormals !== void 0)
- material.morphNormals = json.morphNormals;
- if (json.dithering !== void 0)
- material.dithering = json.dithering;
- if (json.visible !== void 0)
- material.visible = json.visible;
- if (json.toneMapped !== void 0)
- material.toneMapped = json.toneMapped;
- if (json.userData !== void 0)
- material.userData = json.userData;
- if (json.uniforms !== void 0) {
- for (var name in json.uniforms) {
- var uniform = json.uniforms[name];
- material.uniforms[name] = {};
- switch (uniform.type) {
- case "t":
- material.uniforms[name].value = getTexture(uniform.value);
- break;
- case "c":
- material.uniforms[name].value = new Color().setHex(uniform.value);
- break;
- case "v2":
- material.uniforms[name].value = new Vector2().fromArray(uniform.value);
- break;
- case "v3":
- material.uniforms[name].value = new Vector3().fromArray(uniform.value);
- break;
- case "v4":
- material.uniforms[name].value = new Vector4().fromArray(uniform.value);
- break;
- case "m3":
- material.uniforms[name].value = new Matrix3().fromArray(uniform.value);
- case "m4":
- material.uniforms[name].value = new Matrix4().fromArray(uniform.value);
- break;
- default:
- material.uniforms[name].value = uniform.value;
- }
- }
- }
- if (json.defines !== void 0)
- material.defines = json.defines;
- if (json.vertexShader !== void 0)
- material.vertexShader = json.vertexShader;
- if (json.fragmentShader !== void 0)
- material.fragmentShader = json.fragmentShader;
- if (json.extensions !== void 0) {
- for (var key in json.extensions) {
- material.extensions[key] = json.extensions[key];
- }
- }
- if (json.shading !== void 0)
- material.flatShading = json.shading === 1;
- if (json.size !== void 0)
- material.size = json.size;
- if (json.sizeAttenuation !== void 0)
- material.sizeAttenuation = json.sizeAttenuation;
- if (json.map !== void 0)
- material.map = getTexture(json.map);
- if (json.matcap !== void 0)
- material.matcap = getTexture(json.matcap);
- if (json.alphaMap !== void 0) {
- material.alphaMap = getTexture(json.alphaMap);
- material.transparent = true;
- }
- if (json.bumpMap !== void 0)
- material.bumpMap = getTexture(json.bumpMap);
- if (json.bumpScale !== void 0)
- material.bumpScale = json.bumpScale;
- if (json.normalMap !== void 0)
- material.normalMap = getTexture(json.normalMap);
- if (json.normalMapType !== void 0)
- material.normalMapType = json.normalMapType;
- if (json.normalScale !== void 0) {
- var normalScale = json.normalScale;
- if (Array.isArray(normalScale) === false) {
- normalScale = [normalScale, normalScale];
- }
- material.normalScale = new Vector2().fromArray(normalScale);
- }
- if (json.displacementMap !== void 0)
- material.displacementMap = getTexture(json.displacementMap);
- if (json.displacementScale !== void 0)
- material.displacementScale = json.displacementScale;
- if (json.displacementBias !== void 0)
- material.displacementBias = json.displacementBias;
- if (json.roughnessMap !== void 0)
- material.roughnessMap = getTexture(json.roughnessMap);
- if (json.metalnessMap !== void 0)
- material.metalnessMap = getTexture(json.metalnessMap);
- if (json.emissiveMap !== void 0)
- material.emissiveMap = getTexture(json.emissiveMap);
- if (json.emissiveIntensity !== void 0)
- material.emissiveIntensity = json.emissiveIntensity;
- if (json.specularMap !== void 0)
- material.specularMap = getTexture(json.specularMap);
- if (json.envMap !== void 0)
- material.envMap = getTexture(json.envMap);
- if (json.envMapIntensity !== void 0)
- material.envMapIntensity = json.envMapIntensity;
- if (json.reflectivity !== void 0)
- material.reflectivity = json.reflectivity;
- if (json.refractionRatio !== void 0)
- material.refractionRatio = json.refractionRatio;
- if (json.lightMap !== void 0)
- material.lightMap = getTexture(json.lightMap);
- if (json.lightMapIntensity !== void 0)
- material.lightMapIntensity = json.lightMapIntensity;
- if (json.aoMap !== void 0)
- material.aoMap = getTexture(json.aoMap);
- if (json.aoMapIntensity !== void 0)
- material.aoMapIntensity = json.aoMapIntensity;
- if (json.gradientMap !== void 0)
- material.gradientMap = getTexture(json.gradientMap);
- if (json.clearcoatNormalMap !== void 0)
- material.clearcoatNormalMap = getTexture(json.clearcoatNormalMap);
- if (json.clearcoatNormalScale !== void 0)
- material.clearcoatNormalScale = new Vector2().fromArray(json.clearcoatNormalScale);
- return material;
- },
- setTextures: function(value) {
- this.textures = value;
- return this;
- }
- });
- var LoaderUtils = {
- decodeText: function(array) {
- if (typeof TextDecoder !== "undefined") {
- return new TextDecoder().decode(array);
- }
- var s = "";
- for (var i2 = 0, il = array.length; i2 < il; i2++) {
- s += String.fromCharCode(array[i2]);
- }
- try {
- return decodeURIComponent(escape(s));
- } catch (e) {
- return s;
- }
- },
- extractUrlBase: function(url) {
- var index = url.lastIndexOf("/");
- if (index === -1)
- return "./";
- return url.substr(0, index + 1);
- }
- };
- function InstancedBufferGeometry() {
- BufferGeometry.call(this);
- this.type = "InstancedBufferGeometry";
- this.maxInstancedCount = void 0;
- }
- InstancedBufferGeometry.prototype = Object.assign(Object.create(BufferGeometry.prototype), {
- constructor: InstancedBufferGeometry,
- isInstancedBufferGeometry: true,
- copy: function(source) {
- BufferGeometry.prototype.copy.call(this, source);
- this.maxInstancedCount = source.maxInstancedCount;
- return this;
- },
- clone: function() {
- return new this.constructor().copy(this);
- },
- toJSON: function() {
- var data = BufferGeometry.prototype.toJSON.call(this);
- data.maxInstancedCount = this.maxInstancedCount;
- data.isInstancedBufferGeometry = true;
- return data;
- }
- });
- function InstancedBufferAttribute(array, itemSize, normalized, meshPerAttribute) {
- if (typeof normalized === "number") {
- meshPerAttribute = normalized;
- normalized = false;
- console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.");
- }
- BufferAttribute.call(this, array, itemSize, normalized);
- this.meshPerAttribute = meshPerAttribute || 1;
- }
- InstancedBufferAttribute.prototype = Object.assign(Object.create(BufferAttribute.prototype), {
- constructor: InstancedBufferAttribute,
- isInstancedBufferAttribute: true,
- copy: function(source) {
- BufferAttribute.prototype.copy.call(this, source);
- this.meshPerAttribute = source.meshPerAttribute;
- return this;
- },
- toJSON: function() {
- var data = BufferAttribute.prototype.toJSON.call(this);
- data.meshPerAttribute = this.meshPerAttribute;
- data.isInstancedBufferAttribute = true;
- return data;
- }
- });
- function BufferGeometryLoader(manager) {
- Loader.call(this, manager);
- }
- BufferGeometryLoader.prototype = Object.assign(Object.create(Loader.prototype), {
- constructor: BufferGeometryLoader,
- load: function(url, onLoad, onProgress, onError) {
- var scope = this;
- var loader = new FileLoader(scope.manager);
- loader.setPath(scope.path);
- loader.load(url, function(text) {
- onLoad(scope.parse(JSON.parse(text)));
- }, onProgress, onError);
- },
- parse: function(json) {
- var geometry = json.isInstancedBufferGeometry ? new InstancedBufferGeometry() : new BufferGeometry();
- var index = json.data.index;
- if (index !== void 0) {
- var typedArray = new TYPED_ARRAYS[index.type](index.array);
- geometry.setIndex(new BufferAttribute(typedArray, 1));
- }
- var attributes = json.data.attributes;
- for (var key in attributes) {
- var attribute = attributes[key];
- var typedArray = new TYPED_ARRAYS[attribute.type](attribute.array);
- var bufferAttributeConstr = attribute.isInstancedBufferAttribute ? InstancedBufferAttribute : BufferAttribute;
- var bufferAttribute = new bufferAttributeConstr(typedArray, attribute.itemSize, attribute.normalized);
- if (attribute.name !== void 0)
- bufferAttribute.name = attribute.name;
- geometry.setAttribute(key, bufferAttribute);
- }
- var morphAttributes = json.data.morphAttributes;
- if (morphAttributes) {
- for (var key in morphAttributes) {
- var attributeArray = morphAttributes[key];
- var array = [];
- for (var i2 = 0, il = attributeArray.length; i2 < il; i2++) {
- var attribute = attributeArray[i2];
- var typedArray = new TYPED_ARRAYS[attribute.type](attribute.array);
- var bufferAttribute = new BufferAttribute(typedArray, attribute.itemSize, attribute.normalized);
- if (attribute.name !== void 0)
- bufferAttribute.name = attribute.name;
- array.push(bufferAttribute);
- }
- geometry.morphAttributes[key] = array;
- }
- }
- var morphTargetsRelative = json.data.morphTargetsRelative;
- if (morphTargetsRelative) {
- geometry.morphTargetsRelative = true;
- }
- var groups = json.data.groups || json.data.drawcalls || json.data.offsets;
- if (groups !== void 0) {
- for (var i2 = 0, n = groups.length; i2 !== n; ++i2) {
- var group = groups[i2];
- geometry.addGroup(group.start, group.count, group.materialIndex);
- }
- }
- var boundingSphere = json.data.boundingSphere;
- if (boundingSphere !== void 0) {
- var center = new Vector3();
- if (boundingSphere.center !== void 0) {
- center.fromArray(boundingSphere.center);
- }
- geometry.boundingSphere = new Sphere(center, boundingSphere.radius);
- }
- if (json.name)
- geometry.name = json.name;
- if (json.userData)
- geometry.userData = json.userData;
- return geometry;
- }
- });
- var TYPED_ARRAYS = {
- Int8Array,
- Uint8Array,
- // Workaround for IE11 pre KB2929437. See #11440
- Uint8ClampedArray: typeof Uint8ClampedArray !== "undefined" ? Uint8ClampedArray : Uint8Array,
- Int16Array,
- Uint16Array,
- Int32Array,
- Uint32Array,
- Float32Array,
- Float64Array
- };
- function ObjectLoader(manager) {
- Loader.call(this, manager);
- }
- ObjectLoader.prototype = Object.assign(Object.create(Loader.prototype), {
- constructor: ObjectLoader,
- load: function(url, onLoad, onProgress, onError) {
- var scope = this;
- var path = this.path === "" ? LoaderUtils.extractUrlBase(url) : this.path;
- this.resourcePath = this.resourcePath || path;
- var loader = new FileLoader(scope.manager);
- loader.setPath(this.path);
- loader.load(url, function(text) {
- var json = null;
- try {
- json = JSON.parse(text);
- } catch (error) {
- if (onError !== void 0)
- onError(error);
- console.error("THREE:ObjectLoader: Can't parse " + url + ".", error.message);
- return;
- }
- var metadata = json.metadata;
- if (metadata === void 0 || metadata.type === void 0 || metadata.type.toLowerCase() === "geometry") {
- console.error("THREE.ObjectLoader: Can't load " + url);
- return;
- }
- scope.parse(json, onLoad);
- }, onProgress, onError);
- },
- parse: function(json, onLoad) {
- var shapes = this.parseShape(json.shapes);
- var geometries = this.parseGeometries(json.geometries, shapes);
- var images = this.parseImages(json.images, function() {
- if (onLoad !== void 0)
- onLoad(object);
- });
- var textures = this.parseTextures(json.textures, images);
- var materials = this.parseMaterials(json.materials, textures);
- var object = this.parseObject(json.object, geometries, materials);
- if (json.animations) {
- object.animations = this.parseAnimations(json.animations);
- }
- if (json.images === void 0 || json.images.length === 0) {
- if (onLoad !== void 0)
- onLoad(object);
- }
- return object;
- },
- parseShape: function(json) {
- var shapes = {};
- if (json !== void 0) {
- for (var i2 = 0, l = json.length; i2 < l; i2++) {
- var shape = new Shape().fromJSON(json[i2]);
- shapes[shape.uuid] = shape;
- }
- }
- return shapes;
- },
- parseGeometries: function(json, shapes) {
- var geometries = {};
- if (json !== void 0) {
- var bufferGeometryLoader = new BufferGeometryLoader();
- for (var i2 = 0, l = json.length; i2 < l; i2++) {
- var geometry;
- var data = json[i2];
- switch (data.type) {
- case "PlaneGeometry":
- case "PlaneBufferGeometry":
- geometry = new Geometries[data.type](
- data.width,
- data.height,
- data.widthSegments,
- data.heightSegments
- );
- break;
- case "BoxGeometry":
- case "BoxBufferGeometry":
- case "CubeGeometry":
- geometry = new Geometries[data.type](
- data.width,
- data.height,
- data.depth,
- data.widthSegments,
- data.heightSegments,
- data.depthSegments
- );
- break;
- case "CircleGeometry":
- case "CircleBufferGeometry":
- geometry = new Geometries[data.type](
- data.radius,
- data.segments,
- data.thetaStart,
- data.thetaLength
- );
- break;
- case "CylinderGeometry":
- case "CylinderBufferGeometry":
- geometry = new Geometries[data.type](
- data.radiusTop,
- data.radiusBottom,
- data.height,
- data.radialSegments,
- data.heightSegments,
- data.openEnded,
- data.thetaStart,
- data.thetaLength
- );
- break;
- case "ConeGeometry":
- case "ConeBufferGeometry":
- geometry = new Geometries[data.type](
- data.radius,
- data.height,
- data.radialSegments,
- data.heightSegments,
- data.openEnded,
- data.thetaStart,
- data.thetaLength
- );
- break;
- case "SphereGeometry":
- case "SphereBufferGeometry":
- geometry = new Geometries[data.type](
- data.radius,
- data.widthSegments,
- data.heightSegments,
- data.phiStart,
- data.phiLength,
- data.thetaStart,
- data.thetaLength
- );
- break;
- case "DodecahedronGeometry":
- case "DodecahedronBufferGeometry":
- case "IcosahedronGeometry":
- case "IcosahedronBufferGeometry":
- case "OctahedronGeometry":
- case "OctahedronBufferGeometry":
- case "TetrahedronGeometry":
- case "TetrahedronBufferGeometry":
- geometry = new Geometries[data.type](
- data.radius,
- data.detail
- );
- break;
- case "RingGeometry":
- case "RingBufferGeometry":
- geometry = new Geometries[data.type](
- data.innerRadius,
- data.outerRadius,
- data.thetaSegments,
- data.phiSegments,
- data.thetaStart,
- data.thetaLength
- );
- break;
- case "TorusGeometry":
- case "TorusBufferGeometry":
- geometry = new Geometries[data.type](
- data.radius,
- data.tube,
- data.radialSegments,
- data.tubularSegments,
- data.arc
- );
- break;
- case "TorusKnotGeometry":
- case "TorusKnotBufferGeometry":
- geometry = new Geometries[data.type](
- data.radius,
- data.tube,
- data.tubularSegments,
- data.radialSegments,
- data.p,
- data.q
- );
- break;
- case "TubeGeometry":
- case "TubeBufferGeometry":
- geometry = new Geometries[data.type](
- new Curves[data.path.type]().fromJSON(data.path),
- data.tubularSegments,
- data.radius,
- data.radialSegments,
- data.closed
- );
- break;
- case "LatheGeometry":
- case "LatheBufferGeometry":
- geometry = new Geometries[data.type](
- data.points,
- data.segments,
- data.phiStart,
- data.phiLength
- );
- break;
- case "PolyhedronGeometry":
- case "PolyhedronBufferGeometry":
- geometry = new Geometries[data.type](
- data.vertices,
- data.indices,
- data.radius,
- data.details
- );
- break;
- case "ShapeGeometry":
- case "ShapeBufferGeometry":
- var geometryShapes = [];
- for (var j = 0, jl = data.shapes.length; j < jl; j++) {
- var shape = shapes[data.shapes[j]];
- geometryShapes.push(shape);
- }
- geometry = new Geometries[data.type](
- geometryShapes,
- data.curveSegments
- );
- break;
- case "ExtrudeGeometry":
- case "ExtrudeBufferGeometry":
- var geometryShapes = [];
- for (var j = 0, jl = data.shapes.length; j < jl; j++) {
- var shape = shapes[data.shapes[j]];
- geometryShapes.push(shape);
- }
- var extrudePath = data.options.extrudePath;
- if (extrudePath !== void 0) {
- data.options.extrudePath = new Curves[extrudePath.type]().fromJSON(extrudePath);
- }
- geometry = new Geometries[data.type](
- geometryShapes,
- data.options
- );
- break;
- case "BufferGeometry":
- case "InstancedBufferGeometry":
- geometry = bufferGeometryLoader.parse(data);
- break;
- case "Geometry":
- if ("THREE" in window && "LegacyJSONLoader" in THREE) {
- var geometryLoader = new THREE.LegacyJSONLoader();
- geometry = geometryLoader.parse(data, this.resourcePath).geometry;
- } else {
- console.error('THREE.ObjectLoader: You have to import LegacyJSONLoader in order load geometry data of type "Geometry".');
- }
- break;
- default:
- console.warn('THREE.ObjectLoader: Unsupported geometry type "' + data.type + '"');
- continue;
- }
- geometry.uuid = data.uuid;
- if (data.name !== void 0)
- geometry.name = data.name;
- if (geometry.isBufferGeometry === true && data.userData !== void 0)
- geometry.userData = data.userData;
- geometries[data.uuid] = geometry;
- }
- }
- return geometries;
- },
- parseMaterials: function(json, textures) {
- var cache = {};
- var materials = {};
- if (json !== void 0) {
- var loader = new MaterialLoader();
- loader.setTextures(textures);
- for (var i2 = 0, l = json.length; i2 < l; i2++) {
- var data = json[i2];
- if (data.type === "MultiMaterial") {
- var array = [];
- for (var j = 0; j < data.materials.length; j++) {
- var material = data.materials[j];
- if (cache[material.uuid] === void 0) {
- cache[material.uuid] = loader.parse(material);
- }
- array.push(cache[material.uuid]);
- }
- materials[data.uuid] = array;
- } else {
- if (cache[data.uuid] === void 0) {
- cache[data.uuid] = loader.parse(data);
- }
- materials[data.uuid] = cache[data.uuid];
- }
- }
- }
- return materials;
- },
- parseAnimations: function(json) {
- var animations = [];
- for (var i2 = 0; i2 < json.length; i2++) {
- var data = json[i2];
- var clip = AnimationClip.parse(data);
- if (data.uuid !== void 0)
- clip.uuid = data.uuid;
- animations.push(clip);
- }
- return animations;
- },
- parseImages: function(json, onLoad) {
- var scope = this;
- var images = {};
- function loadImage(url2) {
- scope.manager.itemStart(url2);
- return loader.load(url2, function() {
- scope.manager.itemEnd(url2);
- }, void 0, function() {
- scope.manager.itemError(url2);
- scope.manager.itemEnd(url2);
- });
- }
- if (json !== void 0 && json.length > 0) {
- var manager = new LoadingManager(onLoad);
- var loader = new ImageLoader(manager);
- loader.setCrossOrigin(this.crossOrigin);
- for (var i2 = 0, il = json.length; i2 < il; i2++) {
- var image = json[i2];
- var url = image.url;
- if (Array.isArray(url)) {
- images[image.uuid] = [];
- for (var j = 0, jl = url.length; j < jl; j++) {
- var currentUrl = url[j];
- var path = /^(\/\/)|([a-z]+:(\/\/)?)/i.test(currentUrl) ? currentUrl : scope.resourcePath + currentUrl;
- images[image.uuid].push(loadImage(path));
- }
- } else {
- var path = /^(\/\/)|([a-z]+:(\/\/)?)/i.test(image.url) ? image.url : scope.resourcePath + image.url;
- images[image.uuid] = loadImage(path);
- }
- }
- }
- return images;
- },
- parseTextures: function(json, images) {
- function parseConstant(value, type) {
- if (typeof value === "number")
- return value;
- console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.", value);
- return type[value];
- }
- var textures = {};
- if (json !== void 0) {
- for (var i2 = 0, l = json.length; i2 < l; i2++) {
- var data = json[i2];
- if (data.image === void 0) {
- console.warn('THREE.ObjectLoader: No "image" specified for', data.uuid);
- }
- if (images[data.image] === void 0) {
- console.warn("THREE.ObjectLoader: Undefined image", data.image);
- }
- var texture;
- if (Array.isArray(images[data.image])) {
- texture = new CubeTexture(images[data.image]);
- } else {
- texture = new Texture(images[data.image]);
- }
- texture.needsUpdate = true;
- texture.uuid = data.uuid;
- if (data.name !== void 0)
- texture.name = data.name;
- if (data.mapping !== void 0)
- texture.mapping = parseConstant(data.mapping, TEXTURE_MAPPING);
- if (data.offset !== void 0)
- texture.offset.fromArray(data.offset);
- if (data.repeat !== void 0)
- texture.repeat.fromArray(data.repeat);
- if (data.center !== void 0)
- texture.center.fromArray(data.center);
- if (data.rotation !== void 0)
- texture.rotation = data.rotation;
- if (data.wrap !== void 0) {
- texture.wrapS = parseConstant(data.wrap[0], TEXTURE_WRAPPING);
- texture.wrapT = parseConstant(data.wrap[1], TEXTURE_WRAPPING);
- }
- if (data.format !== void 0)
- texture.format = data.format;
- if (data.type !== void 0)
- texture.type = data.type;
- if (data.encoding !== void 0)
- texture.encoding = data.encoding;
- if (data.minFilter !== void 0)
- texture.minFilter = parseConstant(data.minFilter, TEXTURE_FILTER);
- if (data.magFilter !== void 0)
- texture.magFilter = parseConstant(data.magFilter, TEXTURE_FILTER);
- if (data.anisotropy !== void 0)
- texture.anisotropy = data.anisotropy;
- if (data.flipY !== void 0)
- texture.flipY = data.flipY;
- if (data.premultiplyAlpha !== void 0)
- texture.premultiplyAlpha = data.premultiplyAlpha;
- if (data.unpackAlignment !== void 0)
- texture.unpackAlignment = data.unpackAlignment;
- textures[data.uuid] = texture;
- }
- }
- return textures;
- },
- parseObject: function(data, geometries, materials) {
- var object;
- function getGeometry(name) {
- if (geometries[name] === void 0) {
- console.warn("THREE.ObjectLoader: Undefined geometry", name);
- }
- return geometries[name];
- }
- function getMaterial(name) {
- if (name === void 0)
- return void 0;
- if (Array.isArray(name)) {
- var array = [];
- for (var i3 = 0, l2 = name.length; i3 < l2; i3++) {
- var uuid = name[i3];
- if (materials[uuid] === void 0) {
- console.warn("THREE.ObjectLoader: Undefined material", uuid);
- }
- array.push(materials[uuid]);
- }
- return array;
- }
- if (materials[name] === void 0) {
- console.warn("THREE.ObjectLoader: Undefined material", name);
- }
- return materials[name];
- }
- switch (data.type) {
- case "Scene":
- object = new Scene();
- if (data.background !== void 0) {
- if (Number.isInteger(data.background)) {
- object.background = new Color(data.background);
- }
- }
- if (data.fog !== void 0) {
- if (data.fog.type === "Fog") {
- object.fog = new Fog(data.fog.color, data.fog.near, data.fog.far);
- } else if (data.fog.type === "FogExp2") {
- object.fog = new FogExp2(data.fog.color, data.fog.density);
- }
- }
- break;
- case "PerspectiveCamera":
- object = new PerspectiveCamera(data.fov, data.aspect, data.near, data.far);
- if (data.focus !== void 0)
- object.focus = data.focus;
- if (data.zoom !== void 0)
- object.zoom = data.zoom;
- if (data.filmGauge !== void 0)
- object.filmGauge = data.filmGauge;
- if (data.filmOffset !== void 0)
- object.filmOffset = data.filmOffset;
- if (data.view !== void 0)
- object.view = Object.assign({}, data.view);
- break;
- case "OrthographicCamera":
- object = new OrthographicCamera(data.left, data.right, data.top, data.bottom, data.near, data.far);
- if (data.zoom !== void 0)
- object.zoom = data.zoom;
- if (data.view !== void 0)
- object.view = Object.assign({}, data.view);
- break;
- case "AmbientLight":
- object = new AmbientLight(data.color, data.intensity);
- break;
- case "DirectionalLight":
- object = new DirectionalLight(data.color, data.intensity);
- break;
- case "PointLight":
- object = new PointLight(data.color, data.intensity, data.distance, data.decay);
- break;
- case "RectAreaLight":
- object = new RectAreaLight(data.color, data.intensity, data.width, data.height);
- break;
- case "SpotLight":
- object = new SpotLight(data.color, data.intensity, data.distance, data.angle, data.penumbra, data.decay);
- break;
- case "HemisphereLight":
- object = new HemisphereLight(data.color, data.groundColor, data.intensity);
- break;
- case "SkinnedMesh":
- console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.");
- case "Mesh":
- var geometry = getGeometry(data.geometry);
- var material = getMaterial(data.material);
- if (geometry.bones && geometry.bones.length > 0) {
- object = new SkinnedMesh(geometry, material);
- } else {
- object = new Mesh(geometry, material);
- }
- break;
- case "InstancedMesh":
- var geometry = getGeometry(data.geometry);
- var material = getMaterial(data.material);
- var count = data.count;
- var instanceMatrix = data.instanceMatrix;
- object = new InstancedMesh(geometry, material, count);
- object.instanceMatrix = new BufferAttribute(new Float32Array(instanceMatrix.array), 16);
- break;
- case "LOD":
- object = new LOD();
- break;
- case "Line":
- object = new Line(getGeometry(data.geometry), getMaterial(data.material), data.mode);
- break;
- case "LineLoop":
- object = new LineLoop(getGeometry(data.geometry), getMaterial(data.material));
- break;
- case "LineSegments":
- object = new LineSegments(getGeometry(data.geometry), getMaterial(data.material));
- break;
- case "PointCloud":
- case "Points":
- object = new Points(getGeometry(data.geometry), getMaterial(data.material));
- break;
- case "Sprite":
- object = new Sprite(getMaterial(data.material));
- break;
- case "Group":
- object = new Group();
- break;
- default:
- object = new Object3D();
- }
- object.uuid = data.uuid;
- if (data.name !== void 0)
- object.name = data.name;
- if (data.matrix !== void 0) {
- object.matrix.fromArray(data.matrix);
- if (data.matrixAutoUpdate !== void 0)
- object.matrixAutoUpdate = data.matrixAutoUpdate;
- if (object.matrixAutoUpdate)
- object.matrix.decompose(object.position, object.quaternion, object.scale);
- } else {
- if (data.position !== void 0)
- object.position.fromArray(data.position);
- if (data.rotation !== void 0)
- object.rotation.fromArray(data.rotation);
- if (data.quaternion !== void 0)
- object.quaternion.fromArray(data.quaternion);
- if (data.scale !== void 0)
- object.scale.fromArray(data.scale);
- }
- if (data.castShadow !== void 0)
- object.castShadow = data.castShadow;
- if (data.receiveShadow !== void 0)
- object.receiveShadow = data.receiveShadow;
- if (data.shadow) {
- if (data.shadow.bias !== void 0)
- object.shadow.bias = data.shadow.bias;
- if (data.shadow.radius !== void 0)
- object.shadow.radius = data.shadow.radius;
- if (data.shadow.mapSize !== void 0)
- object.shadow.mapSize.fromArray(data.shadow.mapSize);
- if (data.shadow.camera !== void 0)
- object.shadow.camera = this.parseObject(data.shadow.camera);
- }
- if (data.visible !== void 0)
- object.visible = data.visible;
- if (data.frustumCulled !== void 0)
- object.frustumCulled = data.frustumCulled;
- if (data.renderOrder !== void 0)
- object.renderOrder = data.renderOrder;
- if (data.userData !== void 0)
- object.userData = data.userData;
- if (data.layers !== void 0)
- object.layers.mask = data.layers;
- if (data.children !== void 0) {
- var children = data.children;
- for (var i2 = 0; i2 < children.length; i2++) {
- object.add(this.parseObject(children[i2], geometries, materials));
- }
- }
- if (data.type === "LOD") {
- if (data.autoUpdate !== void 0)
- object.autoUpdate = data.autoUpdate;
- var levels = data.levels;
- for (var l = 0; l < levels.length; l++) {
- var level = levels[l];
- var child = object.getObjectByProperty("uuid", level.object);
- if (child !== void 0) {
- object.addLevel(child, level.distance);
- }
- }
- }
- return object;
- }
- });
- var TEXTURE_MAPPING = {
- UVMapping,
- CubeReflectionMapping,
- CubeRefractionMapping,
- EquirectangularReflectionMapping,
- EquirectangularRefractionMapping,
- SphericalReflectionMapping,
- CubeUVReflectionMapping,
- CubeUVRefractionMapping
- };
- var TEXTURE_WRAPPING = {
- RepeatWrapping,
- ClampToEdgeWrapping,
- MirroredRepeatWrapping
- };
- var TEXTURE_FILTER = {
- NearestFilter,
- NearestMipmapNearestFilter,
- NearestMipmapLinearFilter,
- LinearFilter,
- LinearMipmapNearestFilter,
- LinearMipmapLinearFilter
- };
- function ImageBitmapLoader(manager) {
- if (typeof createImageBitmap === "undefined") {
- console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported.");
- }
- if (typeof fetch === "undefined") {
- console.warn("THREE.ImageBitmapLoader: fetch() not supported.");
- }
- Loader.call(this, manager);
- this.options = void 0;
- }
- ImageBitmapLoader.prototype = Object.assign(Object.create(Loader.prototype), {
- constructor: ImageBitmapLoader,
- setOptions: function setOptions(options) {
- this.options = options;
- return this;
- },
- load: function(url, onLoad, onProgress, onError) {
- if (url === void 0)
- url = "";
- if (this.path !== void 0)
- url = this.path + url;
- url = this.manager.resolveURL(url);
- var scope = this;
- var cached = Cache.get(url);
- if (cached !== void 0) {
- scope.manager.itemStart(url);
- setTimeout(function() {
- if (onLoad)
- onLoad(cached);
- scope.manager.itemEnd(url);
- }, 0);
- return cached;
- }
- fetch(url).then(function(res) {
- return res.blob();
- }).then(function(blob) {
- if (scope.options === void 0) {
- return createImageBitmap(blob);
- } else {
- return createImageBitmap(blob, scope.options);
- }
- }).then(function(imageBitmap) {
- Cache.add(url, imageBitmap);
- if (onLoad)
- onLoad(imageBitmap);
- scope.manager.itemEnd(url);
- }).catch(function(e) {
- if (onError)
- onError(e);
- scope.manager.itemError(url);
- scope.manager.itemEnd(url);
- });
- scope.manager.itemStart(url);
- }
- });
- function ShapePath() {
- this.type = "ShapePath";
- this.color = new Color();
- this.subPaths = [];
- this.currentPath = null;
- }
- Object.assign(ShapePath.prototype, {
- moveTo: function(x, y) {
- this.currentPath = new Path();
- this.subPaths.push(this.currentPath);
- this.currentPath.moveTo(x, y);
- return this;
- },
- lineTo: function(x, y) {
- this.currentPath.lineTo(x, y);
- return this;
- },
- quadraticCurveTo: function(aCPx, aCPy, aX, aY) {
- this.currentPath.quadraticCurveTo(aCPx, aCPy, aX, aY);
- return this;
- },
- bezierCurveTo: function(aCP1x, aCP1y, aCP2x, aCP2y, aX, aY) {
- this.currentPath.bezierCurveTo(aCP1x, aCP1y, aCP2x, aCP2y, aX, aY);
- return this;
- },
- splineThru: function(pts) {
- this.currentPath.splineThru(pts);
- return this;
- },
- toShapes: function(isCCW, noHoles) {
- function toShapesNoHoles(inSubpaths) {
- var shapes2 = [];
- for (var i3 = 0, l2 = inSubpaths.length; i3 < l2; i3++) {
- var tmpPath2 = inSubpaths[i3];
- var tmpShape2 = new Shape();
- tmpShape2.curves = tmpPath2.curves;
- shapes2.push(tmpShape2);
- }
- return shapes2;
- }
- function isPointInsidePolygon(inPt, inPolygon) {
- var polyLen = inPolygon.length;
- var inside = false;
- for (var p = polyLen - 1, q = 0; q < polyLen; p = q++) {
- var edgeLowPt = inPolygon[p];
- var edgeHighPt = inPolygon[q];
- var edgeDx = edgeHighPt.x - edgeLowPt.x;
- var edgeDy = edgeHighPt.y - edgeLowPt.y;
- if (Math.abs(edgeDy) > Number.EPSILON) {
- if (edgeDy < 0) {
- edgeLowPt = inPolygon[q];
- edgeDx = -edgeDx;
- edgeHighPt = inPolygon[p];
- edgeDy = -edgeDy;
- }
- if (inPt.y < edgeLowPt.y || inPt.y > edgeHighPt.y)
- continue;
- if (inPt.y === edgeLowPt.y) {
- if (inPt.x === edgeLowPt.x)
- return true;
- } else {
- var perpEdge = edgeDy * (inPt.x - edgeLowPt.x) - edgeDx * (inPt.y - edgeLowPt.y);
- if (perpEdge === 0)
- return true;
- if (perpEdge < 0)
- continue;
- inside = !inside;
- }
- } else {
- if (inPt.y !== edgeLowPt.y)
- continue;
- if (edgeHighPt.x <= inPt.x && inPt.x <= edgeLowPt.x || edgeLowPt.x <= inPt.x && inPt.x <= edgeHighPt.x)
- return true;
- }
- }
- return inside;
- }
- var isClockWise = ShapeUtils.isClockWise;
- var subPaths = this.subPaths;
- if (subPaths.length === 0)
- return [];
- if (noHoles === true)
- return toShapesNoHoles(subPaths);
- var solid, tmpPath, tmpShape, shapes = [];
- if (subPaths.length === 1) {
- tmpPath = subPaths[0];
- tmpShape = new Shape();
- tmpShape.curves = tmpPath.curves;
- shapes.push(tmpShape);
- return shapes;
- }
- var holesFirst = !isClockWise(subPaths[0].getPoints());
- holesFirst = isCCW ? !holesFirst : holesFirst;
- var betterShapeHoles = [];
- var newShapes = [];
- var newShapeHoles = [];
- var mainIdx = 0;
- var tmpPoints;
- newShapes[mainIdx] = void 0;
- newShapeHoles[mainIdx] = [];
- for (var i2 = 0, l = subPaths.length; i2 < l; i2++) {
- tmpPath = subPaths[i2];
- tmpPoints = tmpPath.getPoints();
- solid = isClockWise(tmpPoints);
- solid = isCCW ? !solid : solid;
- if (solid) {
- if (!holesFirst && newShapes[mainIdx])
- mainIdx++;
- newShapes[mainIdx] = { s: new Shape(), p: tmpPoints };
- newShapes[mainIdx].s.curves = tmpPath.curves;
- if (holesFirst)
- mainIdx++;
- newShapeHoles[mainIdx] = [];
- } else {
- newShapeHoles[mainIdx].push({ h: tmpPath, p: tmpPoints[0] });
- }
- }
- if (!newShapes[0])
- return toShapesNoHoles(subPaths);
- if (newShapes.length > 1) {
- var ambiguous = false;
- var toChange = [];
- for (var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx++) {
- betterShapeHoles[sIdx] = [];
- }
- for (var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx++) {
- var sho = newShapeHoles[sIdx];
- for (var hIdx = 0; hIdx < sho.length; hIdx++) {
- var ho = sho[hIdx];
- var hole_unassigned = true;
- for (var s2Idx = 0; s2Idx < newShapes.length; s2Idx++) {
- if (isPointInsidePolygon(ho.p, newShapes[s2Idx].p)) {
- if (sIdx !== s2Idx)
- toChange.push({ froms: sIdx, tos: s2Idx, hole: hIdx });
- if (hole_unassigned) {
- hole_unassigned = false;
- betterShapeHoles[s2Idx].push(ho);
- } else {
- ambiguous = true;
- }
- }
- }
- if (hole_unassigned) {
- betterShapeHoles[sIdx].push(ho);
- }
- }
- }
- if (toChange.length > 0) {
- if (!ambiguous)
- newShapeHoles = betterShapeHoles;
- }
- }
- var tmpHoles;
- for (var i2 = 0, il = newShapes.length; i2 < il; i2++) {
- tmpShape = newShapes[i2].s;
- shapes.push(tmpShape);
- tmpHoles = newShapeHoles[i2];
- for (var j = 0, jl = tmpHoles.length; j < jl; j++) {
- tmpShape.holes.push(tmpHoles[j].h);
- }
- }
- return shapes;
- }
- });
- function Font(data) {
- this.type = "Font";
- this.data = data;
- }
- Object.assign(Font.prototype, {
- isFont: true,
- generateShapes: function(text, size) {
- if (size === void 0)
- size = 100;
- var shapes = [];
- var paths = createPaths(text, size, this.data);
- for (var p = 0, pl = paths.length; p < pl; p++) {
- Array.prototype.push.apply(shapes, paths[p].toShapes());
- }
- return shapes;
- }
- });
- function createPaths(text, size, data) {
- var chars = Array.from ? Array.from(text) : String(text).split("");
- var scale = size / data.resolution;
- var line_height = (data.boundingBox.yMax - data.boundingBox.yMin + data.underlineThickness) * scale;
- var paths = [];
- var offsetX = 0, offsetY = 0;
- for (var i2 = 0; i2 < chars.length; i2++) {
- var char = chars[i2];
- if (char === "\n") {
- offsetX = 0;
- offsetY -= line_height;
- } else {
- var ret = createPath(char, scale, offsetX, offsetY, data);
- offsetX += ret.offsetX;
- paths.push(ret.path);
- }
- }
- return paths;
- }
- function createPath(char, scale, offsetX, offsetY, data) {
- var glyph = data.glyphs[char] || data.glyphs["?"];
- if (!glyph) {
- console.error('THREE.Font: character "' + char + '" does not exists in font family ' + data.familyName + ".");
- return;
- }
- var path = new ShapePath();
- var x, y, cpx, cpy, cpx1, cpy1, cpx2, cpy2;
- if (glyph.o) {
- var outline = glyph._cachedOutline || (glyph._cachedOutline = glyph.o.split(" "));
- for (var i2 = 0, l = outline.length; i2 < l; ) {
- var action = outline[i2++];
- switch (action) {
- case "m":
- x = outline[i2++] * scale + offsetX;
- y = outline[i2++] * scale + offsetY;
- path.moveTo(x, y);
- break;
- case "l":
- x = outline[i2++] * scale + offsetX;
- y = outline[i2++] * scale + offsetY;
- path.lineTo(x, y);
- break;
- case "q":
- cpx = outline[i2++] * scale + offsetX;
- cpy = outline[i2++] * scale + offsetY;
- cpx1 = outline[i2++] * scale + offsetX;
- cpy1 = outline[i2++] * scale + offsetY;
- path.quadraticCurveTo(cpx1, cpy1, cpx, cpy);
- break;
- case "b":
- cpx = outline[i2++] * scale + offsetX;
- cpy = outline[i2++] * scale + offsetY;
- cpx1 = outline[i2++] * scale + offsetX;
- cpy1 = outline[i2++] * scale + offsetY;
- cpx2 = outline[i2++] * scale + offsetX;
- cpy2 = outline[i2++] * scale + offsetY;
- path.bezierCurveTo(cpx1, cpy1, cpx2, cpy2, cpx, cpy);
- break;
- }
- }
- }
- return { offsetX: glyph.ha * scale, path };
- }
- function FontLoader(manager) {
- Loader.call(this, manager);
- }
- FontLoader.prototype = Object.assign(Object.create(Loader.prototype), {
- constructor: FontLoader,
- load: function(url, onLoad, onProgress, onError) {
- var scope = this;
- var loader = new FileLoader(this.manager);
- loader.setPath(this.path);
- loader.load(url, function(text) {
- var json;
- try {
- json = JSON.parse(text);
- } catch (e) {
- console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead.");
- json = JSON.parse(text.substring(65, text.length - 2));
- }
- var font = scope.parse(json);
- if (onLoad)
- onLoad(font);
- }, onProgress, onError);
- },
- parse: function(json) {
- return new Font(json);
- }
- });
- var _context;
- var AudioContext = {
- getContext: function() {
- if (_context === void 0) {
- _context = new (window.AudioContext || window.webkitAudioContext)();
- }
- return _context;
- },
- setContext: function(value) {
- _context = value;
- }
- };
- function AudioLoader(manager) {
- Loader.call(this, manager);
- }
- AudioLoader.prototype = Object.assign(Object.create(Loader.prototype), {
- constructor: AudioLoader,
- load: function(url, onLoad, onProgress, onError) {
- var loader = new FileLoader(this.manager);
- loader.setResponseType("arraybuffer");
- loader.setPath(this.path);
- loader.load(url, function(buffer) {
- var bufferCopy = buffer.slice(0);
- var context = AudioContext.getContext();
- context.decodeAudioData(bufferCopy, function(audioBuffer) {
- onLoad(audioBuffer);
- });
- }, onProgress, onError);
- }
- });
- function SphericalHarmonics3() {
- this.coefficients = [];
- for (var i2 = 0; i2 < 9; i2++) {
- this.coefficients.push(new Vector3());
- }
- }
- Object.assign(SphericalHarmonics3.prototype, {
- isSphericalHarmonics3: true,
- set: function(coefficients) {
- for (var i2 = 0; i2 < 9; i2++) {
- this.coefficients[i2].copy(coefficients[i2]);
- }
- return this;
- },
- zero: function() {
- for (var i2 = 0; i2 < 9; i2++) {
- this.coefficients[i2].set(0, 0, 0);
- }
- return this;
- },
- // get the radiance in the direction of the normal
- // target is a Vector3
- getAt: function(normal, target) {
- var x = normal.x, y = normal.y, z = normal.z;
- var coeff = this.coefficients;
- target.copy(coeff[0]).multiplyScalar(0.282095);
- target.addScale(coeff[1], 0.488603 * y);
- target.addScale(coeff[2], 0.488603 * z);
- target.addScale(coeff[3], 0.488603 * x);
- target.addScale(coeff[4], 1.092548 * (x * y));
- target.addScale(coeff[5], 1.092548 * (y * z));
- target.addScale(coeff[6], 0.315392 * (3 * z * z - 1));
- target.addScale(coeff[7], 1.092548 * (x * z));
- target.addScale(coeff[8], 0.546274 * (x * x - y * y));
- return target;
- },
- // get the irradiance (radiance convolved with cosine lobe) in the direction of the normal
- // target is a Vector3
- // https://graphics.stanford.edu/papers/envmap/envmap.pdf
- getIrradianceAt: function(normal, target) {
- var x = normal.x, y = normal.y, z = normal.z;
- var coeff = this.coefficients;
- target.copy(coeff[0]).multiplyScalar(0.886227);
- target.addScale(coeff[1], 2 * 0.511664 * y);
- target.addScale(coeff[2], 2 * 0.511664 * z);
- target.addScale(coeff[3], 2 * 0.511664 * x);
- target.addScale(coeff[4], 2 * 0.429043 * x * y);
- target.addScale(coeff[5], 2 * 0.429043 * y * z);
- target.addScale(coeff[6], 0.743125 * z * z - 0.247708);
- target.addScale(coeff[7], 2 * 0.429043 * x * z);
- target.addScale(coeff[8], 0.429043 * (x * x - y * y));
- return target;
- },
- add: function(sh) {
- for (var i2 = 0; i2 < 9; i2++) {
- this.coefficients[i2].add(sh.coefficients[i2]);
- }
- return this;
- },
- scale: function(s) {
- for (var i2 = 0; i2 < 9; i2++) {
- this.coefficients[i2].multiplyScalar(s);
- }
- return this;
- },
- lerp: function(sh, alpha) {
- for (var i2 = 0; i2 < 9; i2++) {
- this.coefficients[i2].lerp(sh.coefficients[i2], alpha);
- }
- return this;
- },
- equals: function(sh) {
- for (var i2 = 0; i2 < 9; i2++) {
- if (!this.coefficients[i2].equals(sh.coefficients[i2])) {
- return false;
- }
- }
- return true;
- },
- copy: function(sh) {
- return this.set(sh.coefficients);
- },
- clone: function() {
- return new this.constructor().copy(this);
- },
- fromArray: function(array, offset) {
- if (offset === void 0)
- offset = 0;
- var coefficients = this.coefficients;
- for (var i2 = 0; i2 < 9; i2++) {
- coefficients[i2].fromArray(array, offset + i2 * 3);
- }
- return this;
- },
- toArray: function(array, offset) {
- if (array === void 0)
- array = [];
- if (offset === void 0)
- offset = 0;
- var coefficients = this.coefficients;
- for (var i2 = 0; i2 < 9; i2++) {
- coefficients[i2].toArray(array, offset + i2 * 3);
- }
- return array;
- }
- });
- Object.assign(SphericalHarmonics3, {
- // evaluate the basis functions
- // shBasis is an Array[ 9 ]
- getBasisAt: function(normal, shBasis) {
- var x = normal.x, y = normal.y, z = normal.z;
- shBasis[0] = 0.282095;
- shBasis[1] = 0.488603 * y;
- shBasis[2] = 0.488603 * z;
- shBasis[3] = 0.488603 * x;
- shBasis[4] = 1.092548 * x * y;
- shBasis[5] = 1.092548 * y * z;
- shBasis[6] = 0.315392 * (3 * z * z - 1);
- shBasis[7] = 1.092548 * x * z;
- shBasis[8] = 0.546274 * (x * x - y * y);
- }
- });
- function LightProbe(sh, intensity) {
- Light.call(this, void 0, intensity);
- this.sh = sh !== void 0 ? sh : new SphericalHarmonics3();
- }
- LightProbe.prototype = Object.assign(Object.create(Light.prototype), {
- constructor: LightProbe,
- isLightProbe: true,
- copy: function(source) {
- Light.prototype.copy.call(this, source);
- this.sh.copy(source.sh);
- this.intensity = source.intensity;
- return this;
- },
- toJSON: function(meta) {
- var data = Light.prototype.toJSON.call(this, meta);
- return data;
- }
- });
- function HemisphereLightProbe(skyColor, groundColor, intensity) {
- LightProbe.call(this, void 0, intensity);
- var color1 = new Color().set(skyColor);
- var color2 = new Color().set(groundColor);
- var sky = new Vector3(color1.r, color1.g, color1.b);
- var ground = new Vector3(color2.r, color2.g, color2.b);
- var c0 = Math.sqrt(Math.PI);
- var c1 = c0 * Math.sqrt(0.75);
- this.sh.coefficients[0].copy(sky).add(ground).multiplyScalar(c0);
- this.sh.coefficients[1].copy(sky).sub(ground).multiplyScalar(c1);
- }
- HemisphereLightProbe.prototype = Object.assign(Object.create(LightProbe.prototype), {
- constructor: HemisphereLightProbe,
- isHemisphereLightProbe: true,
- copy: function(source) {
- LightProbe.prototype.copy.call(this, source);
- return this;
- },
- toJSON: function(meta) {
- var data = LightProbe.prototype.toJSON.call(this, meta);
- return data;
- }
- });
- function AmbientLightProbe(color, intensity) {
- LightProbe.call(this, void 0, intensity);
- var color1 = new Color().set(color);
- this.sh.coefficients[0].set(color1.r, color1.g, color1.b).multiplyScalar(2 * Math.sqrt(Math.PI));
- }
- AmbientLightProbe.prototype = Object.assign(Object.create(LightProbe.prototype), {
- constructor: AmbientLightProbe,
- isAmbientLightProbe: true,
- copy: function(source) {
- LightProbe.prototype.copy.call(this, source);
- return this;
- },
- toJSON: function(meta) {
- var data = LightProbe.prototype.toJSON.call(this, meta);
- return data;
- }
- });
- var _eyeRight = new Matrix4();
- var _eyeLeft = new Matrix4();
- function StereoCamera() {
- this.type = "StereoCamera";
- this.aspect = 1;
- this.eyeSep = 0.064;
- this.cameraL = new PerspectiveCamera();
- this.cameraL.layers.enable(1);
- this.cameraL.matrixAutoUpdate = false;
- this.cameraR = new PerspectiveCamera();
- this.cameraR.layers.enable(2);
- this.cameraR.matrixAutoUpdate = false;
- this._cache = {
- focus: null,
- fov: null,
- aspect: null,
- near: null,
- far: null,
- zoom: null,
- eyeSep: null
- };
- }
- Object.assign(StereoCamera.prototype, {
- update: function(camera) {
- var cache = this._cache;
- 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;
- if (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;
- var projectionMatrix = camera.projectionMatrix.clone();
- var eyeSepHalf = cache.eyeSep / 2;
- var eyeSepOnProjection = eyeSepHalf * cache.near / cache.focus;
- var ymax = cache.near * Math.tan(MathUtils.DEG2RAD * cache.fov * 0.5) / cache.zoom;
- var xmin, xmax;
- _eyeLeft.elements[12] = -eyeSepHalf;
- _eyeRight.elements[12] = eyeSepHalf;
- xmin = -ymax * cache.aspect + eyeSepOnProjection;
- xmax = ymax * cache.aspect + eyeSepOnProjection;
- projectionMatrix.elements[0] = 2 * cache.near / (xmax - xmin);
- projectionMatrix.elements[8] = (xmax + xmin) / (xmax - xmin);
- this.cameraL.projectionMatrix.copy(projectionMatrix);
- xmin = -ymax * cache.aspect - eyeSepOnProjection;
- xmax = ymax * cache.aspect - eyeSepOnProjection;
- projectionMatrix.elements[0] = 2 * cache.near / (xmax - xmin);
- projectionMatrix.elements[8] = (xmax + xmin) / (xmax - xmin);
- this.cameraR.projectionMatrix.copy(projectionMatrix);
- }
- this.cameraL.matrixWorld.copy(camera.matrixWorld).multiply(_eyeLeft);
- this.cameraR.matrixWorld.copy(camera.matrixWorld).multiply(_eyeRight);
- }
- });
- function Clock(autoStart) {
- this.autoStart = autoStart !== void 0 ? autoStart : true;
- this.startTime = 0;
- this.oldTime = 0;
- this.elapsedTime = 0;
- this.running = false;
- }
- Object.assign(Clock.prototype, {
- start: function() {
- this.startTime = (typeof performance === "undefined" ? Date : performance).now();
- this.oldTime = this.startTime;
- this.elapsedTime = 0;
- this.running = true;
- },
- stop: function() {
- this.getElapsedTime();
- this.running = false;
- this.autoStart = false;
- },
- getElapsedTime: function() {
- this.getDelta();
- return this.elapsedTime;
- },
- getDelta: function() {
- var diff = 0;
- if (this.autoStart && !this.running) {
- this.start();
- return 0;
- }
- if (this.running) {
- var newTime = (typeof performance === "undefined" ? Date : performance).now();
- diff = (newTime - this.oldTime) / 1e3;
- this.oldTime = newTime;
- this.elapsedTime += diff;
- }
- return diff;
- }
- });
- var _position$2 = new Vector3();
- var _quaternion$3 = new Quaternion();
- var _scale$1 = new Vector3();
- var _orientation = new Vector3();
- function AudioListener() {
- Object3D.call(this);
- this.type = "AudioListener";
- this.context = AudioContext.getContext();
- this.gain = this.context.createGain();
- this.gain.connect(this.context.destination);
- this.filter = null;
- this.timeDelta = 0;
- this._clock = new Clock();
- }
- AudioListener.prototype = Object.assign(Object.create(Object3D.prototype), {
- constructor: AudioListener,
- getInput: function() {
- return this.gain;
- },
- removeFilter: function() {
- if (this.filter !== null) {
- this.gain.disconnect(this.filter);
- this.filter.disconnect(this.context.destination);
- this.gain.connect(this.context.destination);
- this.filter = null;
- }
- return this;
- },
- getFilter: function() {
- return this.filter;
- },
- setFilter: function(value) {
- if (this.filter !== null) {
- this.gain.disconnect(this.filter);
- this.filter.disconnect(this.context.destination);
- } else {
- this.gain.disconnect(this.context.destination);
- }
- this.filter = value;
- this.gain.connect(this.filter);
- this.filter.connect(this.context.destination);
- return this;
- },
- getMasterVolume: function() {
- return this.gain.gain.value;
- },
- setMasterVolume: function(value) {
- this.gain.gain.setTargetAtTime(value, this.context.currentTime, 0.01);
- return this;
- },
- updateMatrixWorld: function(force) {
- Object3D.prototype.updateMatrixWorld.call(this, force);
- var listener = this.context.listener;
- var up = this.up;
- this.timeDelta = this._clock.getDelta();
- this.matrixWorld.decompose(_position$2, _quaternion$3, _scale$1);
- _orientation.set(0, 0, -1).applyQuaternion(_quaternion$3);
- if (listener.positionX) {
- var endTime = this.context.currentTime + this.timeDelta;
- listener.positionX.linearRampToValueAtTime(_position$2.x, endTime);
- listener.positionY.linearRampToValueAtTime(_position$2.y, endTime);
- listener.positionZ.linearRampToValueAtTime(_position$2.z, endTime);
- listener.forwardX.linearRampToValueAtTime(_orientation.x, endTime);
- listener.forwardY.linearRampToValueAtTime(_orientation.y, endTime);
- listener.forwardZ.linearRampToValueAtTime(_orientation.z, endTime);
- listener.upX.linearRampToValueAtTime(up.x, endTime);
- listener.upY.linearRampToValueAtTime(up.y, endTime);
- listener.upZ.linearRampToValueAtTime(up.z, endTime);
- } else {
- listener.setPosition(_position$2.x, _position$2.y, _position$2.z);
- listener.setOrientation(_orientation.x, _orientation.y, _orientation.z, up.x, up.y, up.z);
- }
- }
- });
- function Audio(listener) {
- Object3D.call(this);
- this.type = "Audio";
- this.listener = listener;
- this.context = listener.context;
- this.gain = this.context.createGain();
- this.gain.connect(listener.getInput());
- this.autoplay = false;
- this.buffer = null;
- this.detune = 0;
- this.loop = false;
- this.loopStart = 0;
- this.loopEnd = 0;
- this.offset = 0;
- this.duration = void 0;
- this.playbackRate = 1;
- this.isPlaying = false;
- this.hasPlaybackControl = true;
- this.sourceType = "empty";
- this._startedAt = 0;
- this._pausedAt = 0;
- this.filters = [];
- }
- Audio.prototype = Object.assign(Object.create(Object3D.prototype), {
- constructor: Audio,
- getOutput: function() {
- return this.gain;
- },
- setNodeSource: function(audioNode) {
- this.hasPlaybackControl = false;
- this.sourceType = "audioNode";
- this.source = audioNode;
- this.connect();
- return this;
- },
- setMediaElementSource: function(mediaElement) {
- this.hasPlaybackControl = false;
- this.sourceType = "mediaNode";
- this.source = this.context.createMediaElementSource(mediaElement);
- this.connect();
- return this;
- },
- setMediaStreamSource: function(mediaStream) {
- this.hasPlaybackControl = false;
- this.sourceType = "mediaStreamNode";
- this.source = this.context.createMediaStreamSource(mediaStream);
- this.connect();
- return this;
- },
- setBuffer: function(audioBuffer) {
- this.buffer = audioBuffer;
- this.sourceType = "buffer";
- if (this.autoplay)
- this.play();
- return this;
- },
- play: function(delay) {
- if (delay === void 0)
- delay = 0;
- if (this.isPlaying === true) {
- console.warn("THREE.Audio: Audio is already playing.");
- return;
- }
- if (this.hasPlaybackControl === false) {
- console.warn("THREE.Audio: this Audio has no playback control.");
- return;
- }
- this._startedAt = this.context.currentTime + delay;
- var source = this.context.createBufferSource();
- source.buffer = this.buffer;
- source.loop = this.loop;
- source.loopStart = this.loopStart;
- source.loopEnd = this.loopEnd;
- source.onended = this.onEnded.bind(this);
- source.start(this._startedAt, this._pausedAt + this.offset, this.duration);
- this.isPlaying = true;
- this.source = source;
- this.setDetune(this.detune);
- this.setPlaybackRate(this.playbackRate);
- return this.connect();
- },
- pause: function() {
- if (this.hasPlaybackControl === false) {
- console.warn("THREE.Audio: this Audio has no playback control.");
- return;
- }
- if (this.isPlaying === true) {
- this._pausedAt = (this.context.currentTime - this._startedAt) * this.playbackRate;
- this.source.stop();
- this.source.onended = null;
- this.isPlaying = false;
- }
- return this;
- },
- stop: function() {
- if (this.hasPlaybackControl === false) {
- console.warn("THREE.Audio: this Audio has no playback control.");
- return;
- }
- this._pausedAt = 0;
- this.source.stop();
- this.source.onended = null;
- this.isPlaying = false;
- return this;
- },
- connect: function() {
- if (this.filters.length > 0) {
- this.source.connect(this.filters[0]);
- for (var i2 = 1, l = this.filters.length; i2 < l; i2++) {
- this.filters[i2 - 1].connect(this.filters[i2]);
- }
- this.filters[this.filters.length - 1].connect(this.getOutput());
- } else {
- this.source.connect(this.getOutput());
- }
- return this;
- },
- disconnect: function() {
- if (this.filters.length > 0) {
- this.source.disconnect(this.filters[0]);
- for (var i2 = 1, l = this.filters.length; i2 < l; i2++) {
- this.filters[i2 - 1].disconnect(this.filters[i2]);
- }
- this.filters[this.filters.length - 1].disconnect(this.getOutput());
- } else {
- this.source.disconnect(this.getOutput());
- }
- return this;
- },
- getFilters: function() {
- return this.filters;
- },
- setFilters: function(value) {
- if (!value)
- value = [];
- if (this.isPlaying === true) {
- this.disconnect();
- this.filters = value;
- this.connect();
- } else {
- this.filters = value;
- }
- return this;
- },
- setDetune: function(value) {
- this.detune = value;
- if (this.source.detune === void 0)
- return;
- if (this.isPlaying === true) {
- this.source.detune.setTargetAtTime(this.detune, this.context.currentTime, 0.01);
- }
- return this;
- },
- getDetune: function() {
- return this.detune;
- },
- getFilter: function() {
- return this.getFilters()[0];
- },
- setFilter: function(filter) {
- return this.setFilters(filter ? [filter] : []);
- },
- setPlaybackRate: function(value) {
- if (this.hasPlaybackControl === false) {
- console.warn("THREE.Audio: this Audio has no playback control.");
- return;
- }
- this.playbackRate = value;
- if (this.isPlaying === true) {
- this.source.playbackRate.setTargetAtTime(this.playbackRate, this.context.currentTime, 0.01);
- }
- return this;
- },
- getPlaybackRate: function() {
- return this.playbackRate;
- },
- onEnded: function() {
- this.isPlaying = false;
- },
- getLoop: function() {
- if (this.hasPlaybackControl === false) {
- console.warn("THREE.Audio: this Audio has no playback control.");
- return false;
- }
- return this.loop;
- },
- setLoop: function(value) {
- if (this.hasPlaybackControl === false) {
- console.warn("THREE.Audio: this Audio has no playback control.");
- return;
- }
- this.loop = value;
- if (this.isPlaying === true) {
- this.source.loop = this.loop;
- }
- return this;
- },
- setLoopStart: function(value) {
- this.loopStart = value;
- return this;
- },
- setLoopEnd: function(value) {
- this.loopEnd = value;
- return this;
- },
- getVolume: function() {
- return this.gain.gain.value;
- },
- setVolume: function(value) {
- this.gain.gain.setTargetAtTime(value, this.context.currentTime, 0.01);
- return this;
- }
- });
- var _position$3 = new Vector3();
- var _quaternion$4 = new Quaternion();
- var _scale$2 = new Vector3();
- var _orientation$1 = new Vector3();
- function PositionalAudio(listener) {
- Audio.call(this, listener);
- this.panner = this.context.createPanner();
- this.panner.panningModel = "HRTF";
- this.panner.connect(this.gain);
- }
- PositionalAudio.prototype = Object.assign(Object.create(Audio.prototype), {
- constructor: PositionalAudio,
- getOutput: function() {
- return this.panner;
- },
- getRefDistance: function() {
- return this.panner.refDistance;
- },
- setRefDistance: function(value) {
- this.panner.refDistance = value;
- return this;
- },
- getRolloffFactor: function() {
- return this.panner.rolloffFactor;
- },
- setRolloffFactor: function(value) {
- this.panner.rolloffFactor = value;
- return this;
- },
- getDistanceModel: function() {
- return this.panner.distanceModel;
- },
- setDistanceModel: function(value) {
- this.panner.distanceModel = value;
- return this;
- },
- getMaxDistance: function() {
- return this.panner.maxDistance;
- },
- setMaxDistance: function(value) {
- this.panner.maxDistance = value;
- return this;
- },
- setDirectionalCone: function(coneInnerAngle, coneOuterAngle, coneOuterGain) {
- this.panner.coneInnerAngle = coneInnerAngle;
- this.panner.coneOuterAngle = coneOuterAngle;
- this.panner.coneOuterGain = coneOuterGain;
- return this;
- },
- updateMatrixWorld: function(force) {
- Object3D.prototype.updateMatrixWorld.call(this, force);
- if (this.hasPlaybackControl === true && this.isPlaying === false)
- return;
- this.matrixWorld.decompose(_position$3, _quaternion$4, _scale$2);
- _orientation$1.set(0, 0, 1).applyQuaternion(_quaternion$4);
- var panner = this.panner;
- if (panner.positionX) {
- var endTime = this.context.currentTime + this.listener.timeDelta;
- panner.positionX.linearRampToValueAtTime(_position$3.x, endTime);
- panner.positionY.linearRampToValueAtTime(_position$3.y, endTime);
- panner.positionZ.linearRampToValueAtTime(_position$3.z, endTime);
- panner.orientationX.linearRampToValueAtTime(_orientation$1.x, endTime);
- panner.orientationY.linearRampToValueAtTime(_orientation$1.y, endTime);
- panner.orientationZ.linearRampToValueAtTime(_orientation$1.z, endTime);
- } else {
- panner.setPosition(_position$3.x, _position$3.y, _position$3.z);
- panner.setOrientation(_orientation$1.x, _orientation$1.y, _orientation$1.z);
- }
- }
- });
- function AudioAnalyser(audio, fftSize) {
- this.analyser = audio.context.createAnalyser();
- this.analyser.fftSize = fftSize !== void 0 ? fftSize : 2048;
- this.data = new Uint8Array(this.analyser.frequencyBinCount);
- audio.getOutput().connect(this.analyser);
- }
- Object.assign(AudioAnalyser.prototype, {
- getFrequencyData: function() {
- this.analyser.getByteFrequencyData(this.data);
- return this.data;
- },
- getAverageFrequency: function() {
- var value = 0, data = this.getFrequencyData();
- for (var i2 = 0; i2 < data.length; i2++) {
- value += data[i2];
- }
- return value / data.length;
- }
- });
- function PropertyMixer(binding, typeName, valueSize) {
- this.binding = binding;
- this.valueSize = valueSize;
- var bufferType = Float64Array, mixFunction;
- switch (typeName) {
- case "quaternion":
- mixFunction = this._slerp;
- break;
- case "string":
- case "bool":
- bufferType = Array;
- mixFunction = this._select;
- break;
- default:
- mixFunction = this._lerp;
- }
- this.buffer = new bufferType(valueSize * 4);
- this._mixBufferRegion = mixFunction;
- this.cumulativeWeight = 0;
- this.useCount = 0;
- this.referenceCount = 0;
- }
- Object.assign(PropertyMixer.prototype, {
- // accumulate data in the 'incoming' region into 'accu<i>'
- accumulate: function(accuIndex, weight) {
- var buffer = this.buffer, stride = this.valueSize, offset = accuIndex * stride + stride, currentWeight = this.cumulativeWeight;
- if (currentWeight === 0) {
- for (var i2 = 0; i2 !== stride; ++i2) {
- buffer[offset + i2] = buffer[i2];
- }
- currentWeight = weight;
- } else {
- currentWeight += weight;
- var mix = weight / currentWeight;
- this._mixBufferRegion(buffer, offset, 0, mix, stride);
- }
- this.cumulativeWeight = currentWeight;
- },
- // apply the state of 'accu<i>' to the binding when accus differ
- apply: function(accuIndex) {
- var stride = this.valueSize, buffer = this.buffer, offset = accuIndex * stride + stride, weight = this.cumulativeWeight, binding = this.binding;
- this.cumulativeWeight = 0;
- if (weight < 1) {
- var originalValueOffset = stride * 3;
- this._mixBufferRegion(
- buffer,
- offset,
- originalValueOffset,
- 1 - weight,
- stride
- );
- }
- for (var i2 = stride, e = stride + stride; i2 !== e; ++i2) {
- if (buffer[i2] !== buffer[i2 + stride]) {
- binding.setValue(buffer, offset);
- break;
- }
- }
- },
- // remember the state of the bound property and copy it to both accus
- saveOriginalState: function() {
- var binding = this.binding;
- var buffer = this.buffer, stride = this.valueSize, originalValueOffset = stride * 3;
- binding.getValue(buffer, originalValueOffset);
- for (var i2 = stride, e = originalValueOffset; i2 !== e; ++i2) {
- buffer[i2] = buffer[originalValueOffset + i2 % stride];
- }
- this.cumulativeWeight = 0;
- },
- // apply the state previously taken via 'saveOriginalState' to the binding
- restoreOriginalState: function() {
- var originalValueOffset = this.valueSize * 3;
- this.binding.setValue(this.buffer, originalValueOffset);
- },
- // mix functions
- _select: function(buffer, dstOffset, srcOffset, t, stride) {
- if (t >= 0.5) {
- for (var i2 = 0; i2 !== stride; ++i2) {
- buffer[dstOffset + i2] = buffer[srcOffset + i2];
- }
- }
- },
- _slerp: function(buffer, dstOffset, srcOffset, t) {
- Quaternion.slerpFlat(buffer, dstOffset, buffer, dstOffset, buffer, srcOffset, t);
- },
- _lerp: function(buffer, dstOffset, srcOffset, t, stride) {
- var s = 1 - t;
- for (var i2 = 0; i2 !== stride; ++i2) {
- var j = dstOffset + i2;
- buffer[j] = buffer[j] * s + buffer[srcOffset + i2] * t;
- }
- }
- });
- var _RESERVED_CHARS_RE = "\\[\\]\\.:\\/";
- var _reservedRe = new RegExp("[" + _RESERVED_CHARS_RE + "]", "g");
- var _wordChar = "[^" + _RESERVED_CHARS_RE + "]";
- var _wordCharOrDot = "[^" + _RESERVED_CHARS_RE.replace("\\.", "") + "]";
- var _directoryRe = /((?:WC+[\/:])*)/.source.replace("WC", _wordChar);
- var _nodeRe = /(WCOD+)?/.source.replace("WCOD", _wordCharOrDot);
- var _objectRe = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC", _wordChar);
- var _propertyRe = /\.(WC+)(?:\[(.+)\])?/.source.replace("WC", _wordChar);
- var _trackRe = new RegExp(
- "^" + _directoryRe + _nodeRe + _objectRe + _propertyRe + "$"
- );
- var _supportedObjectNames = ["material", "materials", "bones"];
- function Composite(targetGroup, path, optionalParsedPath) {
- var parsedPath = optionalParsedPath || PropertyBinding.parseTrackName(path);
- this._targetGroup = targetGroup;
- this._bindings = targetGroup.subscribe_(path, parsedPath);
- }
- Object.assign(Composite.prototype, {
- getValue: function(array, offset) {
- this.bind();
- var firstValidIndex = this._targetGroup.nCachedObjects_, binding = this._bindings[firstValidIndex];
- if (binding !== void 0)
- binding.getValue(array, offset);
- },
- setValue: function(array, offset) {
- var bindings = this._bindings;
- for (var i2 = this._targetGroup.nCachedObjects_, n = bindings.length; i2 !== n; ++i2) {
- bindings[i2].setValue(array, offset);
- }
- },
- bind: function() {
- var bindings = this._bindings;
- for (var i2 = this._targetGroup.nCachedObjects_, n = bindings.length; i2 !== n; ++i2) {
- bindings[i2].bind();
- }
- },
- unbind: function() {
- var bindings = this._bindings;
- for (var i2 = this._targetGroup.nCachedObjects_, n = bindings.length; i2 !== n; ++i2) {
- bindings[i2].unbind();
- }
- }
- });
- function PropertyBinding(rootNode, path, parsedPath) {
- this.path = path;
- this.parsedPath = parsedPath || PropertyBinding.parseTrackName(path);
- this.node = PropertyBinding.findNode(rootNode, this.parsedPath.nodeName) || rootNode;
- this.rootNode = rootNode;
- }
- Object.assign(PropertyBinding, {
- Composite,
- create: function(root, path, parsedPath) {
- if (!(root && root.isAnimationObjectGroup)) {
- return new PropertyBinding(root, path, parsedPath);
- } else {
- return new PropertyBinding.Composite(root, path, parsedPath);
- }
- },
- /**
- * Replaces spaces with underscores and removes unsupported characters from
- * node names, to ensure compatibility with parseTrackName().
- *
- * @param {string} name Node name to be sanitized.
- * @return {string}
- */
- sanitizeNodeName: function(name) {
- return name.replace(/\s/g, "_").replace(_reservedRe, "");
- },
- parseTrackName: function(trackName) {
- var matches = _trackRe.exec(trackName);
- if (!matches) {
- throw new Error("PropertyBinding: Cannot parse trackName: " + trackName);
- }
- var results = {
- // directoryName: matches[ 1 ], // (tschw) currently unused
- nodeName: matches[2],
- objectName: matches[3],
- objectIndex: matches[4],
- propertyName: matches[5],
- // required
- propertyIndex: matches[6]
- };
- var lastDot = results.nodeName && results.nodeName.lastIndexOf(".");
- if (lastDot !== void 0 && lastDot !== -1) {
- var objectName = results.nodeName.substring(lastDot + 1);
- if (_supportedObjectNames.indexOf(objectName) !== -1) {
- results.nodeName = results.nodeName.substring(0, lastDot);
- results.objectName = objectName;
- }
- }
- if (results.propertyName === null || results.propertyName.length === 0) {
- throw new Error("PropertyBinding: can not parse propertyName from trackName: " + trackName);
- }
- return results;
- },
- findNode: function(root, nodeName) {
- if (!nodeName || nodeName === "" || nodeName === "root" || nodeName === "." || nodeName === -1 || nodeName === root.name || nodeName === root.uuid) {
- return root;
- }
- if (root.skeleton) {
- var bone = root.skeleton.getBoneByName(nodeName);
- if (bone !== void 0) {
- return bone;
- }
- }
- if (root.children) {
- var searchNodeSubtree = function(children) {
- for (var i2 = 0; i2 < children.length; i2++) {
- var childNode = children[i2];
- if (childNode.name === nodeName || childNode.uuid === nodeName) {
- return childNode;
- }
- var result = searchNodeSubtree(childNode.children);
- if (result)
- return result;
- }
- return null;
- };
- var subTreeNode = searchNodeSubtree(root.children);
- if (subTreeNode) {
- return subTreeNode;
- }
- }
- return null;
- }
- });
- Object.assign(PropertyBinding.prototype, {
- // prototype, continued
- // these are used to "bind" a nonexistent property
- _getValue_unavailable: function() {
- },
- _setValue_unavailable: function() {
- },
- BindingType: {
- Direct: 0,
- EntireArray: 1,
- ArrayElement: 2,
- HasFromToArray: 3
- },
- Versioning: {
- None: 0,
- NeedsUpdate: 1,
- MatrixWorldNeedsUpdate: 2
- },
- GetterByBindingType: [
- function getValue_direct(buffer, offset) {
- buffer[offset] = this.node[this.propertyName];
- },
- function getValue_array(buffer, offset) {
- var source = this.resolvedProperty;
- for (var i2 = 0, n = source.length; i2 !== n; ++i2) {
- buffer[offset++] = source[i2];
- }
- },
- function getValue_arrayElement(buffer, offset) {
- buffer[offset] = this.resolvedProperty[this.propertyIndex];
- },
- function getValue_toArray(buffer, offset) {
- this.resolvedProperty.toArray(buffer, offset);
- }
- ],
- SetterByBindingTypeAndVersioning: [
- [
- // Direct
- function setValue_direct(buffer, offset) {
- this.targetObject[this.propertyName] = buffer[offset];
- },
- function setValue_direct_setNeedsUpdate(buffer, offset) {
- this.targetObject[this.propertyName] = buffer[offset];
- this.targetObject.needsUpdate = true;
- },
- function setValue_direct_setMatrixWorldNeedsUpdate(buffer, offset) {
- this.targetObject[this.propertyName] = buffer[offset];
- this.targetObject.matrixWorldNeedsUpdate = true;
- }
- ],
- [
- // EntireArray
- function setValue_array(buffer, offset) {
- var dest = this.resolvedProperty;
- for (var i2 = 0, n = dest.length; i2 !== n; ++i2) {
- dest[i2] = buffer[offset++];
- }
- },
- function setValue_array_setNeedsUpdate(buffer, offset) {
- var dest = this.resolvedProperty;
- for (var i2 = 0, n = dest.length; i2 !== n; ++i2) {
- dest[i2] = buffer[offset++];
- }
- this.targetObject.needsUpdate = true;
- },
- function setValue_array_setMatrixWorldNeedsUpdate(buffer, offset) {
- var dest = this.resolvedProperty;
- for (var i2 = 0, n = dest.length; i2 !== n; ++i2) {
- dest[i2] = buffer[offset++];
- }
- this.targetObject.matrixWorldNeedsUpdate = true;
- }
- ],
- [
- // ArrayElement
- function setValue_arrayElement(buffer, offset) {
- this.resolvedProperty[this.propertyIndex] = buffer[offset];
- },
- function setValue_arrayElement_setNeedsUpdate(buffer, offset) {
- this.resolvedProperty[this.propertyIndex] = buffer[offset];
- this.targetObject.needsUpdate = true;
- },
- function setValue_arrayElement_setMatrixWorldNeedsUpdate(buffer, offset) {
- this.resolvedProperty[this.propertyIndex] = buffer[offset];
- this.targetObject.matrixWorldNeedsUpdate = true;
- }
- ],
- [
- // HasToFromArray
- function setValue_fromArray(buffer, offset) {
- this.resolvedProperty.fromArray(buffer, offset);
- },
- function setValue_fromArray_setNeedsUpdate(buffer, offset) {
- this.resolvedProperty.fromArray(buffer, offset);
- this.targetObject.needsUpdate = true;
- },
- function setValue_fromArray_setMatrixWorldNeedsUpdate(buffer, offset) {
- this.resolvedProperty.fromArray(buffer, offset);
- this.targetObject.matrixWorldNeedsUpdate = true;
- }
- ]
- ],
- getValue: function getValue_unbound(targetArray, offset) {
- this.bind();
- this.getValue(targetArray, offset);
- },
- setValue: function getValue_unbound(sourceArray, offset) {
- this.bind();
- this.setValue(sourceArray, offset);
- },
- // create getter / setter pair for a property in the scene graph
- bind: function() {
- var targetObject = this.node, parsedPath = this.parsedPath, objectName = parsedPath.objectName, propertyName = parsedPath.propertyName, propertyIndex = parsedPath.propertyIndex;
- if (!targetObject) {
- targetObject = PropertyBinding.findNode(this.rootNode, parsedPath.nodeName) || this.rootNode;
- this.node = targetObject;
- }
- this.getValue = this._getValue_unavailable;
- this.setValue = this._setValue_unavailable;
- if (!targetObject) {
- console.error("THREE.PropertyBinding: Trying to update node for track: " + this.path + " but it wasn't found.");
- return;
- }
- if (objectName) {
- var objectIndex = parsedPath.objectIndex;
- switch (objectName) {
- case "materials":
- if (!targetObject.material) {
- console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.", this);
- return;
- }
- if (!targetObject.material.materials) {
- console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.", this);
- return;
- }
- targetObject = targetObject.material.materials;
- break;
- case "bones":
- if (!targetObject.skeleton) {
- console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.", this);
- return;
- }
- targetObject = targetObject.skeleton.bones;
- for (var i2 = 0; i2 < targetObject.length; i2++) {
- if (targetObject[i2].name === objectIndex) {
- objectIndex = i2;
- break;
- }
- }
- break;
- default:
- if (targetObject[objectName] === void 0) {
- console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.", this);
- return;
- }
- targetObject = targetObject[objectName];
- }
- if (objectIndex !== void 0) {
- if (targetObject[objectIndex] === void 0) {
- console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.", this, targetObject);
- return;
- }
- targetObject = targetObject[objectIndex];
- }
- }
- var nodeProperty = targetObject[propertyName];
- if (nodeProperty === void 0) {
- var nodeName = parsedPath.nodeName;
- console.error("THREE.PropertyBinding: Trying to update property for track: " + nodeName + "." + propertyName + " but it wasn't found.", targetObject);
- return;
- }
- var versioning = this.Versioning.None;
- this.targetObject = targetObject;
- if (targetObject.needsUpdate !== void 0) {
- versioning = this.Versioning.NeedsUpdate;
- } else if (targetObject.matrixWorldNeedsUpdate !== void 0) {
- versioning = this.Versioning.MatrixWorldNeedsUpdate;
- }
- var bindingType = this.BindingType.Direct;
- if (propertyIndex !== void 0) {
- if (propertyName === "morphTargetInfluences") {
- if (!targetObject.geometry) {
- console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.", this);
- return;
- }
- if (targetObject.geometry.isBufferGeometry) {
- if (!targetObject.geometry.morphAttributes) {
- console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.", this);
- return;
- }
- for (var i2 = 0; i2 < this.node.geometry.morphAttributes.position.length; i2++) {
- if (targetObject.geometry.morphAttributes.position[i2].name === propertyIndex) {
- propertyIndex = i2;
- break;
- }
- }
- } else {
- if (!targetObject.geometry.morphTargets) {
- console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphTargets.", this);
- return;
- }
- for (var i2 = 0; i2 < this.node.geometry.morphTargets.length; i2++) {
- if (targetObject.geometry.morphTargets[i2].name === propertyIndex) {
- propertyIndex = i2;
- break;
- }
- }
- }
- }
- bindingType = this.BindingType.ArrayElement;
- this.resolvedProperty = nodeProperty;
- this.propertyIndex = propertyIndex;
- } else if (nodeProperty.fromArray !== void 0 && nodeProperty.toArray !== void 0) {
- bindingType = this.BindingType.HasFromToArray;
- this.resolvedProperty = nodeProperty;
- } else if (Array.isArray(nodeProperty)) {
- bindingType = this.BindingType.EntireArray;
- this.resolvedProperty = nodeProperty;
- } else {
- this.propertyName = propertyName;
- }
- this.getValue = this.GetterByBindingType[bindingType];
- this.setValue = this.SetterByBindingTypeAndVersioning[bindingType][versioning];
- },
- unbind: function() {
- this.node = null;
- this.getValue = this._getValue_unbound;
- this.setValue = this._setValue_unbound;
- }
- });
- //!\ DECLARE ALIAS AFTER assign prototype !
- Object.assign(PropertyBinding.prototype, {
- // initial state of these methods that calls 'bind'
- _getValue_unbound: PropertyBinding.prototype.getValue,
- _setValue_unbound: PropertyBinding.prototype.setValue
- });
- function AnimationObjectGroup() {
- this.uuid = MathUtils.generateUUID();
- this._objects = Array.prototype.slice.call(arguments);
- this.nCachedObjects_ = 0;
- var indices = {};
- this._indicesByUUID = indices;
- for (var i2 = 0, n = arguments.length; i2 !== n; ++i2) {
- indices[arguments[i2].uuid] = i2;
- }
- this._paths = [];
- this._parsedPaths = [];
- this._bindings = [];
- this._bindingsIndicesByPath = {};
- var scope = this;
- this.stats = {
- objects: {
- get total() {
- return scope._objects.length;
- },
- get inUse() {
- return this.total - scope.nCachedObjects_;
- }
- },
- get bindingsPerObject() {
- return scope._bindings.length;
- }
- };
- }
- Object.assign(AnimationObjectGroup.prototype, {
- isAnimationObjectGroup: true,
- add: function() {
- 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;
- for (var i2 = 0, n = arguments.length; i2 !== n; ++i2) {
- var object = arguments[i2], uuid = object.uuid, index = indicesByUUID[uuid];
- if (index === void 0) {
- index = nObjects++;
- indicesByUUID[uuid] = index;
- objects.push(object);
- for (var j = 0, m = nBindings; j !== m; ++j) {
- bindings[j].push(new PropertyBinding(object, paths[j], parsedPaths[j]));
- }
- } else if (index < nCachedObjects) {
- knownObject = objects[index];
- var firstActiveIndex = --nCachedObjects, lastCachedObject = objects[firstActiveIndex];
- indicesByUUID[lastCachedObject.uuid] = index;
- objects[index] = lastCachedObject;
- indicesByUUID[uuid] = firstActiveIndex;
- objects[firstActiveIndex] = object;
- for (var j = 0, m = nBindings; j !== m; ++j) {
- var bindingsForPath = bindings[j], lastCached = bindingsForPath[firstActiveIndex], binding = bindingsForPath[index];
- bindingsForPath[index] = lastCached;
- if (binding === void 0) {
- binding = new PropertyBinding(object, paths[j], parsedPaths[j]);
- }
- bindingsForPath[firstActiveIndex] = binding;
- }
- } else if (objects[index] !== knownObject) {
- console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.");
- }
- }
- this.nCachedObjects_ = nCachedObjects;
- },
- remove: function() {
- var objects = this._objects, nCachedObjects = this.nCachedObjects_, indicesByUUID = this._indicesByUUID, bindings = this._bindings, nBindings = bindings.length;
- for (var i2 = 0, n = arguments.length; i2 !== n; ++i2) {
- var object = arguments[i2], uuid = object.uuid, index = indicesByUUID[uuid];
- if (index !== void 0 && index >= nCachedObjects) {
- var lastCachedIndex = nCachedObjects++, firstActiveObject = objects[lastCachedIndex];
- indicesByUUID[firstActiveObject.uuid] = index;
- objects[index] = firstActiveObject;
- indicesByUUID[uuid] = lastCachedIndex;
- objects[lastCachedIndex] = object;
- for (var j = 0, m = nBindings; j !== m; ++j) {
- var bindingsForPath = bindings[j], firstActive = bindingsForPath[lastCachedIndex], binding = bindingsForPath[index];
- bindingsForPath[index] = firstActive;
- bindingsForPath[lastCachedIndex] = binding;
- }
- }
- }
- this.nCachedObjects_ = nCachedObjects;
- },
- // remove & forget
- uncache: function() {
- var objects = this._objects, nObjects = objects.length, nCachedObjects = this.nCachedObjects_, indicesByUUID = this._indicesByUUID, bindings = this._bindings, nBindings = bindings.length;
- for (var i2 = 0, n = arguments.length; i2 !== n; ++i2) {
- var object = arguments[i2], uuid = object.uuid, index = indicesByUUID[uuid];
- if (index !== void 0) {
- delete indicesByUUID[uuid];
- if (index < nCachedObjects) {
- var firstActiveIndex = --nCachedObjects, lastCachedObject = objects[firstActiveIndex], lastIndex = --nObjects, lastObject = objects[lastIndex];
- indicesByUUID[lastCachedObject.uuid] = index;
- objects[index] = lastCachedObject;
- indicesByUUID[lastObject.uuid] = firstActiveIndex;
- objects[firstActiveIndex] = lastObject;
- objects.pop();
- for (var j = 0, m = nBindings; j !== m; ++j) {
- var bindingsForPath = bindings[j], lastCached = bindingsForPath[firstActiveIndex], last = bindingsForPath[lastIndex];
- bindingsForPath[index] = lastCached;
- bindingsForPath[firstActiveIndex] = last;
- bindingsForPath.pop();
- }
- } else {
- var lastIndex = --nObjects, lastObject = objects[lastIndex];
- indicesByUUID[lastObject.uuid] = index;
- objects[index] = lastObject;
- objects.pop();
- for (var j = 0, m = nBindings; j !== m; ++j) {
- var bindingsForPath = bindings[j];
- bindingsForPath[index] = bindingsForPath[lastIndex];
- bindingsForPath.pop();
- }
- }
- }
- }
- this.nCachedObjects_ = nCachedObjects;
- },
- // Internal interface used by befriended PropertyBinding.Composite:
- subscribe_: function(path, parsedPath) {
- var indicesByPath = this._bindingsIndicesByPath, index = indicesByPath[path], bindings = this._bindings;
- if (index !== void 0)
- return bindings[index];
- var paths = this._paths, parsedPaths = this._parsedPaths, objects = this._objects, nObjects = objects.length, nCachedObjects = this.nCachedObjects_, bindingsForPath = new Array(nObjects);
- index = bindings.length;
- indicesByPath[path] = index;
- paths.push(path);
- parsedPaths.push(parsedPath);
- bindings.push(bindingsForPath);
- for (var i2 = nCachedObjects, n = objects.length; i2 !== n; ++i2) {
- var object = objects[i2];
- bindingsForPath[i2] = new PropertyBinding(object, path, parsedPath);
- }
- return bindingsForPath;
- },
- unsubscribe_: function(path) {
- var indicesByPath = this._bindingsIndicesByPath, index = indicesByPath[path];
- if (index !== void 0) {
- var paths = this._paths, parsedPaths = this._parsedPaths, bindings = this._bindings, lastBindingsIndex = bindings.length - 1, lastBindings = bindings[lastBindingsIndex], lastBindingsPath = path[lastBindingsIndex];
- indicesByPath[lastBindingsPath] = index;
- bindings[index] = lastBindings;
- bindings.pop();
- parsedPaths[index] = parsedPaths[lastBindingsIndex];
- parsedPaths.pop();
- paths[index] = paths[lastBindingsIndex];
- paths.pop();
- }
- }
- });
- function AnimationAction(mixer, clip, localRoot) {
- this._mixer = mixer;
- this._clip = clip;
- this._localRoot = localRoot || null;
- var tracks = clip.tracks, nTracks = tracks.length, interpolants = new Array(nTracks);
- var interpolantSettings = {
- endingStart: ZeroCurvatureEnding,
- endingEnd: ZeroCurvatureEnding
- };
- for (var i2 = 0; i2 !== nTracks; ++i2) {
- var interpolant = tracks[i2].createInterpolant(null);
- interpolants[i2] = interpolant;
- interpolant.settings = interpolantSettings;
- }
- this._interpolantSettings = interpolantSettings;
- this._interpolants = interpolants;
- this._propertyBindings = new Array(nTracks);
- this._cacheIndex = null;
- this._byClipCacheIndex = null;
- this._timeScaleInterpolant = null;
- this._weightInterpolant = null;
- this.loop = LoopRepeat;
- this._loopCount = -1;
- this._startTime = null;
- this.time = 0;
- this.timeScale = 1;
- this._effectiveTimeScale = 1;
- this.weight = 1;
- this._effectiveWeight = 1;
- this.repetitions = Infinity;
- this.paused = false;
- this.enabled = true;
- this.clampWhenFinished = false;
- this.zeroSlopeAtStart = true;
- this.zeroSlopeAtEnd = true;
- }
- Object.assign(AnimationAction.prototype, {
- // State & Scheduling
- play: function() {
- this._mixer._activateAction(this);
- return this;
- },
- stop: function() {
- this._mixer._deactivateAction(this);
- return this.reset();
- },
- reset: function() {
- this.paused = false;
- this.enabled = true;
- this.time = 0;
- this._loopCount = -1;
- this._startTime = null;
- return this.stopFading().stopWarping();
- },
- isRunning: function() {
- return this.enabled && !this.paused && this.timeScale !== 0 && this._startTime === null && this._mixer._isActiveAction(this);
- },
- // return true when play has been called
- isScheduled: function() {
- return this._mixer._isActiveAction(this);
- },
- startAt: function(time) {
- this._startTime = time;
- return this;
- },
- setLoop: function(mode, repetitions) {
- this.loop = mode;
- this.repetitions = repetitions;
- return this;
- },
- // Weight
- // set the weight stopping any scheduled fading
- // although .enabled = false yields an effective weight of zero, this
- // method does *not* change .enabled, because it would be confusing
- setEffectiveWeight: function(weight) {
- this.weight = weight;
- this._effectiveWeight = this.enabled ? weight : 0;
- return this.stopFading();
- },
- // return the weight considering fading and .enabled
- getEffectiveWeight: function() {
- return this._effectiveWeight;
- },
- fadeIn: function(duration) {
- return this._scheduleFading(duration, 0, 1);
- },
- fadeOut: function(duration) {
- return this._scheduleFading(duration, 1, 0);
- },
- crossFadeFrom: function(fadeOutAction, duration, warp) {
- fadeOutAction.fadeOut(duration);
- this.fadeIn(duration);
- if (warp) {
- var fadeInDuration = this._clip.duration, fadeOutDuration = fadeOutAction._clip.duration, startEndRatio = fadeOutDuration / fadeInDuration, endStartRatio = fadeInDuration / fadeOutDuration;
- fadeOutAction.warp(1, startEndRatio, duration);
- this.warp(endStartRatio, 1, duration);
- }
- return this;
- },
- crossFadeTo: function(fadeInAction, duration, warp) {
- return fadeInAction.crossFadeFrom(this, duration, warp);
- },
- stopFading: function() {
- var weightInterpolant = this._weightInterpolant;
- if (weightInterpolant !== null) {
- this._weightInterpolant = null;
- this._mixer._takeBackControlInterpolant(weightInterpolant);
- }
- return this;
- },
- // Time Scale Control
- // set the time scale stopping any scheduled warping
- // although .paused = true yields an effective time scale of zero, this
- // method does *not* change .paused, because it would be confusing
- setEffectiveTimeScale: function(timeScale) {
- this.timeScale = timeScale;
- this._effectiveTimeScale = this.paused ? 0 : timeScale;
- return this.stopWarping();
- },
- // return the time scale considering warping and .paused
- getEffectiveTimeScale: function() {
- return this._effectiveTimeScale;
- },
- setDuration: function(duration) {
- this.timeScale = this._clip.duration / duration;
- return this.stopWarping();
- },
- syncWith: function(action) {
- this.time = action.time;
- this.timeScale = action.timeScale;
- return this.stopWarping();
- },
- halt: function(duration) {
- return this.warp(this._effectiveTimeScale, 0, duration);
- },
- warp: function(startTimeScale, endTimeScale, duration) {
- var mixer = this._mixer, now = mixer.time, interpolant = this._timeScaleInterpolant, timeScale = this.timeScale;
- if (interpolant === null) {
- interpolant = mixer._lendControlInterpolant();
- this._timeScaleInterpolant = interpolant;
- }
- var times = interpolant.parameterPositions, values = interpolant.sampleValues;
- times[0] = now;
- times[1] = now + duration;
- values[0] = startTimeScale / timeScale;
- values[1] = endTimeScale / timeScale;
- return this;
- },
- stopWarping: function() {
- var timeScaleInterpolant = this._timeScaleInterpolant;
- if (timeScaleInterpolant !== null) {
- this._timeScaleInterpolant = null;
- this._mixer._takeBackControlInterpolant(timeScaleInterpolant);
- }
- return this;
- },
- // Object Accessors
- getMixer: function() {
- return this._mixer;
- },
- getClip: function() {
- return this._clip;
- },
- getRoot: function() {
- return this._localRoot || this._mixer._root;
- },
- // Interna
- _update: function(time, deltaTime, timeDirection, accuIndex) {
- if (!this.enabled) {
- this._updateWeight(time);
- return;
- }
- var startTime = this._startTime;
- if (startTime !== null) {
- var timeRunning = (time - startTime) * timeDirection;
- if (timeRunning < 0 || timeDirection === 0) {
- return;
- }
- this._startTime = null;
- deltaTime = timeDirection * timeRunning;
- }
- deltaTime *= this._updateTimeScale(time);
- var clipTime = this._updateTime(deltaTime);
- var weight = this._updateWeight(time);
- if (weight > 0) {
- var interpolants = this._interpolants;
- var propertyMixers = this._propertyBindings;
- for (var j = 0, m = interpolants.length; j !== m; ++j) {
- interpolants[j].evaluate(clipTime);
- propertyMixers[j].accumulate(accuIndex, weight);
- }
- }
- },
- _updateWeight: function(time) {
- var weight = 0;
- if (this.enabled) {
- weight = this.weight;
- var interpolant = this._weightInterpolant;
- if (interpolant !== null) {
- var interpolantValue = interpolant.evaluate(time)[0];
- weight *= interpolantValue;
- if (time > interpolant.parameterPositions[1]) {
- this.stopFading();
- if (interpolantValue === 0) {
- this.enabled = false;
- }
- }
- }
- }
- this._effectiveWeight = weight;
- return weight;
- },
- _updateTimeScale: function(time) {
- var timeScale = 0;
- if (!this.paused) {
- timeScale = this.timeScale;
- var interpolant = this._timeScaleInterpolant;
- if (interpolant !== null) {
- var interpolantValue = interpolant.evaluate(time)[0];
- timeScale *= interpolantValue;
- if (time > interpolant.parameterPositions[1]) {
- this.stopWarping();
- if (timeScale === 0) {
- this.paused = true;
- } else {
- this.timeScale = timeScale;
- }
- }
- }
- }
- this._effectiveTimeScale = timeScale;
- return timeScale;
- },
- _updateTime: function(deltaTime) {
- var time = this.time + deltaTime;
- var duration = this._clip.duration;
- var loop = this.loop;
- var loopCount = this._loopCount;
- var pingPong = loop === LoopPingPong;
- if (deltaTime === 0) {
- if (loopCount === -1)
- return time;
- return pingPong && (loopCount & 1) === 1 ? duration - time : time;
- }
- if (loop === LoopOnce) {
- if (loopCount === -1) {
- this._loopCount = 0;
- this._setEndings(true, true, false);
- }
- handle_stop: {
- if (time >= duration) {
- time = duration;
- } else if (time < 0) {
- time = 0;
- } else {
- this.time = time;
- break handle_stop;
- }
- if (this.clampWhenFinished)
- this.paused = true;
- else
- this.enabled = false;
- this.time = time;
- this._mixer.dispatchEvent({
- type: "finished",
- action: this,
- direction: deltaTime < 0 ? -1 : 1
- });
- }
- } else {
- if (loopCount === -1) {
- if (deltaTime >= 0) {
- loopCount = 0;
- this._setEndings(true, this.repetitions === 0, pingPong);
- } else {
- this._setEndings(this.repetitions === 0, true, pingPong);
- }
- }
- if (time >= duration || time < 0) {
- var loopDelta = Math.floor(time / duration);
- time -= duration * loopDelta;
- loopCount += Math.abs(loopDelta);
- var pending = this.repetitions - loopCount;
- if (pending <= 0) {
- if (this.clampWhenFinished)
- this.paused = true;
- else
- this.enabled = false;
- time = deltaTime > 0 ? duration : 0;
- this.time = time;
- this._mixer.dispatchEvent({
- type: "finished",
- action: this,
- direction: deltaTime > 0 ? 1 : -1
- });
- } else {
- if (pending === 1) {
- var atStart = deltaTime < 0;
- this._setEndings(atStart, !atStart, pingPong);
- } else {
- this._setEndings(false, false, pingPong);
- }
- this._loopCount = loopCount;
- this.time = time;
- this._mixer.dispatchEvent({
- type: "loop",
- action: this,
- loopDelta
- });
- }
- } else {
- this.time = time;
- }
- if (pingPong && (loopCount & 1) === 1) {
- return duration - time;
- }
- }
- return time;
- },
- _setEndings: function(atStart, atEnd, pingPong) {
- var settings = this._interpolantSettings;
- if (pingPong) {
- settings.endingStart = ZeroSlopeEnding;
- settings.endingEnd = ZeroSlopeEnding;
- } else {
- if (atStart) {
- settings.endingStart = this.zeroSlopeAtStart ? ZeroSlopeEnding : ZeroCurvatureEnding;
- } else {
- settings.endingStart = WrapAroundEnding;
- }
- if (atEnd) {
- settings.endingEnd = this.zeroSlopeAtEnd ? ZeroSlopeEnding : ZeroCurvatureEnding;
- } else {
- settings.endingEnd = WrapAroundEnding;
- }
- }
- },
- _scheduleFading: function(duration, weightNow, weightThen) {
- var mixer = this._mixer, now = mixer.time, interpolant = this._weightInterpolant;
- if (interpolant === null) {
- interpolant = mixer._lendControlInterpolant();
- this._weightInterpolant = interpolant;
- }
- var times = interpolant.parameterPositions, values = interpolant.sampleValues;
- times[0] = now;
- values[0] = weightNow;
- times[1] = now + duration;
- values[1] = weightThen;
- return this;
- }
- });
- function AnimationMixer(root) {
- this._root = root;
- this._initMemoryManager();
- this._accuIndex = 0;
- this.time = 0;
- this.timeScale = 1;
- }
- AnimationMixer.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
- constructor: AnimationMixer,
- _bindAction: function(action, prototypeAction) {
- 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];
- if (bindingsByName === void 0) {
- bindingsByName = {};
- bindingsByRoot[rootUuid] = bindingsByName;
- }
- for (var i2 = 0; i2 !== nTracks; ++i2) {
- var track = tracks[i2], trackName = track.name, binding = bindingsByName[trackName];
- if (binding !== void 0) {
- bindings[i2] = binding;
- } else {
- binding = bindings[i2];
- if (binding !== void 0) {
- if (binding._cacheIndex === null) {
- ++binding.referenceCount;
- this._addInactiveBinding(binding, rootUuid, trackName);
- }
- continue;
- }
- var path = prototypeAction && prototypeAction._propertyBindings[i2].binding.parsedPath;
- binding = new PropertyMixer(
- PropertyBinding.create(root, trackName, path),
- track.ValueTypeName,
- track.getValueSize()
- );
- ++binding.referenceCount;
- this._addInactiveBinding(binding, rootUuid, trackName);
- bindings[i2] = binding;
- }
- interpolants[i2].resultBuffer = binding.buffer;
- }
- },
- _activateAction: function(action) {
- if (!this._isActiveAction(action)) {
- if (action._cacheIndex === null) {
- var rootUuid = (action._localRoot || this._root).uuid, clipUuid = action._clip.uuid, actionsForClip = this._actionsByClip[clipUuid];
- this._bindAction(
- action,
- actionsForClip && actionsForClip.knownActions[0]
- );
- this._addInactiveAction(action, clipUuid, rootUuid);
- }
- var bindings = action._propertyBindings;
- for (var i2 = 0, n = bindings.length; i2 !== n; ++i2) {
- var binding = bindings[i2];
- if (binding.useCount++ === 0) {
- this._lendBinding(binding);
- binding.saveOriginalState();
- }
- }
- this._lendAction(action);
- }
- },
- _deactivateAction: function(action) {
- if (this._isActiveAction(action)) {
- var bindings = action._propertyBindings;
- for (var i2 = 0, n = bindings.length; i2 !== n; ++i2) {
- var binding = bindings[i2];
- if (--binding.useCount === 0) {
- binding.restoreOriginalState();
- this._takeBackBinding(binding);
- }
- }
- this._takeBackAction(action);
- }
- },
- // Memory manager
- _initMemoryManager: function() {
- this._actions = [];
- this._nActiveActions = 0;
- this._actionsByClip = {};
- this._bindings = [];
- this._nActiveBindings = 0;
- this._bindingsByRootAndName = {};
- this._controlInterpolants = [];
- this._nActiveControlInterpolants = 0;
- var scope = this;
- this.stats = {
- actions: {
- get total() {
- return scope._actions.length;
- },
- get inUse() {
- return scope._nActiveActions;
- }
- },
- bindings: {
- get total() {
- return scope._bindings.length;
- },
- get inUse() {
- return scope._nActiveBindings;
- }
- },
- controlInterpolants: {
- get total() {
- return scope._controlInterpolants.length;
- },
- get inUse() {
- return scope._nActiveControlInterpolants;
- }
- }
- };
- },
- // Memory management for AnimationAction objects
- _isActiveAction: function(action) {
- var index = action._cacheIndex;
- return index !== null && index < this._nActiveActions;
- },
- _addInactiveAction: function(action, clipUuid, rootUuid) {
- var actions = this._actions, actionsByClip = this._actionsByClip, actionsForClip = actionsByClip[clipUuid];
- if (actionsForClip === void 0) {
- actionsForClip = {
- knownActions: [action],
- actionByRoot: {}
- };
- action._byClipCacheIndex = 0;
- actionsByClip[clipUuid] = actionsForClip;
- } else {
- var knownActions = actionsForClip.knownActions;
- action._byClipCacheIndex = knownActions.length;
- knownActions.push(action);
- }
- action._cacheIndex = actions.length;
- actions.push(action);
- actionsForClip.actionByRoot[rootUuid] = action;
- },
- _removeInactiveAction: function(action) {
- var actions = this._actions, lastInactiveAction = actions[actions.length - 1], cacheIndex = action._cacheIndex;
- lastInactiveAction._cacheIndex = cacheIndex;
- actions[cacheIndex] = lastInactiveAction;
- actions.pop();
- action._cacheIndex = null;
- var clipUuid = action._clip.uuid, actionsByClip = this._actionsByClip, actionsForClip = actionsByClip[clipUuid], knownActionsForClip = actionsForClip.knownActions, lastKnownAction = knownActionsForClip[knownActionsForClip.length - 1], byClipCacheIndex = action._byClipCacheIndex;
- lastKnownAction._byClipCacheIndex = byClipCacheIndex;
- knownActionsForClip[byClipCacheIndex] = lastKnownAction;
- knownActionsForClip.pop();
- action._byClipCacheIndex = null;
- var actionByRoot = actionsForClip.actionByRoot, rootUuid = (action._localRoot || this._root).uuid;
- delete actionByRoot[rootUuid];
- if (knownActionsForClip.length === 0) {
- delete actionsByClip[clipUuid];
- }
- this._removeInactiveBindingsForAction(action);
- },
- _removeInactiveBindingsForAction: function(action) {
- var bindings = action._propertyBindings;
- for (var i2 = 0, n = bindings.length; i2 !== n; ++i2) {
- var binding = bindings[i2];
- if (--binding.referenceCount === 0) {
- this._removeInactiveBinding(binding);
- }
- }
- },
- _lendAction: function(action) {
- var actions = this._actions, prevIndex = action._cacheIndex, lastActiveIndex = this._nActiveActions++, firstInactiveAction = actions[lastActiveIndex];
- action._cacheIndex = lastActiveIndex;
- actions[lastActiveIndex] = action;
- firstInactiveAction._cacheIndex = prevIndex;
- actions[prevIndex] = firstInactiveAction;
- },
- _takeBackAction: function(action) {
- var actions = this._actions, prevIndex = action._cacheIndex, firstInactiveIndex = --this._nActiveActions, lastActiveAction = actions[firstInactiveIndex];
- action._cacheIndex = firstInactiveIndex;
- actions[firstInactiveIndex] = action;
- lastActiveAction._cacheIndex = prevIndex;
- actions[prevIndex] = lastActiveAction;
- },
- // Memory management for PropertyMixer objects
- _addInactiveBinding: function(binding, rootUuid, trackName) {
- var bindingsByRoot = this._bindingsByRootAndName, bindingByName = bindingsByRoot[rootUuid], bindings = this._bindings;
- if (bindingByName === void 0) {
- bindingByName = {};
- bindingsByRoot[rootUuid] = bindingByName;
- }
- bindingByName[trackName] = binding;
- binding._cacheIndex = bindings.length;
- bindings.push(binding);
- },
- _removeInactiveBinding: function(binding) {
- 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;
- lastInactiveBinding._cacheIndex = cacheIndex;
- bindings[cacheIndex] = lastInactiveBinding;
- bindings.pop();
- delete bindingByName[trackName];
- if (Object.keys(bindingByName).length === 0) {
- delete bindingsByRoot[rootUuid];
- }
- },
- _lendBinding: function(binding) {
- var bindings = this._bindings, prevIndex = binding._cacheIndex, lastActiveIndex = this._nActiveBindings++, firstInactiveBinding = bindings[lastActiveIndex];
- binding._cacheIndex = lastActiveIndex;
- bindings[lastActiveIndex] = binding;
- firstInactiveBinding._cacheIndex = prevIndex;
- bindings[prevIndex] = firstInactiveBinding;
- },
- _takeBackBinding: function(binding) {
- var bindings = this._bindings, prevIndex = binding._cacheIndex, firstInactiveIndex = --this._nActiveBindings, lastActiveBinding = bindings[firstInactiveIndex];
- binding._cacheIndex = firstInactiveIndex;
- bindings[firstInactiveIndex] = binding;
- lastActiveBinding._cacheIndex = prevIndex;
- bindings[prevIndex] = lastActiveBinding;
- },
- // Memory management of Interpolants for weight and time scale
- _lendControlInterpolant: function() {
- var interpolants = this._controlInterpolants, lastActiveIndex = this._nActiveControlInterpolants++, interpolant = interpolants[lastActiveIndex];
- if (interpolant === void 0) {
- interpolant = new LinearInterpolant(
- new Float32Array(2),
- new Float32Array(2),
- 1,
- this._controlInterpolantsResultBuffer
- );
- interpolant.__cacheIndex = lastActiveIndex;
- interpolants[lastActiveIndex] = interpolant;
- }
- return interpolant;
- },
- _takeBackControlInterpolant: function(interpolant) {
- var interpolants = this._controlInterpolants, prevIndex = interpolant.__cacheIndex, firstInactiveIndex = --this._nActiveControlInterpolants, lastActiveInterpolant = interpolants[firstInactiveIndex];
- interpolant.__cacheIndex = firstInactiveIndex;
- interpolants[firstInactiveIndex] = interpolant;
- lastActiveInterpolant.__cacheIndex = prevIndex;
- interpolants[prevIndex] = lastActiveInterpolant;
- },
- _controlInterpolantsResultBuffer: new Float32Array(1),
- // return an action for a clip optionally using a custom root target
- // object (this method allocates a lot of dynamic memory in case a
- // previously unknown clip/root combination is specified)
- clipAction: function(clip, optionalRoot) {
- 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;
- if (actionsForClip !== void 0) {
- var existingAction = actionsForClip.actionByRoot[rootUuid];
- if (existingAction !== void 0) {
- return existingAction;
- }
- prototypeAction = actionsForClip.knownActions[0];
- if (clipObject === null)
- clipObject = prototypeAction._clip;
- }
- if (clipObject === null)
- return null;
- var newAction = new AnimationAction(this, clipObject, optionalRoot);
- this._bindAction(newAction, prototypeAction);
- this._addInactiveAction(newAction, clipUuid, rootUuid);
- return newAction;
- },
- // get an existing action
- existingAction: function(clip, optionalRoot) {
- 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];
- if (actionsForClip !== void 0) {
- return actionsForClip.actionByRoot[rootUuid] || null;
- }
- return null;
- },
- // deactivates all previously scheduled actions
- stopAllAction: function() {
- var actions = this._actions, nActions = this._nActiveActions, bindings = this._bindings, nBindings = this._nActiveBindings;
- this._nActiveActions = 0;
- this._nActiveBindings = 0;
- for (var i2 = 0; i2 !== nActions; ++i2) {
- actions[i2].reset();
- }
- for (var i2 = 0; i2 !== nBindings; ++i2) {
- bindings[i2].useCount = 0;
- }
- return this;
- },
- // advance the time and update apply the animation
- update: function(deltaTime) {
- deltaTime *= this.timeScale;
- var actions = this._actions, nActions = this._nActiveActions, time = this.time += deltaTime, timeDirection = Math.sign(deltaTime), accuIndex = this._accuIndex ^= 1;
- for (var i2 = 0; i2 !== nActions; ++i2) {
- var action = actions[i2];
- action._update(time, deltaTime, timeDirection, accuIndex);
- }
- var bindings = this._bindings, nBindings = this._nActiveBindings;
- for (var i2 = 0; i2 !== nBindings; ++i2) {
- bindings[i2].apply(accuIndex);
- }
- return this;
- },
- // Allows you to seek to a specific time in an animation.
- setTime: function(timeInSeconds) {
- this.time = 0;
- for (var i2 = 0; i2 < this._actions.length; i2++) {
- this._actions[i2].time = 0;
- }
- return this.update(timeInSeconds);
- },
- // return this mixer's root target object
- getRoot: function() {
- return this._root;
- },
- // free all resources specific to a particular clip
- uncacheClip: function(clip) {
- var actions = this._actions, clipUuid = clip.uuid, actionsByClip = this._actionsByClip, actionsForClip = actionsByClip[clipUuid];
- if (actionsForClip !== void 0) {
- var actionsToRemove = actionsForClip.knownActions;
- for (var i2 = 0, n = actionsToRemove.length; i2 !== n; ++i2) {
- var action = actionsToRemove[i2];
- this._deactivateAction(action);
- var cacheIndex = action._cacheIndex, lastInactiveAction = actions[actions.length - 1];
- action._cacheIndex = null;
- action._byClipCacheIndex = null;
- lastInactiveAction._cacheIndex = cacheIndex;
- actions[cacheIndex] = lastInactiveAction;
- actions.pop();
- this._removeInactiveBindingsForAction(action);
- }
- delete actionsByClip[clipUuid];
- }
- },
- // free all resources specific to a particular root target object
- uncacheRoot: function(root) {
- var rootUuid = root.uuid, actionsByClip = this._actionsByClip;
- for (var clipUuid in actionsByClip) {
- var actionByRoot = actionsByClip[clipUuid].actionByRoot, action = actionByRoot[rootUuid];
- if (action !== void 0) {
- this._deactivateAction(action);
- this._removeInactiveAction(action);
- }
- }
- var bindingsByRoot = this._bindingsByRootAndName, bindingByName = bindingsByRoot[rootUuid];
- if (bindingByName !== void 0) {
- for (var trackName in bindingByName) {
- var binding = bindingByName[trackName];
- binding.restoreOriginalState();
- this._removeInactiveBinding(binding);
- }
- }
- },
- // remove a targeted clip from the cache
- uncacheAction: function(clip, optionalRoot) {
- var action = this.existingAction(clip, optionalRoot);
- if (action !== null) {
- this._deactivateAction(action);
- this._removeInactiveAction(action);
- }
- }
- });
- function Uniform(value) {
- if (typeof value === "string") {
- console.warn("THREE.Uniform: Type parameter is no longer needed.");
- value = arguments[1];
- }
- this.value = value;
- }
- Uniform.prototype.clone = function() {
- return new Uniform(this.value.clone === void 0 ? this.value : this.value.clone());
- };
- function InstancedInterleavedBuffer(array, stride, meshPerAttribute) {
- InterleavedBuffer.call(this, array, stride);
- this.meshPerAttribute = meshPerAttribute || 1;
- }
- InstancedInterleavedBuffer.prototype = Object.assign(Object.create(InterleavedBuffer.prototype), {
- constructor: InstancedInterleavedBuffer,
- isInstancedInterleavedBuffer: true,
- copy: function(source) {
- InterleavedBuffer.prototype.copy.call(this, source);
- this.meshPerAttribute = source.meshPerAttribute;
- return this;
- }
- });
- function Raycaster(origin, direction, near, far) {
- this.ray = new Ray(origin, direction);
- this.near = near || 0;
- this.far = far || Infinity;
- this.camera = null;
- this.params = {
- Mesh: {},
- Line: {},
- LOD: {},
- Points: { threshold: 1 },
- Sprite: {}
- };
- Object.defineProperties(this.params, {
- PointCloud: {
- get: function() {
- console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points.");
- return this.Points;
- }
- }
- });
- }
- function ascSort(a, b) {
- return a.distance - b.distance;
- }
- function intersectObject(object, raycaster, intersects2, recursive) {
- if (object.visible === false)
- return;
- object.raycast(raycaster, intersects2);
- if (recursive === true) {
- var children = object.children;
- for (var i2 = 0, l = children.length; i2 < l; i2++) {
- intersectObject(children[i2], raycaster, intersects2, true);
- }
- }
- }
- Object.assign(Raycaster.prototype, {
- linePrecision: 1,
- set: function(origin, direction) {
- this.ray.set(origin, direction);
- },
- setFromCamera: function(coords, camera) {
- if (camera && camera.isPerspectiveCamera) {
- this.ray.origin.setFromMatrixPosition(camera.matrixWorld);
- this.ray.direction.set(coords.x, coords.y, 0.5).unproject(camera).sub(this.ray.origin).normalize();
- this.camera = camera;
- } else if (camera && camera.isOrthographicCamera) {
- this.ray.origin.set(coords.x, coords.y, (camera.near + camera.far) / (camera.near - camera.far)).unproject(camera);
- this.ray.direction.set(0, 0, -1).transformDirection(camera.matrixWorld);
- this.camera = camera;
- } else {
- console.error("THREE.Raycaster: Unsupported camera type.");
- }
- },
- intersectObject: function(object, recursive, optionalTarget) {
- var intersects2 = optionalTarget || [];
- intersectObject(object, this, intersects2, recursive);
- intersects2.sort(ascSort);
- return intersects2;
- },
- intersectObjects: function(objects, recursive, optionalTarget) {
- var intersects2 = optionalTarget || [];
- if (Array.isArray(objects) === false) {
- console.warn("THREE.Raycaster.intersectObjects: objects is not an Array.");
- return intersects2;
- }
- for (var i2 = 0, l = objects.length; i2 < l; i2++) {
- intersectObject(objects[i2], this, intersects2, recursive);
- }
- intersects2.sort(ascSort);
- return intersects2;
- }
- });
- function Spherical(radius, phi, theta) {
- this.radius = radius !== void 0 ? radius : 1;
- this.phi = phi !== void 0 ? phi : 0;
- this.theta = theta !== void 0 ? theta : 0;
- return this;
- }
- Object.assign(Spherical.prototype, {
- set: function(radius, phi, theta) {
- this.radius = radius;
- this.phi = phi;
- this.theta = theta;
- return this;
- },
- clone: function() {
- return new this.constructor().copy(this);
- },
- copy: function(other) {
- this.radius = other.radius;
- this.phi = other.phi;
- this.theta = other.theta;
- return this;
- },
- // restrict phi to be betwee EPS and PI-EPS
- makeSafe: function() {
- var EPS = 1e-6;
- this.phi = Math.max(EPS, Math.min(Math.PI - EPS, this.phi));
- return this;
- },
- setFromVector3: function(v) {
- return this.setFromCartesianCoords(v.x, v.y, v.z);
- },
- setFromCartesianCoords: function(x, y, z) {
- this.radius = Math.sqrt(x * x + y * y + z * z);
- if (this.radius === 0) {
- this.theta = 0;
- this.phi = 0;
- } else {
- this.theta = Math.atan2(x, z);
- this.phi = Math.acos(MathUtils.clamp(y / this.radius, -1, 1));
- }
- return this;
- }
- });
- function Cylindrical(radius, theta, y) {
- this.radius = radius !== void 0 ? radius : 1;
- this.theta = theta !== void 0 ? theta : 0;
- this.y = y !== void 0 ? y : 0;
- return this;
- }
- Object.assign(Cylindrical.prototype, {
- set: function(radius, theta, y) {
- this.radius = radius;
- this.theta = theta;
- this.y = y;
- return this;
- },
- clone: function() {
- return new this.constructor().copy(this);
- },
- copy: function(other) {
- this.radius = other.radius;
- this.theta = other.theta;
- this.y = other.y;
- return this;
- },
- setFromVector3: function(v) {
- return this.setFromCartesianCoords(v.x, v.y, v.z);
- },
- setFromCartesianCoords: function(x, y, z) {
- this.radius = Math.sqrt(x * x + z * z);
- this.theta = Math.atan2(x, z);
- this.y = y;
- return this;
- }
- });
- var _vector$7 = new Vector2();
- function Box2(min, max) {
- this.min = min !== void 0 ? min : new Vector2(Infinity, Infinity);
- this.max = max !== void 0 ? max : new Vector2(-Infinity, -Infinity);
- }
- Object.assign(Box2.prototype, {
- set: function(min, max) {
- this.min.copy(min);
- this.max.copy(max);
- return this;
- },
- setFromPoints: function(points) {
- this.makeEmpty();
- for (var i2 = 0, il = points.length; i2 < il; i2++) {
- this.expandByPoint(points[i2]);
- }
- return this;
- },
- setFromCenterAndSize: function(center, size) {
- var halfSize = _vector$7.copy(size).multiplyScalar(0.5);
- this.min.copy(center).sub(halfSize);
- this.max.copy(center).add(halfSize);
- return this;
- },
- clone: function() {
- return new this.constructor().copy(this);
- },
- copy: function(box) {
- this.min.copy(box.min);
- this.max.copy(box.max);
- return this;
- },
- makeEmpty: function() {
- this.min.x = this.min.y = Infinity;
- this.max.x = this.max.y = -Infinity;
- return this;
- },
- isEmpty: function() {
- return this.max.x < this.min.x || this.max.y < this.min.y;
- },
- getCenter: function(target) {
- if (target === void 0) {
- console.warn("THREE.Box2: .getCenter() target is now required");
- target = new Vector2();
- }
- return this.isEmpty() ? target.set(0, 0) : target.addVectors(this.min, this.max).multiplyScalar(0.5);
- },
- getSize: function(target) {
- if (target === void 0) {
- console.warn("THREE.Box2: .getSize() target is now required");
- target = new Vector2();
- }
- return this.isEmpty() ? target.set(0, 0) : target.subVectors(this.max, this.min);
- },
- expandByPoint: function(point) {
- this.min.min(point);
- this.max.max(point);
- return this;
- },
- expandByVector: function(vector) {
- this.min.sub(vector);
- this.max.add(vector);
- return this;
- },
- expandByScalar: function(scalar) {
- this.min.addScalar(-scalar);
- this.max.addScalar(scalar);
- return this;
- },
- containsPoint: function(point) {
- return point.x < this.min.x || point.x > this.max.x || point.y < this.min.y || point.y > this.max.y ? false : true;
- },
- containsBox: function(box) {
- 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;
- },
- getParameter: function(point, target) {
- if (target === void 0) {
- console.warn("THREE.Box2: .getParameter() target is now required");
- target = new Vector2();
- }
- return target.set(
- (point.x - this.min.x) / (this.max.x - this.min.x),
- (point.y - this.min.y) / (this.max.y - this.min.y)
- );
- },
- intersectsBox: function(box) {
- 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;
- },
- clampPoint: function(point, target) {
- if (target === void 0) {
- console.warn("THREE.Box2: .clampPoint() target is now required");
- target = new Vector2();
- }
- return target.copy(point).clamp(this.min, this.max);
- },
- distanceToPoint: function(point) {
- var clampedPoint = _vector$7.copy(point).clamp(this.min, this.max);
- return clampedPoint.sub(point).length();
- },
- intersect: function(box) {
- this.min.max(box.min);
- this.max.min(box.max);
- return this;
- },
- union: function(box) {
- this.min.min(box.min);
- this.max.max(box.max);
- return this;
- },
- translate: function(offset) {
- this.min.add(offset);
- this.max.add(offset);
- return this;
- },
- equals: function(box) {
- return box.min.equals(this.min) && box.max.equals(this.max);
- }
- });
- var _startP = new Vector3();
- var _startEnd = new Vector3();
- function Line3(start, end) {
- this.start = start !== void 0 ? start : new Vector3();
- this.end = end !== void 0 ? end : new Vector3();
- }
- Object.assign(Line3.prototype, {
- set: function(start, end) {
- this.start.copy(start);
- this.end.copy(end);
- return this;
- },
- clone: function() {
- return new this.constructor().copy(this);
- },
- copy: function(line) {
- this.start.copy(line.start);
- this.end.copy(line.end);
- return this;
- },
- getCenter: function(target) {
- if (target === void 0) {
- console.warn("THREE.Line3: .getCenter() target is now required");
- target = new Vector3();
- }
- return target.addVectors(this.start, this.end).multiplyScalar(0.5);
- },
- delta: function(target) {
- if (target === void 0) {
- console.warn("THREE.Line3: .delta() target is now required");
- target = new Vector3();
- }
- return target.subVectors(this.end, this.start);
- },
- distanceSq: function() {
- return this.start.distanceToSquared(this.end);
- },
- distance: function() {
- return this.start.distanceTo(this.end);
- },
- at: function(t, target) {
- if (target === void 0) {
- console.warn("THREE.Line3: .at() target is now required");
- target = new Vector3();
- }
- return this.delta(target).multiplyScalar(t).add(this.start);
- },
- closestPointToPointParameter: function(point, clampToLine) {
- _startP.subVectors(point, this.start);
- _startEnd.subVectors(this.end, this.start);
- var startEnd2 = _startEnd.dot(_startEnd);
- var startEnd_startP = _startEnd.dot(_startP);
- var t = startEnd_startP / startEnd2;
- if (clampToLine) {
- t = MathUtils.clamp(t, 0, 1);
- }
- return t;
- },
- closestPointToPoint: function(point, clampToLine, target) {
- var t = this.closestPointToPointParameter(point, clampToLine);
- if (target === void 0) {
- console.warn("THREE.Line3: .closestPointToPoint() target is now required");
- target = new Vector3();
- }
- return this.delta(target).multiplyScalar(t).add(this.start);
- },
- applyMatrix4: function(matrix) {
- this.start.applyMatrix4(matrix);
- this.end.applyMatrix4(matrix);
- return this;
- },
- equals: function(line) {
- return line.start.equals(this.start) && line.end.equals(this.end);
- }
- });
- function ImmediateRenderObject(material) {
- Object3D.call(this);
- this.material = material;
- this.render = function() {
- };
- }
- ImmediateRenderObject.prototype = Object.create(Object3D.prototype);
- ImmediateRenderObject.prototype.constructor = ImmediateRenderObject;
- ImmediateRenderObject.prototype.isImmediateRenderObject = true;
- var _vector$8 = new Vector3();
- function SpotLightHelper(light, color) {
- Object3D.call(this);
- this.light = light;
- this.light.updateMatrixWorld();
- this.matrix = light.matrixWorld;
- this.matrixAutoUpdate = false;
- this.color = color;
- var geometry = new BufferGeometry();
- var positions = [
- 0,
- 0,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 1,
- 0,
- 1,
- 0,
- 0,
- 0,
- -1,
- 0,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1,
- 1,
- 0,
- 0,
- 0,
- 0,
- -1,
- 1
- ];
- for (var i2 = 0, j = 1, l = 32; i2 < l; i2++, j++) {
- var p1 = i2 / l * Math.PI * 2;
- var p2 = j / l * Math.PI * 2;
- positions.push(
- Math.cos(p1),
- Math.sin(p1),
- 1,
- Math.cos(p2),
- Math.sin(p2),
- 1
- );
- }
- geometry.setAttribute("position", new Float32BufferAttribute(positions, 3));
- var material = new LineBasicMaterial({ fog: false });
- this.cone = new LineSegments(geometry, material);
- this.add(this.cone);
- this.update();
- }
- SpotLightHelper.prototype = Object.create(Object3D.prototype);
- SpotLightHelper.prototype.constructor = SpotLightHelper;
- SpotLightHelper.prototype.dispose = function() {
- this.cone.geometry.dispose();
- this.cone.material.dispose();
- };
- SpotLightHelper.prototype.update = function() {
- this.light.updateMatrixWorld();
- var coneLength = this.light.distance ? this.light.distance : 1e3;
- var coneWidth = coneLength * Math.tan(this.light.angle);
- this.cone.scale.set(coneWidth, coneWidth, coneLength);
- _vector$8.setFromMatrixPosition(this.light.target.matrixWorld);
- this.cone.lookAt(_vector$8);
- if (this.color !== void 0) {
- this.cone.material.color.set(this.color);
- } else {
- this.cone.material.color.copy(this.light.color);
- }
- };
- var _vector$9 = new Vector3();
- var _boneMatrix = new Matrix4();
- var _matrixWorldInv = new Matrix4();
- function getBoneList(object) {
- var boneList = [];
- if (object && object.isBone) {
- boneList.push(object);
- }
- for (var i2 = 0; i2 < object.children.length; i2++) {
- boneList.push.apply(boneList, getBoneList(object.children[i2]));
- }
- return boneList;
- }
- function SkeletonHelper(object) {
- var bones = getBoneList(object);
- var geometry = new BufferGeometry();
- var vertices = [];
- var colors = [];
- var color1 = new Color(0, 0, 1);
- var color2 = new Color(0, 1, 0);
- for (var i2 = 0; i2 < bones.length; i2++) {
- var bone = bones[i2];
- if (bone.parent && bone.parent.isBone) {
- vertices.push(0, 0, 0);
- vertices.push(0, 0, 0);
- colors.push(color1.r, color1.g, color1.b);
- colors.push(color2.r, color2.g, color2.b);
- }
- }
- geometry.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- geometry.setAttribute("color", new Float32BufferAttribute(colors, 3));
- var material = new LineBasicMaterial({ vertexColors: VertexColors, depthTest: false, depthWrite: false, transparent: true });
- LineSegments.call(this, geometry, material);
- this.root = object;
- this.bones = bones;
- this.matrix = object.matrixWorld;
- this.matrixAutoUpdate = false;
- }
- SkeletonHelper.prototype = Object.create(LineSegments.prototype);
- SkeletonHelper.prototype.constructor = SkeletonHelper;
- SkeletonHelper.prototype.updateMatrixWorld = function(force) {
- var bones = this.bones;
- var geometry = this.geometry;
- var position = geometry.getAttribute("position");
- _matrixWorldInv.getInverse(this.root.matrixWorld);
- for (var i2 = 0, j = 0; i2 < bones.length; i2++) {
- var bone = bones[i2];
- if (bone.parent && bone.parent.isBone) {
- _boneMatrix.multiplyMatrices(_matrixWorldInv, bone.matrixWorld);
- _vector$9.setFromMatrixPosition(_boneMatrix);
- position.setXYZ(j, _vector$9.x, _vector$9.y, _vector$9.z);
- _boneMatrix.multiplyMatrices(_matrixWorldInv, bone.parent.matrixWorld);
- _vector$9.setFromMatrixPosition(_boneMatrix);
- position.setXYZ(j + 1, _vector$9.x, _vector$9.y, _vector$9.z);
- j += 2;
- }
- }
- geometry.getAttribute("position").needsUpdate = true;
- Object3D.prototype.updateMatrixWorld.call(this, force);
- };
- function PointLightHelper(light, sphereSize, color) {
- this.light = light;
- this.light.updateMatrixWorld();
- this.color = color;
- var geometry = new SphereBufferGeometry(sphereSize, 4, 2);
- var material = new MeshBasicMaterial({ wireframe: true, fog: false });
- Mesh.call(this, geometry, material);
- this.matrix = this.light.matrixWorld;
- this.matrixAutoUpdate = false;
- this.update();
- }
- PointLightHelper.prototype = Object.create(Mesh.prototype);
- PointLightHelper.prototype.constructor = PointLightHelper;
- PointLightHelper.prototype.dispose = function() {
- this.geometry.dispose();
- this.material.dispose();
- };
- PointLightHelper.prototype.update = function() {
- if (this.color !== void 0) {
- this.material.color.set(this.color);
- } else {
- this.material.color.copy(this.light.color);
- }
- };
- var _vector$a = new Vector3();
- var _color1 = new Color();
- var _color2 = new Color();
- function HemisphereLightHelper(light, size, color) {
- Object3D.call(this);
- this.light = light;
- this.light.updateMatrixWorld();
- this.matrix = light.matrixWorld;
- this.matrixAutoUpdate = false;
- this.color = color;
- var geometry = new OctahedronBufferGeometry(size);
- geometry.rotateY(Math.PI * 0.5);
- this.material = new MeshBasicMaterial({ wireframe: true, fog: false });
- if (this.color === void 0)
- this.material.vertexColors = VertexColors;
- var position = geometry.getAttribute("position");
- var colors = new Float32Array(position.count * 3);
- geometry.setAttribute("color", new BufferAttribute(colors, 3));
- this.add(new Mesh(geometry, this.material));
- this.update();
- }
- HemisphereLightHelper.prototype = Object.create(Object3D.prototype);
- HemisphereLightHelper.prototype.constructor = HemisphereLightHelper;
- HemisphereLightHelper.prototype.dispose = function() {
- this.children[0].geometry.dispose();
- this.children[0].material.dispose();
- };
- HemisphereLightHelper.prototype.update = function() {
- var mesh = this.children[0];
- if (this.color !== void 0) {
- this.material.color.set(this.color);
- } else {
- var colors = mesh.geometry.getAttribute("color");
- _color1.copy(this.light.color);
- _color2.copy(this.light.groundColor);
- for (var i2 = 0, l = colors.count; i2 < l; i2++) {
- var color = i2 < l / 2 ? _color1 : _color2;
- colors.setXYZ(i2, color.r, color.g, color.b);
- }
- colors.needsUpdate = true;
- }
- mesh.lookAt(_vector$a.setFromMatrixPosition(this.light.matrixWorld).negate());
- };
- function GridHelper(size, divisions, color1, color2) {
- size = size || 10;
- divisions = divisions || 10;
- color1 = new Color(color1 !== void 0 ? color1 : 4473924);
- color2 = new Color(color2 !== void 0 ? color2 : 8947848);
- var center = divisions / 2;
- var step = size / divisions;
- var halfSize = size / 2;
- var vertices = [], colors = [];
- for (var i2 = 0, j = 0, k = -halfSize; i2 <= divisions; i2++, k += step) {
- vertices.push(-halfSize, 0, k, halfSize, 0, k);
- vertices.push(k, 0, -halfSize, k, 0, halfSize);
- var color = i2 === center ? color1 : color2;
- color.toArray(colors, j);
- j += 3;
- color.toArray(colors, j);
- j += 3;
- color.toArray(colors, j);
- j += 3;
- color.toArray(colors, j);
- j += 3;
- }
- var geometry = new BufferGeometry();
- geometry.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- geometry.setAttribute("color", new Float32BufferAttribute(colors, 3));
- var material = new LineBasicMaterial({ vertexColors: VertexColors });
- LineSegments.call(this, geometry, material);
- }
- GridHelper.prototype = Object.assign(Object.create(LineSegments.prototype), {
- constructor: GridHelper,
- copy: function(source) {
- LineSegments.prototype.copy.call(this, source);
- this.geometry.copy(source.geometry);
- this.material.copy(source.material);
- return this;
- },
- clone: function() {
- return new this.constructor().copy(this);
- }
- });
- function PolarGridHelper(radius, radials, circles, divisions, color1, color2) {
- radius = radius || 10;
- radials = radials || 16;
- circles = circles || 8;
- divisions = divisions || 64;
- color1 = new Color(color1 !== void 0 ? color1 : 4473924);
- color2 = new Color(color2 !== void 0 ? color2 : 8947848);
- var vertices = [];
- var colors = [];
- var x, z;
- var v, i2, j, r, color;
- for (i2 = 0; i2 <= radials; i2++) {
- v = i2 / radials * (Math.PI * 2);
- x = Math.sin(v) * radius;
- z = Math.cos(v) * radius;
- vertices.push(0, 0, 0);
- vertices.push(x, 0, z);
- color = i2 & 1 ? color1 : color2;
- colors.push(color.r, color.g, color.b);
- colors.push(color.r, color.g, color.b);
- }
- for (i2 = 0; i2 <= circles; i2++) {
- color = i2 & 1 ? color1 : color2;
- r = radius - radius / circles * i2;
- for (j = 0; j < divisions; j++) {
- v = j / divisions * (Math.PI * 2);
- x = Math.sin(v) * r;
- z = Math.cos(v) * r;
- vertices.push(x, 0, z);
- colors.push(color.r, color.g, color.b);
- v = (j + 1) / divisions * (Math.PI * 2);
- x = Math.sin(v) * r;
- z = Math.cos(v) * r;
- vertices.push(x, 0, z);
- colors.push(color.r, color.g, color.b);
- }
- }
- var geometry = new BufferGeometry();
- geometry.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- geometry.setAttribute("color", new Float32BufferAttribute(colors, 3));
- var material = new LineBasicMaterial({ vertexColors: VertexColors });
- LineSegments.call(this, geometry, material);
- }
- PolarGridHelper.prototype = Object.create(LineSegments.prototype);
- PolarGridHelper.prototype.constructor = PolarGridHelper;
- var _v1$5 = new Vector3();
- var _v2$3 = new Vector3();
- var _v3$1 = new Vector3();
- function DirectionalLightHelper(light, size, color) {
- Object3D.call(this);
- this.light = light;
- this.light.updateMatrixWorld();
- this.matrix = light.matrixWorld;
- this.matrixAutoUpdate = false;
- this.color = color;
- if (size === void 0)
- size = 1;
- var geometry = new BufferGeometry();
- geometry.setAttribute("position", new Float32BufferAttribute([
- -size,
- size,
- 0,
- size,
- size,
- 0,
- size,
- -size,
- 0,
- -size,
- -size,
- 0,
- -size,
- size,
- 0
- ], 3));
- var material = new LineBasicMaterial({ fog: false });
- this.lightPlane = new Line(geometry, material);
- this.add(this.lightPlane);
- geometry = new BufferGeometry();
- geometry.setAttribute("position", new Float32BufferAttribute([0, 0, 0, 0, 0, 1], 3));
- this.targetLine = new Line(geometry, material);
- this.add(this.targetLine);
- this.update();
- }
- DirectionalLightHelper.prototype = Object.create(Object3D.prototype);
- DirectionalLightHelper.prototype.constructor = DirectionalLightHelper;
- DirectionalLightHelper.prototype.dispose = function() {
- this.lightPlane.geometry.dispose();
- this.lightPlane.material.dispose();
- this.targetLine.geometry.dispose();
- this.targetLine.material.dispose();
- };
- DirectionalLightHelper.prototype.update = function() {
- _v1$5.setFromMatrixPosition(this.light.matrixWorld);
- _v2$3.setFromMatrixPosition(this.light.target.matrixWorld);
- _v3$1.subVectors(_v2$3, _v1$5);
- this.lightPlane.lookAt(_v2$3);
- if (this.color !== void 0) {
- this.lightPlane.material.color.set(this.color);
- this.targetLine.material.color.set(this.color);
- } else {
- this.lightPlane.material.color.copy(this.light.color);
- this.targetLine.material.color.copy(this.light.color);
- }
- this.targetLine.lookAt(_v2$3);
- this.targetLine.scale.z = _v3$1.length();
- };
- var _vector$b = new Vector3();
- var _camera = new Camera();
- function CameraHelper(camera) {
- var geometry = new BufferGeometry();
- var material = new LineBasicMaterial({ color: 16777215, vertexColors: FaceColors });
- var vertices = [];
- var colors = [];
- var pointMap = {};
- var colorFrustum = new Color(16755200);
- var colorCone = new Color(16711680);
- var colorUp = new Color(43775);
- var colorTarget = new Color(16777215);
- var colorCross = new Color(3355443);
- addLine("n1", "n2", colorFrustum);
- addLine("n2", "n4", colorFrustum);
- addLine("n4", "n3", colorFrustum);
- addLine("n3", "n1", colorFrustum);
- addLine("f1", "f2", colorFrustum);
- addLine("f2", "f4", colorFrustum);
- addLine("f4", "f3", colorFrustum);
- addLine("f3", "f1", colorFrustum);
- addLine("n1", "f1", colorFrustum);
- addLine("n2", "f2", colorFrustum);
- addLine("n3", "f3", colorFrustum);
- addLine("n4", "f4", colorFrustum);
- addLine("p", "n1", colorCone);
- addLine("p", "n2", colorCone);
- addLine("p", "n3", colorCone);
- addLine("p", "n4", colorCone);
- addLine("u1", "u2", colorUp);
- addLine("u2", "u3", colorUp);
- addLine("u3", "u1", colorUp);
- addLine("c", "t", colorTarget);
- addLine("p", "c", colorCross);
- addLine("cn1", "cn2", colorCross);
- addLine("cn3", "cn4", colorCross);
- addLine("cf1", "cf2", colorCross);
- addLine("cf3", "cf4", colorCross);
- function addLine(a, b, color) {
- addPoint(a, color);
- addPoint(b, color);
- }
- function addPoint(id, color) {
- vertices.push(0, 0, 0);
- colors.push(color.r, color.g, color.b);
- if (pointMap[id] === void 0) {
- pointMap[id] = [];
- }
- pointMap[id].push(vertices.length / 3 - 1);
- }
- geometry.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- geometry.setAttribute("color", new Float32BufferAttribute(colors, 3));
- LineSegments.call(this, geometry, material);
- this.camera = camera;
- if (this.camera.updateProjectionMatrix)
- this.camera.updateProjectionMatrix();
- this.matrix = camera.matrixWorld;
- this.matrixAutoUpdate = false;
- this.pointMap = pointMap;
- this.update();
- }
- CameraHelper.prototype = Object.create(LineSegments.prototype);
- CameraHelper.prototype.constructor = CameraHelper;
- CameraHelper.prototype.update = function() {
- var geometry = this.geometry;
- var pointMap = this.pointMap;
- var w = 1, h = 1;
- _camera.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse);
- setPoint("c", pointMap, geometry, _camera, 0, 0, -1);
- setPoint("t", pointMap, geometry, _camera, 0, 0, 1);
- setPoint("n1", pointMap, geometry, _camera, -w, -h, -1);
- setPoint("n2", pointMap, geometry, _camera, w, -h, -1);
- setPoint("n3", pointMap, geometry, _camera, -w, h, -1);
- setPoint("n4", pointMap, geometry, _camera, w, h, -1);
- setPoint("f1", pointMap, geometry, _camera, -w, -h, 1);
- setPoint("f2", pointMap, geometry, _camera, w, -h, 1);
- setPoint("f3", pointMap, geometry, _camera, -w, h, 1);
- setPoint("f4", pointMap, geometry, _camera, w, h, 1);
- setPoint("u1", pointMap, geometry, _camera, w * 0.7, h * 1.1, -1);
- setPoint("u2", pointMap, geometry, _camera, -w * 0.7, h * 1.1, -1);
- setPoint("u3", pointMap, geometry, _camera, 0, h * 2, -1);
- setPoint("cf1", pointMap, geometry, _camera, -w, 0, 1);
- setPoint("cf2", pointMap, geometry, _camera, w, 0, 1);
- setPoint("cf3", pointMap, geometry, _camera, 0, -h, 1);
- setPoint("cf4", pointMap, geometry, _camera, 0, h, 1);
- setPoint("cn1", pointMap, geometry, _camera, -w, 0, -1);
- setPoint("cn2", pointMap, geometry, _camera, w, 0, -1);
- setPoint("cn3", pointMap, geometry, _camera, 0, -h, -1);
- setPoint("cn4", pointMap, geometry, _camera, 0, h, -1);
- geometry.getAttribute("position").needsUpdate = true;
- };
- function setPoint(point, pointMap, geometry, camera, x, y, z) {
- _vector$b.set(x, y, z).unproject(camera);
- var points = pointMap[point];
- if (points !== void 0) {
- var position = geometry.getAttribute("position");
- for (var i2 = 0, l = points.length; i2 < l; i2++) {
- position.setXYZ(points[i2], _vector$b.x, _vector$b.y, _vector$b.z);
- }
- }
- }
- var _box$3 = new Box3();
- function BoxHelper(object, color) {
- this.object = object;
- if (color === void 0)
- color = 16776960;
- 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]);
- var positions = new Float32Array(8 * 3);
- var geometry = new BufferGeometry();
- geometry.setIndex(new BufferAttribute(indices, 1));
- geometry.setAttribute("position", new BufferAttribute(positions, 3));
- LineSegments.call(this, geometry, new LineBasicMaterial({ color }));
- this.matrixAutoUpdate = false;
- this.update();
- }
- BoxHelper.prototype = Object.create(LineSegments.prototype);
- BoxHelper.prototype.constructor = BoxHelper;
- BoxHelper.prototype.update = function(object) {
- if (object !== void 0) {
- console.warn("THREE.BoxHelper: .update() has no longer arguments.");
- }
- if (this.object !== void 0) {
- _box$3.setFromObject(this.object);
- }
- if (_box$3.isEmpty())
- return;
- var min = _box$3.min;
- var max = _box$3.max;
- var position = this.geometry.attributes.position;
- var array = position.array;
- array[0] = max.x;
- array[1] = max.y;
- array[2] = max.z;
- array[3] = min.x;
- array[4] = max.y;
- array[5] = max.z;
- array[6] = min.x;
- array[7] = min.y;
- array[8] = max.z;
- array[9] = max.x;
- array[10] = min.y;
- array[11] = max.z;
- array[12] = max.x;
- array[13] = max.y;
- array[14] = min.z;
- array[15] = min.x;
- array[16] = max.y;
- array[17] = min.z;
- array[18] = min.x;
- array[19] = min.y;
- array[20] = min.z;
- array[21] = max.x;
- array[22] = min.y;
- array[23] = min.z;
- position.needsUpdate = true;
- this.geometry.computeBoundingSphere();
- };
- BoxHelper.prototype.setFromObject = function(object) {
- this.object = object;
- this.update();
- return this;
- };
- BoxHelper.prototype.copy = function(source) {
- LineSegments.prototype.copy.call(this, source);
- this.object = source.object;
- return this;
- };
- BoxHelper.prototype.clone = function() {
- return new this.constructor().copy(this);
- };
- function Box3Helper(box, color) {
- this.type = "Box3Helper";
- this.box = box;
- color = color || 16776960;
- 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]);
- 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];
- var geometry = new BufferGeometry();
- geometry.setIndex(new BufferAttribute(indices, 1));
- geometry.setAttribute("position", new Float32BufferAttribute(positions, 3));
- LineSegments.call(this, geometry, new LineBasicMaterial({ color }));
- this.geometry.computeBoundingSphere();
- }
- Box3Helper.prototype = Object.create(LineSegments.prototype);
- Box3Helper.prototype.constructor = Box3Helper;
- Box3Helper.prototype.updateMatrixWorld = function(force) {
- var box = this.box;
- if (box.isEmpty())
- return;
- box.getCenter(this.position);
- box.getSize(this.scale);
- this.scale.multiplyScalar(0.5);
- Object3D.prototype.updateMatrixWorld.call(this, force);
- };
- function PlaneHelper(plane, size, hex) {
- this.type = "PlaneHelper";
- this.plane = plane;
- this.size = size === void 0 ? 1 : size;
- var color = hex !== void 0 ? hex : 16776960;
- 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];
- var geometry = new BufferGeometry();
- geometry.setAttribute("position", new Float32BufferAttribute(positions, 3));
- geometry.computeBoundingSphere();
- Line.call(this, geometry, new LineBasicMaterial({ color }));
- var positions2 = [1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1];
- var geometry2 = new BufferGeometry();
- geometry2.setAttribute("position", new Float32BufferAttribute(positions2, 3));
- geometry2.computeBoundingSphere();
- this.add(new Mesh(geometry2, new MeshBasicMaterial({ color, opacity: 0.2, transparent: true, depthWrite: false })));
- }
- PlaneHelper.prototype = Object.create(Line.prototype);
- PlaneHelper.prototype.constructor = PlaneHelper;
- PlaneHelper.prototype.updateMatrixWorld = function(force) {
- var scale = -this.plane.constant;
- if (Math.abs(scale) < 1e-8)
- scale = 1e-8;
- this.scale.set(0.5 * this.size, 0.5 * this.size, scale);
- this.children[0].material.side = scale < 0 ? BackSide : FrontSide;
- this.lookAt(this.plane.normal);
- Object3D.prototype.updateMatrixWorld.call(this, force);
- };
- var _axis = new Vector3();
- var _lineGeometry, _coneGeometry;
- function ArrowHelper(dir, origin, length, color, headLength, headWidth) {
- Object3D.call(this);
- if (dir === void 0)
- dir = new Vector3(0, 0, 1);
- if (origin === void 0)
- origin = new Vector3(0, 0, 0);
- if (length === void 0)
- length = 1;
- if (color === void 0)
- color = 16776960;
- if (headLength === void 0)
- headLength = 0.2 * length;
- if (headWidth === void 0)
- headWidth = 0.2 * headLength;
- if (_lineGeometry === void 0) {
- _lineGeometry = new BufferGeometry();
- _lineGeometry.setAttribute("position", new Float32BufferAttribute([0, 0, 0, 0, 1, 0], 3));
- _coneGeometry = new CylinderBufferGeometry(0, 0.5, 1, 5, 1);
- _coneGeometry.translate(0, -0.5, 0);
- }
- this.position.copy(origin);
- this.line = new Line(_lineGeometry, new LineBasicMaterial({ color }));
- this.line.matrixAutoUpdate = false;
- this.add(this.line);
- this.cone = new Mesh(_coneGeometry, new MeshBasicMaterial({ color }));
- this.cone.matrixAutoUpdate = false;
- this.add(this.cone);
- this.setDirection(dir);
- this.setLength(length, headLength, headWidth);
- }
- ArrowHelper.prototype = Object.create(Object3D.prototype);
- ArrowHelper.prototype.constructor = ArrowHelper;
- ArrowHelper.prototype.setDirection = function(dir) {
- if (dir.y > 0.99999) {
- this.quaternion.set(0, 0, 0, 1);
- } else if (dir.y < -0.99999) {
- this.quaternion.set(1, 0, 0, 0);
- } else {
- _axis.set(dir.z, 0, -dir.x).normalize();
- var radians = Math.acos(dir.y);
- this.quaternion.setFromAxisAngle(_axis, radians);
- }
- };
- ArrowHelper.prototype.setLength = function(length, headLength, headWidth) {
- if (headLength === void 0)
- headLength = 0.2 * length;
- if (headWidth === void 0)
- headWidth = 0.2 * headLength;
- this.line.scale.set(1, Math.max(1e-4, length - headLength), 1);
- this.line.updateMatrix();
- this.cone.scale.set(headWidth, headLength, headWidth);
- this.cone.position.y = length;
- this.cone.updateMatrix();
- };
- ArrowHelper.prototype.setColor = function(color) {
- this.line.material.color.set(color);
- this.cone.material.color.set(color);
- };
- ArrowHelper.prototype.copy = function(source) {
- Object3D.prototype.copy.call(this, source, false);
- this.line.copy(source.line);
- this.cone.copy(source.cone);
- return this;
- };
- ArrowHelper.prototype.clone = function() {
- return new this.constructor().copy(this);
- };
- function AxesHelper(size) {
- size = size || 1;
- var vertices = [
- 0,
- 0,
- 0,
- size,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- size,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- size
- ];
- var colors = [
- 1,
- 0,
- 0,
- 1,
- 0.6,
- 0,
- 0,
- 1,
- 0,
- 0.6,
- 1,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0.6,
- 1
- ];
- var geometry = new BufferGeometry();
- geometry.setAttribute("position", new Float32BufferAttribute(vertices, 3));
- geometry.setAttribute("color", new Float32BufferAttribute(colors, 3));
- var material = new LineBasicMaterial({ vertexColors: VertexColors });
- LineSegments.call(this, geometry, material);
- }
- AxesHelper.prototype = Object.create(LineSegments.prototype);
- AxesHelper.prototype.constructor = AxesHelper;
- var LOD_MIN = 4;
- var LOD_MAX = 8;
- var SIZE_MAX = Math.pow(2, LOD_MAX);
- var EXTRA_LOD_SIGMA = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582];
- var TOTAL_LODS = LOD_MAX - LOD_MIN + 1 + EXTRA_LOD_SIGMA.length;
- var MAX_SAMPLES = 20;
- var ENCODINGS = {
- [LinearEncoding]: 0,
- [sRGBEncoding]: 1,
- [RGBEEncoding]: 2,
- [RGBM7Encoding]: 3,
- [RGBM16Encoding]: 4,
- [RGBDEncoding]: 5,
- [GammaEncoding]: 6
- };
- var _flatCamera = new OrthographicCamera();
- var _blurMaterial = _getBlurShader(MAX_SAMPLES);
- var _equirectShader = null;
- var _cubemapShader = null;
- var { _lodPlanes, _sizeLods, _sigmas } = _createPlanes();
- var _pingPongRenderTarget = null;
- var _renderer = null;
- var _oldTarget = null;
- var PHI = (1 + Math.sqrt(5)) / 2;
- var INV_PHI = 1 / PHI;
- var _axisDirections = [
- new Vector3(1, 1, 1),
- new Vector3(-1, 1, 1),
- new Vector3(1, 1, -1),
- new Vector3(-1, 1, -1),
- new Vector3(0, PHI, INV_PHI),
- new Vector3(0, PHI, -INV_PHI),
- new Vector3(INV_PHI, 0, PHI),
- new Vector3(-INV_PHI, 0, PHI),
- new Vector3(PHI, INV_PHI, 0),
- new Vector3(-PHI, INV_PHI, 0)
- ];
- function PMREMGenerator(renderer) {
- _renderer = renderer;
- _compileMaterial(_blurMaterial);
- }
- PMREMGenerator.prototype = {
- constructor: PMREMGenerator,
- /**
- * Generates a PMREM from a supplied Scene, which can be faster than using an
- * image if networking bandwidth is low. Optional sigma specifies a blur radius
- * in radians to be applied to the scene before PMREM generation. Optional near
- * and far planes ensure the scene is rendered in its entirety (the cubeCamera
- * is placed at the origin).
- */
- fromScene: function(scene, sigma = 0, near = 0.1, far = 100) {
- _oldTarget = _renderer.getRenderTarget();
- var cubeUVRenderTarget = _allocateTargets();
- _sceneToCubeUV(scene, near, far, cubeUVRenderTarget);
- if (sigma > 0) {
- _blur(cubeUVRenderTarget, 0, 0, sigma);
- }
- _applyPMREM(cubeUVRenderTarget);
- _cleanup(cubeUVRenderTarget);
- return cubeUVRenderTarget;
- },
- /**
- * Generates a PMREM from an equirectangular texture, which can be either LDR
- * (RGBFormat) or HDR (RGBEFormat). The ideal input image size is 1k (1024 x 512),
- * as this matches best with the 256 x 256 cubemap output.
- */
- fromEquirectangular: function(equirectangular) {
- equirectangular.magFilter = NearestFilter;
- equirectangular.minFilter = NearestFilter;
- equirectangular.generateMipmaps = false;
- return this.fromCubemap(equirectangular);
- },
- /**
- * Generates a PMREM from an cubemap texture, which can be either LDR
- * (RGBFormat) or HDR (RGBEFormat). The ideal input cube size is 256 x 256,
- * as this matches best with the 256 x 256 cubemap output.
- */
- fromCubemap: function(cubemap) {
- _oldTarget = _renderer.getRenderTarget();
- var cubeUVRenderTarget = _allocateTargets(cubemap);
- _textureToCubeUV(cubemap, cubeUVRenderTarget);
- _applyPMREM(cubeUVRenderTarget);
- _cleanup(cubeUVRenderTarget);
- return cubeUVRenderTarget;
- },
- /**
- * Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during
- * your texture's network fetch for increased concurrency.
- */
- compileCubemapShader: function() {
- if (_cubemapShader == null) {
- _cubemapShader = _getCubemapShader();
- _compileMaterial(_cubemapShader);
- }
- },
- /**
- * Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during
- * your texture's network fetch for increased concurrency.
- */
- compileEquirectangularShader: function() {
- if (_equirectShader == null) {
- _equirectShader = _getEquirectShader();
- _compileMaterial(_equirectShader);
- }
- },
- /**
- * Disposes of the PMREMGenerator's internal memory. Note that PMREMGenerator is a static class,
- * so you should not need more than one PMREMGenerator object. If you do, calling dispose() on
- * one of them will cause any others to also become unusable.
- */
- dispose: function() {
- _blurMaterial.dispose();
- if (_cubemapShader != null)
- _cubemapShader.dispose();
- if (_equirectShader != null)
- _equirectShader.dispose();
- for (var i2 = 0; i2 < _lodPlanes.length; i2++) {
- _lodPlanes[i2].dispose();
- }
- }
- };
- function _createPlanes() {
- var _lodPlanes2 = [];
- var _sizeLods2 = [];
- var _sigmas2 = [];
- var lod = LOD_MAX;
- for (var i2 = 0; i2 < TOTAL_LODS; i2++) {
- var sizeLod = Math.pow(2, lod);
- _sizeLods2.push(sizeLod);
- var sigma = 1 / sizeLod;
- if (i2 > LOD_MAX - LOD_MIN) {
- sigma = EXTRA_LOD_SIGMA[i2 - LOD_MAX + LOD_MIN - 1];
- } else if (i2 == 0) {
- sigma = 0;
- }
- _sigmas2.push(sigma);
- var texelSize = 1 / (sizeLod - 1);
- var min = -texelSize / 2;
- var max = 1 + texelSize / 2;
- var uv1 = [min, min, max, min, max, max, min, min, max, max, min, max];
- var cubeFaces = 6;
- var vertices = 6;
- var positionSize = 3;
- var uvSize = 2;
- var faceIndexSize = 1;
- var position = new Float32Array(positionSize * vertices * cubeFaces);
- var uv = new Float32Array(uvSize * vertices * cubeFaces);
- var faceIndex = new Float32Array(faceIndexSize * vertices * cubeFaces);
- for (var face = 0; face < cubeFaces; face++) {
- var x = face % 3 * 2 / 3 - 1;
- var y = face > 2 ? 0 : -1;
- var coordinates = [
- x,
- y,
- 0,
- x + 2 / 3,
- y,
- 0,
- x + 2 / 3,
- y + 1,
- 0,
- x,
- y,
- 0,
- x + 2 / 3,
- y + 1,
- 0,
- x,
- y + 1,
- 0
- ];
- position.set(coordinates, positionSize * vertices * face);
- uv.set(uv1, uvSize * vertices * face);
- var fill = [face, face, face, face, face, face];
- faceIndex.set(fill, faceIndexSize * vertices * face);
- }
- var planes = new BufferGeometry();
- planes.setAttribute("position", new BufferAttribute(position, positionSize));
- planes.setAttribute("uv", new BufferAttribute(uv, uvSize));
- planes.setAttribute("faceIndex", new BufferAttribute(faceIndex, faceIndexSize));
- _lodPlanes2.push(planes);
- if (lod > LOD_MIN) {
- lod--;
- }
- }
- return { _lodPlanes: _lodPlanes2, _sizeLods: _sizeLods2, _sigmas: _sigmas2 };
- }
- function _allocateTargets(equirectangular) {
- var params = {
- magFilter: NearestFilter,
- minFilter: NearestFilter,
- generateMipmaps: false,
- type: equirectangular ? equirectangular.type : UnsignedByteType,
- format: equirectangular ? equirectangular.format : RGBEFormat,
- encoding: equirectangular ? equirectangular.encoding : RGBEEncoding,
- depthBuffer: false,
- stencilBuffer: false
- };
- var cubeUVRenderTarget = _createRenderTarget(params);
- cubeUVRenderTarget.depthBuffer = equirectangular ? false : true;
- _pingPongRenderTarget = _createRenderTarget(params);
- return cubeUVRenderTarget;
- }
- function _cleanup(outputTarget) {
- _pingPongRenderTarget.dispose();
- _renderer.setRenderTarget(_oldTarget);
- outputTarget.scissorTest = false;
- outputTarget.setSize(outputTarget.width, outputTarget.height);
- }
- function _sceneToCubeUV(scene, near, far, cubeUVRenderTarget) {
- var fov2 = 90;
- var aspect2 = 1;
- var cubeCamera = new PerspectiveCamera(fov2, aspect2, near, far);
- var upSign = [1, 1, 1, 1, -1, 1];
- var forwardSign = [1, 1, -1, -1, -1, 1];
- var outputEncoding = _renderer.outputEncoding;
- var toneMapping = _renderer.toneMapping;
- var toneMappingExposure = _renderer.toneMappingExposure;
- var clearColor = _renderer.getClearColor();
- var clearAlpha = _renderer.getClearAlpha();
- _renderer.toneMapping = LinearToneMapping;
- _renderer.toneMappingExposure = 1;
- _renderer.outputEncoding = LinearEncoding;
- scene.scale.z *= -1;
- var background = scene.background;
- if (background && background.isColor) {
- background.convertSRGBToLinear();
- var maxComponent = Math.max(background.r, background.g, background.b);
- var fExp = Math.min(Math.max(Math.ceil(Math.log2(maxComponent)), -128), 127);
- background = background.multiplyScalar(Math.pow(2, -fExp));
- var alpha = (fExp + 128) / 255;
- _renderer.setClearColor(background, alpha);
- scene.background = null;
- }
- for (var i2 = 0; i2 < 6; i2++) {
- var col = i2 % 3;
- if (col == 0) {
- cubeCamera.up.set(0, upSign[i2], 0);
- cubeCamera.lookAt(forwardSign[i2], 0, 0);
- } else if (col == 1) {
- cubeCamera.up.set(0, 0, upSign[i2]);
- cubeCamera.lookAt(0, forwardSign[i2], 0);
- } else {
- cubeCamera.up.set(0, upSign[i2], 0);
- cubeCamera.lookAt(0, 0, forwardSign[i2]);
- }
- _setViewport(
- cubeUVRenderTarget,
- col * SIZE_MAX,
- i2 > 2 ? SIZE_MAX : 0,
- SIZE_MAX,
- SIZE_MAX
- );
- _renderer.setRenderTarget(cubeUVRenderTarget);
- _renderer.render(scene, cubeCamera);
- }
- _renderer.toneMapping = toneMapping;
- _renderer.toneMappingExposure = toneMappingExposure;
- _renderer.outputEncoding = outputEncoding;
- _renderer.setClearColor(clearColor, clearAlpha);
- scene.scale.z *= -1;
- }
- function _textureToCubeUV(texture, cubeUVRenderTarget) {
- var scene = new Scene();
- if (texture.isCubeTexture) {
- if (_cubemapShader == null) {
- _cubemapShader = _getCubemapShader();
- }
- } else {
- if (_equirectShader == null) {
- _equirectShader = _getEquirectShader();
- }
- }
- var material = texture.isCubeTexture ? _cubemapShader : _equirectShader;
- scene.add(new Mesh(_lodPlanes[0], material));
- var uniforms = material.uniforms;
- uniforms["envMap"].value = texture;
- if (!texture.isCubeTexture) {
- uniforms["texelSize"].value.set(1 / texture.image.width, 1 / texture.image.height);
- }
- uniforms["inputEncoding"].value = ENCODINGS[texture.encoding];
- uniforms["outputEncoding"].value = ENCODINGS[texture.encoding];
- _setViewport(cubeUVRenderTarget, 0, 0, 3 * SIZE_MAX, 2 * SIZE_MAX);
- _renderer.setRenderTarget(cubeUVRenderTarget);
- _renderer.render(scene, _flatCamera);
- }
- function _compileMaterial(material) {
- var tmpScene = new Scene();
- tmpScene.add(new Mesh(_lodPlanes[0], material));
- _renderer.compile(tmpScene, _flatCamera);
- }
- function _createRenderTarget(params) {
- var cubeUVRenderTarget = new WebGLRenderTarget(3 * SIZE_MAX, 3 * SIZE_MAX, params);
- cubeUVRenderTarget.texture.mapping = CubeUVReflectionMapping;
- cubeUVRenderTarget.texture.name = "PMREM.cubeUv";
- cubeUVRenderTarget.scissorTest = true;
- return cubeUVRenderTarget;
- }
- function _setViewport(target, x, y, width, height) {
- target.viewport.set(x, y, width, height);
- target.scissor.set(x, y, width, height);
- }
- function _applyPMREM(cubeUVRenderTarget) {
- var autoClear = _renderer.autoClear;
- _renderer.autoClear = false;
- for (var i2 = 1; i2 < TOTAL_LODS; i2++) {
- var sigma = Math.sqrt(
- _sigmas[i2] * _sigmas[i2] - _sigmas[i2 - 1] * _sigmas[i2 - 1]
- );
- var poleAxis = _axisDirections[(i2 - 1) % _axisDirections.length];
- _blur(cubeUVRenderTarget, i2 - 1, i2, sigma, poleAxis);
- }
- _renderer.autoClear = autoClear;
- }
- function _blur(cubeUVRenderTarget, lodIn, lodOut, sigma, poleAxis) {
- _halfBlur(
- cubeUVRenderTarget,
- _pingPongRenderTarget,
- lodIn,
- lodOut,
- sigma,
- "latitudinal",
- poleAxis
- );
- _halfBlur(
- _pingPongRenderTarget,
- cubeUVRenderTarget,
- lodOut,
- lodOut,
- sigma,
- "longitudinal",
- poleAxis
- );
- }
- function _halfBlur(targetIn, targetOut, lodIn, lodOut, sigmaRadians, direction, poleAxis) {
- if (direction !== "latitudinal" && direction !== "longitudinal") {
- console.error(
- "blur direction must be either latitudinal or longitudinal!"
- );
- }
- var STANDARD_DEVIATIONS = 3;
- var blurScene = new Scene();
- blurScene.add(new Mesh(_lodPlanes[lodOut], _blurMaterial));
- var blurUniforms = _blurMaterial.uniforms;
- var pixels = _sizeLods[lodIn] - 1;
- var radiansPerPixel = isFinite(sigmaRadians) ? Math.PI / (2 * pixels) : 2 * Math.PI / (2 * MAX_SAMPLES - 1);
- var sigmaPixels = sigmaRadians / radiansPerPixel;
- var samples = isFinite(sigmaRadians) ? 1 + Math.floor(STANDARD_DEVIATIONS * sigmaPixels) : MAX_SAMPLES;
- if (samples > MAX_SAMPLES) {
- console.warn(`sigmaRadians, ${sigmaRadians}, is too large and will clip, as it requested ${samples} samples when the maximum is set to ${MAX_SAMPLES}`);
- }
- var weights = [];
- var sum = 0;
- for (var i2 = 0; i2 < MAX_SAMPLES; ++i2) {
- var x = i2 / sigmaPixels;
- var weight = Math.exp(-x * x / 2);
- weights.push(weight);
- if (i2 == 0) {
- sum += weight;
- } else if (i2 < samples) {
- sum += 2 * weight;
- }
- }
- for (var i2 = 0; i2 < weights.length; i2++) {
- weights[i2] = weights[i2] / sum;
- }
- blurUniforms["envMap"].value = targetIn.texture;
- blurUniforms["samples"].value = samples;
- blurUniforms["weights"].value = weights;
- blurUniforms["latitudinal"].value = direction === "latitudinal";
- if (poleAxis) {
- blurUniforms["poleAxis"].value = poleAxis;
- }
- blurUniforms["dTheta"].value = radiansPerPixel;
- blurUniforms["mipInt"].value = LOD_MAX - lodIn;
- blurUniforms["inputEncoding"].value = ENCODINGS[targetIn.texture.encoding];
- blurUniforms["outputEncoding"].value = ENCODINGS[targetIn.texture.encoding];
- var outputSize = _sizeLods[lodOut];
- var x = 3 * Math.max(0, SIZE_MAX - 2 * outputSize);
- var y = (lodOut === 0 ? 0 : 2 * SIZE_MAX) + 2 * outputSize * (lodOut > LOD_MAX - LOD_MIN ? lodOut - LOD_MAX + LOD_MIN : 0);
- _setViewport(targetOut, x, y, 3 * outputSize, 2 * outputSize);
- _renderer.setRenderTarget(targetOut);
- _renderer.render(blurScene, _flatCamera);
- }
- function _getBlurShader(maxSamples) {
- var weights = new Float32Array(maxSamples);
- var poleAxis = new Vector3(0, 1, 0);
- var shaderMaterial = new RawShaderMaterial({
- defines: { "n": maxSamples },
- uniforms: {
- "envMap": { value: null },
- "samples": { value: 1 },
- "weights": { value: weights },
- "latitudinal": { value: false },
- "dTheta": { value: 0 },
- "mipInt": { value: 0 },
- "poleAxis": { value: poleAxis },
- "inputEncoding": { value: ENCODINGS[LinearEncoding] },
- "outputEncoding": { value: ENCODINGS[LinearEncoding] }
- },
- vertexShader: _getCommonVertexShader(),
- fragmentShader: `
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[n];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- ${_getEncodings()}
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- void main() {
- gl_FragColor = vec4(0.0);
- for (int i = 0; i < n; i++) {
- if (i >= samples)
- break;
- for (int dir = -1; dir < 2; dir += 2) {
- if (i == 0 && dir == 1)
- continue;
- vec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);
- if (all(equal(axis, vec3(0.0))))
- axis = cross(vec3(0.0, 1.0, 0.0), vOutputDirection);
- axis = normalize(axis);
- float theta = dTheta * float(dir * i);
- float cosTheta = cos(theta);
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross(axis, vOutputDirection) * sin(theta)
- + axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);
- gl_FragColor.rgb +=
- weights[i] * bilinearCubeUV(envMap, sampleDirection, mipInt);
- }
- }
- gl_FragColor = linearToOutputTexel(gl_FragColor);
- }
- `,
- blending: NoBlending,
- depthTest: false,
- depthWrite: false
- });
- shaderMaterial.type = "SphericalGaussianBlur";
- return shaderMaterial;
- }
- function _getEquirectShader() {
- var texelSize = new Vector2(1, 1);
- var shaderMaterial = new RawShaderMaterial({
- uniforms: {
- "envMap": { value: null },
- "texelSize": { value: texelSize },
- "inputEncoding": { value: ENCODINGS[LinearEncoding] },
- "outputEncoding": { value: ENCODINGS[LinearEncoding] }
- },
- vertexShader: _getCommonVertexShader(),
- fragmentShader: `
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform vec2 texelSize;
- ${_getEncodings()}
- #define RECIPROCAL_PI 0.31830988618
- #define RECIPROCAL_PI2 0.15915494
- void main() {
- gl_FragColor = vec4(0.0);
- vec3 outputDirection = normalize(vOutputDirection);
- vec2 uv;
- uv.y = asin(clamp(outputDirection.y, -1.0, 1.0)) * RECIPROCAL_PI + 0.5;
- uv.x = atan(outputDirection.z, outputDirection.x) * RECIPROCAL_PI2 + 0.5;
- vec2 f = fract(uv / texelSize - 0.5);
- uv -= f * texelSize;
- vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
- uv.x += texelSize.x;
- vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
- uv.y += texelSize.y;
- vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
- uv.x -= texelSize.x;
- vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
- vec3 tm = mix(tl, tr, f.x);
- vec3 bm = mix(bl, br, f.x);
- gl_FragColor.rgb = mix(tm, bm, f.y);
- gl_FragColor = linearToOutputTexel(gl_FragColor);
- }
- `,
- blending: NoBlending,
- depthTest: false,
- depthWrite: false
- });
- shaderMaterial.type = "EquirectangularToCubeUV";
- return shaderMaterial;
- }
- function _getCubemapShader() {
- var shaderMaterial = new RawShaderMaterial({
- uniforms: {
- "envMap": { value: null },
- "inputEncoding": { value: ENCODINGS[LinearEncoding] },
- "outputEncoding": { value: ENCODINGS[LinearEncoding] }
- },
- vertexShader: _getCommonVertexShader(),
- fragmentShader: `
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- ${_getEncodings()}
- void main() {
- gl_FragColor = vec4(0.0);
- gl_FragColor.rgb = envMapTexelToLinear(textureCube(envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ))).rgb;
- gl_FragColor = linearToOutputTexel(gl_FragColor);
- }
- `,
- blending: NoBlending,
- depthTest: false,
- depthWrite: false
- });
- shaderMaterial.type = "CubemapToCubeUV";
- return shaderMaterial;
- }
- function _getCommonVertexShader() {
- return `
- precision mediump float;
- precision mediump int;
- attribute vec3 position;
- attribute vec2 uv;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- vec3 getDirection(vec2 uv, float face) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3(uv, 1.0);
- if (face == 0.0) {
- direction = direction.zyx;
- direction.z *= -1.0;
- } else if (face == 1.0) {
- direction = direction.xzy;
- direction.z *= -1.0;
- } else if (face == 3.0) {
- direction = direction.zyx;
- direction.x *= -1.0;
- } else if (face == 4.0) {
- direction = direction.xzy;
- direction.y *= -1.0;
- } else if (face == 5.0) {
- direction.xz *= -1.0;
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection(uv, faceIndex);
- gl_Position = vec4( position, 1.0 );
- }
- `;
- }
- function _getEncodings() {
- return `
- uniform int inputEncoding;
- uniform int outputEncoding;
- #include <encodings_pars_fragment>
- vec4 inputTexelToLinear(vec4 value){
- if(inputEncoding == 0){
- return value;
- }else if(inputEncoding == 1){
- return sRGBToLinear(value);
- }else if(inputEncoding == 2){
- return RGBEToLinear(value);
- }else if(inputEncoding == 3){
- return RGBMToLinear(value, 7.0);
- }else if(inputEncoding == 4){
- return RGBMToLinear(value, 16.0);
- }else if(inputEncoding == 5){
- return RGBDToLinear(value, 256.0);
- }else{
- return GammaToLinear(value, 2.2);
- }
- }
- vec4 linearToOutputTexel(vec4 value){
- if(outputEncoding == 0){
- return value;
- }else if(outputEncoding == 1){
- return LinearTosRGB(value);
- }else if(outputEncoding == 2){
- return LinearToRGBE(value);
- }else if(outputEncoding == 3){
- return LinearToRGBM(value, 7.0);
- }else if(outputEncoding == 4){
- return LinearToRGBM(value, 16.0);
- }else if(outputEncoding == 5){
- return LinearToRGBD(value, 256.0);
- }else{
- return LinearToGamma(value, 2.2);
- }
- }
- vec4 envMapTexelToLinear(vec4 color) {
- return inputTexelToLinear(color);
- }
- `;
- }
- Curve.create = function(construct, getPoint) {
- console.log("THREE.Curve.create() has been deprecated");
- construct.prototype = Object.create(Curve.prototype);
- construct.prototype.constructor = construct;
- construct.prototype.getPoint = getPoint;
- return construct;
- };
- Object.assign(CurvePath.prototype, {
- createPointsGeometry: function(divisions) {
- console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");
- var pts = this.getPoints(divisions);
- return this.createGeometry(pts);
- },
- createSpacedPointsGeometry: function(divisions) {
- console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");
- var pts = this.getSpacedPoints(divisions);
- return this.createGeometry(pts);
- },
- createGeometry: function(points) {
- console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");
- var geometry = new Geometry();
- for (var i2 = 0, l = points.length; i2 < l; i2++) {
- var point = points[i2];
- geometry.vertices.push(new Vector3(point.x, point.y, point.z || 0));
- }
- return geometry;
- }
- });
- Object.assign(Path.prototype, {
- fromPoints: function(points) {
- console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints().");
- return this.setFromPoints(points);
- }
- });
- Object.create(CatmullRomCurve3.prototype);
- Object.create(CatmullRomCurve3.prototype);
- function Spline(points) {
- console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead.");
- CatmullRomCurve3.call(this, points);
- this.type = "catmullrom";
- }
- Spline.prototype = Object.create(CatmullRomCurve3.prototype);
- Object.assign(Spline.prototype, {
- initFromArray: function() {
- console.error("THREE.Spline: .initFromArray() has been removed.");
- },
- getControlPointsArray: function() {
- console.error("THREE.Spline: .getControlPointsArray() has been removed.");
- },
- reparametrizeByArcLength: function() {
- console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.");
- }
- });
- GridHelper.prototype.setColors = function() {
- console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.");
- };
- SkeletonHelper.prototype.update = function() {
- console.error("THREE.SkeletonHelper: update() no longer needs to be called.");
- };
- Object.assign(Loader.prototype, {
- extractUrlBase: function(url) {
- console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead.");
- return LoaderUtils.extractUrlBase(url);
- }
- });
- Loader.Handlers = {
- add: function() {
- console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.");
- },
- get: function() {
- console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.");
- }
- };
- Object.assign(ObjectLoader.prototype, {
- setTexturePath: function(value) {
- console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath().");
- return this.setResourcePath(value);
- }
- });
- Object.assign(Box2.prototype, {
- center: function(optionalTarget) {
- console.warn("THREE.Box2: .center() has been renamed to .getCenter().");
- return this.getCenter(optionalTarget);
- },
- empty: function() {
- console.warn("THREE.Box2: .empty() has been renamed to .isEmpty().");
- return this.isEmpty();
- },
- isIntersectionBox: function(box) {
- console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().");
- return this.intersectsBox(box);
- },
- size: function(optionalTarget) {
- console.warn("THREE.Box2: .size() has been renamed to .getSize().");
- return this.getSize(optionalTarget);
- }
- });
- Object.assign(Box3.prototype, {
- center: function(optionalTarget) {
- console.warn("THREE.Box3: .center() has been renamed to .getCenter().");
- return this.getCenter(optionalTarget);
- },
- empty: function() {
- console.warn("THREE.Box3: .empty() has been renamed to .isEmpty().");
- return this.isEmpty();
- },
- isIntersectionBox: function(box) {
- console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().");
- return this.intersectsBox(box);
- },
- isIntersectionSphere: function(sphere) {
- console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().");
- return this.intersectsSphere(sphere);
- },
- size: function(optionalTarget) {
- console.warn("THREE.Box3: .size() has been renamed to .getSize().");
- return this.getSize(optionalTarget);
- }
- });
- Frustum.prototype.setFromMatrix = function(m) {
- console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix().");
- return this.setFromProjectionMatrix(m);
- };
- Line3.prototype.center = function(optionalTarget) {
- console.warn("THREE.Line3: .center() has been renamed to .getCenter().");
- return this.getCenter(optionalTarget);
- };
- Object.assign(MathUtils, {
- random16: function() {
- console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead.");
- return Math.random();
- },
- nearestPowerOfTwo: function(value) {
- console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo().");
- return MathUtils.floorPowerOfTwo(value);
- },
- nextPowerOfTwo: function(value) {
- console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo().");
- return MathUtils.ceilPowerOfTwo(value);
- }
- });
- Object.assign(Matrix3.prototype, {
- flattenToArrayOffset: function(array, offset) {
- console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.");
- return this.toArray(array, offset);
- },
- multiplyVector3: function(vector) {
- console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.");
- return vector.applyMatrix3(this);
- },
- multiplyVector3Array: function() {
- console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.");
- },
- applyToBufferAttribute: function(attribute) {
- console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead.");
- return attribute.applyMatrix3(this);
- },
- applyToVector3Array: function() {
- console.error("THREE.Matrix3: .applyToVector3Array() has been removed.");
- }
- });
- Object.assign(Matrix4.prototype, {
- extractPosition: function(m) {
- console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().");
- return this.copyPosition(m);
- },
- flattenToArrayOffset: function(array, offset) {
- console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.");
- return this.toArray(array, offset);
- },
- getPosition: function() {
- console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.");
- return new Vector3().setFromMatrixColumn(this, 3);
- },
- setRotationFromQuaternion: function(q) {
- console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().");
- return this.makeRotationFromQuaternion(q);
- },
- multiplyToArray: function() {
- console.warn("THREE.Matrix4: .multiplyToArray() has been removed.");
- },
- multiplyVector3: function(vector) {
- console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead.");
- return vector.applyMatrix4(this);
- },
- multiplyVector4: function(vector) {
- console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.");
- return vector.applyMatrix4(this);
- },
- multiplyVector3Array: function() {
- console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.");
- },
- rotateAxis: function(v) {
- console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.");
- v.transformDirection(this);
- },
- crossVector: function(vector) {
- console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.");
- return vector.applyMatrix4(this);
- },
- translate: function() {
- console.error("THREE.Matrix4: .translate() has been removed.");
- },
- rotateX: function() {
- console.error("THREE.Matrix4: .rotateX() has been removed.");
- },
- rotateY: function() {
- console.error("THREE.Matrix4: .rotateY() has been removed.");
- },
- rotateZ: function() {
- console.error("THREE.Matrix4: .rotateZ() has been removed.");
- },
- rotateByAxis: function() {
- console.error("THREE.Matrix4: .rotateByAxis() has been removed.");
- },
- applyToBufferAttribute: function(attribute) {
- console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead.");
- return attribute.applyMatrix4(this);
- },
- applyToVector3Array: function() {
- console.error("THREE.Matrix4: .applyToVector3Array() has been removed.");
- },
- makeFrustum: function(left, right, bottom, top2, near, far) {
- console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead.");
- return this.makePerspective(left, right, top2, bottom, near, far);
- }
- });
- Plane.prototype.isIntersectionLine = function(line) {
- console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().");
- return this.intersectsLine(line);
- };
- Quaternion.prototype.multiplyVector3 = function(vector) {
- console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.");
- return vector.applyQuaternion(this);
- };
- Object.assign(Ray.prototype, {
- isIntersectionBox: function(box) {
- console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().");
- return this.intersectsBox(box);
- },
- isIntersectionPlane: function(plane) {
- console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().");
- return this.intersectsPlane(plane);
- },
- isIntersectionSphere: function(sphere) {
- console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().");
- return this.intersectsSphere(sphere);
- }
- });
- Object.assign(Triangle.prototype, {
- area: function() {
- console.warn("THREE.Triangle: .area() has been renamed to .getArea().");
- return this.getArea();
- },
- barycoordFromPoint: function(point, target) {
- console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().");
- return this.getBarycoord(point, target);
- },
- midpoint: function(target) {
- console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint().");
- return this.getMidpoint(target);
- },
- normal: function(target) {
- console.warn("THREE.Triangle: .normal() has been renamed to .getNormal().");
- return this.getNormal(target);
- },
- plane: function(target) {
- console.warn("THREE.Triangle: .plane() has been renamed to .getPlane().");
- return this.getPlane(target);
- }
- });
- Object.assign(Triangle, {
- barycoordFromPoint: function(point, a, b, c, target) {
- console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().");
- return Triangle.getBarycoord(point, a, b, c, target);
- },
- normal: function(a, b, c, target) {
- console.warn("THREE.Triangle: .normal() has been renamed to .getNormal().");
- return Triangle.getNormal(a, b, c, target);
- }
- });
- Object.assign(Shape.prototype, {
- extractAllPoints: function(divisions) {
- console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead.");
- return this.extractPoints(divisions);
- },
- extrude: function(options) {
- console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.");
- return new ExtrudeGeometry(this, options);
- },
- makeGeometry: function(options) {
- console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.");
- return new ShapeGeometry(this, options);
- }
- });
- Object.assign(Vector2.prototype, {
- fromAttribute: function(attribute, index, offset) {
- console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute().");
- return this.fromBufferAttribute(attribute, index, offset);
- },
- distanceToManhattan: function(v) {
- console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo().");
- return this.manhattanDistanceTo(v);
- },
- lengthManhattan: function() {
- console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength().");
- return this.manhattanLength();
- }
- });
- Object.assign(Vector3.prototype, {
- setEulerFromRotationMatrix: function() {
- console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.");
- },
- setEulerFromQuaternion: function() {
- console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.");
- },
- getPositionFromMatrix: function(m) {
- console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().");
- return this.setFromMatrixPosition(m);
- },
- getScaleFromMatrix: function(m) {
- console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().");
- return this.setFromMatrixScale(m);
- },
- getColumnFromMatrix: function(index, matrix) {
- console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().");
- return this.setFromMatrixColumn(matrix, index);
- },
- applyProjection: function(m) {
- console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead.");
- return this.applyMatrix4(m);
- },
- fromAttribute: function(attribute, index, offset) {
- console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute().");
- return this.fromBufferAttribute(attribute, index, offset);
- },
- distanceToManhattan: function(v) {
- console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo().");
- return this.manhattanDistanceTo(v);
- },
- lengthManhattan: function() {
- console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength().");
- return this.manhattanLength();
- }
- });
- Object.assign(Vector4.prototype, {
- fromAttribute: function(attribute, index, offset) {
- console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute().");
- return this.fromBufferAttribute(attribute, index, offset);
- },
- lengthManhattan: function() {
- console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength().");
- return this.manhattanLength();
- }
- });
- Object.assign(Geometry.prototype, {
- computeTangents: function() {
- console.error("THREE.Geometry: .computeTangents() has been removed.");
- },
- computeLineDistances: function() {
- console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.");
- },
- applyMatrix: function(matrix) {
- console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4().");
- return this.applyMatrix4(matrix);
- }
- });
- Object.assign(Object3D.prototype, {
- getChildByName: function(name) {
- console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().");
- return this.getObjectByName(name);
- },
- renderDepth: function() {
- console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.");
- },
- translate: function(distance, axis) {
- console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.");
- return this.translateOnAxis(axis, distance);
- },
- getWorldRotation: function() {
- console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.");
- },
- applyMatrix: function(matrix) {
- console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4().");
- return this.applyMatrix4(matrix);
- }
- });
- Object.defineProperties(Object3D.prototype, {
- eulerOrder: {
- get: function() {
- console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");
- return this.rotation.order;
- },
- set: function(value) {
- console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");
- this.rotation.order = value;
- }
- },
- useQuaternion: {
- get: function() {
- console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.");
- },
- set: function() {
- console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.");
- }
- }
- });
- Object.assign(Mesh.prototype, {
- setDrawMode: function() {
- console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.");
- }
- });
- Object.defineProperties(Mesh.prototype, {
- drawMode: {
- get: function() {
- console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode.");
- return TrianglesDrawMode;
- },
- set: function() {
- console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.");
- }
- }
- });
- Object.defineProperties(LOD.prototype, {
- objects: {
- get: function() {
- console.warn("THREE.LOD: .objects has been renamed to .levels.");
- return this.levels;
- }
- }
- });
- Object.defineProperty(Skeleton.prototype, "useVertexTexture", {
- get: function() {
- console.warn("THREE.Skeleton: useVertexTexture has been removed.");
- },
- set: function() {
- console.warn("THREE.Skeleton: useVertexTexture has been removed.");
- }
- });
- SkinnedMesh.prototype.initBones = function() {
- console.error("THREE.SkinnedMesh: initBones() has been removed.");
- };
- Object.defineProperty(Curve.prototype, "__arcLengthDivisions", {
- get: function() {
- console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions.");
- return this.arcLengthDivisions;
- },
- set: function(value) {
- console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions.");
- this.arcLengthDivisions = value;
- }
- });
- PerspectiveCamera.prototype.setLens = function(focalLength, filmGauge) {
- console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup.");
- if (filmGauge !== void 0)
- this.filmGauge = filmGauge;
- this.setFocalLength(focalLength);
- };
- Object.defineProperties(Light.prototype, {
- onlyShadow: {
- set: function() {
- console.warn("THREE.Light: .onlyShadow has been removed.");
- }
- },
- shadowCameraFov: {
- set: function(value) {
- console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov.");
- this.shadow.camera.fov = value;
- }
- },
- shadowCameraLeft: {
- set: function(value) {
- console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left.");
- this.shadow.camera.left = value;
- }
- },
- shadowCameraRight: {
- set: function(value) {
- console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right.");
- this.shadow.camera.right = value;
- }
- },
- shadowCameraTop: {
- set: function(value) {
- console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top.");
- this.shadow.camera.top = value;
- }
- },
- shadowCameraBottom: {
- set: function(value) {
- console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.");
- this.shadow.camera.bottom = value;
- }
- },
- shadowCameraNear: {
- set: function(value) {
- console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near.");
- this.shadow.camera.near = value;
- }
- },
- shadowCameraFar: {
- set: function(value) {
- console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far.");
- this.shadow.camera.far = value;
- }
- },
- shadowCameraVisible: {
- set: function() {
- console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.");
- }
- },
- shadowBias: {
- set: function(value) {
- console.warn("THREE.Light: .shadowBias is now .shadow.bias.");
- this.shadow.bias = value;
- }
- },
- shadowDarkness: {
- set: function() {
- console.warn("THREE.Light: .shadowDarkness has been removed.");
- }
- },
- shadowMapWidth: {
- set: function(value) {
- console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.");
- this.shadow.mapSize.width = value;
- }
- },
- shadowMapHeight: {
- set: function(value) {
- console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.");
- this.shadow.mapSize.height = value;
- }
- }
- });
- Object.defineProperties(BufferAttribute.prototype, {
- length: {
- get: function() {
- console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead.");
- return this.array.length;
- }
- },
- dynamic: {
- get: function() {
- console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead.");
- return this.usage === DynamicDrawUsage;
- },
- set: function() {
- console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead.");
- this.setUsage(DynamicDrawUsage);
- }
- }
- });
- Object.assign(BufferAttribute.prototype, {
- setDynamic: function(value) {
- console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead.");
- this.setUsage(value === true ? DynamicDrawUsage : StaticDrawUsage);
- return this;
- },
- copyIndicesArray: function() {
- console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.");
- },
- setArray: function() {
- console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers");
- }
- });
- Object.assign(BufferGeometry.prototype, {
- addIndex: function(index) {
- console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().");
- this.setIndex(index);
- },
- addAttribute: function(name, attribute) {
- console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute().");
- if (!(attribute && attribute.isBufferAttribute) && !(attribute && attribute.isInterleavedBufferAttribute)) {
- console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute ).");
- return this.setAttribute(name, new BufferAttribute(arguments[1], arguments[2]));
- }
- if (name === "index") {
- console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute.");
- this.setIndex(attribute);
- return this;
- }
- return this.setAttribute(name, attribute);
- },
- addDrawCall: function(start, count, indexOffset) {
- if (indexOffset !== void 0) {
- console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.");
- }
- console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup().");
- this.addGroup(start, count);
- },
- clearDrawCalls: function() {
- console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().");
- this.clearGroups();
- },
- computeTangents: function() {
- console.warn("THREE.BufferGeometry: .computeTangents() has been removed.");
- },
- computeOffsets: function() {
- console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.");
- },
- removeAttribute: function(name) {
- console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute().");
- return this.deleteAttribute(name);
- },
- applyMatrix: function(matrix) {
- console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4().");
- return this.applyMatrix4(matrix);
- }
- });
- Object.defineProperties(BufferGeometry.prototype, {
- drawcalls: {
- get: function() {
- console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups.");
- return this.groups;
- }
- },
- offsets: {
- get: function() {
- console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups.");
- return this.groups;
- }
- }
- });
- Object.defineProperties(InterleavedBuffer.prototype, {
- dynamic: {
- get: function() {
- console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead.");
- return this.usage === DynamicDrawUsage;
- },
- set: function(value) {
- console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead.");
- this.setUsage(value);
- }
- }
- });
- Object.assign(InterleavedBuffer.prototype, {
- setDynamic: function(value) {
- console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead.");
- this.setUsage(value === true ? DynamicDrawUsage : StaticDrawUsage);
- return this;
- },
- setArray: function() {
- console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers");
- }
- });
- Object.assign(ExtrudeBufferGeometry.prototype, {
- getArrays: function() {
- console.error("THREE.ExtrudeBufferGeometry: .getArrays() has been removed.");
- },
- addShapeList: function() {
- console.error("THREE.ExtrudeBufferGeometry: .addShapeList() has been removed.");
- },
- addShape: function() {
- console.error("THREE.ExtrudeBufferGeometry: .addShape() has been removed.");
- }
- });
- Object.defineProperties(Uniform.prototype, {
- dynamic: {
- set: function() {
- console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.");
- }
- },
- onUpdate: {
- value: function() {
- console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead.");
- return this;
- }
- }
- });
- Object.defineProperties(Material.prototype, {
- wrapAround: {
- get: function() {
- console.warn("THREE.Material: .wrapAround has been removed.");
- },
- set: function() {
- console.warn("THREE.Material: .wrapAround has been removed.");
- }
- },
- overdraw: {
- get: function() {
- console.warn("THREE.Material: .overdraw has been removed.");
- },
- set: function() {
- console.warn("THREE.Material: .overdraw has been removed.");
- }
- },
- wrapRGB: {
- get: function() {
- console.warn("THREE.Material: .wrapRGB has been removed.");
- return new Color();
- }
- },
- shading: {
- get: function() {
- console.error("THREE." + this.type + ": .shading has been removed. Use the boolean .flatShading instead.");
- },
- set: function(value) {
- console.warn("THREE." + this.type + ": .shading has been removed. Use the boolean .flatShading instead.");
- this.flatShading = value === FlatShading;
- }
- },
- stencilMask: {
- get: function() {
- console.warn("THREE." + this.type + ": .stencilMask has been removed. Use .stencilFuncMask instead.");
- return this.stencilFuncMask;
- },
- set: function(value) {
- console.warn("THREE." + this.type + ": .stencilMask has been removed. Use .stencilFuncMask instead.");
- this.stencilFuncMask = value;
- }
- }
- });
- Object.defineProperties(MeshPhongMaterial.prototype, {
- metal: {
- get: function() {
- console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead.");
- return false;
- },
- set: function() {
- console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead");
- }
- }
- });
- Object.defineProperties(ShaderMaterial.prototype, {
- derivatives: {
- get: function() {
- console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");
- return this.extensions.derivatives;
- },
- set: function(value) {
- console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");
- this.extensions.derivatives = value;
- }
- }
- });
- Object.assign(WebGLRenderer.prototype, {
- clearTarget: function(renderTarget, color, depth, stencil) {
- console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead.");
- this.setRenderTarget(renderTarget);
- this.clear(color, depth, stencil);
- },
- animate: function(callback) {
- console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop().");
- this.setAnimationLoop(callback);
- },
- getCurrentRenderTarget: function() {
- console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget().");
- return this.getRenderTarget();
- },
- getMaxAnisotropy: function() {
- console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy().");
- return this.capabilities.getMaxAnisotropy();
- },
- getPrecision: function() {
- console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision.");
- return this.capabilities.precision;
- },
- resetGLState: function() {
- console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset().");
- return this.state.reset();
- },
- supportsFloatTextures: function() {
- console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' ).");
- return this.extensions.get("OES_texture_float");
- },
- supportsHalfFloatTextures: function() {
- console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' ).");
- return this.extensions.get("OES_texture_half_float");
- },
- supportsStandardDerivatives: function() {
- console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' ).");
- return this.extensions.get("OES_standard_derivatives");
- },
- supportsCompressedTextureS3TC: function() {
- console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' ).");
- return this.extensions.get("WEBGL_compressed_texture_s3tc");
- },
- supportsCompressedTexturePVRTC: function() {
- console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' ).");
- return this.extensions.get("WEBGL_compressed_texture_pvrtc");
- },
- supportsBlendMinMax: function() {
- console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' ).");
- return this.extensions.get("EXT_blend_minmax");
- },
- supportsVertexTextures: function() {
- console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures.");
- return this.capabilities.vertexTextures;
- },
- supportsInstancedArrays: function() {
- console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' ).");
- return this.extensions.get("ANGLE_instanced_arrays");
- },
- enableScissorTest: function(boolean) {
- console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().");
- this.setScissorTest(boolean);
- },
- initMaterial: function() {
- console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.");
- },
- addPrePlugin: function() {
- console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.");
- },
- addPostPlugin: function() {
- console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.");
- },
- updateShadowMap: function() {
- console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.");
- },
- setFaceCulling: function() {
- console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.");
- },
- allocTextureUnit: function() {
- console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.");
- },
- setTexture: function() {
- console.warn("THREE.WebGLRenderer: .setTexture() has been removed.");
- },
- setTexture2D: function() {
- console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.");
- },
- setTextureCube: function() {
- console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.");
- },
- getActiveMipMapLevel: function() {
- console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel().");
- return this.getActiveMipmapLevel();
- }
- });
- Object.defineProperties(WebGLRenderer.prototype, {
- shadowMapEnabled: {
- get: function() {
- return this.shadowMap.enabled;
- },
- set: function(value) {
- console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.");
- this.shadowMap.enabled = value;
- }
- },
- shadowMapType: {
- get: function() {
- return this.shadowMap.type;
- },
- set: function(value) {
- console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.");
- this.shadowMap.type = value;
- }
- },
- shadowMapCullFace: {
- get: function() {
- console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.");
- return void 0;
- },
- set: function() {
- console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.");
- }
- },
- context: {
- get: function() {
- console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead.");
- return this.getContext();
- }
- },
- vr: {
- get: function() {
- console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr");
- return this.xr;
- }
- },
- gammaInput: {
- get: function() {
- console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.");
- return false;
- },
- set: function() {
- console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.");
- }
- },
- gammaOutput: {
- get: function() {
- console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead.");
- return false;
- },
- set: function(value) {
- console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead.");
- this.outputEncoding = value === true ? sRGBEncoding : LinearEncoding;
- }
- }
- });
- Object.defineProperties(WebGLShadowMap.prototype, {
- cullFace: {
- get: function() {
- console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.");
- return void 0;
- },
- set: function() {
- console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.");
- }
- },
- renderReverseSided: {
- get: function() {
- console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.");
- return void 0;
- },
- set: function() {
- console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.");
- }
- },
- renderSingleSided: {
- get: function() {
- console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.");
- return void 0;
- },
- set: function() {
- console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.");
- }
- }
- });
- Object.defineProperties(WebGLRenderTarget.prototype, {
- wrapS: {
- get: function() {
- console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");
- return this.texture.wrapS;
- },
- set: function(value) {
- console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");
- this.texture.wrapS = value;
- }
- },
- wrapT: {
- get: function() {
- console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");
- return this.texture.wrapT;
- },
- set: function(value) {
- console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");
- this.texture.wrapT = value;
- }
- },
- magFilter: {
- get: function() {
- console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");
- return this.texture.magFilter;
- },
- set: function(value) {
- console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");
- this.texture.magFilter = value;
- }
- },
- minFilter: {
- get: function() {
- console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");
- return this.texture.minFilter;
- },
- set: function(value) {
- console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");
- this.texture.minFilter = value;
- }
- },
- anisotropy: {
- get: function() {
- console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");
- return this.texture.anisotropy;
- },
- set: function(value) {
- console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");
- this.texture.anisotropy = value;
- }
- },
- offset: {
- get: function() {
- console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");
- return this.texture.offset;
- },
- set: function(value) {
- console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");
- this.texture.offset = value;
- }
- },
- repeat: {
- get: function() {
- console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");
- return this.texture.repeat;
- },
- set: function(value) {
- console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");
- this.texture.repeat = value;
- }
- },
- format: {
- get: function() {
- console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");
- return this.texture.format;
- },
- set: function(value) {
- console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");
- this.texture.format = value;
- }
- },
- type: {
- get: function() {
- console.warn("THREE.WebGLRenderTarget: .type is now .texture.type.");
- return this.texture.type;
- },
- set: function(value) {
- console.warn("THREE.WebGLRenderTarget: .type is now .texture.type.");
- this.texture.type = value;
- }
- },
- generateMipmaps: {
- get: function() {
- console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");
- return this.texture.generateMipmaps;
- },
- set: function(value) {
- console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");
- this.texture.generateMipmaps = value;
- }
- }
- });
- Object.defineProperties(Audio.prototype, {
- load: {
- value: function(file) {
- console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");
- var scope = this;
- var audioLoader = new AudioLoader();
- audioLoader.load(file, function(buffer) {
- scope.setBuffer(buffer);
- });
- return this;
- }
- },
- startTime: {
- set: function() {
- console.warn("THREE.Audio: .startTime is now .play( delay ).");
- }
- }
- });
- AudioAnalyser.prototype.getData = function() {
- console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData().");
- return this.getFrequencyData();
- };
- CubeCamera.prototype.updateCubeMap = function(renderer, scene) {
- console.warn("THREE.CubeCamera: .updateCubeMap() is now .update().");
- return this.update(renderer, scene);
- };
- ImageUtils.crossOrigin = void 0;
- ImageUtils.loadTexture = function(url, mapping, onLoad, onError) {
- console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");
- var loader = new TextureLoader();
- loader.setCrossOrigin(this.crossOrigin);
- var texture = loader.load(url, onLoad, void 0, onError);
- if (mapping)
- texture.mapping = mapping;
- return texture;
- };
- ImageUtils.loadTextureCube = function(urls, mapping, onLoad, onError) {
- console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");
- var loader = new CubeTextureLoader();
- loader.setCrossOrigin(this.crossOrigin);
- var texture = loader.load(urls, onLoad, void 0, onError);
- if (mapping)
- texture.mapping = mapping;
- return texture;
- };
- ImageUtils.loadCompressedTexture = function() {
- console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.");
- };
- ImageUtils.loadCompressedTextureCube = function() {
- console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.");
- };
- if (typeof __THREE_DEVTOOLS__ !== "undefined") {
- __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: {
- revision: REVISION
- } }));
- }
- class MyAlignedDimension extends mxdraw.MxDbAlignedDimension {
- constructor() {
- super();
- }
- getDimText() {
- var v2ndPtTo1stPt = new Vector3(this.point1.x - this.point2.x, this.point1.y - this.point2.y, 0);
- var fLen = v2ndPtTo1stPt.length();
- return fLen.toFixed(2);
- }
- create() {
- return new MyAlignedDimension();
- }
- getTypeName() {
- return this.constructor.name;
- }
- }
- function Mx_Linear() {
- return __async(this, null, function* () {
- const getPoint = new mxdraw.MrxDbgUiPrPoint();
- getPoint.setMessage("\n指定第一点:");
- getPoint.go((status) => {
- if (status != 0) {
- return;
- }
- const pt1 = getPoint.value();
- let dim = new MyAlignedDimension();
- dim.setPoint1(pt1);
- dim.setColor(65314);
- const worldDrawComment = new mxdraw.McEdGetPointWorldDrawObject();
- worldDrawComment.setDraw((currentPoint) => {
- dim.setPoint2(currentPoint);
- worldDrawComment.drawCustomEntity(dim);
- });
- getPoint.setBasePt(pt1);
- getPoint.setUseBasePt(true);
- getPoint.setUserDraw(worldDrawComment);
- getPoint.setMessage("\n指定第二点:");
- getPoint.setInputToucheType(mxdraw.MxType.InputToucheType.kGetEnd);
- getPoint.go((status2) => {
- if (status2 != 0) {
- console.log(status2);
- return;
- }
- const pt2 = getPoint.value();
- dim.setPoint2(pt2);
- mxdraw.MxFun.getCurrentDraw().addMxEntity(dim);
- alert("测试长度是:" + dim.getDimText());
- });
- });
- });
- }
- function BR_AngleMeasure() {
- const point = new mxdraw.MrxDbgUiPrPoint();
- const mxDraw = mxdraw.MxFun.getCurrentDraw();
- const angleDim = new mxdraw.MxDb2LineAngularDimension();
- angleDim.color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
- const worldDraw = new mxdraw.McEdGetPointWorldDrawObject();
- worldDraw.setColor(mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor());
- point.setMessage("\n指定第一点:");
- point.go((status) => {
- if (status !== 0) {
- return;
- }
- point.setMessage("\n指定第二个角度点:");
- angleDim.point1 = point.value();
- worldDraw.setDraw((currentPoint, pWorldDraw) => {
- angleDim.point2 = currentPoint;
- pWorldDraw.drawLine(angleDim.point1, currentPoint);
- });
- point.setUserDraw(worldDraw);
- point.go((status2) => {
- point.setMessage("\n指定最后一个点:");
- if (status2 !== 0) {
- return;
- }
- angleDim.point2 = point.value();
- worldDraw.setDraw((currentPoint, pWorldDraw) => {
- angleDim.point3 = currentPoint;
- worldDraw.drawCustomEntity(angleDim);
- });
- point.go((status3) => {
- if (status3 !== 0) {
- return;
- }
- mxDraw.addMxEntity(angleDim);
- });
- });
- });
- }
- function BR_CoordMeasure() {
- const getPoint = new mxdraw.MrxDbgUiPrPoint();
- getPoint.setMessage("\n指定坐标点:");
- getPoint.go((status) => {
- if (status != 0) {
- return;
- }
- const pt1 = getPoint.value();
- let mxCoord = new mxdraw.MxDbCoord();
- mxCoord.point1 = pt1;
- mxCoord.point2 = pt1.clone();
- mxCoord.color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
- getPoint.setBasePt(pt1);
- getPoint.setUseBasePt(true);
- getPoint.setUserDraw((curPoint, pWorldDraw) => {
- mxCoord.point2 = curPoint;
- pWorldDraw.drawCustomEntity(mxCoord);
- });
- getPoint.setMessage("\n指定标注点:");
- getPoint.go((status2) => {
- if (status2 != 0) {
- console.log(status2);
- return;
- }
- mxCoord.point2 = getPoint.value();
- mxdraw.MxFun.addToCurrentSpace(mxCoord);
- });
- });
- }
- function init$m() {
- new MyAlignedDimension().rxInit();
- mxdraw.MxFun.addCommand("Mx_Linear", Mx_Linear);
- mxdraw.MxFun.addCommand("BR_AngleMeasure", BR_AngleMeasure);
- mxdraw.MxFun.addCommand("BR_CoordMeasure", BR_CoordMeasure);
- }
- function MxTest_SelectEntity() {
- return __async(this, null, function* () {
- let getEnt = new mxcad2.MxCADUiPrEntity();
- getEnt.setMessage("select entity:");
- let id = yield getEnt.go();
- let ent = id.getMcDbEntity();
- if (ent === null)
- return;
- console.log("ent.objectName", ent.objectName);
- if (ent instanceof mxcad2.McDbBlockReference) {
- let blkRef = ent;
- let retExplode = blkRef.explode();
- if (retExplode.GetCount() == 0)
- return;
- let iExplodeConut = retExplode.GetCount();
- for (let j = 0; j < iExplodeConut; j++) {
- let tmpobj = retExplode.AtObject(j).val;
- if (tmpobj instanceof mxcad2.McDbPolyline) {
- let polyline = tmpobj;
- let num = polyline.numVerts();
- for (let i2 = 0; i2 < num; i2++) {
- let pt = polyline.getPointAt(i2);
- let bulge = polyline.getBulgeAt(i2);
- console.log("polyline.pt" + i2 + ":" + McGePoint3dToString(pt.val));
- console.log("polyline.bulge" + i2 + ":" + bulge);
- }
- }
- }
- } else if (ent instanceof mxcad2.McDbPolyline) {
- let polyline = ent;
- let num = polyline.numVerts();
- for (let i2 = 0; i2 < num; i2++) {
- let pt = polyline.getPointAt(i2);
- let bulge = polyline.getBulgeAt(i2);
- console.log("polyline.pt" + i2 + ":" + McGePoint3dToString(pt.val));
- console.log("polyline.bulge" + i2 + ":" + bulge);
- }
- }
- });
- }
- function init$l() {
- mxdraw.MxFun.addCommand("MxTest_SelectEntity", MxTest_SelectEntity);
- }
- class MxDrawTableData {
- constructor() {
- this.m_aryColumn = [];
- this.m_allData = [];
- this.m_dColumnHeight = 14;
- this.m_dRowHeight = 10;
- this.m_dRowLineWdith = 0;
- this.m_dColumnLineWidth = 0.5;
- this.m_dRowTextHeight = 6;
- this.m_dColumnTextHeight = 10;
- }
- addColumn(sName, dW) {
- this.m_aryColumn.push({ name: sName, w: dW });
- }
- addRow(ary) {
- this.m_allData.push(ary);
- }
- }
- class MxDrawTable {
- constructor() {
- this.data = new MxDrawTableData();
- this.pt = new mxcad2.McGePoint3d();
- this.dScale = 1;
- this.mxcad = mxcad2.MxCpp.getCurrentMxCAD();
- }
- draw(pt, dScale) {
- this.pt = pt;
- this.dScale = dScale;
- if (this.data.m_aryColumn.length == 0)
- return false;
- if (this.data.m_allData.length == 0)
- return false;
- this.DrawTableHead();
- this.DrawContent();
- return true;
- }
- DrawTableHead() {
- let m_data = this.data;
- let m_instPt = this.pt.clone();
- let curPt = this.pt.clone();
- let vecTmp = new mxcad2.McGeVector3d(0, 1, 0).mult(this.Scale(this.data.m_dColumnHeight));
- console.log(vecTmp);
- let dLineWidth = this.Scale(this.data.m_dColumnLineWidth);
- let dAllW = 0;
- let kXAxis = new mxcad2.McGeVector3d(1, 0, 0);
- for (let i2 = 0; i2 < m_data.m_aryColumn.length; i2++) {
- let col = m_data.m_aryColumn[i2];
- this.DrawLine(curPt, curPt.clone().subvec(vecTmp), dLineWidth);
- 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));
- curPt.addvec(kXAxis.clone().mult(this.Scale(col.w)));
- dAllW += this.Scale(col.w);
- }
- this.DrawLine(curPt, curPt.clone().subvec(vecTmp), dLineWidth);
- this.DrawLine(m_instPt, m_instPt.clone().addvec(kXAxis.clone().mult(dAllW)), dLineWidth);
- this.DrawLine(m_instPt.clone().subvec(vecTmp), m_instPt.addvec(kXAxis.clone().mult(dAllW)).subvec(vecTmp), dLineWidth);
- return true;
- }
- DrawContent() {
- let m_data = this.data;
- let m_instPt = this.pt;
- let dAllW = 0;
- for (let i2 = 0; i2 < m_data.m_aryColumn.length; i2++) {
- dAllW += this.Scale(m_data.m_aryColumn[i2].w);
- }
- let dLineWidth = this.Scale(this.data.m_dRowLineWdith);
- let kXAxis = new mxcad2.McGeVector3d(1, 0, 0);
- let kYAxis = new mxcad2.McGeVector3d(0, 1, 0);
- let instPt = m_instPt.clone().subvec(kYAxis.clone().mult(this.Scale(m_data.m_dColumnHeight)));
- let vecTmp = kYAxis.clone().mult(this.Scale(m_data.m_dRowHeight));
- for (let i2 = 0; i2 < m_data.m_allData.length; i2++) {
- let curPt = instPt.clone();
- for (let j = 0; j < m_data.m_aryColumn.length; j++) {
- let col = m_data.m_aryColumn[j];
- this.DrawLine(curPt, curPt.clone().subvec(vecTmp), dLineWidth);
- 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));
- curPt.addvec(kXAxis.clone().mult(this.Scale(col.w)));
- }
- this.DrawLine(curPt, curPt.clone().subvec(vecTmp), dLineWidth);
- this.DrawLine(instPt, instPt.clone().addvec(kXAxis.clone().mult(dAllW)), dLineWidth);
- this.DrawLine(instPt.clone().subvec(vecTmp), instPt.clone().addvec(kXAxis.clone().mult(dAllW)).subvec(vecTmp), dLineWidth);
- instPt.subvec(vecTmp);
- }
- return true;
- }
- DrawLine(pt1, pt2, dLineWidth) {
- this.mxcad.drawLineWidth = dLineWidth;
- this.mxcad.drawColorIndex = mxcad2.ColorIndexType.kMagenta;
- this.mxcad.drawLine(pt1.x, pt1.y, pt2.x, pt2.y);
- }
- DrawMCText(pt1, sTxt, dTextHeight) {
- this.mxcad.drawColorIndex = 0;
- this.mxcad.drawColor = new mxcad2.McCmColor(0, 255, 0);
- this.mxcad.drawText(pt1.x, pt1.y, sTxt, dTextHeight, 0, mxcad2.McDb.TextHorzMode.kTextMid, mxcad2.McDb.TextVertMode.kTextVertMid);
- }
- Scale(dL) {
- return dL * this.dScale;
- }
- }
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
- function getDefaultExportFromCjs(x) {
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
- }
- var qrcode = { exports: {} };
- (function(module, exports2) {
- var qrcode2 = function() {
- var qrcode3 = function(typeNumber, errorCorrectionLevel) {
- var PAD0 = 236;
- var PAD1 = 17;
- var _typeNumber = typeNumber;
- var _errorCorrectionLevel = QRErrorCorrectionLevel[errorCorrectionLevel];
- var _modules = null;
- var _moduleCount = 0;
- var _dataCache = null;
- var _dataList = [];
- var _this = {};
- var makeImpl = function(test2, maskPattern) {
- _moduleCount = _typeNumber * 4 + 17;
- _modules = function(moduleCount) {
- var modules = new Array(moduleCount);
- for (var row = 0; row < moduleCount; row += 1) {
- modules[row] = new Array(moduleCount);
- for (var col = 0; col < moduleCount; col += 1) {
- modules[row][col] = null;
- }
- }
- return modules;
- }(_moduleCount);
- setupPositionProbePattern(0, 0);
- setupPositionProbePattern(_moduleCount - 7, 0);
- setupPositionProbePattern(0, _moduleCount - 7);
- setupPositionAdjustPattern();
- setupTimingPattern();
- setupTypeInfo(test2, maskPattern);
- if (_typeNumber >= 7) {
- setupTypeNumber(test2);
- }
- if (_dataCache == null) {
- _dataCache = createData(_typeNumber, _errorCorrectionLevel, _dataList);
- }
- mapData(_dataCache, maskPattern);
- };
- var setupPositionProbePattern = function(row, col) {
- for (var r = -1; r <= 7; r += 1) {
- if (row + r <= -1 || _moduleCount <= row + r)
- continue;
- for (var c = -1; c <= 7; c += 1) {
- if (col + c <= -1 || _moduleCount <= col + c)
- continue;
- 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) {
- _modules[row + r][col + c] = true;
- } else {
- _modules[row + r][col + c] = false;
- }
- }
- }
- };
- var getBestMaskPattern = function() {
- var minLostPoint = 0;
- var pattern = 0;
- for (var i2 = 0; i2 < 8; i2 += 1) {
- makeImpl(true, i2);
- var lostPoint = QRUtil.getLostPoint(_this);
- if (i2 == 0 || minLostPoint > lostPoint) {
- minLostPoint = lostPoint;
- pattern = i2;
- }
- }
- return pattern;
- };
- var setupTimingPattern = function() {
- for (var r = 8; r < _moduleCount - 8; r += 1) {
- if (_modules[r][6] != null) {
- continue;
- }
- _modules[r][6] = r % 2 == 0;
- }
- for (var c = 8; c < _moduleCount - 8; c += 1) {
- if (_modules[6][c] != null) {
- continue;
- }
- _modules[6][c] = c % 2 == 0;
- }
- };
- var setupPositionAdjustPattern = function() {
- var pos = QRUtil.getPatternPosition(_typeNumber);
- for (var i2 = 0; i2 < pos.length; i2 += 1) {
- for (var j = 0; j < pos.length; j += 1) {
- var row = pos[i2];
- var col = pos[j];
- if (_modules[row][col] != null) {
- continue;
- }
- for (var r = -2; r <= 2; r += 1) {
- for (var c = -2; c <= 2; c += 1) {
- if (r == -2 || r == 2 || c == -2 || c == 2 || r == 0 && c == 0) {
- _modules[row + r][col + c] = true;
- } else {
- _modules[row + r][col + c] = false;
- }
- }
- }
- }
- }
- };
- var setupTypeNumber = function(test2) {
- var bits = QRUtil.getBCHTypeNumber(_typeNumber);
- for (var i2 = 0; i2 < 18; i2 += 1) {
- var mod = !test2 && (bits >> i2 & 1) == 1;
- _modules[Math.floor(i2 / 3)][i2 % 3 + _moduleCount - 8 - 3] = mod;
- }
- for (var i2 = 0; i2 < 18; i2 += 1) {
- var mod = !test2 && (bits >> i2 & 1) == 1;
- _modules[i2 % 3 + _moduleCount - 8 - 3][Math.floor(i2 / 3)] = mod;
- }
- };
- var setupTypeInfo = function(test2, maskPattern) {
- var data = _errorCorrectionLevel << 3 | maskPattern;
- var bits = QRUtil.getBCHTypeInfo(data);
- for (var i2 = 0; i2 < 15; i2 += 1) {
- var mod = !test2 && (bits >> i2 & 1) == 1;
- if (i2 < 6) {
- _modules[i2][8] = mod;
- } else if (i2 < 8) {
- _modules[i2 + 1][8] = mod;
- } else {
- _modules[_moduleCount - 15 + i2][8] = mod;
- }
- }
- for (var i2 = 0; i2 < 15; i2 += 1) {
- var mod = !test2 && (bits >> i2 & 1) == 1;
- if (i2 < 8) {
- _modules[8][_moduleCount - i2 - 1] = mod;
- } else if (i2 < 9) {
- _modules[8][15 - i2 - 1 + 1] = mod;
- } else {
- _modules[8][15 - i2 - 1] = mod;
- }
- }
- _modules[_moduleCount - 8][8] = !test2;
- };
- var mapData = function(data, maskPattern) {
- var inc = -1;
- var row = _moduleCount - 1;
- var bitIndex = 7;
- var byteIndex = 0;
- var maskFunc = QRUtil.getMaskFunction(maskPattern);
- for (var col = _moduleCount - 1; col > 0; col -= 2) {
- if (col == 6)
- col -= 1;
- while (true) {
- for (var c = 0; c < 2; c += 1) {
- if (_modules[row][col - c] == null) {
- var dark = false;
- if (byteIndex < data.length) {
- dark = (data[byteIndex] >>> bitIndex & 1) == 1;
- }
- var mask = maskFunc(row, col - c);
- if (mask) {
- dark = !dark;
- }
- _modules[row][col - c] = dark;
- bitIndex -= 1;
- if (bitIndex == -1) {
- byteIndex += 1;
- bitIndex = 7;
- }
- }
- }
- row += inc;
- if (row < 0 || _moduleCount <= row) {
- row -= inc;
- inc = -inc;
- break;
- }
- }
- }
- };
- var createBytes = function(buffer, rsBlocks) {
- var offset = 0;
- var maxDcCount = 0;
- var maxEcCount = 0;
- var dcdata = new Array(rsBlocks.length);
- var ecdata = new Array(rsBlocks.length);
- for (var r = 0; r < rsBlocks.length; r += 1) {
- var dcCount = rsBlocks[r].dataCount;
- var ecCount = rsBlocks[r].totalCount - dcCount;
- maxDcCount = Math.max(maxDcCount, dcCount);
- maxEcCount = Math.max(maxEcCount, ecCount);
- dcdata[r] = new Array(dcCount);
- for (var i2 = 0; i2 < dcdata[r].length; i2 += 1) {
- dcdata[r][i2] = 255 & buffer.getBuffer()[i2 + offset];
- }
- offset += dcCount;
- var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
- var rawPoly = qrPolynomial(dcdata[r], rsPoly.getLength() - 1);
- var modPoly = rawPoly.mod(rsPoly);
- ecdata[r] = new Array(rsPoly.getLength() - 1);
- for (var i2 = 0; i2 < ecdata[r].length; i2 += 1) {
- var modIndex = i2 + modPoly.getLength() - ecdata[r].length;
- ecdata[r][i2] = modIndex >= 0 ? modPoly.getAt(modIndex) : 0;
- }
- }
- var totalCodeCount = 0;
- for (var i2 = 0; i2 < rsBlocks.length; i2 += 1) {
- totalCodeCount += rsBlocks[i2].totalCount;
- }
- var data = new Array(totalCodeCount);
- var index = 0;
- for (var i2 = 0; i2 < maxDcCount; i2 += 1) {
- for (var r = 0; r < rsBlocks.length; r += 1) {
- if (i2 < dcdata[r].length) {
- data[index] = dcdata[r][i2];
- index += 1;
- }
- }
- }
- for (var i2 = 0; i2 < maxEcCount; i2 += 1) {
- for (var r = 0; r < rsBlocks.length; r += 1) {
- if (i2 < ecdata[r].length) {
- data[index] = ecdata[r][i2];
- index += 1;
- }
- }
- }
- return data;
- };
- var createData = function(typeNumber2, errorCorrectionLevel2, dataList) {
- var rsBlocks = QRRSBlock.getRSBlocks(typeNumber2, errorCorrectionLevel2);
- var buffer = qrBitBuffer();
- for (var i2 = 0; i2 < dataList.length; i2 += 1) {
- var data = dataList[i2];
- buffer.put(data.getMode(), 4);
- buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber2));
- data.write(buffer);
- }
- var totalDataCount = 0;
- for (var i2 = 0; i2 < rsBlocks.length; i2 += 1) {
- totalDataCount += rsBlocks[i2].dataCount;
- }
- if (buffer.getLengthInBits() > totalDataCount * 8) {
- throw "code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")";
- }
- if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
- buffer.put(0, 4);
- }
- while (buffer.getLengthInBits() % 8 != 0) {
- buffer.putBit(false);
- }
- while (true) {
- if (buffer.getLengthInBits() >= totalDataCount * 8) {
- break;
- }
- buffer.put(PAD0, 8);
- if (buffer.getLengthInBits() >= totalDataCount * 8) {
- break;
- }
- buffer.put(PAD1, 8);
- }
- return createBytes(buffer, rsBlocks);
- };
- _this.addData = function(data, mode) {
- mode = mode || "Byte";
- var newData = null;
- switch (mode) {
- case "Numeric":
- newData = qrNumber(data);
- break;
- case "Alphanumeric":
- newData = qrAlphaNum(data);
- break;
- case "Byte":
- newData = qr8BitByte(data);
- break;
- case "Kanji":
- newData = qrKanji(data);
- break;
- default:
- throw "mode:" + mode;
- }
- _dataList.push(newData);
- _dataCache = null;
- };
- _this.isDark = function(row, col) {
- if (row < 0 || _moduleCount <= row || col < 0 || _moduleCount <= col) {
- throw row + "," + col;
- }
- return _modules[row][col];
- };
- _this.getModuleCount = function() {
- return _moduleCount;
- };
- _this.make = function() {
- if (_typeNumber < 1) {
- var typeNumber2 = 1;
- for (; typeNumber2 < 40; typeNumber2++) {
- var rsBlocks = QRRSBlock.getRSBlocks(typeNumber2, _errorCorrectionLevel);
- var buffer = qrBitBuffer();
- for (var i2 = 0; i2 < _dataList.length; i2++) {
- var data = _dataList[i2];
- buffer.put(data.getMode(), 4);
- buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber2));
- data.write(buffer);
- }
- var totalDataCount = 0;
- for (var i2 = 0; i2 < rsBlocks.length; i2++) {
- totalDataCount += rsBlocks[i2].dataCount;
- }
- if (buffer.getLengthInBits() <= totalDataCount * 8) {
- break;
- }
- }
- _typeNumber = typeNumber2;
- }
- makeImpl(false, getBestMaskPattern());
- };
- _this.createTableTag = function(cellSize, margin) {
- cellSize = cellSize || 2;
- margin = typeof margin == "undefined" ? cellSize * 4 : margin;
- var qrHtml = "";
- qrHtml += '<table style="';
- qrHtml += " border-width: 0px; border-style: none;";
- qrHtml += " border-collapse: collapse;";
- qrHtml += " padding: 0px; margin: " + margin + "px;";
- qrHtml += '">';
- qrHtml += "<tbody>";
- for (var r = 0; r < _this.getModuleCount(); r += 1) {
- qrHtml += "<tr>";
- for (var c = 0; c < _this.getModuleCount(); c += 1) {
- qrHtml += '<td style="';
- qrHtml += " border-width: 0px; border-style: none;";
- qrHtml += " border-collapse: collapse;";
- qrHtml += " padding: 0px; margin: 0px;";
- qrHtml += " width: " + cellSize + "px;";
- qrHtml += " height: " + cellSize + "px;";
- qrHtml += " background-color: ";
- qrHtml += _this.isDark(r, c) ? "#000000" : "#ffffff";
- qrHtml += ";";
- qrHtml += '"/>';
- }
- qrHtml += "</tr>";
- }
- qrHtml += "</tbody>";
- qrHtml += "</table>";
- return qrHtml;
- };
- _this.createSvgTag = function(cellSize, margin, alt, title) {
- var opts = {};
- if (typeof arguments[0] == "object") {
- opts = arguments[0];
- cellSize = opts.cellSize;
- margin = opts.margin;
- alt = opts.alt;
- title = opts.title;
- }
- cellSize = cellSize || 2;
- margin = typeof margin == "undefined" ? cellSize * 4 : margin;
- alt = typeof alt === "string" ? { text: alt } : alt || {};
- alt.text = alt.text || null;
- alt.id = alt.text ? alt.id || "qrcode-description" : null;
- title = typeof title === "string" ? { text: title } : title || {};
- title.text = title.text || null;
- title.id = title.text ? title.id || "qrcode-title" : null;
- var size = _this.getModuleCount() * cellSize + margin * 2;
- var c, mc, r, mr, qrSvg = "", rect;
- rect = "l" + cellSize + ",0 0," + cellSize + " -" + cellSize + ",0 0,-" + cellSize + "z ";
- qrSvg += '<svg version="1.1" xmlns="http://www.w3.org/2000/svg"';
- qrSvg += !opts.scalable ? ' width="' + size + 'px" height="' + size + 'px"' : "";
- qrSvg += ' viewBox="0 0 ' + size + " " + size + '" ';
- qrSvg += ' preserveAspectRatio="xMinYMin meet"';
- qrSvg += title.text || alt.text ? ' role="img" aria-labelledby="' + escapeXml([title.id, alt.id].join(" ").trim()) + '"' : "";
- qrSvg += ">";
- qrSvg += title.text ? '<title id="' + escapeXml(title.id) + '">' + escapeXml(title.text) + "</title>" : "";
- qrSvg += alt.text ? '<description id="' + escapeXml(alt.id) + '">' + escapeXml(alt.text) + "</description>" : "";
- qrSvg += '<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>';
- qrSvg += '<path d="';
- for (r = 0; r < _this.getModuleCount(); r += 1) {
- mr = r * cellSize + margin;
- for (c = 0; c < _this.getModuleCount(); c += 1) {
- if (_this.isDark(r, c)) {
- mc = c * cellSize + margin;
- qrSvg += "M" + mc + "," + mr + rect;
- }
- }
- }
- qrSvg += '" stroke="transparent" fill="black"/>';
- qrSvg += "</svg>";
- return qrSvg;
- };
- _this.createDataURL = function(cellSize, margin) {
- cellSize = cellSize || 2;
- margin = typeof margin == "undefined" ? cellSize * 4 : margin;
- var size = _this.getModuleCount() * cellSize + margin * 2;
- var min = margin;
- var max = size - margin;
- return createDataURL(size, size, function(x, y) {
- if (min <= x && x < max && min <= y && y < max) {
- var c = Math.floor((x - min) / cellSize);
- var r = Math.floor((y - min) / cellSize);
- return _this.isDark(r, c) ? 0 : 1;
- } else {
- return 1;
- }
- });
- };
- _this.createImgTag = function(cellSize, margin, alt) {
- cellSize = cellSize || 2;
- margin = typeof margin == "undefined" ? cellSize * 4 : margin;
- var size = _this.getModuleCount() * cellSize + margin * 2;
- var img = "";
- img += "<img";
- img += ' src="';
- img += _this.createDataURL(cellSize, margin);
- img += '"';
- img += ' width="';
- img += size;
- img += '"';
- img += ' height="';
- img += size;
- img += '"';
- if (alt) {
- img += ' alt="';
- img += escapeXml(alt);
- img += '"';
- }
- img += "/>";
- return img;
- };
- var escapeXml = function(s) {
- var escaped = "";
- for (var i2 = 0; i2 < s.length; i2 += 1) {
- var c = s.charAt(i2);
- switch (c) {
- case "<":
- escaped += "<";
- break;
- case ">":
- escaped += ">";
- break;
- case "&":
- escaped += "&";
- break;
- case '"':
- escaped += """;
- break;
- default:
- escaped += c;
- break;
- }
- }
- return escaped;
- };
- var _createHalfASCII = function(margin) {
- var cellSize = 1;
- margin = typeof margin == "undefined" ? cellSize * 2 : margin;
- var size = _this.getModuleCount() * cellSize + margin * 2;
- var min = margin;
- var max = size - margin;
- var y, x, r1, r2, p;
- var blocks = {
- "██": "█",
- "█ ": "▀",
- " █": "▄",
- " ": " "
- };
- var blocksLastLineNoMargin = {
- "██": "▀",
- "█ ": "▀",
- " █": " ",
- " ": " "
- };
- var ascii = "";
- for (y = 0; y < size; y += 2) {
- r1 = Math.floor((y - min) / cellSize);
- r2 = Math.floor((y + 1 - min) / cellSize);
- for (x = 0; x < size; x += 1) {
- p = "█";
- if (min <= x && x < max && min <= y && y < max && _this.isDark(r1, Math.floor((x - min) / cellSize))) {
- p = " ";
- }
- if (min <= x && x < max && min <= y + 1 && y + 1 < max && _this.isDark(r2, Math.floor((x - min) / cellSize))) {
- p += " ";
- } else {
- p += "█";
- }
- ascii += margin < 1 && y + 1 >= max ? blocksLastLineNoMargin[p] : blocks[p];
- }
- ascii += "\n";
- }
- if (size % 2 && margin > 0) {
- return ascii.substring(0, ascii.length - size - 1) + Array(size + 1).join("▀");
- }
- return ascii.substring(0, ascii.length - 1);
- };
- _this.createASCII = function(cellSize, margin) {
- cellSize = cellSize || 1;
- if (cellSize < 2) {
- return _createHalfASCII(margin);
- }
- cellSize -= 1;
- margin = typeof margin == "undefined" ? cellSize * 2 : margin;
- var size = _this.getModuleCount() * cellSize + margin * 2;
- var min = margin;
- var max = size - margin;
- var y, x, r, p;
- var white = Array(cellSize + 1).join("██");
- var black = Array(cellSize + 1).join(" ");
- var ascii = "";
- var line = "";
- for (y = 0; y < size; y += 1) {
- r = Math.floor((y - min) / cellSize);
- line = "";
- for (x = 0; x < size; x += 1) {
- p = 1;
- if (min <= x && x < max && min <= y && y < max && _this.isDark(r, Math.floor((x - min) / cellSize))) {
- p = 0;
- }
- line += p ? white : black;
- }
- for (r = 0; r < cellSize; r += 1) {
- ascii += line + "\n";
- }
- }
- return ascii.substring(0, ascii.length - 1);
- };
- _this.renderTo2dContext = function(context, cellSize) {
- cellSize = cellSize || 2;
- var length = _this.getModuleCount();
- for (var row = 0; row < length; row++) {
- for (var col = 0; col < length; col++) {
- context.fillStyle = _this.isDark(row, col) ? "black" : "white";
- context.fillRect(row * cellSize, col * cellSize, cellSize, cellSize);
- }
- }
- };
- return _this;
- };
- qrcode3.stringToBytesFuncs = {
- "default": function(s) {
- var bytes = [];
- for (var i2 = 0; i2 < s.length; i2 += 1) {
- var c = s.charCodeAt(i2);
- bytes.push(c & 255);
- }
- return bytes;
- }
- };
- qrcode3.stringToBytes = qrcode3.stringToBytesFuncs["default"];
- qrcode3.createStringToBytes = function(unicodeData, numChars) {
- var unicodeMap = function() {
- var bin = base64DecodeInputStream(unicodeData);
- var read = function() {
- var b = bin.read();
- if (b == -1)
- throw "eof";
- return b;
- };
- var count = 0;
- var unicodeMap2 = {};
- while (true) {
- var b0 = bin.read();
- if (b0 == -1)
- break;
- var b1 = read();
- var b2 = read();
- var b3 = read();
- var k = String.fromCharCode(b0 << 8 | b1);
- var v = b2 << 8 | b3;
- unicodeMap2[k] = v;
- count += 1;
- }
- if (count != numChars) {
- throw count + " != " + numChars;
- }
- return unicodeMap2;
- }();
- var unknownChar = "?".charCodeAt(0);
- return function(s) {
- var bytes = [];
- for (var i2 = 0; i2 < s.length; i2 += 1) {
- var c = s.charCodeAt(i2);
- if (c < 128) {
- bytes.push(c);
- } else {
- var b = unicodeMap[s.charAt(i2)];
- if (typeof b == "number") {
- if ((b & 255) == b) {
- bytes.push(b);
- } else {
- bytes.push(b >>> 8);
- bytes.push(b & 255);
- }
- } else {
- bytes.push(unknownChar);
- }
- }
- }
- return bytes;
- };
- };
- var QRMode = {
- MODE_NUMBER: 1 << 0,
- MODE_ALPHA_NUM: 1 << 1,
- MODE_8BIT_BYTE: 1 << 2,
- MODE_KANJI: 1 << 3
- };
- var QRErrorCorrectionLevel = {
- L: 1,
- M: 0,
- Q: 3,
- H: 2
- };
- var QRMaskPattern = {
- PATTERN000: 0,
- PATTERN001: 1,
- PATTERN010: 2,
- PATTERN011: 3,
- PATTERN100: 4,
- PATTERN101: 5,
- PATTERN110: 6,
- PATTERN111: 7
- };
- var QRUtil = function() {
- var PATTERN_POSITION_TABLE = [
- [],
- [6, 18],
- [6, 22],
- [6, 26],
- [6, 30],
- [6, 34],
- [6, 22, 38],
- [6, 24, 42],
- [6, 26, 46],
- [6, 28, 50],
- [6, 30, 54],
- [6, 32, 58],
- [6, 34, 62],
- [6, 26, 46, 66],
- [6, 26, 48, 70],
- [6, 26, 50, 74],
- [6, 30, 54, 78],
- [6, 30, 56, 82],
- [6, 30, 58, 86],
- [6, 34, 62, 90],
- [6, 28, 50, 72, 94],
- [6, 26, 50, 74, 98],
- [6, 30, 54, 78, 102],
- [6, 28, 54, 80, 106],
- [6, 32, 58, 84, 110],
- [6, 30, 58, 86, 114],
- [6, 34, 62, 90, 118],
- [6, 26, 50, 74, 98, 122],
- [6, 30, 54, 78, 102, 126],
- [6, 26, 52, 78, 104, 130],
- [6, 30, 56, 82, 108, 134],
- [6, 34, 60, 86, 112, 138],
- [6, 30, 58, 86, 114, 142],
- [6, 34, 62, 90, 118, 146],
- [6, 30, 54, 78, 102, 126, 150],
- [6, 24, 50, 76, 102, 128, 154],
- [6, 28, 54, 80, 106, 132, 158],
- [6, 32, 58, 84, 110, 136, 162],
- [6, 26, 54, 82, 110, 138, 166],
- [6, 30, 58, 86, 114, 142, 170]
- ];
- var G15 = 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0;
- var G18 = 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0;
- var G15_MASK = 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1;
- var _this = {};
- var getBCHDigit = function(data) {
- var digit = 0;
- while (data != 0) {
- digit += 1;
- data >>>= 1;
- }
- return digit;
- };
- _this.getBCHTypeInfo = function(data) {
- var d = data << 10;
- while (getBCHDigit(d) - getBCHDigit(G15) >= 0) {
- d ^= G15 << getBCHDigit(d) - getBCHDigit(G15);
- }
- return (data << 10 | d) ^ G15_MASK;
- };
- _this.getBCHTypeNumber = function(data) {
- var d = data << 12;
- while (getBCHDigit(d) - getBCHDigit(G18) >= 0) {
- d ^= G18 << getBCHDigit(d) - getBCHDigit(G18);
- }
- return data << 12 | d;
- };
- _this.getPatternPosition = function(typeNumber) {
- return PATTERN_POSITION_TABLE[typeNumber - 1];
- };
- _this.getMaskFunction = function(maskPattern) {
- switch (maskPattern) {
- case QRMaskPattern.PATTERN000:
- return function(i2, j) {
- return (i2 + j) % 2 == 0;
- };
- case QRMaskPattern.PATTERN001:
- return function(i2, j) {
- return i2 % 2 == 0;
- };
- case QRMaskPattern.PATTERN010:
- return function(i2, j) {
- return j % 3 == 0;
- };
- case QRMaskPattern.PATTERN011:
- return function(i2, j) {
- return (i2 + j) % 3 == 0;
- };
- case QRMaskPattern.PATTERN100:
- return function(i2, j) {
- return (Math.floor(i2 / 2) + Math.floor(j / 3)) % 2 == 0;
- };
- case QRMaskPattern.PATTERN101:
- return function(i2, j) {
- return i2 * j % 2 + i2 * j % 3 == 0;
- };
- case QRMaskPattern.PATTERN110:
- return function(i2, j) {
- return (i2 * j % 2 + i2 * j % 3) % 2 == 0;
- };
- case QRMaskPattern.PATTERN111:
- return function(i2, j) {
- return (i2 * j % 3 + (i2 + j) % 2) % 2 == 0;
- };
- default:
- throw "bad maskPattern:" + maskPattern;
- }
- };
- _this.getErrorCorrectPolynomial = function(errorCorrectLength) {
- var a = qrPolynomial([1], 0);
- for (var i2 = 0; i2 < errorCorrectLength; i2 += 1) {
- a = a.multiply(qrPolynomial([1, QRMath.gexp(i2)], 0));
- }
- return a;
- };
- _this.getLengthInBits = function(mode, type) {
- if (1 <= type && type < 10) {
- switch (mode) {
- case QRMode.MODE_NUMBER:
- return 10;
- case QRMode.MODE_ALPHA_NUM:
- return 9;
- case QRMode.MODE_8BIT_BYTE:
- return 8;
- case QRMode.MODE_KANJI:
- return 8;
- default:
- throw "mode:" + mode;
- }
- } else if (type < 27) {
- switch (mode) {
- case QRMode.MODE_NUMBER:
- return 12;
- case QRMode.MODE_ALPHA_NUM:
- return 11;
- case QRMode.MODE_8BIT_BYTE:
- return 16;
- case QRMode.MODE_KANJI:
- return 10;
- default:
- throw "mode:" + mode;
- }
- } else if (type < 41) {
- switch (mode) {
- case QRMode.MODE_NUMBER:
- return 14;
- case QRMode.MODE_ALPHA_NUM:
- return 13;
- case QRMode.MODE_8BIT_BYTE:
- return 16;
- case QRMode.MODE_KANJI:
- return 12;
- default:
- throw "mode:" + mode;
- }
- } else {
- throw "type:" + type;
- }
- };
- _this.getLostPoint = function(qrcode4) {
- var moduleCount = qrcode4.getModuleCount();
- var lostPoint = 0;
- for (var row = 0; row < moduleCount; row += 1) {
- for (var col = 0; col < moduleCount; col += 1) {
- var sameCount = 0;
- var dark = qrcode4.isDark(row, col);
- for (var r = -1; r <= 1; r += 1) {
- if (row + r < 0 || moduleCount <= row + r) {
- continue;
- }
- for (var c = -1; c <= 1; c += 1) {
- if (col + c < 0 || moduleCount <= col + c) {
- continue;
- }
- if (r == 0 && c == 0) {
- continue;
- }
- if (dark == qrcode4.isDark(row + r, col + c)) {
- sameCount += 1;
- }
- }
- }
- if (sameCount > 5) {
- lostPoint += 3 + sameCount - 5;
- }
- }
- }
- for (var row = 0; row < moduleCount - 1; row += 1) {
- for (var col = 0; col < moduleCount - 1; col += 1) {
- var count = 0;
- if (qrcode4.isDark(row, col))
- count += 1;
- if (qrcode4.isDark(row + 1, col))
- count += 1;
- if (qrcode4.isDark(row, col + 1))
- count += 1;
- if (qrcode4.isDark(row + 1, col + 1))
- count += 1;
- if (count == 0 || count == 4) {
- lostPoint += 3;
- }
- }
- }
- for (var row = 0; row < moduleCount; row += 1) {
- for (var col = 0; col < moduleCount - 6; col += 1) {
- 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)) {
- lostPoint += 40;
- }
- }
- }
- for (var col = 0; col < moduleCount; col += 1) {
- for (var row = 0; row < moduleCount - 6; row += 1) {
- 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)) {
- lostPoint += 40;
- }
- }
- }
- var darkCount = 0;
- for (var col = 0; col < moduleCount; col += 1) {
- for (var row = 0; row < moduleCount; row += 1) {
- if (qrcode4.isDark(row, col)) {
- darkCount += 1;
- }
- }
- }
- var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
- lostPoint += ratio * 10;
- return lostPoint;
- };
- return _this;
- }();
- var QRMath = function() {
- var EXP_TABLE = new Array(256);
- var LOG_TABLE = new Array(256);
- for (var i2 = 0; i2 < 8; i2 += 1) {
- EXP_TABLE[i2] = 1 << i2;
- }
- for (var i2 = 8; i2 < 256; i2 += 1) {
- EXP_TABLE[i2] = EXP_TABLE[i2 - 4] ^ EXP_TABLE[i2 - 5] ^ EXP_TABLE[i2 - 6] ^ EXP_TABLE[i2 - 8];
- }
- for (var i2 = 0; i2 < 255; i2 += 1) {
- LOG_TABLE[EXP_TABLE[i2]] = i2;
- }
- var _this = {};
- _this.glog = function(n) {
- if (n < 1) {
- throw "glog(" + n + ")";
- }
- return LOG_TABLE[n];
- };
- _this.gexp = function(n) {
- while (n < 0) {
- n += 255;
- }
- while (n >= 256) {
- n -= 255;
- }
- return EXP_TABLE[n];
- };
- return _this;
- }();
- function qrPolynomial(num, shift) {
- if (typeof num.length == "undefined") {
- throw num.length + "/" + shift;
- }
- var _num = function() {
- var offset = 0;
- while (offset < num.length && num[offset] == 0) {
- offset += 1;
- }
- var _num2 = new Array(num.length - offset + shift);
- for (var i2 = 0; i2 < num.length - offset; i2 += 1) {
- _num2[i2] = num[i2 + offset];
- }
- return _num2;
- }();
- var _this = {};
- _this.getAt = function(index) {
- return _num[index];
- };
- _this.getLength = function() {
- return _num.length;
- };
- _this.multiply = function(e) {
- var num2 = new Array(_this.getLength() + e.getLength() - 1);
- for (var i2 = 0; i2 < _this.getLength(); i2 += 1) {
- for (var j = 0; j < e.getLength(); j += 1) {
- num2[i2 + j] ^= QRMath.gexp(QRMath.glog(_this.getAt(i2)) + QRMath.glog(e.getAt(j)));
- }
- }
- return qrPolynomial(num2, 0);
- };
- _this.mod = function(e) {
- if (_this.getLength() - e.getLength() < 0) {
- return _this;
- }
- var ratio = QRMath.glog(_this.getAt(0)) - QRMath.glog(e.getAt(0));
- var num2 = new Array(_this.getLength());
- for (var i2 = 0; i2 < _this.getLength(); i2 += 1) {
- num2[i2] = _this.getAt(i2);
- }
- for (var i2 = 0; i2 < e.getLength(); i2 += 1) {
- num2[i2] ^= QRMath.gexp(QRMath.glog(e.getAt(i2)) + ratio);
- }
- return qrPolynomial(num2, 0).mod(e);
- };
- return _this;
- }
- var QRRSBlock = function() {
- var RS_BLOCK_TABLE = [
- // L
- // M
- // Q
- // H
- // 1
- [1, 26, 19],
- [1, 26, 16],
- [1, 26, 13],
- [1, 26, 9],
- // 2
- [1, 44, 34],
- [1, 44, 28],
- [1, 44, 22],
- [1, 44, 16],
- // 3
- [1, 70, 55],
- [1, 70, 44],
- [2, 35, 17],
- [2, 35, 13],
- // 4
- [1, 100, 80],
- [2, 50, 32],
- [2, 50, 24],
- [4, 25, 9],
- // 5
- [1, 134, 108],
- [2, 67, 43],
- [2, 33, 15, 2, 34, 16],
- [2, 33, 11, 2, 34, 12],
- // 6
- [2, 86, 68],
- [4, 43, 27],
- [4, 43, 19],
- [4, 43, 15],
- // 7
- [2, 98, 78],
- [4, 49, 31],
- [2, 32, 14, 4, 33, 15],
- [4, 39, 13, 1, 40, 14],
- // 8
- [2, 121, 97],
- [2, 60, 38, 2, 61, 39],
- [4, 40, 18, 2, 41, 19],
- [4, 40, 14, 2, 41, 15],
- // 9
- [2, 146, 116],
- [3, 58, 36, 2, 59, 37],
- [4, 36, 16, 4, 37, 17],
- [4, 36, 12, 4, 37, 13],
- // 10
- [2, 86, 68, 2, 87, 69],
- [4, 69, 43, 1, 70, 44],
- [6, 43, 19, 2, 44, 20],
- [6, 43, 15, 2, 44, 16],
- // 11
- [4, 101, 81],
- [1, 80, 50, 4, 81, 51],
- [4, 50, 22, 4, 51, 23],
- [3, 36, 12, 8, 37, 13],
- // 12
- [2, 116, 92, 2, 117, 93],
- [6, 58, 36, 2, 59, 37],
- [4, 46, 20, 6, 47, 21],
- [7, 42, 14, 4, 43, 15],
- // 13
- [4, 133, 107],
- [8, 59, 37, 1, 60, 38],
- [8, 44, 20, 4, 45, 21],
- [12, 33, 11, 4, 34, 12],
- // 14
- [3, 145, 115, 1, 146, 116],
- [4, 64, 40, 5, 65, 41],
- [11, 36, 16, 5, 37, 17],
- [11, 36, 12, 5, 37, 13],
- // 15
- [5, 109, 87, 1, 110, 88],
- [5, 65, 41, 5, 66, 42],
- [5, 54, 24, 7, 55, 25],
- [11, 36, 12, 7, 37, 13],
- // 16
- [5, 122, 98, 1, 123, 99],
- [7, 73, 45, 3, 74, 46],
- [15, 43, 19, 2, 44, 20],
- [3, 45, 15, 13, 46, 16],
- // 17
- [1, 135, 107, 5, 136, 108],
- [10, 74, 46, 1, 75, 47],
- [1, 50, 22, 15, 51, 23],
- [2, 42, 14, 17, 43, 15],
- // 18
- [5, 150, 120, 1, 151, 121],
- [9, 69, 43, 4, 70, 44],
- [17, 50, 22, 1, 51, 23],
- [2, 42, 14, 19, 43, 15],
- // 19
- [3, 141, 113, 4, 142, 114],
- [3, 70, 44, 11, 71, 45],
- [17, 47, 21, 4, 48, 22],
- [9, 39, 13, 16, 40, 14],
- // 20
- [3, 135, 107, 5, 136, 108],
- [3, 67, 41, 13, 68, 42],
- [15, 54, 24, 5, 55, 25],
- [15, 43, 15, 10, 44, 16],
- // 21
- [4, 144, 116, 4, 145, 117],
- [17, 68, 42],
- [17, 50, 22, 6, 51, 23],
- [19, 46, 16, 6, 47, 17],
- // 22
- [2, 139, 111, 7, 140, 112],
- [17, 74, 46],
- [7, 54, 24, 16, 55, 25],
- [34, 37, 13],
- // 23
- [4, 151, 121, 5, 152, 122],
- [4, 75, 47, 14, 76, 48],
- [11, 54, 24, 14, 55, 25],
- [16, 45, 15, 14, 46, 16],
- // 24
- [6, 147, 117, 4, 148, 118],
- [6, 73, 45, 14, 74, 46],
- [11, 54, 24, 16, 55, 25],
- [30, 46, 16, 2, 47, 17],
- // 25
- [8, 132, 106, 4, 133, 107],
- [8, 75, 47, 13, 76, 48],
- [7, 54, 24, 22, 55, 25],
- [22, 45, 15, 13, 46, 16],
- // 26
- [10, 142, 114, 2, 143, 115],
- [19, 74, 46, 4, 75, 47],
- [28, 50, 22, 6, 51, 23],
- [33, 46, 16, 4, 47, 17],
- // 27
- [8, 152, 122, 4, 153, 123],
- [22, 73, 45, 3, 74, 46],
- [8, 53, 23, 26, 54, 24],
- [12, 45, 15, 28, 46, 16],
- // 28
- [3, 147, 117, 10, 148, 118],
- [3, 73, 45, 23, 74, 46],
- [4, 54, 24, 31, 55, 25],
- [11, 45, 15, 31, 46, 16],
- // 29
- [7, 146, 116, 7, 147, 117],
- [21, 73, 45, 7, 74, 46],
- [1, 53, 23, 37, 54, 24],
- [19, 45, 15, 26, 46, 16],
- // 30
- [5, 145, 115, 10, 146, 116],
- [19, 75, 47, 10, 76, 48],
- [15, 54, 24, 25, 55, 25],
- [23, 45, 15, 25, 46, 16],
- // 31
- [13, 145, 115, 3, 146, 116],
- [2, 74, 46, 29, 75, 47],
- [42, 54, 24, 1, 55, 25],
- [23, 45, 15, 28, 46, 16],
- // 32
- [17, 145, 115],
- [10, 74, 46, 23, 75, 47],
- [10, 54, 24, 35, 55, 25],
- [19, 45, 15, 35, 46, 16],
- // 33
- [17, 145, 115, 1, 146, 116],
- [14, 74, 46, 21, 75, 47],
- [29, 54, 24, 19, 55, 25],
- [11, 45, 15, 46, 46, 16],
- // 34
- [13, 145, 115, 6, 146, 116],
- [14, 74, 46, 23, 75, 47],
- [44, 54, 24, 7, 55, 25],
- [59, 46, 16, 1, 47, 17],
- // 35
- [12, 151, 121, 7, 152, 122],
- [12, 75, 47, 26, 76, 48],
- [39, 54, 24, 14, 55, 25],
- [22, 45, 15, 41, 46, 16],
- // 36
- [6, 151, 121, 14, 152, 122],
- [6, 75, 47, 34, 76, 48],
- [46, 54, 24, 10, 55, 25],
- [2, 45, 15, 64, 46, 16],
- // 37
- [17, 152, 122, 4, 153, 123],
- [29, 74, 46, 14, 75, 47],
- [49, 54, 24, 10, 55, 25],
- [24, 45, 15, 46, 46, 16],
- // 38
- [4, 152, 122, 18, 153, 123],
- [13, 74, 46, 32, 75, 47],
- [48, 54, 24, 14, 55, 25],
- [42, 45, 15, 32, 46, 16],
- // 39
- [20, 147, 117, 4, 148, 118],
- [40, 75, 47, 7, 76, 48],
- [43, 54, 24, 22, 55, 25],
- [10, 45, 15, 67, 46, 16],
- // 40
- [19, 148, 118, 6, 149, 119],
- [18, 75, 47, 31, 76, 48],
- [34, 54, 24, 34, 55, 25],
- [20, 45, 15, 61, 46, 16]
- ];
- var qrRSBlock = function(totalCount, dataCount) {
- var _this2 = {};
- _this2.totalCount = totalCount;
- _this2.dataCount = dataCount;
- return _this2;
- };
- var _this = {};
- var getRsBlockTable = function(typeNumber, errorCorrectionLevel) {
- switch (errorCorrectionLevel) {
- case QRErrorCorrectionLevel.L:
- return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
- case QRErrorCorrectionLevel.M:
- return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
- case QRErrorCorrectionLevel.Q:
- return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
- case QRErrorCorrectionLevel.H:
- return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
- default:
- return void 0;
- }
- };
- _this.getRSBlocks = function(typeNumber, errorCorrectionLevel) {
- var rsBlock = getRsBlockTable(typeNumber, errorCorrectionLevel);
- if (typeof rsBlock == "undefined") {
- throw "bad rs block @ typeNumber:" + typeNumber + "/errorCorrectionLevel:" + errorCorrectionLevel;
- }
- var length = rsBlock.length / 3;
- var list = [];
- for (var i2 = 0; i2 < length; i2 += 1) {
- var count = rsBlock[i2 * 3 + 0];
- var totalCount = rsBlock[i2 * 3 + 1];
- var dataCount = rsBlock[i2 * 3 + 2];
- for (var j = 0; j < count; j += 1) {
- list.push(qrRSBlock(totalCount, dataCount));
- }
- }
- return list;
- };
- return _this;
- }();
- var qrBitBuffer = function() {
- var _buffer = [];
- var _length = 0;
- var _this = {};
- _this.getBuffer = function() {
- return _buffer;
- };
- _this.getAt = function(index) {
- var bufIndex = Math.floor(index / 8);
- return (_buffer[bufIndex] >>> 7 - index % 8 & 1) == 1;
- };
- _this.put = function(num, length) {
- for (var i2 = 0; i2 < length; i2 += 1) {
- _this.putBit((num >>> length - i2 - 1 & 1) == 1);
- }
- };
- _this.getLengthInBits = function() {
- return _length;
- };
- _this.putBit = function(bit) {
- var bufIndex = Math.floor(_length / 8);
- if (_buffer.length <= bufIndex) {
- _buffer.push(0);
- }
- if (bit) {
- _buffer[bufIndex] |= 128 >>> _length % 8;
- }
- _length += 1;
- };
- return _this;
- };
- var qrNumber = function(data) {
- var _mode = QRMode.MODE_NUMBER;
- var _data = data;
- var _this = {};
- _this.getMode = function() {
- return _mode;
- };
- _this.getLength = function(buffer) {
- return _data.length;
- };
- _this.write = function(buffer) {
- var data2 = _data;
- var i2 = 0;
- while (i2 + 2 < data2.length) {
- buffer.put(strToNum(data2.substring(i2, i2 + 3)), 10);
- i2 += 3;
- }
- if (i2 < data2.length) {
- if (data2.length - i2 == 1) {
- buffer.put(strToNum(data2.substring(i2, i2 + 1)), 4);
- } else if (data2.length - i2 == 2) {
- buffer.put(strToNum(data2.substring(i2, i2 + 2)), 7);
- }
- }
- };
- var strToNum = function(s) {
- var num = 0;
- for (var i2 = 0; i2 < s.length; i2 += 1) {
- num = num * 10 + chatToNum(s.charAt(i2));
- }
- return num;
- };
- var chatToNum = function(c) {
- if ("0" <= c && c <= "9") {
- return c.charCodeAt(0) - "0".charCodeAt(0);
- }
- throw "illegal char :" + c;
- };
- return _this;
- };
- var qrAlphaNum = function(data) {
- var _mode = QRMode.MODE_ALPHA_NUM;
- var _data = data;
- var _this = {};
- _this.getMode = function() {
- return _mode;
- };
- _this.getLength = function(buffer) {
- return _data.length;
- };
- _this.write = function(buffer) {
- var s = _data;
- var i2 = 0;
- while (i2 + 1 < s.length) {
- buffer.put(
- getCode(s.charAt(i2)) * 45 + getCode(s.charAt(i2 + 1)),
- 11
- );
- i2 += 2;
- }
- if (i2 < s.length) {
- buffer.put(getCode(s.charAt(i2)), 6);
- }
- };
- var getCode = function(c) {
- if ("0" <= c && c <= "9") {
- return c.charCodeAt(0) - "0".charCodeAt(0);
- } else if ("A" <= c && c <= "Z") {
- return c.charCodeAt(0) - "A".charCodeAt(0) + 10;
- } else {
- switch (c) {
- case " ":
- return 36;
- case "$":
- return 37;
- case "%":
- return 38;
- case "*":
- return 39;
- case "+":
- return 40;
- case "-":
- return 41;
- case ".":
- return 42;
- case "/":
- return 43;
- case ":":
- return 44;
- default:
- throw "illegal char :" + c;
- }
- }
- };
- return _this;
- };
- var qr8BitByte = function(data) {
- var _mode = QRMode.MODE_8BIT_BYTE;
- var _bytes = qrcode3.stringToBytes(data);
- var _this = {};
- _this.getMode = function() {
- return _mode;
- };
- _this.getLength = function(buffer) {
- return _bytes.length;
- };
- _this.write = function(buffer) {
- for (var i2 = 0; i2 < _bytes.length; i2 += 1) {
- buffer.put(_bytes[i2], 8);
- }
- };
- return _this;
- };
- var qrKanji = function(data) {
- var _mode = QRMode.MODE_KANJI;
- var stringToBytes = qrcode3.stringToBytesFuncs["SJIS"];
- if (!stringToBytes) {
- throw "sjis not supported.";
- }
- !function(c, code) {
- var test2 = stringToBytes(c);
- if (test2.length != 2 || (test2[0] << 8 | test2[1]) != code) {
- throw "sjis not supported.";
- }
- }("友", 38726);
- var _bytes = stringToBytes(data);
- var _this = {};
- _this.getMode = function() {
- return _mode;
- };
- _this.getLength = function(buffer) {
- return ~~(_bytes.length / 2);
- };
- _this.write = function(buffer) {
- var data2 = _bytes;
- var i2 = 0;
- while (i2 + 1 < data2.length) {
- var c = (255 & data2[i2]) << 8 | 255 & data2[i2 + 1];
- if (33088 <= c && c <= 40956) {
- c -= 33088;
- } else if (57408 <= c && c <= 60351) {
- c -= 49472;
- } else {
- throw "illegal char at " + (i2 + 1) + "/" + c;
- }
- c = (c >>> 8 & 255) * 192 + (c & 255);
- buffer.put(c, 13);
- i2 += 2;
- }
- if (i2 < data2.length) {
- throw "illegal char at " + (i2 + 1);
- }
- };
- return _this;
- };
- var byteArrayOutputStream = function() {
- var _bytes = [];
- var _this = {};
- _this.writeByte = function(b) {
- _bytes.push(b & 255);
- };
- _this.writeShort = function(i2) {
- _this.writeByte(i2);
- _this.writeByte(i2 >>> 8);
- };
- _this.writeBytes = function(b, off, len) {
- off = off || 0;
- len = len || b.length;
- for (var i2 = 0; i2 < len; i2 += 1) {
- _this.writeByte(b[i2 + off]);
- }
- };
- _this.writeString = function(s) {
- for (var i2 = 0; i2 < s.length; i2 += 1) {
- _this.writeByte(s.charCodeAt(i2));
- }
- };
- _this.toByteArray = function() {
- return _bytes;
- };
- _this.toString = function() {
- var s = "";
- s += "[";
- for (var i2 = 0; i2 < _bytes.length; i2 += 1) {
- if (i2 > 0) {
- s += ",";
- }
- s += _bytes[i2];
- }
- s += "]";
- return s;
- };
- return _this;
- };
- var base64EncodeOutputStream = function() {
- var _buffer = 0;
- var _buflen = 0;
- var _length = 0;
- var _base64 = "";
- var _this = {};
- var writeEncoded = function(b) {
- _base64 += String.fromCharCode(encode(b & 63));
- };
- var encode = function(n) {
- if (n < 0)
- ;
- else if (n < 26) {
- return 65 + n;
- } else if (n < 52) {
- return 97 + (n - 26);
- } else if (n < 62) {
- return 48 + (n - 52);
- } else if (n == 62) {
- return 43;
- } else if (n == 63) {
- return 47;
- }
- throw "n:" + n;
- };
- _this.writeByte = function(n) {
- _buffer = _buffer << 8 | n & 255;
- _buflen += 8;
- _length += 1;
- while (_buflen >= 6) {
- writeEncoded(_buffer >>> _buflen - 6);
- _buflen -= 6;
- }
- };
- _this.flush = function() {
- if (_buflen > 0) {
- writeEncoded(_buffer << 6 - _buflen);
- _buffer = 0;
- _buflen = 0;
- }
- if (_length % 3 != 0) {
- var padlen = 3 - _length % 3;
- for (var i2 = 0; i2 < padlen; i2 += 1) {
- _base64 += "=";
- }
- }
- };
- _this.toString = function() {
- return _base64;
- };
- return _this;
- };
- var base64DecodeInputStream = function(str) {
- var _str = str;
- var _pos = 0;
- var _buffer = 0;
- var _buflen = 0;
- var _this = {};
- _this.read = function() {
- while (_buflen < 8) {
- if (_pos >= _str.length) {
- if (_buflen == 0) {
- return -1;
- }
- throw "unexpected end of file./" + _buflen;
- }
- var c = _str.charAt(_pos);
- _pos += 1;
- if (c == "=") {
- _buflen = 0;
- return -1;
- } else if (c.match(/^\s$/)) {
- continue;
- }
- _buffer = _buffer << 6 | decode(c.charCodeAt(0));
- _buflen += 6;
- }
- var n = _buffer >>> _buflen - 8 & 255;
- _buflen -= 8;
- return n;
- };
- var decode = function(c) {
- if (65 <= c && c <= 90) {
- return c - 65;
- } else if (97 <= c && c <= 122) {
- return c - 97 + 26;
- } else if (48 <= c && c <= 57) {
- return c - 48 + 52;
- } else if (c == 43) {
- return 62;
- } else if (c == 47) {
- return 63;
- } else {
- throw "c:" + c;
- }
- };
- return _this;
- };
- var gifImage = function(width, height) {
- var _width = width;
- var _height = height;
- var _data = new Array(width * height);
- var _this = {};
- _this.setPixel = function(x, y, pixel) {
- _data[y * _width + x] = pixel;
- };
- _this.write = function(out) {
- out.writeString("GIF87a");
- out.writeShort(_width);
- out.writeShort(_height);
- out.writeByte(128);
- out.writeByte(0);
- out.writeByte(0);
- out.writeByte(0);
- out.writeByte(0);
- out.writeByte(0);
- out.writeByte(255);
- out.writeByte(255);
- out.writeByte(255);
- out.writeString(",");
- out.writeShort(0);
- out.writeShort(0);
- out.writeShort(_width);
- out.writeShort(_height);
- out.writeByte(0);
- var lzwMinCodeSize = 2;
- var raster = getLZWRaster(lzwMinCodeSize);
- out.writeByte(lzwMinCodeSize);
- var offset = 0;
- while (raster.length - offset > 255) {
- out.writeByte(255);
- out.writeBytes(raster, offset, 255);
- offset += 255;
- }
- out.writeByte(raster.length - offset);
- out.writeBytes(raster, offset, raster.length - offset);
- out.writeByte(0);
- out.writeString(";");
- };
- var bitOutputStream = function(out) {
- var _out = out;
- var _bitLength = 0;
- var _bitBuffer = 0;
- var _this2 = {};
- _this2.write = function(data, length) {
- if (data >>> length != 0) {
- throw "length over";
- }
- while (_bitLength + length >= 8) {
- _out.writeByte(255 & (data << _bitLength | _bitBuffer));
- length -= 8 - _bitLength;
- data >>>= 8 - _bitLength;
- _bitBuffer = 0;
- _bitLength = 0;
- }
- _bitBuffer = data << _bitLength | _bitBuffer;
- _bitLength = _bitLength + length;
- };
- _this2.flush = function() {
- if (_bitLength > 0) {
- _out.writeByte(_bitBuffer);
- }
- };
- return _this2;
- };
- var getLZWRaster = function(lzwMinCodeSize) {
- var clearCode = 1 << lzwMinCodeSize;
- var endCode = (1 << lzwMinCodeSize) + 1;
- var bitLength = lzwMinCodeSize + 1;
- var table = lzwTable();
- for (var i2 = 0; i2 < clearCode; i2 += 1) {
- table.add(String.fromCharCode(i2));
- }
- table.add(String.fromCharCode(clearCode));
- table.add(String.fromCharCode(endCode));
- var byteOut = byteArrayOutputStream();
- var bitOut = bitOutputStream(byteOut);
- bitOut.write(clearCode, bitLength);
- var dataIndex = 0;
- var s = String.fromCharCode(_data[dataIndex]);
- dataIndex += 1;
- while (dataIndex < _data.length) {
- var c = String.fromCharCode(_data[dataIndex]);
- dataIndex += 1;
- if (table.contains(s + c)) {
- s = s + c;
- } else {
- bitOut.write(table.indexOf(s), bitLength);
- if (table.size() < 4095) {
- if (table.size() == 1 << bitLength) {
- bitLength += 1;
- }
- table.add(s + c);
- }
- s = c;
- }
- }
- bitOut.write(table.indexOf(s), bitLength);
- bitOut.write(endCode, bitLength);
- bitOut.flush();
- return byteOut.toByteArray();
- };
- var lzwTable = function() {
- var _map = {};
- var _size = 0;
- var _this2 = {};
- _this2.add = function(key) {
- if (_this2.contains(key)) {
- throw "dup key:" + key;
- }
- _map[key] = _size;
- _size += 1;
- };
- _this2.size = function() {
- return _size;
- };
- _this2.indexOf = function(key) {
- return _map[key];
- };
- _this2.contains = function(key) {
- return typeof _map[key] != "undefined";
- };
- return _this2;
- };
- return _this;
- };
- var createDataURL = function(width, height, getPixel) {
- var gif = gifImage(width, height);
- for (var y = 0; y < height; y += 1) {
- for (var x = 0; x < width; x += 1) {
- gif.setPixel(x, y, getPixel(x, y));
- }
- }
- var b = byteArrayOutputStream();
- gif.write(b);
- var base64 = base64EncodeOutputStream();
- var bytes = b.toByteArray();
- for (var i2 = 0; i2 < bytes.length; i2 += 1) {
- base64.writeByte(bytes[i2]);
- }
- base64.flush();
- return "data:image/gif;base64," + base64;
- };
- return qrcode3;
- }();
- !function() {
- qrcode2.stringToBytesFuncs["UTF-8"] = function(s) {
- function toUTF8Array(str) {
- var utf8 = [];
- for (var i2 = 0; i2 < str.length; i2++) {
- var charcode = str.charCodeAt(i2);
- if (charcode < 128)
- utf8.push(charcode);
- else if (charcode < 2048) {
- utf8.push(
- 192 | charcode >> 6,
- 128 | charcode & 63
- );
- } else if (charcode < 55296 || charcode >= 57344) {
- utf8.push(
- 224 | charcode >> 12,
- 128 | charcode >> 6 & 63,
- 128 | charcode & 63
- );
- } else {
- i2++;
- charcode = 65536 + ((charcode & 1023) << 10 | str.charCodeAt(i2) & 1023);
- utf8.push(
- 240 | charcode >> 18,
- 128 | charcode >> 12 & 63,
- 128 | charcode >> 6 & 63,
- 128 | charcode & 63
- );
- }
- }
- return utf8;
- }
- return toUTF8Array(s);
- };
- }();
- (function(factory) {
- {
- module.exports = factory();
- }
- })(function() {
- return qrcode2;
- });
- })(qrcode);
- var qrcodeExports = qrcode.exports;
- const QRCode = /* @__PURE__ */ getDefaultExportFromCjs(qrcodeExports);
- function McDbEntityToJsonObject(ent) {
- let obj = {};
- obj.ObjectName = ent.objectName;
- obj.id = ent.getObjectID().id;
- obj.handle = ent.getHandle();
- obj.layer = ent.layer;
- obj.color = ent.trueColor.getColorString();
- obj.colorVal = ent.trueColor.getColorValue(ent.layerId);
- obj.linetype = ent.linetype;
- obj.textStyle = ent.textStyle;
- obj.type = ent.objectName;
- obj.dxf0 = ent.dxf0;
- if (ent instanceof mxcad2.McDbText) {
- let txt = ent;
- obj.position = McGePoint3dToString(txt.position);
- obj.textString = txt.textString;
- } else if (ent instanceof mxcad2.McDbMText) {
- let mtxt = ent;
- obj.contents = mtxt.contents;
- obj.location = McGePoint3dToString(mtxt.location);
- } else if (ent instanceof mxcad2.McDbLine) {
- let line = ent;
- obj.startPoint = McGePoint3dToString(line.startPoint);
- obj.endPoint = McGePoint3dToString(line.endPoint);
- } else if (ent instanceof mxcad2.McDbCircle) {
- let circle = ent;
- obj.center = McGePoint3dToString(circle.center);
- obj.radius = circle.radius;
- } else if (ent instanceof mxcad2.McDbArc) {
- let arc = ent;
- obj.center = McGePoint3dToString(arc.center);
- obj.startAngle = arc.startAngle;
- obj.endAngle = arc.endAngle;
- } else if (ent instanceof mxcad2.McDbPolyline) {
- let polyline = ent;
- let num = polyline.numVerts();
- obj.num = num;
- for (let i2 = 0; i2 < num; i2++) {
- let pt = polyline.getPointAt(i2);
- let bulge = polyline.getBulgeAt(i2);
- obj["pt" + i2] = McGePoint3dToString(pt.val);
- obj["bulge" + i2] = bulge;
- }
- } else if (ent instanceof mxcad2.McDbBlockReference) {
- let blkRef = ent;
- obj.position = McGePoint3dToString(blkRef.position);
- obj.blockTransform = blkRef.blockTransform;
- obj.blockName = blkRef.blockName;
- } else if (ent instanceof mxcad2.McDbAlignedDimension) {
- let alignedDim = ent;
- obj.xLine1Point = McGePoint3dToString(alignedDim.xLine1Point);
- obj.xLine2Point = McGePoint3dToString(alignedDim.xLine2Point);
- let txts = alignedDim.GetAllText();
- txts.forEach((val, index) => {
- obj["txt:" + index] = val;
- });
- } else if (ent instanceof mxcad2.McDbRotatedDimension) {
- let rotatedDim = ent;
- obj.xLine1Point = McGePoint3dToString(rotatedDim.xLine1Point);
- obj.xLine2Point = McGePoint3dToString(rotatedDim.xLine2Point);
- let txts = rotatedDim.GetAllText();
- txts.forEach((val, index) => {
- obj["txt:" + index] = val;
- });
- } else if (ent instanceof mxcad2.McDbDimension) {
- let dim = ent;
- let txts = dim.GetAllText();
- txts.forEach((val, index) => {
- obj["txt:" + index] = val;
- });
- } else if (ent instanceof mxcad2.McDbHatch) {
- let hatch = ent;
- obj.patternType = hatch.patternType();
- obj.patternName = hatch.patternName();
- obj.patternAngle = hatch.patternAngle;
- obj.patternScale = hatch.patternScale;
- obj.patternSpace = hatch.patternSpace;
- obj.patternDouble = hatch.patternDouble;
- obj.hatchStyle = hatch.hatchStyle();
- obj.isSolid = hatch.isSolid();
- obj.numLoops = hatch.numLoops;
- for (let i2 = 0; i2 < obj.numLoops; i2++) {
- let loop = hatch.getLoopAt(i2);
- loop.vertices.forEach((val, inidex) => {
- loop["pt:" + inidex] = {};
- loop["pt:" + inidex].x = val.x;
- loop["pt:" + inidex].y = val.y;
- loop["pt:" + inidex].z = val.z;
- });
- obj["loop:" + i2] = loop;
- }
- obj.numPatternDefinitions = hatch.numPatternDefinitions;
- for (let i2 = 0; i2 < obj.numPatternDefinitions; i2++) {
- obj["patternDefinitions:" + i2] = hatch.getPatternDefinitionAt(i2);
- }
- } else if (ent instanceof mxcad2.McDbRasterImage) {
- let image = ent;
- let orientation = image.getOrientation();
- obj.orientation = {};
- obj.orientation.origin = orientation.origin.toVector3();
- obj.orientation.uCorner = orientation.uCorner.toVector3();
- obj.orientation.vOnPlane = orientation.vOnPlane.toVector3();
- let clipBoundary = image.clipBoundary();
- obj.clipBoundary = {};
- clipBoundary.forEach((pt, index) => {
- obj.clipBoundary["pt" + index] = pt.toVector3();
- });
- obj.clipBoundaryType = image.clipBoundaryType();
- let imageDef = image.imageDefId().getMcDbRasterImageDef();
- if (imageDef) {
- obj.filePath = imageDef.sourceFileName;
- }
- }
- return obj;
- }
- function TestGetAllEntity() {
- return __async(this, null, function* () {
- let ss = new mxcad2.MxCADSelectionSet();
- ss.allSelect();
- ss.forEach((id) => {
- let ent = id.getMcDbEntity();
- if (!ent)
- return;
- ent = McDbEntityToJsonObject(ent);
- console.log(JSON.stringify(ent));
- });
- });
- }
- function TestGentEntityOnLayer() {
- return __async(this, null, function* () {
- let ss = new mxcad2.MxCADSelectionSet();
- let filter = new mxcad2.MxCADResbuf();
- filter.AddString("0", 8);
- ss.allSelect(filter);
- ss.forEach((id) => {
- let ent = id.getMcDbEntity();
- if (!ent)
- return;
- if (ent instanceof mxcad2.McDbHatch) {
- let obj = {};
- let hatch = ent;
- obj.patternType = hatch.patternType();
- obj.patternName = hatch.patternName();
- obj.patternAngle = hatch.patternAngle;
- obj.patternScale = hatch.patternScale;
- obj.patternSpace = hatch.patternSpace;
- obj.patternDouble = hatch.patternDouble;
- obj.hatchStyle = hatch.hatchStyle();
- obj.isSolid = hatch.isSolid();
- obj.numLoops = hatch.numLoops;
- for (let i2 = 0; i2 < obj.numLoops; i2++) {
- let loop = hatch.getLoopAt(i2);
- loop.vertices.forEach((val, inidex) => {
- loop["pt:" + inidex] = {};
- loop["pt:" + inidex].x = val.x;
- loop["pt:" + inidex].y = val.y;
- loop["pt:" + inidex].z = val.z;
- });
- obj["loop:" + i2] = loop;
- }
- obj.numPatternDefinitions = hatch.numPatternDefinitions;
- for (let i2 = 0; i2 < obj.numPatternDefinitions; i2++) {
- obj["patternDefinitions:" + i2] = hatch.getPatternDefinitionAt(i2);
- }
- console.log(obj);
- }
- });
- });
- }
- function MxTest_GetSysVars() {
- return __async(this, null, function* () {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- let database = mxcad$1.getDatabase();
- let grid = {};
- grid["name"] = "GRIDMODE";
- grid["isShow"] = mxcad$1.getSysVarLong("GRIDMODE");
- let ptSnapUnit = mxcad$1.getSysVarPoint("SNAPUNIT");
- grid["xdist"] = ptSnapUnit.x;
- grid["ydist"] = ptSnapUnit.x;
- console.log(grid);
- let ortho = {};
- ortho["name"] = "ORTHOMODE";
- ortho["isShow"] = mxcad$1.getSysVarLong("ORTHOMODE");
- console.log(ortho);
- let polarAxis = {};
- polarAxis["name"] = "AUTOSNAP";
- polarAxis["enable"] = (mxcad$1.getSysVarLong("AUTOSNAP") & 8) != 0;
- polarAxis["polarang"] = mxcad$1.getSysVarDouble("POLARANG");
- console.log(polarAxis);
- let osnap = {};
- osnap["name"] = "OSMODE";
- osnap["enable"] = (mxcad$1.getSysVarLong("OSMODE") & 16384) == 0;
- osnap["value"] = mxcad$1.getSysVarLong("OSMODE");
- osnap["End"] = (mxcad$1.getSysVarLong("OSMODE") & 1) != 0;
- osnap["Mid"] = (mxcad$1.getSysVarLong("OSMODE") & 2) != 0;
- osnap["Cen"] = (mxcad$1.getSysVarLong("OSMODE") & 4) != 0;
- osnap["Node"] = (mxcad$1.getSysVarLong("OSMODE") & 8) != 0;
- osnap["Quad"] = (mxcad$1.getSysVarLong("OSMODE") & 16) != 0;
- osnap["Int"] = (mxcad$1.getSysVarLong("OSMODE") & 32) != 0;
- osnap["Ins"] = (mxcad$1.getSysVarLong("OSMODE") & 64) != 0;
- osnap["Perp"] = (mxcad$1.getSysVarLong("OSMODE") & 128) != 0;
- osnap["Tan"] = (mxcad$1.getSysVarLong("OSMODE") & 256) != 0;
- osnap["Near"] = (mxcad$1.getSysVarLong("OSMODE") & 512) != 0;
- console.log(osnap);
- let dyntrace = {};
- dyntrace["name"] = "DYNTRACE";
- dyntrace["enable"] = mxcad$1.getSysVarLong("DYNTRACE") != 0;
- console.log(dyntrace);
- let dyn = {};
- dyn["name"] = "DYNINPUT";
- dyn["enable"] = mxcad$1.getSysVarLong("DYNINPUT") != 0;
- console.log(dyn);
- let sysvar = {};
- sysvar.LTSCALE = mxcad$1.getSysVarDouble("LTSCALE");
- sysvar.CELTSCALE = mxcad$1.getSysVarDouble("CELTSCALE");
- sysvar.CELTYPE = mxcad$1.getSysVarString("CELTYPE");
- sysvar.TEXTSTYLE = mxcad$1.getSysVarString("TEXTSTYLE");
- sysvar.CLAYOUTNAME = mxcad$1.getSysVarString("CLAYOUTNAME");
- sysvar.CLAYER = mxcad$1.getSysVarString("CLAYER");
- sysvar.CECOLOR = database.getCurrentlyTrueColor().getColorValue();
- sysvar.INSBASE = mxcad$1.getSysVarPoint("INSBASE");
- sysvar.CELWEIGHT = mxcad$1.getSysVarLong("CELWEIGHT");
- sysvar.PDMODE = mxcad$1.getSysVarLong("PDMODE");
- sysvar.PDSIZE = mxcad$1.getSysVarDouble("PDSIZE");
- console.log(sysvar);
- });
- }
- function MxTest_ReadxData() {
- return __async(this, null, function* () {
- let selEntity = new mxcad2.MxCADUiPrEntity();
- selEntity.setMessage("选择对象");
- let id = yield selEntity.go();
- if (!id.isValid())
- return;
- let ent = id.getMcDbEntity();
- if (ent === null)
- return;
- let data = ent.getxData();
- data.forEach((val, type, dxf) => {
- console.log(JSON.stringify({ val, type, dxf }));
- });
- });
- }
- function MxTest_WritexData() {
- return __async(this, null, function* () {
- let selEntity = new mxcad2.MxCADUiPrEntity();
- selEntity.setMessage("选择对象");
- let id = yield selEntity.go();
- if (!id.isValid())
- return;
- let ent = id.getMcDbEntity();
- if (ent === null)
- return;
- ent.setxDataString("DataName", "xxxxx");
- });
- }
- function MxTest_DrawLine() {
- return __async(this, null, function* () {
- const getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.setMessage("\n指定第一点:");
- let prvPoint = yield getPoint.go();
- if (!prvPoint)
- return;
- getPoint.setMessage("\n指定下一个点:");
- while (true) {
- getPoint.setBasePt(prvPoint);
- let pt = yield getPoint.go();
- if (!pt)
- return;
- let line = new mxcad2.McDbLine(prvPoint, pt);
- mxcad2.MxCpp.getCurrentMxCAD().drawEntity(line);
- prvPoint = pt;
- }
- });
- }
- function getHostUrl() {
- let host = window.location.hostname;
- if (host.substring(0, 4) != "http") {
- host = document.location.protocol + "//" + host;
- }
- return host;
- }
- function MxTest_InsertBlock() {
- return __async(this, null, function* () {
- let baseUrl = "http://localhost:3000/mxcad/";
- if (baseUrl.substring(0, 16) == "http://localhost") {
- baseUrl = getHostUrl() + baseUrl.substring(16);
- }
- let blkFilePath = baseUrl + "tree.mxweb";
- let mxcad$1 = mxcad2.MxCpp.App.getCurrentMxCAD();
- let blkrecId = yield mxcad$1.insertBlock(blkFilePath, "tree");
- if (!blkrecId.isValid()) {
- return;
- }
- let blkRef = new mxcad2.McDbBlockReference();
- blkRef.blockTableRecordId = blkrecId;
- let box = blkRef.getBoundingBox();
- if (box.ret) {
- let dLen = box.maxPt.distanceTo(box.minPt);
- if (dLen > 1e-5) {
- blkRef.setScale(mxcad$1.getMxDrawObject().screenCoordLong2Doc(100) / dLen);
- }
- }
- let getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.setMessage("指定插入基点");
- getPoint.setUserDraw((v, worldDraw) => {
- blkRef.position = v;
- worldDraw.drawMcDbEntity(blkRef);
- });
- let pt = yield getPoint.go();
- if (!pt)
- return;
- blkRef.position = pt;
- let newBlkRefId = mxcad$1.drawEntity(blkRef);
- if (!newBlkRefId.isValid) {
- console.log("insert error");
- return;
- }
- blkRef = newBlkRefId.getMcDbEntity();
- blkRef.disableDisplay(true);
- let blkRecord = blkrecId.getMcDbBlockTableRecord();
- let ids = blkRecord.getAllEntityId();
- ids.forEach((id, index) => {
- if (!id.isKindOf("McDbAttributeDefinition"))
- return;
- let attribDef = id.getMcDbEntity();
- let tag = attribDef.tag;
- let txt = attribDef.textString;
- let attrib = new mxcad2.McDbAttribute();
- attrib.position = attribDef.position;
- attrib.alignmentPoint = attribDef.alignmentPoint;
- attrib.height = attribDef.height;
- attrib.trueColor = attribDef.trueColor;
- attrib.widthFactor = attribDef.widthFactor;
- if (txt.length > 0)
- attrib.textString = txt;
- else
- attrib.textString = "test" + index;
- attrib.tag = tag;
- attrib.isInvisible = attribDef.isInvisible;
- attrib.transformBy(blkRef.blockTransform);
- attrib = blkRef.appendAttribute(attrib).getMcDbEntity();
- attrib.textStyle = attribDef.textStyle;
- attrib.layer = attribDef.layer;
- });
- blkRef.disableDisplay(false);
- });
- }
- function MxTest_GetAllLayer() {
- let mxcad$1 = mxcad2.MxCpp.App.getCurrentMxCAD();
- let layerTable = mxcad$1.getDatabase().getLayerTable();
- let aryId = layerTable.getAllRecordId();
- let ret = [];
- aryId.forEach((id) => {
- let layerRec = id.getMcDbLayerTableRecord();
- if (layerRec === null)
- return;
- console.log(layerRec);
- console.log("layerRec.color:" + layerRec.color.getColorString());
- console.log("layerRec.name:" + layerRec.name);
- let layer = {};
- layer.name = layerRec.name;
- layer.color = layerRec.color.getColorString();
- ret.push(layer);
- });
- mxdraw.MxFun.postMessageToParentFrame(ret);
- return ret;
- }
- function MxTest_AddLayer() {
- let mxcad$1 = mxcad2.MxCpp.App.getCurrentMxCAD();
- let layerTable = mxcad$1.getDatabase().getLayerTable();
- if (!layerTable.has("xxx11")) {
- let newLayer = new mxcad2.McDbLayerTableRecord();
- newLayer.name = "xxx11";
- layerTable.add(newLayer);
- }
- if (layerTable.has("xxx11")) {
- console.log("add layer ok");
- }
- }
- function MxTest_GetAllLinetype() {
- let mxcad$1 = mxcad2.MxCpp.App.getCurrentMxCAD();
- let linetypeTable = mxcad$1.getDatabase().getLinetypeTable();
- let aryId = linetypeTable.getAllRecordId();
- aryId.forEach((id) => {
- let linetypeRec = id.getMcDbLinetypeTableRecord();
- if (linetypeRec === null)
- return;
- console.log(linetypeRec);
- });
- }
- function MxTest_GetAllTextStyle() {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- let textSyleTable = mxcad$1.getDatabase().getTextStyleTable();
- let aryId = textSyleTable.getAllRecordId();
- aryId.forEach((id) => {
- let textSyleRec = id.getMcDbTextStyleTableRecord();
- if (textSyleRec === null)
- return;
- let out = {};
- out.name = textSyleRec.name;
- out.font = textSyleRec.font();
- out.fileName = textSyleRec.fileName;
- out.bigFontFileName = textSyleRec.bigFontFileName;
- out.textSize = textSyleRec.textSize;
- out.xScale = textSyleRec.xScale;
- console.log(out);
- });
- }
- function MxTest_AddTextStyleTable() {
- return __async(this, null, function* () {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- let textSyleTable = mxcad$1.getDatabase().getTextStyleTable();
- let sMyTextStyle = "MyTextStyle";
- if (textSyleTable.has(sMyTextStyle, false)) {
- let id = textSyleTable.get(sMyTextStyle, false);
- id.erase(false);
- }
- let newTextStyleRecord = new mxcad2.McDbTextStyleTableRecord();
- newTextStyleRecord.fileName = "txt.shx";
- newTextStyleRecord.bigFontFileName = "hztxt.shx";
- newTextStyleRecord.textSize = 10;
- newTextStyleRecord.name = sMyTextStyle;
- newTextStyleRecord.xScale = 0.7;
- if (textSyleTable.add(newTextStyleRecord).isValid()) {
- console.log("add ok");
- }
- });
- }
- function MxTest_GetAllBlock() {
- let mxcad$1 = mxcad2.MxCpp.App.getCurrentMxCAD();
- let blockTable = mxcad$1.getDatabase().getBlockTable();
- let aryId = blockTable.getAllRecordId();
- aryId.forEach((id) => {
- let blkRec = id.getMcDbBlockTableRecord();
- if (blkRec === null)
- return;
- console.log(blkRec);
- console.log("blkRec.name:" + blkRec.name);
- console.log("blkRec.origin:" + blkRec.origin);
- });
- }
- function Mx_Test_DrawTable() {
- return __async(this, null, function* () {
- let draw = new MxDrawTable();
- draw.data.addColumn("序号", 30);
- draw.data.addColumn("名称", 45);
- draw.data.addColumn("材料", 60);
- draw.data.addColumn("长度", 50);
- for (let i2 = 0; i2 < 10; i2++) {
- let sT = "" + i2;
- draw.data.addRow([sT, "AAAA", "BBBB", "1000"]);
- }
- let getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.setMessage("\n指定表格插入点:");
- let pt = yield getPoint.go();
- if (!pt)
- return;
- let lScale = mxdraw.MxFun.screenCoordLong2Doc(100) / 200;
- draw.draw(pt, lScale);
- });
- }
- function Mx_Test_QRCode() {
- return __async(this, null, function* () {
- const getPoint = new mxdraw.MrxDbgUiPrPoint();
- getPoint.setMessage("\n指定插入点:");
- let pt = yield getPoint.go();
- if (!pt)
- return;
- let mxobj = mxdraw.MxFun.getCurrentDraw();
- const qr = QRCode(5, "L");
- qr.addData("https://www.mxdraw3d.com");
- qr.make();
- const qrDataURL = qr.createDataURL();
- const texture = new TextureLoader().load(qrDataURL);
- const material = new MeshBasicMaterial({ map: texture });
- let w = mxdraw.MxFun.screenCoordLong2Doc(80);
- let h = mxdraw.MxFun.screenCoordLong2Doc(80);
- let image = new mxdraw.MxDbImage();
- image.setRenderOrder(mxdraw.MxType.MxDefaultRenderOrder.kCADMeshRenderOrder - 1);
- image.setPoint1(pt);
- let pt2 = new Vector3(pt.x + w, pt.y + h, pt.z);
- image.setPoint2(pt2);
- image.setMaterial(material);
- mxobj.addMxEntity(image);
- setInterval(() => {
- mxobj.updateDisplay();
- }, 100);
- });
- }
- function MxTest_InsertStamp() {
- return __async(this, null, function* () {
- let baseUrl = "http://localhost:3000/mxcad/";
- if (baseUrl.substring(0, 16) == "http://localhost") {
- baseUrl = getHostUrl() + baseUrl.substring(16);
- }
- let blkFilePath = baseUrl + "stamp.mxweb";
- let mxcad$1 = mxcad2.MxCpp.App.getCurrentMxCAD();
- let blkrecId = yield mxcad$1.insertBlock(blkFilePath, "stamp");
- if (!blkrecId.isValid()) {
- return;
- }
- let blkRef = new mxcad2.McDbBlockReference();
- blkRef.blockTableRecordId = blkrecId;
- let box = blkRef.getBoundingBox();
- if (box.ret) {
- let dLen = box.maxPt.distanceTo(box.minPt);
- if (dLen > 1e-5) {
- blkRef.setScale(mxcad$1.getMxDrawObject().screenCoordLong2Doc(100) / dLen);
- }
- }
- let getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.setMessage("指定插入基点");
- getPoint.setUserDraw((v, worldDraw) => {
- blkRef.position = v;
- worldDraw.drawMcDbEntity(blkRef);
- });
- let pt = yield getPoint.go();
- if (!pt)
- return;
- blkRef.position = pt;
- mxcad$1.drawEntity(blkRef);
- });
- }
- function MxTest_LineTypeTest() {
- return __async(this, null, function* () {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- let linetypeRecord = mxcad$1.database.getLinetypeTable().get("TestMyLine");
- if (!linetypeRecord.isErase()) {
- linetypeRecord.erase();
- }
- let lintype = mxcad$1.addLinetypeEx("TestMyLine", '.5,-.2,["HW",STANDARD,S=.1,R=0.0,X=-0.1,Y=-.05],-.2', "");
- if (!lintype.isValid())
- return;
- let getEnt = new mxcad2.MxCADUiPrEntity();
- let entId = yield getEnt.go();
- let ent = entId.getMcDbEntity();
- if (!ent)
- return;
- ent.linetypeId = lintype;
- });
- }
- function MxTest_DictionaryData(dict) {
- let aryName = dict.getAllObjectName();
- aryName.forEach((name) => {
- console.log(name);
- let id = dict.getAt(name);
- let obj = id.getMcDbObject();
- if (obj instanceof mxcad2.McDbDictionary) {
- let dict2 = obj;
- console.log(dict2);
- MxTest_DictionaryData(dict2);
- } else if (obj instanceof mxcad2.McDbXrecord) {
- let xrec = obj;
- let data = xrec.getData();
- data.PrintData();
- }
- });
- }
- function MxTest_GetObjectExDictionaryData() {
- return __async(this, null, function* () {
- let selEntity = new mxcad2.MxCADUiPrEntity();
- selEntity.setMessage("选择标注对象");
- let id = yield selEntity.go();
- if (!id.isValid())
- return;
- let ent = id.getMcDbEntity();
- if (ent && ent.isHaveExtensionDictionary()) {
- let dict = ent.getExtensionDictionary();
- MxTest_DictionaryData(dict);
- }
- });
- }
- function MxTest_GetNamedObjectsDictionary() {
- return __async(this, null, function* () {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- let dict = mxcad$1.getDatabase().getNamedObjectsDictionary();
- let aryName = dict.getAllObjectName();
- aryName.forEach((name) => {
- console.log(name);
- let id = dict.getAt(name);
- let obj = id.getMcDbObject();
- if (obj instanceof mxcad2.McDbDictionary) {
- let dict2 = obj;
- console.log(dict2);
- MxTest_DictionaryData(dict2);
- }
- });
- });
- }
- function MxTest_WriteXRecord() {
- return __async(this, null, function* () {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- let dict = mxcad$1.getDatabase().getNamedObjectsDictionary();
- let sName = "MyDict";
- let idDict = dict.getAt(sName);
- if (idDict.isNull()) {
- let newDict = new mxcad2.McDbDictionary();
- idDict = dict.addObject(sName, newDict);
- }
- let myDict = idDict.getMcDbDictionary();
- if (myDict) {
- let xrec = new mxcad2.McDbXrecord();
- let data = new mxcad2.MxCADResbuf();
- data.AddString("TestData");
- xrec.setData(data);
- myDict.addObject("MyRecord", xrec);
- console.log("write xrecord ok");
- }
- });
- }
- function Mx_Test_ChangeColor() {
- return __async(this, null, function* () {
- let getEntity = new mxcad2.MxCADUiPrEntity();
- getEntity.setMessage("选择标注对象");
- let id = yield getEntity.go();
- if (!id.isValid())
- return;
- let ent = id.getMcDbEntity();
- if (!ent)
- return;
- ent.trueColor = new mxcad2.McCmColor(255, 0, 255);
- });
- }
- let idVisible;
- function Mx_Test_ChangeVisible() {
- return __async(this, null, function* () {
- if (!idVisible) {
- let getEntity = new mxcad2.MxCADUiPrEntity();
- getEntity.setMessage("选择标注对象");
- let id = yield getEntity.go();
- if (!id.isValid())
- return;
- let ent = id.getMcDbEntity();
- if (!ent)
- return;
- ent.visible = false;
- idVisible = id;
- } else {
- let ent = idVisible.getMcDbEntity();
- if (!ent)
- return;
- ent.visible = true;
- }
- });
- }
- function Mx_Test_ChangeEntityLayer() {
- return __async(this, null, function* () {
- let newLayerName = "WALL";
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- if (!mxcad$1.database.layerTable.has(newLayerName)) {
- console.log("no have layer:" + newLayerName);
- }
- let getEntity = new mxcad2.MxCADUiPrEntity();
- getEntity.setMessage("选择对象");
- let id = yield getEntity.go();
- if (!id.isValid())
- return;
- let ent = id.getMcDbEntity();
- if (!ent)
- return;
- ent.layer = newLayerName;
- });
- }
- function Mx_ChaneEntityDrawOrder() {
- return __async(this, null, function* () {
- let ss = new mxcad2.MxCADSelectionSet();
- if (!(yield ss.userSelect("\n选择对象")))
- return;
- let minmaxOrder = mxcad2.MxCpp.getCurrentDatabase().currentSpace.getMinMaxDrawOrder();
- let lOrder = minmaxOrder.maxDrawOrder + 1;
- ss.forEach((id) => {
- let ent = id.getMcDbEntity();
- if (ent) {
- ent.drawOrder = lOrder;
- }
- });
- });
- }
- function init$k() {
- mxdraw.MxFun.addCommand("TestGetAllEntity", TestGetAllEntity);
- mxdraw.MxFun.addCommand("MxTest_GetSysVars", MxTest_GetSysVars);
- mxdraw.MxFun.addCommand("MxTest_ReadxData", MxTest_ReadxData);
- mxdraw.MxFun.addCommand("MxTest_WritexData", MxTest_WritexData);
- mxdraw.MxFun.addCommand("MxTest_DrawLine", MxTest_DrawLine);
- mxdraw.MxFun.addCommand("MxTest_InsertBlock", MxTest_InsertBlock);
- mxdraw.MxFun.addCommand("MxTest_GetAllLayer", MxTest_GetAllLayer);
- mxdraw.MxFun.addCommand("MxTest_AddLayer", MxTest_AddLayer);
- mxdraw.MxFun.addCommand("MxTest_GetAllTextStyle", MxTest_GetAllTextStyle);
- mxdraw.MxFun.addCommand("MxTest_GetAllBlock", MxTest_GetAllBlock);
- mxdraw.MxFun.addCommand("MxTest_GetAllLinetype", MxTest_GetAllLinetype);
- mxdraw.MxFun.addCommand("Mx_Test_DrawTable", Mx_Test_DrawTable);
- mxdraw.MxFun.addCommand("Mx_Test_QRCode", Mx_Test_QRCode);
- mxdraw.MxFun.addCommand("MxTest_InsertStamp", MxTest_InsertStamp);
- mxdraw.MxFun.addCommand("MxTest_LineTypeTest", MxTest_LineTypeTest);
- mxdraw.MxFun.addCommand("TestGentEntityOnLayer", TestGentEntityOnLayer);
- mxdraw.MxFun.addCommand("MxTest_GetNamedObjectsDictionary", MxTest_GetNamedObjectsDictionary);
- mxdraw.MxFun.addCommand("MxTest_GetObjectExDictionaryData", MxTest_GetObjectExDictionaryData);
- mxdraw.MxFun.addCommand("MxTest_WriteXRecord", MxTest_WriteXRecord);
- mxdraw.MxFun.addCommand("MxTest_AddTextStyleTable", MxTest_AddTextStyleTable);
- mxdraw.MxFun.addCommand("Mx_Test_ChangeColor", Mx_Test_ChangeColor);
- mxdraw.MxFun.addCommand("Mx_Test_ChangeVisible", Mx_Test_ChangeVisible);
- mxdraw.MxFun.addCommand("Mx_Test_ChangeEntityLayer", Mx_Test_ChangeEntityLayer);
- mxdraw.MxFun.addCommand("Mx_ChaneEntityDrawOrder", Mx_ChaneEntityDrawOrder);
- }
- function Mx_Export_DWG() {
- return __async(this, null, function* () {
- let {
- baseUrl = "",
- saveDwgUrl = "",
- mxfilepath = ""
- } = getMxCADUi().getUploadFileConfig();
- mxcad2.MxCpp.getCurrentMxCAD().saveFileToUrl(saveDwgUrl, (iResult, sserverResult) => {
- try {
- let ret = JSON.parse(sserverResult);
- if (ret.ret == "ok") {
- let filePath = baseUrl + mxfilepath + ret.file;
- fetch(filePath).then((res) => __async(this, null, function* () {
- const blob = yield res.blob();
- mxcad2.MxTools.saveAsFileDialog({
- blob,
- filename: ret.file,
- types: [{
- description: "dwg图纸",
- accept: {
- "application/octet-stream": [".dwg"]
- }
- }]
- });
- }));
- } else {
- console.log(sserverResult);
- }
- } catch (e) {
- console.log("Mx: sserverResult error");
- }
- });
- });
- }
- function Mx_Export_MxWeb() {
- return __async(this, null, function* () {
- let {
- baseUrl = "",
- mxfilepath = "",
- saveUrl = ""
- } = getMxCADUi().getUploadFileConfig();
- mxcad2.MxCpp.getCurrentMxCAD().saveFileToUrl(saveUrl, (iResult, sserverResult) => {
- try {
- let ret = JSON.parse(sserverResult);
- if (ret.ret == "ok") {
- let filePath = baseUrl + mxfilepath + ret.file;
- mxcad2.MxTools.downloadFileFromUrl(filePath, ret.file);
- } else {
- console.log(sserverResult);
- }
- } catch (e) {
- console.log("Mx: sserverResult error");
- }
- });
- });
- }
- function Mx_Open_MxWeb() {
- return __async(this, null, function* () {
- mxcad2.MxCpp.getCurrentMxCAD().openWebFile("http://localhost:1337/mxcad/file/8c79da20e232495888dbb0da17459399.mxweb");
- });
- }
- function MxTest_NewFile() {
- return __async(this, null, function* () {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.newFile();
- });
- }
- function Mx_Export_Pdf() {
- return __async(this, null, function* () {
- let getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.setMessage("\n指定输出范围第一点:");
- let pt1 = yield getPoint.go();
- if (!pt1)
- return;
- getPoint.setMessage("\n指定输出范围第二点:");
- getPoint.setUserDraw((currentPoint, worldDraw) => {
- worldDraw.setColor(16711680);
- let pl = new mxcad2.McDbPolyline();
- pl.addVertexAt(pt1);
- pl.addVertexAt(new mxcad2.McGePoint3d(pt1.x, currentPoint.y));
- pl.addVertexAt(currentPoint);
- pl.addVertexAt(new mxcad2.McGePoint3d(currentPoint.x, pt1.y));
- pl.constantWidth = mxdraw.MxFun.screenCoordLong2Doc(2);
- pl.isClosed = true;
- worldDraw.drawMcDbEntity(pl);
- let points = [];
- points.push(pt1.toVector3());
- points.push(new THREE.Vector3(pt1.x, currentPoint.y));
- points.push(currentPoint.toVector3());
- points.push(new THREE.Vector3(currentPoint.x, pt1.y));
- worldDraw.setColor(12868);
- worldDraw.drawSolid(points, 0.5);
- });
- getPoint.setDisableOsnap(true);
- getPoint.setDisableOrthoTrace(true);
- getPoint.setDynamicInputType(mxdraw.DynamicInputType.kXYCoordInput);
- let pt2 = yield getPoint.go();
- if (!pt2) {
- return;
- }
- let {
- baseUrl = "",
- mxfilepath = "",
- printPdfUrl = ""
- } = getMxCADUi().getUploadFileConfig();
- console.log(getMxCADUi().getUploadFileConfig());
- let param = {
- width: "2100",
- height: "2970",
- bd_pt1_x: "" + pt1.x,
- bd_pt1_y: "" + pt1.y,
- bd_pt2_x: "" + pt2.x,
- bd_pt2_y: "" + pt2.y
- };
- mxcad2.MxCpp.getCurrentMxCAD().saveFileToUrl(printPdfUrl, (iResult, sserverResult) => {
- try {
- let ret = JSON.parse(sserverResult);
- if (ret.ret == "ok") {
- let filePath = baseUrl + mxfilepath + ret.file;
- mxcad2.MxTools.downloadFileFromUrl(filePath, ret.file);
- } else {
- console.log(sserverResult);
- }
- } catch (e) {
- console.log("Mx: sserverResult error");
- }
- }, void 0, JSON.stringify(param));
- });
- }
- function init$j() {
- mxdraw.MxFun.addCommand("Mx_Export_DWG", Mx_Export_DWG);
- mxdraw.MxFun.addCommand("Mx_Export_MxWeb", Mx_Export_MxWeb);
- mxdraw.MxFun.addCommand("Mx_Open_MxWeb", Mx_Open_MxWeb);
- mxdraw.MxFun.addCommand("MxTest_NewFile", MxTest_NewFile);
- mxdraw.MxFun.addCommand("Mx_Export_Pdf", Mx_Export_Pdf);
- }
- function MxTest_FindText() {
- return __async(this, null, function* () {
- let sFindText1 = "0601";
- let sFindText2 = "001A";
- let ss = new mxcad2.MxCADSelectionSet();
- let filter = new mxcad2.MxCADResbuf();
- filter.AddMcDbEntityTypes("TEXT,MTEXT,INSERT,ACAD_PROXY_ENTITY");
- ss.allSelect(filter);
- let findPos;
- let entBox;
- let iCount = ss.count();
- for (let i2 = 0; i2 < iCount; i2++) {
- let id = ss.item(i2);
- let ent = id.getMcDbEntity();
- if (!ent)
- return;
- if (ent instanceof mxcad2.McDbText) {
- let txt = ent;
- if (txt.textString == sFindText1) {
- findPos = txt.position;
- entBox = txt.getBoundingBox();
- break;
- }
- } else if (ent instanceof mxcad2.McDbMText) {
- let mtxt = ent;
- if (mtxt.contents == sFindText1) {
- findPos = mtxt.location;
- entBox = mtxt.getBoundingBox();
- break;
- }
- } else if (ent instanceof mxcad2.McDbBlockReference) {
- let blkRef = ent;
- let aryId = blkRef.getAllAttribute();
- let iFind = 0;
- aryId.forEach((id2) => {
- let attribt = id2.getMcDbEntity();
- if (attribt.textString == sFindText1) {
- iFind++;
- } else if (attribt.textString == sFindText2) {
- iFind++;
- }
- });
- if (iFind == 2) {
- findPos = blkRef.position;
- entBox = blkRef.getBoundingBox();
- break;
- }
- } else if (ent instanceof mxcad2.McDbProxyEntity) {
- let proxyEntity = ent;
- let aryText = proxyEntity.getAllTextContent();
- let iFind = 0;
- aryText.forEach((val) => {
- if (val == sFindText1) {
- iFind++;
- }
- });
- if (iFind >= 1) {
- entBox = proxyEntity.getBoundingBox();
- if (entBox && entBox.ret) {
- 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);
- }
- break;
- }
- }
- }
- if (entBox && entBox.ret) {
- console.log(entBox);
- let len = entBox.minPt.distanceTo(entBox.maxPt) * 2;
- mxdraw.MxFun.getCurrentDraw().zoomW(
- new THREE.Vector3(entBox.minPt.x - len, entBox.minPt.y - len, 0),
- new THREE.Vector3(entBox.maxPt.x + len, entBox.maxPt.y + len, 0)
- );
- } else if (findPos) {
- mxdraw.MxFun.getCurrentDraw().zoomCenter(findPos.x, findPos.y);
- } else {
- console.log("没有找到文字:" + sFindText1);
- }
- });
- }
- function init$i() {
- mxdraw.MxFun.addCommand("MxTest_FindText", MxTest_FindText);
- }
- class McDbTestLineCustomEntity extends mxcad2.McDbCustomEntity {
- constructor(imp) {
- super(imp);
- this.pt1 = new mxcad2.McGePoint3d();
- this.pt2 = new mxcad2.McGePoint3d();
- }
- create(imp) {
- return new McDbTestLineCustomEntity(imp);
- }
- getTypeName() {
- return "McDbTestLineCustomEntity";
- }
- dwgInFields(filter) {
- this.pt1 = filter.readPoint("pt1").val;
- this.pt2 = filter.readPoint("pt2").val;
- return true;
- }
- dwgOutFields(filter) {
- filter.writePoint("pt1", this.pt1);
- filter.writePoint("pt2", this.pt2);
- return true;
- }
- moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset) {
- this.assertWrite();
- if (iIndex == 0) {
- this.pt1.x += dXOffset;
- this.pt1.y += dYOffset;
- this.pt1.z += dZOffset;
- } else if (iIndex == 1) {
- this.pt2.x += dXOffset;
- this.pt2.y += dYOffset;
- this.pt2.z += dZOffset;
- }
- }
- getGripPoints() {
- let ret = new mxcad2.McGePoint3dArray();
- ret.append(this.pt1);
- ret.append(this.pt2);
- return ret;
- }
- worldDraw(draw) {
- let tmpline = new mxcad2.McDbLine(this.pt1, this.pt2);
- draw.drawEntity(tmpline);
- }
- //
- setPoint1(pt1) {
- this.assertWrite();
- this.pt1 = pt1.clone();
- }
- setPoint2(pt2) {
- this.assertWrite();
- this.pt2 = pt2.clone();
- }
- getPoint1() {
- return this.pt1;
- }
- getPoint2() {
- return this.pt2;
- }
- }
- function MxTest_DrawCustomEntity() {
- return __async(this, null, function* () {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- const getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.setMessage("\n指定一点:");
- let pt1 = yield getPoint.go();
- if (!pt1)
- return;
- getPoint.setBasePt(pt1);
- getPoint.setUseBasePt(true);
- getPoint.setMessage("\n指定二点:");
- let pt2 = yield getPoint.go();
- if (!pt2)
- return;
- let myline = new McDbTestLineCustomEntity();
- myline.setPoint1(pt1);
- myline.setPoint2(pt2);
- mxcad$1.drawEntity(myline);
- });
- }
- function init$h() {
- new McDbTestLineCustomEntity().rxInit();
- mxdraw.MxFun.addCommand("MxTest_DrawCustomEntity", MxTest_DrawCustomEntity);
- }
- function MxTest_SelectEntitysToBlock() {
- return __async(this, null, function* () {
- let ss = new mxcad2.MxCADSelectionSet();
- if (!(yield ss.userSelect("选择要做成块的对象:")))
- return;
- if (ss.count() == 0)
- return;
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- let blkTable = mxcad$1.getDatabase().getBlockTable();
- let blkRecId = blkTable.add(new mxcad2.McDbBlockTableRecord());
- let blkTableRecord = blkRecId.getMcDbBlockTableRecord();
- if (blkTableRecord == null)
- return;
- let pt1x, pt1y, pt2x, pt2y;
- ss.forEach((id) => {
- let ent = id.getMcDbEntity();
- if (!ent)
- return;
- let cent = ent.clone();
- blkTableRecord.appendAcDbEntity(cent);
- let entBox = ent.getBoundingBox();
- if (entBox.ret) {
- if (!pt1x) {
- pt1x = entBox.minPt.x;
- pt1y = entBox.minPt.y;
- pt2x = entBox.maxPt.x;
- pt2y = entBox.maxPt.y;
- } else {
- if (pt1x > entBox.minPt.x)
- pt1x = entBox.minPt.x;
- if (pt1y > entBox.minPt.y)
- pt1y = entBox.minPt.y;
- if (pt2x < entBox.maxPt.x)
- pt2x = entBox.maxPt.x;
- if (pt2y < entBox.maxPt.y)
- pt2y = entBox.maxPt.y;
- }
- }
- });
- if (pt1x === void 0) {
- return;
- }
- let insertPtx = pt1x + (pt2x - pt1x) * 0.5;
- let insertPty = pt1y + (pt2y - pt1y) * 0.5;
- blkTableRecord.origin = new mxcad2.McGePoint3d(insertPtx, insertPty, 0);
- let blkRef = new mxcad2.McDbBlockReference();
- blkRef.blockTableRecordId = blkRecId;
- blkRef.position = new mxcad2.McGePoint3d(insertPtx, insertPty, 0);
- mxcad$1.drawEntity(blkRef);
- ss.forEach((id) => {
- let ent = id.getMcDbEntity();
- if (!ent)
- return;
- ent.erase();
- });
- });
- }
- function init$g() {
- mxdraw.MxFun.addCommand("MxTest_SelectEntitysToBlock", MxTest_SelectEntitysToBlock);
- }
- function MxTest_DrawHatchFormPoint() {
- return __async(this, null, function* () {
- const getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.setMessage("\n指定填充区域内部一点:");
- getPoint.disableAllTrace(true);
- getPoint.setDisableOsnap(true);
- let pt = yield getPoint.go();
- if (!pt)
- return;
- let hatch = mxcad2.MxCADUtility.builderHatchFromPoint(pt);
- if (!hatch) {
- mxdraw.MxFun.acutPrintf("没有找到闭合区域\n");
- return;
- }
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.drawEntity(hatch);
- });
- }
- function init$f() {
- mxdraw.MxFun.addCommand("MxTest_DrawHatchFormPoint", MxTest_DrawHatchFormPoint);
- }
- const namedColors = {
- aliceblue: [240, 248, 255],
- antiquewhite: [250, 235, 215],
- aqua: [0, 255, 255],
- aquamarine: [127, 255, 212],
- azure: [240, 255, 255],
- beige: [245, 245, 220],
- bisque: [255, 228, 196],
- black: [0, 0, 0],
- blanchedalmond: [255, 235, 205],
- blue: [0, 0, 255],
- blueviolet: [138, 43, 226],
- brown: [165, 42, 42],
- burlywood: [222, 184, 135],
- cadetblue: [95, 158, 160],
- chartreuse: [127, 255, 0],
- chocolate: [210, 105, 30],
- coral: [255, 127, 80],
- cornflowerblue: [100, 149, 237],
- cornsilk: [255, 248, 220],
- crimson: [220, 20, 60],
- cyan: [0, 255, 255],
- darkblue: [0, 0, 139],
- darkcyan: [0, 139, 139],
- darkgoldenrod: [184, 134, 11],
- darkgray: [169, 169, 169],
- darkgreen: [0, 100, 0],
- darkkhaki: [189, 183, 107],
- darkmagenta: [139, 0, 139],
- darkolivegreen: [85, 107, 47],
- darkorange: [255, 140, 0],
- darkorchid: [153, 50, 204],
- darkred: [139, 0, 0],
- darksalmon: [233, 150, 122],
- darkseagreen: [143, 188, 143],
- darkslateblue: [72, 61, 139],
- darkslategray: [47, 79, 79],
- darkturquoise: [0, 206, 209],
- darkviolet: [148, 0, 211],
- deeppink: [255, 20, 147],
- deepskyblue: [0, 191, 255],
- dimgray: [105, 105, 105],
- dodgerblue: [30, 144, 255],
- firebrick: [178, 34, 34],
- floralwhite: [255, 250, 240],
- forestgreen: [34, 139, 34],
- fuchsia: [255, 0, 255],
- gainsboro: [220, 220, 220],
- ghostwhite: [248, 248, 255],
- gold: [255, 215, 0],
- goldenrod: [218, 165, 32],
- gray: [128, 128, 128],
- green: [0, 128, 0],
- greenyellow: [173, 255, 47],
- honeydew: [240, 255, 240],
- hotpink: [255, 105, 180],
- indianred: [205, 92, 92],
- indigo: [75, 0, 130],
- ivory: [255, 255, 240],
- khaki: [240, 230, 140],
- lavender: [230, 230, 250],
- lavenderblush: [255, 240, 245],
- lawngreen: [124, 252, 0],
- lemonchiffon: [255, 250, 205],
- lightblue: [173, 216, 230],
- lightcoral: [240, 128, 128],
- lightcyan: [224, 255, 255],
- lightgoldenrodyellow: [250, 250, 210],
- lightgray: [211, 211, 211],
- lightgreen: [144, 238, 144],
- lightpink: [255, 182, 193],
- lightsalmon: [255, 160, 122],
- lightseagreen: [32, 178, 170],
- lightskyblue: [135, 206, 250],
- lightslategray: [119, 136, 153],
- lightsteelblue: [176, 196, 222],
- lightyellow: [255, 255, 224],
- lime: [0, 255, 0],
- limegreen: [50, 205, 50],
- linen: [250, 240, 230],
- magenta: [255, 0, 255],
- maroon: [128, 0, 0],
- mediumaquamarine: [102, 205, 170],
- mediumblue: [0, 0, 205],
- mediumorchid: [186, 85, 211],
- mediumpurple: [147, 112, 219],
- mediumseagreen: [60, 179, 113],
- mediumslateblue: [123, 104, 238],
- mediumspringgreen: [0, 250, 154],
- mediumturquoise: [72, 209, 204],
- mediumvioletred: [199, 21, 133],
- midnightblue: [25, 25, 112],
- mintcream: [245, 255, 250],
- mistyrose: [255, 228, 225],
- moccasin: [255, 228, 181],
- navajowhite: [255, 222, 173],
- navy: [0, 0, 128],
- oldlace: [253, 245, 230],
- olive: [128, 128, 0],
- olivedrab: [107, 142, 35],
- orange: [255, 165, 0],
- orangered: [255, 69, 0],
- orchid: [218, 112, 214],
- palegoldenrod: [238, 232, 170],
- palegreen: [152, 251, 152],
- paleturquoise: [175, 238, 238],
- palevioletred: [219, 112, 147],
- papayawhip: [255, 239, 213],
- peachpuff: [255, 218, 185],
- peru: [205, 133, 63],
- pink: [255, 192, 203],
- plum: [221, 160, 221],
- powderblue: [176, 224, 230],
- purple: [128, 0, 128],
- rebeccapurple: [102, 51, 153],
- red: [255, 0, 0],
- rosybrown: [188, 143, 143],
- royalblue: [65, 105, 225],
- saddlebrown: [139, 69, 19],
- salmon: [250, 128, 114],
- sandybrown: [244, 164, 96],
- seagreen: [46, 139, 87],
- seashell: [255, 245, 238],
- sienna: [160, 82, 45],
- silver: [192, 192, 192],
- skyblue: [135, 206, 235],
- slateblue: [106, 90, 205],
- slategray: [112, 128, 144],
- snow: [255, 250, 250],
- springgreen: [0, 255, 127],
- steelblue: [70, 130, 180],
- tan: [210, 180, 140],
- teal: [0, 128, 128],
- thistle: [216, 191, 216],
- tomato: [255, 99, 71],
- turquoise: [64, 224, 208],
- violet: [238, 130, 238],
- wheat: [245, 222, 179],
- white: [255, 255, 255],
- whitesmoke: [245, 245, 245],
- yellow: [255, 255, 0],
- yellowgreen: [154, 205, 50]
- };
- function parseColor(color) {
- if (/^\d+,\s*\d+,\s*\d+$/.test(color)) {
- return color.split(",").map(Number);
- } else if (/^0x[0-9a-fA-F]{6}$/.test(color)) {
- const hexValue = parseInt(color, 16);
- return [
- hexValue >> 16 & 255,
- hexValue >> 8 & 255,
- hexValue & 255
- ];
- } else if (/^#[0-9a-fA-F]{6}$/.test(color)) {
- const hexValue = parseInt(color.slice(1), 16);
- return [
- hexValue >> 16 & 255,
- hexValue >> 8 & 255,
- hexValue & 255
- ];
- } else if (namedColors[color.toLowerCase()]) {
- const lowerCaseColor = color.toLowerCase();
- if (namedColors[lowerCaseColor]) {
- return namedColors[lowerCaseColor];
- }
- } else {
- const color2 = new mxcad2.McCmColor();
- color2.setColorIndex(256);
- return [color2.red, color2.green, color2.blue];
- }
- }
- const addLayer = (layerName) => {
- const layerTable = mxcad2.MxCpp.getCurrentDatabase().layerTable;
- if (layerTable.has(layerName)) {
- return;
- }
- const layer = new mxcad2.McDbLayerTableRecord();
- layer.color = new mxcad2.McCmColor(0, 0, 0);
- layer.isFrozen = false;
- layer.isLocked = false;
- layer.isOff = false;
- layer.lineWeight = mxcad2.McDb.LineWeight.kLnWtByLayer;
- layer.name = layerName;
- layerTable.add(layer);
- };
- const baseParams = [
- {
- name: "color",
- description: "颜色",
- "type": "str",
- "required": true
- },
- {
- name: "layer",
- description: "图层",
- "type": "str",
- "required": true
- },
- {
- name: "lineweight",
- description: "线重",
- "type": "float",
- "required": true
- }
- ];
- const mergeBaseMcDbEntityProps = (entity, param) => {
- if (param.layer) {
- addLayer(param.layer);
- }
- const setMcDbEntityProps = (ent) => {
- if (param.color) {
- ent.trueColor = new mxcad2.McCmColor(...parseColor(param.color));
- } else {
- ent.trueColor = new mxcad2.McCmColor(mxcad2.MxCpp.getCurrentDatabase().getCurrentlyDrawColor());
- }
- if (param.layer) {
- ent.layer = param.layer;
- } else {
- ent.layer = mxcad2.MxCpp.getCurrentDatabase().getCurrentlyLayerName();
- }
- if (param.lineweight) {
- ent.lineweight = param.lineweight;
- }
- };
- if (Array.isArray(entity)) {
- entity.forEach(setMcDbEntityProps);
- } else if (entity) {
- setMcDbEntityProps(entity);
- }
- };
- const parseParamPoints = (pointsStr) => {
- const pointsArr = pointsStr.split(",").map((i22) => Number(i22));
- const points = [];
- let i2 = 0;
- while (i2 < pointsArr.length) {
- const x = pointsArr[i2];
- i2++;
- const y = pointsArr[i2];
- i2++;
- if (typeof x === "undefined" || typeof y === "undefined")
- return points;
- const point = new mxcad2.McGePoint3d(x, y);
- points.push(point);
- }
- return points;
- };
- const parsePoint = (point) => {
- if (typeof point === "object" && "x" in point && "y" in point) {
- return new mxcad2.McGePoint3d(point.x, point.y);
- }
- if (Array.isArray(point)) {
- return new mxcad2.McGePoint3d(point[0], point[1]);
- } else if (typeof point === "string") {
- const [x, y] = point.split(",").map((i2) => Number(i2));
- if (typeof x === "number" && typeof y === "number") {
- return new mxcad2.McGePoint3d(x, y);
- }
- }
- };
- class MxAiDrawLine {
- call(param) {
- console.log(param);
- if (param && param.pt1 && param.pt2) {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- if (param.pt1)
- param.pt1 = parsePoint(param.pt1);
- if (param.pt2)
- param.pt2 = parsePoint(param.pt2);
- const objId = mxcad$1.drawLine(param.pt1.x, param.pt1.y, param.pt2.x, param.pt2.y);
- mergeBaseMcDbEntityProps(objId.getMcDbEntity(), param);
- mxcad$1.updateDisplay();
- }
- }
- regist_data() {
- return {
- filename: "drawline.json",
- name: "draw_line",
- description: "根据直线的开始点和结束点绘制一个直线段",
- params: [
- {
- name: "pt1",
- description: "直线开始点",
- "type": "tuple[float, float]",
- "required": true
- },
- {
- name: "pt2",
- description: "直线结束点",
- "type": "tuple[float, float]",
- "required": true
- },
- ...baseParams
- ]
- };
- }
- }
- function init$e() {
- MxAiModule.regist(MxAiDrawLine);
- }
- class MxAiDrawCircle {
- call(param) {
- console.log(param);
- if (param && param.cen && param.radius) {
- if (param.cen)
- param.center = parsePoint(param.cen);
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- const objId = mxcad$1.drawCircle(param.center.x, param.center.y, param.radius);
- mergeBaseMcDbEntityProps(objId.getMcDbEntity(), param);
- mxcad$1.updateDisplay();
- }
- }
- regist_data() {
- return {
- filename: "drawcircle.json",
- name: "draw_circle",
- description: "根据圆心和半径绘制一个圆",
- params: [
- {
- name: "center",
- description: "圆的中心点",
- "type": "tuple[float, float]",
- "required": true
- },
- {
- name: "radius",
- description: "圆的半径",
- "type": "float",
- "required": true
- },
- ...baseParams
- ]
- };
- }
- }
- const init$d = () => {
- MxAiModule.regist(MxAiDrawCircle);
- };
- function findIntersection(p1, p2, p3, p4, isExtending) {
- const x1 = p1.x, y1 = p1.y;
- const x2 = p2.x, y2 = p2.y;
- const x3 = p3.x, y3 = p3.y;
- const x4 = p4.x, y4 = p4.y;
- const denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
- if (denominator === 0) {
- return null;
- }
- const t = ((x1 - x3) * (y3 - y4) - (y1 - y3) * (x3 - x4)) / denominator;
- const u = -((x1 - x2) * (y1 - y3) - (y1 - y2) * (x1 - x3)) / denominator;
- const intersectionX = x1 + t * (x2 - x1);
- const intersectionY = y1 + t * (y2 - y1);
- const point = new mxcad2.McGePoint3d(intersectionX, intersectionY, 0);
- if (isExtending)
- return point;
- if (t > 0 && t < 1 && u > 0 && u < 1) {
- return point;
- } else {
- return null;
- }
- }
- function insidePolygon(points, point) {
- const x = point.x, y = point.y;
- let inside = false;
- for (let i2 = 0, j = points.length - 1; i2 < points.length; j = i2++) {
- const xi = points[i2].x, yi = points[i2].y;
- const xj = points[j].x, yj = points[j].y;
- const intersect = yi > y != yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
- if (intersect)
- inside = !inside;
- }
- return inside;
- }
- function angleTo(x1, y1, x2, y2) {
- const x = x1 - x2;
- const y = y1 - y2;
- let angle_temp = 0;
- if (x == 0) {
- angle_temp = Math.PI / 2;
- } else {
- angle_temp = Math.atan(Math.abs(y / x));
- }
- if (x < 0 && y >= 0) {
- angle_temp = Math.PI - angle_temp;
- } else if (x < 0 && y < 0) {
- angle_temp = Math.PI + angle_temp;
- } else if (x >= 0 && y < 0) {
- angle_temp = Math.PI * 2 - angle_temp;
- }
- return angle_temp;
- }
- function createArc(center, radius, startAngle, endAngle) {
- const arc = new mxcad2.McDbArc();
- arc.center = center;
- arc.radius = radius;
- arc.startAngle = startAngle;
- arc.endAngle = endAngle;
- return arc;
- }
- class MxAiDrawCircleArc {
- call(param) {
- return __async(this, null, function* () {
- console.log(param);
- let { center, radius, startAngle, endAngle, is3PDraw, point1, point2, point3 } = param;
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.newFile();
- mxcad$1.zoomAll();
- const getPoint = new mxcad2.MxCADUiPrPoint();
- const getDist = new mxcad2.MxCADUiPrDist();
- if (is3PDraw) {
- if (point1)
- point1 = parsePoint(point1);
- if (point2)
- point2 = parsePoint(point2);
- if (point3)
- point3 = parsePoint(point3);
- getPoint.setKeyWords("");
- if (!point1) {
- getPoint.setMessage("指定圆弧起点");
- getPoint.setUserDraw((pt, pw) => {
- if (!point2 || !point3)
- return;
- const arc2 = new mxcad2.McDbArc();
- arc2.computeArc(pt.x, pt.y, point2.x, point2.y, point3.x, point3.y);
- pw.drawMcDbEntity(arc2);
- });
- point1 = yield getPoint.go();
- if (!point1)
- return;
- }
- if (!point2) {
- getPoint.setMessage("指定圆弧第二个点");
- getPoint.setUserDraw((pt, pw) => {
- if (!point1 || !point3)
- return;
- const arc2 = new mxcad2.McDbArc();
- arc2.computeArc(point1.x, point1.y, pt.x, pt.y, point3.x, point3.y);
- pw.drawMcDbEntity(arc2);
- });
- point2 = yield getPoint.go();
- if (!point2)
- return;
- }
- if (!point3) {
- getPoint.setMessage("指定圆弧的端点");
- getPoint.setUserDraw((pt, pw) => {
- if (!point1 || !point2)
- return;
- const arc2 = new mxcad2.McDbArc();
- arc2.computeArc(point1.x, point1.y, point2.x, point2.y, pt.x, pt.y);
- pw.drawMcDbEntity(arc2);
- });
- point3 = yield getPoint.go();
- if (!point3)
- return;
- }
- const arc = new mxcad2.McDbArc();
- console.log(point1.x, point1.y, point2.x, point2.y, point3.x, point3.y);
- arc.computeArc(point1.x, point1.y, point2.x, point2.y, point3.x, point3.y);
- mergeBaseMcDbEntityProps(arc, param);
- mxcad$1.drawEntity(arc);
- mxcad$1.updateDisplay();
- } else {
- if (center)
- center = parsePoint(center);
- if (startAngle)
- startAngle = startAngle * (Math.PI / 180);
- if (endAngle)
- endAngle = endAngle * (Math.PI / 180);
- if (!center) {
- getPoint.setMessage("指定圆弧圆心");
- getPoint.setKeyWords("");
- getPoint.setUserDraw((pt, pw) => {
- if (!radius)
- return;
- pw.drawMcDbEntity(createArc(pt, radius, startAngle || 0, endAngle || Math.PI * 2));
- });
- const point = yield getPoint.go();
- if (!point)
- return;
- center = point;
- }
- if (!radius) {
- getDist.setBasePt(center);
- getDist.setMessage(mxcad2._ML_String("MxAiDrawCircleArc_Radius", "指定圆弧半径"));
- getDist.setKeyWords("");
- getDist.setUserDraw((pt, pw) => {
- if (!center)
- return;
- const radius2 = pt.distanceTo(center);
- pw.drawMcDbEntity(createArc(center, radius2, startAngle || 0, endAngle || Math.PI * 2));
- });
- radius = yield getDist.go();
- if (!radius)
- return;
- }
- if (!startAngle) {
- if (!center)
- return;
- getDist.setBasePt(center);
- getDist.setMessage(mxcad2._ML_String("MxAiDrawCircleArc_StartAngle", "指定圆弧开始角"));
- getDist.setKeyWords("");
- getDist.setUserDraw((pt, pw) => {
- if (!center)
- return;
- if (!radius)
- return;
- startAngle = angleTo(center.x, center.y, pt.x, pt.y) - Math.PI;
- pw.drawMcDbEntity(createArc(center, radius, startAngle || 0, endAngle || Math.PI * 2));
- });
- const val = yield getDist.go();
- if (!val)
- return;
- if (getDist.getDetailedResult() === mxdraw.DetailedResult.kCoordIn) {
- startAngle = val * (Math.PI / 180);
- }
- }
- if (!endAngle) {
- if (!center)
- return;
- getDist.setBasePt(center);
- getDist.setMessage(mxcad2._ML_String("MxAiDrawCircleArc_EndAngle", "指定圆弧结束角"));
- getDist.setKeyWords("");
- getDist.setUserDraw((pt, pw) => {
- if (!center)
- return;
- if (!radius)
- return;
- endAngle = angleTo(center.x, center.y, pt.x, pt.y) - Math.PI;
- pw.drawMcDbEntity(createArc(center, radius, startAngle || 0, endAngle || Math.PI * 2));
- });
- const val = yield getDist.go();
- if (!val)
- return;
- if (getDist.getDetailedResult() === mxdraw.DetailedResult.kCoordIn) {
- endAngle = val * (Math.PI / 180);
- }
- }
- const arc = createArc(center, radius, startAngle, endAngle);
- mergeBaseMcDbEntityProps(arc, param);
- mxcad$1.drawEntity(arc);
- mxcad$1.updateDisplay();
- }
- });
- }
- regist_data() {
- return {
- filename: "drawcirclearc.json",
- name: "draw_circle_arc",
- description: "绘制圆弧",
- params: [
- {
- name: "center",
- description: "圆弧圆心",
- "type": "tuple[float, float]",
- "required": true
- },
- {
- name: "radius",
- description: "圆弧半径",
- "type": "float",
- "required": true
- },
- {
- name: "startAngle",
- description: "圆弧开始角",
- "type": "float",
- "required": true
- },
- {
- name: "endAngle",
- description: "圆弧结束角",
- "type": "float",
- "required": true
- },
- {
- name: "is3PDraw",
- description: "是否三点绘制",
- "type": "boolean",
- "required": true
- },
- {
- name: "point1",
- description: "三点绘制圆弧的第一个点(起点)",
- "type": "tuple[float, float]",
- "required": true
- },
- {
- name: "point2",
- description: "三点绘制圆弧的第二个点",
- "type": "tuple[float, float]",
- "required": true
- },
- {
- name: "point3",
- description: "三点绘制圆弧的第三个点(终点)",
- "type": "tuple[float, float]",
- "required": true
- },
- ...baseParams
- ]
- };
- }
- }
- const init$c = () => {
- MxAiModule.regist(MxAiDrawCircleArc);
- };
- function computePolygonVerticesFromMidpoint(centerPoint = new mxcad2.McGePoint3d(), edgeMidPoint = new mxcad2.McGePoint3d(), sides = 3) {
- const midX = edgeMidPoint.x;
- const midY = edgeMidPoint.y;
- const centerX = centerPoint.x;
- const centerY = centerPoint.y;
- const numberOfSides = Math.max(3, sides);
- const distanceToCenter = Math.sqrt(__pow(midX - centerX, 2) + __pow(midY - centerY, 2));
- const radius = distanceToCenter / Math.cos(Math.PI / numberOfSides);
- const startAngle = Math.atan2(midY - centerY, midX - centerX) - Math.PI / numberOfSides;
- const vertices = [];
- for (let i2 = 0; i2 < numberOfSides; i2++) {
- const angle = startAngle + i2 * 2 * Math.PI / numberOfSides;
- const x = centerX + radius * Math.cos(angle);
- const y = centerY + radius * Math.sin(angle);
- vertices.push(new mxcad2.McGePoint3d(x, y));
- }
- return vertices;
- }
- function computeRegularPolygonVertices(centerPoint = new mxcad2.McGePoint3d(), vertexPoint = new mxcad2.McGePoint3d(), sides = 3) {
- const verticesArray = [];
- sides = Math.max(3, sides);
- verticesArray.push(vertexPoint);
- const angleIncrement = Math.PI * 2 / sides;
- for (let i2 = 1; i2 < sides; i2++) {
- const cosValue = Math.cos(angleIncrement * i2), sinValue = Math.sin(angleIncrement * i2);
- const startPt = centerPoint.clone();
- const endPt = vertexPoint.clone();
- const deltaX = endPt.x - startPt.x;
- const deltaY = endPt.y - startPt.y;
- const newX = deltaX * cosValue - deltaY * sinValue + startPt.x;
- const newY = deltaX * sinValue + deltaY * cosValue + startPt.y;
- const point = new mxcad2.McGePoint3d(newX, newY);
- verticesArray.push(point);
- }
- return verticesArray;
- }
- function computePolygonVerticesFromEdge(startPoint, endPoint, sides) {
- let dx = endPoint.x - startPoint.x;
- let dy = endPoint.y - startPoint.y;
- let length = Math.sqrt(dx * dx + dy * dy);
- let angle = Math.atan2(dy, dx);
- let angleIncrement = 2 * Math.PI / Math.max(3, sides);
- let polygonVertices = [startPoint, endPoint];
- for (let i2 = 0; i2 < sides; i2++) {
- let x = startPoint.x + length * Math.cos(angle + i2 * angleIncrement);
- let y = startPoint.y + length * Math.sin(angle + i2 * angleIncrement);
- startPoint = new mxcad2.McGePoint3d(x, y);
- polygonVertices.push(startPoint);
- }
- return polygonVertices;
- }
- class MxAiDrawPolygon {
- call(param) {
- return __async(this, null, function* () {
- mxcad2.MxCpp.getCurrentMxCAD().newFile();
- console.log(param);
- let { isDrawToCenter, sideNum, startPoint, endPoint, radius, centerPoint, isTangentToTheCircle } = param;
- if (!sideNum) {
- const getInt = new mxcad2.MxCADUiPrInt();
- getInt.setMessage("输入边的数目<5>");
- getInt.setKeyWords("");
- getInt.clearLastInputPoint();
- sideNum = (yield getInt.go()) || 5;
- }
- if (isDrawToCenter) {
- if (!centerPoint) {
- const getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.setMessage("\n指定正多变形的中心点");
- getPoint.setKeyWords("");
- getPoint.clearLastInputPoint();
- centerPoint = yield getPoint.go();
- if (!centerPoint)
- return;
- } else {
- centerPoint = parsePoint(centerPoint);
- }
- let vet = mxcad2.McGeVector3d.kXAxis;
- let vertexPoint;
- if (!radius) {
- const getPoint = new mxcad2.MxCADUiPrDist();
- getPoint.setMessage(mxcad2._ML_String("MxAiDrawPolygon_radius", "指定圆的半径"));
- getPoint.setKeyWords("");
- getPoint.setBasePt(centerPoint);
- getPoint.setUserDraw((pt, pw) => {
- if (isTangentToTheCircle) {
- const _radius2 = pt.distanceTo(centerPoint);
- vet = pt.sub(centerPoint);
- const midPoint = centerPoint.clone().addvec(pt.sub(centerPoint).normalize().mult(_radius2));
- const points = computePolygonVerticesFromMidpoint(centerPoint, midPoint, sideNum);
- const polygon2 = new mxcad2.McDbPolyline();
- points.forEach((point) => {
- polygon2.addVertexAt(point);
- });
- polygon2.isClosed = true;
- pw.drawMcDbEntity(polygon2);
- } else {
- vertexPoint = pt;
- const polygon2 = new mxcad2.McDbPolyline();
- computeRegularPolygonVertices(centerPoint, pt, sideNum).forEach((point) => {
- polygon2.addVertexAt(point);
- });
- polygon2.isClosed = true;
- pw.drawMcDbEntity(polygon2);
- }
- });
- const _radius = yield getPoint.go();
- if (!_radius)
- return;
- radius = _radius;
- }
- const polygon = new mxcad2.McDbPolyline();
- polygon.isClosed = true;
- if (isTangentToTheCircle) {
- const midPoint = centerPoint.clone().addvec(vet.normalize().mult(radius));
- const points = computePolygonVerticesFromMidpoint(centerPoint, midPoint, sideNum);
- points.forEach((point) => {
- polygon.addVertexAt(point);
- });
- } else {
- if (!vertexPoint) {
- const vet2 = mxcad2.McGeVector3d.kXAxis.clone().rotateBy(Math.PI / sideNum).mult(radius);
- vertexPoint = centerPoint.clone().addvec(vet2);
- }
- computeRegularPolygonVertices(centerPoint, vertexPoint, sideNum).forEach((point) => {
- polygon.addVertexAt(point);
- });
- }
- mxcad2.MxCpp.getCurrentMxCAD().drawEntity(polygon);
- } else {
- const createStarEndPointPolygon = (currentPoint) => {
- const pPolyline = new mxcad2.McDbPolyline();
- const points = computePolygonVerticesFromEdge(startPoint, currentPoint, sideNum || 5);
- points.forEach((point) => {
- pPolyline.addVertexAt(point);
- });
- pPolyline.isClosed = true;
- return pPolyline;
- };
- if (!startPoint) {
- const getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.clearLastInputPoint();
- getPoint.setMessage("\n指定边的第一个端点");
- getPoint.setKeyWords("");
- startPoint = yield getPoint.go();
- if (!startPoint)
- return;
- getPoint.setUserDraw((currentPoint, pWorldDraw) => {
- pWorldDraw.drawMcDbEntity(createStarEndPointPolygon(currentPoint));
- });
- } else {
- startPoint = parsePoint(startPoint);
- }
- if (!endPoint) {
- const getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.setBasePt(startPoint);
- getPoint.setMessage("\n指定边的第二个端点");
- endPoint = yield getPoint.go();
- } else {
- endPoint = parsePoint(endPoint);
- }
- if (!endPoint)
- return;
- const polygon = createStarEndPointPolygon(endPoint);
- mxcad2.MxCpp.getCurrentMxCAD().drawEntity(polygon);
- }
- });
- }
- regist_data() {
- return {
- filename: "DrawPolygon.json",
- name: "draw_polygon",
- description: "绘制正多边形",
- params: [
- {
- name: "isDrawToCenter",
- description: "是否用圆绘制多边形",
- "type": "boolean",
- "required": true
- },
- {
- name: "sideNum",
- description: "边数",
- type: "int",
- "required": true
- },
- {
- name: "startPoint",
- description: "边绘制提供开始点",
- "type": "tuple[float, float]",
- "required": true
- },
- {
- name: "endPoint",
- description: "边绘制提供结束点",
- "type": "tuple[float, float]",
- "required": true
- },
- {
- name: "radius",
- description: "圆的半径",
- type: "number",
- "required": true
- },
- {
- name: "centerPoint",
- description: "圆心",
- "type": "tuple[float, float]",
- "required": true
- },
- {
- name: "isTangentToTheCircle",
- description: "外切于圆",
- "type": "boolean",
- "required": true
- }
- ]
- };
- }
- }
- const init$b = () => {
- MxAiModule.regist(MxAiDrawPolygon);
- };
- const rotatePoint = (center, point, angle) => {
- const cosAngle = Math.cos(angle);
- const sinAngle = Math.sin(angle);
- const translatedX = point.x - center.x;
- const translatedY = point.y - center.y;
- const x = translatedX * cosAngle - translatedY * sinAngle + center.x;
- const y = translatedX * sinAngle + translatedY * cosAngle + center.y;
- const z = point.z;
- return new mxcad2.McGePoint3d(x, y, z);
- };
- const getRectPoints = (pt1, pt3, angle = 0) => {
- const center = new mxcad2.McGePoint3d((pt1.x + pt3.x) / 2, (pt1.y + pt3.y) / 2, (pt1.z + pt3.z) / 2);
- const pt2 = new mxcad2.McGePoint3d(pt1.x, pt3.y, pt1.z);
- const pt4 = new mxcad2.McGePoint3d(pt3.x, pt1.y, pt3.z);
- const rotatedPt2 = rotatePoint(center, pt2, angle);
- const rotatedPt4 = rotatePoint(center, pt4, angle);
- return [pt1, rotatedPt2, pt3, rotatedPt4];
- };
- const getQuadrant = (pt1, pt3) => {
- 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];
- };
- function calculateRoundedRectangleVertices(points, chamferDistance1, chamferDistance2) {
- if (chamferDistance1 === 0 && chamferDistance2 === 0)
- return points;
- const [pt1, pt2, pt3, pt4] = points;
- const width = pt1.distanceTo(pt4);
- const height = pt1.distanceTo(pt2);
- const [_, isPt3InQuadrant2, isPt3InQuadrant3, isPt3InQuadrant4] = getQuadrant(pt1, pt3);
- const chamferDistanceX = isPt3InQuadrant2 || isPt3InQuadrant3 ? -chamferDistance1 : chamferDistance1;
- const chamferDistanceY = isPt3InQuadrant3 || isPt3InQuadrant4 ? -chamferDistance2 : chamferDistance2;
- if (width - Math.abs(chamferDistanceX) * 2 <= 0)
- return points;
- if (height - Math.abs(chamferDistanceY) * 2 <= 0)
- return points;
- const chamferedPt1 = new mxcad2.McGePoint3d(pt1.x + chamferDistanceX, pt1.y, pt1.z);
- const chamferedPt2 = new mxcad2.McGePoint3d(pt1.x, pt1.y + chamferDistanceY, pt1.z);
- const chamferedPt3 = new mxcad2.McGePoint3d(pt2.x, pt2.y - chamferDistanceY, pt2.z);
- const chamferedPt4 = new mxcad2.McGePoint3d(pt2.x + chamferDistanceX, pt2.y, pt2.z);
- const chamferedPt5 = new mxcad2.McGePoint3d(pt3.x - chamferDistanceX, pt3.y, pt3.z);
- const chamferedPt6 = new mxcad2.McGePoint3d(pt3.x, pt2.y - chamferDistanceY, pt3.z);
- const chamferedPt7 = new mxcad2.McGePoint3d(pt4.x, pt4.y + chamferDistanceY, pt4.z);
- const chamferedPt8 = new mxcad2.McGePoint3d(pt4.x - chamferDistanceX, pt4.y, pt4.z);
- const chamferedPolygon = [
- chamferedPt1,
- chamferedPt2,
- chamferedPt3,
- chamferedPt4,
- chamferedPt5,
- chamferedPt6,
- chamferedPt7,
- chamferedPt8
- ];
- return chamferedPolygon;
- }
- function CMxDrawPolylineDragArcDraw_CalcArcBulge(firstPoint, nextPoint, vecArcTangent) {
- if (firstPoint.isEqualTo(nextPoint))
- return 0;
- let midPt = firstPoint.c().addvec(nextPoint.c().sub(firstPoint).mult(0.5));
- let vecMid = nextPoint.c().sub(firstPoint);
- vecMid.rotateBy(Math.PI / 2, mxcad2.McGeVector3d.kZAxis);
- let tmpMidLine = new mxcad2.McDbLine(midPt, midPt.c().addvec(vecMid));
- let vecVertical = vecArcTangent.c();
- vecVertical.rotateBy(Math.PI / 2, mxcad2.McGeVector3d.kZAxis);
- let tmpVerticalLine = new mxcad2.McDbLine(firstPoint, firstPoint.c().addvec(vecVertical));
- let aryPoint = tmpMidLine.IntersectWith(tmpVerticalLine, mxcad2.McDb.Intersect.kExtendBoth);
- if (aryPoint.isEmpty())
- return 0;
- let arcCenPoint = aryPoint.at(0);
- let dR = arcCenPoint.distanceTo(firstPoint);
- vecMid.normalize();
- vecMid.mult(dR);
- let arcMidPt1 = arcCenPoint.c().addvec(vecMid);
- let arcMidPt2 = arcCenPoint.c().subvec(vecMid);
- let vecArcDir1 = arcMidPt1.c().sub(firstPoint);
- let vecArcDir2 = arcMidPt2.c().sub(firstPoint);
- let arcMidPt = arcMidPt1;
- if (vecArcDir1.angleTo1(vecArcTangent) > vecArcDir2.angleTo1(vecArcTangent)) {
- arcMidPt = arcMidPt2;
- }
- return mxcad2.MxCADUtility.calcBulge(firstPoint, arcMidPt, nextPoint).val;
- }
- class MxAiDrawRect {
- call(param) {
- return __async(this, null, function* () {
- console.log(param);
- mxcad2.MxCpp.getCurrentMxCAD().newFile();
- let { pt1, pt2: pt3, chamfer1Length, chamfer2Length, filletRadius, lineWidth, area: area2, rectLength, rectWidth, rotationAngle } = param;
- const createRect = (pt12, pt32) => {
- const [_pt1, pt2, _pt3, pt4] = getRectPoints(pt12, pt32, rotationAngle);
- const rect2 = new mxcad2.McDbPolyline();
- rect2.addVertexAt(_pt1, 0, lineWidth, lineWidth);
- rect2.addVertexAt(pt2, 0, lineWidth, lineWidth);
- rect2.addVertexAt(_pt3, 0, lineWidth, lineWidth);
- rect2.addVertexAt(pt4, 0, lineWidth, lineWidth);
- rect2.isClosed = true;
- if (lineWidth)
- rect2.constantWidth = lineWidth;
- return rect2;
- };
- const create = (pt12, pt32) => {
- let rect2;
- if (filletRadius) {
- const points = calculateRoundedRectangleVertices(getRectPoints(pt12, pt32, rotationAngle), filletRadius, filletRadius);
- const [_, isPt3InQuadrant2, isPt3InQuadrant3, isPt3InQuadrant4] = getQuadrant(pt12, pt32);
- if (points.length === 8) {
- if (!rect2)
- rect2 = new mxcad2.McDbPolyline();
- const addArc = (startPoint, endPoint, key) => {
- let vecArcTangent = new mxcad2.McGeVector3d(key);
- const bulge = CMxDrawPolylineDragArcDraw_CalcArcBulge(startPoint, endPoint, vecArcTangent);
- rect2.addVertexAt(startPoint, bulge, lineWidth, lineWidth);
- rect2.addVertexAt(endPoint, 0, lineWidth, lineWidth);
- };
- const vec1 = new mxcad2.McGeVector3d(-1, 0);
- const vec2 = new mxcad2.McGeVector3d(0, 1);
- const vec3 = new mxcad2.McGeVector3d(1, 0);
- const vec4 = new mxcad2.McGeVector3d(0, -1);
- if (isPt3InQuadrant4) {
- vec2.y = -1;
- vec3.x = 1;
- vec4.y = 1;
- }
- if (isPt3InQuadrant2) {
- vec1.x = 1;
- vec2.y = 1;
- vec3.x = -1;
- vec4.y = -1;
- }
- if (isPt3InQuadrant3) {
- vec1.x = 1;
- vec2.y = -1;
- vec3.x = -1;
- vec4.y = 1;
- }
- addArc(points[0], points[1], vec1);
- addArc(points[2], points[3], vec2);
- addArc(points[4], points[5], vec3);
- addArc(points[6], points[7], vec4);
- rect2.isClosed = true;
- }
- } else if (chamfer1Length || chamfer2Length) {
- if (!rect2)
- rect2 = new mxcad2.McDbPolyline();
- const points = calculateRoundedRectangleVertices(getRectPoints(pt12, pt32, rotationAngle), chamfer1Length || chamfer2Length, chamfer2Length || chamfer1Length);
- points.forEach((point) => {
- rect2.addVertexAt(point);
- });
- rect2.isClosed = true;
- }
- if (!rect2)
- rect2 = createRect(pt12, pt32);
- if (lineWidth)
- rect2.constantWidth = lineWidth;
- return rect2;
- };
- if (!pt1) {
- const getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.setMessage("指定第一个角点");
- getPoint.setKeyWords("");
- pt1 = yield getPoint.go();
- if (!pt1)
- return;
- } else {
- pt1 = parsePoint(pt1);
- }
- if (area2) {
- if (rectLength) {
- rectWidth = area2 / rectLength;
- }
- if (rectWidth) {
- rectLength = area2 / rectWidth;
- }
- }
- if (rectLength && rectWidth) {
- pt3 = new mxcad2.McGePoint3d(pt1.x + rectWidth, pt1.y + rectLength, 0);
- }
- if (!pt3) {
- const getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.setMessage("指定第二个角点");
- getPoint.setKeyWords("");
- getPoint.setUserDraw((pt, pw) => {
- pw.drawMcDbEntity(create(pt1, pt));
- });
- pt3 = yield getPoint.go();
- if (!pt3)
- return;
- } else {
- pt3 = parsePoint(pt3);
- }
- const rect = create(pt1, pt3);
- mergeBaseMcDbEntityProps(rect, param);
- mxcad2.MxCpp.getCurrentMxCAD().drawEntity(rect);
- });
- }
- regist_data() {
- return {
- filename: "drawRect.json",
- name: "draw_rect",
- description: "根据一些信息绘制矩形",
- params: [
- {
- name: "pt1",
- description: "一个对角点",
- "type": "tuple[float, float]",
- "required": true
- },
- {
- name: "pt2",
- description: "另一个对角点",
- "type": "tuple[float, float]",
- "required": true
- },
- {
- name: "lineWidth",
- description: "矩形线的宽",
- "type": "float",
- "required": true
- },
- {
- name: "filletRadius",
- description: "圆角半径",
- "type": "float",
- "required": true
- },
- {
- name: "chamfer1Length",
- description: "第一个倒角距离",
- "type": "float",
- "required": true
- },
- {
- name: "chamfer2Length",
- description: "第二个倒角距离",
- "type": "float",
- "required": true
- },
- {
- name: "rectLength",
- description: "长度",
- "type": "float",
- "required": true
- },
- {
- name: "rectWidth",
- description: "矩形宽度",
- "type": "float",
- "required": true
- },
- {
- name: "area",
- description: "面积",
- "type": "float",
- "required": true
- },
- {
- name: "rotationAngle",
- description: "旋转角度",
- "type": "float",
- "required": true
- },
- ...baseParams
- ]
- };
- }
- }
- function init$a() {
- MxAiModule.regist(MxAiDrawRect);
- }
- const createEllipse = (endPoint1, endPoint2, halfAxisLength, startAngle, endAngle) => {
- const ellipse = new mxcad2.McDbEllipse();
- const center = new mxcad2.McGePoint3d((endPoint1.x + endPoint2.x) / 2, (endPoint2.y + endPoint2.y) / 2);
- const majorAxis = endPoint1.sub(endPoint2);
- const minorAxis = majorAxis;
- const xRadius = endPoint1.distanceTo(endPoint2) / 2;
- const yRadius = halfAxisLength / 2;
- const radiusRatio = yRadius / xRadius;
- ellipse.center = center;
- ellipse.majorAxis = majorAxis;
- ellipse.minorAxis = minorAxis;
- ellipse.radiusRatio = radiusRatio;
- ellipse.startAngle = startAngle;
- ellipse.endAngle = endAngle;
- return ellipse;
- };
- class MxAiDrawEllipse {
- call(param) {
- return __async(this, null, function* () {
- let { endPoint1, endPoint2, halfAxisLength } = param;
- const mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.newFile();
- const getPoint = new mxcad2.MxCADUiPrPoint();
- const getDist = new mxcad2.MxCADUiPrDist();
- if (endPoint1)
- endPoint1 = parsePoint(endPoint1);
- if (endPoint2)
- endPoint2 = parsePoint(endPoint2);
- if (!endPoint1) {
- getPoint.setMessage("指定椭圆的轴端点1");
- getPoint.setKeyWords("");
- getPoint.setUserDraw((pt, pw) => {
- if (!endPoint2)
- return;
- if (!halfAxisLength)
- return;
- pw.drawMcDbEntity(createEllipse(pt, endPoint2, halfAxisLength, 0, Math.PI * 2));
- });
- endPoint1 = yield getPoint.go();
- if (!endPoint1)
- return;
- }
- if (!endPoint2) {
- getPoint.setMessage("指定椭圆的轴端点2");
- getPoint.setKeyWords("");
- getPoint.setUserDraw((pt, pw) => {
- if (!endPoint1)
- return;
- if (!halfAxisLength)
- return;
- pw.drawMcDbEntity(createEllipse(endPoint1, pt, halfAxisLength, 0, Math.PI * 2));
- });
- endPoint2 = yield getPoint.go();
- if (!endPoint2)
- return;
- }
- if (!halfAxisLength) {
- getDist.setMessage("指定半轴长度");
- getDist.setKeyWords("");
- const center = new mxcad2.McGePoint3d((endPoint1.x + endPoint2.x) / 2, (endPoint2.y + endPoint2.y) / 2);
- getDist.setBasePt(center);
- getDist.setUserDraw((pt, pw) => {
- if (!endPoint1)
- return;
- pw.drawMcDbEntity(createEllipse(endPoint1, endPoint2, center.distanceTo(pt), 0, Math.PI * 2));
- });
- halfAxisLength = yield getDist.go();
- if (!halfAxisLength)
- return;
- }
- const ellipse = createEllipse(endPoint1, endPoint2, halfAxisLength, 0, Math.PI * 2);
- mergeBaseMcDbEntityProps(ellipse, param);
- mxcad$1.drawEntity(ellipse);
- });
- }
- regist_data() {
- return {
- filename: "drawellipse.json",
- name: "draw_ellipse",
- description: "绘制椭圆",
- params: [
- {
- name: "endPoint1",
- description: "椭圆端点1",
- "type": "tuple[float, float]",
- "required": true
- },
- {
- name: "endPoint2",
- description: "椭圆端点2",
- "type": "tuple[float, float]",
- "required": true
- },
- {
- name: "halfAxisLength",
- description: "半轴长度",
- "type": "float",
- "required": true
- },
- ...baseParams
- ]
- };
- }
- }
- class MxAiDrawEllipseArc {
- call(param) {
- return __async(this, null, function* () {
- let { endPoint1, endPoint2, halfAxisLength, startAngle, endAngle } = param;
- const mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.newFile();
- const getPoint = new mxcad2.MxCADUiPrPoint();
- const getDist = new mxcad2.MxCADUiPrDist();
- if (endPoint1)
- endPoint1 = parsePoint(endPoint1);
- if (endPoint2)
- endPoint2 = parsePoint(endPoint2);
- if (startAngle)
- startAngle = startAngle * (Math.PI / 180);
- if (endAngle)
- endAngle = endAngle * (Math.PI / 180);
- if (!endPoint1) {
- getPoint.setMessage("指定椭圆的轴端点1");
- getPoint.setKeyWords("");
- getPoint.setUserDraw((pt, pw) => {
- if (!endPoint2)
- return;
- if (!halfAxisLength)
- return;
- pw.drawMcDbEntity(createEllipse(pt, endPoint2, halfAxisLength, 0, Math.PI * 2));
- });
- endPoint1 = yield getPoint.go();
- if (!endPoint1)
- return;
- }
- if (!endPoint2) {
- getPoint.setMessage("指定椭圆的轴端点2");
- getPoint.setKeyWords("");
- getPoint.setUserDraw((pt, pw) => {
- if (!endPoint1)
- return;
- if (!halfAxisLength)
- return;
- pw.drawMcDbEntity(createEllipse(endPoint1, pt, halfAxisLength, 0, Math.PI * 2));
- });
- endPoint2 = yield getPoint.go();
- if (!endPoint2)
- return;
- }
- const center = new mxcad2.McGePoint3d((endPoint1.x + endPoint2.x) / 2, (endPoint2.y + endPoint2.y) / 2);
- if (!halfAxisLength) {
- getDist.setMessage("指定半轴长度");
- getDist.setKeyWords("");
- getDist.setBasePt(center);
- getDist.setUserDraw((pt, pw) => {
- if (!endPoint1)
- return;
- pw.drawMcDbEntity(createEllipse(endPoint1, endPoint2, center.distanceTo(pt), 0, Math.PI * 2));
- });
- halfAxisLength = yield getDist.go();
- if (!halfAxisLength)
- return;
- }
- const angle = angleTo(center.x, center.y, endPoint1.x, endPoint1.y);
- if (!startAngle) {
- getDist.setMessage(mxcad2._ML_String("EllipticalArc_startAngle", "指定起点角度"));
- getDist.setKeyWords("");
- getDist.setUserDraw((currentPoint, pWorldDraw) => {
- startAngle = angleTo(center.x, center.y, currentPoint.x, currentPoint.y) - angle - Math.PI;
- pWorldDraw.drawMcDbEntity(createEllipse(endPoint1, endPoint2, halfAxisLength, startAngle, Math.PI * 2));
- });
- const val = yield getDist.go();
- if (!val)
- return;
- if (getDist.getDetailedResult() == mxdraw.DetailedResult.kCoordIn) {
- startAngle = val * (180 / Math.PI);
- }
- }
- if (!endAngle) {
- getDist.setLastInputPoint(center);
- getDist.setMessage(mxcad2._ML_String("EllipticalArc_endAngle", "指定端点角度"));
- getDist.setKeyWords("");
- getDist.setUserDraw((currentPoint, pWorldDraw) => {
- endAngle = angleTo(center.x, center.y, currentPoint.x, currentPoint.y) - angle - Math.PI;
- pWorldDraw.drawMcDbEntity(createEllipse(endPoint1, endPoint2, halfAxisLength, startAngle, endAngle));
- });
- const val1 = yield getDist.go();
- if (!val1)
- return;
- if (getDist.getDetailedResult() === mxdraw.DetailedResult.kCoordIn) {
- endAngle = val1 * (180 / Math.PI);
- }
- }
- const ellipse = createEllipse(endPoint1, endPoint2, halfAxisLength, startAngle, endAngle);
- mergeBaseMcDbEntityProps(ellipse, param);
- mxcad$1.drawEntity(ellipse);
- });
- }
- regist_data() {
- return {
- filename: "drawellipseArc.json",
- name: "draw_ellipse_arc",
- description: "绘制椭圆弧",
- params: [
- {
- name: "endPoint1",
- description: "椭圆弧端点1",
- "type": "tuple[float, float]",
- "required": true
- },
- {
- name: "endPoint2",
- description: "椭圆弧端点2",
- "type": "tuple[float, float]",
- "required": true
- },
- {
- name: "halfAxisLength",
- description: "半轴长度",
- "type": "float",
- "required": true
- },
- {
- name: "startAngle",
- description: "开始角度",
- "type": "float",
- "required": true
- },
- {
- name: "endAngle",
- description: "结束角度",
- "type": "float",
- "required": true
- },
- ...baseParams
- ]
- };
- }
- }
- const init$9 = () => {
- MxAiModule.regist(MxAiDrawEllipse);
- MxAiModule.regist(MxAiDrawEllipseArc);
- };
- const _WallLine = class _WallLine {
- constructor(start, end, width = 50) {
- this.width = 50;
- this.isDraw = false;
- this.update(start, end, width);
- }
- update(start, end, width = this.width) {
- let dirVector = start.clone().sub(end).normalize();
- dirVector = new mxcad2.McGeVector3d(-dirVector.y, dirVector.x, 0).mult(width / 2);
- const negateDirVector = dirVector.clone().negate();
- this.outsidePoints = [start.clone().addvec(dirVector), end.clone().addvec(dirVector)];
- this.insidePoints = [start.clone().addvec(negateDirVector), end.clone().addvec(negateDirVector)];
- this.width = width;
- this.startPoint = start.clone();
- this.endPoint = end.clone();
- if (!this.outsideLine) {
- this.outsideLine = new mxcad2.McDbLine(this.outsidePoints[0], this.outsidePoints[1]);
- } else {
- this.outsideLine.startPoint = this.outsidePoints[0];
- this.outsideLine.endPoint = this.outsidePoints[1];
- }
- if (!this.insideLine) {
- this.insideLine = new mxcad2.McDbLine(this.insidePoints[0], this.insidePoints[1]);
- } else {
- this.insideLine.startPoint = this.insidePoints[0];
- this.insideLine.endPoint = this.insidePoints[1];
- }
- if (!this.startClosedLine) {
- this.startClosedLine = new mxcad2.McDbLine(this.outsidePoints[0], this.insidePoints[0]);
- } else {
- this.startClosedLine.startPoint = this.outsidePoints[0];
- this.startClosedLine.endPoint = this.insidePoints[0];
- }
- if (!this.endClosedLine) {
- this.endClosedLine = new mxcad2.McDbLine(this.outsidePoints[1], this.insidePoints[1]);
- } else {
- this.endClosedLine.startPoint = this.outsidePoints[1];
- this.endClosedLine.endPoint = this.insidePoints[1];
- }
- }
- clone() {
- const line = new _WallLine(this.startPoint, this.endPoint, this.width);
- line.insideLine = this.insideLine.clone();
- line.outsideLine = this.outsideLine.clone();
- return line;
- }
- hiddenStartClosedLine() {
- this.startClosedLine.visible = false;
- }
- hiddenEndClosedLine() {
- this.endClosedLine.visible = false;
- }
- /** 开始点闭合线与比较墙体内线的交点 (开始-内)*/
- getClosedStartLineToDiffWallInsideLineIntersectionPoint(diffLine, is = false) {
- return this.startClosedLine.visible ? findIntersection(diffLine.insideLine.startPoint, diffLine.insideLine.endPoint, this.startClosedLine.startPoint, this.startClosedLine.endPoint, is) : null;
- }
- /** 开始点闭合线与比较墙体外线的交点 (开始-外)*/
- getClosedStartLineToDiffWallOutsideLineIntersectionPoint(diffLine, is = false) {
- return this.startClosedLine.visible ? findIntersection(diffLine.outsideLine.startPoint, diffLine.outsideLine.endPoint, this.startClosedLine.startPoint, this.startClosedLine.endPoint, is) : null;
- }
- /** 结束点闭合线与比较墙体内线的交点 (结束-内)*/
- getClosedEndLineToDiffWallInsideLineIntersectionPoint(diffLine, is = false) {
- return this.endClosedLine.visible ? findIntersection(diffLine.insideLine.startPoint, diffLine.insideLine.endPoint, this.endClosedLine.startPoint, this.endClosedLine.endPoint, is) : null;
- }
- /** 开始点闭合线与比较墙体外线的交点 (结束-外)*/
- getClosedEndLineToDiffWallOutsideLineIntersectionPoint(diffLine, is = false) {
- return this.endClosedLine.visible ? findIntersection(diffLine.outsideLine.startPoint, diffLine.outsideLine.endPoint, this.endClosedLine.startPoint, this.endClosedLine.endPoint, is) : null;
- }
- /** 内线与比较墙体的内线交点 (内-内)*/
- getInsideToDiffInsideIntersectionPoint(diffLine, is = false) {
- return findIntersection(diffLine.insideLine.startPoint, diffLine.insideLine.endPoint, this.insideLine.startPoint, this.insideLine.endPoint, is);
- }
- /** 外线与比较墙体的外线交点 (外-外)*/
- getOutsideToDiffOutsideIntersectionPoint(diffLine, is = false) {
- return findIntersection(diffLine.outsideLine.startPoint, diffLine.outsideLine.endPoint, this.outsideLine.startPoint, this.outsideLine.endPoint, is);
- }
- /** 内线与比较墙体的外线交点 (内-外)*/
- getInsideToDiffOutsideIntersectionPoint(diffLine, is = false) {
- return findIntersection(diffLine.outsideLine.startPoint, diffLine.outsideLine.endPoint, this.insideLine.startPoint, this.insideLine.endPoint, is);
- }
- /** 外线与比较墙体的内线交点 (外-内)*/
- getOutsideToDiffInsideIntersectionPoint(diffLine, is = false) {
- return findIntersection(diffLine.insideLine.startPoint, diffLine.insideLine.endPoint, this.outsideLine.startPoint, this.outsideLine.endPoint, is);
- }
- /** 开始闭合线与比较墙体开始闭合线交点 (开始-开始)*/
- getClosedStartLineToDiffLineClosedStartLineIntersectionPoint(diffLine, is = false) {
- return this.startClosedLine.visible ? findIntersection(diffLine.startClosedLine.startPoint, diffLine.startClosedLine.endPoint, this.startClosedLine.startPoint, this.startClosedLine.endPoint, is) : null;
- }
- /** 开始闭合线与比较墙体结束闭合线交点 (开始-结束)*/
- getClosedStartLineToDiffLineClosedEndLineIntersectionPoint(diffLine, is = false) {
- return this.startClosedLine.visible ? findIntersection(diffLine.endClosedLine.startPoint, diffLine.endClosedLine.endPoint, this.startClosedLine.startPoint, this.startClosedLine.endPoint, is) : null;
- }
- /** 结束点闭合线与比较墙体开始闭合线交点 (结束-开始)*/
- getClosedEndLineToDiffLineClosedStartLineIntersectionPoint(diffLine, is = false) {
- return this.endClosedLine.visible ? findIntersection(diffLine.startClosedLine.startPoint, diffLine.startClosedLine.endPoint, this.endClosedLine.startPoint, this.endClosedLine.endPoint, is) : null;
- }
- /** 结束点闭合线与比较墙体结束点闭合线交点 (结束-结束)*/
- getClosedEndLineToDiffLineClosedEndLineIntersectionPoint(diffLine, is = false) {
- return this.endClosedLine.visible ? findIntersection(diffLine.endClosedLine.startPoint, diffLine.endClosedLine.endPoint, this.endClosedLine.startPoint, this.endClosedLine.endPoint, is) : null;
- }
- // 是否拐角
- isCorner(diffLine) {
- const v = diffLine.startPoint.sub(diffLine.endPoint).normalize();
- const v1 = v.clone().mult(diffLine.width);
- const v2 = v.clone().mult(-diffLine.width);
- const pt1 = diffLine.insideLine.startPoint.clone().addvec(v1);
- const pt2 = diffLine.insideLine.startPoint.clone().addvec(v2);
- const pt3 = diffLine.outsideLine.startPoint.clone().addvec(v2);
- const pt4 = diffLine.outsideLine.startPoint.clone().addvec(v1);
- const pt5 = diffLine.insideLine.endPoint.clone().addvec(v1);
- const pt6 = diffLine.insideLine.endPoint.clone().addvec(v2);
- const pt7 = diffLine.outsideLine.endPoint.clone().addvec(v2);
- const pt8 = diffLine.outsideLine.endPoint.clone().addvec(v1);
- const start = insidePolygon([pt1, pt2, pt3, pt4], this.startPoint);
- const end = insidePolygon([pt1, pt2, pt3, pt4], this.endPoint);
- const start1 = insidePolygon([pt5, pt6, pt7, pt8], this.startPoint);
- const end1 = insidePolygon([pt5, pt6, pt7, pt8], this.endPoint);
- return [{
- start,
- end
- }, {
- start: start1,
- end: end1
- }];
- }
- // 处理拐角
- handlingCorners(diffLine) {
- const [startCorner, endCorner] = this.isCorner(diffLine);
- if (endCorner.start) {
- this.outsideLine.startPoint = diffLine.outsideLine.endPoint = this.getOutsideToDiffOutsideIntersectionPoint(diffLine, true);
- this.insideLine.startPoint = diffLine.insideLine.endPoint = this.getInsideToDiffInsideIntersectionPoint(diffLine, true);
- this.hiddenStartClosedLine();
- diffLine.hiddenEndClosedLine();
- return;
- } else if (endCorner.end) {
- this.outsideLine.endPoint = diffLine.insideLine.endPoint = this.getOutsideToDiffInsideIntersectionPoint(diffLine, true);
- this.insideLine.endPoint = diffLine.outsideLine.endPoint = this.getInsideToDiffOutsideIntersectionPoint(diffLine, true);
- this.hiddenEndClosedLine();
- diffLine.hiddenEndClosedLine();
- return;
- } else if (startCorner.start) {
- this.insideLine.startPoint = diffLine.outsideLine.startPoint = this.getInsideToDiffOutsideIntersectionPoint(diffLine, true);
- this.outsideLine.startPoint = diffLine.insideLine.startPoint = this.getOutsideToDiffInsideIntersectionPoint(diffLine, true);
- this.hiddenStartClosedLine();
- diffLine.hiddenStartClosedLine();
- return;
- } else if (startCorner.end) {
- this.outsideLine.endPoint = diffLine.outsideLine.startPoint = this.getOutsideToDiffOutsideIntersectionPoint(diffLine, true);
- this.insideLine.endPoint = diffLine.insideLine.startPoint = this.getInsideToDiffInsideIntersectionPoint(diffLine, true);
- this.hiddenEndClosedLine();
- diffLine.hiddenStartClosedLine();
- return;
- }
- }
- // 交集处理
- processingIntersection() {
- const diffUpdate = [];
- _WallLine.lines.forEach((diffLine) => {
- const point = this.getInsideToDiffInsideIntersectionPoint(diffLine);
- const point1 = this.getInsideToDiffOutsideIntersectionPoint(diffLine);
- const point2 = this.getOutsideToDiffOutsideIntersectionPoint(diffLine);
- const point3 = this.getOutsideToDiffInsideIntersectionPoint(diffLine);
- if (point || point1 || point2 || point3) {
- diffUpdate.push({
- diffLine,
- intersectionPoints: [point, point1, point2, point3]
- });
- }
- });
- diffUpdate.forEach(({ diffLine, intersectionPoints }) => {
- const [startCorner, endCorner] = this.isCorner(diffLine);
- startCorner.end || startCorner.start || endCorner.start || endCorner.start;
- const [ii, io, oo, oi] = intersectionPoints;
- const points = [diffLine.insideLine.startPoint, diffLine.insideLine.endPoint, diffLine.outsideLine.endPoint, diffLine.outsideLine.startPoint];
- insidePolygon(points, this.startPoint);
- insidePolygon(points, this.endPoint);
- if (ii && io && oo && oi) {
- const point = findIntersection(this.startPoint, this.endPoint, diffLine.startPoint, diffLine.endPoint);
- const wall1 = new _WallLine(this.startPoint, point, this.width);
- const wall2 = new _WallLine(point, this.endPoint, this.width);
- const diffWall1 = new _WallLine(diffLine.startPoint, point, diffLine.width);
- const diffWall2 = new _WallLine(point, diffLine.endPoint, diffLine.width);
- wall1.insideLine.startPoint = this.insideLine.startPoint;
- wall1.outsideLine.startPoint = this.outsideLine.startPoint;
- wall2.insideLine.endPoint = this.insideLine.endPoint;
- wall2.outsideLine.endPoint = this.outsideLine.endPoint;
- diffLine.remove();
- this.remove();
- wall1.draw();
- wall2.draw();
- diffWall1.draw();
- diffWall2.draw();
- } else if (oo && io || ii && oi) {
- const point = findIntersection(this.startPoint, this.endPoint, diffLine.startPoint, diffLine.endPoint, true);
- const wall1 = new _WallLine(diffLine.startPoint, point, diffLine.width);
- wall1.hiddenEndClosedLine();
- const wall2 = new _WallLine(point, diffLine.endPoint, diffLine.width);
- wall2.hiddenStartClosedLine();
- diffLine.remove();
- wall1.draw();
- wall2.draw();
- } else {
- if (diffUpdate.length === 1)
- return this.handlingCorners(diffLine);
- if (endCorner.start) {
- console.log("endCorner.start");
- if (oo) {
- diffLine.outsideLine.endPoint = this.outsideLine.startPoint = oo;
- }
- if (ii) {
- diffLine.insideLine.endPoint = this.insideLine.startPoint = ii;
- }
- this.hiddenStartClosedLine();
- diffLine.hiddenEndClosedLine();
- } else if (endCorner.end) {
- console.log("endCorner.end");
- if (oi) {
- diffLine.insideLine.endPoint = this.outsideLine.endPoint = oi;
- }
- if (io) {
- diffLine.outsideLine.endPoint = this.insideLine.endPoint = io;
- }
- this.hiddenEndClosedLine();
- diffLine.hiddenEndClosedLine();
- } else if (startCorner.start) {
- console.log("startCorner.start");
- if (io) {
- diffLine.outsideLine.startPoint = this.insideLine.startPoint = io;
- }
- if (oi) {
- diffLine.insideLine.startPoint = this.outsideLine.startPoint = oi;
- }
- diffLine.hiddenStartClosedLine();
- this.hiddenStartClosedLine();
- } else if (startCorner.end) {
- console.log("startCorner.end");
- if (oo) {
- diffLine.outsideLine.startPoint = this.outsideLine.endPoint = oo;
- }
- if (ii) {
- diffLine.insideLine.startPoint = this.insideLine.endPoint = ii;
- }
- diffLine.hiddenStartClosedLine();
- this.hiddenEndClosedLine();
- }
- }
- });
- }
- draw(isIntersection = true) {
- if (this.isDraw)
- return;
- const mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- if (this.outsideLine) {
- this.outsideLine.erase();
- }
- if (this.insideLine) {
- this.insideLine.erase();
- }
- if (!mxcad$1)
- return;
- this.outsideLine.trueColor = new mxcad2.McCmColor(255, 0, 0);
- this.outsideId = mxcad$1.drawEntity(this.outsideLine);
- this.insideLine.trueColor = new mxcad2.McCmColor(0, 255, 255);
- this.insideId = mxcad$1.drawEntity(this.insideLine);
- const outsideLine = this.outsideId.getMcDbEntity();
- if (outsideLine)
- this.outsideLine = outsideLine;
- const insideLine = this.insideId.getMcDbEntity();
- if (insideLine)
- this.insideLine = insideLine;
- this.startClosedId = mxcad$1.drawEntity(this.startClosedLine);
- this.endClosedId = mxcad$1.drawEntity(this.endClosedLine);
- const startClosedLine = this.startClosedId.getMcDbEntity();
- if (startClosedLine)
- this.startClosedLine = startClosedLine;
- const endClosedLine = this.endClosedId.getMcDbEntity();
- if (endClosedLine)
- this.endClosedLine = endClosedLine;
- mxcad$1.updateDisplay();
- _WallLine.lines.add(this);
- this.isDraw = true;
- if (isIntersection)
- this.processingIntersection();
- }
- remove() {
- this.endClosedId && this.endClosedId.erase();
- this.startClosedId && this.startClosedId.erase();
- this.insideId && this.insideId.erase();
- this.outsideId && this.outsideId.erase();
- _WallLine.lines.delete(this);
- }
- };
- _WallLine.lines = /* @__PURE__ */ new Set();
- let WallLine = _WallLine;
- class Wall {
- call(param) {
- if (param && param.points) {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- const points = parseParamPoints(param.points);
- if (points.length < 2)
- return;
- points.forEach((point, index) => {
- const nextLine = points[index + 1];
- if (!nextLine)
- return;
- const wall = new WallLine(point, nextLine, param.width);
- wall.draw();
- });
- mxcad$1.updateDisplay();
- }
- }
- regist_data() {
- return {
- filename: "drawWall.json",
- name: "drawWall",
- description: "根据坐标点合集绘制墙",
- params: [
- {
- name: "points",
- description: "绘制墙的坐标点",
- "type": "str",
- "required": true
- },
- {
- name: "width",
- description: "绘制墙的宽度",
- "type": "float",
- "required": false
- },
- ...baseParams
- ]
- };
- }
- }
- setTimeout(() => {
- let mxcad$1 = mxcad2.MxCpp.App.getCurrentMxCAD();
- 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, "树");
- }, 2e3);
- class Bock {
- call(param) {
- return __async(this, null, function* () {
- let mxcad$1 = mxcad2.MxCpp.App.getCurrentMxCAD();
- if (param.name) {
- const table = mxcad$1.getDatabase().getBlockTable();
- const blkrecId = table.get(param.name);
- if (!blkrecId)
- return;
- if (!blkrecId.isValid())
- return;
- let blkRef = new mxcad2.McDbBlockReference();
- blkRef.blockTableRecordId = blkrecId;
- let box = blkRef.getBoundingBox();
- let oldScale = 0;
- if (box.ret) {
- let dLen = box.maxPt.distanceTo(box.minPt);
- if (dLen > 1e-5) {
- oldScale = mxcad$1.getMxDrawObject().screenCoordLong2Doc(100) / dLen;
- blkRef.setScale(oldScale);
- }
- }
- blkRef.position = new mxcad2.McGePoint3d(param.pos[0], param.pos[1]);
- mxcad$1.drawEntity(blkRef);
- mxcad$1.updateDisplay();
- }
- });
- }
- regist_data() {
- return {
- filename: "insertBock.json",
- name: "insertBock",
- description: "放置插入某个物品",
- params: [
- {
- name: "name",
- description: "要放置插入的物品名称",
- "type": "str",
- "required": true
- },
- {
- name: "pos",
- description: "要放置插入物品的位置",
- "type": "tuple[float, float]",
- "required": true
- }
- ]
- };
- }
- }
- function init$8() {
- MxAiModule.regist(Wall);
- MxAiModule.regist(Bock);
- }
- class MxAiDrawText {
- call(param) {
- return __async(this, null, function* () {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- console.log(param);
- mxcad$1.newFile();
- let objId;
- const isMText = typeof param.isMText === "undefined" ? false : param.isMText;
- const createMText = () => {
- const mText = new mxcad2.McDbMText();
- mText.textHeight = param.textSize || 100;
- mText.location = param.textPos || new mxcad2.McGePoint3d();
- mText.contents = param.textString || "";
- return mText;
- };
- const createText = () => {
- const text = new mxcad2.McDbText();
- text.height = param.textSize || 100;
- text.textString = param.textString || "";
- text.position = param.textPos || new mxcad2.McGePoint3d();
- return text;
- };
- if (!param.textString) {
- const getStr = new mxcad2.MxCADUiPrString();
- getStr.setMessage("请输入文字");
- const text = yield getStr.go();
- if (!text)
- return;
- param.textString = text;
- }
- if (!param.textPos) {
- const getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.clearLastInputPoint();
- getPoint.setMessage("请指定文字位置");
- const point = yield getPoint.go();
- getPoint.setUserDraw((pt, pw) => {
- param.textPos = pt;
- if (isMText) {
- const mText = createMText();
- pw.drawMcDbEntity(mText);
- } else {
- const text = createText();
- pw.drawMcDbEntity(text);
- }
- });
- if (!point)
- return;
- param.textPos = point;
- } else {
- param.textPos = parsePoint(param.textPos);
- }
- if (!param.textSize) {
- const getDist = new mxcad2.MxCADUiPrPoint();
- getDist.clearLastInputPoint();
- getDist.setMessage("通过线段长度确定文字高度");
- const point = yield getDist.go();
- if (point) {
- getDist.setUserDraw((pt, pw) => {
- param.textSize = point.distanceTo(pt);
- if (isMText) {
- const mText = createMText();
- pw.drawMcDbEntity(mText);
- } else {
- const text = createText();
- pw.drawMcDbEntity(text);
- }
- });
- const point1 = yield getDist.go();
- if (point1) {
- param.textSize = point1.distanceTo(point);
- }
- }
- }
- if (isMText) {
- const mText = createMText();
- objId = mxcad$1.drawEntity(mText);
- } else {
- const text = createText();
- objId = mxcad$1.drawEntity(text);
- }
- mergeBaseMcDbEntityProps(objId.getMcDbEntity(), param);
- mxcad$1.updateDisplay();
- });
- }
- regist_data() {
- return {
- filename: "drawText.json",
- name: "draw_text",
- description: "绘制或者插入文字或者多行文字(文本)",
- params: [
- {
- name: "isMText",
- description: "绘制的文字是否为多行文字",
- "type": "boolean",
- "required": true
- },
- {
- name: "textString",
- description: "绘制的文字的内容",
- "type": "str",
- "required": true
- },
- {
- name: "textPos",
- description: "绘制的文字的位置",
- "type": "tuple[float, float]",
- "required": true
- },
- {
- name: "textSize",
- description: "绘制的文字的高度",
- "type": "float",
- "required": true
- },
- ...baseParams
- ]
- };
- }
- }
- function init$7() {
- MxAiModule.regist(MxAiDrawText);
- }
- class MxAiWithdrawAndRestore {
- call(param) {
- console.log(param);
- if (param.isWithdraw) {
- if (typeof param.withdrawNum !== "number")
- param.withdrawNum = 1;
- for (let index = 0; index < param.withdrawNum; index++) {
- mxdraw.MxFun.sendStringToExecute("Mx_Undo");
- }
- }
- if (param.isRestore) {
- if (typeof param.restoreNum !== "number")
- param.restoreNum = 1;
- for (let index = 0; index < param.restoreNum; index++) {
- mxdraw.MxFun.sendStringToExecute("Mx_Redo");
- }
- }
- }
- regist_data() {
- return {
- filename: "call_withdraw_restore.json",
- name: "call_withdraw_restore",
- description: "撤回撤销和恢复",
- params: [
- {
- name: "isWithdraw",
- description: "是否要撤回或撤销",
- "type": "boolean",
- "required": true
- },
- {
- name: "isRestore",
- description: "是否要恢复",
- "type": "boolean",
- "required": true
- },
- {
- name: "withdrawNum",
- description: "撤回撤销(上)几步",
- "type": "int",
- "required": false
- },
- {
- name: "restoreNum",
- description: "恢复(前)几步",
- "type": "int",
- "required": false
- }
- ]
- };
- }
- }
- function init$6() {
- MxAiModule.regist(MxAiWithdrawAndRestore);
- }
- class MxAiModuleType {
- constructor() {
- this.aryRegData = [];
- }
- regist(type) {
- let fun = new type();
- let regdata = fun.regist_data();
- mxcad2.MxCpp.Ai.addFunction(regdata.name, fun.call);
- this.aryRegData.push(regdata);
- }
- regist_server(operation_code) {
- this.aryRegData.forEach((val) => {
- val.operation_code = operation_code;
- mxcad2.MxCpp.Ai.registTool(val);
- });
- mxcad2.MxCpp.Ai.reloadTools({ operation_code });
- }
- }
- let MxAiModule = new MxAiModuleType();
- function Mx_Ai() {
- return __async(this, null, function* () {
- let getString = new mxcad2.MxCADUiPrString();
- getString.setMessage("\n human:");
- let str = yield getString.go();
- if (!str)
- return;
- mxcad2.MxCpp.Ai.chat_tool(str);
- });
- }
- function Mx_AiRegistServer() {
- return __async(this, null, function* () {
- let getString = new mxcad2.MxCADUiPrString();
- getString.setMessage("\n 输入 server_operate_code:");
- let str = yield getString.go();
- if (!str)
- return;
- MxAiModule.regist_server(str);
- });
- }
- function init$5() {
- mxdraw.MxFun.addCommand("Mx_Ai", Mx_Ai);
- mxdraw.MxFun.addCommand("Mx_AiRegistServer", Mx_AiRegistServer);
- init$e();
- init$d();
- init$c();
- init$b();
- init$9();
- init$8();
- init$7();
- init$6();
- init$a();
- }
- function FindBlock(pt, blks) {
- let dSearch = 40;
- let filter = new mxcad2.MxCADResbuf();
- filter.AddString("电杆层", 0);
- filter.AddString("INSERT", 5020);
- let ss = new mxcad2.MxCADSelectionSet();
- ss.crossingSelect(pt.x - dSearch, pt.y - dSearch, pt.x + dSearch, pt.y + dSearch, filter);
- let aryFind = [];
- ss.forEach((id) => {
- let ent = id.getMcDbEntity();
- if (ent) {
- let blkRef = ent;
- if (blks[blkRef.getObjectID().id]) {
- aryFind.push({ dist: blkRef.position.distanceTo(pt), blk: blks[blkRef.getObjectID().id] });
- }
- }
- });
- if (aryFind.length == 0)
- return void 0;
- aryFind.sort((a, b) => {
- return a.dist - b.dist;
- });
- if (aryFind[0].dist < dSearch) {
- return aryFind[0].blk;
- }
- return false;
- }
- function FindLine(key, blks, lines) {
- let blkdata = blks[key];
- let blkref = blkdata.ref;
- let dSearch = 40;
- let filter = new mxcad2.MxCADResbuf();
- filter.AddString("0", 0);
- filter.AddString("LINE", 5020);
- let ss = new mxcad2.MxCADSelectionSet();
- ss.crossingSelect(blkref.position.x - dSearch, blkref.position.y - dSearch, blkref.position.x + dSearch, blkref.position.y + dSearch, filter);
- ss.forEach((id) => {
- let ent = id.getMcDbEntity();
- if (ent) {
- let line = ent;
- let nexPoint = line.endPoint;
- let dist = line.startPoint.distanceTo(blkref.position);
- if (dist > line.endPoint.distanceTo(blkref.position)) {
- dist = line.endPoint.distanceTo(blkref.position);
- nexPoint = line.startPoint;
- }
- if (dist < dSearch) {
- if (!line[line.getObjectID().id]) {
- let nexBlk = FindBlock(nexPoint, blks);
- if (nexBlk) {
- lines[line.getObjectID().id] = { tag1: blkdata.tag, tag2: nexBlk.tag, handle: line.getHandle() };
- }
- }
- }
- }
- });
- }
- function MxTest_UserGetData() {
- return __async(this, null, function* () {
- let ss = new mxcad2.MxCADSelectionSet();
- let filter = new mxcad2.MxCADResbuf();
- filter.AddString("电杆层", 0);
- filter.AddString("INSERT", 5020);
- ss.allSelect(filter);
- let blks = {};
- ss.forEach((id) => {
- let ent = id.getMcDbEntity();
- if (ent) {
- let blkRef = ent;
- let aryId = blkRef.getAllAttribute();
- let obj = {};
- aryId.forEach((id2) => {
- let attribt = id2.getMcDbEntity();
- if (attribt.tag == "杆号") {
- obj.tag = attribt.textString;
- }
- });
- if (obj.tag) {
- obj.handle = blkRef.getHandle();
- blks[id.id] = { ref: blkRef, tag: obj.tag };
- console.log(obj);
- }
- }
- });
- let lines = {};
- Object.keys(blks).forEach((key) => {
- FindLine(key, blks, lines);
- });
- Object.keys(lines).forEach((key) => {
- console.log(lines[key]);
- });
- });
- }
- function init$4() {
- mxdraw.MxFun.addCommand("MxTest_UserGetData", MxTest_UserGetData);
- }
- function init$3() {
- init$4();
- }
- class McDbGisEntity extends mxcad2.McDbCustomEntity {
- create(imp) {
- throw new Error("Method not implemented.");
- }
- getTypeName() {
- throw new Error("Method not implemented.");
- }
- dwgInFields(filter) {
- throw new Error("Method not implemented.");
- }
- dwgOutFields(filter) {
- throw new Error("Method not implemented.");
- }
- worldDraw(draw) {
- throw new Error("Method not implemented.");
- }
- }
- class McDbGisPoint extends McDbGisEntity {
- constructor(imp) {
- super(imp);
- this.pt = new mxcad2.McGePoint3d();
- }
- create(imp) {
- return new McDbGisPoint(imp);
- }
- getTypeName() {
- return "McDbGisPoint";
- }
- dwgInFields(filter) {
- this.pt = filter.readPoint("pt").val;
- return true;
- }
- dwgOutFields(filter) {
- filter.writePoint("pt", this.pt);
- return true;
- }
- moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset) {
- this.assertWrite();
- if (iIndex == 0) {
- this.pt.x += dXOffset;
- this.pt.y += dYOffset;
- this.pt.z += dZOffset;
- }
- }
- getGripPoints() {
- let ret = new mxcad2.McGePoint3dArray();
- ret.append(this.pt);
- return ret;
- }
- worldDraw(draw) {
- draw.drawEntity(new mxcad2.McDbPoint(this.pt));
- }
- //
- setPoint(pt) {
- this.assertWrite();
- this.pt = pt.clone();
- }
- getPoint() {
- return this.pt;
- }
- }
- class McDbGisMultiPoint extends McDbGisEntity {
- constructor(imp) {
- super(imp);
- this.pts = [];
- }
- create(imp) {
- return new McDbGisMultiPoint(imp);
- }
- getTypeName() {
- return "McDbGisMultiPoint";
- }
- dwgInFields(filter) {
- this.pts = filter.readPoints("pts").val;
- return true;
- }
- dwgOutFields(filter) {
- filter.writePoints("pts", this.pts);
- return true;
- }
- moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset) {
- this.assertWrite();
- if (iIndex >= 0 && iIndex < this.pts.length) {
- this.pts[iIndex].x += dXOffset;
- this.pts[iIndex].y += dYOffset;
- this.pts[iIndex].z += dZOffset;
- }
- }
- getGripPoints() {
- let ret = new mxcad2.McGePoint3dArray();
- this.pts.forEach((val) => {
- ret.append(val);
- });
- return ret;
- }
- worldDraw(draw) {
- this.pts.forEach((val) => {
- draw.drawEntity(new mxcad2.McDbPoint(val));
- });
- }
- //
- setPoint(index, pt) {
- this.assertWrite();
- if (index >= 0 && index < this.pts.length) {
- this.pts[index] = pt.clone();
- }
- }
- getPoint(index) {
- if (index >= 0 && index < this.pts.length) {
- return this.pts[index];
- } else {
- return new mxcad2.McGePoint3d();
- }
- }
- addPoint(pt) {
- this.pts.push(pt.clone());
- }
- removeAllPoint() {
- this.pts = [];
- }
- getPointCount() {
- return this.pts.length;
- }
- }
- class McDbGisLineString extends McDbGisEntity {
- constructor(imp) {
- super(imp);
- this.pts = [];
- }
- create(imp) {
- return new McDbGisLineString(imp);
- }
- getTypeName() {
- return "McDbGisLineString";
- }
- dwgInFields(filter) {
- this.pts = filter.readPoints("pts").val;
- return true;
- }
- dwgOutFields(filter) {
- filter.writePoints("pts", this.pts);
- return true;
- }
- moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset) {
- this.assertWrite();
- if (iIndex >= 0 && iIndex < this.pts.length) {
- this.pts[iIndex].x += dXOffset;
- this.pts[iIndex].y += dYOffset;
- this.pts[iIndex].z += dZOffset;
- }
- }
- getGripPoints() {
- let ret = new mxcad2.McGePoint3dArray();
- this.pts.forEach((val) => {
- ret.append(val);
- });
- return ret;
- }
- worldDraw(draw) {
- let pl = new mxcad2.McDbPolyline();
- this.pts.forEach((val) => {
- pl.addVertexAt(val);
- });
- draw.drawEntity(pl);
- }
- //
- setPoint(index, pt) {
- this.assertWrite();
- if (index >= 0 && index < this.pts.length) {
- this.pts[index] = pt.clone();
- }
- }
- getPoint(index) {
- if (index >= 0 && index < this.pts.length) {
- return this.pts[index];
- } else {
- return new mxcad2.McGePoint3d();
- }
- }
- addPoint(pt) {
- this.pts.push(pt.clone());
- }
- removeAllPoint() {
- this.pts = [];
- }
- getPointCount() {
- return this.pts.length;
- }
- }
- class McDbGisMultiLineString extends McDbGisEntity {
- constructor(imp) {
- super(imp);
- this.ptss = [];
- }
- create(imp) {
- return new McDbGisMultiLineString(imp);
- }
- getTypeName() {
- return "McDbGisMultiLineString";
- }
- dwgInFields(filter) {
- this.ptss = [];
- let ptss_n = filter.readLong("ptss_n");
- for (let i2 = 0; i2 < ptss_n.val; i2++) {
- let pts = filter.readPoints("ptss_" + i2);
- if (pts.ret) {
- this.ptss.push(pts.val);
- }
- }
- return true;
- }
- dwgOutFields(filter) {
- filter.writeLong("ptss_n", this.ptss.length);
- this.ptss.forEach((pts, index) => {
- filter.writePoints("ptss_" + index, pts);
- });
- return true;
- }
- moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset) {
- this.assertWrite();
- let iCount = 0;
- for (let i2 = 0; i2 < this.ptss.length; i2++) {
- let pts = this.ptss[i2];
- for (let j = 0; j < pts.length; j++) {
- if (iCount == iIndex) {
- this.ptss[i2][j].x += dXOffset;
- this.ptss[i2][j].y += dYOffset;
- this.ptss[i2][j].z += dZOffset;
- i2 = this.ptss.length;
- break;
- }
- iCount++;
- }
- }
- }
- getGripPoints() {
- let ret = new mxcad2.McGePoint3dArray();
- this.ptss.forEach((pts) => {
- pts.forEach((pt) => {
- ret.append(pt);
- });
- });
- return ret;
- }
- worldDraw(draw) {
- for (let i2 = 0; i2 < this.ptss.length; i2++) {
- let pts = this.ptss[i2];
- let pl = new mxcad2.McDbPolyline();
- pts.forEach((val) => {
- pl.addVertexAt(val);
- });
- draw.drawEntity(pl);
- }
- }
- addPoints(pts) {
- this.ptss.push(pts);
- }
- removeAllPoint() {
- this.ptss = [];
- }
- getPointsCount() {
- return this.ptss.length;
- }
- getPoints(index) {
- if (index >= 0 && index < this.ptss.length) {
- return this.ptss[index];
- } else {
- return [];
- }
- }
- }
- class McDbGisPolygon extends McDbGisEntity {
- constructor(imp) {
- super(imp);
- this.ptss = [];
- }
- create(imp) {
- return new McDbGisPolygon(imp);
- }
- getTypeName() {
- return "McDbGisPolygon";
- }
- dwgInFields(filter) {
- this.ptss = [];
- let ptss_n = filter.readLong("ptss_n");
- for (let i2 = 0; i2 < ptss_n.val; i2++) {
- let pts = filter.readPoints("ptss_" + i2);
- if (pts.ret) {
- this.ptss.push(pts.val);
- }
- }
- return true;
- }
- dwgOutFields(filter) {
- filter.writeLong("ptss_n", this.ptss.length);
- this.ptss.forEach((pts, index) => {
- filter.writePoints("ptss_" + index, pts);
- });
- return true;
- }
- moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset) {
- this.assertWrite();
- let iCount = 0;
- for (let i2 = 0; i2 < this.ptss.length; i2++) {
- let pts = this.ptss[i2];
- for (let j = 0; j < pts.length; j++) {
- if (iCount == iIndex) {
- this.ptss[i2][j].x += dXOffset;
- this.ptss[i2][j].y += dYOffset;
- this.ptss[i2][j].z += dZOffset;
- i2 = this.ptss.length;
- break;
- }
- iCount++;
- }
- }
- }
- getGripPoints() {
- let ret = new mxcad2.McGePoint3dArray();
- this.ptss.forEach((pts) => {
- pts.forEach((pt) => {
- ret.append(pt);
- });
- });
- return ret;
- }
- worldDraw(draw) {
- let solid = new mxcad2.McDbHatch();
- for (let i2 = 0; i2 < this.ptss.length; i2++) {
- let pts = this.ptss[i2];
- if (pts.length > 2) {
- solid.appendLoop(new mxcad2.McGePoint3dArray(pts));
- }
- }
- if (solid.numLoops > 0) {
- draw.drawEntity(solid);
- }
- }
- addPoints(pts) {
- this.ptss.push(pts);
- }
- removeAllPoint() {
- this.ptss = [];
- }
- getPointsCount() {
- return this.ptss.length;
- }
- getPoints(index) {
- if (index >= 0 && index < this.ptss.length) {
- return this.ptss[index];
- } else {
- return [];
- }
- }
- }
- function MxGis_DrawPoint() {
- return __async(this, null, function* () {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- let getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.setMessage("点取一个点坐标");
- let pt = yield getPoint.go();
- if (pt) {
- let point = new McDbGisPoint();
- point.setPoint(pt);
- mxcad$1.drawEntity(point);
- }
- });
- }
- function MxGis_DrawMultiPoint() {
- return __async(this, null, function* () {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- let getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.setMessage("点取一个点坐标");
- let points = new McDbGisMultiPoint();
- let aryTmpEntityId = [];
- while (true) {
- getPoint.clearLastInputPoint();
- getPoint.setDynamicInputType(mxdraw.DynamicInputType.kXYCoordInput);
- let pt = yield getPoint.go();
- if (pt) {
- points.addPoint(pt);
- let point = new mxcad2.McDbPoint(pt);
- aryTmpEntityId.push(mxcad$1.drawEntity(point));
- } else {
- break;
- }
- }
- if (points.getPointCount() > 0) {
- mxcad$1.drawEntity(points);
- }
- aryTmpEntityId.forEach((id) => {
- id.erase();
- });
- });
- }
- function MxGis_DrawLineString() {
- return __async(this, null, function* () {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- let getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.setMessage("点取一个点坐标");
- let lines = new McDbGisLineString();
- let aryTmpEntityId = [];
- let prvPoint = void 0;
- while (true) {
- if (prvPoint) {
- getPoint.setBasePt(prvPoint);
- getPoint.setUseBasePt(true);
- }
- getPoint.setDynamicInputType(mxdraw.DynamicInputType.kXYCoordInput);
- let pt = yield getPoint.go();
- if (pt) {
- lines.addPoint(pt);
- if (prvPoint) {
- let line = new mxcad2.McDbLine();
- line.startPoint = prvPoint;
- line.endPoint = pt;
- aryTmpEntityId.push(mxcad$1.drawEntity(line));
- }
- prvPoint = pt;
- } else {
- break;
- }
- }
- if (lines.getPointCount() > 1) {
- mxcad$1.drawEntity(lines);
- }
- aryTmpEntityId.forEach((id) => {
- id.erase();
- });
- });
- }
- function MxGis_DrawMultiLineString() {
- return __async(this, null, function* () {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- let getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.setMessage("点取一个点坐标");
- getPoint.setKeyWords("[下一段线(N)]");
- let lines = new McDbGisMultiLineString();
- let pts = [];
- let aryTmpEntityId = [];
- let prvPoint = void 0;
- while (true) {
- if (prvPoint) {
- getPoint.setBasePt(prvPoint);
- } else {
- getPoint.setUseBasePt(false);
- }
- getPoint.setDynamicInputType(mxdraw.DynamicInputType.kXYCoordInput);
- let pt = yield getPoint.go();
- if (getPoint.isKeyWordPicked("N")) {
- if (pts.length > 1) {
- lines.addPoints(pts);
- }
- pts = [];
- prvPoint = void 0;
- } else {
- if (pt) {
- pts.push(pt);
- if (prvPoint) {
- let line = new mxcad2.McDbLine();
- line.startPoint = prvPoint;
- line.endPoint = pt;
- aryTmpEntityId.push(mxcad$1.drawEntity(line));
- }
- prvPoint = pt;
- } else {
- break;
- }
- }
- }
- if (pts.length > 1) {
- lines.addPoints(pts);
- }
- if (lines.getPointsCount() > 0) {
- mxcad$1.drawEntity(lines);
- }
- aryTmpEntityId.forEach((id) => {
- id.erase();
- });
- });
- }
- function MxGis_DrawPolygon() {
- return __async(this, null, function* () {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- let getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.setMessage("点取一个点坐标");
- let polygon = new McDbGisPolygon();
- let pts = [];
- let aryTmpEntityId = [];
- let prvPoint = void 0;
- while (true) {
- if (prvPoint) {
- getPoint.setBasePt(prvPoint);
- } else {
- getPoint.setUseBasePt(false);
- }
- if (pts.length > 2) {
- getPoint.setKeyWords("[闭合(C)/退出(E)]");
- }
- getPoint.setDynamicInputType(mxdraw.DynamicInputType.kXYCoordInput);
- let pt = yield getPoint.go();
- if (getPoint.isKeyWordPicked("C")) {
- let line = new mxcad2.McDbLine();
- line.startPoint = pts[0];
- line.endPoint = pts[pts.length - 1];
- aryTmpEntityId.push(mxcad$1.drawEntity(line));
- if (pts.length > 2) {
- polygon.addPoints(pts);
- }
- pts = [];
- prvPoint = void 0;
- } else if (getPoint.isKeyWordPicked("E")) {
- break;
- } else {
- if (pt) {
- pts.push(pt);
- if (prvPoint) {
- let line = new mxcad2.McDbLine();
- line.startPoint = prvPoint;
- line.endPoint = pt;
- aryTmpEntityId.push(mxcad$1.drawEntity(line));
- }
- prvPoint = pt;
- } else {
- break;
- }
- }
- }
- if (pts.length > 2) {
- polygon.addPoints(pts);
- }
- if (polygon.getPointsCount() > 0) {
- mxcad$1.drawEntity(polygon);
- }
- aryTmpEntityId.forEach((id) => {
- id.erase();
- });
- });
- }
- function MxGis_Get_geojson() {
- let ss = new mxcad2.MxCADSelectionSet();
- let filter = new mxcad2.MxCADResbuf();
- filter.AddMcDbEntityTypes("McDbCustomEntity");
- ss.allSelect(filter);
- let genjson = { "type": "FeatureCollection", "features": [] };
- ss.forEach((id) => {
- let ent = id.getMcDbEntity();
- if (!ent)
- return;
- if (ent instanceof McDbGisPoint) {
- let point = ent;
- let pt = point.getPoint();
- let feature = {
- "type": "Feature",
- "properties": {},
- "geometry": {
- "type": "Point",
- "coordinates": [pt.x, pt.y, pt.z]
- }
- };
- genjson.features.push(feature);
- } else if (ent instanceof McDbGisMultiPoint) {
- let points = ent;
- let pts = [];
- let len = points.getPointCount();
- for (let i2 = 0; i2 < len; i2++) {
- let pt = points.getPoint(i2);
- pts.push([pt.x, pt.y, pt.z]);
- }
- let feature = {
- "type": "Feature",
- "properties": {},
- "geometry": {
- "type": "MultiPoint",
- "coordinates": pts
- }
- };
- genjson.features.push(feature);
- } else if (ent instanceof McDbGisLineString) {
- let line = ent;
- let pts = [];
- let len = line.getPointCount();
- for (let i2 = 0; i2 < len; i2++) {
- let pt = line.getPoint(i2);
- pts.push([pt.x, pt.y, pt.z]);
- }
- let feature = {
- "type": "Feature",
- "properties": {},
- "geometry": {
- "type": "LineString",
- "coordinates": pts
- }
- };
- genjson.features.push(feature);
- } else if (ent instanceof McDbGisMultiLineString) {
- let lines = ent;
- let ptss = [];
- let len = lines.getPointsCount();
- for (let i2 = 0; i2 < len; i2++) {
- let pts = lines.getPoints(i2);
- let ary = [];
- for (let j = 0; j < pts.length; j++) {
- let pt = pts[j];
- ary.push([pt.x, pt.y, pt.z]);
- }
- ptss.push(ary);
- }
- let feature = {
- "type": "Feature",
- "properties": {},
- "geometry": {
- "type": "MultiLineString",
- "coordinates": ptss
- }
- };
- genjson.features.push(feature);
- } else if (ent instanceof McDbGisPolygon) {
- let lines = ent;
- let ptss = [];
- let len = lines.getPointsCount();
- for (let i2 = 0; i2 < len; i2++) {
- let pts = lines.getPoints(i2);
- let ary = [];
- for (let j = 0; j < pts.length; j++) {
- let pt = pts[j];
- ary.push([pt.x, pt.y, pt.z]);
- }
- ptss.push(ary);
- }
- let feature = {
- "type": "Feature",
- "properties": {},
- "geometry": {
- "type": "Polygon",
- "coordinates": ptss
- }
- };
- genjson.features.push(feature);
- }
- });
- console.log(JSON.stringify(genjson));
- }
- function init$2() {
- mxdraw.MxFun.addCommand("MxGis_DrawPoint", MxGis_DrawPoint);
- mxdraw.MxFun.addCommand("MxGis_DrawMultiPoint", MxGis_DrawMultiPoint);
- mxdraw.MxFun.addCommand("MxGis_DrawLineString", MxGis_DrawLineString);
- mxdraw.MxFun.addCommand("MxGis_DrawMultiLineString", MxGis_DrawMultiLineString);
- mxdraw.MxFun.addCommand("MxGis_DrawPolygon", MxGis_DrawPolygon);
- mxdraw.MxFun.addCommand("MxGis_Get_geojson", MxGis_Get_geojson);
- new McDbGisPoint().rxInit();
- new McDbGisMultiPoint().rxInit();
- new McDbGisLineString().rxInit();
- new McDbGisMultiLineString().rxInit();
- new McDbGisPolygon().rxInit();
- }
- var mapboxGl = { exports: {} };
- (function(module, exports2) {
- (function(global2, factory) {
- module.exports = factory();
- })(commonjsGlobal, function() {
- var shared, worker, mapboxgl2;
- function define(_, chunk) {
- if (!shared) {
- shared = chunk;
- } else if (!worker) {
- worker = chunk;
- } else {
- 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;";
- var sharedChunk = {};
- shared(sharedChunk);
- mapboxgl2 = chunk(sharedChunk);
- if (typeof window !== "undefined" && window && window.URL && window.URL.createObjectURL) {
- mapboxgl2.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: "text/javascript" }));
- }
- }
- }
- define(["exports"], function(t) {
- var e = "2.8.2", r = n;
- function n(t2, e2, r2, n2) {
- 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;
- }
- n.prototype.sampleCurveX = function(t2) {
- return ((this.ax * t2 + this.bx) * t2 + this.cx) * t2;
- }, n.prototype.sampleCurveY = function(t2) {
- return ((this.ay * t2 + this.by) * t2 + this.cy) * t2;
- }, n.prototype.sampleCurveDerivativeX = function(t2) {
- return (3 * this.ax * t2 + 2 * this.bx) * t2 + this.cx;
- }, n.prototype.solveCurveX = function(t2, e2) {
- var r2, n2, i3, s2, a2;
- for (void 0 === e2 && (e2 = 1e-6), i3 = t2, a2 = 0; a2 < 8; a2++) {
- if (s2 = this.sampleCurveX(i3) - t2, Math.abs(s2) < e2)
- return i3;
- var o2 = this.sampleCurveDerivativeX(i3);
- if (Math.abs(o2) < 1e-6)
- break;
- i3 -= s2 / o2;
- }
- if ((i3 = t2) < (r2 = 0))
- return r2;
- if (i3 > (n2 = 1))
- return n2;
- for (; r2 < n2; ) {
- if (s2 = this.sampleCurveX(i3), Math.abs(s2 - t2) < e2)
- return i3;
- t2 > s2 ? r2 = i3 : n2 = i3, i3 = 0.5 * (n2 - r2) + r2;
- }
- return i3;
- }, n.prototype.solve = function(t2, e2) {
- return this.sampleCurveY(this.solveCurveX(t2, e2));
- };
- var i2 = s;
- function s(t2, e2) {
- this.x = t2, this.y = e2;
- }
- s.prototype = { clone: function() {
- return new s(this.x, this.y);
- }, add: function(t2) {
- return this.clone()._add(t2);
- }, sub: function(t2) {
- return this.clone()._sub(t2);
- }, multByPoint: function(t2) {
- return this.clone()._multByPoint(t2);
- }, divByPoint: function(t2) {
- return this.clone()._divByPoint(t2);
- }, mult: function(t2) {
- return this.clone()._mult(t2);
- }, div: function(t2) {
- return this.clone()._div(t2);
- }, rotate: function(t2) {
- return this.clone()._rotate(t2);
- }, rotateAround: function(t2, e2) {
- return this.clone()._rotateAround(t2, e2);
- }, matMult: function(t2) {
- return this.clone()._matMult(t2);
- }, unit: function() {
- return this.clone()._unit();
- }, perp: function() {
- return this.clone()._perp();
- }, round: function() {
- return this.clone()._round();
- }, mag: function() {
- return Math.sqrt(this.x * this.x + this.y * this.y);
- }, equals: function(t2) {
- return this.x === t2.x && this.y === t2.y;
- }, dist: function(t2) {
- return Math.sqrt(this.distSqr(t2));
- }, distSqr: function(t2) {
- var e2 = t2.x - this.x, r2 = t2.y - this.y;
- return e2 * e2 + r2 * r2;
- }, angle: function() {
- return Math.atan2(this.y, this.x);
- }, angleTo: function(t2) {
- return Math.atan2(this.y - t2.y, this.x - t2.x);
- }, angleWith: function(t2) {
- return this.angleWithSep(t2.x, t2.y);
- }, angleWithSep: function(t2, e2) {
- return Math.atan2(this.x * e2 - this.y * t2, this.x * t2 + this.y * e2);
- }, _matMult: function(t2) {
- var e2 = t2[2] * this.x + t2[3] * this.y;
- return this.x = t2[0] * this.x + t2[1] * this.y, this.y = e2, this;
- }, _add: function(t2) {
- return this.x += t2.x, this.y += t2.y, this;
- }, _sub: function(t2) {
- return this.x -= t2.x, this.y -= t2.y, this;
- }, _mult: function(t2) {
- return this.x *= t2, this.y *= t2, this;
- }, _div: function(t2) {
- return this.x /= t2, this.y /= t2, this;
- }, _multByPoint: function(t2) {
- return this.x *= t2.x, this.y *= t2.y, this;
- }, _divByPoint: function(t2) {
- return this.x /= t2.x, this.y /= t2.y, this;
- }, _unit: function() {
- return this._div(this.mag()), this;
- }, _perp: function() {
- var t2 = this.y;
- return this.y = this.x, this.x = -t2, this;
- }, _rotate: function(t2) {
- var e2 = Math.cos(t2), r2 = Math.sin(t2), n2 = r2 * this.x + e2 * this.y;
- return this.x = e2 * this.x - r2 * this.y, this.y = n2, this;
- }, _rotateAround: function(t2, e2) {
- var r2 = Math.cos(t2), n2 = Math.sin(t2), i3 = e2.y + n2 * (this.x - e2.x) + r2 * (this.y - e2.y);
- return this.x = e2.x + r2 * (this.x - e2.x) - n2 * (this.y - e2.y), this.y = i3, this;
- }, _round: function() {
- return this.x = Math.round(this.x), this.y = Math.round(this.y), this;
- } }, s.convert = function(t2) {
- return t2 instanceof s ? t2 : Array.isArray(t2) ? new s(t2[0], t2[1]) : t2;
- };
- var a = "undefined" != typeof self ? self : {};
- const o = Math.PI / 180, l = 180 / Math.PI;
- function u(t2) {
- return t2 * o;
- }
- function c(t2) {
- return t2 * l;
- }
- const h = [[0, 0], [1, 0], [1, 1], [0, 1]];
- function p(t2) {
- if (t2 <= 0)
- return 0;
- if (t2 >= 1)
- return 1;
- const e2 = t2 * t2, r2 = e2 * t2;
- return 4 * (t2 < 0.5 ? r2 : 3 * (t2 - e2) + r2 - 0.75);
- }
- function f(t2, e2, n2, i3) {
- const s2 = new r(t2, e2, n2, i3);
- return function(t3) {
- return s2.solve(t3);
- };
- }
- const d = f(0.25, 0.1, 0.25, 1);
- function y(t2, e2, r2) {
- return Math.min(r2, Math.max(e2, t2));
- }
- function m(t2, e2, r2) {
- return (r2 = y((r2 - t2) / (e2 - t2), 0, 1)) * r2 * (3 - 2 * r2);
- }
- function g(t2, e2, r2) {
- const n2 = r2 - e2, i3 = ((t2 - e2) % n2 + n2) % n2 + e2;
- return i3 === e2 ? r2 : i3;
- }
- function x(t2, e2, r2) {
- if (!t2.length)
- return r2(null, []);
- let n2 = t2.length;
- const i3 = new Array(t2.length);
- let s2 = null;
- t2.forEach((t3, a2) => {
- e2(t3, (t4, e3) => {
- t4 && (s2 = t4), i3[a2] = e3, 0 == --n2 && r2(s2, i3);
- });
- });
- }
- function v(t2) {
- const e2 = [];
- for (const r2 in t2)
- e2.push(t2[r2]);
- return e2;
- }
- function b(t2, ...e2) {
- for (const r2 of e2)
- for (const e3 in r2)
- t2[e3] = r2[e3];
- return t2;
- }
- let _ = 1;
- function w() {
- return _++;
- }
- function A() {
- return function t2(e2) {
- return e2 ? (e2 ^ Math.random() * (16 >> e2 / 4)).toString(16) : ([1e7] + -[1e3] + -4e3 + -8e3 + -1e11).replace(/[018]/g, t2);
- }();
- }
- function k(t2) {
- return t2 <= 1 ? 1 : Math.pow(2, Math.ceil(Math.log(t2) / Math.LN2));
- }
- function S(t2) {
- 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);
- }
- function I(t2, e2) {
- t2.forEach((t3) => {
- e2[t3] && (e2[t3] = e2[t3].bind(e2));
- });
- }
- function M(t2, e2) {
- return -1 !== t2.indexOf(e2, t2.length - e2.length);
- }
- function T(t2, e2, r2) {
- const n2 = {};
- for (const i3 in t2)
- n2[i3] = e2.call(r2 || this, t2[i3], i3, t2);
- return n2;
- }
- function z(t2, e2, r2) {
- const n2 = {};
- for (const i3 in t2)
- e2.call(r2 || this, t2[i3], i3, t2) && (n2[i3] = t2[i3]);
- return n2;
- }
- function B(t2) {
- return Array.isArray(t2) ? t2.map(B) : "object" == typeof t2 && t2 ? T(t2, B) : t2;
- }
- const E = {};
- function C(t2) {
- E[t2] || ("undefined" != typeof console && console.warn(t2), E[t2] = true);
- }
- function D(t2, e2, r2) {
- return (r2.y - t2.y) * (e2.x - t2.x) > (e2.y - t2.y) * (r2.x - t2.x);
- }
- function P(t2) {
- let e2 = 0;
- for (let r2, n2, i3 = 0, s2 = t2.length, a2 = s2 - 1; i3 < s2; a2 = i3++)
- r2 = t2[i3], n2 = t2[a2], e2 += (n2.x - r2.x) * (r2.y + n2.y);
- return e2;
- }
- function V() {
- return "undefined" != typeof WorkerGlobalScope && "undefined" != typeof self && self instanceof WorkerGlobalScope;
- }
- function F(t2) {
- const e2 = {};
- if (t2.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g, (t3, r2, n2, i3) => {
- const s2 = n2 || i3;
- return e2[r2] = !s2 || s2.toLowerCase(), "";
- }), e2["max-age"]) {
- const t3 = parseInt(e2["max-age"], 10);
- isNaN(t3) ? delete e2["max-age"] : e2["max-age"] = t3;
- }
- return e2;
- }
- let L, R, U, $, j = null;
- function O(t2) {
- if (null == j) {
- const e2 = t2.navigator ? t2.navigator.userAgent : null;
- j = !!t2.safari || !(!e2 || !(/\b(iPad|iPhone|iPod)\b/.test(e2) || e2.match("Safari") && !e2.match("Chrome")));
- }
- return j;
- }
- function q(t2) {
- try {
- const e2 = a[t2];
- return e2.setItem("_mapbox_test_", 1), e2.removeItem("_mapbox_test_"), true;
- } catch (t3) {
- return false;
- }
- }
- const N = { now: () => void 0 !== U ? U : a.performance.now(), setNow(t2) {
- U = t2;
- }, restoreNow() {
- U = void 0;
- }, frame(t2) {
- const e2 = a.requestAnimationFrame(t2);
- return { cancel: () => a.cancelAnimationFrame(e2) };
- }, getImageData(t2, e2 = 0) {
- const { width: r2, height: n2 } = t2;
- $ || ($ = a.document.createElement("canvas"));
- const i3 = $.getContext("2d");
- if (!i3)
- throw new Error("failed to create canvas 2d context");
- 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);
- }, resolveURL: (t2) => (L || (L = a.document.createElement("a")), L.href = t2, L.href), get devicePixelRatio() {
- return a.devicePixelRatio;
- }, get prefersReducedMotion() {
- return !!a.matchMedia && (null == R && (R = a.matchMedia("(prefers-reduced-motion: reduce)")), R.matches);
- } };
- let G;
- const Z = { API_URL: "https://api.mapbox.com", get API_URL_REGEX() {
- if (null == G) {
- const t2 = /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;
- try {
- G = null != process.env.API_URL_REGEX ? new RegExp(process.env.API_URL_REGEX) : t2;
- } catch (e2) {
- G = t2;
- }
- }
- return G;
- }, get EVENTS_URL() {
- 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;
- }, 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) {
- !H && Y && (W ? J(t2) : K = t2);
- } };
- let K, Y, H = false, W = false;
- function J(t2) {
- const e2 = t2.createTexture();
- t2.bindTexture(t2.TEXTURE_2D, e2);
- try {
- if (t2.texImage2D(t2.TEXTURE_2D, 0, t2.RGBA, t2.RGBA, t2.UNSIGNED_BYTE, Y), t2.isContextLost())
- return;
- X.supported = true;
- } catch (t3) {
- }
- t2.deleteTexture(e2), H = true;
- }
- a.document && (Y = a.document.createElement("img"), Y.onload = function() {
- K && J(K), K = null, W = true;
- }, Y.onerror = function() {
- H = true, K = null;
- }, Y.src = "data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");
- const Q = "01", tt = "NO_ACCESS_TOKEN";
- function et(t2) {
- return 0 === t2.indexOf("mapbox:");
- }
- function rt(t2) {
- return Z.API_URL_REGEX.test(t2);
- }
- const nt = /^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;
- function it(t2) {
- const e2 = t2.match(nt);
- if (!e2)
- throw new Error("Unable to parse URL object");
- return { protocol: e2[1], authority: e2[2], path: e2[3] || "/", params: e2[4] ? e2[4].split("&") : [] };
- }
- function st(t2) {
- const e2 = t2.params.length ? `?${t2.params.join("&")}` : "";
- return `${t2.protocol}://${t2.authority}${t2.path}${e2}`;
- }
- function at(t2) {
- if (!t2)
- return null;
- const e2 = t2.split(".");
- if (!e2 || 3 !== e2.length)
- return null;
- try {
- return JSON.parse(decodeURIComponent(a.atob(e2[1]).split("").map((t3) => "%" + ("00" + t3.charCodeAt(0).toString(16)).slice(-2)).join("")));
- } catch (t3) {
- return null;
- }
- }
- class ot {
- constructor(t2) {
- this.type = t2, this.anonId = null, this.eventData = {}, this.queue = [], this.pendingRequest = null;
- }
- getStorageKey(t2) {
- const e2 = at(Z.ACCESS_TOKEN);
- let r2 = "";
- 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}`;
- }
- fetchEventData() {
- const t2 = q("localStorage"), e2 = this.getStorageKey(), r2 = this.getStorageKey("uuid");
- if (t2)
- try {
- const t3 = a.localStorage.getItem(e2);
- t3 && (this.eventData = JSON.parse(t3));
- const n2 = a.localStorage.getItem(r2);
- n2 && (this.anonId = n2);
- } catch (t3) {
- C("Unable to read from LocalStorage");
- }
- }
- saveEventData() {
- const t2 = q("localStorage"), e2 = this.getStorageKey(), r2 = this.getStorageKey("uuid");
- if (t2)
- try {
- a.localStorage.setItem(r2, this.anonId), Object.keys(this.eventData).length >= 1 && a.localStorage.setItem(e2, JSON.stringify(this.eventData));
- } catch (t3) {
- C("Unable to write to LocalStorage");
- }
- }
- processRequests(t2) {
- }
- postEvent(t2, r2, n2, i3) {
- if (!Z.EVENTS_URL)
- return;
- const s2 = it(Z.EVENTS_URL);
- s2.params.push(`access_token=${i3 || Z.ACCESS_TOKEN || ""}`);
- 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]) };
- this.pendingRequest = Tt(l2, (t3) => {
- this.pendingRequest = null, n2(t3), this.saveEventData(), this.processRequests(i3);
- });
- }
- queueRequest(t2, e2) {
- this.queue.push(t2), this.processRequests(e2);
- }
- }
- const lt = new class extends ot {
- constructor(t2) {
- super("appUserTurnstile"), this._customAccessToken = t2;
- }
- postTurnstileEvent(t2, e2) {
- Z.EVENTS_URL && Z.ACCESS_TOKEN && Array.isArray(t2) && t2.some((t3) => et(t3) || rt(t3)) && this.queueRequest(Date.now(), e2);
- }
- processRequests(t2) {
- if (this.pendingRequest || 0 === this.queue.length)
- return;
- this.anonId && this.eventData.lastSuccess && this.eventData.tokenU || this.fetchEventData();
- const e2 = at(Z.ACCESS_TOKEN), r2 = e2 ? e2.u : Z.ACCESS_TOKEN;
- let n2 = r2 !== this.eventData.tokenU;
- S(this.anonId) || (this.anonId = A(), n2 = true);
- const i3 = this.queue.shift();
- if (this.eventData.lastSuccess) {
- const t3 = new Date(this.eventData.lastSuccess), e3 = new Date(i3), r3 = (i3 - this.eventData.lastSuccess) / 864e5;
- n2 = n2 || r3 >= 1 || r3 < -1 || t3.getDate() !== e3.getDate();
- } else
- n2 = true;
- n2 ? this.postEvent(i3, { "enabled.telemetry": false }, (t3) => {
- t3 || (this.eventData.lastSuccess = i3, this.eventData.tokenU = r2);
- }, t2) : this.processRequests();
- }
- }(), ut = lt.postTurnstileEvent.bind(lt), ct = new class extends ot {
- constructor() {
- super("map.load"), this.success = {}, this.skuToken = "";
- }
- postMapLoadEvent(t2, e2, r2, n2) {
- 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)));
- }
- processRequests(t2) {
- if (this.pendingRequest || 0 === this.queue.length)
- return;
- const { id: e2, timestamp: r2 } = this.queue.shift();
- e2 && this.success[e2] || (this.anonId || this.fetchEventData(), S(this.anonId) || (this.anonId = A()), this.postEvent(r2, { skuToken: this.skuToken }, (t3) => {
- t3 ? this.errorCb(t3) : e2 && (this.success[e2] = true);
- }, t2));
- }
- }(), ht = ct.postMapLoadEvent.bind(ct), pt = new class extends ot {
- constructor() {
- super("map.auth"), this.success = {}, this.skuToken = "";
- }
- getSession(t2, e2, r2, n2) {
- if (!Z.API_URL || !Z.SESSION_PATH)
- return;
- const i3 = it(Z.API_URL + Z.SESSION_PATH);
- i3.params.push(`sku=${e2 || ""}`), i3.params.push(`access_token=${n2 || Z.ACCESS_TOKEN || ""}`);
- const s2 = { url: st(i3), headers: { "Content-Type": "text/plain" } };
- this.pendingRequest = zt(s2, (t3) => {
- this.pendingRequest = null, r2(t3), this.saveEventData(), this.processRequests(n2);
- });
- }
- getSessionAPI(t2, e2, r2, n2) {
- 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)));
- }
- processRequests(t2) {
- if (this.pendingRequest || 0 === this.queue.length)
- return;
- const { id: e2, timestamp: r2 } = this.queue.shift();
- e2 && this.success[e2] || this.getSession(r2, this.skuToken, (t3) => {
- t3 ? this.errorCb(t3) : e2 && (this.success[e2] = true);
- }, t2);
- }
- }(), ft = pt.getSessionAPI.bind(pt), dt = /* @__PURE__ */ new Set(), yt = "mapbox-tiles";
- let mt, gt, xt = 500, vt = 50;
- function bt() {
- a.caches && !mt && (mt = a.caches.open(yt));
- }
- function _t(t2) {
- const e2 = t2.indexOf("?");
- return e2 < 0 ? t2 : t2.slice(0, e2);
- }
- let wt = 1 / 0;
- const At = { Unknown: "Unknown", Style: "Style", Source: "Source", Tile: "Tile", Glyphs: "Glyphs", SpriteImage: "SpriteImage", SpriteJSON: "SpriteJSON", Image: "Image" };
- "function" == typeof Object.freeze && Object.freeze(At);
- class kt extends Error {
- constructor(t2, e2, r2) {
- 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;
- }
- toString() {
- return `${this.name}: ${this.message} (${this.status}): ${this.url}`;
- }
- }
- const St = V() ? () => self.worker && self.worker.referrer : () => ("blob:" === a.location.protocol ? a.parent : a).location.href;
- const It = function(t2, e2) {
- if (!(/^file:/.test(r2 = t2.url) || /^file:/.test(St()) && !/^\w+:/.test(r2))) {
- if (a.fetch && a.Request && a.AbortController && a.Request.prototype.hasOwnProperty("signal"))
- return function(t3, e3) {
- 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 });
- let i3 = false, s2 = false;
- const o2 = (l2 = n2.url).indexOf("sku=") > 0 && rt(l2);
- var l2;
- "json" === t3.type && n2.headers.set("Accept", "application/json");
- const u2 = (r4, i4, l3) => {
- if (s2)
- return;
- if (r4 && "SecurityError" !== r4.message && C(r4), i4 && l3)
- return c2(i4);
- const u3 = Date.now();
- a.fetch(n2).then((r5) => {
- if (r5.ok) {
- const t4 = o2 ? r5.clone() : null;
- return c2(r5, t4, u3);
- }
- return e3(new kt(r5.statusText, r5.status, t3.url));
- }).catch((t4) => {
- 20 !== t4.code && e3(new Error(t4.message));
- });
- }, c2 = (r4, o3, l3) => {
- ("arrayBuffer" === t3.type ? r4.arrayBuffer() : "json" === t3.type ? r4.json() : r4.text()).then((t4) => {
- s2 || (o3 && l3 && function(t5, e4, r5) {
- if (bt(), !mt)
- return;
- const n3 = { status: e4.status, statusText: e4.statusText, headers: new a.Headers() };
- e4.headers.forEach((t6, e5) => n3.headers.set(e5, t6));
- const i4 = F(e4.headers.get("Cache-Control") || "");
- if (i4["no-store"])
- return;
- i4["max-age"] && n3.headers.set("Expires", new Date(r5 + 1e3 * i4["max-age"]).toUTCString());
- const s3 = n3.headers.get("Expires");
- s3 && (new Date(s3).getTime() - r5 < 42e4 || function(t6, e5) {
- if (void 0 === gt)
- try {
- new Response(new ReadableStream()), gt = true;
- } catch (t7) {
- gt = false;
- }
- gt ? e5(t6.body) : t6.blob().then(e5);
- }(e4, (e5) => {
- const r6 = new a.Response(e5, n3);
- bt(), mt && mt.then((e6) => e6.put(_t(t5.url), r6)).catch((t6) => C(t6.message));
- }));
- }(n2, o3, l3), i3 = true, e3(null, t4, r4.headers.get("Cache-Control"), r4.headers.get("Expires")));
- }).catch((t4) => {
- s2 || e3(new Error(t4.message));
- });
- };
- return o2 ? function(t4, e4) {
- if (bt(), !mt)
- return e4(null);
- const r4 = _t(t4.url);
- mt.then((t5) => {
- t5.match(r4).then((n3) => {
- const i4 = function(t6) {
- if (!t6)
- return false;
- const e5 = new Date(t6.headers.get("Expires") || 0), r5 = F(t6.headers.get("Cache-Control") || "");
- return e5 > Date.now() && !r5["no-cache"];
- }(n3);
- t5.delete(r4), i4 && t5.put(r4, n3.clone()), e4(null, n3, i4);
- }).catch(e4);
- }).catch(e4);
- }(n2, u2) : u2(null, null), { cancel: () => {
- s2 = true, i3 || r3.abort();
- } };
- }(t2, e2);
- if (V() && self.worker && self.worker.actor)
- return self.worker.actor.send("getResource", t2, e2, void 0, true);
- }
- var r2;
- return function(t3, e3) {
- const r3 = new a.XMLHttpRequest();
- r3.open(t3.method || "GET", t3.url, true), "arrayBuffer" === t3.type && (r3.responseType = "arraybuffer");
- for (const e4 in t3.headers)
- r3.setRequestHeader(e4, t3.headers[e4]);
- return "json" === t3.type && (r3.responseType = "text", r3.setRequestHeader("Accept", "application/json")), r3.withCredentials = "include" === t3.credentials, r3.onerror = () => {
- e3(new Error(r3.statusText));
- }, r3.onload = () => {
- if ((r3.status >= 200 && r3.status < 300 || 0 === r3.status) && null !== r3.response) {
- let n2 = r3.response;
- if ("json" === t3.type)
- try {
- n2 = JSON.parse(r3.response);
- } catch (t4) {
- return e3(t4);
- }
- e3(null, n2, r3.getResponseHeader("Cache-Control"), r3.getResponseHeader("Expires"));
- } else
- e3(new kt(r3.statusText, r3.status, t3.url));
- }, r3.send(t3.body), { cancel: () => r3.abort() };
- }(t2, e2);
- }, Mt = function(t2, e2) {
- return It(b(t2, { type: "arrayBuffer" }), e2);
- }, Tt = function(t2, e2) {
- return It(b(t2, { method: "POST" }), e2);
- }, zt = function(t2, e2) {
- return It(b(t2, { method: "GET" }), e2);
- };
- function Bt(t2) {
- const e2 = a.document.createElement("a");
- return e2.href = t2, e2.protocol === a.document.location.protocol && e2.host === a.document.location.host;
- }
- const Et = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";
- let Ct, Dt;
- Ct = [], Dt = 0;
- const Pt = function(t2, e2) {
- if (X.supported && (t2.headers || (t2.headers = {}), t2.headers.accept = "image/webp,*/*"), Dt >= Z.MAX_PARALLEL_IMAGE_REQUESTS) {
- const r3 = { requestParameters: t2, callback: e2, cancelled: false, cancel() {
- this.cancelled = true;
- } };
- return Ct.push(r3), r3;
- }
- Dt++;
- let r2 = false;
- const n2 = () => {
- if (!r2)
- for (r2 = true, Dt--; Ct.length && Dt < Z.MAX_PARALLEL_IMAGE_REQUESTS; ) {
- const t3 = Ct.shift(), { requestParameters: e3, callback: r3, cancelled: n3 } = t3;
- n3 || (t3.cancel = Pt(e3, r3).cancel);
- }
- }, i3 = Mt(t2, (t3, r3, i4, s2) => {
- n2(), t3 ? e2(t3) : r3 && (a.createImageBitmap ? function(t4, e3) {
- const r4 = new a.Blob([new Uint8Array(t4)], { type: "image/png" });
- a.createImageBitmap(r4).then((t5) => {
- e3(null, t5);
- }).catch((t5) => {
- 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.`));
- });
- }(r3, (t4, r4) => e2(t4, r4, i4, s2)) : function(t4, e3) {
- const r4 = new a.Image(), n3 = a.URL;
- r4.onload = () => {
- e3(null, r4), n3.revokeObjectURL(r4.src), r4.onload = null, a.requestAnimationFrame(() => {
- r4.src = Et;
- });
- }, 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."));
- const i5 = new a.Blob([new Uint8Array(t4)], { type: "image/png" });
- r4.src = t4.byteLength ? n3.createObjectURL(i5) : Et;
- }(r3, (t4, r4) => e2(t4, r4, i4, s2)));
- });
- return { cancel: () => {
- i3.cancel(), n2();
- } };
- };
- function Vt(t2, e2, r2) {
- r2[t2] && -1 !== r2[t2].indexOf(e2) || (r2[t2] = r2[t2] || [], r2[t2].push(e2));
- }
- function Ft(t2, e2, r2) {
- if (r2 && r2[t2]) {
- const n2 = r2[t2].indexOf(e2);
- -1 !== n2 && r2[t2].splice(n2, 1);
- }
- }
- class Lt {
- constructor(t2, e2 = {}) {
- b(this, e2), this.type = t2;
- }
- }
- class Rt extends Lt {
- constructor(t2, e2 = {}) {
- super("error", b({ error: t2 }, e2));
- }
- }
- class Ut {
- on(t2, e2) {
- return this._listeners = this._listeners || {}, Vt(t2, e2, this._listeners), this;
- }
- off(t2, e2) {
- return Ft(t2, e2, this._listeners), Ft(t2, e2, this._oneTimeListeners), this;
- }
- once(t2, e2) {
- return e2 ? (this._oneTimeListeners = this._oneTimeListeners || {}, Vt(t2, e2, this._oneTimeListeners), this) : new Promise((e3) => this.once(t2, e3));
- }
- fire(t2, e2) {
- "string" == typeof t2 && (t2 = new Lt(t2, e2 || {}));
- const r2 = t2.type;
- if (this.listens(r2)) {
- t2.target = this;
- const e3 = this._listeners && this._listeners[r2] ? this._listeners[r2].slice() : [];
- for (const r3 of e3)
- r3.call(this, t2);
- const n2 = this._oneTimeListeners && this._oneTimeListeners[r2] ? this._oneTimeListeners[r2].slice() : [];
- for (const e4 of n2)
- Ft(r2, e4, this._oneTimeListeners), e4.call(this, t2);
- const i3 = this._eventedParent;
- i3 && (b(t2, "function" == typeof this._eventedParentData ? this._eventedParentData() : this._eventedParentData), i3.fire(t2));
- } else
- t2 instanceof Rt && console.error(t2.error);
- return this;
- }
- listens(t2) {
- 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));
- }
- setEventedParent(t2, e2) {
- return this._eventedParent = t2, this._eventedParentData = e2, this;
- }
- }
- 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"}}}');
- function jt(t2, ...e2) {
- for (const r2 of e2)
- for (const e3 in r2)
- t2[e3] = r2[e3];
- return t2;
- }
- function Ot(t2) {
- return t2 instanceof Number || t2 instanceof String || t2 instanceof Boolean ? t2.valueOf() : t2;
- }
- function qt(t2) {
- if (Array.isArray(t2))
- return t2.map(qt);
- if (t2 instanceof Object && !(t2 instanceof Number || t2 instanceof String || t2 instanceof Boolean)) {
- const e2 = {};
- for (const r2 in t2)
- e2[r2] = qt(t2[r2]);
- return e2;
- }
- return Ot(t2);
- }
- class Nt extends Error {
- constructor(t2, e2) {
- super(e2), this.message = e2, this.key = t2;
- }
- }
- class Gt {
- constructor(t2, e2 = []) {
- this.parent = t2, this.bindings = {};
- for (const [t3, r2] of e2)
- this.bindings[t3] = r2;
- }
- concat(t2) {
- return new Gt(this, t2);
- }
- get(t2) {
- if (this.bindings[t2])
- return this.bindings[t2];
- if (this.parent)
- return this.parent.get(t2);
- throw new Error(`${t2} not found in scope.`);
- }
- has(t2) {
- return !!this.bindings[t2] || !!this.parent && this.parent.has(t2);
- }
- }
- 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" };
- function re(t2, e2) {
- return { kind: "array", itemType: t2, N: e2 };
- }
- function ne(t2) {
- if ("array" === t2.kind) {
- const e2 = ne(t2.itemType);
- return "number" == typeof t2.N ? `array<${e2}, ${t2.N}>` : "value" === t2.itemType.kind ? "array" : `array<${e2}>`;
- }
- return t2.kind;
- }
- const ie = [Zt, Xt, Kt, Yt, Ht, te, Wt, re(Jt), ee];
- function se(t2, e2) {
- if ("error" === e2.kind)
- return null;
- if ("array" === t2.kind) {
- if ("array" === e2.kind && (0 === e2.N && "value" === e2.itemType.kind || !se(t2.itemType, e2.itemType)) && ("number" != typeof t2.N || t2.N === e2.N))
- return null;
- } else {
- if (t2.kind === e2.kind)
- return null;
- if ("value" === t2.kind) {
- for (const t3 of ie)
- if (!se(t3, e2))
- return null;
- }
- }
- return `Expected ${ne(t2)} but found ${ne(e2)} instead.`;
- }
- function ae(t2, e2) {
- return e2.some((e3) => e3.kind === t2.kind);
- }
- function oe(t2, e2) {
- 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);
- }
- function le(t2) {
- var e2 = { exports: {} };
- return t2(e2, e2.exports), e2.exports;
- }
- var ue = le(function(t2, e2) {
- 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] };
- function n2(t3) {
- return (t3 = Math.round(t3)) < 0 ? 0 : t3 > 255 ? 255 : t3;
- }
- function i3(t3) {
- return n2("%" === t3[t3.length - 1] ? parseFloat(t3) / 100 * 255 : parseInt(t3));
- }
- function s2(t3) {
- return (e3 = "%" === t3[t3.length - 1] ? parseFloat(t3) / 100 : parseFloat(t3)) < 0 ? 0 : e3 > 1 ? 1 : e3;
- var e3;
- }
- function a2(t3, e3, r3) {
- 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;
- }
- try {
- e2.parseCSSColor = function(t3) {
- var e3, o2 = t3.replace(/ /g, "").toLowerCase();
- if (o2 in r2)
- return r2[o2].slice();
- if ("#" === o2[0])
- 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;
- var l2 = o2.indexOf("("), u2 = o2.indexOf(")");
- if (-1 !== l2 && u2 + 1 === o2.length) {
- var c2 = o2.substr(0, l2), h2 = o2.substr(l2 + 1, u2 - (l2 + 1)).split(","), p2 = 1;
- switch (c2) {
- case "rgba":
- if (4 !== h2.length)
- return null;
- p2 = s2(h2.pop());
- case "rgb":
- return 3 !== h2.length ? null : [i3(h2[0]), i3(h2[1]), i3(h2[2]), p2];
- case "hsla":
- if (4 !== h2.length)
- return null;
- p2 = s2(h2.pop());
- case "hsl":
- if (3 !== h2.length)
- return null;
- 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;
- return [n2(255 * a2(g2, m2, f2 + 1 / 3)), n2(255 * a2(g2, m2, f2)), n2(255 * a2(g2, m2, f2 - 1 / 3)), p2];
- default:
- return null;
- }
- }
- return null;
- };
- } catch (t3) {
- }
- });
- class ce {
- constructor(t2, e2, r2, n2 = 1) {
- this.r = t2, this.g = e2, this.b = r2, this.a = n2;
- }
- static parse(t2) {
- if (!t2)
- return;
- if (t2 instanceof ce)
- return t2;
- if ("string" != typeof t2)
- return;
- const e2 = ue.parseCSSColor(t2);
- return e2 ? new ce(e2[0] / 255 * e2[3], e2[1] / 255 * e2[3], e2[2] / 255 * e2[3], e2[3]) : void 0;
- }
- toString() {
- const [t2, e2, r2, n2] = this.toArray();
- return `rgba(${Math.round(t2)},${Math.round(e2)},${Math.round(r2)},${n2})`;
- }
- toArray() {
- const { r: t2, g: e2, b: r2, a: n2 } = this;
- return 0 === n2 ? [0, 0, 0, 0] : [255 * t2 / n2, 255 * e2 / n2, 255 * r2 / n2, n2];
- }
- }
- 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);
- class he {
- constructor(t2, e2, r2) {
- 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" });
- }
- compare(t2, e2) {
- return this.collator.compare(t2, e2);
- }
- resolvedLocale() {
- return new Intl.Collator(this.locale ? this.locale : []).resolvedOptions().locale;
- }
- }
- class pe {
- constructor(t2, e2, r2, n2, i3) {
- this.text = t2.normalize ? t2.normalize() : t2, this.image = e2, this.scale = r2, this.fontStack = n2, this.textColor = i3;
- }
- }
- class fe {
- constructor(t2) {
- this.sections = t2;
- }
- static fromString(t2) {
- return new fe([new pe(t2, null, null, null, null)]);
- }
- isEmpty() {
- return 0 === this.sections.length || !this.sections.some((t2) => 0 !== t2.text.length || t2.image && 0 !== t2.image.name.length);
- }
- static factory(t2) {
- return t2 instanceof fe ? t2 : fe.fromString(t2);
- }
- toString() {
- return 0 === this.sections.length ? "" : this.sections.map((t2) => t2.text).join("");
- }
- serialize() {
- const t2 = ["format"];
- for (const e2 of this.sections) {
- if (e2.image) {
- t2.push(["image", e2.image.name]);
- continue;
- }
- t2.push(e2.text);
- const r2 = {};
- 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);
- }
- return t2;
- }
- }
- class de {
- constructor(t2) {
- this.name = t2.name, this.available = t2.available;
- }
- toString() {
- return this.name;
- }
- static fromString(t2) {
- return t2 ? new de({ name: t2, available: false }) : null;
- }
- serialize() {
- return ["image", this.name];
- }
- }
- function ye(t2, e2, r2, n2) {
- 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.`;
- }
- function me(t2) {
- if (null === t2)
- return true;
- if ("string" == typeof t2)
- return true;
- if ("boolean" == typeof t2)
- return true;
- if ("number" == typeof t2)
- return true;
- if (t2 instanceof ce)
- return true;
- if (t2 instanceof he)
- return true;
- if (t2 instanceof fe)
- return true;
- if (t2 instanceof de)
- return true;
- if (Array.isArray(t2)) {
- for (const e2 of t2)
- if (!me(e2))
- return false;
- return true;
- }
- if ("object" == typeof t2) {
- for (const e2 in t2)
- if (!me(t2[e2]))
- return false;
- return true;
- }
- return false;
- }
- function ge(t2) {
- if (null === t2)
- return Zt;
- if ("string" == typeof t2)
- return Kt;
- if ("boolean" == typeof t2)
- return Yt;
- if ("number" == typeof t2)
- return Xt;
- if (t2 instanceof ce)
- return Ht;
- if (t2 instanceof he)
- return Qt;
- if (t2 instanceof fe)
- return te;
- if (t2 instanceof de)
- return ee;
- if (Array.isArray(t2)) {
- const e2 = t2.length;
- let r2;
- for (const e3 of t2) {
- const t3 = ge(e3);
- if (r2) {
- if (r2 === t3)
- continue;
- r2 = Jt;
- break;
- }
- r2 = t3;
- }
- return re(r2 || Jt, e2);
- }
- return Wt;
- }
- function xe(t2) {
- const e2 = typeof t2;
- 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);
- }
- class ve {
- constructor(t2, e2) {
- this.type = t2, this.value = e2;
- }
- static parse(t2, e2) {
- if (2 !== t2.length)
- return e2.error(`'literal' expression requires exactly one argument, but found ${t2.length - 1} instead.`);
- if (!me(t2[1]))
- return e2.error("invalid value");
- const r2 = t2[1];
- let n2 = ge(r2);
- const i3 = e2.expectedType;
- return "array" !== n2.kind || 0 !== n2.N || !i3 || "array" !== i3.kind || "number" == typeof i3.N && 0 !== i3.N || (n2 = i3), new ve(n2, r2);
- }
- evaluate() {
- return this.value;
- }
- eachChild() {
- }
- outputDefined() {
- return true;
- }
- serialize() {
- 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;
- }
- }
- class be {
- constructor(t2) {
- this.name = "ExpressionEvaluationError", this.message = t2;
- }
- toJSON() {
- return this.message;
- }
- }
- const _e = { string: Kt, number: Xt, boolean: Yt, object: Wt };
- class we {
- constructor(t2, e2) {
- this.type = t2, this.args = e2;
- }
- static parse(t2, e2) {
- if (t2.length < 2)
- return e2.error("Expected at least one argument.");
- let r2, n2 = 1;
- const i3 = t2[0];
- if ("array" === i3) {
- let i4, s3;
- if (t2.length > 2) {
- const r3 = t2[1];
- if ("string" != typeof r3 || !(r3 in _e) || "object" === r3)
- return e2.error('The item type argument of "array" must be one of string, number, boolean', 1);
- i4 = _e[r3], n2++;
- } else
- i4 = Jt;
- if (t2.length > 3) {
- if (null !== t2[2] && ("number" != typeof t2[2] || t2[2] < 0 || t2[2] !== Math.floor(t2[2])))
- return e2.error('The length argument to "array" must be a positive integer literal', 2);
- s3 = t2[2], n2++;
- }
- r2 = re(i4, s3);
- } else
- r2 = _e[i3];
- const s2 = [];
- for (; n2 < t2.length; n2++) {
- const r3 = e2.parse(t2[n2], n2, Jt);
- if (!r3)
- return null;
- s2.push(r3);
- }
- return new we(r2, s2);
- }
- evaluate(t2) {
- for (let e2 = 0; e2 < this.args.length; e2++) {
- const r2 = this.args[e2].evaluate(t2);
- if (!se(this.type, ge(r2)))
- return r2;
- if (e2 === this.args.length - 1)
- throw new be(`Expected value to be of type ${ne(this.type)}, but found ${ne(ge(r2))} instead.`);
- }
- return null;
- }
- eachChild(t2) {
- this.args.forEach(t2);
- }
- outputDefined() {
- return this.args.every((t2) => t2.outputDefined());
- }
- serialize() {
- const t2 = this.type, e2 = [t2.kind];
- if ("array" === t2.kind) {
- const r2 = t2.itemType;
- if ("string" === r2.kind || "number" === r2.kind || "boolean" === r2.kind) {
- e2.push(r2.kind);
- const n2 = t2.N;
- ("number" == typeof n2 || this.args.length > 1) && e2.push(n2);
- }
- }
- return e2.concat(this.args.map((t3) => t3.serialize()));
- }
- }
- class Ae {
- constructor(t2) {
- this.type = te, this.sections = t2;
- }
- static parse(t2, e2) {
- if (t2.length < 2)
- return e2.error("Expected at least one argument.");
- const r2 = t2[1];
- if (!Array.isArray(r2) && "object" == typeof r2)
- return e2.error("First argument must be an image or text section.");
- const n2 = [];
- let i3 = false;
- for (let r3 = 1; r3 <= t2.length - 1; ++r3) {
- const s2 = t2[r3];
- if (i3 && "object" == typeof s2 && !Array.isArray(s2)) {
- i3 = false;
- let t3 = null;
- if (s2["font-scale"] && (t3 = e2.parse(s2["font-scale"], 1, Xt), !t3))
- return null;
- let r4 = null;
- if (s2["text-font"] && (r4 = e2.parse(s2["text-font"], 1, re(Kt)), !r4))
- return null;
- let a2 = null;
- if (s2["text-color"] && (a2 = e2.parse(s2["text-color"], 1, Ht), !a2))
- return null;
- const o2 = n2[n2.length - 1];
- o2.scale = t3, o2.font = r4, o2.textColor = a2;
- } else {
- const s3 = e2.parse(t2[r3], 1, Jt);
- if (!s3)
- return null;
- const a2 = s3.type.kind;
- if ("string" !== a2 && "value" !== a2 && "null" !== a2 && "resolvedImage" !== a2)
- return e2.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");
- i3 = true, n2.push({ content: s3, scale: null, font: null, textColor: null });
- }
- }
- return new Ae(n2);
- }
- evaluate(t2) {
- return new fe(this.sections.map((e2) => {
- const r2 = e2.content.evaluate(t2);
- 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);
- }));
- }
- eachChild(t2) {
- for (const e2 of this.sections)
- t2(e2.content), e2.scale && t2(e2.scale), e2.font && t2(e2.font), e2.textColor && t2(e2.textColor);
- }
- outputDefined() {
- return false;
- }
- serialize() {
- const t2 = ["format"];
- for (const e2 of this.sections) {
- t2.push(e2.content.serialize());
- const r2 = {};
- 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);
- }
- return t2;
- }
- }
- class ke {
- constructor(t2) {
- this.type = ee, this.input = t2;
- }
- static parse(t2, e2) {
- if (2 !== t2.length)
- return e2.error("Expected two arguments.");
- const r2 = e2.parse(t2[1], 1, Kt);
- return r2 ? new ke(r2) : e2.error("No image name provided.");
- }
- evaluate(t2) {
- const e2 = this.input.evaluate(t2), r2 = de.fromString(e2);
- return r2 && t2.availableImages && (r2.available = t2.availableImages.indexOf(e2) > -1), r2;
- }
- eachChild(t2) {
- t2(this.input);
- }
- outputDefined() {
- return false;
- }
- serialize() {
- return ["image", this.input.serialize()];
- }
- }
- const Se = { "to-boolean": Yt, "to-color": Ht, "to-number": Xt, "to-string": Kt };
- class Ie {
- constructor(t2, e2) {
- this.type = t2, this.args = e2;
- }
- static parse(t2, e2) {
- if (t2.length < 2)
- return e2.error("Expected at least one argument.");
- const r2 = t2[0];
- if (("to-boolean" === r2 || "to-string" === r2) && 2 !== t2.length)
- return e2.error("Expected one argument.");
- const n2 = Se[r2], i3 = [];
- for (let r3 = 1; r3 < t2.length; r3++) {
- const n3 = e2.parse(t2[r3], r3, Jt);
- if (!n3)
- return null;
- i3.push(n3);
- }
- return new Ie(n2, i3);
- }
- evaluate(t2) {
- if ("boolean" === this.type.kind)
- return Boolean(this.args[0].evaluate(t2));
- if ("color" === this.type.kind) {
- let e2, r2;
- for (const n2 of this.args) {
- if (e2 = n2.evaluate(t2), r2 = null, e2 instanceof ce)
- return e2;
- if ("string" == typeof e2) {
- const r3 = t2.parseColor(e2);
- if (r3)
- return r3;
- } 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))
- return new ce(e2[0] / 255, e2[1] / 255, e2[2] / 255, e2[3]);
- }
- throw new be(r2 || `Could not parse color from value '${"string" == typeof e2 ? e2 : String(JSON.stringify(e2))}'`);
- }
- if ("number" === this.type.kind) {
- let e2 = null;
- for (const r2 of this.args) {
- if (e2 = r2.evaluate(t2), null === e2)
- return 0;
- const n2 = Number(e2);
- if (!isNaN(n2))
- return n2;
- }
- throw new be(`Could not convert ${JSON.stringify(e2)} to number.`);
- }
- 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));
- }
- eachChild(t2) {
- this.args.forEach(t2);
- }
- outputDefined() {
- return this.args.every((t2) => t2.outputDefined());
- }
- serialize() {
- if ("formatted" === this.type.kind)
- return new Ae([{ content: this.args[0], scale: null, font: null, textColor: null }]).serialize();
- if ("resolvedImage" === this.type.kind)
- return new ke(this.args[0]).serialize();
- const t2 = [`to-${this.type.kind}`];
- return this.eachChild((e2) => {
- t2.push(e2.serialize());
- }), t2;
- }
- }
- const Me = ["Unknown", "Point", "LineString", "Polygon"];
- class Te {
- constructor() {
- 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;
- }
- id() {
- return this.feature && "id" in this.feature && this.feature.id ? this.feature.id : null;
- }
- geometryType() {
- return this.feature ? "number" == typeof this.feature.type ? Me[this.feature.type] : this.feature.type : null;
- }
- geometry() {
- return this.feature && "geometry" in this.feature ? this.feature.geometry : null;
- }
- canonicalID() {
- return this.canonical;
- }
- properties() {
- return this.feature && this.feature.properties || {};
- }
- distanceFromCenter() {
- if (this.featureTileCoord && this.featureDistanceData) {
- const t2 = this.featureDistanceData.center, e2 = this.featureDistanceData.scale, { x: r2, y: n2 } = this.featureTileCoord;
- return this.featureDistanceData.bearing[0] * (r2 * e2 - t2[0]) + this.featureDistanceData.bearing[1] * (n2 * e2 - t2[1]);
- }
- return 0;
- }
- parseColor(t2) {
- let e2 = this._parseColorCache[t2];
- return e2 || (e2 = this._parseColorCache[t2] = ce.parse(t2)), e2;
- }
- }
- class ze {
- constructor(t2, e2, r2, n2) {
- this.name = t2, this.type = e2, this._evaluate = r2, this.args = n2;
- }
- evaluate(t2) {
- return this._evaluate(t2, this.args);
- }
- eachChild(t2) {
- this.args.forEach(t2);
- }
- outputDefined() {
- return false;
- }
- serialize() {
- return [this.name].concat(this.args.map((t2) => t2.serialize()));
- }
- static parse(t2, e2) {
- const r2 = t2[0], n2 = ze.definitions[r2];
- if (!n2)
- return e2.error(`Unknown expression "${r2}". If you wanted a literal array, use ["literal", [...]].`, 0);
- 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);
- let o2 = null;
- for (const [n3, s3] of a2) {
- o2 = new Je(e2.registry, e2.path, null, e2.scope);
- const a3 = [];
- let l2 = false;
- for (let e3 = 1; e3 < t2.length; e3++) {
- const r3 = t2[e3], i4 = Array.isArray(n3) ? n3[e3 - 1] : n3.type, s4 = o2.parse(r3, 1 + a3.length, i4);
- if (!s4) {
- l2 = true;
- break;
- }
- a3.push(s4);
- }
- if (!l2)
- if (Array.isArray(n3) && n3.length !== a3.length)
- o2.error(`Expected ${n3.length} arguments, but found ${a3.length} instead.`);
- else {
- for (let t3 = 0; t3 < a3.length; t3++) {
- const e3 = Array.isArray(n3) ? n3[t3] : n3.type, r3 = a3[t3];
- o2.concat(t3 + 1).checkSubtype(e3, r3.type);
- }
- if (0 === o2.errors.length)
- return new ze(r2, i3, s3, a3);
- }
- }
- if (1 === a2.length)
- e2.errors.push(...o2.errors);
- else {
- const r3 = (a2.length ? a2 : s2).map(([t3]) => {
- return e3 = t3, Array.isArray(e3) ? `(${e3.map(ne).join(", ")})` : `(${ne(e3.type)}...)`;
- var e3;
- }).join(" | "), n3 = [];
- for (let r4 = 1; r4 < t2.length; r4++) {
- const i4 = e2.parse(t2[r4], 1 + n3.length);
- if (!i4)
- return null;
- n3.push(ne(i4.type));
- }
- e2.error(`Expected arguments of type ${r3}, but found (${n3.join(", ")}) instead.`);
- }
- return null;
- }
- static register(t2, e2) {
- ze.definitions = e2;
- for (const r2 in e2)
- t2[r2] = ze;
- }
- }
- class Be {
- constructor(t2, e2, r2) {
- this.type = Qt, this.locale = r2, this.caseSensitive = t2, this.diacriticSensitive = e2;
- }
- static parse(t2, e2) {
- if (2 !== t2.length)
- return e2.error("Expected one argument.");
- const r2 = t2[1];
- if ("object" != typeof r2 || Array.isArray(r2))
- return e2.error("Collator options argument must be an object.");
- const n2 = e2.parse(void 0 !== r2["case-sensitive"] && r2["case-sensitive"], 1, Yt);
- if (!n2)
- return null;
- const i3 = e2.parse(void 0 !== r2["diacritic-sensitive"] && r2["diacritic-sensitive"], 1, Yt);
- if (!i3)
- return null;
- let s2 = null;
- return r2.locale && (s2 = e2.parse(r2.locale, 1, Kt), !s2) ? null : new Be(n2, i3, s2);
- }
- evaluate(t2) {
- return new he(this.caseSensitive.evaluate(t2), this.diacriticSensitive.evaluate(t2), this.locale ? this.locale.evaluate(t2) : null);
- }
- eachChild(t2) {
- t2(this.caseSensitive), t2(this.diacriticSensitive), this.locale && t2(this.locale);
- }
- outputDefined() {
- return false;
- }
- serialize() {
- const t2 = {};
- return t2["case-sensitive"] = this.caseSensitive.serialize(), t2["diacritic-sensitive"] = this.diacriticSensitive.serialize(), this.locale && (t2.locale = this.locale.serialize()), ["collator", t2];
- }
- }
- const Ee = 8192;
- function Ce(t2, e2) {
- 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]);
- }
- function De(t2, e2) {
- return !(t2[0] <= e2[0] || t2[2] >= e2[2] || t2[1] <= e2[1] || t2[3] >= e2[3]);
- }
- function Pe(t2, e2) {
- 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);
- return [Math.round(r2 * i3 * Ee), Math.round(n2 * i3 * Ee)];
- }
- function Ve(t2, e2, r2) {
- const n2 = t2[0] - e2[0], i3 = t2[1] - e2[1], s2 = t2[0] - r2[0], a2 = t2[1] - r2[1];
- return n2 * a2 - s2 * i3 == 0 && n2 * s2 <= 0 && i3 * a2 <= 0;
- }
- function Fe(t2, e2) {
- let r2 = false;
- for (let a2 = 0, o2 = e2.length; a2 < o2; a2++) {
- const o3 = e2[a2];
- for (let e3 = 0, a3 = o3.length; e3 < a3 - 1; e3++) {
- if (Ve(t2, o3[e3], o3[e3 + 1]))
- return false;
- (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);
- }
- }
- var n2, i3, s2;
- return r2;
- }
- function Le(t2, e2) {
- for (let r2 = 0; r2 < e2.length; r2++)
- if (Fe(t2, e2[r2]))
- return true;
- return false;
- }
- function Re(t2, e2, r2, n2) {
- 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]);
- return a2 > 0 && o2 < 0 || a2 < 0 && o2 > 0;
- }
- function Ue(t2, e2, r2) {
- for (const u2 of r2)
- for (let r3 = 0; r3 < u2.length - 1; ++r3)
- 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))
- return true;
- var n2, i3, s2, a2, o2, l2;
- return false;
- }
- function $e(t2, e2) {
- for (let r2 = 0; r2 < t2.length; ++r2)
- if (!Fe(t2[r2], e2))
- return false;
- for (let r2 = 0; r2 < t2.length - 1; ++r2)
- if (Ue(t2[r2], t2[r2 + 1], e2))
- return false;
- return true;
- }
- function je(t2, e2) {
- for (let r2 = 0; r2 < e2.length; r2++)
- if ($e(t2, e2[r2]))
- return true;
- return false;
- }
- function Oe(t2, e2, r2) {
- const n2 = [];
- for (let i3 = 0; i3 < t2.length; i3++) {
- const s2 = [];
- for (let n3 = 0; n3 < t2[i3].length; n3++) {
- const a2 = Pe(t2[i3][n3], r2);
- Ce(e2, a2), s2.push(a2);
- }
- n2.push(s2);
- }
- return n2;
- }
- function qe(t2, e2, r2) {
- const n2 = [];
- for (let i3 = 0; i3 < t2.length; i3++) {
- const s2 = Oe(t2[i3], e2, r2);
- n2.push(s2);
- }
- return n2;
- }
- function Ne(t2, e2, r2, n2) {
- if (t2[0] < r2[0] || t2[0] > r2[2]) {
- const e3 = 0.5 * n2;
- let i3 = t2[0] - r2[0] > e3 ? -n2 : r2[0] - t2[0] > e3 ? n2 : 0;
- 0 === i3 && (i3 = t2[0] - r2[2] > e3 ? -n2 : r2[2] - t2[0] > e3 ? n2 : 0), t2[0] += i3;
- }
- Ce(e2, t2);
- }
- function Ge(t2, e2, r2, n2) {
- const i3 = Math.pow(2, n2.z) * Ee, s2 = [n2.x * Ee, n2.y * Ee], a2 = [];
- if (!t2)
- return a2;
- for (const n3 of t2)
- for (const t3 of n3) {
- const n4 = [t3.x + s2[0], t3.y + s2[1]];
- Ne(n4, e2, r2, i3), a2.push(n4);
- }
- return a2;
- }
- function Ze(t2, e2, r2, n2) {
- const i3 = Math.pow(2, n2.z) * Ee, s2 = [n2.x * Ee, n2.y * Ee], a2 = [];
- if (!t2)
- return a2;
- for (const r3 of t2) {
- const t3 = [];
- for (const n3 of r3) {
- const r4 = [n3.x + s2[0], n3.y + s2[1]];
- Ce(e2, r4), t3.push(r4);
- }
- a2.push(t3);
- }
- if (e2[2] - e2[0] <= i3 / 2) {
- (o2 = e2)[0] = o2[1] = 1 / 0, o2[2] = o2[3] = -1 / 0;
- for (const t3 of a2)
- for (const n3 of t3)
- Ne(n3, e2, r2, i3);
- }
- var o2;
- return a2;
- }
- class Xe {
- constructor(t2, e2) {
- this.type = Yt, this.geojson = t2, this.geometries = e2;
- }
- static parse(t2, e2) {
- if (2 !== t2.length)
- return e2.error(`'within' expression requires exactly one argument, but found ${t2.length - 1} instead.`);
- if (me(t2[1])) {
- const e3 = t2[1];
- if ("FeatureCollection" === e3.type)
- for (let t3 = 0; t3 < e3.features.length; ++t3) {
- const r2 = e3.features[t3].geometry.type;
- if ("Polygon" === r2 || "MultiPolygon" === r2)
- return new Xe(e3, e3.features[t3].geometry);
- }
- else if ("Feature" === e3.type) {
- const t3 = e3.geometry.type;
- if ("Polygon" === t3 || "MultiPolygon" === t3)
- return new Xe(e3, e3.geometry);
- } else if ("Polygon" === e3.type || "MultiPolygon" === e3.type)
- return new Xe(e3, e3);
- }
- return e2.error("'within' expression requires valid geojson object that contains polygon geometry type.");
- }
- evaluate(t2) {
- if (null != t2.geometry() && null != t2.canonicalID()) {
- if ("Point" === t2.geometryType())
- return function(t3, e2) {
- const r2 = [1 / 0, 1 / 0, -1 / 0, -1 / 0], n2 = [1 / 0, 1 / 0, -1 / 0, -1 / 0], i3 = t3.canonicalID();
- if (!i3)
- return false;
- if ("Polygon" === e2.type) {
- const s2 = Oe(e2.coordinates, n2, i3), a2 = Ge(t3.geometry(), r2, n2, i3);
- if (!De(r2, n2))
- return false;
- for (const t4 of a2)
- if (!Fe(t4, s2))
- return false;
- }
- if ("MultiPolygon" === e2.type) {
- const s2 = qe(e2.coordinates, n2, i3), a2 = Ge(t3.geometry(), r2, n2, i3);
- if (!De(r2, n2))
- return false;
- for (const t4 of a2)
- if (!Le(t4, s2))
- return false;
- }
- return true;
- }(t2, this.geometries);
- if ("LineString" === t2.geometryType())
- return function(t3, e2) {
- const r2 = [1 / 0, 1 / 0, -1 / 0, -1 / 0], n2 = [1 / 0, 1 / 0, -1 / 0, -1 / 0], i3 = t3.canonicalID();
- if (!i3)
- return false;
- if ("Polygon" === e2.type) {
- const s2 = Oe(e2.coordinates, n2, i3), a2 = Ze(t3.geometry(), r2, n2, i3);
- if (!De(r2, n2))
- return false;
- for (const t4 of a2)
- if (!$e(t4, s2))
- return false;
- }
- if ("MultiPolygon" === e2.type) {
- const s2 = qe(e2.coordinates, n2, i3), a2 = Ze(t3.geometry(), r2, n2, i3);
- if (!De(r2, n2))
- return false;
- for (const t4 of a2)
- if (!je(t4, s2))
- return false;
- }
- return true;
- }(t2, this.geometries);
- }
- return false;
- }
- eachChild() {
- }
- outputDefined() {
- return true;
- }
- serialize() {
- return ["within", this.geojson];
- }
- }
- function Ke(t2) {
- if (t2 instanceof ze) {
- if ("get" === t2.name && 1 === t2.args.length)
- return false;
- if ("feature-state" === t2.name)
- return false;
- if ("has" === t2.name && 1 === t2.args.length)
- return false;
- if ("properties" === t2.name || "geometry-type" === t2.name || "id" === t2.name)
- return false;
- if (/^filter-/.test(t2.name))
- return false;
- }
- if (t2 instanceof Xe)
- return false;
- let e2 = true;
- return t2.eachChild((t3) => {
- e2 && !Ke(t3) && (e2 = false);
- }), e2;
- }
- function Ye(t2) {
- if (t2 instanceof ze && "feature-state" === t2.name)
- return false;
- let e2 = true;
- return t2.eachChild((t3) => {
- e2 && !Ye(t3) && (e2 = false);
- }), e2;
- }
- function He(t2, e2) {
- if (t2 instanceof ze && e2.indexOf(t2.name) >= 0)
- return false;
- let r2 = true;
- return t2.eachChild((t3) => {
- r2 && !He(t3, e2) && (r2 = false);
- }), r2;
- }
- class We {
- constructor(t2, e2) {
- this.type = e2.type, this.name = t2, this.boundExpression = e2;
- }
- static parse(t2, e2) {
- if (2 !== t2.length || "string" != typeof t2[1])
- return e2.error("'var' expression requires exactly one string literal argument.");
- const r2 = t2[1];
- 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);
- }
- evaluate(t2) {
- return this.boundExpression.evaluate(t2);
- }
- eachChild() {
- }
- outputDefined() {
- return false;
- }
- serialize() {
- return ["var", this.name];
- }
- }
- class Je {
- constructor(t2, e2 = [], r2, n2 = new Gt(), i3 = []) {
- this.registry = t2, this.path = e2, this.key = e2.map((t3) => `[${t3}]`).join(""), this.scope = n2, this.errors = i3, this.expectedType = r2;
- }
- parse(t2, e2, r2, n2, i3 = {}) {
- return e2 ? this.concat(e2, r2, n2)._parse(t2, i3) : this._parse(t2, i3);
- }
- _parse(t2, e2) {
- function r2(t3, e3, r3) {
- return "assert" === r3 ? new we(e3, [t3]) : "coerce" === r3 ? new Ie(e3, [t3]) : t3;
- }
- if (null !== t2 && "string" != typeof t2 && "boolean" != typeof t2 && "number" != typeof t2 || (t2 = ["literal", t2]), Array.isArray(t2)) {
- if (0 === t2.length)
- return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');
- const n2 = t2[0];
- if ("string" != typeof n2)
- return this.error(`Expression name must be a string, but found ${typeof n2} instead. If you wanted a literal array, use ["literal", [...]].`, 0), null;
- const i3 = this.registry[n2];
- if (i3) {
- let n3 = i3.parse(t2, this);
- if (!n3)
- return null;
- if (this.expectedType) {
- const t3 = this.expectedType, i4 = n3.type;
- if ("string" !== t3.kind && "number" !== t3.kind && "boolean" !== t3.kind && "object" !== t3.kind && "array" !== t3.kind || "value" !== i4.kind)
- if ("color" !== t3.kind && "formatted" !== t3.kind && "resolvedImage" !== t3.kind || "value" !== i4.kind && "string" !== i4.kind) {
- if (this.checkSubtype(t3, i4))
- return null;
- } else
- n3 = r2(n3, t3, e2.typeAnnotation || "coerce");
- else
- n3 = r2(n3, t3, e2.typeAnnotation || "assert");
- }
- if (!(n3 instanceof ve) && "resolvedImage" !== n3.type.kind && Qe(n3)) {
- const t3 = new Te();
- try {
- n3 = new ve(n3.type, n3.evaluate(t3));
- } catch (t4) {
- return this.error(t4.message), null;
- }
- }
- return n3;
- }
- return this.error(`Unknown expression "${n2}". If you wanted a literal array, use ["literal", [...]].`, 0);
- }
- 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.`);
- }
- concat(t2, e2, r2) {
- const n2 = "number" == typeof t2 ? this.path.concat(t2) : this.path, i3 = r2 ? this.scope.concat(r2) : this.scope;
- return new Je(this.registry, n2, e2 || null, i3, this.errors);
- }
- error(t2, ...e2) {
- const r2 = `${this.key}${e2.map((t3) => `[${t3}]`).join("")}`;
- this.errors.push(new Nt(r2, t2));
- }
- checkSubtype(t2, e2) {
- const r2 = se(t2, e2);
- return r2 && this.error(r2), r2;
- }
- }
- function Qe(t2) {
- if (t2 instanceof We)
- return Qe(t2.boundExpression);
- if (t2 instanceof ze && "error" === t2.name)
- return false;
- if (t2 instanceof Be)
- return false;
- if (t2 instanceof Xe)
- return false;
- const e2 = t2 instanceof Ie || t2 instanceof we;
- let r2 = true;
- return t2.eachChild((t3) => {
- r2 = e2 ? r2 && Qe(t3) : r2 && t3 instanceof ve;
- }), !!r2 && Ke(t2) && He(t2, ["zoom", "heatmap-density", "line-progress", "sky-radial-progress", "accumulated", "is-supported-script", "pitch", "distance-from-center"]);
- }
- function tr(t2, e2) {
- const r2 = t2.length - 1;
- let n2, i3, s2 = 0, a2 = r2, o2 = 0;
- for (; s2 <= a2; )
- if (o2 = Math.floor((s2 + a2) / 2), n2 = t2[o2], i3 = t2[o2 + 1], n2 <= e2) {
- if (o2 === r2 || e2 < i3)
- return o2;
- s2 = o2 + 1;
- } else {
- if (!(n2 > e2))
- throw new be("Input is not a number.");
- a2 = o2 - 1;
- }
- return 0;
- }
- class er {
- constructor(t2, e2, r2) {
- this.type = t2, this.input = e2, this.labels = [], this.outputs = [];
- for (const [t3, e3] of r2)
- this.labels.push(t3), this.outputs.push(e3);
- }
- static parse(t2, e2) {
- if (t2.length - 1 < 4)
- return e2.error(`Expected at least 4 arguments, but found only ${t2.length - 1}.`);
- if ((t2.length - 1) % 2 != 0)
- return e2.error("Expected an even number of arguments.");
- const r2 = e2.parse(t2[1], 1, Xt);
- if (!r2)
- return null;
- const n2 = [];
- let i3 = null;
- e2.expectedType && "value" !== e2.expectedType.kind && (i3 = e2.expectedType);
- for (let r3 = 1; r3 < t2.length; r3 += 2) {
- const s2 = 1 === r3 ? -1 / 0 : t2[r3], a2 = t2[r3 + 1], o2 = r3, l2 = r3 + 1;
- if ("number" != typeof s2)
- return e2.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.', o2);
- if (n2.length && n2[n2.length - 1][0] >= s2)
- return e2.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.', o2);
- const u2 = e2.parse(a2, l2, i3);
- if (!u2)
- return null;
- i3 = i3 || u2.type, n2.push([s2, u2]);
- }
- return new er(i3, r2, n2);
- }
- evaluate(t2) {
- const e2 = this.labels, r2 = this.outputs;
- if (1 === e2.length)
- return r2[0].evaluate(t2);
- const n2 = this.input.evaluate(t2);
- if (n2 <= e2[0])
- return r2[0].evaluate(t2);
- const i3 = e2.length;
- return n2 >= e2[i3 - 1] ? r2[i3 - 1].evaluate(t2) : r2[tr(e2, n2)].evaluate(t2);
- }
- eachChild(t2) {
- t2(this.input);
- for (const e2 of this.outputs)
- t2(e2);
- }
- outputDefined() {
- return this.outputs.every((t2) => t2.outputDefined());
- }
- serialize() {
- const t2 = ["step", this.input.serialize()];
- for (let e2 = 0; e2 < this.labels.length; e2++)
- e2 > 0 && t2.push(this.labels[e2]), t2.push(this.outputs[e2].serialize());
- return t2;
- }
- }
- function rr(t2, e2, r2) {
- return t2 * (1 - r2) + e2 * r2;
- }
- var nr = Object.freeze({ __proto__: null, number: rr, color: function(t2, e2, r2) {
- 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));
- }, array: function(t2, e2, r2) {
- return t2.map((t3, n2) => rr(t3, e2[n2], r2));
- } });
- 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;
- function hr(t2) {
- return t2 > 0.008856451679035631 ? Math.pow(t2, 1 / 3) : t2 / lr + ar;
- }
- function pr(t2) {
- return t2 > or ? t2 * t2 * t2 : lr * (t2 - ar);
- }
- function fr(t2) {
- return 255 * (t2 <= 31308e-7 ? 12.92 * t2 : 1.055 * Math.pow(t2, 1 / 2.4) - 0.055);
- }
- function dr(t2) {
- return (t2 /= 255) <= 0.04045 ? t2 / 12.92 : Math.pow((t2 + 0.055) / 1.055, 2.4);
- }
- function yr(t2) {
- 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);
- 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 };
- }
- function mr(t2) {
- let e2 = (t2.l + 16) / 116, r2 = isNaN(t2.a) ? e2 : e2 + t2.a / 500, n2 = isNaN(t2.b) ? e2 : e2 - t2.b / 200;
- 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);
- }
- function gr(t2, e2, r2) {
- const n2 = e2 - t2;
- return t2 + r2 * (n2 > 180 || n2 < -180 ? n2 - 360 * Math.round(n2 / 360) : n2);
- }
- const xr = { forward: yr, reverse: mr, interpolate: function(t2, e2, r2) {
- 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) };
- } }, vr = { forward: function(t2) {
- const { l: e2, a: r2, b: n2 } = yr(t2), i3 = Math.atan2(n2, r2) * cr;
- return { h: i3 < 0 ? i3 + 360 : i3, c: Math.sqrt(r2 * r2 + n2 * n2), l: e2, alpha: t2.a };
- }, reverse: function(t2) {
- const e2 = t2.h * ur, r2 = t2.c;
- return mr({ l: t2.l, a: Math.cos(e2) * r2, b: Math.sin(e2) * r2, alpha: t2.alpha });
- }, interpolate: function(t2, e2, r2) {
- 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) };
- } };
- var br = Object.freeze({ __proto__: null, lab: xr, hcl: vr });
- class _r {
- constructor(t2, e2, r2, n2, i3) {
- this.type = t2, this.operator = e2, this.interpolation = r2, this.input = n2, this.labels = [], this.outputs = [];
- for (const [t3, e3] of i3)
- this.labels.push(t3), this.outputs.push(e3);
- }
- static interpolationFactor(t2, e2, n2, i3) {
- let s2 = 0;
- if ("exponential" === t2.name)
- s2 = wr(e2, t2.base, n2, i3);
- else if ("linear" === t2.name)
- s2 = wr(e2, 1, n2, i3);
- else if ("cubic-bezier" === t2.name) {
- const a2 = t2.controlPoints;
- s2 = new r(a2[0], a2[1], a2[2], a2[3]).solve(wr(e2, 1, n2, i3));
- }
- return s2;
- }
- static parse(t2, e2) {
- let [r2, n2, i3, ...s2] = t2;
- if (!Array.isArray(n2) || 0 === n2.length)
- return e2.error("Expected an interpolation type expression.", 1);
- if ("linear" === n2[0])
- n2 = { name: "linear" };
- else if ("exponential" === n2[0]) {
- const t3 = n2[1];
- if ("number" != typeof t3)
- return e2.error("Exponential interpolation requires a numeric base.", 1, 1);
- n2 = { name: "exponential", base: t3 };
- } else {
- if ("cubic-bezier" !== n2[0])
- return e2.error(`Unknown interpolation type ${String(n2[0])}`, 1, 0);
- {
- const t3 = n2.slice(1);
- if (4 !== t3.length || t3.some((t4) => "number" != typeof t4 || t4 < 0 || t4 > 1))
- return e2.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.", 1);
- n2 = { name: "cubic-bezier", controlPoints: t3 };
- }
- }
- if (t2.length - 1 < 4)
- return e2.error(`Expected at least 4 arguments, but found only ${t2.length - 1}.`);
- if ((t2.length - 1) % 2 != 0)
- return e2.error("Expected an even number of arguments.");
- if (i3 = e2.parse(i3, 2, Xt), !i3)
- return null;
- const a2 = [];
- let o2 = null;
- "interpolate-hcl" === r2 || "interpolate-lab" === r2 ? o2 = Ht : e2.expectedType && "value" !== e2.expectedType.kind && (o2 = e2.expectedType);
- for (let t3 = 0; t3 < s2.length; t3 += 2) {
- const r3 = s2[t3], n3 = s2[t3 + 1], i4 = t3 + 3, l2 = t3 + 4;
- if ("number" != typeof r3)
- return e2.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.', i4);
- if (a2.length && a2[a2.length - 1][0] >= r3)
- return e2.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.', i4);
- const u2 = e2.parse(n3, l2, o2);
- if (!u2)
- return null;
- o2 = o2 || u2.type, a2.push([r3, u2]);
- }
- 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.`);
- }
- evaluate(t2) {
- const e2 = this.labels, r2 = this.outputs;
- if (1 === e2.length)
- return r2[0].evaluate(t2);
- const n2 = this.input.evaluate(t2);
- if (n2 <= e2[0])
- return r2[0].evaluate(t2);
- const i3 = e2.length;
- if (n2 >= e2[i3 - 1])
- return r2[i3 - 1].evaluate(t2);
- 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);
- 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));
- }
- eachChild(t2) {
- t2(this.input);
- for (const e2 of this.outputs)
- t2(e2);
- }
- outputDefined() {
- return this.outputs.every((t2) => t2.outputDefined());
- }
- serialize() {
- let t2;
- 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);
- const e2 = [this.operator, t2, this.input.serialize()];
- for (let t3 = 0; t3 < this.labels.length; t3++)
- e2.push(this.labels[t3], this.outputs[t3].serialize());
- return e2;
- }
- }
- function wr(t2, e2, r2, n2) {
- const i3 = n2 - r2, s2 = t2 - r2;
- return 0 === i3 ? 0 : 1 === e2 ? s2 / i3 : (Math.pow(e2, s2) - 1) / (Math.pow(e2, i3) - 1);
- }
- class Ar {
- constructor(t2, e2) {
- this.type = t2, this.args = e2;
- }
- static parse(t2, e2) {
- if (t2.length < 2)
- return e2.error("Expectected at least one argument.");
- let r2 = null;
- const n2 = e2.expectedType;
- n2 && "value" !== n2.kind && (r2 = n2);
- const i3 = [];
- for (const n3 of t2.slice(1)) {
- const t3 = e2.parse(n3, 1 + i3.length, r2, void 0, { typeAnnotation: "omit" });
- if (!t3)
- return null;
- r2 = r2 || t3.type, i3.push(t3);
- }
- const s2 = n2 && i3.some((t3) => se(n2, t3.type));
- return new Ar(s2 ? Jt : r2, i3);
- }
- evaluate(t2) {
- let e2, r2 = null, n2 = 0;
- for (const i3 of this.args) {
- if (n2++, r2 = i3.evaluate(t2), r2 && r2 instanceof de && !r2.available && (e2 || (e2 = r2), r2 = null, n2 === this.args.length))
- return e2;
- if (null !== r2)
- break;
- }
- return r2;
- }
- eachChild(t2) {
- this.args.forEach(t2);
- }
- outputDefined() {
- return this.args.every((t2) => t2.outputDefined());
- }
- serialize() {
- const t2 = ["coalesce"];
- return this.eachChild((e2) => {
- t2.push(e2.serialize());
- }), t2;
- }
- }
- class kr {
- constructor(t2, e2) {
- this.type = e2.type, this.bindings = [].concat(t2), this.result = e2;
- }
- evaluate(t2) {
- return this.result.evaluate(t2);
- }
- eachChild(t2) {
- for (const e2 of this.bindings)
- t2(e2[1]);
- t2(this.result);
- }
- static parse(t2, e2) {
- if (t2.length < 4)
- return e2.error(`Expected at least 3 arguments, but found ${t2.length - 1} instead.`);
- const r2 = [];
- for (let n3 = 1; n3 < t2.length - 1; n3 += 2) {
- const i3 = t2[n3];
- if ("string" != typeof i3)
- return e2.error(`Expected string, but found ${typeof i3} instead.`, n3);
- if (/[^a-zA-Z0-9_]/.test(i3))
- return e2.error("Variable names must contain only alphanumeric characters or '_'.", n3);
- const s2 = e2.parse(t2[n3 + 1], n3 + 1);
- if (!s2)
- return null;
- r2.push([i3, s2]);
- }
- const n2 = e2.parse(t2[t2.length - 1], t2.length - 1, e2.expectedType, r2);
- return n2 ? new kr(r2, n2) : null;
- }
- outputDefined() {
- return this.result.outputDefined();
- }
- serialize() {
- const t2 = ["let"];
- for (const [e2, r2] of this.bindings)
- t2.push(e2, r2.serialize());
- return t2.push(this.result.serialize()), t2;
- }
- }
- class Sr {
- constructor(t2, e2, r2) {
- this.type = t2, this.index = e2, this.input = r2;
- }
- static parse(t2, e2) {
- if (3 !== t2.length)
- return e2.error(`Expected 2 arguments, but found ${t2.length - 1} instead.`);
- const r2 = e2.parse(t2[1], 1, Xt), n2 = e2.parse(t2[2], 2, re(e2.expectedType || Jt));
- return r2 && n2 ? new Sr(n2.type.itemType, r2, n2) : null;
- }
- evaluate(t2) {
- const e2 = this.index.evaluate(t2), r2 = this.input.evaluate(t2);
- if (e2 < 0)
- throw new be(`Array index out of bounds: ${e2} < 0.`);
- if (e2 >= r2.length)
- throw new be(`Array index out of bounds: ${e2} > ${r2.length - 1}.`);
- if (e2 !== Math.floor(e2))
- throw new be(`Array index must be an integer, but found ${e2} instead.`);
- return r2[e2];
- }
- eachChild(t2) {
- t2(this.index), t2(this.input);
- }
- outputDefined() {
- return false;
- }
- serialize() {
- return ["at", this.index.serialize(), this.input.serialize()];
- }
- }
- class Ir {
- constructor(t2, e2) {
- this.type = Yt, this.needle = t2, this.haystack = e2;
- }
- static parse(t2, e2) {
- if (3 !== t2.length)
- return e2.error(`Expected 2 arguments, but found ${t2.length - 1} instead.`);
- const r2 = e2.parse(t2[1], 1, Jt), n2 = e2.parse(t2[2], 2, Jt);
- 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;
- }
- evaluate(t2) {
- const e2 = this.needle.evaluate(t2), r2 = this.haystack.evaluate(t2);
- if (null == r2)
- return false;
- if (!oe(e2, ["boolean", "string", "number", "null"]))
- throw new be(`Expected first argument to be of type boolean, string, number or null, but found ${ne(ge(e2))} instead.`);
- if (!oe(r2, ["string", "array"]))
- throw new be(`Expected second argument to be of type array or string, but found ${ne(ge(r2))} instead.`);
- return r2.indexOf(e2) >= 0;
- }
- eachChild(t2) {
- t2(this.needle), t2(this.haystack);
- }
- outputDefined() {
- return true;
- }
- serialize() {
- return ["in", this.needle.serialize(), this.haystack.serialize()];
- }
- }
- class Mr {
- constructor(t2, e2, r2) {
- this.type = Xt, this.needle = t2, this.haystack = e2, this.fromIndex = r2;
- }
- static parse(t2, e2) {
- if (t2.length <= 2 || t2.length >= 5)
- return e2.error(`Expected 3 or 4 arguments, but found ${t2.length - 1} instead.`);
- const r2 = e2.parse(t2[1], 1, Jt), n2 = e2.parse(t2[2], 2, Jt);
- if (!r2 || !n2)
- return null;
- if (!ae(r2.type, [Yt, Kt, Xt, Zt, Jt]))
- return e2.error(`Expected first argument to be of type boolean, string, number or null, but found ${ne(r2.type)} instead`);
- if (4 === t2.length) {
- const i3 = e2.parse(t2[3], 3, Xt);
- return i3 ? new Mr(r2, n2, i3) : null;
- }
- return new Mr(r2, n2);
- }
- evaluate(t2) {
- const e2 = this.needle.evaluate(t2), r2 = this.haystack.evaluate(t2);
- if (!oe(e2, ["boolean", "string", "number", "null"]))
- throw new be(`Expected first argument to be of type boolean, string, number or null, but found ${ne(ge(e2))} instead.`);
- if (!oe(r2, ["string", "array"]))
- throw new be(`Expected second argument to be of type array or string, but found ${ne(ge(r2))} instead.`);
- if (this.fromIndex) {
- const n2 = this.fromIndex.evaluate(t2);
- return r2.indexOf(e2, n2);
- }
- return r2.indexOf(e2);
- }
- eachChild(t2) {
- t2(this.needle), t2(this.haystack), this.fromIndex && t2(this.fromIndex);
- }
- outputDefined() {
- return false;
- }
- serialize() {
- if (null != this.fromIndex && void 0 !== this.fromIndex) {
- const t2 = this.fromIndex.serialize();
- return ["index-of", this.needle.serialize(), this.haystack.serialize(), t2];
- }
- return ["index-of", this.needle.serialize(), this.haystack.serialize()];
- }
- }
- class Tr {
- constructor(t2, e2, r2, n2, i3, s2) {
- this.inputType = t2, this.type = e2, this.input = r2, this.cases = n2, this.outputs = i3, this.otherwise = s2;
- }
- static parse(t2, e2) {
- if (t2.length < 5)
- return e2.error(`Expected at least 4 arguments, but found only ${t2.length - 1}.`);
- if (t2.length % 2 != 1)
- return e2.error("Expected an even number of arguments.");
- let r2, n2;
- e2.expectedType && "value" !== e2.expectedType.kind && (n2 = e2.expectedType);
- const i3 = {}, s2 = [];
- for (let a3 = 2; a3 < t2.length - 1; a3 += 2) {
- let o3 = t2[a3];
- const l2 = t2[a3 + 1];
- Array.isArray(o3) || (o3 = [o3]);
- const u2 = e2.concat(a3);
- if (0 === o3.length)
- return u2.error("Expected at least one branch label.");
- for (const t3 of o3) {
- if ("number" != typeof t3 && "string" != typeof t3)
- return u2.error("Branch labels must be numbers or strings.");
- if ("number" == typeof t3 && Math.abs(t3) > Number.MAX_SAFE_INTEGER)
- return u2.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);
- if ("number" == typeof t3 && Math.floor(t3) !== t3)
- return u2.error("Numeric branch labels must be integer values.");
- if (r2) {
- if (u2.checkSubtype(r2, ge(t3)))
- return null;
- } else
- r2 = ge(t3);
- if (void 0 !== i3[String(t3)])
- return u2.error("Branch labels must be unique.");
- i3[String(t3)] = s2.length;
- }
- const c2 = e2.parse(l2, a3, n2);
- if (!c2)
- return null;
- n2 = n2 || c2.type, s2.push(c2);
- }
- const a2 = e2.parse(t2[1], 1, Jt);
- if (!a2)
- return null;
- const o2 = e2.parse(t2[t2.length - 1], t2.length - 1, n2);
- return o2 ? "value" !== a2.type.kind && e2.concat(1).checkSubtype(r2, a2.type) ? null : new Tr(r2, n2, a2, i3, s2, o2) : null;
- }
- evaluate(t2) {
- const e2 = this.input.evaluate(t2);
- return (ge(e2) === this.inputType && this.outputs[this.cases[e2]] || this.otherwise).evaluate(t2);
- }
- eachChild(t2) {
- t2(this.input), this.outputs.forEach(t2), t2(this.otherwise);
- }
- outputDefined() {
- return this.outputs.every((t2) => t2.outputDefined()) && this.otherwise.outputDefined();
- }
- serialize() {
- const t2 = ["match", this.input.serialize()], e2 = Object.keys(this.cases).sort(), r2 = [], n2 = {};
- for (const t3 of e2) {
- const e3 = n2[this.cases[t3]];
- void 0 === e3 ? (n2[this.cases[t3]] = r2.length, r2.push([this.cases[t3], [t3]])) : r2[e3][1].push(t3);
- }
- const i3 = (t3) => "number" === this.inputType.kind ? Number(t3) : t3;
- for (const [e3, n3] of r2)
- t2.push(1 === n3.length ? i3(n3[0]) : n3.map(i3)), t2.push(this.outputs[e3].serialize());
- return t2.push(this.otherwise.serialize()), t2;
- }
- }
- class zr {
- constructor(t2, e2, r2) {
- this.type = t2, this.branches = e2, this.otherwise = r2;
- }
- static parse(t2, e2) {
- if (t2.length < 4)
- return e2.error(`Expected at least 3 arguments, but found only ${t2.length - 1}.`);
- if (t2.length % 2 != 0)
- return e2.error("Expected an odd number of arguments.");
- let r2;
- e2.expectedType && "value" !== e2.expectedType.kind && (r2 = e2.expectedType);
- const n2 = [];
- for (let i4 = 1; i4 < t2.length - 1; i4 += 2) {
- const s2 = e2.parse(t2[i4], i4, Yt);
- if (!s2)
- return null;
- const a2 = e2.parse(t2[i4 + 1], i4 + 1, r2);
- if (!a2)
- return null;
- n2.push([s2, a2]), r2 = r2 || a2.type;
- }
- const i3 = e2.parse(t2[t2.length - 1], t2.length - 1, r2);
- return i3 ? new zr(r2, n2, i3) : null;
- }
- evaluate(t2) {
- for (const [e2, r2] of this.branches)
- if (e2.evaluate(t2))
- return r2.evaluate(t2);
- return this.otherwise.evaluate(t2);
- }
- eachChild(t2) {
- for (const [e2, r2] of this.branches)
- t2(e2), t2(r2);
- t2(this.otherwise);
- }
- outputDefined() {
- return this.branches.every(([t2, e2]) => e2.outputDefined()) && this.otherwise.outputDefined();
- }
- serialize() {
- const t2 = ["case"];
- return this.eachChild((e2) => {
- t2.push(e2.serialize());
- }), t2;
- }
- }
- class Br {
- constructor(t2, e2, r2, n2) {
- this.type = t2, this.input = e2, this.beginIndex = r2, this.endIndex = n2;
- }
- static parse(t2, e2) {
- if (t2.length <= 2 || t2.length >= 5)
- return e2.error(`Expected 3 or 4 arguments, but found ${t2.length - 1} instead.`);
- const r2 = e2.parse(t2[1], 1, Jt), n2 = e2.parse(t2[2], 2, Xt);
- if (!r2 || !n2)
- return null;
- if (!ae(r2.type, [re(Jt), Kt, Jt]))
- return e2.error(`Expected first argument to be of type array or string, but found ${ne(r2.type)} instead`);
- if (4 === t2.length) {
- const i3 = e2.parse(t2[3], 3, Xt);
- return i3 ? new Br(r2.type, r2, n2, i3) : null;
- }
- return new Br(r2.type, r2, n2);
- }
- evaluate(t2) {
- const e2 = this.input.evaluate(t2), r2 = this.beginIndex.evaluate(t2);
- if (!oe(e2, ["string", "array"]))
- throw new be(`Expected first argument to be of type array or string, but found ${ne(ge(e2))} instead.`);
- if (this.endIndex) {
- const n2 = this.endIndex.evaluate(t2);
- return e2.slice(r2, n2);
- }
- return e2.slice(r2);
- }
- eachChild(t2) {
- t2(this.input), t2(this.beginIndex), this.endIndex && t2(this.endIndex);
- }
- outputDefined() {
- return false;
- }
- serialize() {
- if (null != this.endIndex && void 0 !== this.endIndex) {
- const t2 = this.endIndex.serialize();
- return ["slice", this.input.serialize(), this.beginIndex.serialize(), t2];
- }
- return ["slice", this.input.serialize(), this.beginIndex.serialize()];
- }
- }
- function Er(t2, e2) {
- 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;
- }
- function Cr(t2, e2, r2, n2) {
- return 0 === n2.compare(e2, r2);
- }
- function Dr(t2, e2, r2) {
- const n2 = "==" !== t2 && "!=" !== t2;
- return class i3 {
- constructor(t3, e3, r3) {
- this.type = Yt, this.lhs = t3, this.rhs = e3, this.collator = r3, this.hasUntypedArgument = "value" === t3.type.kind || "value" === e3.type.kind;
- }
- static parse(t3, e3) {
- if (3 !== t3.length && 4 !== t3.length)
- return e3.error("Expected two or three arguments.");
- const r3 = t3[0];
- let s2 = e3.parse(t3[1], 1, Jt);
- if (!s2)
- return null;
- if (!Er(r3, s2.type))
- return e3.concat(1).error(`"${r3}" comparisons are not supported for type '${ne(s2.type)}'.`);
- let a2 = e3.parse(t3[2], 2, Jt);
- if (!a2)
- return null;
- if (!Er(r3, a2.type))
- return e3.concat(2).error(`"${r3}" comparisons are not supported for type '${ne(a2.type)}'.`);
- if (s2.type.kind !== a2.type.kind && "value" !== s2.type.kind && "value" !== a2.type.kind)
- return e3.error(`Cannot compare types '${ne(s2.type)}' and '${ne(a2.type)}'.`);
- 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])));
- let o2 = null;
- if (4 === t3.length) {
- if ("string" !== s2.type.kind && "string" !== a2.type.kind && "value" !== s2.type.kind && "value" !== a2.type.kind)
- return e3.error("Cannot use collator to compare non-string types.");
- if (o2 = e3.parse(t3[3], 3, Qt), !o2)
- return null;
- }
- return new i3(s2, a2, o2);
- }
- evaluate(i4) {
- const s2 = this.lhs.evaluate(i4), a2 = this.rhs.evaluate(i4);
- if (n2 && this.hasUntypedArgument) {
- const e3 = ge(s2), r3 = ge(a2);
- if (e3.kind !== r3.kind || "string" !== e3.kind && "number" !== e3.kind)
- throw new be(`Expected arguments for "${t2}" to be (string, string) or (number, number), but found (${e3.kind}, ${r3.kind}) instead.`);
- }
- if (this.collator && !n2 && this.hasUntypedArgument) {
- const t3 = ge(s2), r3 = ge(a2);
- if ("string" !== t3.kind || "string" !== r3.kind)
- return e2(i4, s2, a2);
- }
- return this.collator ? r2(i4, s2, a2, this.collator.evaluate(i4)) : e2(i4, s2, a2);
- }
- eachChild(t3) {
- t3(this.lhs), t3(this.rhs), this.collator && t3(this.collator);
- }
- outputDefined() {
- return true;
- }
- serialize() {
- const e3 = [t2];
- return this.eachChild((t3) => {
- e3.push(t3.serialize());
- }), e3;
- }
- };
- }
- const Pr = Dr("==", function(t2, e2, r2) {
- return e2 === r2;
- }, Cr), Vr = Dr("!=", function(t2, e2, r2) {
- return e2 !== r2;
- }, function(t2, e2, r2, n2) {
- return !Cr(0, e2, r2, n2);
- }), Fr = Dr("<", function(t2, e2, r2) {
- return e2 < r2;
- }, function(t2, e2, r2, n2) {
- return n2.compare(e2, r2) < 0;
- }), Lr = Dr(">", function(t2, e2, r2) {
- return e2 > r2;
- }, function(t2, e2, r2, n2) {
- return n2.compare(e2, r2) > 0;
- }), Rr = Dr("<=", function(t2, e2, r2) {
- return e2 <= r2;
- }, function(t2, e2, r2, n2) {
- return n2.compare(e2, r2) <= 0;
- }), Ur = Dr(">=", function(t2, e2, r2) {
- return e2 >= r2;
- }, function(t2, e2, r2, n2) {
- return n2.compare(e2, r2) >= 0;
- });
- class $r {
- constructor(t2, e2, r2, n2, i3) {
- this.type = Kt, this.number = t2, this.locale = e2, this.currency = r2, this.minFractionDigits = n2, this.maxFractionDigits = i3;
- }
- static parse(t2, e2) {
- if (3 !== t2.length)
- return e2.error("Expected two arguments.");
- const r2 = e2.parse(t2[1], 1, Xt);
- if (!r2)
- return null;
- const n2 = t2[2];
- if ("object" != typeof n2 || Array.isArray(n2))
- return e2.error("NumberFormat options argument must be an object.");
- let i3 = null;
- if (n2.locale && (i3 = e2.parse(n2.locale, 1, Kt), !i3))
- return null;
- let s2 = null;
- if (n2.currency && (s2 = e2.parse(n2.currency, 1, Kt), !s2))
- return null;
- let a2 = null;
- if (n2["min-fraction-digits"] && (a2 = e2.parse(n2["min-fraction-digits"], 1, Xt), !a2))
- return null;
- let o2 = null;
- return n2["max-fraction-digits"] && (o2 = e2.parse(n2["max-fraction-digits"], 1, Xt), !o2) ? null : new $r(r2, i3, s2, a2, o2);
- }
- evaluate(t2) {
- 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));
- }
- eachChild(t2) {
- t2(this.number), this.locale && t2(this.locale), this.currency && t2(this.currency), this.minFractionDigits && t2(this.minFractionDigits), this.maxFractionDigits && t2(this.maxFractionDigits);
- }
- outputDefined() {
- return false;
- }
- serialize() {
- const t2 = {};
- 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];
- }
- }
- class jr {
- constructor(t2) {
- this.type = Xt, this.input = t2;
- }
- static parse(t2, e2) {
- if (2 !== t2.length)
- return e2.error(`Expected 1 argument, but found ${t2.length - 1} instead.`);
- const r2 = e2.parse(t2[1], 1);
- 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;
- }
- evaluate(t2) {
- const e2 = this.input.evaluate(t2);
- if ("string" == typeof e2)
- return e2.length;
- if (Array.isArray(e2))
- return e2.length;
- throw new be(`Expected value to be of type string or array, but found ${ne(ge(e2))} instead.`);
- }
- eachChild(t2) {
- t2(this.input);
- }
- outputDefined() {
- return false;
- }
- serialize() {
- const t2 = ["length"];
- return this.eachChild((e2) => {
- t2.push(e2.serialize());
- }), t2;
- }
- }
- 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 };
- function qr(t2, [e2, r2, n2, i3]) {
- e2 = e2.evaluate(t2), r2 = r2.evaluate(t2), n2 = n2.evaluate(t2);
- const s2 = i3 ? i3.evaluate(t2) : 1, a2 = ye(e2, r2, n2, s2);
- if (a2)
- throw new be(a2);
- return new ce(e2 / 255 * s2, r2 / 255 * s2, n2 / 255 * s2, s2);
- }
- function Nr(t2, e2) {
- return t2 in e2;
- }
- function Gr(t2, e2) {
- const r2 = e2[t2];
- return void 0 === r2 ? null : r2;
- }
- function Zr(t2) {
- return { type: t2 };
- }
- function Xr(t2) {
- return { result: "success", value: t2 };
- }
- function Kr(t2) {
- return { result: "error", value: t2 };
- }
- function Yr(t2) {
- return "data-driven" === t2["property-type"] || "cross-faded-data-driven" === t2["property-type"];
- }
- function Hr(t2) {
- return !!t2.expression && t2.expression.parameters.indexOf("zoom") > -1;
- }
- function Wr(t2) {
- return !!t2.expression && t2.expression.interpolated;
- }
- function Jr(t2) {
- return t2 instanceof Number ? "number" : t2 instanceof String ? "string" : t2 instanceof Boolean ? "boolean" : Array.isArray(t2) ? "array" : null === t2 ? "null" : typeof t2;
- }
- function Qr(t2) {
- return "object" == typeof t2 && null !== t2 && !Array.isArray(t2);
- }
- function tn(t2) {
- return t2;
- }
- function en(t2, e2) {
- 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");
- 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])
- throw new Error(`Unknown color space: ${t2.colorSpace}`);
- let a2, o2, l2;
- if ("exponential" === s2)
- a2 = an;
- else if ("interval" === s2)
- a2 = sn;
- else if ("categorical" === s2) {
- a2 = nn, o2 = /* @__PURE__ */ Object.create(null);
- for (const e3 of t2.stops)
- o2[e3[0]] = e3[1];
- l2 = typeof t2.stops[0][0];
- } else {
- if ("identity" !== s2)
- throw new Error(`Unknown function type "${s2}"`);
- a2 = on;
- }
- if (n2) {
- const r3 = {}, n3 = [];
- for (let e3 = 0; e3 < t2.stops.length; e3++) {
- const i5 = t2.stops[e3], s4 = i5[0].zoom;
- 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]]);
- }
- const i4 = [];
- for (const t3 of n3)
- i4.push([r3[t3].zoom, en(r3[t3], e2)]);
- const s3 = { name: "linear" };
- 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) };
- }
- if (i3) {
- const r3 = "exponential" === s2 ? { name: "exponential", base: void 0 !== t2.base ? t2.base : 1 } : null;
- 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) };
- }
- return { kind: "source", evaluate(r3, n3) {
- const i4 = n3 && n3.properties ? n3.properties[t2.property] : void 0;
- return void 0 === i4 ? rn(t2.default, e2.default) : a2(t2, e2, i4, o2, l2);
- } };
- }
- function rn(t2, e2, r2) {
- return void 0 !== t2 ? t2 : void 0 !== e2 ? e2 : void 0 !== r2 ? r2 : void 0;
- }
- function nn(t2, e2, r2, n2, i3) {
- return rn(typeof r2 === i3 ? n2[r2] : void 0, t2.default, e2.default);
- }
- function sn(t2, e2, r2) {
- if ("number" !== Jr(r2))
- return rn(t2.default, e2.default);
- const n2 = t2.stops.length;
- if (1 === n2)
- return t2.stops[0][1];
- if (r2 <= t2.stops[0][0])
- return t2.stops[0][1];
- if (r2 >= t2.stops[n2 - 1][0])
- return t2.stops[n2 - 1][1];
- const i3 = tr(t2.stops.map((t3) => t3[0]), r2);
- return t2.stops[i3][1];
- }
- function an(t2, e2, r2) {
- const n2 = void 0 !== t2.base ? t2.base : 1;
- if ("number" !== Jr(r2))
- return rn(t2.default, e2.default);
- const i3 = t2.stops.length;
- if (1 === i3)
- return t2.stops[0][1];
- if (r2 <= t2.stops[0][0])
- return t2.stops[0][1];
- if (r2 >= t2.stops[i3 - 1][0])
- return t2.stops[i3 - 1][1];
- const s2 = tr(t2.stops.map((t3) => t3[0]), r2), a2 = function(t3, e3, r3, n3) {
- const i4 = n3 - r3, s3 = t3 - r3;
- return 0 === i4 ? 0 : 1 === e3 ? s3 / i4 : (Math.pow(e3, s3) - 1) / (Math.pow(e3, i4) - 1);
- }(r2, n2, t2.stops[s2][0], t2.stops[s2 + 1][0]), o2 = t2.stops[s2][1], l2 = t2.stops[s2 + 1][1];
- let u2 = nr[e2.type] || tn;
- if (t2.colorSpace && "rgb" !== t2.colorSpace) {
- const e3 = br[t2.colorSpace];
- u2 = (t3, r3) => e3.reverse(e3.interpolate(e3.forward(t3), e3.forward(r3), a2));
- }
- return "function" == typeof o2.evaluate ? { evaluate(...t3) {
- const e3 = o2.evaluate.apply(void 0, t3), r3 = l2.evaluate.apply(void 0, t3);
- if (void 0 !== e3 && void 0 !== r3)
- return u2(e3, r3, a2);
- } } : u2(o2, l2, a2);
- }
- function on(t2, e2, r2) {
- 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);
- }
- ze.register(Or, { error: [{ kind: "error" }, [Kt], (t2, [e2]) => {
- throw new be(e2.evaluate(t2));
- }], 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) => {
- let r2 = 0;
- for (const n2 of e2)
- r2 += n2.evaluate(t2);
- return r2;
- }], "*": [Xt, Zr(Xt), (t2, e2) => {
- let r2 = 1;
- for (const n2 of e2)
- r2 *= n2.evaluate(t2);
- return r2;
- }], "-": { 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]) => {
- const r2 = e2.evaluate(t2);
- return r2 < 0 ? -Math.round(-r2) : Math.round(r2);
- }], 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]) => {
- const n2 = t2.properties()[e2.value], i3 = r2.value;
- return typeof n2 == typeof i3 && n2 < i3;
- }], "filter-id-<": [Yt, [Jt], (t2, [e2]) => {
- const r2 = t2.id(), n2 = e2.value;
- return typeof r2 == typeof n2 && r2 < n2;
- }], "filter->": [Yt, [Kt, Jt], (t2, [e2, r2]) => {
- const n2 = t2.properties()[e2.value], i3 = r2.value;
- return typeof n2 == typeof i3 && n2 > i3;
- }], "filter-id->": [Yt, [Jt], (t2, [e2]) => {
- const r2 = t2.id(), n2 = e2.value;
- return typeof r2 == typeof n2 && r2 > n2;
- }], "filter-<=": [Yt, [Kt, Jt], (t2, [e2, r2]) => {
- const n2 = t2.properties()[e2.value], i3 = r2.value;
- return typeof n2 == typeof i3 && n2 <= i3;
- }], "filter-id-<=": [Yt, [Jt], (t2, [e2]) => {
- const r2 = t2.id(), n2 = e2.value;
- return typeof r2 == typeof n2 && r2 <= n2;
- }], "filter->=": [Yt, [Kt, Jt], (t2, [e2, r2]) => {
- const n2 = t2.properties()[e2.value], i3 = r2.value;
- return typeof n2 == typeof i3 && n2 >= i3;
- }], "filter-id->=": [Yt, [Jt], (t2, [e2]) => {
- const r2 = t2.id(), n2 = e2.value;
- return typeof r2 == typeof n2 && r2 >= n2;
- }], "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) {
- for (; r3 <= n2; ) {
- const i3 = r3 + n2 >> 1;
- if (e3[i3] === t3)
- return true;
- e3[i3] > t3 ? n2 = i3 - 1 : r3 = i3 + 1;
- }
- return false;
- }(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) => {
- for (const r2 of e2)
- if (!r2.evaluate(t2))
- return false;
- return true;
- }]] }, any: { type: Yt, overloads: [[[Yt, Yt], (t2, [e2, r2]) => e2.evaluate(t2) || r2.evaluate(t2)], [Zr(Yt), (t2, e2) => {
- for (const r2 of e2)
- if (r2.evaluate(t2))
- return true;
- return false;
- }]] }, "!": [Yt, [Yt], (t2, [e2]) => !e2.evaluate(t2)], "is-supported-script": [Yt, [Kt], (t2, [e2]) => {
- const r2 = t2.globals && t2.globals.isSupportedScript;
- return !r2 || r2(e2.evaluate(t2));
- }], 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()] });
- class ln {
- constructor(t2, e2) {
- this.expression = t2, this._warningHistory = {}, this._evaluator = new Te(), this._defaultValue = e2 ? function(t3) {
- 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;
- }(e2) : null, this._enumValues = e2 && "enum" === e2.type ? e2.values : null;
- }
- evaluateWithoutErrorHandling(t2, e2, r2, n2, i3, s2, a2, o2) {
- 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);
- }
- evaluate(t2, e2, r2, n2, i3, s2, a2, o2) {
- 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;
- try {
- const t3 = this.expression.evaluate(this._evaluator);
- if (null == t3 || "number" == typeof t3 && t3 != t3)
- return this._defaultValue;
- if (this._enumValues && !(t3 in this._enumValues))
- 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.`);
- return t3;
- } catch (t3) {
- return this._warningHistory[t3.message] || (this._warningHistory[t3.message] = true, "undefined" != typeof console && console.warn(t3.message)), this._defaultValue;
- }
- }
- }
- function un(t2) {
- return Array.isArray(t2) && t2.length > 0 && "string" == typeof t2[0] && t2[0] in Or;
- }
- function cn(t2, e2) {
- const r2 = new Je(Or, [], e2 ? function(t3) {
- const e3 = { color: Ht, string: Kt, number: Xt, enum: Kt, boolean: Yt, formatted: te, resolvedImage: ee };
- return "array" === t3.type ? re(e3[t3.value] || Jt, t3.length) : e3[t3.type];
- }(e2) : void 0), n2 = r2.parse(t2, void 0, void 0, void 0, e2 && "string" === e2.type ? { typeAnnotation: "coerce" } : void 0);
- return n2 ? Xr(new ln(n2, e2)) : Kr(r2.errors);
- }
- class hn {
- constructor(t2, e2) {
- this.kind = t2, this._styleExpression = e2, this.isStateDependent = "constant" !== t2 && !Ye(e2.expression);
- }
- evaluateWithoutErrorHandling(t2, e2, r2, n2, i3, s2) {
- return this._styleExpression.evaluateWithoutErrorHandling(t2, e2, r2, n2, i3, s2);
- }
- evaluate(t2, e2, r2, n2, i3, s2) {
- return this._styleExpression.evaluate(t2, e2, r2, n2, i3, s2);
- }
- }
- class pn {
- constructor(t2, e2, r2, n2) {
- this.kind = t2, this.zoomStops = r2, this._styleExpression = e2, this.isStateDependent = "camera" !== t2 && !Ye(e2.expression), this.interpolationType = n2;
- }
- evaluateWithoutErrorHandling(t2, e2, r2, n2, i3, s2) {
- return this._styleExpression.evaluateWithoutErrorHandling(t2, e2, r2, n2, i3, s2);
- }
- evaluate(t2, e2, r2, n2, i3, s2) {
- return this._styleExpression.evaluate(t2, e2, r2, n2, i3, s2);
- }
- interpolationFactor(t2, e2, r2) {
- return this.interpolationType ? _r.interpolationFactor(this.interpolationType, t2, e2, r2) : 0;
- }
- }
- function fn(t2, e2) {
- if ("error" === (t2 = cn(t2, e2)).result)
- return t2;
- const r2 = t2.value.expression, n2 = Ke(r2);
- if (!n2 && !Yr(e2))
- return Kr([new Nt("", "data expressions not supported")]);
- const i3 = He(r2, ["zoom", "pitch", "distance-from-center"]);
- if (!i3 && !Hr(e2))
- return Kr([new Nt("", "zoom expressions not supported")]);
- const s2 = yn(r2);
- 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.')]);
- }
- class dn {
- constructor(t2, e2) {
- this._parameters = t2, this._specification = e2, jt(this, en(this._parameters, this._specification));
- }
- static deserialize(t2) {
- return new dn(t2._parameters, t2._specification);
- }
- static serialize(t2) {
- return { _parameters: t2._parameters, _specification: t2._specification };
- }
- }
- function yn(t2) {
- let e2 = null;
- if (t2 instanceof kr)
- e2 = yn(t2.result);
- else if (t2 instanceof Ar) {
- for (const r2 of t2.args)
- if (e2 = yn(r2), e2)
- break;
- } else
- (t2 instanceof er || t2 instanceof _r) && t2.input instanceof ze && "zoom" === t2.input.name && (e2 = t2);
- return e2 instanceof Nt || t2.eachChild((t3) => {
- const r2 = yn(t3);
- 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.'));
- }), e2;
- }
- class mn {
- constructor(t2, e2, r2, n2) {
- this.message = (t2 ? `${t2}: ` : "") + r2, n2 && (this.identifier = n2), null != e2 && e2.__line__ && (this.line = e2.__line__);
- }
- }
- function gn(t2) {
- const e2 = t2.key, r2 = t2.value, n2 = t2.valueSpec || {}, i3 = t2.objectElementValidators || {}, s2 = t2.style, a2 = t2.styleSpec;
- let o2 = [];
- const l2 = Jr(r2);
- if ("object" !== l2)
- return [new mn(e2, r2, `object expected, ${l2} found`)];
- for (const t3 in r2) {
- const l3 = t3.split(".")[0], u2 = n2[l3] || n2["*"];
- let c2;
- 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}"`));
- }
- for (const t3 in n2)
- i3[t3] || n2[t3].required && void 0 === n2[t3].default && void 0 === r2[t3] && o2.push(new mn(e2, r2, `missing required property "${t3}"`));
- return o2;
- }
- function xn(t2) {
- const e2 = t2.value, r2 = t2.valueSpec, n2 = t2.style, i3 = t2.styleSpec, s2 = t2.key, a2 = t2.arrayElementValidator || Hn;
- if ("array" !== Jr(e2))
- return [new mn(s2, e2, `array expected, ${Jr(e2)} found`)];
- if (r2.length && e2.length !== r2.length)
- return [new mn(s2, e2, `array length ${r2.length} expected, length ${e2.length} found`)];
- if (r2["min-length"] && e2.length < r2["min-length"])
- return [new mn(s2, e2, `array length at least ${r2["min-length"]} expected, length ${e2.length} found`)];
- let o2 = { type: r2.value, values: r2.values, minimum: r2.minimum, maximum: r2.maximum, function: void 0 };
- i3.$version < 7 && (o2.function = r2.function), "object" === Jr(r2.value) && (o2 = r2.value);
- let l2 = [];
- for (let t3 = 0; t3 < e2.length; t3++)
- l2 = l2.concat(a2({ array: e2, arrayIndex: t3, value: e2[t3], valueSpec: o2, style: n2, styleSpec: i3, key: `${s2}[${t3}]` }));
- return l2;
- }
- function vn(t2) {
- const e2 = t2.key, r2 = t2.value, n2 = t2.valueSpec;
- let i3 = Jr(r2);
- if ("number" === i3 && r2 != r2 && (i3 = "NaN"), "number" !== i3)
- return [new mn(e2, r2, `number expected, ${i3} found`)];
- if ("minimum" in n2) {
- let i4 = n2.minimum;
- if ("array" === Jr(n2.minimum) && (i4 = n2.minimum[t2.arrayIndex]), r2 < i4)
- return [new mn(e2, r2, `${r2} is less than the minimum value ${i4}`)];
- }
- if ("maximum" in n2) {
- let i4 = n2.maximum;
- if ("array" === Jr(n2.maximum) && (i4 = n2.maximum[t2.arrayIndex]), r2 > i4)
- return [new mn(e2, r2, `${r2} is greater than the maximum value ${i4}`)];
- }
- return [];
- }
- function bn(t2) {
- const e2 = t2.valueSpec, r2 = Ot(t2.value.type);
- let n2, i3, s2, a2 = {};
- 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) {
- if ("identity" === r2)
- return [new mn(t3.key, t3.value, 'identity function may not have a "stops" property')];
- let e3 = [];
- const n3 = t3.value;
- 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;
- }, default: function(t3) {
- return Hn({ key: t3.key, value: t3.value, valueSpec: e2, style: t3.style, styleSpec: t3.styleSpec });
- } } });
- 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;
- function h2(t3) {
- let r3 = [];
- const n3 = t3.value, o3 = t3.key;
- if ("array" !== Jr(n3))
- return [new mn(o3, n3, `array expected, ${Jr(n3)} found`)];
- if (2 !== n3.length)
- return [new mn(o3, n3, `array length 2 expected, length ${n3.length} found`)];
- if (u2) {
- if ("object" !== Jr(n3[0]))
- return [new mn(o3, n3, `object expected, ${Jr(n3[0])} found`)];
- if (void 0 === n3[0].zoom)
- return [new mn(o3, n3, "object stop key must have zoom")];
- if (void 0 === n3[0].value)
- return [new mn(o3, n3, "object stop key must have value")];
- const e3 = Ot(n3[0].zoom);
- if ("number" != typeof e3)
- return [new mn(o3, n3[0].zoom, "stop zoom values must be numbers")];
- if (s2 && s2 > e3)
- return [new mn(o3, n3[0].zoom, "stop zoom values must appear in ascending order")];
- 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 } }));
- } else
- r3 = r3.concat(p2({ key: `${o3}[0]`, value: n3[0], valueSpec: {}, style: t3.style, styleSpec: t3.styleSpec }, n3));
- 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 }));
- }
- function p2(t3, s3) {
- const o3 = Jr(t3.value), l3 = Ot(t3.value), u3 = null !== t3.value ? t3.value : s3;
- if (n2) {
- if (o3 !== n2)
- return [new mn(t3.key, u3, `${o3} stop domain type must match previous stop domain type ${n2}`)];
- } else
- n2 = o3;
- if ("number" !== o3 && "string" !== o3 && "boolean" !== o3 && "number" != typeof l3 && "string" != typeof l3 && "boolean" != typeof l3)
- return [new mn(t3.key, u3, "stop domain value must be a number, string, or boolean")];
- if ("number" !== o3 && "categorical" !== r2) {
- let n3 = `number expected, ${o3} found`;
- return Yr(e2) && void 0 === r2 && (n3 += '\nIf you intended to use a categorical function, specify `"type": "categorical"`.'), [new mn(t3.key, u3, n3)];
- }
- 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)}`)];
- }
- }
- function _n(t2) {
- const e2 = ("property" === t2.expressionContext ? fn : cn)(qt(t2.value), t2.valueSpec);
- if ("error" === e2.result)
- return e2.value.map((e3) => new mn(`${t2.key}${e3.key}`, t2.value, e3.message));
- const r2 = e2.value.expression || e2.value._styleExpression.expression;
- if ("property" === t2.expressionContext && "text-font" === t2.propertyKey && !r2.outputDefined())
- return [new mn(t2.key, t2.value, `Invalid data expression for "${t2.propertyKey}". Output values must be contained as literals within the expression.`)];
- if ("property" === t2.expressionContext && "layout" === t2.propertyType && !Ye(r2))
- return [new mn(t2.key, t2.value, '"feature-state" data expressions are not supported with layout properties.')];
- if ("filter" === t2.expressionContext)
- return wn(r2, t2);
- if (t2.expressionContext && 0 === t2.expressionContext.indexOf("cluster")) {
- if (!He(r2, ["zoom", "feature-state"]))
- return [new mn(t2.key, t2.value, '"zoom" and "feature-state" expressions are not supported with cluster properties.')];
- if ("cluster-initial" === t2.expressionContext && !Ke(r2))
- return [new mn(t2.key, t2.value, "Feature data expressions are not supported with initial expression part of cluster properties.")];
- }
- return [];
- }
- function wn(t2, e2) {
- const r2 = /* @__PURE__ */ new Set(["zoom", "feature-state", "pitch", "distance-from-center"]);
- if (e2.valueSpec && e2.valueSpec.expression)
- for (const t3 of e2.valueSpec.expression.parameters)
- r2.delete(t3);
- if (0 === r2.size)
- return [];
- const n2 = [];
- 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) => {
- n2.push(...wn(t3, e2));
- }), n2);
- }
- function An(t2) {
- const e2 = t2.key, r2 = t2.value, n2 = t2.valueSpec, i3 = [];
- 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;
- }
- function kn(t2) {
- if (true === t2 || false === t2)
- return true;
- if (!Array.isArray(t2) || 0 === t2.length)
- return false;
- switch (t2[0]) {
- case "has":
- return t2.length >= 2 && "$id" !== t2[1] && "$type" !== t2[1];
- case "in":
- return t2.length >= 3 && ("string" != typeof t2[1] || Array.isArray(t2[2]));
- case "!in":
- case "!has":
- case "none":
- return false;
- case "==":
- case "!=":
- case ">":
- case ">=":
- case "<":
- case "<=":
- return 3 !== t2.length || Array.isArray(t2[1]) || Array.isArray(t2[2]);
- case "any":
- case "all":
- for (const e2 of t2.slice(1))
- if (!kn(e2) && "boolean" != typeof e2)
- return false;
- return true;
- default:
- return true;
- }
- }
- function Sn(t2, e2 = "fill") {
- if (null == t2)
- return { filter: () => true, needGeometry: false, needFeature: false };
- kn(t2) || (t2 = Cn(t2));
- const r2 = t2;
- let n2 = true;
- try {
- n2 = function(t3) {
- if (!Tn(t3))
- return t3;
- let e3 = qt(t3);
- return Mn(e3), e3 = In(e3), e3;
- }(r2);
- } catch (t3) {
- console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.
- 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
- and paste the contents of this message in the report.
- Thank you!
- Filter Expression:
- ${JSON.stringify(r2, null, 2)}
- `);
- }
- const i3 = $t[`filter_${e2}`], s2 = cn(n2, i3);
- let a2 = null;
- if ("error" === s2.result)
- throw new Error(s2.value.map((t3) => `${t3.key}: ${t3.message}`).join(", "));
- a2 = (t3, e3, r3) => s2.value.evaluate(t3, e3, {}, r3);
- let o2 = null, l2 = null;
- if (n2 !== r2) {
- const t3 = cn(r2, i3);
- if ("error" === t3.result)
- throw new Error(t3.value.map((t4) => `${t4.key}: ${t4.message}`).join(", "));
- o2 = (e3, r3, n3, i4, s3) => t3.value.evaluate(e3, r3, {}, n3, void 0, void 0, i4, s3), l2 = !Ke(t3.value.expression);
- }
- return a2 = a2, { filter: a2, dynamicFilter: o2 || void 0, needGeometry: En(n2), needFeature: !!l2 };
- }
- function In(t2) {
- if (!Array.isArray(t2))
- return t2;
- const e2 = function(t3) {
- if (zn.has(t3[0])) {
- for (let e3 = 1; e3 < t3.length; e3++)
- if (Tn(t3[e3]))
- return true;
- }
- return t3;
- }(t2);
- return true === e2 ? e2 : e2.map((t3) => In(t3));
- }
- function Mn(t2) {
- let e2 = false;
- const r2 = [];
- if ("case" === t2[0]) {
- for (let n2 = 1; n2 < t2.length - 1; n2 += 2)
- e2 = e2 || Tn(t2[n2]), r2.push(t2[n2 + 1]);
- r2.push(t2[t2.length - 1]);
- } else if ("match" === t2[0]) {
- e2 = e2 || Tn(t2[1]);
- for (let e3 = 2; e3 < t2.length - 1; e3 += 2)
- r2.push(t2[e3 + 1]);
- r2.push(t2[t2.length - 1]);
- } else if ("step" === t2[0]) {
- e2 = e2 || Tn(t2[1]);
- for (let e3 = 1; e3 < t2.length - 1; e3 += 2)
- r2.push(t2[e3 + 1]);
- }
- e2 && (t2.length = 0, t2.push("any", ...r2));
- for (let e3 = 1; e3 < t2.length; e3++)
- Mn(t2[e3]);
- }
- function Tn(t2) {
- if (!Array.isArray(t2))
- return false;
- if ("pitch" === (e2 = t2[0]) || "distance-from-center" === e2)
- return true;
- var e2;
- for (let e3 = 1; e3 < t2.length; e3++)
- if (Tn(t2[e3]))
- return true;
- return false;
- }
- const zn = /* @__PURE__ */ new Set(["in", "==", "!=", ">", ">=", "<", "<=", "to-boolean"]);
- function Bn(t2, e2) {
- return t2 < e2 ? -1 : t2 > e2 ? 1 : 0;
- }
- function En(t2) {
- if (!Array.isArray(t2))
- return false;
- if ("within" === t2[0])
- return true;
- for (let e2 = 1; e2 < t2.length; e2++)
- if (En(t2[e2]))
- return true;
- return false;
- }
- function Cn(t2) {
- if (!t2)
- return true;
- const e2 = t2[0];
- 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;
- var r2;
- }
- function Dn(t2, e2, r2) {
- switch (t2) {
- case "$type":
- return [`filter-type-${r2}`, e2];
- case "$id":
- return [`filter-id-${r2}`, e2];
- default:
- return [`filter-${r2}`, t2, e2];
- }
- }
- function Pn(t2, e2) {
- if (0 === e2.length)
- return false;
- switch (t2) {
- case "$type":
- return ["filter-type-in", ["literal", e2]];
- case "$id":
- return ["filter-id-in", ["literal", e2]];
- default:
- 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]];
- }
- }
- function Vn(t2) {
- switch (t2) {
- case "$type":
- return true;
- case "$id":
- return ["filter-has-id"];
- default:
- return ["filter-has", t2];
- }
- }
- function Fn(t2) {
- return ["!", t2];
- }
- function Ln(t2) {
- return kn(qt(t2.value)) ? _n(jt({}, t2, { expressionContext: "filter", valueSpec: t2.styleSpec[`filter_${t2.layerType || "fill"}`] })) : Rn(t2);
- }
- function Rn(t2) {
- const e2 = t2.value, r2 = t2.key;
- if ("array" !== Jr(e2))
- return [new mn(r2, e2, `array expected, ${Jr(e2)} found`)];
- const n2 = t2.styleSpec;
- let i3, s2 = [];
- if (e2.length < 1)
- return [new mn(r2, e2, "filter array must have at least 1 element")];
- switch (s2 = s2.concat(An({ key: `${r2}[0]`, value: e2[0], valueSpec: n2.filter_operator, style: t2.style, styleSpec: t2.styleSpec })), Ot(e2[0])) {
- case "<":
- case "<=":
- case ">":
- case ">=":
- e2.length >= 2 && "$type" === Ot(e2[1]) && s2.push(new mn(r2, e2, `"$type" cannot be use with operator "${e2[0]}"`));
- case "==":
- case "!=":
- 3 !== e2.length && s2.push(new mn(r2, e2, `filter array for operator "${e2[0]}" must have 3 elements`));
- case "in":
- case "!in":
- e2.length >= 2 && (i3 = Jr(e2[1]), "string" !== i3 && s2.push(new mn(`${r2}[1]`, e2[1], `string expected, ${i3} found`)));
- for (let a2 = 2; a2 < e2.length; a2++)
- 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`));
- break;
- case "any":
- case "all":
- case "none":
- for (let n3 = 1; n3 < e2.length; n3++)
- s2 = s2.concat(Rn({ key: `${r2}[${n3}]`, value: e2[n3], style: t2.style, styleSpec: t2.styleSpec }));
- break;
- case "has":
- case "!has":
- 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`));
- break;
- case "within":
- 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`));
- }
- return s2;
- }
- function Un(t2, e2) {
- const r2 = t2.key, n2 = t2.style, i3 = t2.styleSpec, s2 = t2.value, a2 = t2.objectKey, o2 = i3[`${e2}_${t2.layerType}`];
- if (!o2)
- return [];
- const l2 = a2.match(/^(.*)-transition$/);
- if ("paint" === e2 && l2 && o2[l2[1]] && o2[l2[1]].transition)
- return Hn({ key: r2, value: s2, valueSpec: i3.transition, style: n2, styleSpec: i3 });
- const u2 = t2.valueSpec || o2[a2];
- if (!u2)
- return [new mn(r2, s2, `unknown property "${a2}"`)];
- let c2;
- if ("string" === Jr(s2) && Yr(u2) && !u2.tokens && (c2 = /^{([^}]+)}$/.exec(s2)))
- return [new mn(r2, s2, `"${a2}" does not support interpolation syntax
- Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(c2[1])} }\`.`)];
- const h2 = [];
- 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 }));
- }
- function $n(t2) {
- return Un(t2, "paint");
- }
- function jn(t2) {
- return Un(t2, "layout");
- }
- function On(t2) {
- let e2 = [];
- const r2 = t2.value, n2 = t2.key, i3 = t2.style, s2 = t2.styleSpec;
- r2.type || r2.ref || e2.push(new mn(n2, r2, 'either "type" or "ref" is required'));
- let a2 = Ot(r2.type);
- const o2 = Ot(r2.ref);
- if (r2.id) {
- const s3 = Ot(r2.id);
- for (let a3 = 0; a3 < t2.arrayIndex; a3++) {
- const t3 = i3.layers[a3];
- Ot(t3.id) === s3 && e2.push(new mn(n2, r2.id, `duplicate layer id "${r2.id}", previously used at line ${t3.id.__line__}`));
- }
- }
- if ("ref" in r2) {
- let t3;
- ["type", "source", "source-layer", "filter", "layout"].forEach((t4) => {
- t4 in r2 && e2.push(new mn(n2, r2[t4], `"${t4}" is prohibited for ref layers`));
- }), i3.layers.forEach((e3) => {
- Ot(e3.id) === o2 && (t3 = e3);
- }), 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`));
- } else if ("background" !== a2 && "sky" !== a2)
- if (r2.source) {
- const t3 = i3.sources && i3.sources[r2.source], s3 = t3 && Ot(t3.type);
- 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`));
- } else
- e2.push(new mn(n2, r2, 'missing required property "source"'));
- 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;
- }
- function qn(t2) {
- const e2 = t2.value, r2 = t2.key, n2 = Jr(e2);
- return "string" !== n2 ? [new mn(r2, e2, `string expected, ${n2} found`)] : [];
- }
- const Nn = { promoteId: function({ key: t2, value: e2 }) {
- if ("string" === Jr(e2))
- return qn({ key: t2, value: e2 });
- {
- const r2 = [];
- for (const n2 in e2)
- r2.push(...qn({ key: `${t2}.${n2}`, value: e2[n2] }));
- return r2;
- }
- } };
- function Gn(t2) {
- const e2 = t2.value, r2 = t2.key, n2 = t2.styleSpec, i3 = t2.style;
- if (!e2.type)
- return [new mn(r2, e2, '"type" is required')];
- const s2 = Ot(e2.type);
- let a2;
- switch (s2) {
- case "vector":
- case "raster":
- case "raster-dem":
- return a2 = gn({ key: r2, value: e2, valueSpec: n2[`source_${s2.replace("-", "_")}`], style: t2.style, styleSpec: n2, objectElementValidators: Nn }), a2;
- case "geojson":
- if (a2 = gn({ key: r2, value: e2, valueSpec: n2.source_geojson, style: i3, styleSpec: n2, objectElementValidators: Nn }), e2.cluster)
- for (const t3 in e2.clusterProperties) {
- const [n3, i4] = e2.clusterProperties[t3], s3 = "string" == typeof n3 ? [n3, ["accumulated"], ["get", t3]] : n3;
- a2.push(..._n({ key: `${r2}.${t3}.map`, value: i4, expressionContext: "cluster-map" })), a2.push(..._n({ key: `${r2}.${t3}.reduce`, value: s3, expressionContext: "cluster-reduce" }));
- }
- return a2;
- case "video":
- return gn({ key: r2, value: e2, valueSpec: n2.source_video, style: i3, styleSpec: n2 });
- case "image":
- return gn({ key: r2, value: e2, valueSpec: n2.source_image, style: i3, styleSpec: n2 });
- case "canvas":
- return [new mn(r2, null, "Please use runtime APIs to add canvas sources, rather than including them in stylesheets.", "source.canvas")];
- default:
- return An({ key: `${r2}.type`, value: e2.type, valueSpec: { values: ["vector", "raster", "raster-dem", "geojson", "video", "image"] }, style: i3, styleSpec: n2 });
- }
- }
- function Zn(t2) {
- const e2 = t2.value, r2 = t2.styleSpec, n2 = r2.light, i3 = t2.style;
- let s2 = [];
- const a2 = Jr(e2);
- if (void 0 === e2)
- return s2;
- if ("object" !== a2)
- return s2 = s2.concat([new mn("light", e2, `object expected, ${a2} found`)]), s2;
- for (const t3 in e2) {
- const a3 = t3.match(/^(.*)-transition$/);
- 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}"`)]);
- }
- return s2;
- }
- function Xn(t2) {
- const e2 = t2.value, r2 = t2.key, n2 = t2.style, i3 = t2.styleSpec, s2 = i3.terrain;
- let a2 = [];
- const o2 = Jr(e2);
- if (void 0 === e2)
- return a2;
- if ("object" !== o2)
- return a2 = a2.concat([new mn("terrain", e2, `object expected, ${o2} found`)]), a2;
- for (const t3 in e2) {
- const r3 = t3.match(/^(.*)-transition$/);
- 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}"`)]);
- }
- if (e2.source) {
- const t3 = n2.sources && n2.sources[e2.source], i4 = t3 && Ot(t3.type);
- 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`));
- } else
- a2.push(new mn(r2, e2, 'terrain is missing required property "source"'));
- return a2;
- }
- function Kn(t2) {
- const e2 = t2.value, r2 = t2.style, n2 = t2.styleSpec, i3 = n2.fog;
- let s2 = [];
- const a2 = Jr(e2);
- if (void 0 === e2)
- return s2;
- if ("object" !== a2)
- return s2 = s2.concat([new mn("fog", e2, `object expected, ${a2} found`)]), s2;
- for (const t3 in e2) {
- const a3 = t3.match(/^(.*)-transition$/);
- 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}"`)]);
- }
- return s2;
- }
- const Yn = { "*": () => [], array: xn, boolean: function(t2) {
- const e2 = t2.value, r2 = t2.key, n2 = Jr(e2);
- return "boolean" !== n2 ? [new mn(r2, e2, `boolean expected, ${n2} found`)] : [];
- }, number: vn, color: function(t2) {
- const e2 = t2.key, r2 = t2.value, n2 = Jr(r2);
- return "string" !== n2 ? [new mn(e2, r2, `color expected, ${n2} found`)] : null === ue.parseCSSColor(r2) ? [new mn(e2, r2, `color expected, "${r2}" found`)] : [];
- }, enum: An, filter: Ln, function: bn, layer: On, object: gn, source: Gn, light: Zn, terrain: Xn, fog: Kn, string: qn, formatted: function(t2) {
- return 0 === qn(t2).length ? [] : _n(t2);
- }, resolvedImage: function(t2) {
- return 0 === qn(t2).length ? [] : _n(t2);
- }, projection: function(t2) {
- const e2 = t2.value, r2 = t2.styleSpec, n2 = r2.projection, i3 = t2.style;
- let s2 = [];
- const a2 = Jr(e2);
- if ("object" === a2)
- for (const t3 in e2)
- s2 = s2.concat(Hn({ key: t3, value: e2[t3], valueSpec: n2[t3], style: i3, styleSpec: r2 }));
- else
- "string" !== a2 && (s2 = s2.concat([new mn("projection", e2, `object or string expected, ${a2} found`)]));
- return s2;
- } };
- function Hn(t2) {
- const e2 = t2.value, r2 = t2.valueSpec, n2 = t2.styleSpec;
- 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 }));
- }
- function Wn(t2) {
- const e2 = t2.value, r2 = t2.key, n2 = qn(t2);
- 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;
- }
- function Jn(t2, e2 = $t) {
- return ei(Hn({ key: "", value: t2, valueSpec: e2.$root, styleSpec: e2, style: t2, objectElementValidators: { glyphs: Wn, "*": () => [] } }));
- }
- const Qn = (t2) => ei($n(t2)), ti = (t2) => ei(jn(t2));
- function ei(t2) {
- return t2.slice().sort((t3, e2) => t3.line && e2.line ? t3.line - e2.line : 0);
- }
- function ri(t2, e2) {
- let r2 = false;
- if (e2 && e2.length)
- for (const n2 of e2)
- t2.fire(new Rt(new Error(n2.message))), r2 = true;
- return r2;
- }
- var ni = ii;
- function ii(t2, e2, r2) {
- var n2 = this.cells = [];
- if (t2 instanceof ArrayBuffer) {
- this.arrayBuffer = t2;
- var i3 = new Int32Array(this.arrayBuffer);
- t2 = i3[0], this.d = (e2 = i3[1]) + 2 * (r2 = i3[2]);
- for (var s2 = 0; s2 < this.d * this.d; s2++) {
- var a2 = i3[3 + s2], o2 = i3[3 + s2 + 1];
- n2.push(a2 === o2 ? null : i3.subarray(a2, o2));
- }
- var l2 = i3[3 + n2.length + 1];
- this.keys = i3.subarray(i3[3 + n2.length], l2), this.bboxes = i3.subarray(l2), this.insert = this._insertReadonly;
- } else {
- this.d = e2 + 2 * r2;
- for (var u2 = 0; u2 < this.d * this.d; u2++)
- n2.push([]);
- this.keys = [], this.bboxes = [];
- }
- this.n = e2, this.extent = t2, this.padding = r2, this.scale = e2 / t2, this.uid = 0;
- var c2 = r2 / e2 * t2;
- this.min = -c2, this.max = t2 + c2;
- }
- ii.prototype.insert = function(t2, e2, r2, n2, i3) {
- 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);
- }, ii.prototype._insertReadonly = function() {
- throw "Cannot insert into a GridIndex created from an ArrayBuffer.";
- }, ii.prototype._insertCell = function(t2, e2, r2, n2, i3, s2) {
- this.cells[i3].push(s2);
- }, ii.prototype.query = function(t2, e2, r2, n2, i3) {
- var s2 = this.min, a2 = this.max;
- if (t2 <= s2 && e2 <= s2 && a2 <= r2 && a2 <= n2 && !i3)
- return Array.prototype.slice.call(this.keys);
- var o2 = [];
- return this._forEachCell(t2, e2, r2, n2, this._queryCell, o2, {}, i3), o2;
- }, ii.prototype._queryCell = function(t2, e2, r2, n2, i3, s2, a2, o2) {
- var l2 = this.cells[i3];
- if (null !== l2)
- for (var u2 = this.keys, c2 = this.bboxes, h2 = 0; h2 < l2.length; h2++) {
- var p2 = l2[h2];
- if (void 0 === a2[p2]) {
- var f2 = 4 * p2;
- (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;
- }
- }
- }, ii.prototype._forEachCell = function(t2, e2, r2, n2, i3, s2, a2, o2) {
- for (var l2 = this._convertToCellCoord(t2), u2 = this._convertToCellCoord(e2), c2 = this._convertToCellCoord(r2), h2 = this._convertToCellCoord(n2), p2 = l2; p2 <= c2; p2++)
- for (var f2 = u2; f2 <= h2; f2++) {
- var d2 = this.d * f2 + p2;
- 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))
- return;
- }
- }, ii.prototype._convertFromCellCoord = function(t2) {
- return (t2 - this.padding) / this.scale;
- }, ii.prototype._convertToCellCoord = function(t2) {
- return Math.max(0, Math.min(this.d - 1, Math.floor(t2 * this.scale) + this.padding));
- }, ii.prototype.toArrayBuffer = function() {
- if (this.arrayBuffer)
- return this.arrayBuffer;
- for (var t2 = this.cells, e2 = 3 + this.cells.length + 1 + 1, r2 = 0, n2 = 0; n2 < this.cells.length; n2++)
- r2 += this.cells[n2].length;
- var i3 = new Int32Array(e2 + r2 + this.keys.length + this.bboxes.length);
- i3[0] = this.extent, i3[1] = this.n, i3[2] = this.padding;
- for (var s2 = e2, a2 = 0; a2 < t2.length; a2++) {
- var o2 = t2[a2];
- i3[3 + a2] = s2, i3.set(o2, s2), s2 += o2.length;
- }
- 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;
- };
- const si = {};
- function ai(t2, e2, r2 = {}) {
- Object.defineProperty(t2, "_classRegistryKey", { value: e2, writeable: false }), si[e2] = { klass: t2, omit: r2.omit || [] };
- }
- ai(Object, "Object"), ni.serialize = function(t2, e2) {
- const r2 = t2.toArrayBuffer();
- return e2 && e2.push(r2), { buffer: r2 };
- }, ni.deserialize = function(t2) {
- return new ni(t2.buffer);
- }, 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"] });
- for (const t2 in Or)
- si[Or[t2]._classRegistryKey] || ai(Or[t2], `Expression${t2}`);
- function oi(t2) {
- return t2 && "undefined" != typeof ArrayBuffer && (t2 instanceof ArrayBuffer || t2.constructor && "ArrayBuffer" === t2.constructor.name);
- }
- function li(t2) {
- return a.ImageBitmap && t2 instanceof a.ImageBitmap;
- }
- function ui(t2, e2) {
- 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)
- return t2;
- if (oi(t2) || li(t2))
- return e2 && e2.push(t2), t2;
- if (ArrayBuffer.isView(t2)) {
- const r2 = t2;
- return e2 && e2.push(r2.buffer), r2;
- }
- if (t2 instanceof a.ImageData)
- return e2 && e2.push(t2.data.buffer), t2;
- if (Array.isArray(t2)) {
- const r2 = [];
- for (const n2 of t2)
- r2.push(ui(n2, e2));
- return r2;
- }
- if ("object" == typeof t2) {
- const r2 = t2.constructor, n2 = r2._classRegistryKey;
- if (!n2)
- throw new Error(`can't serialize object of unregistered class ${n2}`);
- const i3 = r2.serialize ? r2.serialize(t2, e2) : {};
- if (!r2.serialize) {
- for (const r3 in t2)
- t2.hasOwnProperty(r3) && (si[n2].omit.indexOf(r3) >= 0 || (i3[r3] = ui(t2[r3], e2)));
- t2 instanceof Error && (i3.message = t2.message);
- }
- if (i3.$name)
- throw new Error("$name property is reserved for worker serialization logic.");
- return "Object" !== n2 && (i3.$name = n2), i3;
- }
- throw new Error("can't serialize object of type " + typeof t2);
- }
- function ci(t2) {
- 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)
- return t2;
- if (Array.isArray(t2))
- return t2.map(ci);
- if ("object" == typeof t2) {
- const e2 = t2.$name || "Object", { klass: r2 } = si[e2];
- if (!r2)
- throw new Error(`can't deserialize unregistered class ${e2}`);
- if (r2.deserialize)
- return r2.deserialize(t2);
- const n2 = Object.create(r2.prototype);
- for (const e3 of Object.keys(t2))
- "$name" !== e3 && (n2[e3] = ci(t2[e3]));
- return n2;
- }
- throw new Error("can't deserialize object of type " + typeof t2);
- }
- class hi {
- constructor() {
- this.first = true;
- }
- update(t2, e2) {
- const r2 = Math.floor(t2);
- 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));
- }
- }
- 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;
- function Ui(t2) {
- for (const e2 of t2)
- if (Oi(e2.charCodeAt(0)))
- return true;
- return false;
- }
- function $i(t2) {
- for (const e2 of t2)
- if (!ji(e2.charCodeAt(0)))
- return false;
- return true;
- }
- function ji(t2) {
- return !(pi(t2) || fi(t2) || di(t2) || Di(t2) || Li(t2));
- }
- function Oi(t2) {
- 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))));
- }
- function qi(t2) {
- return !(Oi(t2) || function(t3) {
- 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);
- }(t2));
- }
- function Ni(t2) {
- return t2 >= 1424 && t2 <= 2303 || Di(t2) || Li(t2);
- }
- function Gi(t2, e2) {
- return !(!e2 && Ni(t2) || t2 >= 2304 && t2 <= 3583 || t2 >= 3840 && t2 <= 4255 || ((t3) => t3 >= 6016 && t3 <= 6143)(t2));
- }
- function Zi(t2) {
- for (const e2 of t2)
- if (Ni(e2.charCodeAt(0)))
- return true;
- return false;
- }
- const Xi = "deferred", Ki = "loading", Yi = "loaded";
- let Hi = null, Wi = "unavailable", Ji = null;
- const Qi = function(t2) {
- t2 && "string" == typeof t2 && t2.indexOf("NetworkError") > -1 && (Wi = "error"), Hi && Hi(t2);
- };
- function ts() {
- es.fire(new Lt("pluginStateChange", { pluginStatus: Wi, pluginURL: Ji }));
- }
- const es = new Ut(), rs = function() {
- return Wi;
- }, ns = function() {
- if (Wi !== Xi || !Ji)
- throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");
- Wi = Ki, ts(), Ji && Mt({ url: Ji }, (t2) => {
- t2 ? Qi(t2) : (Wi = Yi, ts());
- });
- }, is = { applyArabicShaping: null, processBidirectionalText: null, processStyledBidirectionalText: null, isLoaded: () => Wi === Yi || null != is.applyArabicShaping, isLoading: () => Wi === Ki, setState(t2) {
- Wi = t2.pluginStatus, Ji = t2.pluginURL;
- }, isParsed: () => null != is.applyArabicShaping && null != is.processBidirectionalText && null != is.processStyledBidirectionalText, getPluginURL: () => Ji };
- class ss {
- constructor(t2, e2) {
- 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);
- }
- isSupportedScript(t2) {
- return function(t3, e2) {
- for (const r2 of t3)
- if (!Gi(r2.charCodeAt(0), e2))
- return false;
- return true;
- }(t2, is.isLoaded());
- }
- crossFadingFactor() {
- return 0 === this.fadeDuration ? 1 : Math.min((this.now - this.zoomHistory.lastIntegerZoomTime) / this.fadeDuration, 1);
- }
- getCrossfadeParameters() {
- const t2 = this.zoom, e2 = t2 - Math.floor(t2), r2 = this.crossFadingFactor();
- return t2 > this.zoomHistory.lastIntegerZoom ? { fromScale: 2, toScale: 1, t: e2 + (1 - e2) * r2 } : { fromScale: 0.5, toScale: 1, t: 1 - (1 - r2) * e2 };
- }
- }
- class as {
- constructor(t2, e2) {
- this.property = t2, this.value = e2, this.expression = function(t3, e3) {
- if (Qr(t3))
- return new dn(t3, e3);
- if (un(t3)) {
- const r2 = fn(t3, e3);
- if ("error" === r2.result)
- throw new Error(r2.value.map((t4) => `${t4.key}: ${t4.message}`).join(", "));
- return r2.value;
- }
- {
- let r2 = t3;
- return "string" == typeof t3 && "color" === e3.type && (r2 = ce.parse(t3)), { kind: "constant", evaluate: () => r2 };
- }
- }(void 0 === e2 ? t2.specification.default : e2, t2.specification);
- }
- isDataDriven() {
- return "source" === this.expression.kind || "composite" === this.expression.kind;
- }
- possiblyEvaluate(t2, e2, r2) {
- return this.property.possiblyEvaluate(this, t2, e2, r2);
- }
- }
- class os {
- constructor(t2) {
- this.property = t2, this.value = new as(t2, void 0);
- }
- transitioned(t2, e2) {
- return new us(this.property, this.value, e2, b({}, t2.transition, this.transition), t2.now);
- }
- untransitioned() {
- return new us(this.property, this.value, null, {}, 0);
- }
- }
- class ls {
- constructor(t2) {
- this._properties = t2, this._values = Object.create(t2.defaultTransitionablePropertyValues);
- }
- getValue(t2) {
- return B(this._values[t2].value.value);
- }
- setValue(t2, e2) {
- 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));
- }
- getTransition(t2) {
- return B(this._values[t2].transition);
- }
- setTransition(t2, e2) {
- this._values.hasOwnProperty(t2) || (this._values[t2] = new os(this._values[t2].property)), this._values[t2].transition = B(e2) || void 0;
- }
- serialize() {
- const t2 = {};
- for (const e2 of Object.keys(this._values)) {
- const r2 = this.getValue(e2);
- void 0 !== r2 && (t2[e2] = r2);
- const n2 = this.getTransition(e2);
- void 0 !== n2 && (t2[`${e2}-transition`] = n2);
- }
- return t2;
- }
- transitioned(t2, e2) {
- const r2 = new cs(this._properties);
- for (const n2 of Object.keys(this._values))
- r2._values[n2] = this._values[n2].transitioned(t2, e2._values[n2]);
- return r2;
- }
- untransitioned() {
- const t2 = new cs(this._properties);
- for (const e2 of Object.keys(this._values))
- t2._values[e2] = this._values[e2].untransitioned();
- return t2;
- }
- }
- class us {
- constructor(t2, e2, r2, n2, i3) {
- const s2 = n2.delay || 0, a2 = n2.duration || 0;
- 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);
- }
- possiblyEvaluate(t2, e2, r2) {
- const n2 = t2.now || 0, i3 = this.value.possiblyEvaluate(t2, e2, r2), s2 = this.prior;
- if (s2) {
- if (n2 > this.end)
- return this.prior = null, i3;
- if (this.value.isDataDriven())
- return this.prior = null, i3;
- if (n2 < this.begin)
- return s2.possiblyEvaluate(t2, e2, r2);
- {
- const a2 = (n2 - this.begin) / (this.end - this.begin);
- return this.property.interpolate(s2.possiblyEvaluate(t2, e2, r2), i3, p(a2));
- }
- }
- return i3;
- }
- }
- class cs {
- constructor(t2) {
- this._properties = t2, this._values = Object.create(t2.defaultTransitioningPropertyValues);
- }
- possiblyEvaluate(t2, e2, r2) {
- const n2 = new fs(this._properties);
- for (const i3 of Object.keys(this._values))
- n2._values[i3] = this._values[i3].possiblyEvaluate(t2, e2, r2);
- return n2;
- }
- hasTransition() {
- for (const t2 of Object.keys(this._values))
- if (this._values[t2].prior)
- return true;
- return false;
- }
- }
- class hs {
- constructor(t2) {
- this._properties = t2, this._values = Object.create(t2.defaultPropertyValues);
- }
- getValue(t2) {
- return B(this._values[t2].value);
- }
- setValue(t2, e2) {
- this._values[t2] = new as(this._values[t2].property, null === e2 ? void 0 : B(e2));
- }
- serialize() {
- const t2 = {};
- for (const e2 of Object.keys(this._values)) {
- const r2 = this.getValue(e2);
- void 0 !== r2 && (t2[e2] = r2);
- }
- return t2;
- }
- possiblyEvaluate(t2, e2, r2) {
- const n2 = new fs(this._properties);
- for (const i3 of Object.keys(this._values))
- n2._values[i3] = this._values[i3].possiblyEvaluate(t2, e2, r2);
- return n2;
- }
- }
- class ps {
- constructor(t2, e2, r2) {
- this.property = t2, this.value = e2, this.parameters = r2;
- }
- isConstant() {
- return "constant" === this.value.kind;
- }
- constantOr(t2) {
- return "constant" === this.value.kind ? this.value.value : t2;
- }
- evaluate(t2, e2, r2, n2) {
- return this.property.evaluate(this.value, this.parameters, t2, e2, r2, n2);
- }
- }
- class fs {
- constructor(t2) {
- this._properties = t2, this._values = Object.create(t2.defaultPossiblyEvaluatedValues);
- }
- get(t2) {
- return this._values[t2];
- }
- }
- class ds {
- constructor(t2) {
- this.specification = t2;
- }
- possiblyEvaluate(t2, e2) {
- return t2.expression.evaluate(e2);
- }
- interpolate(t2, e2, r2) {
- const n2 = nr[this.specification.type];
- return n2 ? n2(t2, e2, r2) : t2;
- }
- }
- class ys {
- constructor(t2, e2) {
- this.specification = t2, this.overrides = e2;
- }
- possiblyEvaluate(t2, e2, r2, n2) {
- 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);
- }
- interpolate(t2, e2, r2) {
- if ("constant" !== t2.value.kind || "constant" !== e2.value.kind)
- return t2;
- if (void 0 === t2.value.value || void 0 === e2.value.value)
- return new ps(this, { kind: "constant", value: void 0 }, t2.parameters);
- const n2 = nr[this.specification.type];
- return n2 ? new ps(this, { kind: "constant", value: n2(t2.value.value, e2.value.value, r2) }, t2.parameters) : t2;
- }
- evaluate(t2, e2, r2, n2, i3, s2) {
- return "constant" === t2.kind ? t2.value : t2.evaluate(e2, r2, n2, i3, s2);
- }
- }
- class ms extends ys {
- possiblyEvaluate(t2, e2, r2, n2) {
- if (void 0 === t2.value)
- return new ps(this, { kind: "constant", value: void 0 }, e2);
- if ("constant" === t2.expression.kind) {
- 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);
- return new ps(this, { kind: "constant", value: a2 }, e2);
- }
- if ("camera" === t2.expression.kind) {
- 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);
- return new ps(this, { kind: "constant", value: r3 }, e2);
- }
- return new ps(this, t2.expression, e2);
- }
- evaluate(t2, e2, r2, n2, i3, s2) {
- if ("source" === t2.kind) {
- const a2 = t2.evaluate(e2, r2, n2, i3, s2);
- return this._calculate(a2, a2, a2, e2);
- }
- 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;
- }
- _calculate(t2, e2, r2, n2) {
- return n2.zoom > n2.zoomHistory.lastIntegerZoom ? { from: t2, to: e2, other: r2 } : { from: r2, to: e2, other: t2 };
- }
- interpolate(t2) {
- return t2;
- }
- }
- class gs {
- constructor(t2) {
- this.specification = t2;
- }
- possiblyEvaluate(t2, e2, r2, n2) {
- if (void 0 !== t2.value) {
- if ("constant" === t2.expression.kind) {
- const i3 = t2.expression.evaluate(e2, null, {}, r2, n2);
- return this._calculate(i3, i3, i3, e2);
- }
- 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);
- }
- }
- _calculate(t2, e2, r2, n2) {
- return n2.zoom > n2.zoomHistory.lastIntegerZoom ? { from: t2, to: e2 } : { from: r2, to: e2 };
- }
- interpolate(t2) {
- return t2;
- }
- }
- class xs {
- constructor(t2) {
- this.specification = t2;
- }
- possiblyEvaluate(t2, e2, r2, n2) {
- return !!t2.expression.evaluate(e2, null, {}, r2, n2);
- }
- interpolate() {
- return false;
- }
- }
- class vs {
- constructor(t2) {
- this.properties = t2, this.defaultPropertyValues = {}, this.defaultTransitionablePropertyValues = {}, this.defaultTransitioningPropertyValues = {}, this.defaultPossiblyEvaluatedValues = {}, this.overridableProperties = [];
- for (const e2 in t2) {
- const r2 = t2[e2];
- r2.specification.overridable && this.overridableProperties.push(e2);
- const n2 = this.defaultPropertyValues[e2] = new as(r2, void 0), i3 = this.defaultTransitionablePropertyValues[e2] = new os(r2);
- this.defaultTransitioningPropertyValues[e2] = i3.untransitioned(), this.defaultPossiblyEvaluatedValues[e2] = n2.possiblyEvaluate({});
- }
- }
- }
- function bs(t2, e2) {
- return 256 * (t2 = y(Math.floor(t2), 0, 255)) + y(Math.floor(e2), 0, 255);
- }
- ai(ys, "DataDrivenProperty"), ai(ds, "DataConstantProperty"), ai(ms, "CrossFadedDataDrivenProperty"), ai(gs, "CrossFadedProperty"), ai(xs, "ColorRampProperty");
- const _s = { Int8: Int8Array, Uint8: Uint8Array, Int16: Int16Array, Uint16: Uint16Array, Int32: Int32Array, Uint32: Uint32Array, Float32: Float32Array };
- class ws {
- constructor(t2, e2) {
- this._structArray = t2, this._pos1 = e2 * this.size, this._pos2 = this._pos1 / 2, this._pos4 = this._pos1 / 4, this._pos8 = this._pos1 / 8;
- }
- }
- class As {
- constructor() {
- this.isTransferred = false, this.capacity = -1, this.resize(0);
- }
- static serialize(t2, e2) {
- return t2._trim(), e2 && (t2.isTransferred = true, e2.push(t2.arrayBuffer)), { length: t2.length, arrayBuffer: t2.arrayBuffer };
- }
- static deserialize(t2) {
- const e2 = Object.create(this.prototype);
- return e2.arrayBuffer = t2.arrayBuffer, e2.length = t2.length, e2.capacity = t2.arrayBuffer.byteLength / e2.bytesPerElement, e2._refreshViews(), e2;
- }
- _trim() {
- this.length !== this.capacity && (this.capacity = this.length, this.arrayBuffer = this.arrayBuffer.slice(0, this.length * this.bytesPerElement), this._refreshViews());
- }
- clear() {
- this.length = 0;
- }
- resize(t2) {
- this.reserve(t2), this.length = t2;
- }
- reserve(t2) {
- if (t2 > this.capacity) {
- this.capacity = Math.max(t2, Math.floor(5 * this.capacity), 128), this.arrayBuffer = new ArrayBuffer(this.capacity * this.bytesPerElement);
- const e2 = this.uint8;
- this._refreshViews(), e2 && this.uint8.set(e2);
- }
- }
- _refreshViews() {
- throw new Error("_refreshViews() must be implemented by each concrete StructArray layout");
- }
- destroy() {
- this.int8 = this.uint8 = this.int16 = this.uint16 = this.int32 = this.uint32 = this.float32 = null, this.arrayBuffer = null;
- }
- }
- function ks(t2, e2 = 1) {
- let r2 = 0, n2 = 0;
- return { members: t2.map((t3) => {
- const i3 = _s[t3.type].BYTES_PER_ELEMENT, s2 = r2 = Ss(r2, Math.max(e2, i3)), a2 = t3.components || 1;
- return n2 = Math.max(n2, i3), r2 += i3 * a2, { name: t3.name, type: t3.type, components: a2, offset: s2 };
- }), size: Ss(r2, Math.max(n2, e2)), alignment: e2 };
- }
- function Ss(t2, e2) {
- return Math.ceil(t2 / e2) * e2;
- }
- class Is extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2) {
- const r2 = this.length;
- return this.resize(r2 + 1), this.emplace(r2, t2, e2);
- }
- emplace(t2, e2, r2) {
- const n2 = 2 * t2;
- return this.int16[n2 + 0] = e2, this.int16[n2 + 1] = r2, t2;
- }
- }
- Is.prototype.bytesPerElement = 4, ai(Is, "StructArrayLayout2i4");
- class Ms extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2, r2) {
- const n2 = this.length;
- return this.resize(n2 + 1), this.emplace(n2, t2, e2, r2);
- }
- emplace(t2, e2, r2, n2) {
- const i3 = 3 * t2;
- return this.int16[i3 + 0] = e2, this.int16[i3 + 1] = r2, this.int16[i3 + 2] = n2, t2;
- }
- }
- Ms.prototype.bytesPerElement = 6, ai(Ms, "StructArrayLayout3i6");
- class Ts extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2, r2, n2) {
- const i3 = this.length;
- return this.resize(i3 + 1), this.emplace(i3, t2, e2, r2, n2);
- }
- emplace(t2, e2, r2, n2, i3) {
- const s2 = 4 * t2;
- return this.int16[s2 + 0] = e2, this.int16[s2 + 1] = r2, this.int16[s2 + 2] = n2, this.int16[s2 + 3] = i3, t2;
- }
- }
- Ts.prototype.bytesPerElement = 8, ai(Ts, "StructArrayLayout4i8");
- class zs extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2, r2, n2, i3, s2, a2) {
- const o2 = this.length;
- return this.resize(o2 + 1), this.emplace(o2, t2, e2, r2, n2, i3, s2, a2);
- }
- emplace(t2, e2, r2, n2, i3, s2, a2, o2) {
- const l2 = 6 * t2, u2 = 12 * t2, c2 = 3 * t2;
- 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;
- }
- }
- zs.prototype.bytesPerElement = 12, ai(zs, "StructArrayLayout2i4ub1f12");
- class Bs extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2, r2, n2) {
- const i3 = this.length;
- return this.resize(i3 + 1), this.emplace(i3, t2, e2, r2, n2);
- }
- emplace(t2, e2, r2, n2, i3) {
- const s2 = 4 * t2;
- return this.float32[s2 + 0] = e2, this.float32[s2 + 1] = r2, this.float32[s2 + 2] = n2, this.float32[s2 + 3] = i3, t2;
- }
- }
- Bs.prototype.bytesPerElement = 16, ai(Bs, "StructArrayLayout4f16");
- class Es extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2) {
- const c2 = this.length;
- return this.resize(c2 + 1), this.emplace(c2, t2, e2, r2, n2, i3, s2, a2, o2, l2, u2);
- }
- emplace(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2) {
- const h2 = 10 * t2;
- 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;
- }
- }
- Es.prototype.bytesPerElement = 20, ai(Es, "StructArrayLayout10ui20");
- class Cs extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2, r2, n2, i3, s2, a2, o2) {
- const l2 = this.length;
- return this.resize(l2 + 1), this.emplace(l2, t2, e2, r2, n2, i3, s2, a2, o2);
- }
- emplace(t2, e2, r2, n2, i3, s2, a2, o2, l2) {
- const u2 = 8 * t2;
- 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;
- }
- }
- Cs.prototype.bytesPerElement = 16, ai(Cs, "StructArrayLayout8ui16");
- class Ds extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2, r2, n2, i3, s2) {
- const a2 = this.length;
- return this.resize(a2 + 1), this.emplace(a2, t2, e2, r2, n2, i3, s2);
- }
- emplace(t2, e2, r2, n2, i3, s2, a2) {
- const o2 = 6 * t2;
- 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;
- }
- }
- Ds.prototype.bytesPerElement = 12, ai(Ds, "StructArrayLayout6i12");
- class Ps extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2) {
- const m2 = this.length;
- return this.resize(m2 + 1), this.emplace(m2, t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2);
- }
- emplace(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2, m2) {
- const g2 = 16 * t2;
- 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;
- }
- }
- Ps.prototype.bytesPerElement = 32, ai(Ps, "StructArrayLayout4i4ui4i4i32");
- class Vs extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2, r2) {
- const n2 = this.length;
- return this.resize(n2 + 1), this.emplace(n2, t2, e2, r2);
- }
- emplace(t2, e2, r2, n2) {
- const i3 = 3 * t2;
- return this.float32[i3 + 0] = e2, this.float32[i3 + 1] = r2, this.float32[i3 + 2] = n2, t2;
- }
- }
- Vs.prototype.bytesPerElement = 12, ai(Vs, "StructArrayLayout3f12");
- class Fs extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.uint32 = new Uint32Array(this.arrayBuffer);
- }
- emplaceBack(t2) {
- const e2 = this.length;
- return this.resize(e2 + 1), this.emplace(e2, t2);
- }
- emplace(t2, e2) {
- return this.uint32[1 * t2 + 0] = e2, t2;
- }
- }
- Fs.prototype.bytesPerElement = 4, ai(Fs, "StructArrayLayout1ul4");
- class Ls extends As {
- _refreshViews() {
- 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);
- }
- emplaceBack(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2) {
- const f2 = this.length;
- return this.resize(f2 + 1), this.emplace(f2, t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2);
- }
- emplace(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2) {
- const d2 = 20 * t2, y2 = 10 * t2;
- 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;
- }
- }
- Ls.prototype.bytesPerElement = 40, ai(Ls, "StructArrayLayout5i4f1i1ul2ui40");
- class Rs extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2, r2, n2, i3, s2, a2) {
- const o2 = this.length;
- return this.resize(o2 + 1), this.emplace(o2, t2, e2, r2, n2, i3, s2, a2);
- }
- emplace(t2, e2, r2, n2, i3, s2, a2, o2) {
- const l2 = 8 * t2;
- 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;
- }
- }
- Rs.prototype.bytesPerElement = 16, ai(Rs, "StructArrayLayout3i2i2i16");
- class Us extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2, r2, n2, i3) {
- const s2 = this.length;
- return this.resize(s2 + 1), this.emplace(s2, t2, e2, r2, n2, i3);
- }
- emplace(t2, e2, r2, n2, i3, s2) {
- const a2 = 4 * t2, o2 = 8 * t2;
- 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;
- }
- }
- Us.prototype.bytesPerElement = 16, ai(Us, "StructArrayLayout2f1f2i16");
- class $s extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2, r2, n2) {
- const i3 = this.length;
- return this.resize(i3 + 1), this.emplace(i3, t2, e2, r2, n2);
- }
- emplace(t2, e2, r2, n2, i3) {
- const s2 = 12 * t2, a2 = 3 * t2;
- return this.uint8[s2 + 0] = e2, this.uint8[s2 + 1] = r2, this.float32[a2 + 1] = n2, this.float32[a2 + 2] = i3, t2;
- }
- }
- $s.prototype.bytesPerElement = 12, ai($s, "StructArrayLayout2ub2f12");
- class js extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2, r2) {
- const n2 = this.length;
- return this.resize(n2 + 1), this.emplace(n2, t2, e2, r2);
- }
- emplace(t2, e2, r2, n2) {
- const i3 = 3 * t2;
- return this.uint16[i3 + 0] = e2, this.uint16[i3 + 1] = r2, this.uint16[i3 + 2] = n2, t2;
- }
- }
- js.prototype.bytesPerElement = 6, ai(js, "StructArrayLayout3ui6");
- class Os extends As {
- _refreshViews() {
- 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);
- }
- emplaceBack(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2, m2, g2, x2, v2, b2) {
- const _2 = this.length;
- 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);
- }
- emplace(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2, m2, g2, x2, v2, b2, _2) {
- const w2 = 30 * t2, A2 = 15 * t2, k2 = 60 * t2;
- 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;
- }
- }
- Os.prototype.bytesPerElement = 60, ai(Os, "StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");
- class qs extends As {
- _refreshViews() {
- 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);
- }
- 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) {
- const B2 = this.length;
- 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);
- }
- 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) {
- const E2 = 38 * t2, C2 = 19 * t2;
- 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;
- }
- }
- qs.prototype.bytesPerElement = 76, ai(qs, "StructArrayLayout3i2f6i15ui1ul3f76");
- class Ns extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
- }
- emplaceBack(t2) {
- const e2 = this.length;
- return this.resize(e2 + 1), this.emplace(e2, t2);
- }
- emplace(t2, e2) {
- return this.float32[1 * t2 + 0] = e2, t2;
- }
- }
- Ns.prototype.bytesPerElement = 4, ai(Ns, "StructArrayLayout1f4");
- class Gs extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2, r2, n2, i3, s2, a2) {
- const o2 = this.length;
- return this.resize(o2 + 1), this.emplace(o2, t2, e2, r2, n2, i3, s2, a2);
- }
- emplace(t2, e2, r2, n2, i3, s2, a2, o2) {
- const l2 = 7 * t2;
- 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;
- }
- }
- Gs.prototype.bytesPerElement = 28, ai(Gs, "StructArrayLayout7f28");
- class Zs extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2, r2, n2, i3) {
- const s2 = this.length;
- return this.resize(s2 + 1), this.emplace(s2, t2, e2, r2, n2, i3);
- }
- emplace(t2, e2, r2, n2, i3, s2) {
- const a2 = 5 * t2;
- 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;
- }
- }
- Zs.prototype.bytesPerElement = 20, ai(Zs, "StructArrayLayout5f20");
- class Xs extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.uint32 = new Uint32Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2, r2, n2) {
- const i3 = this.length;
- return this.resize(i3 + 1), this.emplace(i3, t2, e2, r2, n2);
- }
- emplace(t2, e2, r2, n2, i3) {
- const s2 = 6 * t2;
- return this.uint32[3 * t2 + 0] = e2, this.uint16[s2 + 2] = r2, this.uint16[s2 + 3] = n2, this.uint16[s2 + 4] = i3, t2;
- }
- }
- Xs.prototype.bytesPerElement = 12, ai(Xs, "StructArrayLayout1ul3ui12");
- class Ks extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2) {
- const r2 = this.length;
- return this.resize(r2 + 1), this.emplace(r2, t2, e2);
- }
- emplace(t2, e2, r2) {
- const n2 = 2 * t2;
- return this.uint16[n2 + 0] = e2, this.uint16[n2 + 1] = r2, t2;
- }
- }
- Ks.prototype.bytesPerElement = 4, ai(Ks, "StructArrayLayout2ui4");
- class Ys extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
- }
- emplaceBack(t2) {
- const e2 = this.length;
- return this.resize(e2 + 1), this.emplace(e2, t2);
- }
- emplace(t2, e2) {
- return this.uint16[1 * t2 + 0] = e2, t2;
- }
- }
- Ys.prototype.bytesPerElement = 2, ai(Ys, "StructArrayLayout1ui2");
- class Hs extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2) {
- const r2 = this.length;
- return this.resize(r2 + 1), this.emplace(r2, t2, e2);
- }
- emplace(t2, e2, r2) {
- const n2 = 2 * t2;
- return this.float32[n2 + 0] = e2, this.float32[n2 + 1] = r2, t2;
- }
- }
- Hs.prototype.bytesPerElement = 8, ai(Hs, "StructArrayLayout2f8");
- class Ws extends As {
- _refreshViews() {
- this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
- }
- emplaceBack(t2, e2, r2, n2, i3, s2, a2) {
- const o2 = this.length;
- return this.resize(o2 + 1), this.emplace(o2, t2, e2, r2, n2, i3, s2, a2);
- }
- emplace(t2, e2, r2, n2, i3, s2, a2, o2) {
- const l2 = 8 * t2, u2 = 4 * t2;
- 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;
- }
- }
- Ws.prototype.bytesPerElement = 16, ai(Ws, "StructArrayLayout6i1f16");
- class Js extends ws {
- get a_pos_30() {
- return this._structArray.int16[this._pos2 + 0];
- }
- get a_pos_31() {
- return this._structArray.int16[this._pos2 + 1];
- }
- get a_pos_32() {
- return this._structArray.int16[this._pos2 + 2];
- }
- get a_pos_normal_30() {
- return this._structArray.int16[this._pos2 + 3];
- }
- get a_pos_normal_31() {
- return this._structArray.int16[this._pos2 + 4];
- }
- get a_pos_normal_32() {
- return this._structArray.int16[this._pos2 + 5];
- }
- }
- Js.prototype.size = 12;
- class Qs extends Ds {
- get(t2) {
- return new Js(this, t2);
- }
- }
- ai(Qs, "FillExtrusionExtArray");
- class ta extends ws {
- get projectedAnchorX() {
- return this._structArray.int16[this._pos2 + 0];
- }
- get projectedAnchorY() {
- return this._structArray.int16[this._pos2 + 1];
- }
- get projectedAnchorZ() {
- return this._structArray.int16[this._pos2 + 2];
- }
- get tileAnchorX() {
- return this._structArray.int16[this._pos2 + 3];
- }
- get tileAnchorY() {
- return this._structArray.int16[this._pos2 + 4];
- }
- get x1() {
- return this._structArray.float32[this._pos4 + 3];
- }
- get y1() {
- return this._structArray.float32[this._pos4 + 4];
- }
- get x2() {
- return this._structArray.float32[this._pos4 + 5];
- }
- get y2() {
- return this._structArray.float32[this._pos4 + 6];
- }
- get padding() {
- return this._structArray.int16[this._pos2 + 14];
- }
- get featureIndex() {
- return this._structArray.uint32[this._pos4 + 8];
- }
- get sourceLayerIndex() {
- return this._structArray.uint16[this._pos2 + 18];
- }
- get bucketIndex() {
- return this._structArray.uint16[this._pos2 + 19];
- }
- }
- ta.prototype.size = 40;
- class ea extends Ls {
- get(t2) {
- return new ta(this, t2);
- }
- }
- ai(ea, "CollisionBoxArray");
- class ra extends ws {
- get projectedAnchorX() {
- return this._structArray.int16[this._pos2 + 0];
- }
- get projectedAnchorY() {
- return this._structArray.int16[this._pos2 + 1];
- }
- get projectedAnchorZ() {
- return this._structArray.int16[this._pos2 + 2];
- }
- get tileAnchorX() {
- return this._structArray.float32[this._pos4 + 2];
- }
- get tileAnchorY() {
- return this._structArray.float32[this._pos4 + 3];
- }
- get glyphStartIndex() {
- return this._structArray.uint16[this._pos2 + 8];
- }
- get numGlyphs() {
- return this._structArray.uint16[this._pos2 + 9];
- }
- get vertexStartIndex() {
- return this._structArray.uint32[this._pos4 + 5];
- }
- get lineStartIndex() {
- return this._structArray.uint32[this._pos4 + 6];
- }
- get lineLength() {
- return this._structArray.uint32[this._pos4 + 7];
- }
- get segment() {
- return this._structArray.uint16[this._pos2 + 16];
- }
- get lowerSize() {
- return this._structArray.uint16[this._pos2 + 17];
- }
- get upperSize() {
- return this._structArray.uint16[this._pos2 + 18];
- }
- get lineOffsetX() {
- return this._structArray.float32[this._pos4 + 10];
- }
- get lineOffsetY() {
- return this._structArray.float32[this._pos4 + 11];
- }
- get writingMode() {
- return this._structArray.uint8[this._pos1 + 48];
- }
- get placedOrientation() {
- return this._structArray.uint8[this._pos1 + 49];
- }
- set placedOrientation(t2) {
- this._structArray.uint8[this._pos1 + 49] = t2;
- }
- get hidden() {
- return this._structArray.uint8[this._pos1 + 50];
- }
- set hidden(t2) {
- this._structArray.uint8[this._pos1 + 50] = t2;
- }
- get crossTileID() {
- return this._structArray.uint32[this._pos4 + 13];
- }
- set crossTileID(t2) {
- this._structArray.uint32[this._pos4 + 13] = t2;
- }
- get associatedIconIndex() {
- return this._structArray.int16[this._pos2 + 28];
- }
- get flipState() {
- return this._structArray.uint8[this._pos1 + 58];
- }
- set flipState(t2) {
- this._structArray.uint8[this._pos1 + 58] = t2;
- }
- }
- ra.prototype.size = 60;
- class na extends Os {
- get(t2) {
- return new ra(this, t2);
- }
- }
- ai(na, "PlacedSymbolArray");
- class ia extends ws {
- get projectedAnchorX() {
- return this._structArray.int16[this._pos2 + 0];
- }
- get projectedAnchorY() {
- return this._structArray.int16[this._pos2 + 1];
- }
- get projectedAnchorZ() {
- return this._structArray.int16[this._pos2 + 2];
- }
- get tileAnchorX() {
- return this._structArray.float32[this._pos4 + 2];
- }
- get tileAnchorY() {
- return this._structArray.float32[this._pos4 + 3];
- }
- get rightJustifiedTextSymbolIndex() {
- return this._structArray.int16[this._pos2 + 8];
- }
- get centerJustifiedTextSymbolIndex() {
- return this._structArray.int16[this._pos2 + 9];
- }
- get leftJustifiedTextSymbolIndex() {
- return this._structArray.int16[this._pos2 + 10];
- }
- get verticalPlacedTextSymbolIndex() {
- return this._structArray.int16[this._pos2 + 11];
- }
- get placedIconSymbolIndex() {
- return this._structArray.int16[this._pos2 + 12];
- }
- get verticalPlacedIconSymbolIndex() {
- return this._structArray.int16[this._pos2 + 13];
- }
- get key() {
- return this._structArray.uint16[this._pos2 + 14];
- }
- get textBoxStartIndex() {
- return this._structArray.uint16[this._pos2 + 15];
- }
- get textBoxEndIndex() {
- return this._structArray.uint16[this._pos2 + 16];
- }
- get verticalTextBoxStartIndex() {
- return this._structArray.uint16[this._pos2 + 17];
- }
- get verticalTextBoxEndIndex() {
- return this._structArray.uint16[this._pos2 + 18];
- }
- get iconBoxStartIndex() {
- return this._structArray.uint16[this._pos2 + 19];
- }
- get iconBoxEndIndex() {
- return this._structArray.uint16[this._pos2 + 20];
- }
- get verticalIconBoxStartIndex() {
- return this._structArray.uint16[this._pos2 + 21];
- }
- get verticalIconBoxEndIndex() {
- return this._structArray.uint16[this._pos2 + 22];
- }
- get featureIndex() {
- return this._structArray.uint16[this._pos2 + 23];
- }
- get numHorizontalGlyphVertices() {
- return this._structArray.uint16[this._pos2 + 24];
- }
- get numVerticalGlyphVertices() {
- return this._structArray.uint16[this._pos2 + 25];
- }
- get numIconVertices() {
- return this._structArray.uint16[this._pos2 + 26];
- }
- get numVerticalIconVertices() {
- return this._structArray.uint16[this._pos2 + 27];
- }
- get useRuntimeCollisionCircles() {
- return this._structArray.uint16[this._pos2 + 28];
- }
- get crossTileID() {
- return this._structArray.uint32[this._pos4 + 15];
- }
- set crossTileID(t2) {
- this._structArray.uint32[this._pos4 + 15] = t2;
- }
- get textOffset0() {
- return this._structArray.float32[this._pos4 + 16];
- }
- get textOffset1() {
- return this._structArray.float32[this._pos4 + 17];
- }
- get collisionCircleDiameter() {
- return this._structArray.float32[this._pos4 + 18];
- }
- }
- ia.prototype.size = 76;
- class sa extends qs {
- get(t2) {
- return new ia(this, t2);
- }
- }
- ai(sa, "SymbolInstanceArray");
- class aa extends Ns {
- getoffsetX(t2) {
- return this.float32[1 * t2 + 0];
- }
- }
- ai(aa, "GlyphOffsetArray");
- class oa extends Ms {
- getx(t2) {
- return this.int16[3 * t2 + 0];
- }
- gety(t2) {
- return this.int16[3 * t2 + 1];
- }
- gettileUnitDistanceFromAnchor(t2) {
- return this.int16[3 * t2 + 2];
- }
- }
- ai(oa, "SymbolLineVertexArray");
- class la extends ws {
- get featureIndex() {
- return this._structArray.uint32[this._pos4 + 0];
- }
- get sourceLayerIndex() {
- return this._structArray.uint16[this._pos2 + 2];
- }
- get bucketIndex() {
- return this._structArray.uint16[this._pos2 + 3];
- }
- get layoutVertexArrayOffset() {
- return this._structArray.uint16[this._pos2 + 4];
- }
- }
- la.prototype.size = 12;
- class ua extends Xs {
- get(t2) {
- return new la(this, t2);
- }
- }
- ai(ua, "FeatureIndexArray");
- class ca extends ws {
- get a_centroid_pos0() {
- return this._structArray.uint16[this._pos2 + 0];
- }
- get a_centroid_pos1() {
- return this._structArray.uint16[this._pos2 + 1];
- }
- }
- ca.prototype.size = 4;
- class ha extends Ks {
- get(t2) {
- return new ca(this, t2);
- }
- }
- ai(ha, "FillExtrusionCentroidArray");
- class pa extends ws {
- get a_pos_30() {
- return this._structArray.int16[this._pos2 + 0];
- }
- get a_pos_31() {
- return this._structArray.int16[this._pos2 + 1];
- }
- get a_pos_32() {
- return this._structArray.int16[this._pos2 + 2];
- }
- get a_pos_normal_30() {
- return this._structArray.int16[this._pos2 + 3];
- }
- get a_pos_normal_31() {
- return this._structArray.int16[this._pos2 + 4];
- }
- get a_pos_normal_32() {
- return this._structArray.int16[this._pos2 + 5];
- }
- get a_scale() {
- return this._structArray.float32[this._pos4 + 3];
- }
- }
- pa.prototype.size = 16;
- class fa extends Ws {
- get(t2) {
- return new pa(this, t2);
- }
- }
- ai(fa, "CircleGlobeExtArray");
- 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" }]);
- var ma = le(function(t2) {
- t2.exports = function(t3, e2) {
- var r2, n2, i3, s2, a2, o2, l2, u2;
- for (n2 = t3.length - (r2 = 3 & t3.length), i3 = e2, a2 = 3432918353, o2 = 461845907, u2 = 0; u2 < n2; )
- 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);
- switch (l2 = 0, r2) {
- case 3:
- l2 ^= (255 & t3.charCodeAt(u2 + 2)) << 16;
- case 2:
- l2 ^= (255 & t3.charCodeAt(u2 + 1)) << 8;
- case 1:
- 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;
- }
- 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;
- };
- }), ga = le(function(t2) {
- t2.exports = function(t3, e2) {
- for (var r2, n2 = t3.length, i3 = e2 ^ n2, s2 = 0; n2 >= 4; )
- 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;
- switch (n2) {
- case 3:
- i3 ^= (255 & t3.charCodeAt(s2 + 2)) << 16;
- case 2:
- i3 ^= (255 & t3.charCodeAt(s2 + 1)) << 8;
- case 1:
- i3 = 1540483477 * (65535 & (i3 ^= 255 & t3.charCodeAt(s2))) + ((1540483477 * (i3 >>> 16) & 65535) << 16);
- }
- return i3 = 1540483477 * (65535 & (i3 ^= i3 >>> 13)) + ((1540483477 * (i3 >>> 16) & 65535) << 16), (i3 ^= i3 >>> 15) >>> 0;
- };
- }), xa = ma, va = ga;
- xa.murmur3 = ma, xa.murmur2 = va;
- class ba {
- constructor() {
- this.ids = [], this.positions = [], this.indexed = false;
- }
- add(t2, e2, r2, n2) {
- this.ids.push(_a(t2)), this.positions.push(e2, r2, n2);
- }
- getPositions(t2) {
- const e2 = _a(t2);
- let r2 = 0, n2 = this.ids.length - 1;
- for (; r2 < n2; ) {
- const t3 = r2 + n2 >> 1;
- this.ids[t3] >= e2 ? n2 = t3 : r2 = t3 + 1;
- }
- const i3 = [];
- for (; this.ids[r2] === e2; )
- i3.push({ index: this.positions[3 * r2], start: this.positions[3 * r2 + 1], end: this.positions[3 * r2 + 2] }), r2++;
- return i3;
- }
- static serialize(t2, e2) {
- const r2 = new Float64Array(t2.ids), n2 = new Uint32Array(t2.positions);
- return wa(r2, n2, 0, r2.length - 1), e2 && e2.push(r2.buffer, n2.buffer), { ids: r2, positions: n2 };
- }
- static deserialize(t2) {
- const e2 = new ba();
- return e2.ids = t2.ids, e2.positions = t2.positions, e2.indexed = true, e2;
- }
- }
- function _a(t2) {
- const e2 = +t2;
- return !isNaN(e2) && Number.MIN_SAFE_INTEGER <= e2 && e2 <= Number.MAX_SAFE_INTEGER ? e2 : xa(String(t2));
- }
- function wa(t2, e2, r2, n2) {
- for (; r2 < n2; ) {
- const i3 = t2[r2 + n2 >> 1];
- let s2 = r2 - 1, a2 = n2 + 1;
- for (; ; ) {
- do {
- s2++;
- } while (t2[s2] < i3);
- do {
- a2--;
- } while (t2[a2] > i3);
- if (s2 >= a2)
- break;
- 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);
- }
- a2 - r2 < n2 - a2 ? (wa(t2, e2, r2, a2), r2 = a2 + 1) : (wa(t2, e2, a2 + 1, n2), n2 = a2);
- }
- }
- function Aa(t2, e2, r2) {
- const n2 = t2[e2];
- t2[e2] = t2[r2], t2[r2] = n2;
- }
- ai(ba, "FeaturePositionMap");
- class ka {
- constructor(t2, e2) {
- this.gl = t2.gl, this.location = e2;
- }
- }
- class Sa extends ka {
- constructor(t2, e2) {
- super(t2, e2), this.current = 0;
- }
- set(t2) {
- this.current !== t2 && (this.current = t2, this.gl.uniform1f(this.location, t2));
- }
- }
- class Ia extends ka {
- constructor(t2, e2) {
- super(t2, e2), this.current = [0, 0, 0, 0];
- }
- set(t2) {
- 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]));
- }
- }
- class Ma extends ka {
- constructor(t2, e2) {
- super(t2, e2), this.current = ce.transparent;
- }
- set(t2) {
- 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));
- }
- }
- const Ta = new Float32Array(16), za = new Float32Array(9), Ba = new Float32Array(4);
- function Ea(t2) {
- return [bs(255 * t2.r, 255 * t2.g), bs(255 * t2.b, 255 * t2.a)];
- }
- class Ca {
- constructor(t2, e2, r2) {
- this.value = t2, this.uniformNames = e2.map((t3) => `u_${t3}`), this.type = r2;
- }
- setUniform(t2, e2, r2) {
- t2.set(r2.constantOr(this.value));
- }
- getBinding(t2, e2, r2) {
- return "color" === this.type ? new Ma(t2, e2) : new Sa(t2, e2);
- }
- }
- class Da {
- constructor(t2, e2) {
- this.uniformNames = e2.map((t3) => `u_${t3}`), this.patternFrom = null, this.patternTo = null, this.pixelRatioFrom = 1, this.pixelRatioTo = 1;
- }
- setConstantPatternPositions(t2, e2) {
- this.pixelRatioFrom = e2.pixelRatio || 1, this.pixelRatioTo = t2.pixelRatio || 1, this.patternFrom = e2.tl.concat(e2.br), this.patternTo = t2.tl.concat(t2.br);
- }
- setUniform(t2, e2, r2, n2) {
- 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;
- i3 && t2.set(i3);
- }
- getBinding(t2, e2, r2) {
- 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);
- }
- }
- class Pa {
- constructor(t2, e2, r2, n2) {
- 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();
- }
- populatePaintArray(t2, e2, r2, n2, i3, s2) {
- const a2 = this.paintVertexArray.length, o2 = this.expression.evaluate(new ss(0), e2, {}, i3, n2, s2);
- this.paintVertexArray.resize(t2), this._setPaintValue(a2, t2, o2);
- }
- updatePaintArray(t2, e2, r2, n2, i3) {
- const s2 = this.expression.evaluate({ zoom: 0 }, r2, n2, void 0, i3);
- this._setPaintValue(t2, e2, s2);
- }
- _setPaintValue(t2, e2, r2) {
- if ("color" === this.type) {
- const n2 = Ea(r2);
- for (let r3 = t2; r3 < e2; r3++)
- this.paintVertexArray.emplace(r3, n2[0], n2[1]);
- } else {
- for (let n2 = t2; n2 < e2; n2++)
- this.paintVertexArray.emplace(n2, r2);
- this.maxValue = Math.max(this.maxValue, Math.abs(r2));
- }
- }
- upload(t2) {
- 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));
- }
- destroy() {
- this.paintVertexBuffer && this.paintVertexBuffer.destroy();
- }
- }
- class Va {
- constructor(t2, e2, r2, n2, i3, s2) {
- 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();
- }
- populatePaintArray(t2, e2, r2, n2, i3, s2) {
- 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;
- this.paintVertexArray.resize(t2), this._setPaintValue(l2, t2, a2, o2);
- }
- updatePaintArray(t2, e2, r2, n2, i3) {
- 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);
- this._setPaintValue(t2, e2, s2, a2);
- }
- _setPaintValue(t2, e2, r2, n2) {
- if ("color" === this.type) {
- const i3 = Ea(r2), s2 = Ea(n2);
- for (let r3 = t2; r3 < e2; r3++)
- this.paintVertexArray.emplace(r3, i3[0], i3[1], s2[0], s2[1]);
- } else {
- for (let i3 = t2; i3 < e2; i3++)
- this.paintVertexArray.emplace(i3, r2, n2);
- this.maxValue = Math.max(this.maxValue, Math.abs(r2), Math.abs(n2));
- }
- }
- upload(t2) {
- 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));
- }
- destroy() {
- this.paintVertexBuffer && this.paintVertexBuffer.destroy();
- }
- setUniform(t2, e2) {
- const r2 = this.useIntegerZoom ? Math.floor(e2.zoom) : e2.zoom, n2 = y(this.expression.interpolationFactor(r2, this.zoom, this.zoom + 1), 0, 1);
- t2.set(n2);
- }
- getBinding(t2, e2, r2) {
- return new Sa(t2, e2);
- }
- }
- class Fa {
- constructor(t2, e2, r2, n2, i3, s2, a2) {
- this.expression = t2, this.type = r2, this.useIntegerZoom = n2, this.zoom = i3, this.layerId = a2, this.paintVertexAttributes = ("array" === r2 ? ya : da).members;
- for (let t3 = 0; t3 < e2.length; ++t3)
- ;
- this.zoomInPaintVertexArray = new s2(), this.zoomOutPaintVertexArray = new s2();
- }
- populatePaintArray(t2, e2, r2) {
- const n2 = this.zoomInPaintVertexArray.length;
- this.zoomInPaintVertexArray.resize(t2), this.zoomOutPaintVertexArray.resize(t2), this._setPaintValues(n2, t2, e2.patterns && e2.patterns[this.layerId], r2);
- }
- updatePaintArray(t2, e2, r2, n2, i3, s2) {
- this._setPaintValues(t2, e2, r2.patterns && r2.patterns[this.layerId], s2);
- }
- _setPaintValues(t2, e2, r2, n2) {
- if (!n2 || !r2)
- return;
- const { min: i3, mid: s2, max: a2 } = r2, o2 = n2[i3], l2 = n2[s2], u2 = n2[a2];
- if (o2 && l2 && u2)
- for (let r3 = t2; r3 < e2; r3++)
- this._setPaintValue(this.zoomInPaintVertexArray, r3, l2, o2), this._setPaintValue(this.zoomOutPaintVertexArray, r3, l2, u2);
- }
- _setPaintValue(t2, e2, r2, n2) {
- 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);
- }
- upload(t2) {
- 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));
- }
- destroy() {
- this.zoomOutPaintVertexBuffer && this.zoomOutPaintVertexBuffer.destroy(), this.zoomInPaintVertexBuffer && this.zoomInPaintVertexBuffer.destroy();
- }
- }
- class La {
- constructor(t2, e2, r2 = () => true) {
- this.binders = {}, this._buffers = [];
- const n2 = [];
- for (const i3 in t2.paint._values) {
- if (!r2(i3))
- continue;
- const s2 = t2.paint.get(i3);
- if (!(s2 instanceof ps && Yr(s2.property.specification)))
- continue;
- 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;
- if ("constant" !== o2.kind || p2)
- if ("source" === o2.kind || p2 || h2) {
- const r3 = qa(i3, l2, "source");
- this.binders[i3] = h2 ? new Fa(o2, a2, l2, u2, e2, r3, t2.id) : new Pa(o2, a2, l2, r3), n2.push(`/a_${i3}`);
- } else {
- const t3 = qa(i3, l2, "composite");
- this.binders[i3] = new Va(o2, a2, l2, u2, e2, t3), n2.push(`/z_${i3}`);
- }
- else
- this.binders[i3] = h2 ? new Da(o2.value, a2) : new Ca(o2.value, a2, l2), n2.push(`/u_${i3}`);
- }
- this.cacheKey = n2.sort().join("");
- }
- getMaxValue(t2) {
- const e2 = this.binders[t2];
- return e2 instanceof Pa || e2 instanceof Va ? e2.maxValue : 0;
- }
- populatePaintArrays(t2, e2, r2, n2, i3, s2) {
- for (const a2 in this.binders) {
- const o2 = this.binders[a2];
- (o2 instanceof Pa || o2 instanceof Va || o2 instanceof Fa) && o2.populatePaintArray(t2, e2, r2, n2, i3, s2);
- }
- }
- setConstantPatternPositions(t2, e2) {
- for (const r2 in this.binders) {
- const n2 = this.binders[r2];
- n2 instanceof Da && n2.setConstantPatternPositions(t2, e2);
- }
- }
- updatePaintArrays(t2, e2, r2, n2, i3, s2) {
- let a2 = false;
- for (const o2 in t2) {
- const l2 = e2.getPositions(o2);
- for (const e3 of l2) {
- const l3 = r2.feature(e3.index);
- for (const r3 in this.binders) {
- const u2 = this.binders[r3];
- if ((u2 instanceof Pa || u2 instanceof Va || u2 instanceof Fa) && true === u2.expression.isStateDependent) {
- const c2 = n2.paint.get(r3);
- u2.expression = c2.value, u2.updatePaintArray(e3.start, e3.end, l3, t2[o2], i3, s2), a2 = true;
- }
- }
- }
- }
- return a2;
- }
- defines() {
- const t2 = [];
- for (const e2 in this.binders) {
- const r2 = this.binders[e2];
- (r2 instanceof Ca || r2 instanceof Da) && t2.push(...r2.uniformNames.map((t3) => `#define HAS_UNIFORM_${t3}`));
- }
- return t2;
- }
- getBinderAttributes() {
- const t2 = [];
- for (const e2 in this.binders) {
- const r2 = this.binders[e2];
- if (r2 instanceof Pa || r2 instanceof Va || r2 instanceof Fa)
- for (let e3 = 0; e3 < r2.paintVertexAttributes.length; e3++)
- t2.push(r2.paintVertexAttributes[e3].name);
- }
- return t2;
- }
- getBinderUniforms() {
- const t2 = [];
- for (const e2 in this.binders) {
- const r2 = this.binders[e2];
- if (r2 instanceof Ca || r2 instanceof Da || r2 instanceof Va)
- for (const e3 of r2.uniformNames)
- t2.push(e3);
- }
- return t2;
- }
- getPaintVertexBuffers() {
- return this._buffers;
- }
- getUniforms(t2, e2) {
- const r2 = [];
- for (const n2 in this.binders) {
- const i3 = this.binders[n2];
- if (i3 instanceof Ca || i3 instanceof Da || i3 instanceof Va) {
- for (const s2 of i3.uniformNames)
- if (e2[s2]) {
- const a2 = i3.getBinding(t2, e2[s2], s2);
- r2.push({ name: s2, property: n2, binding: a2 });
- }
- }
- }
- return r2;
- }
- setUniforms(t2, e2, r2, n2) {
- for (const { name: t3, property: i3, binding: s2 } of e2)
- this.binders[i3].setUniform(s2, n2, r2.get(i3), t3);
- }
- updatePaintBuffers(t2) {
- this._buffers = [];
- for (const e2 in this.binders) {
- const r2 = this.binders[e2];
- if (t2 && r2 instanceof Fa) {
- const e3 = 2 === t2.fromScale ? r2.zoomInPaintVertexBuffer : r2.zoomOutPaintVertexBuffer;
- e3 && this._buffers.push(e3);
- } else
- (r2 instanceof Pa || r2 instanceof Va) && r2.paintVertexBuffer && this._buffers.push(r2.paintVertexBuffer);
- }
- }
- upload(t2) {
- for (const e2 in this.binders) {
- const r2 = this.binders[e2];
- (r2 instanceof Pa || r2 instanceof Va || r2 instanceof Fa) && r2.upload(t2);
- }
- this.updatePaintBuffers();
- }
- destroy() {
- for (const t2 in this.binders) {
- const e2 = this.binders[t2];
- (e2 instanceof Pa || e2 instanceof Va || e2 instanceof Fa) && e2.destroy();
- }
- }
- }
- class Ra {
- constructor(t2, e2, r2 = () => true) {
- this.programConfigurations = {};
- for (const n2 of t2)
- this.programConfigurations[n2.id] = new La(n2, e2, r2);
- this.needsUpload = false, this._featureMap = new ba(), this._bufferOffset = 0;
- }
- populatePaintArrays(t2, e2, r2, n2, i3, s2, a2) {
- for (const r3 in this.programConfigurations)
- this.programConfigurations[r3].populatePaintArrays(t2, e2, n2, i3, s2, a2);
- void 0 !== e2.id && this._featureMap.add(e2.id, r2, this._bufferOffset, t2), this._bufferOffset = t2, this.needsUpload = true;
- }
- updatePaintArrays(t2, e2, r2, n2, i3) {
- for (const s2 of r2)
- this.needsUpload = this.programConfigurations[s2.id].updatePaintArrays(t2, this._featureMap, e2, s2, n2, i3) || this.needsUpload;
- }
- get(t2) {
- return this.programConfigurations[t2];
- }
- upload(t2) {
- if (this.needsUpload) {
- for (const e2 in this.programConfigurations)
- this.programConfigurations[e2].upload(t2);
- this.needsUpload = false;
- }
- }
- destroy() {
- for (const t2 in this.programConfigurations)
- this.programConfigurations[t2].destroy();
- }
- }
- 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"] };
- function $a(t2, e2) {
- return Ua[t2] || [t2.replace(`${e2}-`, "").replace(/-/g, "_")];
- }
- 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 } };
- function qa(t2, e2, r2) {
- const n2 = ja[t2];
- return n2 && n2[r2] || Oa[e2][r2];
- }
- ai(Ca, "ConstantBinder"), ai(Da, "CrossFadedConstantBinder"), ai(Pa, "SourceExpressionBinder"), ai(Fa, "CrossFadedCompositeBinder"), ai(Va, "CompositeExpressionBinder"), ai(La, "ProgramConfiguration", { omit: ["_buffers"] }), ai(Ra, "ProgramConfigurationSet");
- const Na = "-transition";
- class Ga extends Ut {
- constructor(t2, e2) {
- 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)) {
- this._transitionablePaint = new ls(e2.paint);
- for (const e3 in t2.paint)
- this.setPaintProperty(e3, t2.paint[e3], { validate: false });
- for (const e3 in t2.layout)
- this.setLayoutProperty(e3, t2.layout[e3], { validate: false });
- this._transitioningPaint = this._transitionablePaint.untransitioned(), this.paint = new fs(e2.paint);
- }
- }
- getCrossfadeParameters() {
- return this._crossfadeParameters;
- }
- getLayoutProperty(t2) {
- return "visibility" === t2 ? this.visibility : this._unevaluatedLayout.getValue(t2);
- }
- setLayoutProperty(t2, e2, r2 = {}) {
- null != e2 && this._validate(ti, `layers.${this.id}.layout.${t2}`, t2, e2, r2) || ("visibility" !== t2 ? this._unevaluatedLayout.setValue(t2, e2) : this.visibility = e2);
- }
- getPaintProperty(t2) {
- return M(t2, Na) ? this._transitionablePaint.getTransition(t2.slice(0, -Na.length)) : this._transitionablePaint.getValue(t2);
- }
- setPaintProperty(t2, e2, r2 = {}) {
- if (null != e2 && this._validate(Qn, `layers.${this.id}.paint.${t2}`, t2, e2, r2))
- return false;
- if (M(t2, Na))
- return this._transitionablePaint.setTransition(t2.slice(0, -Na.length), e2 || void 0), false;
- {
- const r3 = this._transitionablePaint._values[t2], n2 = "cross-faded-data-driven" === r3.property.specification["property-type"], i3 = r3.value.isDataDriven(), s2 = r3.value;
- this._transitionablePaint.setValue(t2, e2), this._handleSpecialPaintPropertyUpdate(t2);
- const a2 = this._transitionablePaint._values[t2].value;
- return a2.isDataDriven() || i3 || n2 || this._handleOverridablePaintPropertyUpdate(t2, s2, a2);
- }
- }
- _handleSpecialPaintPropertyUpdate(t2) {
- }
- getProgramIds() {
- return null;
- }
- getProgramConfiguration(t2) {
- return null;
- }
- _handleOverridablePaintPropertyUpdate(t2, e2, r2) {
- return false;
- }
- isHidden(t2) {
- return !!(this.minzoom && t2 < this.minzoom) || !!(this.maxzoom && t2 >= this.maxzoom) || "none" === this.visibility;
- }
- updateTransitions(t2) {
- this._transitioningPaint = this._transitionablePaint.transitioned(t2, this._transitioningPaint);
- }
- hasTransition() {
- return this._transitioningPaint.hasTransition();
- }
- recalculate(t2, e2) {
- 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);
- }
- serialize() {
- 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() };
- 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));
- }
- _validate(t2, e2, r2, n2, i3 = {}) {
- 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 } }));
- }
- is3D() {
- return false;
- }
- isSky() {
- return false;
- }
- isTileClipped() {
- return false;
- }
- hasOffscreenPass() {
- return false;
- }
- resize() {
- }
- isStateDependent() {
- for (const t2 in this.paint._values) {
- const e2 = this.paint.get(t2);
- if (e2 instanceof ps && Yr(e2.property.specification) && ("source" === e2.value.kind || "composite" === e2.value.kind) && e2.value.isStateDependent)
- return true;
- }
- return false;
- }
- compileFilter() {
- this._filterCompiled || (this._featureFilter = Sn(this.filter), this._filterCompiled = true);
- }
- invalidateCompiledFilter() {
- this._filterCompiled = false;
- }
- dynamicFilter() {
- return this._featureFilter.dynamicFilter;
- }
- dynamicFilterNeedsFeature() {
- return this._featureFilter.needFeature;
- }
- }
- 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" }]);
- class Ka {
- constructor(t2 = []) {
- this.segments = t2;
- }
- prepareSegment(t2, e2, r2, n2) {
- let i3 = this.segments[this.segments.length - 1];
- 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;
- }
- get() {
- return this.segments;
- }
- destroy() {
- for (const t2 of this.segments)
- for (const e2 in t2.vaos)
- t2.vaos[e2].destroy();
- }
- static simpleSegment(t2, e2, r2, n2) {
- return new Ka([{ vertexOffset: t2, primitiveOffset: e2, vertexLength: r2, primitiveLength: n2, vaos: {}, sortKey: 0 }]);
- }
- }
- Ka.MAX_VERTEX_ARRAY_LENGTH = Math.pow(2, 16) - 1, ai(Ka, "SegmentVector");
- var Ya = 8192;
- class Ha {
- constructor(t2, e2) {
- 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]));
- }
- setNorthEast(t2) {
- return this._ne = t2 instanceof Ja ? new Ja(t2.lng, t2.lat) : Ja.convert(t2), this;
- }
- setSouthWest(t2) {
- return this._sw = t2 instanceof Ja ? new Ja(t2.lng, t2.lat) : Ja.convert(t2), this;
- }
- extend(t2) {
- const e2 = this._sw, r2 = this._ne;
- let n2, i3;
- if (t2 instanceof Ja)
- n2 = t2, i3 = t2;
- else {
- if (!(t2 instanceof Ha))
- return Array.isArray(t2) ? 4 === t2.length || t2.every(Array.isArray) ? this.extend(Ha.convert(t2)) : this.extend(Ja.convert(t2)) : this;
- if (n2 = t2._sw, i3 = t2._ne, !n2 || !i3)
- return this;
- }
- 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;
- }
- getCenter() {
- return new Ja((this._sw.lng + this._ne.lng) / 2, (this._sw.lat + this._ne.lat) / 2);
- }
- getSouthWest() {
- return this._sw;
- }
- getNorthEast() {
- return this._ne;
- }
- getNorthWest() {
- return new Ja(this.getWest(), this.getNorth());
- }
- getSouthEast() {
- return new Ja(this.getEast(), this.getSouth());
- }
- getWest() {
- return this._sw.lng;
- }
- getSouth() {
- return this._sw.lat;
- }
- getEast() {
- return this._ne.lng;
- }
- getNorth() {
- return this._ne.lat;
- }
- toArray() {
- return [this._sw.toArray(), this._ne.toArray()];
- }
- toString() {
- return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`;
- }
- isEmpty() {
- return !(this._sw && this._ne);
- }
- contains(t2) {
- const { lng: e2, lat: r2 } = Ja.convert(t2);
- let n2 = this._sw.lng <= e2 && e2 <= this._ne.lng;
- 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;
- }
- static convert(t2) {
- return !t2 || t2 instanceof Ha ? t2 : new Ha(t2);
- }
- }
- const Wa = 63710088e-1;
- class Ja {
- constructor(t2, e2) {
- if (isNaN(t2) || isNaN(e2))
- throw new Error(`Invalid LngLat object: (${t2}, ${e2})`);
- if (this.lng = +t2, this.lat = +e2, this.lat > 90 || this.lat < -90)
- throw new Error("Invalid LngLat latitude value: must be between -90 and 90");
- }
- wrap() {
- return new Ja(g(this.lng, -180, 180), this.lat);
- }
- toArray() {
- return [this.lng, this.lat];
- }
- toString() {
- return `LngLat(${this.lng}, ${this.lat})`;
- }
- distanceTo(t2) {
- 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);
- return Wa * Math.acos(Math.min(i3, 1));
- }
- toBounds(t2 = 0) {
- const e2 = 360 * t2 / 40075017, r2 = e2 / Math.cos(Math.PI / 180 * this.lat);
- return new Ha(new Ja(this.lng - r2, this.lat - e2), new Ja(this.lng + r2, this.lat + e2));
- }
- static convert(t2) {
- if (t2 instanceof Ja)
- return t2;
- if (Array.isArray(t2) && (2 === t2.length || 3 === t2.length))
- return new Ja(Number(t2[0]), Number(t2[1]));
- if (!Array.isArray(t2) && "object" == typeof t2 && null !== t2)
- return new Ja(Number("lng" in t2 ? t2.lng : t2.lon), Number(t2.lat));
- 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>]");
- }
- }
- const Qa = 2 * Math.PI * Wa;
- function to(t2) {
- return Qa * Math.cos(t2 * Math.PI / 180);
- }
- function eo(t2) {
- return (180 + t2) / 360;
- }
- function ro(t2) {
- return (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + t2 * Math.PI / 360))) / 360;
- }
- function no(t2, e2) {
- return t2 / to(e2);
- }
- function io(t2) {
- return 360 * t2 - 180;
- }
- function so(t2) {
- return 360 / Math.PI * Math.atan(Math.exp((180 - 360 * t2) * Math.PI / 180)) - 90;
- }
- function ao(t2, e2) {
- return t2 * to(so(e2));
- }
- const oo = 85.051129;
- class lo {
- constructor(t2, e2, r2 = 0) {
- this.x = +t2, this.y = +e2, this.z = +r2;
- }
- static fromLngLat(t2, e2 = 0) {
- const r2 = Ja.convert(t2);
- return new lo(eo(r2.lng), ro(r2.lat), no(e2, r2.lat));
- }
- toLngLat() {
- return new Ja(io(this.x), so(this.y));
- }
- toAltitude() {
- return ao(this.z, this.y);
- }
- meterInMercatorCoordinateUnits() {
- return 1 / Qa * (t2 = so(this.y), 1 / Math.cos(t2 * Math.PI / 180));
- var t2;
- }
- }
- function uo(t2, e2, r2, n2, s2, a2, o2, l2, u2) {
- const c2 = (e2 + n2) / 2, h2 = (r2 + s2) / 2, p2 = new i2(c2, h2);
- l2(p2), function(t3, e3, r3, n3, i3, s3) {
- const a3 = r3 - i3, o3 = n3 - s3;
- return Math.abs((n3 - e3) * a3 - (r3 - t3) * o3) / Math.hypot(a3, o3);
- }(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);
- }
- function co(t2, e2, r2) {
- let n2 = t2[0], i3 = n2.x, s2 = n2.y;
- e2(n2);
- const a2 = [n2];
- for (let o2 = 1; o2 < t2.length; o2++) {
- const l2 = t2[o2], { x: u2, y: c2 } = l2;
- e2(l2), uo(a2, i3, s2, u2, c2, n2, l2, e2, r2), i3 = u2, s2 = c2, n2 = l2;
- }
- return a2;
- }
- const ho = Math.pow(2, 14) - 1, po = -ho - 1;
- function fo(t2, e2) {
- const r2 = Math.round(t2.x * e2), n2 = Math.round(t2.y * e2);
- 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;
- }
- function yo(t2, e2, r2) {
- const n2 = t2.loadGeometry(), i3 = t2.extent, s2 = Ya / i3;
- if (e2 && r2 && r2.projection.isReprojectedInTileSpace) {
- const s3 = 1 << e2.z, { scale: a2, x: o2, y: l2, projection: u2 } = r2, c2 = (t3) => {
- const r3 = io((e2.x + t3.x / i3) / s3), n3 = so((e2.y + t3.y / i3) / s3), c3 = u2.project(r3, n3);
- t3.x = (c3.x * a2 - o2) * i3, t3.y = (c3.y * a2 - l2) * i3;
- };
- for (let e3 = 0; e3 < n2.length; e3++)
- if (1 !== t2.type)
- n2[e3] = co(n2[e3], c2, 1);
- else {
- const t3 = [];
- for (const r3 of n2[e3])
- r3.x < 0 || r3.x >= i3 || r3.y < 0 || r3.y >= i3 || (c2(r3), t3.push(r3));
- n2[e3] = t3;
- }
- }
- for (const t3 of n2)
- for (const e3 of t3)
- fo(e3, s2);
- return n2;
- }
- function mo(t2, e2) {
- return { type: t2.type, id: t2.id, properties: t2.properties, geometry: e2 ? yo(t2) : [] };
- }
- function go(t2, e2, r2, n2, i3) {
- t2.emplaceBack(2 * e2 + (n2 + 1) / 2, 2 * r2 + (i3 + 1) / 2);
- }
- function xo(t2, e2, r2, n2) {
- const i3 = 16384;
- t2.emplaceBack(e2.x, e2.y, e2.z, r2[0] * i3, r2[1] * i3, r2[2] * i3, n2);
- }
- class vo {
- constructor(t2) {
- 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);
- }
- populate(t2, e2, r2, n2) {
- const i3 = this.layers[0], s2 = [];
- let a2 = null;
- "circle" === i3.type && (a2 = i3.layout.get("circle-sort-key"));
- for (const { feature: e3, id: i4, index: o3, sourceLayerIndex: l2 } of t2) {
- const t3 = this.layers[0]._featureFilter.needGeometry, u2 = mo(e3, t3);
- if (!this.layers[0]._featureFilter.filter(new ss(this.zoom), u2, r2))
- continue;
- 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 };
- s2.push(h2);
- }
- a2 && s2.sort((t3, e3) => t3.sortKey - e3.sortKey);
- let o2 = null;
- "globe" === n2.projection.name && (this.globeExtVertexArray = new fa(), o2 = n2.projection);
- for (const n3 of s2) {
- const { geometry: i4, index: s3, sourceLayerIndex: a3 } = n3, l2 = t2[s3].feature;
- this.addFeature(n3, i4, s3, e2.availableImages, r2, o2), e2.featureIndex.insert(l2, i4, s3, a3, this.index);
- }
- }
- update(t2, e2, r2, n2) {
- this.stateDependentLayers.length && this.programConfigurations.updatePaintArrays(t2, e2, this.stateDependentLayers, r2, n2);
- }
- isEmpty() {
- return 0 === this.layoutVertexArray.length;
- }
- uploadPending() {
- return !this.uploaded || this.programConfigurations.needsUpload;
- }
- upload(t2) {
- 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;
- }
- destroy() {
- this.layoutVertexBuffer && (this.layoutVertexBuffer.destroy(), this.indexBuffer.destroy(), this.programConfigurations.destroy(), this.segments.destroy(), this.globeExtVertexBuffer && this.globeExtVertexBuffer.destroy());
- }
- addFeature(t2, e2, r2, n2, i3, s2) {
- for (const r3 of e2)
- for (const e3 of r3) {
- const r4 = e3.x, n3 = e3.y;
- if (r4 < 0 || r4 >= Ya || n3 < 0 || n3 >= Ya)
- continue;
- if (s2) {
- 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;
- xo(l2, t3, e4, o3), xo(l2, t3, e4, o3), xo(l2, t3, e4, o3), xo(l2, t3, e4, o3);
- }
- const a2 = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray, t2.sortKey), o2 = a2.vertexLength;
- 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;
- }
- this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, t2, r2, {}, n2, i3);
- }
- }
- function bo(t2, e2) {
- for (let r2 = 0; r2 < t2.length; r2++)
- if (zo(e2, t2[r2]))
- return true;
- for (let r2 = 0; r2 < e2.length; r2++)
- if (zo(t2, e2[r2]))
- return true;
- return !!ko(t2, e2);
- }
- function _o(t2, e2, r2) {
- return !!zo(t2, e2) || !!Io(e2, t2, r2);
- }
- function wo(t2, e2) {
- if (1 === t2.length)
- return To(e2, t2[0]);
- for (let r2 = 0; r2 < e2.length; r2++) {
- const n2 = e2[r2];
- for (let e3 = 0; e3 < n2.length; e3++)
- if (zo(t2, n2[e3]))
- return true;
- }
- for (let r2 = 0; r2 < t2.length; r2++)
- if (To(e2, t2[r2]))
- return true;
- for (let r2 = 0; r2 < e2.length; r2++)
- if (ko(t2, e2[r2]))
- return true;
- return false;
- }
- function Ao(t2, e2, r2) {
- if (t2.length > 1) {
- if (ko(t2, e2))
- return true;
- for (let n2 = 0; n2 < e2.length; n2++)
- if (Io(e2[n2], t2, r2))
- return true;
- }
- for (let n2 = 0; n2 < t2.length; n2++)
- if (Io(t2[n2], e2, r2))
- return true;
- return false;
- }
- function ko(t2, e2) {
- if (0 === t2.length || 0 === e2.length)
- return false;
- for (let r2 = 0; r2 < t2.length - 1; r2++) {
- const n2 = t2[r2], i3 = t2[r2 + 1];
- for (let t3 = 0; t3 < e2.length - 1; t3++)
- if (So(n2, i3, e2[t3], e2[t3 + 1]))
- return true;
- }
- return false;
- }
- function So(t2, e2, r2, n2) {
- return D(t2, r2, n2) !== D(e2, r2, n2) && D(t2, e2, r2) !== D(t2, e2, n2);
- }
- function Io(t2, e2, r2) {
- const n2 = r2 * r2;
- if (1 === e2.length)
- return t2.distSqr(e2[0]) < n2;
- for (let r3 = 1; r3 < e2.length; r3++)
- if (Mo(t2, e2[r3 - 1], e2[r3]) < n2)
- return true;
- return false;
- }
- function Mo(t2, e2, r2) {
- const n2 = e2.distSqr(r2);
- if (0 === n2)
- return t2.distSqr(e2);
- const i3 = ((t2.x - e2.x) * (r2.x - e2.x) + (t2.y - e2.y) * (r2.y - e2.y)) / n2;
- return t2.distSqr(i3 < 0 ? e2 : i3 > 1 ? r2 : r2.sub(e2)._mult(i3)._add(e2));
- }
- function To(t2, e2) {
- let r2, n2, i3, s2 = false;
- for (let a2 = 0; a2 < t2.length; a2++) {
- r2 = t2[a2];
- for (let t3 = 0, a3 = r2.length - 1; t3 < r2.length; a3 = t3++)
- 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);
- }
- return s2;
- }
- function zo(t2, e2) {
- let r2 = false;
- for (let n2 = 0, i3 = t2.length - 1; n2 < t2.length; i3 = n2++) {
- const s2 = t2[n2], a2 = t2[i3];
- 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);
- }
- return r2;
- }
- function Bo(t2, e2, r2, n2, s2) {
- for (const i3 of t2)
- if (e2 <= i3.x && r2 <= i3.y && n2 >= i3.x && s2 >= i3.y)
- return true;
- const a2 = [new i2(e2, r2), new i2(e2, s2), new i2(n2, s2), new i2(n2, r2)];
- if (t2.length > 2) {
- for (const e3 of a2)
- if (zo(t2, e3))
- return true;
- }
- for (let e3 = 0; e3 < t2.length - 1; e3++)
- if (Eo(t2[e3], t2[e3 + 1], a2))
- return true;
- return false;
- }
- function Eo(t2, e2, r2) {
- const n2 = r2[0], i3 = r2[2];
- 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)
- return false;
- const s2 = D(t2, e2, r2[0]);
- return s2 !== D(t2, e2, r2[1]) || s2 !== D(t2, e2, r2[2]) || s2 !== D(t2, e2, r2[3]);
- }
- function Co(t2, e2, r2) {
- const n2 = e2.paint.get(t2).value;
- return "constant" === n2.kind ? n2.value : r2.programConfigurations.get(e2.id).getMaxValue(t2);
- }
- function Do(t2) {
- return Math.sqrt(t2[0] * t2[0] + t2[1] * t2[1]);
- }
- function Po(t2, e2, r2, n2, s2) {
- if (!e2[0] && !e2[1])
- return t2;
- const a2 = i2.convert(e2)._mult(s2);
- "viewport" === r2 && a2._rotate(-n2);
- const o2 = [];
- for (let e3 = 0; e3 < t2.length; e3++)
- o2.push(t2[e3].sub(a2));
- return o2;
- }
- function Vo(t2, e2, r2, n2) {
- const s2 = i2.convert(t2)._mult(n2);
- return "viewport" === e2 && s2._rotate(-r2), s2;
- }
- ai(vo, "CircleBucket", { omit: ["layers"] });
- const Fo = new vs({ "circle-sort-key": new ys($t.layout_circle["circle-sort-key"]) });
- 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;
- function $o() {
- var t2 = new Uo(9);
- 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;
- }
- function jo(t2) {
- 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;
- }
- function Oo(t2, e2, r2) {
- 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];
- 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;
- }
- function qo(t2, e2, r2) {
- var n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2 = r2[0], m2 = r2[1], g2 = r2[2];
- 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;
- }
- function No(t2, e2, r2) {
- var n2 = r2[0], i3 = r2[1], s2 = r2[2];
- 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;
- }
- function Go(t2, e2, r2) {
- 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];
- 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;
- }
- function Zo(t2, e2, r2) {
- 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];
- 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;
- }
- Math.hypot || (Math.hypot = function() {
- for (var t2 = 0, e2 = arguments.length; e2--; )
- t2 += arguments[e2] * arguments[e2];
- return Math.sqrt(t2);
- });
- var Xo = Oo;
- function Ko() {
- var t2 = new Uo(3);
- return Uo != Float32Array && (t2[0] = 0, t2[1] = 0, t2[2] = 0), t2;
- }
- function Yo(t2) {
- var e2 = new Uo(3);
- return e2[0] = t2[0], e2[1] = t2[1], e2[2] = t2[2], e2;
- }
- function Ho(t2) {
- return Math.hypot(t2[0], t2[1], t2[2]);
- }
- function Wo(t2, e2, r2) {
- var n2 = new Uo(3);
- return n2[0] = t2, n2[1] = e2, n2[2] = r2, n2;
- }
- function Jo(t2, e2, r2) {
- return t2[0] = e2[0] + r2[0], t2[1] = e2[1] + r2[1], t2[2] = e2[2] + r2[2], t2;
- }
- function Qo(t2, e2, r2) {
- return t2[0] = e2[0] - r2[0], t2[1] = e2[1] - r2[1], t2[2] = e2[2] - r2[2], t2;
- }
- function tl(t2, e2, r2) {
- return t2[0] = e2[0] * r2[0], t2[1] = e2[1] * r2[1], t2[2] = e2[2] * r2[2], t2;
- }
- function el(t2, e2, r2) {
- 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;
- }
- function rl(t2, e2, r2) {
- 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;
- }
- function nl(t2, e2, r2) {
- return t2[0] = e2[0] * r2, t2[1] = e2[1] * r2, t2[2] = e2[2] * r2, t2;
- }
- function il(t2, e2, r2, n2) {
- return t2[0] = e2[0] + r2[0] * n2, t2[1] = e2[1] + r2[1] * n2, t2[2] = e2[2] + r2[2] * n2, t2;
- }
- function sl(t2, e2) {
- var r2 = e2[0], n2 = e2[1], i3 = e2[2], s2 = r2 * r2 + n2 * n2 + i3 * i3;
- return s2 > 0 && (s2 = 1 / Math.sqrt(s2)), t2[0] = e2[0] * s2, t2[1] = e2[1] * s2, t2[2] = e2[2] * s2, t2;
- }
- function al(t2, e2) {
- return t2[0] * e2[0] + t2[1] * e2[1] + t2[2] * e2[2];
- }
- function ol(t2, e2, r2) {
- var n2 = e2[0], i3 = e2[1], s2 = e2[2], a2 = r2[0], o2 = r2[1], l2 = r2[2];
- return t2[0] = i3 * l2 - s2 * o2, t2[1] = s2 * a2 - n2 * l2, t2[2] = n2 * o2 - i3 * a2, t2;
- }
- function ll(t2, e2, r2) {
- var n2 = e2[0], i3 = e2[1], s2 = e2[2], a2 = r2[3] * n2 + r2[7] * i3 + r2[11] * s2 + r2[15];
- 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;
- }
- function ul(t2, e2, r2) {
- 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];
- 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;
- }
- var cl, hl = Qo, pl = tl, fl = Ho;
- function dl(t2, e2, r2) {
- var n2 = e2[0], i3 = e2[1], s2 = e2[2], a2 = e2[3];
- 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;
- }
- function yl() {
- var t2 = new Uo(4);
- return Uo != Float32Array && (t2[0] = 0, t2[1] = 0, t2[2] = 0), t2[3] = 1, t2;
- }
- function ml(t2) {
- return t2[0] = 0, t2[1] = 0, t2[2] = 0, t2[3] = 1, t2;
- }
- function gl(t2, e2, r2) {
- r2 *= 0.5;
- var n2 = e2[0], i3 = e2[1], s2 = e2[2], a2 = e2[3], o2 = Math.sin(r2), l2 = Math.cos(r2);
- 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;
- }
- 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();
- class xl {
- constructor(t2, e2) {
- this.points = t2, this.planes = e2;
- }
- static fromInvProjectionMatrix(t2, e2, r2, n2) {
- 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) => {
- const s3 = dl([], r3, t2), a3 = 1 / s3[3] / e2 * i3;
- return function(t3, e3, r4) {
- 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;
- }(s3, s3, [a3, a3, n2 ? 1 / s3[3] : a3, a3]);
- }), a2 = [[0, 1, 2], [6, 5, 4], [0, 3, 7], [2, 1, 5], [3, 2, 6], [0, 4, 5]].map((t3) => {
- const e3 = sl([], ol([], hl([], s2[t3[0]], s2[t3[1]]), hl([], s2[t3[2]], s2[t3[1]]))), r3 = -al(e3, s2[t3[1]]);
- return e3.concat(r3);
- });
- return new xl(s2, a2);
- }
- }
- class vl {
- constructor(t2, e2) {
- this.min = t2, this.max = e2, this.center = nl([], Jo([], this.min, this.max), 0.5);
- }
- quadrant(t2) {
- const e2 = [t2 % 2 == 0, t2 < 2], r2 = Yo(this.min), n2 = Yo(this.max);
- for (let t3 = 0; t3 < e2.length; t3++)
- r2[t3] = e2[t3] ? this.min[t3] : this.center[t3], n2[t3] = e2[t3] ? this.center[t3] : this.max[t3];
- return n2[2] = this.max[2], new vl(r2, n2);
- }
- distanceX(t2) {
- return Math.max(Math.min(this.max[0], t2[0]), this.min[0]) - t2[0];
- }
- distanceY(t2) {
- return Math.max(Math.min(this.max[1], t2[1]), this.min[1]) - t2[1];
- }
- distanceZ(t2) {
- return Math.max(Math.min(this.max[2], t2[2]), this.min[2]) - t2[2];
- }
- getCorners() {
- const t2 = this.min, e2 = this.max;
- 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]]];
- }
- intersects(t2) {
- const e2 = this.getCorners();
- let r2 = true;
- for (let n2 = 0; n2 < t2.planes.length; n2++) {
- const i3 = t2.planes[n2];
- let s2 = 0;
- for (let t3 = 0; t3 < e2.length; t3++)
- s2 += al(i3, e2[t3]) + i3[3] >= 0;
- if (0 === s2)
- return 0;
- s2 !== e2.length && (r2 = false);
- }
- if (r2)
- return 2;
- for (let e3 = 0; e3 < 3; e3++) {
- let r3 = Number.MAX_VALUE, n2 = -Number.MAX_VALUE;
- for (let i3 = 0; i3 < t2.points.length; i3++) {
- const s2 = t2.points[i3][e3] - this.min[e3];
- r3 = Math.min(r3, s2), n2 = Math.max(n2, s2);
- }
- if (n2 < 0 || r3 > this.max[e3] - this.min[e3])
- return 0;
- }
- return 1;
- }
- }
- function bl(t2, e2, r2, n2, i3, s2, a2, o2, l2) {
- if (s2 && t2.queryGeometry.isAboveHorizon)
- return false;
- s2 && (l2 *= t2.pixelToTileUnitsFactor);
- for (const u2 of e2)
- for (const e3 of u2) {
- 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);
- if (!a2 && s2 ? l2 *= f2[3] / r2.cameraToCenterDistance : a2 && !s2 && (l2 *= r2.cameraToCenterDistance / f2[3]), _o(p2, h2, l2))
- return true;
- }
- return false;
- }
- function _l(t2, e2, r2) {
- const n2 = dl([], [t2.x, t2.y, e2, 1], r2);
- return new i2(n2[0] / n2[3], n2[1] / n2[3]);
- }
- const wl = Wo(0, 0, 0), Al = Wo(0, 0, 1);
- function kl(t2, e2) {
- const r2 = Ko();
- return wl[2] = e2, t2.intersectsPlane(wl, Al, r2), new i2(r2[0], r2[1]);
- }
- class Sl extends vo {
- }
- function Il(t2, { width: e2, height: r2 }, n2, i3) {
- if (i3) {
- if (i3 instanceof Uint8ClampedArray)
- i3 = new Uint8Array(i3.buffer);
- else if (i3.length !== e2 * r2 * n2)
- throw new RangeError("mismatched image size");
- } else
- i3 = new Uint8Array(e2 * r2 * n2);
- return t2.width = e2, t2.height = r2, t2.data = i3, t2;
- }
- function Ml(t2, e2, r2) {
- const { width: n2, height: i3 } = e2;
- 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);
- }
- function Tl(t2, e2, r2, n2, i3, s2) {
- if (0 === i3.width || 0 === i3.height)
- return e2;
- if (i3.width > t2.width || i3.height > t2.height || r2.x > t2.width - i3.width || r2.y > t2.height - i3.height)
- throw new RangeError("out of range source coordinates for image copy");
- if (i3.width > e2.width || i3.height > e2.height || n2.x > e2.width - i3.width || n2.y > e2.height - i3.height)
- throw new RangeError("out of range destination coordinates for image copy");
- const a2 = t2.data, o2 = e2.data;
- for (let l2 = 0; l2 < i3.height; l2++) {
- const u2 = ((r2.y + l2) * t2.width + r2.x) * s2, c2 = ((n2.y + l2) * e2.width + n2.x) * s2;
- for (let t3 = 0; t3 < i3.width * s2; t3++)
- o2[c2 + t3] = a2[u2 + t3];
- }
- return e2;
- }
- ai(Sl, "HeatmapBucket", { omit: ["layers"] });
- class zl {
- constructor(t2, e2) {
- Il(this, t2, 1, e2);
- }
- resize(t2) {
- Ml(this, new zl(t2), 1);
- }
- clone() {
- return new zl({ width: this.width, height: this.height }, new Uint8Array(this.data));
- }
- static copy(t2, e2, r2, n2, i3) {
- Tl(t2, e2, r2, n2, i3, 1);
- }
- }
- class Bl {
- constructor(t2, e2) {
- Il(this, t2, 4, e2);
- }
- resize(t2) {
- Ml(this, new Bl(t2), 4);
- }
- replace(t2, e2) {
- e2 ? this.data.set(t2) : this.data = t2 instanceof Uint8ClampedArray ? new Uint8Array(t2.buffer) : t2;
- }
- clone() {
- return new Bl({ width: this.width, height: this.height }, new Uint8Array(this.data));
- }
- static copy(t2, e2, r2, n2, i3) {
- Tl(t2, e2, r2, n2, i3, 4);
- }
- }
- ai(zl, "AlphaImage"), ai(Bl, "RGBAImage");
- 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"]) }) };
- function Cl(t2) {
- 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) => {
- e2[t2.evaluationKey] = s3;
- const a2 = t2.expression.evaluate(e2);
- 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);
- };
- if (t2.clips)
- for (let e3 = 0, i4 = 0; e3 < n2; ++e3, i4 += 4 * r2)
- for (let n3 = 0, a2 = 0; n3 < r2; n3++, a2 += 4) {
- const o2 = n3 / (r2 - 1), { start: l2, end: u2 } = t2.clips[e3];
- s2(i4, a2, l2 * (1 - o2) + u2 * o2);
- }
- else
- for (let t3 = 0, e3 = 0; t3 < r2; t3++, e3 += 4)
- s2(0, e3, t3 / (r2 - 1));
- return i3;
- }
- 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"]) }) };
- const Pl = ks([{ name: "a_pos", components: 2, type: "Int16" }], 4), { members: Vl } = Pl;
- var Fl = Rl, Ll = Rl;
- function Rl(t2, e2, r2) {
- r2 = r2 || 2;
- 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 = [];
- if (!p2 || p2.next === p2.prev)
- return f2;
- if (c2 && (p2 = function(t3, e3, r3, n3) {
- var i4, s3, a3, o3 = [];
- for (i4 = 0, s3 = e3.length; i4 < s3; i4++)
- (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));
- for (o3.sort(Zl), i4 = 0; i4 < o3.length; i4++)
- r3 = $l(r3 = Xl(o3[i4], r3), r3.next);
- return r3;
- }(t2, e2, p2, r2)), t2.length > 80 * r2) {
- n2 = s2 = t2[0], i3 = a2 = t2[1];
- for (var d2 = r2; d2 < h2; d2 += r2)
- (o2 = t2[d2]) < n2 && (n2 = o2), (l2 = t2[d2 + 1]) < i3 && (i3 = l2), o2 > s2 && (s2 = o2), l2 > a2 && (a2 = l2);
- u2 = 0 !== (u2 = Math.max(s2 - n2, a2 - i3)) ? 1 / u2 : 0;
- }
- return jl(p2, f2, r2, n2, i3, u2), f2;
- }
- function Ul(t2, e2, r2, n2, i3) {
- var s2, a2;
- if (i3 === uu(t2, e2, r2, n2) > 0)
- for (s2 = e2; s2 < r2; s2 += n2)
- a2 = au(s2, t2[s2], t2[s2 + 1], a2);
- else
- for (s2 = r2 - n2; s2 >= e2; s2 -= n2)
- a2 = au(s2, t2[s2], t2[s2 + 1], a2);
- return a2 && tu(a2, a2.next) && (ou(a2), a2 = a2.next), a2;
- }
- function $l(t2, e2) {
- if (!t2)
- return t2;
- e2 || (e2 = t2);
- var r2, n2 = t2;
- do {
- if (r2 = false, n2.steiner || !tu(n2, n2.next) && 0 !== Ql(n2.prev, n2, n2.next))
- n2 = n2.next;
- else {
- if (ou(n2), (n2 = e2 = n2.prev) === n2.next)
- break;
- r2 = true;
- }
- } while (r2 || n2 !== e2);
- return e2;
- }
- function jl(t2, e2, r2, n2, i3, s2, a2) {
- if (t2) {
- !a2 && s2 && function(t3, e3, r3, n3) {
- var i4 = t3;
- do {
- null === i4.z && (i4.z = Yl(i4.x, i4.y, e3, r3, n3)), i4.prevZ = i4.prev, i4.nextZ = i4.next, i4 = i4.next;
- } while (i4 !== t3);
- i4.prevZ.nextZ = null, i4.prevZ = null, function(t4) {
- var e4, r4, n4, i5, s3, a3, o3, l3, u3 = 1;
- do {
- for (r4 = t4, t4 = null, s3 = null, a3 = 0; r4; ) {
- for (a3++, n4 = r4, o3 = 0, e4 = 0; e4 < u3 && (o3++, n4 = n4.nextZ); e4++)
- ;
- for (l3 = u3; o3 > 0 || l3 > 0 && n4; )
- 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;
- r4 = n4;
- }
- s3.nextZ = null, u3 *= 2;
- } while (a3 > 1);
- }(i4);
- }(t2, n2, i3, s2);
- for (var o2, l2, u2 = t2; t2.prev !== t2.next; )
- if (o2 = t2.prev, l2 = t2.next, s2 ? ql(t2, n2, i3, s2) : Ol(t2))
- e2.push(o2.i / r2), e2.push(t2.i / r2), e2.push(l2.i / r2), ou(t2), t2 = l2.next, u2 = l2.next;
- else if ((t2 = l2) === u2) {
- 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);
- break;
- }
- }
- }
- function Ol(t2) {
- var e2 = t2.prev, r2 = t2, n2 = t2.next;
- if (Ql(e2, r2, n2) >= 0)
- return false;
- for (var i3 = t2.next.next; i3 !== t2.prev; ) {
- 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)
- return false;
- i3 = i3.next;
- }
- return true;
- }
- function ql(t2, e2, r2, n2) {
- var i3 = t2.prev, s2 = t2, a2 = t2.next;
- if (Ql(i3, s2, a2) >= 0)
- return false;
- 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; ) {
- 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)
- return false;
- 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)
- return false;
- p2 = p2.nextZ;
- }
- for (; h2 && h2.z >= u2; ) {
- 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)
- return false;
- h2 = h2.prevZ;
- }
- for (; p2 && p2.z <= c2; ) {
- 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)
- return false;
- p2 = p2.nextZ;
- }
- return true;
- }
- function Nl(t2, e2, r2) {
- var n2 = t2;
- do {
- var i3 = n2.prev, s2 = n2.next.next;
- !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;
- } while (n2 !== t2);
- return $l(n2);
- }
- function Gl(t2, e2, r2, n2, i3, s2) {
- var a2 = t2;
- do {
- for (var o2 = a2.next.next; o2 !== a2.prev; ) {
- if (a2.i !== o2.i && Jl(a2, o2)) {
- var l2 = su(a2, o2);
- 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);
- }
- o2 = o2.next;
- }
- a2 = a2.next;
- } while (a2 !== t2);
- }
- function Zl(t2, e2) {
- return t2.x - e2.x;
- }
- function Xl(t2, e2) {
- var r2 = function(t3, e3) {
- var r3, n3 = e3, i4 = t3.x, s2 = t3.y, a2 = -1 / 0;
- do {
- if (s2 <= n3.y && s2 >= n3.next.y && n3.next.y !== n3.y) {
- var o2 = n3.x + (s2 - n3.y) * (n3.next.x - n3.x) / (n3.next.y - n3.y);
- if (o2 <= i4 && o2 > a2) {
- if (a2 = o2, o2 === i4) {
- if (s2 === n3.y)
- return n3;
- if (s2 === n3.next.y)
- return n3.next;
- }
- r3 = n3.x < n3.next.x ? n3 : n3.next;
- }
- }
- n3 = n3.next;
- } while (n3 !== e3);
- if (!r3)
- return null;
- if (i4 === a2)
- return r3;
- var l2, u2 = r3, c2 = r3.x, h2 = r3.y, p2 = 1 / 0;
- n3 = r3;
- do {
- 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;
- } while (n3 !== u2);
- return r3;
- }(t2, e2);
- if (!r2)
- return e2;
- var n2 = su(r2, t2), i3 = $l(r2, r2.next);
- return $l(n2, n2.next), e2 === r2 ? i3 : e2;
- }
- function Kl(t2, e2) {
- return Ql(t2.prev, t2, e2.prev) < 0 && Ql(e2.next, t2, t2.next) < 0;
- }
- function Yl(t2, e2, r2, n2, i3) {
- 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;
- }
- function Hl(t2) {
- var e2 = t2, r2 = t2;
- do {
- (e2.x < r2.x || e2.x === r2.x && e2.y < r2.y) && (r2 = e2), e2 = e2.next;
- } while (e2 !== t2);
- return r2;
- }
- function Wl(t2, e2, r2, n2, i3, s2, a2, o2) {
- 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;
- }
- function Jl(t2, e2) {
- return t2.next.i !== e2.i && t2.prev.i !== e2.i && !function(t3, e3) {
- var r2 = t3;
- do {
- 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))
- return true;
- r2 = r2.next;
- } while (r2 !== t3);
- return false;
- }(t2, e2) && (iu(t2, e2) && iu(e2, t2) && function(t3, e3) {
- var r2 = t3, n2 = false, i3 = (t3.x + e3.x) / 2, s2 = (t3.y + e3.y) / 2;
- do {
- 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;
- } while (r2 !== t3);
- return n2;
- }(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);
- }
- function Ql(t2, e2, r2) {
- return (e2.y - t2.y) * (r2.x - e2.x) - (e2.x - t2.x) * (r2.y - e2.y);
- }
- function tu(t2, e2) {
- return t2.x === e2.x && t2.y === e2.y;
- }
- function eu(t2, e2, r2, n2) {
- 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));
- 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));
- }
- function ru(t2, e2, r2) {
- 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);
- }
- function nu(t2) {
- return t2 > 0 ? 1 : t2 < 0 ? -1 : 0;
- }
- function iu(t2, e2) {
- 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;
- }
- function su(t2, e2) {
- 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;
- 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;
- }
- function au(t2, e2, r2, n2) {
- var i3 = new lu(t2, e2, r2);
- return n2 ? (i3.next = n2.next, i3.prev = n2, n2.next.prev = i3, n2.next = i3) : (i3.prev = i3, i3.next = i3), i3;
- }
- function ou(t2) {
- t2.next.prev = t2.prev, t2.prev.next = t2.next, t2.prevZ && (t2.prevZ.nextZ = t2.nextZ), t2.nextZ && (t2.nextZ.prevZ = t2.prevZ);
- }
- function lu(t2, e2, r2) {
- 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;
- }
- function uu(t2, e2, r2, n2) {
- for (var i3 = 0, s2 = e2, a2 = r2 - n2; s2 < r2; s2 += n2)
- i3 += (t2[a2] - t2[s2]) * (t2[s2 + 1] + t2[a2 + 1]), a2 = s2;
- return i3;
- }
- function cu(t2, e2, r2, n2, i3) {
- hu(t2, e2, r2 || 0, n2 || t2.length - 1, i3 || fu);
- }
- function hu(t2, e2, r2, n2, i3) {
- for (; n2 > r2; ) {
- if (n2 - r2 > 600) {
- 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);
- 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);
- }
- var c2 = t2[e2], h2 = r2, p2 = n2;
- for (pu(t2, r2, e2), i3(t2[n2], c2) > 0 && pu(t2, r2, n2); h2 < p2; ) {
- for (pu(t2, h2, p2), h2++, p2--; i3(t2[h2], c2) < 0; )
- h2++;
- for (; i3(t2[p2], c2) > 0; )
- p2--;
- }
- 0 === i3(t2[r2], c2) ? pu(t2, r2, p2) : pu(t2, ++p2, n2), p2 <= e2 && (r2 = p2 + 1), e2 <= p2 && (n2 = p2 - 1);
- }
- }
- function pu(t2, e2, r2) {
- var n2 = t2[e2];
- t2[e2] = t2[r2], t2[r2] = n2;
- }
- function fu(t2, e2) {
- return t2 < e2 ? -1 : t2 > e2 ? 1 : 0;
- }
- function du(t2, e2) {
- const r2 = t2.length;
- if (r2 <= 1)
- return [t2];
- const n2 = [];
- let i3, s2;
- for (let e3 = 0; e3 < r2; e3++) {
- const r3 = P(t2[e3]);
- 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]));
- }
- if (i3 && n2.push(i3), e2 > 1)
- for (let t3 = 0; t3 < n2.length; t3++)
- n2[t3].length <= e2 || (cu(n2[t3], e2, 1, n2[t3].length - 1, yu), n2[t3] = n2[t3].slice(0, e2));
- return n2;
- }
- function yu(t2, e2) {
- return e2.area - t2.area;
- }
- function mu(t2, e2, r2) {
- const n2 = r2.patternDependencies;
- let i3 = false;
- for (const r3 of e2) {
- const e3 = r3.paint.get(`${t2}-pattern`);
- e3.isConstant() || (i3 = true);
- const s2 = e3.constantOr(null);
- s2 && (i3 = true, n2[s2.to] = true, n2[s2.from] = true);
- }
- return i3;
- }
- function gu(t2, e2, r2, n2, i3) {
- const s2 = i3.patternDependencies;
- for (const a2 of e2) {
- const e3 = a2.paint.get(`${t2}-pattern`).value;
- if ("constant" !== e3.kind) {
- 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);
- 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 };
- }
- }
- return r2;
- }
- Rl.deviation = function(t2, e2, r2, n2) {
- var i3 = e2 && e2.length, s2 = Math.abs(uu(t2, 0, i3 ? e2[0] * r2 : t2.length, r2));
- if (i3)
- for (var a2 = 0, o2 = e2.length; a2 < o2; a2++)
- s2 -= Math.abs(uu(t2, e2[a2] * r2, a2 < o2 - 1 ? e2[a2 + 1] * r2 : t2.length, r2));
- var l2 = 0;
- for (a2 = 0; a2 < n2.length; a2 += 3) {
- var u2 = n2[a2] * r2, c2 = n2[a2 + 1] * r2, h2 = n2[a2 + 2] * r2;
- l2 += Math.abs((t2[u2] - t2[h2]) * (t2[c2 + 1] - t2[u2 + 1]) - (t2[u2] - t2[c2]) * (t2[h2 + 1] - t2[u2 + 1]));
- }
- return 0 === s2 && 0 === l2 ? 0 : Math.abs((l2 - s2) / s2);
- }, Rl.flatten = function(t2) {
- for (var e2 = t2[0][0].length, r2 = { vertices: [], holes: [], dimensions: e2 }, n2 = 0, i3 = 0; i3 < t2.length; i3++) {
- for (var s2 = 0; s2 < t2[i3].length; s2++)
- for (var a2 = 0; a2 < e2; a2++)
- r2.vertices.push(t2[i3][s2][a2]);
- i3 > 0 && r2.holes.push(n2 += t2[i3 - 1].length);
- }
- return r2;
- }, Fl.default = Ll;
- class xu {
- constructor(t2) {
- 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;
- }
- populate(t2, e2, r2, n2) {
- this.hasPattern = mu("fill", this.layers, e2);
- const i3 = this.layers[0].layout.get("fill-sort-key"), s2 = [];
- for (const { feature: a2, id: o2, index: l2, sourceLayerIndex: u2 } of t2) {
- const t3 = this.layers[0]._featureFilter.needGeometry, c2 = mo(a2, t3);
- if (!this.layers[0]._featureFilter.filter(new ss(this.zoom), c2, r2))
- continue;
- 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 };
- s2.push(p2);
- }
- i3 && s2.sort((t3, e3) => t3.sortKey - e3.sortKey);
- for (const n3 of s2) {
- const { geometry: i4, index: s3, sourceLayerIndex: a2 } = n3;
- if (this.hasPattern) {
- const t3 = gu("fill", this.layers, n3, this.zoom, e2);
- this.patternFeatures.push(t3);
- } else
- this.addFeature(n3, i4, s3, r2, {}, e2.availableImages);
- e2.featureIndex.insert(t2[s3].feature, i4, s3, a2, this.index);
- }
- }
- update(t2, e2, r2, n2) {
- this.stateDependentLayers.length && this.programConfigurations.updatePaintArrays(t2, e2, this.stateDependentLayers, r2, n2);
- }
- addFeatures(t2, e2, r2, n2, i3) {
- for (const t3 of this.patternFeatures)
- this.addFeature(t3, t3.geometry, t3.index, e2, r2, n2);
- }
- isEmpty() {
- return 0 === this.layoutVertexArray.length;
- }
- uploadPending() {
- return !this.uploaded || this.programConfigurations.needsUpload;
- }
- upload(t2) {
- 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;
- }
- destroy() {
- this.layoutVertexBuffer && (this.layoutVertexBuffer.destroy(), this.indexBuffer.destroy(), this.indexBuffer2.destroy(), this.programConfigurations.destroy(), this.segments.destroy(), this.segments2.destroy());
- }
- addFeature(t2, e2, r2, n2, i3, s2 = []) {
- for (const t3 of du(e2, 500)) {
- let e3 = 0;
- for (const r4 of t3)
- e3 += r4.length;
- const r3 = this.segments.prepareSegment(e3, this.layoutVertexArray, this.indexArray), n3 = r3.vertexLength, i4 = [], s3 = [];
- for (const e4 of t3) {
- if (0 === e4.length)
- continue;
- e4 !== t3[0] && s3.push(i4.length / 2);
- const r4 = this.segments2.prepareSegment(e4.length, this.layoutVertexArray, this.indexArray2), n4 = r4.vertexLength;
- 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);
- for (let t4 = 1; t4 < e4.length; t4++)
- 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);
- r4.vertexLength += e4.length, r4.primitiveLength += e4.length;
- }
- const a2 = Fl(i4, s3);
- for (let t4 = 0; t4 < a2.length; t4 += 3)
- this.indexArray.emplaceBack(n3 + a2[t4], n3 + a2[t4 + 1], n3 + a2[t4 + 2]);
- r3.vertexLength += e3, r3.primitiveLength += a2.length / 3;
- }
- this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, t2, r2, i3, s2, n2);
- }
- }
- ai(xu, "FillBucket", { omit: ["layers", "patternFeatures"] });
- const vu = new vs({ "fill-sort-key": new ys($t.layout_fill["fill-sort-key"]) });
- 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 };
- 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;
- var Su = Iu;
- function Iu(t2, e2, r2, n2, i3) {
- 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);
- }
- function Mu(t2, e2, r2) {
- 1 == t2 ? e2.id = r2.readVarint() : 2 == t2 ? function(t3, e3) {
- for (var r3 = t3.readVarint() + t3.pos; t3.pos < r3; ) {
- var n2 = e3._keys[t3.readVarint()], i3 = e3._values[t3.readVarint()];
- e3.properties[n2] = i3;
- }
- }(r2, e2) : 3 == t2 ? e2.type = r2.readVarint() : 4 == t2 && (e2._geometry = r2.pos);
- }
- function Tu(t2) {
- for (var e2, r2, n2 = 0, i3 = 0, s2 = t2.length, a2 = s2 - 1; i3 < s2; a2 = i3++)
- n2 += ((r2 = t2[a2]).x - (e2 = t2[i3]).x) * (e2.y + r2.y);
- return n2;
- }
- Iu.types = ["Unknown", "Point", "LineString", "Polygon"], Iu.prototype.loadGeometry = function() {
- var t2 = this._pbf;
- t2.pos = this._geometry;
- for (var e2, r2 = t2.readVarint() + t2.pos, n2 = 1, s2 = 0, a2 = 0, o2 = 0, l2 = []; t2.pos < r2; ) {
- if (s2 <= 0) {
- var u2 = t2.readVarint();
- n2 = 7 & u2, s2 = u2 >> 3;
- }
- if (s2--, 1 === n2 || 2 === n2)
- a2 += t2.readSVarint(), o2 += t2.readSVarint(), 1 === n2 && (e2 && l2.push(e2), e2 = []), e2.push(new i2(a2, o2));
- else {
- if (7 !== n2)
- throw new Error("unknown command " + n2);
- e2 && e2.push(e2[0].clone());
- }
- }
- return e2 && l2.push(e2), l2;
- }, Iu.prototype.bbox = function() {
- var t2 = this._pbf;
- t2.pos = this._geometry;
- 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; ) {
- if (n2 <= 0) {
- var c2 = t2.readVarint();
- r2 = 7 & c2, n2 = c2 >> 3;
- }
- if (n2--, 1 === r2 || 2 === r2)
- (i3 += t2.readSVarint()) < a2 && (a2 = i3), i3 > o2 && (o2 = i3), (s2 += t2.readSVarint()) < l2 && (l2 = s2), s2 > u2 && (u2 = s2);
- else if (7 !== r2)
- throw new Error("unknown command " + r2);
- }
- return [a2, l2, o2, u2];
- }, Iu.prototype.toGeoJSON = function(t2, e2, r2) {
- 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];
- function c2(t3) {
- for (var e3 = 0; e3 < t3.length; e3++) {
- var r3 = t3[e3];
- 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];
- }
- }
- switch (this.type) {
- case 1:
- var h2 = [];
- for (n2 = 0; n2 < l2.length; n2++)
- h2[n2] = l2[n2][0];
- c2(l2 = h2);
- break;
- case 2:
- for (n2 = 0; n2 < l2.length; n2++)
- c2(l2[n2]);
- break;
- case 3:
- for (l2 = function(t3) {
- var e3 = t3.length;
- if (e3 <= 1)
- return [t3];
- for (var r3, n3, i4 = [], s3 = 0; s3 < e3; s3++) {
- var a3 = Tu(t3[s3]);
- 0 !== a3 && (void 0 === n3 && (n3 = a3 < 0), n3 === a3 < 0 ? (r3 && i4.push(r3), r3 = [t3[s3]]) : r3.push(t3[s3]));
- }
- return r3 && i4.push(r3), i4;
- }(l2), n2 = 0; n2 < l2.length; n2++)
- for (i3 = 0; i3 < l2[n2].length; i3++)
- c2(l2[n2][i3]);
- }
- 1 === l2.length ? l2 = l2[0] : u2 = "Multi" + u2;
- var p2 = { type: "Feature", geometry: { type: u2, coordinates: l2 }, properties: this.properties };
- return "id" in this && (p2.id = this.id), p2;
- };
- var zu = Bu;
- function Bu(t2, e2) {
- 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;
- }
- function Eu(t2, e2, r2) {
- 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) {
- for (var e3 = null, r3 = t3.readVarint() + t3.pos; t3.pos < r3; ) {
- var n2 = t3.readVarint() >> 3;
- 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;
- }
- return e3;
- }(r2));
- }
- function Cu(t2, e2, r2) {
- if (3 === t2) {
- var n2 = new zu(r2, r2.readVarint() + r2.pos);
- n2.length && (e2[n2.name] = n2);
- }
- }
- Bu.prototype.feature = function(t2) {
- if (t2 < 0 || t2 >= this._features.length)
- throw new Error("feature index out of bounds");
- this._pbf.pos = this._features[t2];
- var e2 = this._pbf.readVarint() + this._pbf.pos;
- return new Su(this._pbf, e2, this.extent, this._keys, this._values);
- };
- var Du = { VectorTile: function(t2, e2) {
- this.layers = t2.readFields(Cu, {}, e2);
- }, VectorTileFeature: Su, VectorTileLayer: zu };
- function Pu(t2, e2, r2, n2) {
- const s2 = [], a2 = 0 === n2 ? (t3, e3, r3, n3, s3, a3) => {
- t3.push(new i2(a3, r3 + (a3 - e3) / (n3 - e3) * (s3 - r3)));
- } : (t3, e3, r3, n3, s3, a3) => {
- t3.push(new i2(e3 + (a3 - r3) / (s3 - r3) * (n3 - e3), a3));
- };
- for (const i3 of t2) {
- const t3 = [];
- for (const s3 of i3) {
- if (s3.length <= 2)
- continue;
- const i4 = [];
- for (let t4 = 0; t4 < s3.length - 1; t4++) {
- 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;
- 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);
- }
- let o2 = s3[s3.length - 1];
- const l2 = 0 === n2 ? o2.x : o2.y;
- 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));
- }
- t3.length && s2.push(t3);
- }
- return s2;
- }
- const Vu = Du.VectorTileFeature.types, Fu = Math.pow(2, 13);
- function Lu(t2, e2, r2, n2, i3, s2, a2, o2) {
- t2.emplaceBack((e2 << 1) + a2, (r2 << 1) + s2, (Math.floor(n2 * Fu) << 1) + i3, Math.round(o2));
- }
- function Ru(t2, e2, r2) {
- const n2 = 16384;
- t2.emplaceBack(e2.x, e2.y, e2.z, r2[0] * n2, r2[1] * n2, r2[2] * n2);
- }
- class Uu {
- constructor() {
- this.acc = new i2(0, 0), this.polyCount = [];
- }
- startRing(t2) {
- 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));
- }
- append(t2, e2) {
- this.currentPolyCount.edges++, this.acc._add(t2);
- const r2 = this.min, n2 = this.max;
- 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)));
- }
- addBorderIntersection(t2, e2) {
- 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]]);
- const r2 = this.borders[t2];
- e2 < r2[0] && (r2[0] = e2), e2 > r2[1] && (r2[1] = e2);
- }
- processBorderOverlap(t2, e2) {
- if (t2.x === e2.x) {
- if (t2.y === e2.y)
- return;
- const r2 = 0 === t2.x ? 0 : 1;
- this.addBorderIntersection(r2, e2.y), this.addBorderIntersection(r2, t2.y);
- } else {
- const r2 = 0 === t2.y ? 2 : 3;
- this.addBorderIntersection(r2, e2.x), this.addBorderIntersection(r2, t2.x);
- }
- }
- centroid() {
- const t2 = this.polyCount.reduce((t3, e2) => t3 + e2.edges, 0);
- return 0 !== t2 ? this.acc.div(t2)._round() : new i2(0, 0);
- }
- span() {
- return new i2(this.max.x - this.min.x, this.max.y - this.min.y);
- }
- intersectsCount() {
- return this.borders.reduce((t2, e2) => t2 + +(e2[0] !== Number.MAX_VALUE), 0);
- }
- }
- class $u {
- constructor(t2) {
- 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;
- }
- populate(t2, e2, r2, n2) {
- this.features = [], this.hasPattern = mu("fill-extrusion", this.layers, e2), this.featuresOnBorder = [], this.borders = [[], [], [], []], this.borderDoneWithNeighborZ = [-1, -1, -1, -1], this.tileToMeter = function(t3) {
- const e3 = Math.exp(Math.PI * (1 - t3.y / (1 << t3.z) * 2));
- return 80150034 * e3 / (e3 * e3 + 1) / Ya / (1 << t3.z);
- }(r2);
- for (const { feature: i3, id: s2, index: a2, sourceLayerIndex: o2 } of t2) {
- const t3 = this.layers[0]._featureFilter.needGeometry, l2 = mo(i3, t3);
- if (!this.layers[0]._featureFilter.filter(new ss(this.zoom), l2, r2))
- continue;
- 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;
- 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);
- }
- this.sortBorders();
- }
- addFeatures(t2, e2, r2, n2, i3) {
- for (const t3 of this.features) {
- const { geometry: s2 } = t3;
- this.addFeature(t3, s2, t3.index, e2, r2, n2, i3);
- }
- this.sortBorders();
- }
- update(t2, e2, r2, n2) {
- this.stateDependentLayers.length && this.programConfigurations.updatePaintArrays(t2, e2, this.stateDependentLayers, r2, n2);
- }
- isEmpty() {
- return 0 === this.layoutVertexArray.length;
- }
- uploadPending() {
- return !this.uploaded || this.programConfigurations.needsUpload;
- }
- upload(t2) {
- 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;
- }
- uploadCentroid(t2) {
- 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);
- }
- destroy() {
- this.layoutVertexBuffer && (this.layoutVertexBuffer.destroy(), this.centroidVertexBuffer && this.centroidVertexBuffer.destroy(), this.layoutVertexExtBuffer && this.layoutVertexExtBuffer.destroy(), this.indexBuffer.destroy(), this.programConfigurations.destroy(), this.segments.destroy());
- }
- addFeature(t2, e2, r2, n2, s2, a2, o2) {
- const l2 = [new i2(0, 0), new i2(Ya, Ya)], u2 = o2.projection, c2 = "globe" === u2.name, h2 = this.enableTerrain && !c2 ? new Uu() : null;
- c2 && !this.layoutVertexExtArray && (this.layoutVertexExtArray = new Qs());
- const p2 = du(e2, 500);
- for (let t3 = p2.length - 1; t3 >= 0; t3--) {
- const e3 = p2[t3];
- (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);
- }
- var f2;
- let d2;
- if (c2) {
- 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);
- d2 = function(t4, e4, r4, n3, s4 = 0, a4) {
- const o4 = [];
- if (!t4.length || !r4 || !n3)
- return o4;
- const l3 = (t5, e5) => {
- for (const r5 of t5)
- o4.push({ polygon: r5, bounds: e5 });
- }, u3 = Math.ceil(Math.log2(r4)), c3 = Math.ceil(Math.log2(n3)), h3 = u3 - c3, p3 = [];
- for (let t5 = 0; t5 < Math.abs(h3); t5++)
- p3.push(h3 > 0 ? 0 : 1);
- for (let t5 = 0; t5 < Math.min(u3, c3); t5++)
- p3.push(0), p3.push(1);
- let f3 = t4;
- 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)
- return o4;
- const d3 = [];
- for (p3.length ? d3.push({ polygons: f3, bounds: e4, depth: 0 }) : l3(f3, e4); d3.length; ) {
- 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);
- if (f4.length) {
- const t6 = [n4, new i2(0 === r5 ? h4 : o5.x, 1 === r5 ? h4 : o5.y)];
- p3.length > e5 + 1 ? d3.push({ polygons: f4, bounds: t6, depth: e5 + 1 }) : l3(f4, t6);
- }
- if (y2.length) {
- const t6 = [new i2(0 === r5 ? h4 : n4.x, 1 === r5 ? h4 : n4.y), o5];
- p3.length > e5 + 1 ? d3.push({ polygons: y2, bounds: t6, depth: e5 + 1 }) : l3(y2, t6);
- }
- }
- return o4;
- }(p2, l2, Math.ceil((s3 - r3) / t3), Math.ceil((a3 - o3) / t3), 1, (t4, r4, i3) => {
- if (0 === t4)
- return 0.5 * (r4 + i3);
- {
- const t5 = so((n2.y + r4 / Ya) / e3);
- return (ro(0.5 * (so((n2.y + i3 / Ya) / e3) + t5)) * e3 - n2.y) * Ya;
- }
- });
- } else {
- d2 = [];
- for (const t3 of p2)
- d2.push({ polygon: t3, bounds: l2 });
- }
- for (const e3 of d2) {
- const r3 = e3.polygon;
- let i3 = 0, s3 = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray);
- for (let t3 = 0; t3 < r3.length; t3++) {
- const a4 = r3[t3];
- if (0 === a4.length)
- continue;
- i3 += a4.length;
- let o4 = 0;
- h2 && h2.startRing(a4[0]);
- for (let t4 = 0; t4 < a4.length; t4++) {
- const r4 = a4[t4];
- if (t4 >= 1) {
- const i4 = a4[t4 - 1];
- if (!ju(r4, i4, e3.bounds)) {
- h2 && h2.append(r4, i4), s3.vertexLength + 4 > Ka.MAX_VERTEX_ARRAY_LENGTH && (s3 = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray));
- 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);
- 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);
- const p4 = s3.vertexLength;
- 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) {
- 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);
- Ru(t6, e5, a6), Ru(t6, e5, a6), Ru(t6, s4, o5), Ru(t6, s4, o5);
- }
- }
- }
- }
- }
- if (s3.vertexLength + i3 > Ka.MAX_VERTEX_ARRAY_LENGTH && (s3 = this.segments.prepareSegment(i3, this.layoutVertexArray, this.indexArray)), "Polygon" !== Vu[t2.type])
- continue;
- const a3 = [], o3 = [], l3 = s3.vertexLength;
- for (let t3 = 0; t3 < r3.length; t3++) {
- const e4 = r3[t3];
- if (0 !== e4.length) {
- e4 !== r3[0] && o3.push(a3.length / 2);
- for (let t4 = 0; t4 < e4.length; t4++) {
- const r4 = e4[t4];
- 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));
- }
- }
- }
- const p3 = Fl(a3, o3);
- for (let t3 = 0; t3 < p3.length; t3 += 3)
- this.indexArray.emplaceBack(l3 + p3[t3], l3 + p3[t3 + 2], l3 + p3[t3 + 1]);
- s3.primitiveLength += p3.length / 3, s3.vertexLength += i3;
- }
- if (h2 && h2.polyCount.length > 0) {
- if (h2.borders) {
- h2.vertexArrayOffset = this.centroidVertexArray.length;
- const t3 = h2.borders, e3 = this.featuresOnBorder.push(h2) - 1;
- for (let r3 = 0; r3 < 4; r3++)
- t3[r3][0] !== Number.MAX_VALUE && this.borders[r3].push(e3);
- }
- this.encodeCentroid(h2.borders ? void 0 : h2.centroid(), h2);
- }
- this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, t2, r2, s2, a2, n2);
- }
- sortBorders() {
- for (let t2 = 0; t2 < 4; t2++)
- this.borders[t2].sort((e2, r2) => this.featuresOnBorder[e2].borders[t2][0] - this.featuresOnBorder[r2].borders[t2][0]);
- }
- encodeCentroid(t2, e2, r2 = true) {
- let n2, i3;
- if (t2)
- if (0 !== t2.y) {
- const r3 = e2.span()._mult(this.tileToMeter);
- 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));
- } else
- n2 = Math.ceil(7 * (t2.x + 450)), i3 = 0;
- else
- n2 = 0, i3 = +r2;
- let s2 = r2 ? this.centroidVertexArray.length : e2.vertexArrayOffset;
- for (const t3 of e2.polyCount) {
- r2 && this.centroidVertexArray.resize(this.centroidVertexArray.length + 4 * t3.edges + t3.top);
- for (let e3 = 0; e3 < 2 * t3.edges; e3++)
- this.centroidVertexArray.emplace(s2++, 0, i3), this.centroidVertexArray.emplace(s2++, n2, i3);
- for (let e3 = 0; e3 < t3.top; e3++)
- this.centroidVertexArray.emplace(s2++, n2, i3);
- }
- }
- }
- function ju(t2, e2, r2) {
- 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);
- }
- ai($u, "FillExtrusionBucket", { omit: ["layers", "features"] }), ai(Uu, "PartMetadata");
- 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"]) }) };
- function qu(t2, e2) {
- return t2.x * e2.x + t2.y * e2.y;
- }
- function Nu(t2, e2) {
- if (1 === t2.length) {
- let r2 = 0;
- const n2 = e2[r2++];
- let i3;
- for (; !i3 || n2.equals(i3); )
- if (i3 = e2[r2++], !i3)
- return 1 / 0;
- for (; r2 < e2.length; r2++) {
- 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;
- if (isFinite(x2))
- return x2;
- }
- return 1 / 0;
- }
- {
- let t3 = 1 / 0;
- for (const r2 of e2)
- t3 = Math.min(t3, r2.z);
- return t3;
- }
- }
- function Gu(t2) {
- const e2 = new i2(t2[0], t2[1]);
- return e2.z = t2[2], e2;
- }
- function Zu(t2, e2, r2, n2, i3, s2, a2, o2) {
- 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) {
- 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) {
- 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)];
- }(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);
- return o3 + Math.max(x2 * s3, v2 * a3);
- }(i3, s2, o2) : l2;
- return { base: l2 + (0 === r2) ? -1 : r2, top: u2 ? Math.max(c2 + n2, l2 + r2 + 2) : l2 + n2 };
- }
- 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);
- class Qu {
- constructor(t2) {
- 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) => {
- this.gradients[t3.id] = {};
- }), 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);
- }
- populate(t2, e2, r2, n2) {
- this.hasPattern = mu("line", this.layers, e2);
- const i3 = this.layers[0].layout.get("line-sort-key"), s2 = [];
- for (const { feature: e3, id: a3, index: o3, sourceLayerIndex: l3 } of t2) {
- const t3 = this.layers[0]._featureFilter.needGeometry, u2 = mo(e3, t3);
- if (!this.layers[0]._featureFilter.filter(new ss(this.zoom), u2, r2))
- continue;
- 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 };
- s2.push(h2);
- }
- i3 && s2.sort((t3, e3) => t3.sortKey - e3.sortKey);
- const { lineAtlas: a2, featureIndex: o2 } = e2, l2 = this.addConstantDashes(a2);
- for (const n3 of s2) {
- const { geometry: i4, index: s3, sourceLayerIndex: u2 } = n3;
- if (l2 && this.addFeatureDashes(n3, a2), this.hasPattern) {
- const t3 = gu("line", this.layers, n3, this.zoom, e2);
- this.patternFeatures.push(t3);
- } else
- this.addFeature(n3, i4, s3, r2, a2.positions, e2.availableImages);
- o2.insert(t2[s3].feature, i4, s3, u2, this.index);
- }
- }
- addConstantDashes(t2) {
- let e2 = false;
- for (const r2 of this.layers) {
- const n2 = r2.paint.get("line-dasharray").value, i3 = r2.layout.get("line-cap").value;
- if ("constant" !== n2.kind || "constant" !== i3.kind)
- e2 = true;
- else {
- const e3 = i3.value, r3 = n2.value;
- if (!r3)
- continue;
- t2.addDash(r3.from, e3), t2.addDash(r3.to, e3), r3.other && t2.addDash(r3.other, e3);
- }
- }
- return e2;
- }
- addFeatureDashes(t2, e2) {
- const r2 = this.zoom;
- for (const n2 of this.layers) {
- const i3 = n2.paint.get("line-dasharray").value, s2 = n2.layout.get("line-cap").value;
- if ("constant" === i3.kind && "constant" === s2.kind)
- continue;
- let a2, o2, l2, u2, c2, h2;
- if ("constant" === i3.kind) {
- const t3 = i3.value;
- if (!t3)
- continue;
- a2 = t3.other || t3.to, o2 = t3.to, l2 = t3.from;
- } else
- a2 = i3.evaluate({ zoom: r2 - 1 }, t2), o2 = i3.evaluate({ zoom: r2 }, t2), l2 = i3.evaluate({ zoom: r2 + 1 }, t2);
- "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);
- const p2 = e2.getKey(a2, u2), f2 = e2.getKey(o2, c2), d2 = e2.getKey(l2, h2);
- t2.patterns[n2.id] = { min: p2, mid: f2, max: d2 };
- }
- }
- update(t2, e2, r2, n2) {
- this.stateDependentLayers.length && this.programConfigurations.updatePaintArrays(t2, e2, this.stateDependentLayers, r2, n2);
- }
- addFeatures(t2, e2, r2, n2, i3) {
- for (const t3 of this.patternFeatures)
- this.addFeature(t3, t3.geometry, t3.index, e2, r2, n2);
- }
- isEmpty() {
- return 0 === this.layoutVertexArray.length;
- }
- uploadPending() {
- return !this.uploaded || this.programConfigurations.needsUpload;
- }
- upload(t2) {
- 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;
- }
- destroy() {
- this.layoutVertexBuffer && (this.layoutVertexBuffer.destroy(), this.indexBuffer.destroy(), this.programConfigurations.destroy(), this.segments.destroy());
- }
- lineFeatureClips(t2) {
- if (t2.properties && t2.properties.hasOwnProperty("mapbox_clip_start") && t2.properties.hasOwnProperty("mapbox_clip_end"))
- return { start: +t2.properties.mapbox_clip_start, end: +t2.properties.mapbox_clip_end };
- }
- addFeature(t2, e2, r2, n2, i3, s2) {
- 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");
- this.lineClips = this.lineFeatureClips(t2);
- for (const r3 of e2)
- this.addLine(r3, t2, o2, l2, u2, c2);
- this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, t2, r2, i3, s2, n2);
- }
- addLine(t2, e2, r2, n2, i3, s2) {
- if (this.distance = 0, this.scaledDistance = 0, this.totalDistance = 0, this.lineSoFar = 0, this.lineClips) {
- this.lineClipsArray.push(this.lineClips);
- for (let e3 = 0; e3 < t2.length - 1; e3++)
- this.totalDistance += t2[e3].dist(t2[e3 + 1]);
- this.updateScaledDistance(), this.maxLineLength = Math.max(this.maxLineLength, this.totalDistance);
- }
- const a2 = "Polygon" === Wu[e2.type];
- let o2 = t2.length;
- for (; o2 >= 2 && t2[o2 - 1].equals(t2[o2 - 2]); )
- o2--;
- let l2 = 0;
- for (; l2 < o2 - 1 && t2[l2].equals(t2[l2 + 1]); )
- l2++;
- if (o2 < (a2 ? 3 : 2))
- return;
- "bevel" === r2 && (i3 = 1.05);
- const u2 = this.overscaling <= 16 ? 122880 / (512 * this.overscaling) : 0, c2 = this.segments.prepareSegment(10 * o2, this.layoutVertexArray, this.indexArray);
- let h2, p2, f2, d2, y2;
- this.e1 = this.e2 = -1, a2 && (h2 = t2[o2 - 2], y2 = t2[l2].sub(h2)._unit()._perp());
- for (let e3 = l2; e3 < o2; e3++) {
- if (f2 = e3 === o2 - 1 ? a2 ? t2[l2 + 1] : void 0 : t2[e3 + 1], f2 && t2[e3].equals(f2))
- continue;
- y2 && (d2 = y2), h2 && (p2 = h2), h2 = t2[e3], y2 = f2 ? f2.sub(h2)._unit()._perp() : d2, d2 = d2 || y2;
- let m2 = d2.add(y2);
- 0 === m2.x && 0 === m2.y || m2._unit();
- 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;
- if (_2 && e3 > l2) {
- const t3 = h2.dist(p2);
- if (t3 > 2 * u2) {
- const e4 = h2.sub(h2.sub(p2)._mult(u2 / t3)._round());
- this.updateDistance(p2, e4), this.addCurrentVertex(e4, d2, 0, 0, c2), p2 = e4;
- }
- }
- const A2 = p2 && f2;
- let k2 = A2 ? r2 : a2 ? "butt" : n2;
- 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)
- m2._mult(v2), this.addCurrentVertex(h2, m2, 0, 0, c2);
- else if ("flipbevel" === k2) {
- if (v2 > 100)
- m2 = y2.mult(-1);
- else {
- const t3 = v2 * d2.add(y2).mag() / d2.sub(y2).mag();
- m2._perp()._mult(t3 * (w2 ? -1 : 1));
- }
- this.addCurrentVertex(h2, m2, 0, 0, c2), this.addCurrentVertex(h2, m2.mult(-1), 0, 0, c2);
- } else if ("bevel" === k2 || "fakeround" === k2) {
- const t3 = -Math.sqrt(v2 * v2 - 1), e4 = w2 ? t3 : 0, r3 = w2 ? 0 : t3;
- if (p2 && this.addCurrentVertex(h2, d2, e4, r3, c2), "fakeround" === k2) {
- const t4 = Math.round(180 * b2 / Math.PI / 20);
- for (let e5 = 1; e5 < t4; e5++) {
- let r4 = e5 / t4;
- if (0.5 !== r4) {
- const t5 = r4 - 0.5;
- 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)));
- }
- const n3 = y2.sub(d2)._mult(r4)._add(d2)._unit()._mult(w2 ? -1 : 1);
- this.addHalfVertex(h2, n3.x, n3.y, false, w2, 0, c2);
- }
- }
- f2 && this.addCurrentVertex(h2, y2, -e4, -r3, c2);
- } else if ("butt" === k2)
- this.addCurrentVertex(h2, m2, 0, 0, c2);
- else if ("square" === k2) {
- const t3 = p2 ? 1 : -1;
- p2 || this.addCurrentVertex(h2, m2, t3, t3, c2), this.addCurrentVertex(h2, m2, 0, 0, c2), p2 && this.addCurrentVertex(h2, m2, t3, t3, c2);
- } else
- "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)));
- if (_2 && e3 < o2 - 1) {
- const t3 = h2.dist(f2);
- if (t3 > 2 * u2) {
- const e4 = h2.add(f2.sub(h2)._mult(u2 / t3)._round());
- this.updateDistance(h2, e4), this.addCurrentVertex(e4, y2, 0, 0, c2), h2 = e4;
- }
- }
- }
- }
- addCurrentVertex(t2, e2, r2, n2, i3, s2 = false) {
- const a2 = e2.y * n2 - e2.x, o2 = -e2.y - e2.x * n2;
- 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);
- }
- addHalfVertex({ x: t2, y: e2 }, r2, n2, i3, s2, a2, o2) {
- 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);
- const l2 = o2.vertexLength++;
- this.e1 >= 0 && this.e2 >= 0 && (this.indexArray.emplaceBack(this.e1, this.e2, l2), o2.primitiveLength++), s2 ? this.e2 = l2 : this.e1 = l2;
- }
- updateScaledDistance() {
- if (this.lineClips) {
- const t2 = this.totalDistance / (this.lineClips.end - this.lineClips.start);
- this.scaledDistance = this.distance / this.totalDistance, this.lineSoFar = t2 * this.lineClips.start + this.distance;
- } else
- this.lineSoFar = this.distance;
- }
- updateDistance(t2, e2) {
- this.distance += t2.dist(e2), this.updateScaledDistance();
- }
- }
- ai(Qu, "LineBucket", { omit: ["layers", "patternFeatures"] });
- 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"]) });
- 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 };
- const rc = new class extends ys {
- possiblyEvaluate(t2, e2) {
- return e2 = new ss(Math.floor(e2.zoom), { now: e2.now, fadeDuration: e2.fadeDuration, zoomHistory: e2.zoomHistory, transition: e2.transition }), super.possiblyEvaluate(t2, e2);
- }
- evaluate(t2, e2, r2, n2) {
- return e2 = b({}, e2, { zoom: Math.floor(e2.zoom) }), super.evaluate(t2, e2, r2, n2);
- }
- }(ec.paint.properties["line-width"].specification);
- function nc(t2, e2) {
- return e2 > 0 ? e2 + 2 * t2 : t2;
- }
- rc.useIntegerZoom = true;
- 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);
- ks([{ name: "a_fade_opacity", components: 1, type: "Uint32" }], 4);
- 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" }]);
- 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" }]);
- 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);
- 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" }]);
- var cc = 24;
- const hc = 128;
- function pc(t2, e2) {
- const { expression: r2 } = e2;
- if ("constant" === r2.kind)
- return { kind: "constant", layoutSize: r2.evaluate(new ss(t2 + 1)) };
- if ("source" === r2.kind)
- return { kind: "source" };
- {
- const { zoomStops: e3, interpolationType: n2 } = r2;
- let i3 = 0;
- for (; i3 < e3.length && e3[i3] <= t2; )
- i3++;
- i3 = Math.max(0, i3 - 1);
- let s2 = i3;
- for (; s2 < e3.length && e3[s2] < t2 + 1; )
- s2++;
- s2 = Math.min(e3.length - 1, s2);
- const a2 = e3[i3], o2 = e3[s2];
- 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 };
- }
- }
- function fc(t2, { uSize: e2, uSizeT: r2 }, { lowerSize: n2, upperSize: i3 }) {
- return "source" === t2.kind ? n2 / hc : "composite" === t2.kind ? rr(n2 / hc, i3 / hc, r2) : e2;
- }
- function dc(t2, e2) {
- let r2 = 0, n2 = 0;
- if ("constant" === t2.kind)
- n2 = t2.layoutSize;
- else if ("source" !== t2.kind) {
- const { interpolationType: i3, minZoom: s2, maxZoom: a2 } = t2, o2 = i3 ? y(_r.interpolationFactor(i3, e2, s2, a2), 0, 1) : 0;
- "camera" === t2.kind ? n2 = rr(t2.minSize, t2.maxSize, o2) : r2 = o2;
- }
- return { uSizeT: r2, uSize: n2 };
- }
- var yc = Object.freeze({ __proto__: null, getSizeData: pc, evaluateSizeForFeature: fc, evaluateSizeForZoom: dc, SIZE_PACK_FACTOR: hc });
- function mc(t2, e2, r2) {
- return t2.sections.forEach((t3) => {
- t3.text = function(t4, e3, r3) {
- const n2 = e3.layout.get("text-transform").evaluate(r3, {});
- return "uppercase" === n2 ? t4 = t4.toLocaleUpperCase() : "lowercase" === n2 && (t4 = t4.toLocaleLowerCase()), is.applyArabicShaping && (t4 = is.applyArabicShaping(t4)), t4;
- }(t3.text, e2, r2);
- }), t2;
- }
- const gc = { "!": "︕", "#": "#", $: "$", "%": "%", "&": "&", "(": "︵", ")": "︶", "*": "*", "+": "+", ",": "︐", "-": "︲", ".": "・", "/": "/", ":": "︓", ";": "︔", "<": "︿", "=": "=", ">": "﹀", "?": "︖", "@": "@", "[": "﹇", "\\": "\", "]": "﹈", "^": "^", _: "︳", "`": "`", "{": "︷", "|": "―", "}": "︸", "~": "~", "¢": "¢", "£": "£", "¥": "¥", "¦": "¦", "¬": "¬", "¯": " ̄", "–": "︲", "—": "︱", "‘": "﹃", "’": "﹄", "“": "﹁", "”": "﹂", "…": "︙", "‧": "・", "₩": "₩", "、": "︑", "。": "︒", "〈": "︿", "〉": "﹀", "《": "︽", "》": "︾", "「": "﹁", "」": "﹂", "『": "﹃", "』": "﹄", "【": "︻", "】": "︼", "〔": "︹", "〕": "︺", "〖": "︗", "〗": "︘", "!": "︕", "(": "︵", ")": "︶", ",": "︐", "-": "︲", ".": "・", ":": "︓", ";": "︔", "<": "︿", ">": "﹀", "?": "︖", "[": "﹇", "]": "﹈", "_": "︳", "{": "︷", "|": "―", "}": "︸", "⦅": "︵", "⦆": "︶", "。": "︒", "「": "﹁", "」": "﹂" };
- function xc(t2) {
- return "︶" === t2 || "﹈" === t2 || "︸" === t2 || "﹄" === t2 || "﹂" === t2 || "︾" === t2 || "︼" === t2 || "︺" === t2 || "︘" === t2 || "﹀" === t2 || "︐" === t2 || "︓" === t2 || "︔" === t2 || "`" === t2 || " ̄" === t2 || "︑" === t2 || "︒" === t2;
- }
- function vc(t2) {
- return "︵" === t2 || "﹇" === t2 || "︷" === t2 || "﹃" === t2 || "﹁" === t2 || "︽" === t2 || "︻" === t2 || "︹" === t2 || "︗" === t2 || "︿" === t2;
- }
- var bc = function(t2, e2, r2, n2, i3) {
- 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];
- for (h2 += p2, s2 = f2 & (1 << -c2) - 1, f2 >>= -c2, c2 += o2; c2 > 0; s2 = 256 * s2 + t2[e2 + h2], h2 += p2, c2 -= 8)
- ;
- for (a2 = s2 & (1 << -c2) - 1, s2 >>= -c2, c2 += n2; c2 > 0; a2 = 256 * a2 + t2[e2 + h2], h2 += p2, c2 -= 8)
- ;
- if (0 === s2)
- s2 = 1 - u2;
- else {
- if (s2 === l2)
- return a2 ? NaN : 1 / 0 * (f2 ? -1 : 1);
- a2 += Math.pow(2, n2), s2 -= u2;
- }
- return (f2 ? -1 : 1) * a2 * Math.pow(2, s2 - n2);
- }, _c = function(t2, e2, r2, n2, i3, s2) {
- 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;
- 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)
- ;
- for (a2 = a2 << i3 | o2, u2 += i3; u2 > 0; t2[r2 + f2] = 255 & a2, f2 += d2, a2 /= 256, u2 -= 8)
- ;
- t2[r2 + f2 - d2] |= 128 * y2;
- }, wc = Ac;
- function Ac(t2) {
- this.buf = ArrayBuffer.isView && ArrayBuffer.isView(t2) ? t2 : new Uint8Array(t2 || 0), this.pos = 0, this.type = 0, this.length = this.buf.length;
- }
- Ac.Varint = 0, Ac.Fixed64 = 1, Ac.Bytes = 2, Ac.Fixed32 = 5;
- var kc = 4294967296, Sc = 1 / kc, Ic = "undefined" == typeof TextDecoder ? null : new TextDecoder("utf8");
- function Mc(t2) {
- return t2.type === Ac.Bytes ? t2.readVarint() + t2.pos : t2.pos + 1;
- }
- function Tc(t2, e2, r2) {
- return r2 ? 4294967296 * e2 + (t2 >>> 0) : 4294967296 * (e2 >>> 0) + (t2 >>> 0);
- }
- function zc(t2, e2, r2) {
- var n2 = e2 <= 16383 ? 1 : e2 <= 2097151 ? 2 : e2 <= 268435455 ? 3 : Math.floor(Math.log(e2) / (7 * Math.LN2));
- r2.realloc(n2);
- for (var i3 = r2.pos - 1; i3 >= t2; i3--)
- r2.buf[i3 + n2] = r2.buf[i3];
- }
- function Bc(t2, e2) {
- for (var r2 = 0; r2 < t2.length; r2++)
- e2.writeVarint(t2[r2]);
- }
- function Ec(t2, e2) {
- for (var r2 = 0; r2 < t2.length; r2++)
- e2.writeSVarint(t2[r2]);
- }
- function Cc(t2, e2) {
- for (var r2 = 0; r2 < t2.length; r2++)
- e2.writeFloat(t2[r2]);
- }
- function Dc(t2, e2) {
- for (var r2 = 0; r2 < t2.length; r2++)
- e2.writeDouble(t2[r2]);
- }
- function Pc(t2, e2) {
- for (var r2 = 0; r2 < t2.length; r2++)
- e2.writeBoolean(t2[r2]);
- }
- function Vc(t2, e2) {
- for (var r2 = 0; r2 < t2.length; r2++)
- e2.writeFixed32(t2[r2]);
- }
- function Fc(t2, e2) {
- for (var r2 = 0; r2 < t2.length; r2++)
- e2.writeSFixed32(t2[r2]);
- }
- function Lc(t2, e2) {
- for (var r2 = 0; r2 < t2.length; r2++)
- e2.writeFixed64(t2[r2]);
- }
- function Rc(t2, e2) {
- for (var r2 = 0; r2 < t2.length; r2++)
- e2.writeSFixed64(t2[r2]);
- }
- function Uc(t2, e2) {
- return (t2[e2] | t2[e2 + 1] << 8 | t2[e2 + 2] << 16) + 16777216 * t2[e2 + 3];
- }
- function $c(t2, e2, r2) {
- t2[r2] = e2, t2[r2 + 1] = e2 >>> 8, t2[r2 + 2] = e2 >>> 16, t2[r2 + 3] = e2 >>> 24;
- }
- function jc(t2, e2) {
- return (t2[e2] | t2[e2 + 1] << 8 | t2[e2 + 2] << 16) + (t2[e2 + 3] << 24);
- }
- function Oc(t2, e2, r2) {
- e2.glyphs = [], 1 === t2 && r2.readMessage(qc, e2);
- }
- function qc(t2, e2, r2) {
- if (3 === t2) {
- const { id: t3, bitmap: n2, width: i3, height: s2, left: a2, top: o2, advance: l2 } = r2.readMessage(Nc, {});
- 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 } });
- } else
- 4 === t2 ? e2.ascender = r2.readSVarint() : 5 === t2 && (e2.descender = r2.readSVarint());
- }
- function Nc(t2, e2, r2) {
- 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());
- }
- function Gc(t2) {
- let e2 = 0, r2 = 0;
- for (const n3 of t2)
- e2 += n3.w * n3.h, r2 = Math.max(r2, n3.w);
- t2.sort((t3, e3) => e3.h - t3.h);
- const n2 = [{ x: 0, y: 0, w: Math.max(Math.ceil(Math.sqrt(e2 / 0.95)), r2), h: 1 / 0 }];
- let i3 = 0, s2 = 0;
- for (const e3 of t2)
- for (let t3 = n2.length - 1; t3 >= 0; t3--) {
- const r3 = n2[t3];
- if (!(e3.w > r3.w || e3.h > r3.h)) {
- 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) {
- const e4 = n2.pop();
- t3 < n2.length && (n2[t3] = e4);
- } else
- 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);
- break;
- }
- }
- return { w: i3, h: s2, fill: e2 / (i3 * s2) || 0 };
- }
- Ac.prototype = { destroy: function() {
- this.buf = null;
- }, readFields: function(t2, e2, r2) {
- for (r2 = r2 || this.length; this.pos < r2; ) {
- var n2 = this.readVarint(), i3 = n2 >> 3, s2 = this.pos;
- this.type = 7 & n2, t2(i3, e2, this), this.pos === s2 && this.skip(n2);
- }
- return e2;
- }, readMessage: function(t2, e2) {
- return this.readFields(t2, e2, this.readVarint() + this.pos);
- }, readFixed32: function() {
- var t2 = Uc(this.buf, this.pos);
- return this.pos += 4, t2;
- }, readSFixed32: function() {
- var t2 = jc(this.buf, this.pos);
- return this.pos += 4, t2;
- }, readFixed64: function() {
- var t2 = Uc(this.buf, this.pos) + Uc(this.buf, this.pos + 4) * kc;
- return this.pos += 8, t2;
- }, readSFixed64: function() {
- var t2 = Uc(this.buf, this.pos) + jc(this.buf, this.pos + 4) * kc;
- return this.pos += 8, t2;
- }, readFloat: function() {
- var t2 = bc(this.buf, this.pos, true, 23, 4);
- return this.pos += 4, t2;
- }, readDouble: function() {
- var t2 = bc(this.buf, this.pos, true, 52, 8);
- return this.pos += 8, t2;
- }, readVarint: function(t2) {
- var e2, r2, n2 = this.buf;
- 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) {
- var n3, i3, s2 = r3.buf;
- if (n3 = (112 & (i3 = s2[r3.pos++])) >> 4, i3 < 128)
- return Tc(t3, n3, e3);
- if (n3 |= (127 & (i3 = s2[r3.pos++])) << 3, i3 < 128)
- return Tc(t3, n3, e3);
- if (n3 |= (127 & (i3 = s2[r3.pos++])) << 10, i3 < 128)
- return Tc(t3, n3, e3);
- if (n3 |= (127 & (i3 = s2[r3.pos++])) << 17, i3 < 128)
- return Tc(t3, n3, e3);
- if (n3 |= (127 & (i3 = s2[r3.pos++])) << 24, i3 < 128)
- return Tc(t3, n3, e3);
- if (n3 |= (1 & (i3 = s2[r3.pos++])) << 31, i3 < 128)
- return Tc(t3, n3, e3);
- throw new Error("Expected varint not more than 10 bytes");
- }(e2 |= (15 & (r2 = n2[this.pos])) << 28, t2, this))));
- }, readVarint64: function() {
- return this.readVarint(true);
- }, readSVarint: function() {
- var t2 = this.readVarint();
- return t2 % 2 == 1 ? (t2 + 1) / -2 : t2 / 2;
- }, readBoolean: function() {
- return Boolean(this.readVarint());
- }, readString: function() {
- var t2 = this.readVarint() + this.pos, e2 = this.pos;
- return this.pos = t2, t2 - e2 >= 12 && Ic ? function(t3, e3, r2) {
- return Ic.decode(t3.subarray(e3, r2));
- }(this.buf, e2, t2) : function(t3, e3, r2) {
- for (var n2 = "", i3 = e3; i3 < r2; ) {
- var s2, a2, o2, l2 = t3[i3], u2 = null, c2 = l2 > 239 ? 4 : l2 > 223 ? 3 : l2 > 191 ? 2 : 1;
- if (i3 + c2 > r2)
- break;
- 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;
- }
- return n2;
- }(this.buf, e2, t2);
- }, readBytes: function() {
- var t2 = this.readVarint() + this.pos, e2 = this.buf.subarray(this.pos, t2);
- return this.pos = t2, e2;
- }, readPackedVarint: function(t2, e2) {
- if (this.type !== Ac.Bytes)
- return t2.push(this.readVarint(e2));
- var r2 = Mc(this);
- for (t2 = t2 || []; this.pos < r2; )
- t2.push(this.readVarint(e2));
- return t2;
- }, readPackedSVarint: function(t2) {
- if (this.type !== Ac.Bytes)
- return t2.push(this.readSVarint());
- var e2 = Mc(this);
- for (t2 = t2 || []; this.pos < e2; )
- t2.push(this.readSVarint());
- return t2;
- }, readPackedBoolean: function(t2) {
- if (this.type !== Ac.Bytes)
- return t2.push(this.readBoolean());
- var e2 = Mc(this);
- for (t2 = t2 || []; this.pos < e2; )
- t2.push(this.readBoolean());
- return t2;
- }, readPackedFloat: function(t2) {
- if (this.type !== Ac.Bytes)
- return t2.push(this.readFloat());
- var e2 = Mc(this);
- for (t2 = t2 || []; this.pos < e2; )
- t2.push(this.readFloat());
- return t2;
- }, readPackedDouble: function(t2) {
- if (this.type !== Ac.Bytes)
- return t2.push(this.readDouble());
- var e2 = Mc(this);
- for (t2 = t2 || []; this.pos < e2; )
- t2.push(this.readDouble());
- return t2;
- }, readPackedFixed32: function(t2) {
- if (this.type !== Ac.Bytes)
- return t2.push(this.readFixed32());
- var e2 = Mc(this);
- for (t2 = t2 || []; this.pos < e2; )
- t2.push(this.readFixed32());
- return t2;
- }, readPackedSFixed32: function(t2) {
- if (this.type !== Ac.Bytes)
- return t2.push(this.readSFixed32());
- var e2 = Mc(this);
- for (t2 = t2 || []; this.pos < e2; )
- t2.push(this.readSFixed32());
- return t2;
- }, readPackedFixed64: function(t2) {
- if (this.type !== Ac.Bytes)
- return t2.push(this.readFixed64());
- var e2 = Mc(this);
- for (t2 = t2 || []; this.pos < e2; )
- t2.push(this.readFixed64());
- return t2;
- }, readPackedSFixed64: function(t2) {
- if (this.type !== Ac.Bytes)
- return t2.push(this.readSFixed64());
- var e2 = Mc(this);
- for (t2 = t2 || []; this.pos < e2; )
- t2.push(this.readSFixed64());
- return t2;
- }, skip: function(t2) {
- var e2 = 7 & t2;
- if (e2 === Ac.Varint)
- for (; this.buf[this.pos++] > 127; )
- ;
- else if (e2 === Ac.Bytes)
- this.pos = this.readVarint() + this.pos;
- else if (e2 === Ac.Fixed32)
- this.pos += 4;
- else {
- if (e2 !== Ac.Fixed64)
- throw new Error("Unimplemented type: " + e2);
- this.pos += 8;
- }
- }, writeTag: function(t2, e2) {
- this.writeVarint(t2 << 3 | e2);
- }, realloc: function(t2) {
- for (var e2 = this.length || 16; e2 < this.pos + t2; )
- e2 *= 2;
- if (e2 !== this.length) {
- var r2 = new Uint8Array(e2);
- r2.set(this.buf), this.buf = r2, this.length = e2;
- }
- }, finish: function() {
- return this.length = this.pos, this.pos = 0, this.buf.subarray(0, this.length);
- }, writeFixed32: function(t2) {
- this.realloc(4), $c(this.buf, t2, this.pos), this.pos += 4;
- }, writeSFixed32: function(t2) {
- this.realloc(4), $c(this.buf, t2, this.pos), this.pos += 4;
- }, writeFixed64: function(t2) {
- this.realloc(8), $c(this.buf, -1 & t2, this.pos), $c(this.buf, Math.floor(t2 * Sc), this.pos + 4), this.pos += 8;
- }, writeSFixed64: function(t2) {
- this.realloc(8), $c(this.buf, -1 & t2, this.pos), $c(this.buf, Math.floor(t2 * Sc), this.pos + 4), this.pos += 8;
- }, writeVarint: function(t2) {
- (t2 = +t2 || 0) > 268435455 || t2 < 0 ? function(t3, e2) {
- var r2, n2;
- 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)
- throw new Error("Given varint doesn't fit into 10 bytes");
- e2.realloc(10), function(t4, e3, r3) {
- 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);
- }(r2, 0, e2), function(t4, e3) {
- var r3 = (7 & t4) << 4;
- 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)))));
- }(n2, e2);
- }(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))));
- }, writeSVarint: function(t2) {
- this.writeVarint(t2 < 0 ? 2 * -t2 - 1 : 2 * t2);
- }, writeBoolean: function(t2) {
- this.writeVarint(Boolean(t2));
- }, writeString: function(t2) {
- t2 = String(t2), this.realloc(4 * t2.length), this.pos++;
- var e2 = this.pos;
- this.pos = function(t3, e3, r3) {
- for (var n2, i3, s2 = 0; s2 < e3.length; s2++) {
- if ((n2 = e3.charCodeAt(s2)) > 55295 && n2 < 57344) {
- if (!i3) {
- n2 > 56319 || s2 + 1 === e3.length ? (t3[r3++] = 239, t3[r3++] = 191, t3[r3++] = 189) : i3 = n2;
- continue;
- }
- if (n2 < 56320) {
- t3[r3++] = 239, t3[r3++] = 191, t3[r3++] = 189, i3 = n2;
- continue;
- }
- n2 = i3 - 55296 << 10 | n2 - 56320 | 65536, i3 = null;
- } else
- i3 && (t3[r3++] = 239, t3[r3++] = 191, t3[r3++] = 189, i3 = null);
- 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);
- }
- return r3;
- }(this.buf, t2, this.pos);
- var r2 = this.pos - e2;
- r2 >= 128 && zc(e2, r2, this), this.pos = e2 - 1, this.writeVarint(r2), this.pos += r2;
- }, writeFloat: function(t2) {
- this.realloc(4), _c(this.buf, t2, this.pos, true, 23, 4), this.pos += 4;
- }, writeDouble: function(t2) {
- this.realloc(8), _c(this.buf, t2, this.pos, true, 52, 8), this.pos += 8;
- }, writeBytes: function(t2) {
- var e2 = t2.length;
- this.writeVarint(e2), this.realloc(e2);
- for (var r2 = 0; r2 < e2; r2++)
- this.buf[this.pos++] = t2[r2];
- }, writeRawMessage: function(t2, e2) {
- this.pos++;
- var r2 = this.pos;
- t2(e2, this);
- var n2 = this.pos - r2;
- n2 >= 128 && zc(r2, n2, this), this.pos = r2 - 1, this.writeVarint(n2), this.pos += n2;
- }, writeMessage: function(t2, e2, r2) {
- this.writeTag(t2, Ac.Bytes), this.writeRawMessage(e2, r2);
- }, writePackedVarint: function(t2, e2) {
- e2.length && this.writeMessage(t2, Bc, e2);
- }, writePackedSVarint: function(t2, e2) {
- e2.length && this.writeMessage(t2, Ec, e2);
- }, writePackedBoolean: function(t2, e2) {
- e2.length && this.writeMessage(t2, Pc, e2);
- }, writePackedFloat: function(t2, e2) {
- e2.length && this.writeMessage(t2, Cc, e2);
- }, writePackedDouble: function(t2, e2) {
- e2.length && this.writeMessage(t2, Dc, e2);
- }, writePackedFixed32: function(t2, e2) {
- e2.length && this.writeMessage(t2, Vc, e2);
- }, writePackedSFixed32: function(t2, e2) {
- e2.length && this.writeMessage(t2, Fc, e2);
- }, writePackedFixed64: function(t2, e2) {
- e2.length && this.writeMessage(t2, Lc, e2);
- }, writePackedSFixed64: function(t2, e2) {
- e2.length && this.writeMessage(t2, Rc, e2);
- }, writeBytesField: function(t2, e2) {
- this.writeTag(t2, Ac.Bytes), this.writeBytes(e2);
- }, writeFixed32Field: function(t2, e2) {
- this.writeTag(t2, Ac.Fixed32), this.writeFixed32(e2);
- }, writeSFixed32Field: function(t2, e2) {
- this.writeTag(t2, Ac.Fixed32), this.writeSFixed32(e2);
- }, writeFixed64Field: function(t2, e2) {
- this.writeTag(t2, Ac.Fixed64), this.writeFixed64(e2);
- }, writeSFixed64Field: function(t2, e2) {
- this.writeTag(t2, Ac.Fixed64), this.writeSFixed64(e2);
- }, writeVarintField: function(t2, e2) {
- this.writeTag(t2, Ac.Varint), this.writeVarint(e2);
- }, writeSVarintField: function(t2, e2) {
- this.writeTag(t2, Ac.Varint), this.writeSVarint(e2);
- }, writeStringField: function(t2, e2) {
- this.writeTag(t2, Ac.Bytes), this.writeString(e2);
- }, writeFloatField: function(t2, e2) {
- this.writeTag(t2, Ac.Fixed32), this.writeFloat(e2);
- }, writeDoubleField: function(t2, e2) {
- this.writeTag(t2, Ac.Fixed64), this.writeDouble(e2);
- }, writeBooleanField: function(t2, e2) {
- this.writeVarintField(t2, Boolean(e2));
- } };
- class Zc {
- constructor(t2, { pixelRatio: e2, version: r2, stretchX: n2, stretchY: i3, content: s2 }) {
- this.paddedRect = t2, this.pixelRatio = e2, this.stretchX = n2, this.stretchY = i3, this.content = s2, this.version = r2;
- }
- get tl() {
- return [this.paddedRect.x + 1, this.paddedRect.y + 1];
- }
- get br() {
- return [this.paddedRect.x + this.paddedRect.w - 1, this.paddedRect.y + this.paddedRect.h - 1];
- }
- get displaySize() {
- return [(this.paddedRect.w - 2) / this.pixelRatio, (this.paddedRect.h - 2) / this.pixelRatio];
- }
- }
- class Xc {
- constructor(t2, e2) {
- const r2 = {}, n2 = {};
- this.haveRenderCallbacks = [];
- const i3 = [];
- this.addImages(t2, r2, i3), this.addImages(e2, n2, i3);
- const { w: s2, h: a2 } = Gc(i3), o2 = new Bl({ width: s2 || 1, height: a2 || 1 });
- for (const e3 in t2) {
- const n3 = t2[e3], i4 = r2[e3].paddedRect;
- Bl.copy(n3.data, o2, { x: 0, y: 0 }, { x: i4.x + 1, y: i4.y + 1 }, n3.data);
- }
- for (const t3 in e2) {
- const r3 = e2[t3], i4 = n2[t3].paddedRect, s3 = i4.x + 1, a3 = i4.y + 1, l2 = r3.data.width, u2 = r3.data.height;
- 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 });
- }
- this.image = o2, this.iconPositions = r2, this.patternPositions = n2;
- }
- addImages(t2, e2, r2) {
- for (const n2 in t2) {
- const i3 = t2[n2], s2 = { x: 0, y: 0, w: i3.data.width + 2, h: i3.data.height + 2 };
- r2.push(s2), e2[n2] = new Zc(s2, i3), i3.hasRenderCallback && this.haveRenderCallbacks.push(n2);
- }
- }
- patchUpdatedImages(t2, e2) {
- this.haveRenderCallbacks = this.haveRenderCallbacks.filter((e3) => t2.hasImage(e3)), t2.dispatchRenderCallbacks(this.haveRenderCallbacks);
- for (const r2 in t2.updatedImages)
- this.patchUpdatedImage(this.iconPositions[r2], t2.getImage(r2), e2), this.patchUpdatedImage(this.patternPositions[r2], t2.getImage(r2), e2);
- }
- patchUpdatedImage(t2, e2, r2) {
- if (!t2 || !e2)
- return;
- if (t2.version === e2.version)
- return;
- t2.version = e2.version;
- const [n2, i3] = t2.tl;
- r2.update(e2.data, void 0, { x: n2, y: i3 });
- }
- }
- ai(Zc, "ImagePosition"), ai(Xc, "ImageAtlas");
- const Kc = { horizontal: 1, vertical: 2, horizontalOnly: 3 };
- class Yc {
- constructor() {
- this.scale = 1, this.fontStack = "", this.imageName = null;
- }
- static forText(t2, e2) {
- const r2 = new Yc();
- return r2.scale = t2 || 1, r2.fontStack = e2, r2;
- }
- static forImage(t2) {
- const e2 = new Yc();
- return e2.imageName = t2, e2;
- }
- }
- class Hc {
- constructor() {
- this.text = "", this.sectionIndex = [], this.sections = [], this.imageSectionID = null;
- }
- static fromFeature(t2, e2) {
- const r2 = new Hc();
- for (let n2 = 0; n2 < t2.sections.length; n2++) {
- const i3 = t2.sections[n2];
- i3.image ? r2.addImageSection(i3) : r2.addTextSection(i3, e2);
- }
- return r2;
- }
- length() {
- return this.text.length;
- }
- getSection(t2) {
- return this.sections[this.sectionIndex[t2]];
- }
- getSections() {
- return this.sections;
- }
- getSectionIndex(t2) {
- return this.sectionIndex[t2];
- }
- getCharCode(t2) {
- return this.text.charCodeAt(t2);
- }
- verticalizePunctuation(t2) {
- this.text = function(t3, e2) {
- let r2 = "";
- for (let n2 = 0; n2 < t3.length; n2++) {
- const i3 = t3.charCodeAt(n2 + 1) || null, s2 = t3.charCodeAt(n2 - 1) || null;
- r2 += !e2 && (i3 && qi(i3) && !gc[t3[n2 + 1]] || s2 && qi(s2) && !gc[t3[n2 - 1]]) || !gc[t3[n2]] ? t3[n2] : gc[t3[n2]];
- }
- return r2;
- }(this.text, t2);
- }
- trim() {
- let t2 = 0;
- for (let e3 = 0; e3 < this.text.length && Jc[this.text.charCodeAt(e3)]; e3++)
- t2++;
- let e2 = this.text.length;
- for (let r2 = this.text.length - 1; r2 >= 0 && r2 >= t2 && Jc[this.text.charCodeAt(r2)]; r2--)
- e2--;
- this.text = this.text.substring(t2, e2), this.sectionIndex = this.sectionIndex.slice(t2, e2);
- }
- substring(t2, e2) {
- const r2 = new Hc();
- return r2.text = this.text.substring(t2, e2), r2.sectionIndex = this.sectionIndex.slice(t2, e2), r2.sections = this.sections, r2;
- }
- toString() {
- return this.text;
- }
- getMaxScale() {
- return this.sectionIndex.reduce((t2, e2) => Math.max(t2, this.sections[e2].scale), 0);
- }
- addTextSection(t2, e2) {
- this.text += t2.text, this.sections.push(Yc.forText(t2.scale, t2.fontStack || e2));
- const r2 = this.sections.length - 1;
- for (let e3 = 0; e3 < t2.text.length; ++e3)
- this.sectionIndex.push(r2);
- }
- addImageSection(t2) {
- const e2 = t2.image ? t2.image.name : "";
- if (0 === e2.length)
- return void C("Can't add FormattedSection with an empty image.");
- const r2 = this.getNextImageSectionCharCode();
- 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");
- }
- getNextImageSectionCharCode() {
- return this.imageSectionID ? this.imageSectionID >= 63743 ? null : ++this.imageSectionID : (this.imageSectionID = 57344, this.imageSectionID);
- }
- }
- function Wc(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2) {
- const m2 = Hc.fromFeature(t2, i3);
- let g2;
- h2 === Kc.vertical && m2.verticalizePunctuation(p2);
- const { processBidirectionalText: x2, processStyledBidirectionalText: v2 } = is;
- if (x2 && 1 === m2.sections.length) {
- g2 = [];
- const t3 = x2(m2.toString(), sh(m2, u2, s2, e2, n2, f2, d2));
- for (const e3 of t3) {
- const t4 = new Hc();
- t4.text = e3, t4.sections = m2.sections;
- for (let r3 = 0; r3 < e3.length; r3++)
- t4.sectionIndex.push(0);
- g2.push(t4);
- }
- } else if (v2) {
- g2 = [];
- const t3 = v2(m2.text, m2.sectionIndex, sh(m2, u2, s2, e2, n2, f2, d2));
- for (const e3 of t3) {
- const t4 = new Hc();
- t4.text = e3[0], t4.sectionIndex = e3[1], t4.sections = m2.sections, g2.push(t4);
- }
- } else
- g2 = function(t3, e3) {
- const r3 = [], n3 = t3.text;
- let i4 = 0;
- for (const n4 of e3)
- r3.push(t3.substring(i4, n4)), i4 = n4;
- return i4 < n3.length && r3.push(t3.substring(i4, n3.length)), r3;
- }(m2, sh(m2, u2, s2, e2, n2, f2, d2));
- 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 };
- return function(t3, e3, r3, n3, i4, s3, a3, o3, l3, u3, c3, h3) {
- let p3 = 0, f3 = 0, d3 = 0;
- const y3 = "right" === o3 ? 1 : "left" === o3 ? 0 : 0.5;
- let m3 = false;
- for (const t4 of i4) {
- const r4 = t4.getSections();
- for (const t5 of r4) {
- if (t5.imageName)
- continue;
- const r5 = e3[t5.fontStack];
- if (r5 && (m3 = void 0 !== r5.ascender && void 0 !== r5.descender, !m3))
- break;
- }
- if (!m3)
- break;
- }
- let g3 = 0;
- for (const a4 of i4) {
- a4.trim();
- const i5 = a4.getMaxScale(), o4 = (i5 - 1) * cc, v4 = { positionedGlyphs: [], lineOffset: 0 };
- t3.positionedLines[g3] = v4;
- const b4 = v4.positionedGlyphs;
- let _4 = 0;
- if (!a4.length()) {
- f3 += s3, ++g3;
- continue;
- }
- let w2 = 0, A2 = 0;
- for (let s4 = 0; s4 < a4.length(); s4++) {
- const o5 = a4.getSection(s4), d4 = a4.getSectionIndex(s4), y4 = a4.getCharCode(s4);
- let g4 = o5.scale, v5 = null, k3 = null, S2 = null, I2 = cc, M2 = 0;
- const T2 = !(l3 === Kc.horizontal || !c3 && !Oi(y4) || c3 && (Jc[y4] || (x3 = y4, pi(x3) || fi(x3) || di(x3) || Di(x3) || Li(x3))));
- if (o5.imageName) {
- const e4 = n3[o5.imageName];
- if (!e4)
- continue;
- S2 = o5.imageName, t3.iconsInText = t3.iconsInText || true, k3 = e4.paddedRect;
- const r4 = e4.displaySize;
- 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;
- const s5 = (T2 ? r4[0] : r4[1]) * g4 - cc * i5;
- s5 > 0 && s5 > _4 && (_4 = s5);
- } else {
- const t4 = r3[o5.fontStack];
- if (!t4)
- continue;
- t4[y4] && (k3 = t4[y4]);
- const n4 = e3[o5.fontStack];
- if (!n4)
- continue;
- const s5 = n4.glyphs[y4];
- if (!s5)
- continue;
- if (v5 = s5.metrics, I2 = 8203 !== y4 ? cc : 0, m3) {
- 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;
- w2 < r4 && (w2 = r4, A2 = (t5 - e4) / 2 * g4), M2 = -t5 * g4;
- } else
- M2 = (i5 - g4) * cc - 17;
- }
- 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);
- }
- 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;
- const k2 = s3 * i5 + _4;
- v4.lineOffset = Math.max(_4, o4), f3 += k2, ++g3;
- }
- var x3;
- const v3 = f3, { horizontalAlign: b3, verticalAlign: _3 } = ah(a3);
- (function(t4, e4, r4, n4, i5, s4) {
- const a4 = (e4 - r4) * i5, o4 = -s4 * n4;
- for (const e5 of t4)
- for (const t5 of e5.positionedGlyphs)
- t5.x += a4, t5.y += o4;
- })(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;
- }(_2, e2, r2, n2, g2, a2, o2, l2, h2, u2, p2, y2), !function(t3) {
- for (const e3 of t3)
- if (0 !== e3.positionedGlyphs.length)
- return false;
- return true;
- }(b2) && _2;
- }
- 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 };
- function th(t2, e2, r2, n2, i3, s2) {
- if (e2.imageName) {
- const t3 = n2[e2.imageName];
- return t3 ? t3.displaySize[0] * e2.scale * cc / s2 + i3 : 0;
- }
- {
- const n3 = r2[e2.fontStack], s3 = n3 && n3.glyphs[t2];
- return s3 ? s3.metrics.advance * e2.scale + i3 : 0;
- }
- }
- function eh(t2, e2, r2, n2) {
- const i3 = Math.pow(t2 - e2, 2);
- return n2 ? t2 < e2 ? i3 / 2 : 2 * i3 : i3 + Math.abs(r2) * r2;
- }
- function rh(t2, e2, r2) {
- let n2 = 0;
- return 10 === t2 && (n2 -= 1e4), r2 && (n2 += 150), 40 !== t2 && 65288 !== t2 || (n2 += 50), 41 !== e2 && 65289 !== e2 || (n2 += 50), n2;
- }
- function nh(t2, e2, r2, n2, i3, s2) {
- let a2 = null, o2 = eh(e2, r2, i3, s2);
- for (const t3 of n2) {
- const n3 = eh(e2 - t3.x, r2, i3, s2) + t3.badness;
- n3 <= o2 && (a2 = t3, o2 = n3);
- }
- return { index: t2, x: e2, priorBreak: a2, badness: o2 };
- }
- function ih(t2) {
- return t2 ? ih(t2.priorBreak).concat(t2.index) : [];
- }
- function sh(t2, e2, r2, n2, i3, s2, a2) {
- if ("point" !== s2)
- return [];
- if (!t2)
- return [];
- const o2 = [], l2 = function(t3, e3, r3, n3, i4, s3) {
- let a3 = 0;
- for (let r4 = 0; r4 < t3.length(); r4++) {
- const o3 = t3.getSection(r4);
- a3 += th(t3.getCharCode(r4), o3, n3, i4, e3, s3);
- }
- return a3 / Math.max(1, Math.ceil(a3 / r3));
- }(t2, e2, r2, n2, i3, a2), u2 = t2.text.indexOf("") >= 0;
- let c2 = 0;
- for (let r3 = 0; r3 < t2.length(); r3++) {
- const s3 = t2.getSection(r3), p2 = t2.getCharCode(r3);
- if (Jc[p2] || (c2 += th(p2, s3, n2, i3, e2, a2)), r3 < t2.length() - 1) {
- 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)));
- (Qc[p2] || e3 || s3.imageName) && o2.push(nh(r3 + 1, c2, l2, o2, rh(p2, t2.getCharCode(r3 + 1), e3 && u2), false));
- }
- }
- var h2;
- return ih(nh(t2.length(), c2, l2, o2, 0, true));
- }
- function ah(t2) {
- let e2 = 0.5, r2 = 0.5;
- switch (t2) {
- case "right":
- case "top-right":
- case "bottom-right":
- e2 = 1;
- break;
- case "left":
- case "top-left":
- case "bottom-left":
- e2 = 0;
- }
- switch (t2) {
- case "bottom":
- case "bottom-right":
- case "bottom-left":
- r2 = 1;
- break;
- case "top":
- case "top-right":
- case "top-left":
- r2 = 0;
- }
- return { horizontalAlign: e2, verticalAlign: r2 };
- }
- function oh(t2, e2, r2, n2, i3) {
- if (!(e2 || r2 || n2 || i3))
- return;
- const s2 = t2.length - 1, a2 = t2[s2], o2 = (a2.x + a2.metrics.advance * a2.scale) * e2;
- for (let e3 = 0; e3 <= s2; e3++)
- t2[e3].x -= o2, t2[e3].y += r2 + n2 + i3;
- }
- function lh(t2, e2, r2) {
- const { horizontalAlign: n2, verticalAlign: i3 } = ah(r2), s2 = e2[0] - t2.displaySize[0] * n2, a2 = e2[1] - t2.displaySize[1] * i3;
- return { image: t2, top: a2, bottom: a2 + t2.displaySize[1], left: s2, right: s2 + t2.displaySize[0] };
- }
- function uh(t2, e2, r2, n2, i3, s2) {
- const a2 = t2.image;
- let o2;
- if (a2.content) {
- const t3 = a2.content, e3 = a2.pixelRatio || 1;
- o2 = [t3[0] / e3, t3[1] / e3, a2.displaySize[0] - t3[2] / e3, a2.displaySize[1] - t3[3] / e3];
- }
- const l2 = e2.left * s2, u2 = e2.right * s2;
- let c2, h2, p2, f2;
- "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]);
- const d2 = e2.top * s2, y2 = e2.bottom * s2;
- 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 };
- }
- class ch extends i2 {
- constructor(t2, e2, r2, n2, i3) {
- super(t2, e2), this.angle = n2, this.z = r2, void 0 !== i3 && (this.segment = i3);
- }
- clone() {
- return new ch(this.x, this.y, this.z, this.angle, this.segment);
- }
- }
- function hh(t2, e2, r2, n2, i3) {
- if (void 0 === e2.segment)
- return true;
- let s2 = e2, a2 = e2.segment + 1, o2 = 0;
- for (; o2 > -r2 / 2; ) {
- if (a2--, a2 < 0)
- return false;
- o2 -= t2[a2].dist(s2), s2 = t2[a2];
- }
- o2 += t2[a2].dist(t2[a2 + 1]), a2++;
- const l2 = [];
- let u2 = 0;
- for (; o2 < r2 / 2; ) {
- const e3 = t2[a2], r3 = t2[a2 + 1];
- if (!r3)
- return false;
- let s3 = t2[a2 - 1].angleTo(e3) - e3.angleTo(r3);
- 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; )
- u2 -= l2.shift().angleDelta;
- if (u2 > i3)
- return false;
- a2++, o2 += e3.dist(r3);
- }
- return true;
- }
- function ph(t2) {
- let e2 = 0;
- for (let r2 = 0; r2 < t2.length - 1; r2++)
- e2 += t2[r2].dist(t2[r2 + 1]);
- return e2;
- }
- function fh(t2, e2, r2) {
- return t2 ? 0.6 * e2 * r2 : 0;
- }
- function dh(t2, e2) {
- return Math.max(t2 ? t2.right - t2.left : 0, e2 ? e2.right - e2.left : 0);
- }
- function yh(t2, e2, r2, n2, i3, s2) {
- const a2 = fh(r2, i3, s2), o2 = dh(r2, n2) * s2;
- let l2 = 0;
- const u2 = ph(t2) / 2;
- for (let r3 = 0; r3 < t2.length - 1; r3++) {
- const n3 = t2[r3], i4 = t2[r3 + 1], s3 = n3.dist(i4);
- if (l2 + s3 > u2) {
- 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);
- return !a2 || hh(t2, f2, o2, a2, e2) ? f2 : void 0;
- }
- l2 += s3;
- }
- }
- function mh(t2, e2, r2, n2, i3, s2, a2, o2, l2) {
- 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;
- 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);
- }
- function gh(t2, e2, r2, n2, i3, s2, a2, o2, l2) {
- const u2 = s2 / 2, c2 = ph(t2);
- let h2 = 0, p2 = e2 - r2, f2 = [];
- for (let e3 = 0; e3 < t2.length - 1; e3++) {
- const a3 = t2[e3], o3 = t2[e3 + 1], d2 = a3.dist(o3), y2 = o3.angleTo(a3);
- for (; p2 + r2 < h2 + d2; ) {
- p2 += r2;
- const m2 = (p2 - h2) / d2, g2 = rr(a3.x, o3.x, m2), x2 = rr(a3.y, o3.y, m2);
- if (g2 >= 0 && g2 < l2 && x2 >= 0 && x2 < l2 && p2 - u2 >= 0 && p2 + u2 <= c2) {
- const r3 = new ch(g2, x2, 0, y2, e3);
- r3._round(), n2 && !hh(t2, r3, s2, n2, i3) || f2.push(r3);
- }
- }
- h2 += d2;
- }
- return o2 || f2.length || a2 || (f2 = gh(t2, h2 / 2, r2, n2, i3, s2, a2, true, l2)), f2;
- }
- function xh(t2, e2, r2, n2, s2) {
- const a2 = [];
- for (let o2 = 0; o2 < t2.length; o2++) {
- const l2 = t2[o2];
- let u2;
- for (let t3 = 0; t3 < l2.length - 1; t3++) {
- let o3 = l2[t3], c2 = l2[t3 + 1];
- 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)))));
- }
- }
- return a2;
- }
- ai(ch, "Anchor");
- const vh = 1e20;
- function bh(t2, e2, r2, n2, i3, s2, a2, o2, l2) {
- for (let u2 = e2; u2 < e2 + n2; u2++)
- _h(t2, r2 * s2 + u2, s2, i3, a2, o2, l2);
- for (let u2 = r2; u2 < r2 + i3; u2++)
- _h(t2, u2 * s2 + e2, 1, n2, a2, o2, l2);
- }
- function _h(t2, e2, r2, n2, i3, s2, a2) {
- s2[0] = 0, a2[0] = -vh, a2[1] = vh, i3[0] = t2[e2];
- for (let o2 = 1, l2 = 0, u2 = 0; o2 < n2; o2++) {
- i3[o2] = t2[e2 + o2 * r2];
- const n3 = o2 * o2;
- do {
- const t3 = s2[l2];
- u2 = (i3[o2] - i3[t3] + n3 - t3 * t3) / (o2 - t3) / 2;
- } while (u2 <= a2[l2] && --l2 > -1);
- l2++, s2[l2] = o2, a2[l2] = u2, a2[l2 + 1] = vh;
- }
- for (let o2 = 0, l2 = 0; o2 < n2; o2++) {
- for (; a2[l2 + 1] < o2; )
- l2++;
- const n3 = s2[l2], u2 = o2 - n3;
- t2[e2 + o2 * r2] = i3[n3] + u2 * u2;
- }
- }
- const wh = { none: 0, ideographs: 1, all: 2 };
- class Ah {
- constructor(t2, e2, r2) {
- this.requestManager = t2, this.localGlyphMode = e2, this.localFontFamily = r2, this.entries = {}, this.localGlyphs = { 200: {}, 400: {}, 500: {}, 900: {} };
- }
- setURL(t2) {
- this.url = t2;
- }
- getGlyphs(t2, e2) {
- const r2 = [];
- for (const e3 in t2)
- for (const n2 of t2[e3])
- r2.push({ stack: e3, id: n2 });
- x(r2, ({ stack: t3, id: e3 }, r3) => {
- let n2 = this.entries[t3];
- n2 || (n2 = this.entries[t3] = { glyphs: {}, requests: {}, ranges: {}, ascender: void 0, descender: void 0 });
- let i3 = n2.glyphs[e3];
- if (void 0 !== i3)
- return void r3(null, { stack: t3, id: e3, glyph: i3 });
- if (i3 = this._tinySDF(n2, t3, e3), i3)
- return n2.glyphs[e3] = i3, void r3(null, { stack: t3, id: e3, glyph: i3 });
- const s2 = Math.floor(e3 / 256);
- if (256 * s2 > 65535)
- return void r3(new Error("glyphs > 65535 not supported"));
- if (n2.ranges[s2])
- return void r3(null, { stack: t3, id: e3, glyph: i3 });
- let a2 = n2.requests[s2];
- a2 || (a2 = n2.requests[s2] = [], Ah.loadGlyphRange(t3, s2, this.url, this.requestManager, (t4, e4) => {
- if (e4) {
- n2.ascender = e4.ascender, n2.descender = e4.descender;
- for (const t5 in e4.glyphs)
- this._doesCharSupportLocalGlyph(+t5) || (n2.glyphs[+t5] = e4.glyphs[+t5]);
- n2.ranges[s2] = true;
- }
- for (const r4 of a2)
- r4(t4, e4);
- delete n2.requests[s2];
- })), a2.push((n3, i4) => {
- n3 ? r3(n3) : i4 && r3(null, { stack: t3, id: e3, glyph: i4.glyphs[e3] || null });
- });
- }, (t3, r3) => {
- if (t3)
- e2(t3);
- else if (r3) {
- const t4 = {};
- for (const { stack: e3, id: n2, glyph: i3 } of r3)
- 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;
- e2(null, t4);
- }
- });
- }
- _doesCharSupportLocalGlyph(t2) {
- return this.localGlyphMode !== wh.none && (this.localGlyphMode === wh.all ? !!this.localFontFamily : !!this.localFontFamily && (Ti(t2) || Ei(t2) || vi(t2) || bi(t2) || xi(t2)));
- }
- _tinySDF(t2, e2, r2) {
- const n2 = this.localFontFamily;
- if (!n2 || !this._doesCharSupportLocalGlyph(r2))
- return;
- let i3 = t2.tinySDF;
- if (!i3) {
- let r3 = "400";
- /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;
- }
- if (this.localGlyphs[i3.fontWeight][r2])
- return this.localGlyphs[i3.fontWeight][r2];
- const s2 = String.fromCharCode(r2), { data: a2, width: o2, height: l2, glyphWidth: u2, glyphHeight: c2, glyphLeft: h2, glyphTop: p2, glyphAdvance: f2 } = i3.draw(s2);
- 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 } };
- }
- }
- function kh(t2, e2, r2, n2) {
- 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;
- let v2 = 0, b2 = y2, _2 = 0, w2 = m2, A2 = 0, k2 = g2, S2 = 0, I2 = x2;
- if (a2.content && n2) {
- const t3 = a2.content;
- 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;
- }
- const M2 = (n3, s3, l3, u3) => {
- 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;
- if (F2) {
- const t3 = Math.sin(F2), e3 = Math.cos(F2), r3 = [e3, -t3, t3, e3];
- B2._matMult(r3), E2._matMult(r3), D2._matMult(r3), C2._matMult(r3);
- }
- const L2 = n3.stretch + n3.fixed, R2 = s3.stretch + s3.fixed;
- 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 };
- };
- if (n2 && (a2.stretchX || a2.stretchY)) {
- const t3 = Ih(p2, g2, y2), e3 = Ih(f2, x2, m2);
- for (let r3 = 0; r3 < t3.length - 1; r3++) {
- const n3 = t3[r3], i3 = t3[r3 + 1];
- for (let t4 = 0; t4 < e3.length - 1; t4++)
- s2.push(M2(n3, e3[t4], i3, e3[t4 + 1]));
- }
- } else
- s2.push(M2({ fixed: 0, stretch: -1 }, { fixed: 0, stretch: -1 }, { fixed: 0, stretch: l2 + 1 }, { fixed: 0, stretch: u2 + 1 }));
- return s2;
- }
- function Sh(t2, e2, r2) {
- let n2 = 0;
- for (const i3 of t2)
- n2 += Math.max(e2, Math.min(r2, i3[1])) - Math.max(e2, Math.min(r2, i3[0]));
- return n2;
- }
- function Ih(t2, e2, r2) {
- const n2 = [{ fixed: -1, stretch: 0 }];
- for (const [e3, r3] of t2) {
- const t3 = n2[n2.length - 1];
- n2.push({ fixed: e3 - t3.stretch, stretch: t3.stretch }), n2.push({ fixed: e3 - t3.stretch, stretch: t3.stretch + (r3 - e3) });
- }
- return n2.push({ fixed: e2 + 1, stretch: r2 }), n2;
- }
- function Mh(t2, e2, r2, n2) {
- return t2 / e2 * r2 + n2;
- }
- function Th(t2, e2, r2, n2) {
- return t2 - e2 * r2 / n2;
- }
- function zh(t2, e2, r2, n2) {
- const i3 = e2 + t2.positionedLines[n2].lineOffset;
- return 0 === n2 ? r2 + i3 / 2 : r2 + (i3 + (e2 + t2.positionedLines[n2 - 1].lineOffset)) / 2;
- }
- Ah.loadGlyphRange = function(t2, e2, r2, n2, i3) {
- const s2 = 256 * e2, a2 = s2 + 255, o2 = n2.transformRequest(n2.normalizeGlyphsURL(r2).replace("{fontstack}", t2).replace("{range}", `${s2}-${a2}`), At.Glyphs);
- Mt(o2, (t3, e3) => {
- if (t3)
- i3(t3);
- else if (e3) {
- const t4 = {}, r3 = function(t5) {
- return new wc(t5).readFields(Oc, {});
- }(e3);
- for (const e4 of r3.glyphs)
- t4[e4.id] = e4;
- i3(null, { glyphs: t4, ascender: r3.ascender, descender: r3.descender });
- }
- });
- }, Ah.TinySDF = class {
- constructor({ fontSize: t2 = 24, buffer: e2 = 3, radius: r2 = 8, cutoff: n2 = 0.25, fontFamily: i3 = "sans-serif", fontWeight: s2 = "normal", fontStyle: a2 = "normal" }) {
- this.buffer = e2, this.cutoff = n2, this.radius = r2;
- const o2 = this.size = t2 + 4 * e2, l2 = this._createCanvas(o2), u2 = this.ctx = l2.getContext("2d", { willReadFrequently: true });
- 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);
- }
- _createCanvas(t2) {
- const e2 = document.createElement("canvas");
- return e2.width = e2.height = t2, e2;
- }
- draw(t2) {
- 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 };
- if (0 === o2 || 0 === l2)
- return f2;
- const { ctx: d2, buffer: y2, gridInner: m2, gridOuter: g2 } = this;
- d2.clearRect(y2, y2, o2, l2), d2.fillText(t2, y2, y2 + a2 + 1);
- const x2 = d2.getImageData(y2, y2, o2, l2);
- g2.fill(vh, 0, h2), m2.fill(0, 0, h2);
- for (let t3 = 0; t3 < l2; t3++)
- for (let e3 = 0; e3 < o2; e3++) {
- const r3 = x2.data[4 * (t3 * o2 + e3) + 3] / 255;
- if (0 === r3)
- continue;
- const n3 = (t3 + y2) * u2 + e3 + y2;
- if (1 === r3)
- g2[n3] = 0, m2[n3] = vh;
- else {
- const t4 = 0.5 - r3;
- g2[n3] = t4 > 0 ? t4 * t4 : 0, m2[n3] = t4 < 0 ? t4 * t4 : 0;
- }
- }
- 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);
- for (let t3 = 0; t3 < h2; t3++) {
- const e3 = Math.sqrt(g2[t3]) - Math.sqrt(m2[t3]);
- p2[t3] = Math.round(255 - 255 * (e3 / this.radius + this.cutoff));
- }
- return f2;
- }
- };
- class Bh {
- constructor(t2 = [], e2 = Eh) {
- if (this.data = t2, this.length = this.data.length, this.compare = e2, this.length > 0)
- for (let t3 = (this.length >> 1) - 1; t3 >= 0; t3--)
- this._down(t3);
- }
- push(t2) {
- this.data.push(t2), this.length++, this._up(this.length - 1);
- }
- pop() {
- if (0 === this.length)
- return;
- const t2 = this.data[0], e2 = this.data.pop();
- return this.length--, this.length > 0 && (this.data[0] = e2, this._down(0)), t2;
- }
- peek() {
- return this.data[0];
- }
- _up(t2) {
- const { data: e2, compare: r2 } = this, n2 = e2[t2];
- for (; t2 > 0; ) {
- const i3 = t2 - 1 >> 1, s2 = e2[i3];
- if (r2(n2, s2) >= 0)
- break;
- e2[t2] = s2, t2 = i3;
- }
- e2[t2] = n2;
- }
- _down(t2) {
- const { data: e2, compare: r2 } = this, n2 = this.length >> 1, i3 = e2[t2];
- for (; t2 < n2; ) {
- let n3 = 1 + (t2 << 1), s2 = e2[n3];
- const a2 = n3 + 1;
- if (a2 < this.length && r2(e2[a2], s2) < 0 && (n3 = a2, s2 = e2[a2]), r2(s2, i3) >= 0)
- break;
- e2[t2] = s2, t2 = n3;
- }
- e2[t2] = i3;
- }
- }
- function Eh(t2, e2) {
- return t2 < e2 ? -1 : t2 > e2 ? 1 : 0;
- }
- function Ch(t2, e2 = 1, r2 = false) {
- let n2 = 1 / 0, s2 = 1 / 0, a2 = -1 / 0, o2 = -1 / 0;
- const l2 = t2[0];
- for (let t3 = 0; t3 < l2.length; t3++) {
- const e3 = l2[t3];
- (!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);
- }
- const u2 = Math.min(a2 - n2, o2 - s2);
- let c2 = u2 / 2;
- const h2 = new Bh([], Dh);
- if (0 === u2)
- return new i2(n2, s2);
- for (let e3 = n2; e3 < a2; e3 += u2)
- for (let r3 = s2; r3 < o2; r3 += u2)
- h2.push(new Ph(e3 + c2, r3 + c2, c2, t2));
- let p2 = function(t3) {
- let e3 = 0, r3 = 0, n3 = 0;
- const i3 = t3[0];
- for (let t4 = 0, s3 = i3.length, a3 = s3 - 1; t4 < s3; a3 = t4++) {
- const s4 = i3[t4], o3 = i3[a3], l3 = s4.x * o3.y - o3.x * s4.y;
- r3 += (s4.x + o3.x) * l3, n3 += (s4.y + o3.y) * l3, e3 += 3 * l3;
- }
- return new Ph(r3 / e3, n3 / e3, 0, t3);
- }(t2), f2 = h2.length;
- for (; h2.length; ) {
- const n3 = h2.pop();
- (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);
- }
- return r2 && (console.log(`num probes: ${f2}`), console.log(`best distance: ${p2.d}`)), p2.p;
- }
- function Dh(t2, e2) {
- return e2.max - t2.max;
- }
- function Ph(t2, e2, r2, n2) {
- this.p = new i2(t2, e2), this.h = r2, this.d = function(t3, e3) {
- let r3 = false, n3 = 1 / 0;
- for (let i3 = 0; i3 < e3.length; i3++) {
- const s2 = e3[i3];
- for (let e4 = 0, i4 = s2.length, a2 = i4 - 1; e4 < i4; a2 = e4++) {
- const i5 = s2[e4], o2 = s2[a2];
- 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));
- }
- }
- return (r3 ? 1 : -1) * Math.sqrt(n3);
- }(this.p, n2), this.max = this.d + this.h * Math.SQRT2;
- }
- const Vh = Number.POSITIVE_INFINITY, Fh = Math.sqrt(2);
- function Lh(t2, e2) {
- return e2[1] !== Vh ? function(t3, e3, r2) {
- let n2 = 0, i3 = 0;
- switch (e3 = Math.abs(e3), r2 = Math.abs(r2), t3) {
- case "top-right":
- case "top-left":
- case "top":
- i3 = r2 - 7;
- break;
- case "bottom-right":
- case "bottom-left":
- case "bottom":
- i3 = 7 - r2;
- }
- switch (t3) {
- case "top-right":
- case "bottom-right":
- case "right":
- n2 = -e3;
- break;
- case "top-left":
- case "bottom-left":
- case "left":
- n2 = e3;
- }
- return [n2, i3];
- }(t2, e2[0], e2[1]) : function(t3, e3) {
- let r2 = 0, n2 = 0;
- e3 < 0 && (e3 = 0);
- const i3 = e3 / Fh;
- switch (t3) {
- case "top-right":
- case "top-left":
- n2 = i3 - 7;
- break;
- case "bottom-right":
- case "bottom-left":
- n2 = 7 - i3;
- break;
- case "bottom":
- n2 = 7 - e3;
- break;
- case "top":
- n2 = e3 - 7;
- }
- switch (t3) {
- case "top-right":
- case "bottom-right":
- r2 = -i3;
- break;
- case "top-left":
- case "bottom-left":
- r2 = i3;
- break;
- case "left":
- r2 = e3;
- break;
- case "right":
- r2 = -e3;
- }
- return [r2, n2];
- }(t2, e2[0]);
- }
- function Rh(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2) {
- t2.createArrays(), t2.tilePixelRatio = Ya / (512 * t2.overscaling), t2.compareText = {}, t2.iconsNeedLinear = false;
- const c2 = t2.layers[0].layout, h2 = t2.layers[0]._unevaluatedLayout._values, p2 = {};
- if ("composite" === t2.textSizeData.kind) {
- const { minZoom: e3, maxZoom: r3 } = t2.textSizeData;
- p2.compositeTextSizes = [h2["text-size"].possiblyEvaluate(new ss(e3), o2), h2["text-size"].possiblyEvaluate(new ss(r3), o2)];
- }
- if ("composite" === t2.iconSizeData.kind) {
- const { minZoom: e3, maxZoom: r3 } = t2.iconSizeData;
- p2.compositeIconSizes = [h2["icon-size"].possiblyEvaluate(new ss(e3), o2), h2["icon-size"].possiblyEvaluate(new ss(r3), o2)];
- }
- 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);
- const f2 = "map" === c2.get("text-rotation-alignment") && "point" !== c2.get("symbol-placement"), d2 = c2.get("text-size");
- for (const s3 of t2.features) {
- 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;
- let x2, v2 = [0, 0];
- if (g2) {
- 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");
- if (!x3) {
- const t3 = c2.get("text-radial-offset").evaluate(s3, {}, o2);
- v2 = t3 ? Lh(d3, [t3 * cc, Vh]) : c2.get("text-offset").evaluate(s3, {}, o2).map((t4) => t4 * cc);
- }
- let b3 = f2 ? "center" : c2.get("text-justify").evaluate(s3, {}, o2);
- const _3 = c2.get("symbol-placement"), w2 = "point" === _3, A2 = "point" === _3 ? c2.get("text-max-width").evaluate(s3, {}, o2) * cc : 0, k2 = (s4) => {
- t2.allowVerticalPlacement && Ui(n3) && (m2.vertical = Wc(g2, e2, r2, i3, l3, A2, u3, d3, s4, p3, v2, Kc.vertical, true, _3, y2, h3));
- };
- if (!f2 && x3) {
- const t3 = "auto" === b3 ? x3.map((t4) => Uh(t4)) : [b3];
- let n4 = false;
- for (let s4 = 0; s4 < t3.length; s4++) {
- const a4 = t3[s4];
- if (!m2.horizontal[a4])
- if (n4)
- m2.horizontal[a4] = m2.horizontal[0];
- else {
- const t4 = Wc(g2, e2, r2, i3, l3, A2, u3, "center", a4, p3, v2, Kc.horizontal, false, _3, y2, h3);
- t4 && (m2.horizontal[a4] = t4, n4 = 1 === t4.positionedLines.length);
- }
- }
- k2("left");
- } else {
- if ("auto" === b3 && (b3 = Uh(d3)), w2 || c2.get("text-writing-mode").indexOf("horizontal") >= 0 || !Ui(n3)) {
- const t3 = Wc(g2, e2, r2, i3, l3, A2, u3, d3, b3, p3, v2, Kc.horizontal, false, _3, y2, h3);
- t3 && (m2.horizontal[b3] = t3);
- }
- k2("point" === _3 ? "left" : b3);
- }
- }
- let b2 = false;
- if (s3.icon && s3.icon.name) {
- const e3 = n2[s3.icon.name];
- 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));
- }
- const _2 = qh(m2.horizontal) || m2.vertical;
- t2.iconsInText || (t2.iconsInText = !!_2 && _2.iconsInText), (_2 || x2) && $h(t2, s3, m2, x2, n2, p2, y2, 0, v2, b2, a2, o2, u2);
- }
- s2 && t2.generateCollisionDebugBuffers(l2, t2.collisionBoxArray);
- }
- function Uh(t2) {
- switch (t2) {
- case "right":
- case "top-right":
- case "bottom-right":
- return "right";
- case "left":
- case "top-left":
- case "bottom-left":
- return "left";
- }
- return "center";
- }
- function $h(t2, e2, r2, n2, i3, s2, a2, o2, l2, c2, h2, p2, f2) {
- let d2 = s2.textMaxSize.evaluate(e2, {}, p2);
- void 0 === d2 && (d2 = a2);
- 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;
- var T2;
- const z2 = y2.get("icon-text-fit");
- let B2;
- 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)));
- const E2 = (a3, o3, u2) => {
- if (o3.x < 0 || o3.x >= Ya || o3.y < 0 || o3.y >= Ya)
- return;
- const { x: d3, y: y3, z: g3 } = f2.projectTilePoint(o3.x, o3.y, u2), x3 = new ch(d3, y3, g3, 0, void 0);
- !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) {
- const S3 = t3.addToLineVertexArray(e3, n3);
- let I3, M3, T3, z3, B3, E3, D2, P2 = 0, V2 = 0, F2 = 0, L2 = 0, R2 = -1, U2 = -1;
- const $2 = {};
- let j2 = xa(""), O2 = 0, q2 = 0;
- 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) {
- const t4 = i4.vertical;
- if (d4)
- E3 = Gh(t4), o4 && (D2 = Gh(o4));
- else {
- const n4 = l3.layout.get("text-rotate").evaluate(b3, {}, k3) + 90;
- T3 = Nh(u3, r3, e3, c3, h3, p3, t4, f3, n4, y4), o4 && (z3 = Nh(u3, r3, e3, c3, h3, p3, o4, g4, n4));
- }
- }
- if (s3) {
- 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;
- M3 = Nh(u3, r3, e3, c3, h3, p3, s3, g4, n4), P2 = 4 * a5.length;
- const d5 = t3.iconSizeData;
- let y5 = null;
- "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);
- }
- for (const n4 in i4.horizontal) {
- const s4 = i4.horizontal[n4];
- 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));
- const o5 = 1 === s4.positionedLines.length;
- 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)
- break;
- }
- i4.vertical && (L2 += Oh(t3, r3, e3, i4.vertical, a4, l3, d4, b3, y4, S3, Kc.vertical, ["vertical"], $2, U2, _3, A3, k3));
- let N2 = -1;
- const G2 = (t4, e4) => t4 ? Math.max(t4, e4) : e4;
- N2 = G2(B3, N2), N2 = G2(E3, N2), N2 = G2(D2, N2);
- const Z2 = N2 > -1 ? 1 : 0;
- 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);
- }(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);
- };
- if ("line" === I2)
- for (const i4 of xh(e2.geometry, 0, 0, Ya, Ya)) {
- const e3 = mh(i4, b2, A2, r2.vertical || g2, n2, 24, v2, t2.overscaling, Ya);
- for (const r3 of e3) {
- const e4 = g2;
- e4 && Zh(t2, e4.text, M2, r3) || E2(i4, r3, p2);
- }
- }
- else if ("line-center" === I2) {
- for (const t3 of e2.geometry)
- if (t3.length > 1) {
- const e3 = yh(t3, A2, r2.vertical || g2, n2, 24, v2);
- e3 && E2(t3, e3, p2);
- }
- } else if ("Polygon" === e2.type)
- for (const t3 of du(e2.geometry, 0)) {
- const e3 = Ch(t3, 16);
- E2(t3[0], new ch(e3.x, e3.y, 0, 0, void 0), p2);
- }
- else if ("LineString" === e2.type)
- for (const t3 of e2.geometry)
- E2(t3, new ch(t3[0].x, t3[0].y, 0, 0, void 0), p2);
- else if ("Point" === e2.type)
- for (const t3 of e2.geometry)
- for (const e3 of t3)
- E2([e3], new ch(e3.x, e3.y, 0, 0, void 0), p2);
- }
- const jh = 32640;
- function Oh(t2, e2, r2, n2, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2, m2, g2) {
- const x2 = function(t3, e3, r3, n3, s3, a3, o3, l3) {
- const u3 = [];
- if (0 === e3.positionedLines.length)
- return u3;
- const c3 = n3.layout.get("text-rotate").evaluate(a3, {}) * Math.PI / 180, h3 = function(t4) {
- const e4 = t4[0], r4 = t4[1], n4 = e4 * r4;
- return n4 > 0 ? [e4, -r4] : n4 < 0 ? [-e4, r4] : 0 === e4 ? [r4, e4] : [r4, -e4];
- }(r3);
- let p3 = Math.abs(e3.top - e3.bottom);
- for (const t4 of e3.positionedLines)
- p3 -= t4.lineOffset;
- const f3 = e3.positionedLines.length, d3 = p3 / f3;
- let y3 = e3.top - r3[1];
- for (let t4 = 0; t4 < f3; ++t4) {
- const n4 = e3.positionedLines[t4];
- y3 = zh(e3, d3, y3, t4);
- for (const t5 of n4.positionedGlyphs) {
- if (!t5.rect)
- continue;
- const n5 = t5.rect || {};
- let a4 = 4, p4 = true, f4 = 1, d4 = 0;
- if (t5.imageName) {
- const e4 = o3[t5.imageName];
- if (!e4)
- continue;
- if (e4.sdf) {
- C("SDF images are not supported in formatted text and will be ignored.");
- continue;
- }
- p4 = false, f4 = e4.pixelRatio, a4 = 1 / f4;
- }
- const m3 = (s3 || l3) && t5.vertical, g3 = t5.metrics.advance * t5.scale / 2, x3 = t5.metrics, v3 = t5.rect;
- if (null === v3)
- continue;
- l3 && e3.verticalizable && (d4 = t5.imageName ? g3 - t5.metrics.width * t5.scale / 2 : 0);
- const b3 = s3 ? [t5.x + g3, t5.y] : [0, 0];
- let _2 = [0, 0], w2 = [0, 0], A2 = false;
- 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]);
- const k2 = v3.w * t5.scale / (f4 * (t5.localGlyph ? 2 : 1)), S2 = v3.h * t5.scale / (f4 * (t5.localGlyph ? 2 : 1));
- let I2, M2, T2, z2;
- if (m3) {
- const e4 = t5.y - y3, r4 = new i2(-g3, g3 - e4), n6 = -Math.PI / 2, s4 = new i2(...w2);
- 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;
- const o4 = t5.imageName ? x3.advance * t5.scale : cc * t5.scale, l4 = String.fromCharCode(t5.glyph);
- 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);
- } else {
- const e4 = (x3.left - a4) * t5.scale - g3 + _2[0], r4 = (-x3.top - a4) * t5.scale + _2[1], n6 = e4 + k2, s4 = r4 + S2;
- I2 = new i2(e4, r4), M2 = new i2(n6, r4), T2 = new i2(e4, s4), z2 = new i2(n6, s4);
- }
- if (c3) {
- let t6;
- 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);
- }
- const B2 = new i2(0, 0), E2 = new i2(0, 0);
- 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 });
- }
- }
- return u3;
- }(0, n2, u2, a2, o2, l2, s2, t2.allowVerticalPlacement), v2 = t2.textSizeData;
- let b2 = null;
- "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);
- for (const e3 of p2)
- f2[e3] = t2.text.placedSymbolArray.length - 1;
- return 4 * x2.length;
- }
- function qh(t2) {
- for (const e2 in t2)
- return t2[e2];
- return null;
- }
- function Nh(t2, e2, r2, n2, s2, a2, o2, l2, c2, h2) {
- let p2 = o2.top, f2 = o2.bottom, d2 = o2.left, y2 = o2.right;
- const m2 = o2.collisionPadding;
- if (m2 && (d2 -= m2[0], p2 -= m2[1], y2 += m2[2], f2 += m2[3]), c2) {
- const t3 = new i2(d2, p2), e3 = new i2(y2, p2), r3 = new i2(d2, f2), n3 = new i2(y2, f2), s3 = u(c2);
- let a3 = new i2(0, 0);
- 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);
- }
- return t2.emplaceBack(e2.x, e2.y, e2.z, r2.x, r2.y, d2, p2, y2, f2, l2, n2, s2, a2), t2.length - 1;
- }
- function Gh(t2) {
- t2.collisionPadding && (t2.top -= t2.collisionPadding[1], t2.bottom += t2.collisionPadding[3]);
- const e2 = t2.bottom - t2.top;
- return e2 > 0 ? Math.max(10, e2) : null;
- }
- function Zh(t2, e2, r2, n2) {
- const i3 = t2.compareText;
- if (e2 in i3) {
- const t3 = i3[e2];
- for (let e3 = t3.length - 1; e3 >= 0; e3--)
- if (n2.dist(t3[e3]) < r2)
- return true;
- } else
- i3[e2] = [];
- return i3[e2].push(n2), false;
- }
- const Xh = Du.VectorTileFeature.types, Kh = [{ name: "a_fade_opacity", components: 1, type: "Uint8", offset: 0 }];
- function Yh(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2) {
- const m2 = c2 ? Math.min(jh, Math.round(c2[0])) : 0, g2 = c2 ? Math.min(jh, Math.round(c2[1])) : 0;
- 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);
- }
- function Hh(t2, e2, r2) {
- 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);
- }
- function Wh(t2) {
- for (const e2 of t2.sections)
- if (Zi(e2.text))
- return true;
- return false;
- }
- class Jh {
- constructor(t2) {
- 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();
- }
- isEmpty() {
- return 0 === this.layoutVertexArray.length && 0 === this.indexArray.length && 0 === this.dynamicLayoutVertexArray.length && 0 === this.opacityVertexArray.length;
- }
- upload(t2, e2, r2, n2) {
- 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));
- }
- destroy() {
- this.layoutVertexBuffer && (this.layoutVertexBuffer.destroy(), this.indexBuffer.destroy(), this.programConfigurations.destroy(), this.segments.destroy(), this.dynamicLayoutVertexBuffer.destroy(), this.opacityVertexBuffer.destroy());
- }
- }
- ai(Jh, "SymbolBuffers");
- class Qh {
- constructor(t2, e2, r2) {
- this.layoutVertexArray = new t2(), this.layoutAttributes = e2, this.indexArray = new r2(), this.segments = new Ka(), this.collisionVertexArray = new $s(), this.collisionVertexArrayExt = new Vs();
- }
- upload(t2) {
- 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);
- }
- destroy() {
- this.layoutVertexBuffer && (this.layoutVertexBuffer.destroy(), this.indexBuffer.destroy(), this.segments.destroy(), this.collisionVertexBuffer.destroy(), this.collisionVertexBufferExt.destroy());
- }
- }
- ai(Qh, "CollisionBuffers");
- class tp {
- constructor(t2) {
- 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([]);
- const e2 = this.layers[0]._unevaluatedLayout._values;
- this.textSizeData = pc(this.zoom, e2["text-size"]), this.iconSizeData = pc(this.zoom, e2["icon-size"]);
- const r2 = this.layers[0].layout, n2 = r2.get("symbol-sort-key"), i3 = r2.get("symbol-z-order");
- 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;
- }
- createArrays() {
- 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();
- }
- calculateGlyphDependencies(t2, e2, r2, n2, i3) {
- for (let r3 = 0; r3 < t2.length; r3++)
- if (e2[t2.charCodeAt(r3)] = true, n2 && i3) {
- const n3 = gc[t2.charAt(r3)];
- n3 && (e2[n3.charCodeAt(0)] = true);
- }
- }
- populate(t2, e2, r2, n2) {
- 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");
- if (this.features = [], !u2 && !c2)
- return;
- const p2 = e2.iconDependencies, f2 = e2.glyphDependencies, d2 = e2.availableImages, y2 = new ss(this.zoom);
- for (const { feature: e3, id: o3, index: l3, sourceLayerIndex: m2 } of t2) {
- const t3 = i3._featureFilter.needGeometry, g2 = mo(e3, t3);
- if (!i3._featureFilter.filter(y2, g2, r2))
- continue;
- let x2, v2;
- if (t3 || (g2.geometry = yo(e3, r2, n2)), u2) {
- const t4 = i3.getValueAndResolveTokens("text-field", g2, r2, d2), e4 = fe.factory(t4);
- Wh(e4) && (this.hasRTLText = true), (!this.hasRTLText || "unavailable" === rs() || this.hasRTLText && is.isParsed()) && (x2 = mc(e4, i3, g2));
- }
- if (c2) {
- const t4 = i3.getValueAndResolveTokens("icon-image", g2, r2, d2);
- v2 = t4 instanceof de ? t4 : de.fromString(t4);
- }
- if (!x2 && !v2)
- continue;
- const b2 = this.sortFeaturesByKey ? h2.evaluate(g2, {}, r2) : void 0;
- 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) {
- const t4 = a2.evaluate(g2, {}, r2).join(","), e4 = "map" === s2.get("text-rotation-alignment") && "point" !== s2.get("symbol-placement");
- this.allowVerticalPlacement = this.writingModes && this.writingModes.indexOf(Kc.vertical) >= 0;
- for (const r3 of x2.sections)
- if (r3.image)
- p2[r3.image.name] = true;
- else {
- const n3 = Ui(x2.toString()), i4 = r3.fontStack || t4, s3 = f2[i4] = f2[i4] || {};
- this.calculateGlyphDependencies(r3.text, s3, e4, this.allowVerticalPlacement, n3);
- }
- }
- }
- "line" === s2.get("symbol-placement") && (this.features = function(t3) {
- const e3 = {}, r3 = {}, n3 = [];
- let i4 = 0;
- function s3(e4) {
- n3.push(t3[e4]), i4++;
- }
- function a3(t4, e4, i5) {
- const s4 = r3[t4];
- return delete r3[t4], r3[e4] = s4, n3[s4].geometry[0].pop(), n3[s4].geometry[0] = n3[s4].geometry[0].concat(i5[0]), s4;
- }
- function o3(t4, r4, i5) {
- const s4 = e3[r4];
- return delete e3[r4], e3[t4] = s4, n3[s4].geometry[0].shift(), n3[s4].geometry[0] = i5[0].concat(n3[s4].geometry[0]), s4;
- }
- function l3(t4, e4, r4) {
- const n4 = r4 ? e4[0][e4[0].length - 1] : e4[0][0];
- return `${t4}:${n4.x}:${n4.y}`;
- }
- for (let u3 = 0; u3 < t3.length; u3++) {
- const c3 = t3[u3], h3 = c3.geometry, p3 = c3.text ? c3.text.toString() : null;
- if (!p3) {
- s3(u3);
- continue;
- }
- const f3 = l3(p3, h3), d3 = l3(p3, h3, true);
- if (f3 in r3 && d3 in e3 && r3[f3] !== e3[d3]) {
- const t4 = o3(f3, d3, h3), i5 = a3(f3, d3, n3[t4].geometry);
- delete e3[f3], delete r3[d3], r3[l3(p3, n3[i5].geometry, true)] = i5, n3[t4].geometry = null;
- } else
- f3 in r3 ? a3(f3, d3, h3) : d3 in e3 ? o3(f3, d3, h3) : (s3(u3), e3[f3] = i4 - 1, r3[d3] = i4 - 1);
- }
- return n3.filter((t4) => t4.geometry);
- }(this.features)), this.sortFeaturesByKey && this.features.sort((t3, e3) => t3.sortKey - e3.sortKey);
- }
- update(t2, e2, r2, n2) {
- this.stateDependentLayers.length && (this.text.programConfigurations.updatePaintArrays(t2, e2, this.layers, r2, n2), this.icon.programConfigurations.updatePaintArrays(t2, e2, this.layers, r2, n2));
- }
- isEmpty() {
- return 0 === this.symbolInstances.length && !this.hasRTLText;
- }
- uploadPending() {
- return !this.uploaded || this.text.programConfigurations.needsUpload || this.icon.programConfigurations.needsUpload;
- }
- upload(t2) {
- !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;
- }
- destroyDebugData() {
- this.textCollisionBox.destroy(), this.iconCollisionBox.destroy();
- }
- destroy() {
- this.text.destroy(), this.icon.destroy(), this.hasDebugData() && this.destroyDebugData();
- }
- addToLineVertexArray(t2, e2) {
- const r2 = this.lineVertexArray.length, n2 = t2.segment;
- if (void 0 !== n2) {
- let r3 = t2.dist(e2[n2 + 1]), i3 = t2.dist(e2[n2]);
- const s2 = {};
- for (let t3 = n2 + 1; t3 < e2.length; t3++)
- s2[t3] = { x: e2[t3].x, y: e2[t3].y, tileUnitDistanceFromAnchor: r3 }, t3 < e2.length - 1 && (r3 += e2[t3 + 1].dist(e2[t3]));
- for (let t3 = n2 || 0; t3 >= 0; t3--)
- s2[t3] = { x: e2[t3].x, y: e2[t3].y, tileUnitDistanceFromAnchor: i3 }, t3 > 0 && (i3 += e2[t3 - 1].dist(e2[t3]));
- for (let t3 = 0; t3 < e2.length; t3++) {
- const e3 = s2[t3];
- this.lineVertexArray.emplaceBack(e3.x, e3.y, e3.tileUnitDistanceFromAnchor);
- }
- }
- return { lineStartIndex: r2, lineLength: this.lineVertexArray.length - r2 };
- }
- addSymbols(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2, h2, p2, f2) {
- 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;
- for (let n3 = 0; n3 < e2.length; n3++) {
- 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];
- 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]);
- }
- 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);
- }
- _commitLayoutVertex(t2, e2, r2, n2, i3, s2, a2) {
- t2.emplaceBack(e2, r2, n2, i3, s2, Math.round(a2.x), Math.round(a2.y));
- }
- _addCollisionDebugVertices(t2, e2, r2, n2, s2, a2, o2) {
- const l2 = r2.segments.prepareSegment(4, r2.layoutVertexArray, r2.indexArray), u2 = l2.vertexLength, c2 = o2.tileAnchorX, h2 = o2.tileAnchorY;
- for (let t3 = 0; t3 < 4; t3++)
- r2.collisionVertexArray.emplaceBack(0, 0, 0, 0);
- 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;
- const p2 = r2.indexArray;
- 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;
- }
- _addTextDebugCollisionBoxes(t2, e2, r2, n2, i3, s2) {
- for (let a2 = n2; a2 < i3; a2++) {
- const n3 = r2.get(a2), i4 = this.getSymbolInstanceTextSize(t2, s2, e2, a2);
- this._addCollisionDebugVertices(n3, i4, this.textCollisionBox, n3.projectedAnchorX, n3.projectedAnchorY, n3.projectedAnchorZ, s2);
- }
- }
- _addIconDebugCollisionBoxes(t2, e2, r2, n2, i3, s2) {
- for (let a2 = n2; a2 < i3; a2++) {
- const n3 = r2.get(a2), i4 = this.getSymbolInstanceIconSize(t2, e2, a2);
- this._addCollisionDebugVertices(n3, i4, this.iconCollisionBox, n3.projectedAnchorX, n3.projectedAnchorY, n3.projectedAnchorZ, s2);
- }
- }
- generateCollisionDebugBuffers(t2, e2) {
- this.hasDebugData() && this.destroyDebugData(), this.textCollisionBox = new Qh(Rs, lc.members, Ks), this.iconCollisionBox = new Qh(Rs, lc.members, Ks);
- const r2 = dc(this.iconSizeData, t2), n2 = dc(this.textSizeData, t2);
- for (let i3 = 0; i3 < this.symbolInstances.length; i3++) {
- const s2 = this.symbolInstances.get(i3);
- 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);
- }
- }
- getSymbolInstanceTextSize(t2, e2, r2, n2) {
- 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;
- return this.tilePixelRatio * s2;
- }
- getSymbolInstanceIconSize(t2, e2, r2) {
- const n2 = this.icon.placedSymbolArray.get(r2), i3 = fc(this.iconSizeData, t2, n2);
- return this.tilePixelRatio * i3;
- }
- _commitDebugCollisionVertexUpdate(t2, e2, r2) {
- t2.emplaceBack(e2, -r2, -r2), t2.emplaceBack(e2, r2, -r2), t2.emplaceBack(e2, r2, r2), t2.emplaceBack(e2, -r2, r2);
- }
- _updateTextDebugCollisionBoxes(t2, e2, r2, n2, i3, s2) {
- for (let a2 = n2; a2 < i3; a2++) {
- const n3 = r2.get(a2), i4 = this.getSymbolInstanceTextSize(t2, s2, e2, a2);
- this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt, i4, n3.padding);
- }
- }
- _updateIconDebugCollisionBoxes(t2, e2, r2, n2, i3) {
- for (let s2 = n2; s2 < i3; s2++) {
- const n3 = r2.get(s2), i4 = this.getSymbolInstanceIconSize(t2, e2, s2);
- this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt, i4, n3.padding);
- }
- }
- updateCollisionDebugBuffers(t2, e2) {
- if (!this.hasDebugData())
- return;
- this.hasTextCollisionBoxData() && this.textCollisionBox.collisionVertexArrayExt.clear(), this.hasIconCollisionBoxData() && this.iconCollisionBox.collisionVertexArrayExt.clear();
- const r2 = dc(this.iconSizeData, t2), n2 = dc(this.textSizeData, t2);
- for (let i3 = 0; i3 < this.symbolInstances.length; i3++) {
- const s2 = this.symbolInstances.get(i3);
- 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);
- }
- this.hasTextCollisionBoxData() && this.textCollisionBox.collisionVertexBufferExt && this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt), this.hasIconCollisionBoxData() && this.iconCollisionBox.collisionVertexBufferExt && this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt);
- }
- _deserializeCollisionBoxesForSymbol(t2, e2, r2, n2, i3, s2, a2, o2, l2) {
- const u2 = {};
- for (let n3 = e2; n3 < r2; n3++) {
- const e3 = t2.get(n3);
- 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;
- break;
- }
- for (let e3 = n2; e3 < i3; e3++) {
- const r3 = t2.get(e3);
- 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;
- break;
- }
- for (let e3 = s2; e3 < a2; e3++) {
- const r3 = t2.get(e3);
- 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;
- break;
- }
- for (let e3 = o2; e3 < l2; e3++) {
- const r3 = t2.get(e3);
- 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;
- break;
- }
- return u2;
- }
- deserializeCollisionBoxes(t2) {
- this.collisionArrays = [];
- for (let e2 = 0; e2 < this.symbolInstances.length; e2++) {
- const r2 = this.symbolInstances.get(e2);
- this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t2, r2.textBoxStartIndex, r2.textBoxEndIndex, r2.verticalTextBoxStartIndex, r2.verticalTextBoxEndIndex, r2.iconBoxStartIndex, r2.iconBoxEndIndex, r2.verticalIconBoxStartIndex, r2.verticalIconBoxEndIndex));
- }
- }
- hasTextData() {
- return this.text.segments.get().length > 0;
- }
- hasIconData() {
- return this.icon.segments.get().length > 0;
- }
- hasDebugData() {
- return this.textCollisionBox && this.iconCollisionBox;
- }
- hasTextCollisionBoxData() {
- return this.hasDebugData() && this.textCollisionBox.segments.get().length > 0;
- }
- hasIconCollisionBoxData() {
- return this.hasDebugData() && this.iconCollisionBox.segments.get().length > 0;
- }
- addIndicesForPlacedSymbol(t2, e2) {
- const r2 = t2.placedSymbolArray.get(e2), n2 = r2.vertexStartIndex + 4 * r2.numGlyphs;
- for (let e3 = r2.vertexStartIndex; e3 < n2; e3 += 4)
- t2.indexArray.emplaceBack(e3, e3 + 1, e3 + 2), t2.indexArray.emplaceBack(e3 + 1, e3 + 2, e3 + 3);
- }
- getSortedSymbolIndexes(t2) {
- if (this.sortedAngle === t2 && void 0 !== this.symbolInstanceIndexes)
- return this.symbolInstanceIndexes;
- const e2 = Math.sin(t2), r2 = Math.cos(t2), n2 = [], i3 = [], s2 = [];
- for (let t3 = 0; t3 < this.symbolInstances.length; ++t3) {
- s2.push(t3);
- const a2 = this.symbolInstances.get(t3);
- n2.push(0 | Math.round(e2 * a2.tileAnchorX + r2 * a2.tileAnchorY)), i3.push(a2.featureIndex);
- }
- return s2.sort((t3, e3) => n2[t3] - n2[e3] || i3[e3] - i3[t3]), s2;
- }
- addToSortKeyRanges(t2, e2) {
- const r2 = this.sortKeyRanges[this.sortKeyRanges.length - 1];
- r2 && r2.sortKey === e2 ? r2.symbolInstanceEnd = t2 + 1 : this.sortKeyRanges.push({ sortKey: e2, symbolInstanceStart: t2, symbolInstanceEnd: t2 + 1 });
- }
- sortFeatures(t2) {
- if (this.sortFeaturesByY && this.sortedAngle !== t2 && !(this.text.segments.get().length > 1 || this.icon.segments.get().length > 1)) {
- this.symbolInstanceIndexes = this.getSortedSymbolIndexes(t2), this.sortedAngle = t2, this.text.indexArray.clear(), this.icon.indexArray.clear(), this.featureSortOrder = [];
- for (const t3 of this.symbolInstanceIndexes) {
- const e2 = this.symbolInstances.get(t3);
- this.featureSortOrder.push(e2.featureIndex), [e2.rightJustifiedTextSymbolIndex, e2.centerJustifiedTextSymbolIndex, e2.leftJustifiedTextSymbolIndex].forEach((t4, e3, r2) => {
- t4 >= 0 && r2.indexOf(t4) === e3 && this.addIndicesForPlacedSymbol(this.text, t4);
- }), 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);
- }
- this.text.indexBuffer && this.text.indexBuffer.updateData(this.text.indexArray), this.icon.indexBuffer && this.icon.indexBuffer.updateData(this.icon.indexArray);
- }
- }
- }
- ai(tp, "SymbolBucket", { omit: ["layers", "collisionBoxArray", "features", "compareText"] }), tp.MAX_GLYPHS = 65535, tp.addDynamicAttributes = Hh;
- 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"]) });
- 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 };
- class np {
- constructor(t2) {
- this.type = t2.property.overrides ? t2.property.overrides.runtimeType : Zt, this.defaultValue = t2;
- }
- evaluate(t2) {
- if (t2.formattedSection) {
- const e2 = this.defaultValue.property.overrides;
- if (e2 && e2.hasOverride(t2.formattedSection))
- return e2.getOverride(t2.formattedSection);
- }
- return t2.feature && t2.featureState ? this.defaultValue.evaluate(t2.feature, t2.featureState) : this.defaultValue.property.specification.default;
- }
- eachChild(t2) {
- this.defaultValue.isConstant() || t2(this.defaultValue.value._styleExpression.expression);
- }
- outputDefined() {
- return false;
- }
- serialize() {
- return null;
- }
- }
- ai(np, "FormatSectionOverride", { omit: ["defaultValue"] });
- class ip extends Ga {
- constructor(t2) {
- super(t2, rp);
- }
- recalculate(t2, e2) {
- 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"));
- const r2 = this.layout.get("text-writing-mode");
- if (r2) {
- const t3 = [];
- for (const e3 of r2)
- t3.indexOf(e3) < 0 && t3.push(e3);
- this.layout._values["text-writing-mode"] = t3;
- } else
- this.layout._values["text-writing-mode"] = "point" === this.layout.get("symbol-placement") ? ["horizontal"] : ["horizontal", "vertical"];
- this._setPaintOverrides();
- }
- getValueAndResolveTokens(t2, e2, r2, n2) {
- const i3 = this.layout.get(t2).evaluate(e2, {}, r2, n2), s2 = this._unevaluatedLayout._values[t2];
- return s2.isDataDriven() || un(s2.value) || !i3 ? i3 : function(t3, e3) {
- return e3.replace(/{([^{}]+)}/g, (e4, r3) => r3 in t3 ? String(t3[r3]) : "");
- }(e2.properties, i3);
- }
- createBucket(t2) {
- return new tp(t2);
- }
- queryRadius() {
- return 0;
- }
- queryIntersectsFeature() {
- return false;
- }
- _setPaintOverrides() {
- for (const t2 of rp.paint.overridableProperties) {
- if (!ip.hasPaintOverride(this.layout, t2))
- continue;
- const e2 = this.paint.get(t2), r2 = new np(e2), n2 = new ln(r2, e2.property.specification);
- let i3 = null;
- 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);
- }
- }
- _handleOverridablePaintPropertyUpdate(t2, e2, r2) {
- return !(!this.layout || e2.isDataDriven() || r2.isDataDriven()) && ip.hasPaintOverride(this.layout, t2);
- }
- static hasPaintOverride(t2, e2) {
- const r2 = t2.get("text-field"), n2 = rp.paint.properties[e2];
- let i3 = false;
- const s2 = (t3) => {
- for (const e3 of t3)
- if (n2.overrides && n2.overrides.hasOverride(e3))
- return void (i3 = true);
- };
- if ("constant" === r2.value.kind && r2.value.value instanceof fe)
- s2(r2.value.value.sections);
- else if ("source" === r2.value.kind) {
- const t3 = (e4) => {
- i3 || (e4 instanceof ve && ge(e4.value) === te ? s2(e4.value.sections) : e4 instanceof Ae ? s2(e4.sections) : e4.eachChild(t3));
- }, e3 = r2.value;
- e3._styleExpression && t3(e3._styleExpression.expression);
- }
- return i3;
- }
- getProgramConfiguration(t2) {
- return new La(this, t2);
- }
- }
- 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"]) }) };
- class op extends Ga {
- constructor(t2) {
- super(t2, {}), this.implementation = t2;
- }
- is3D() {
- return "3d" === this.implementation.renderingMode;
- }
- hasOffscreenPass() {
- return void 0 !== this.implementation.prerender;
- }
- recalculate() {
- }
- updateTransitions() {
- }
- hasTransition() {
- return false;
- }
- serialize() {
- }
- onAdd(t2) {
- this.implementation.onAdd && this.implementation.onAdd(t2, t2.painter.context.gl);
- }
- onRemove(t2) {
- this.implementation.onRemove && this.implementation.onRemove(t2, t2.painter.context.gl);
- }
- }
- 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"]) }) };
- function up(t2, e2, r2) {
- const n2 = [0, 0, 1], i3 = ml([]);
- return function(t3, e3, r3) {
- r3 *= 0.5;
- var n3 = e3[0], i4 = e3[1], s2 = e3[2], a2 = e3[3], o2 = Math.sin(r3), l2 = Math.cos(r3);
- t3[0] = n3 * l2 - s2 * o2, t3[1] = i4 * l2 + a2 * o2, t3[2] = s2 * l2 + n3 * o2, t3[3] = a2 * l2 - i4 * o2;
- }(i3, i3, r2 ? -u(t2) + Math.PI : u(t2)), gl(i3, i3, -u(e2)), ul(n2, n2, i3), sl(n2, n2);
- }
- const cp = { circle: class extends Ga {
- constructor(t2) {
- super(t2, Lo);
- }
- createBucket(t2) {
- return new vo(t2);
- }
- queryRadius(t2) {
- const e2 = t2;
- return Co("circle-radius", this, e2) + Co("circle-stroke-width", this, e2) + Do(this.paint.get("circle-translate"));
- }
- queryIntersectsFeature(t2, e2, r2, n2, i3, s2, a2, o2) {
- 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);
- return bl(t2, n2, s2, a2, o2, "map" === this.paint.get("circle-pitch-alignment"), "map" === this.paint.get("circle-pitch-scale"), l2, u2);
- }
- getProgramIds() {
- return ["circle"];
- }
- getProgramConfiguration(t2) {
- return new La(this, t2);
- }
- }, heatmap: class extends Ga {
- createBucket(t2) {
- return new Sl(t2);
- }
- constructor(t2) {
- super(t2, El), this._updateColorRamp();
- }
- _handleSpecialPaintPropertyUpdate(t2) {
- "heatmap-color" === t2 && this._updateColorRamp();
- }
- _updateColorRamp() {
- this.colorRamp = Cl({ expression: this._transitionablePaint._values["heatmap-color"].value.expression, evaluationKey: "heatmapDensity", image: this.colorRamp }), this.colorRampTexture = null;
- }
- resize() {
- this.heatmapFbo && (this.heatmapFbo.destroy(), this.heatmapFbo = null);
- }
- queryRadius(t2) {
- return Co("heatmap-radius", this, t2);
- }
- queryIntersectsFeature(t2, e2, r2, n2, s2, a2, o2, l2) {
- const u2 = this.paint.get("heatmap-radius").evaluate(e2, r2);
- return bl(t2, n2, a2, o2, l2, true, true, new i2(0, 0), u2);
- }
- hasOffscreenPass() {
- return 0 !== this.paint.get("heatmap-opacity") && "none" !== this.visibility;
- }
- getProgramIds() {
- return ["heatmap", "heatmapTexture"];
- }
- getProgramConfiguration(t2) {
- return new La(this, t2);
- }
- }, hillshade: class extends Ga {
- constructor(t2) {
- super(t2, Dl);
- }
- hasOffscreenPass() {
- return 0 !== this.paint.get("hillshade-exaggeration") && "none" !== this.visibility;
- }
- getProgramIds() {
- return ["hillshade", "hillshadePrepare"];
- }
- }, fill: class extends Ga {
- constructor(t2) {
- super(t2, bu);
- }
- getProgramIds() {
- const t2 = this.paint.get("fill-pattern"), e2 = t2 && t2.constantOr(1), r2 = [e2 ? "fillPattern" : "fill"];
- return this.paint.get("fill-antialias") && r2.push(e2 && !this.getPaintProperty("fill-outline-color") ? "fillOutlinePattern" : "fillOutline"), r2;
- }
- getProgramConfiguration(t2) {
- return new La(this, t2);
- }
- recalculate(t2, e2) {
- super.recalculate(t2, e2);
- const r2 = this.paint._values["fill-outline-color"];
- "constant" === r2.value.kind && void 0 === r2.value.value && (this.paint._values["fill-outline-color"] = this.paint._values["fill-color"]);
- }
- createBucket(t2) {
- return new xu(t2);
- }
- queryRadius() {
- return Do(this.paint.get("fill-translate"));
- }
- queryIntersectsFeature(t2, e2, r2, n2, i3, s2) {
- return !t2.queryGeometry.isAboveHorizon && wo(Po(t2.tilespaceGeometry, this.paint.get("fill-translate"), this.paint.get("fill-translate-anchor"), s2.angle, t2.pixelToTileUnitsFactor), n2);
- }
- isTileClipped() {
- return true;
- }
- }, "fill-extrusion": class extends Ga {
- constructor(t2) {
- super(t2, Ou);
- }
- createBucket(t2) {
- return new $u(t2);
- }
- queryRadius() {
- return Do(this.paint.get("fill-extrusion-translate"));
- }
- is3D() {
- return true;
- }
- getProgramIds() {
- return [this.paint.get("fill-extrusion-pattern").constantOr(1) ? "fillExtrusionPattern" : "fillExtrusion"];
- }
- getProgramConfiguration(t2) {
- return new La(this, t2);
- }
- queryIntersectsFeature(t2, e2, r2, n2, s2, a2, o2, l2, u2) {
- 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);
- if (d2 && m2 instanceof $u) {
- const t3 = m2.centroidVertexArray, e3 = u2 + 1;
- if (e3 < t3.length) {
- const r3 = t3.get(e3);
- f2[0] = r3.a_centroid_pos0, f2[1] = r3.a_centroid_pos1;
- }
- }
- if (0 === f2[0] && 1 === f2[1])
- return false;
- const g2 = function(t3, e3, r3, n3, s3, a3, o3, l3, u3) {
- return a3 ? function(t4, e4, r4, n4, i3, s4, a4, o4, l4) {
- const u4 = [], c3 = [], h3 = [0, 0, 0, 1];
- for (const p3 of t4) {
- const t5 = [], f3 = [];
- for (const u5 of p3) {
- const c4 = u5.x + n4.x, p4 = u5.y + n4.y, d3 = Zu(c4, p4, e4, r4, s4, a4, o4, l4);
- 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);
- const y3 = Gu([h3[0] / h3[3], h3[1] / h3[3], h3[2] / h3[3]]);
- 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);
- const m3 = Gu([h3[0] / h3[3], h3[1] / h3[3], h3[2] / h3[3]]);
- t5.push(y3), f3.push(m3);
- }
- u4.push(t5), c3.push(f3);
- }
- return [u4, c3];
- }(t3, e3, r3, n3, s3, a3, o3, l3, u3) : function(t4, e4, r4, n4, s4) {
- 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;
- for (const e5 of t4) {
- const t5 = [], r5 = [];
- for (const a5 of e5) {
- 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);
- T2.z = w2 / A2, t5.push(T2);
- const z2 = new i2(k2 / M2, S2 / M2);
- z2.z = I2 / M2, r5.push(z2);
- }
- a4.push(t5), o4.push(r5);
- }
- return [a4, o4];
- }(t3, e3, r3, n3, s3);
- }(n2, p2, h2, c2, o2, d2 ? l2 : null, f2, y2, a2.center.lat), x2 = t2.queryGeometry;
- return function(t3, e3, r3) {
- let n3 = 1 / 0;
- wo(r3, e3) && (n3 = Nu(r3, e3[0]));
- for (let i3 = 0; i3 < e3.length; i3++) {
- const s3 = e3[i3], a3 = t3[i3];
- for (let t4 = 0; t4 < s3.length - 1; t4++) {
- const e4 = s3[t4], i4 = [e4, s3[t4 + 1], a3[t4 + 1], a3[t4], e4];
- bo(r3, i4) && (n3 = Math.min(n3, Nu(r3, i4)));
- }
- }
- return n3 !== 1 / 0 && n3;
- }(g2[0], g2[1], x2.isPointQuery() ? x2.screenBounds : x2.screenGeometry);
- }
- }, line: class extends Ga {
- constructor(t2) {
- super(t2, ec), this.gradientVersion = 0;
- }
- _handleSpecialPaintPropertyUpdate(t2) {
- if ("line-gradient" === t2) {
- const t3 = this._transitionablePaint._values["line-gradient"].value.expression;
- this.stepInterpolant = t3._styleExpression && t3._styleExpression.expression instanceof er, this.gradientVersion = (this.gradientVersion + 1) % Number.MAX_SAFE_INTEGER;
- }
- }
- gradientExpression() {
- return this._transitionablePaint._values["line-gradient"].value.expression;
- }
- recalculate(t2, e2) {
- super.recalculate(t2, e2), this.paint._values["line-floorwidth"] = rc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value, t2);
- }
- createBucket(t2) {
- return new Qu(t2);
- }
- getProgramIds() {
- return [this.paint.get("line-pattern").constantOr(1) ? "linePattern" : "line"];
- }
- getProgramConfiguration(t2) {
- return new La(this, t2);
- }
- queryRadius(t2) {
- const e2 = t2, r2 = nc(Co("line-width", this, e2), Co("line-gap-width", this, e2)), n2 = Co("line-offset", this, e2);
- return r2 / 2 + Math.abs(n2) + Do(this.paint.get("line-translate"));
- }
- queryIntersectsFeature(t2, e2, r2, n2, s2, a2) {
- if (t2.queryGeometry.isAboveHorizon)
- return false;
- 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);
- return u2 && (n2 = function(t3, e3) {
- const r3 = [], n3 = new i2(0, 0);
- for (let i3 = 0; i3 < t3.length; i3++) {
- const s3 = t3[i3], a3 = [];
- for (let t4 = 0; t4 < s3.length; t4++) {
- 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();
- c2._mult(1 / (c2.x * u3.x + c2.y * u3.y)), a3.push(c2._mult(e3)._add(i4));
- }
- r3.push(a3);
- }
- return r3;
- }(n2, u2 * t2.pixelToTileUnitsFactor)), function(t3, e3, r3) {
- for (let n3 = 0; n3 < e3.length; n3++) {
- const i3 = e3[n3];
- if (t3.length >= 3) {
- for (let e4 = 0; e4 < i3.length; e4++)
- if (zo(t3, i3[e4]))
- return true;
- }
- if (Ao(t3, i3, r3))
- return true;
- }
- return false;
- }(o2, n2, l2);
- }
- isTileClipped() {
- return true;
- }
- }, symbol: ip, background: class extends Ga {
- constructor(t2) {
- super(t2, sp);
- }
- getProgramIds() {
- return [this.paint.get("background-pattern") ? "backgroundPattern" : "background"];
- }
- }, raster: class extends Ga {
- constructor(t2) {
- super(t2, ap);
- }
- getProgramIds() {
- return ["raster"];
- }
- }, sky: class extends Ga {
- constructor(t2) {
- super(t2, lp), this._updateColorRamp();
- }
- _handleSpecialPaintPropertyUpdate(t2) {
- "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);
- }
- _updateColorRamp() {
- this.colorRamp = Cl({ expression: this._transitionablePaint._values["sky-gradient"].value.expression, evaluationKey: "skyRadialProgress" }), this.colorRampTexture && (this.colorRampTexture.destroy(), this.colorRampTexture = null);
- }
- needsSkyboxCapture(t2) {
- if (this._skyboxInvalidated || !this.skyboxTexture || !this.skyboxGeometry)
- return true;
- if (!this.paint.get("sky-atmosphere-sun")) {
- const e2 = t2.style.light.properties.get("position");
- return this._lightPosition.azimuthal !== e2.azimuthal || this._lightPosition.polar !== e2.polar;
- }
- return false;
- }
- getCenter(t2, e2) {
- if ("atmosphere" === this.paint.get("sky-type")) {
- const r3 = this.paint.get("sky-atmosphere-sun"), n2 = !r3, i3 = t2.style.light, s2 = i3.properties.get("position");
- 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);
- }
- const r2 = this.paint.get("sky-gradient-center");
- return up(r2[0], 90 - r2[1], e2);
- }
- is3D() {
- return false;
- }
- isSky() {
- return true;
- }
- markSkyboxValid(t2) {
- this._skyboxInvalidated = false, this._lightPosition = t2.style.light.properties.get("position");
- }
- hasOffscreenPass() {
- return true;
- }
- getProgramIds() {
- const t2 = this.paint.get("sky-type");
- return "atmosphere" === t2 ? ["skyboxCapture", "skybox"] : "gradient" === t2 ? ["skyboxGradient"] : null;
- }
- } };
- class hp {
- constructor(t2, e2, r2, n2) {
- this.context = t2, this.format = r2, this.texture = t2.gl.createTexture(), this.update(e2, n2);
- }
- update(t2, e2, r2) {
- const { width: n2, height: i3 } = t2, { context: s2 } = this, { gl: o2 } = s2, { HTMLImageElement: l2, HTMLCanvasElement: u2, HTMLVideoElement: c2, ImageData: h2, ImageBitmap: p2 } = a;
- 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) {
- const { x: e3, y: s3 } = r2 || { x: 0, y: 0 };
- 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);
- } else
- 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);
- this.useMipmap = Boolean(e2 && e2.useMipmap && this.isSizePowerOfTwo()), this.useMipmap && o2.generateMipmap(o2.TEXTURE_2D);
- }
- bind(t2, e2) {
- const { context: r2 } = this, { gl: n2 } = r2;
- 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);
- }
- isSizePowerOfTwo() {
- return this.size[0] === this.size[1] && Math.log(this.size[0]) / Math.LN2 % 1 == 0;
- }
- destroy() {
- const { gl: t2 } = this.context;
- t2.deleteTexture(this.texture), this.texture = null;
- }
- }
- class pp {
- constructor(t2, e2) {
- this.width = t2, this.height = e2, this.nextRow = 0, this.image = new zl({ width: t2, height: e2 }), this.positions = {}, this.uploaded = false;
- }
- getDash(t2, e2) {
- const r2 = this.getKey(t2, e2);
- return this.positions[r2];
- }
- trim() {
- const t2 = this.width, e2 = this.height = k(this.nextRow);
- this.image.resize({ width: t2, height: e2 });
- }
- getKey(t2, e2) {
- return t2.join(",") + e2;
- }
- getDashRanges(t2, e2, r2) {
- const n2 = [];
- let i3 = t2.length % 2 == 1 ? -t2[t2.length - 1] * r2 : 0, s2 = t2[0] * r2, a2 = true;
- n2.push({ left: i3, right: s2, isDash: a2, zeroLength: 0 === t2[0] });
- let o2 = t2[0];
- for (let e3 = 1; e3 < t2.length; e3++) {
- a2 = !a2;
- const l2 = t2[e3];
- i3 = o2 * r2, o2 += l2, s2 = o2 * r2, n2.push({ left: i3, right: s2, isDash: a2, zeroLength: 0 === l2 });
- }
- return n2;
- }
- addRoundDash(t2, e2, r2) {
- const n2 = e2 / 2;
- for (let e3 = -r2; e3 <= r2; e3++) {
- const i3 = this.width * (this.nextRow + r2 + e3);
- let s2 = 0, a2 = t2[s2];
- for (let o2 = 0; o2 < this.width; o2++) {
- o2 / a2.right > 1 && (a2 = t2[++s2]);
- const l2 = Math.abs(o2 - a2.left), u2 = Math.abs(o2 - a2.right), c2 = Math.min(l2, u2);
- let h2;
- const p2 = e3 / r2 * (n2 + 1);
- if (a2.isDash) {
- const t3 = n2 - Math.abs(p2);
- h2 = Math.sqrt(c2 * c2 + t3 * t3);
- } else
- h2 = n2 - Math.sqrt(c2 * c2 + p2 * p2);
- this.image.data[i3 + o2] = Math.max(0, Math.min(255, h2 + 128));
- }
- }
- }
- addRegularDash(t2, e2) {
- for (let e3 = t2.length - 1; e3 >= 0; --e3) {
- const r3 = t2[e3], n3 = t2[e3 + 1];
- r3.zeroLength ? t2.splice(e3, 1) : n3 && n3.isDash === r3.isDash && (n3.left = r3.left, t2.splice(e3, 1));
- }
- const r2 = t2[0], n2 = t2[t2.length - 1];
- r2.isDash === n2.isDash && (r2.left = n2.left - this.width, n2.right = r2.right + this.width);
- const i3 = this.width * this.nextRow;
- let s2 = 0, a2 = t2[s2];
- for (let r3 = 0; r3 < this.width; r3++) {
- r3 / a2.right > 1 && (a2 = t2[++s2]);
- const n3 = Math.abs(r3 - a2.left), o2 = Math.abs(r3 - a2.right), l2 = Math.min(n3, o2);
- this.image.data[i3 + r3] = Math.max(0, Math.min(255, (a2.isDash ? l2 : -l2) + e2 + 128));
- }
- }
- addDash(t2, e2) {
- const r2 = this.getKey(t2, e2);
- if (this.positions[r2])
- return this.positions[r2];
- const n2 = "round" === e2, i3 = n2 ? 7 : 0, s2 = 2 * i3 + 1;
- if (this.nextRow + s2 > this.height)
- return C("LineAtlas out of space"), null;
- 0 === t2.length && t2.push(1);
- let a2 = 0;
- for (let e3 = 0; e3 < t2.length; e3++)
- t2[e3] < 0 && (C("Negative value is found in line dasharray, replacing values with 0"), t2[e3] = 0), a2 += t2[e3];
- if (0 !== a2) {
- const r3 = this.width / a2, s3 = this.getDashRanges(t2, this.width, r3);
- n2 ? this.addRoundDash(s3, r3, i3) : this.addRegularDash(s3, "square" === e2 ? 0.5 * r3 : 0);
- }
- const o2 = this.nextRow + i3;
- this.nextRow += s2;
- const l2 = { tl: [o2, i3], br: [a2, 0] };
- return this.positions[r2] = l2, l2;
- }
- }
- ai(pp, "LineAtlas");
- class fp {
- constructor(t2) {
- this._callback = t2, this._triggered = false, "undefined" != typeof MessageChannel && (this._channel = new MessageChannel(), this._channel.port2.onmessage = () => {
- this._triggered = false, this._callback();
- });
- }
- trigger() {
- this._triggered || (this._triggered = true, this._channel ? this._channel.port1.postMessage(true) : setTimeout(() => {
- this._triggered = false, this._callback();
- }, 0));
- }
- remove() {
- this._channel = void 0, this._callback = () => {
- };
- }
- }
- const dp = a.performance;
- function yp(t2) {
- const e2 = t2 ? t2.url.toString() : void 0;
- return dp.getEntriesByName(e2);
- }
- class mp {
- constructor() {
- this.tasks = {}, this.taskQueue = [], I(["process"], this), this.invoker = new fp(this.process), this.nextId = 0;
- }
- add(t2, e2) {
- const r2 = this.nextId++, n2 = function({ type: t3, isSymbolTile: e3, zoom: r3 }) {
- 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;
- }(e2);
- if (0 === n2) {
- V();
- try {
- t2();
- } finally {
- }
- return { cancel: () => {
- } };
- }
- return this.tasks[r2] = { fn: t2, metadata: e2, priority: n2, id: r2 }, this.taskQueue.push(r2), this.invoker.trigger(), { cancel: () => {
- delete this.tasks[r2];
- } };
- }
- process() {
- V();
- try {
- if (this.taskQueue = this.taskQueue.filter((t3) => !!this.tasks[t3]), !this.taskQueue.length)
- return;
- const t2 = this.pick();
- if (null === t2)
- return;
- const e2 = this.tasks[t2];
- if (delete this.tasks[t2], this.taskQueue.length && this.invoker.trigger(), !e2)
- return;
- e2.fn();
- } finally {
- }
- }
- pick() {
- let t2 = null, e2 = 1 / 0;
- for (let r3 = 0; r3 < this.taskQueue.length; r3++) {
- const n2 = this.tasks[this.taskQueue[r3]];
- n2.priority < e2 && (e2 = n2.priority, t2 = r3);
- }
- if (null === t2)
- return null;
- const r2 = this.taskQueue[t2];
- return this.taskQueue.splice(t2, 1), r2;
- }
- remove() {
- this.invoker.remove();
- }
- }
- 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" }]);
- var _p = ks([{ name: "a_pos", type: "Int16", components: 2 }]);
- 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])];
- class Ip {
- constructor(t2, e2, r2) {
- this.a = hl([], t2, r2), this.b = hl([], e2, r2), this.center = r2;
- const n2 = sl([], this.a), i3 = sl([], this.b);
- this.angle = Math.acos(al(n2, i3));
- }
- }
- function Mp(t2, e2) {
- if (0 === t2.angle)
- return null;
- let r2;
- 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) {
- const i3 = Math.sin(r3);
- return t3 * (Math.sin((1 - n2) * r3) / i3) + e3 * (Math.sin(n2 * r3) / i3);
- }(t2.a[e2], t2.b[e2], t2.angle, y(r2, 0, 1)) + t2.center[e2];
- }
- function Tp(t2) {
- if (t2.z <= 1)
- return Sp[t2.z + 2 * t2.y + t2.x];
- 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];
- for (const t3 of n2)
- 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]);
- return new vl(i3, s2);
- }
- function zp(t2, e2, r2) {
- const n2 = e2 / t2.worldSize, i3 = (t3, e3) => {
- nl(t3, t3, n2), nl(e3, e3, n2);
- }, s2 = Number.MAX_VALUE, a2 = [-s2, -s2, -s2], o2 = [s2, s2, s2], l2 = Lp(t2);
- if (r2.z <= 1) {
- const t3 = Tp(r2).getCorners();
- for (let e3 = 0; e3 < t3.length; e3++)
- ll(t3[e3], t3[e3], l2), el(o2, o2, t3[e3]), rl(a2, a2, t3[e3]);
- return i3(o2, a2), new vl(o2, a2);
- }
- const [c2, h2] = Bp(r2), p2 = new Ha();
- p2.setSouthWest([c2[1], h2[0]]), p2.setNorthEast([h2[1], c2[0]]);
- const f2 = [Cp(p2.getSouth(), p2.getWest()), Cp(p2.getSouth(), p2.getEast()), Cp(p2.getNorth(), p2.getEast()), Cp(p2.getNorth(), p2.getWest())];
- for (let t3 = 0; t3 < f2.length; t3++)
- ll(f2[t3], f2[t3], l2), el(o2, o2, f2[t3]), rl(a2, a2, f2[t3]);
- if (p2.contains(t2.center))
- return a2[2] = 0, i3(o2, a2), new vl(o2, a2);
- 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)];
- let w2 = new Array(3), A2 = 0;
- const k2 = x2[0] - _2[0], S2 = x2[1] - _2[1];
- if (Math.abs(k2) > Math.abs(S2))
- A2 = k2 >= 0 ? 1 : 3, w2 = d2;
- else {
- A2 = S2 >= 0 ? 0 : 2;
- const t3 = [l2[4], l2[5], l2[6]];
- let e3;
- e3 = S2 >= 0 ? -Math.sin(u(p2.getSouth())) * wp : -Math.sin(u(p2.getNorth())) * wp, w2 = il(w2, d2, t3, e3);
- }
- 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]];
- return o2[2] = Math.min(I2[2], M2[2]), el(o2, o2, z2), rl(a2, a2, z2), i3(o2, a2), new vl(o2, a2);
- }
- function Bp(t2) {
- const e2 = 1 << t2.z, r2 = t2.x / e2, n2 = (t2.x + 1) / e2, i3 = (t2.y + 1) / e2;
- return [[so(t2.y / e2), io(r2)], [so(i3), io(n2)]];
- }
- function Ep(t2, e2, r2, n2 = wp) {
- return r2 = u(r2), [t2 * Math.sin(r2) * n2, -e2 * n2, t2 * Math.cos(r2) * n2];
- }
- function Cp(t2, e2, r2) {
- return Ep(Math.cos(u(t2)), Math.sin(u(t2)), e2, r2);
- }
- function Dp(t2, e2, r2) {
- const n2 = Math.pow(2, r2.z), i3 = (t2 / Ya + r2.x) / n2;
- return Cp(so((e2 / Ya + r2.y) / n2), io(i3));
- }
- function Pp(t2) {
- return 16383 / Math.max(...hl([], t2.max, t2.min));
- }
- function Vp(t2) {
- const e2 = jo(new Float64Array(16)), r2 = Pp(t2);
- var n2, i3;
- 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;
- }
- function Fp(t2, e2, r2, n2, i3) {
- const s2 = function(t3) {
- const e3 = Ya / (2 * Math.PI);
- return t3 / (2 * Math.PI) / e3;
- }(r2), a2 = [t2, e2, -r2 / (2 * Math.PI)], o2 = jo(new Float64Array(16));
- return qo(o2, o2, a2), No(o2, o2, [s2, s2, s2]), Go(o2, o2, u(-i3)), Zo(o2, o2, u(-n2)), o2;
- }
- function Lp(t2) {
- const { x: e2, y: r2 } = t2.point, { lng: n2, lat: i3 } = t2._center;
- return Fp(e2, r2, t2.worldSize, n2, i3);
- }
- const Rp = u(85), Up = Math.cos(Rp), $p = Math.sin(Rp);
- function jp(t2, e2, r2) {
- var n2 = 2 * Math.PI * 6378137 / 256 / Math.pow(2, r2);
- return [t2 * n2 - 2 * Math.PI * 6378137 / 2, e2 * n2 - 2 * Math.PI * 6378137 / 2];
- }
- class Op {
- constructor(t2, e2, r2) {
- this.z = t2, this.x = e2, this.y = r2, this.key = Gp(0, t2, t2, e2, r2);
- }
- equals(t2) {
- return this.z === t2.z && this.x === t2.x && this.y === t2.y;
- }
- url(t2, e2) {
- const r2 = function(t3, e3, r3) {
- var n3 = jp(256 * t3, 256 * (e3 = Math.pow(2, r3) - e3 - 1), r3), i3 = jp(256 * (t3 + 1), 256 * (e3 + 1), r3);
- return n3[0] + "," + n3[1] + "," + i3[0] + "," + i3[1];
- }(this.x, this.y, this.z), n2 = function(t3, e3, r3) {
- let n3, i3 = "";
- for (let s2 = t3; s2 > 0; s2--)
- n3 = 1 << s2 - 1, i3 += (e3 & n3 ? 1 : 0) + (r3 & n3 ? 2 : 0);
- return i3;
- }(this.z, this.x, this.y);
- 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);
- }
- toString() {
- return `${this.z}/${this.x}/${this.y}`;
- }
- }
- class qp {
- constructor(t2, e2) {
- this.wrap = t2, this.canonical = e2, this.key = Gp(t2, e2.z, e2.z, e2.x, e2.y);
- }
- }
- class Np {
- constructor(t2, e2, r2, n2, i3) {
- 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);
- }
- equals(t2) {
- return this.overscaledZ === t2.overscaledZ && this.wrap === t2.wrap && this.canonical.equals(t2.canonical);
- }
- scaledTo(t2) {
- const e2 = this.canonical.z - t2;
- 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);
- }
- calculateScaledKey(t2, e2 = true) {
- if (this.overscaledZ === t2 && e2)
- return this.key;
- if (t2 > this.canonical.z)
- return Gp(this.wrap * +e2, t2, this.canonical.z, this.canonical.x, this.canonical.y);
- {
- const r2 = this.canonical.z - t2;
- return Gp(this.wrap * +e2, t2, t2, this.canonical.x >> r2, this.canonical.y >> r2);
- }
- }
- isChildOf(t2) {
- if (t2.wrap !== this.wrap)
- return false;
- const e2 = this.canonical.z - t2.canonical.z;
- return 0 === t2.overscaledZ || t2.overscaledZ < this.overscaledZ && t2.canonical.x === this.canonical.x >> e2 && t2.canonical.y === this.canonical.y >> e2;
- }
- children(t2) {
- if (this.overscaledZ >= t2)
- return [new Np(this.overscaledZ + 1, this.wrap, this.canonical.z, this.canonical.x, this.canonical.y)];
- const e2 = this.canonical.z + 1, r2 = 2 * this.canonical.x, n2 = 2 * this.canonical.y;
- 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)];
- }
- isLessThan(t2) {
- 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));
- }
- wrapped() {
- return new Np(this.overscaledZ, 0, this.canonical.z, this.canonical.x, this.canonical.y);
- }
- unwrapTo(t2) {
- return new Np(this.overscaledZ, t2, this.canonical.z, this.canonical.x, this.canonical.y);
- }
- overscaleFactor() {
- return Math.pow(2, this.overscaledZ - this.canonical.z);
- }
- toUnwrapped() {
- return new qp(this.wrap, this.canonical);
- }
- toString() {
- return `${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`;
- }
- }
- function Gp(t2, e2, r2, n2, i3) {
- const s2 = 1 << Math.min(r2, 22);
- let a2 = s2 * (i3 % s2) + n2 % s2;
- return t2 && r2 < 22 && (a2 += s2 * s2 * ((t2 < 0 ? -2 * t2 - 1 : 2 * t2) % (1 << 2 * (22 - r2)))), 16 * (32 * a2 + r2) + (e2 - r2);
- }
- function Zp(t2, e2) {
- if (!e2.isReprojectedInTileSpace)
- return { scale: 1 << t2.z, x: t2.x, y: t2.y, x2: t2.x + 1, y2: t2.y + 1, projection: e2 };
- 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);
- 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);
- const v2 = r2 / 16;
- function b2(t3, r3, n3, i4, s3, a3) {
- 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);
- 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));
- }
- 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;
- const _2 = 1 / Math.max(g2 - y2, x2 - m2);
- return { scale: _2, x: y2 * _2, y: m2 * _2, x2: g2 * _2, y2: x2 * _2, projection: e2 };
- }
- ai(Op, "CanonicalTileID"), ai(Np, "OverscaledTileID", { omit: ["projMatrix"] });
- class Xp {
- constructor(t2) {
- this._stringToNumber = {}, this._numberToString = [];
- for (let e2 = 0; e2 < t2.length; e2++) {
- const r2 = t2[e2];
- this._stringToNumber[r2] = e2, this._numberToString[e2] = r2;
- }
- }
- encode(t2) {
- return this._stringToNumber[t2];
- }
- decode(t2) {
- return this._numberToString[t2];
- }
- }
- const Kp = ["tile", "layer", "source", "sourceLayer", "state"];
- class Yp {
- constructor(t2, e2, r2, n2, i3) {
- this.type = "Feature", this._vectorTileFeature = t2, this._z = e2, this._x = r2, this._y = n2, this.properties = t2.properties, this.id = i3;
- }
- get geometry() {
- return void 0 === this._geometry && (this._geometry = this._vectorTileFeature.toGeoJSON(this._x, this._y, this._z).geometry), this._geometry;
- }
- set geometry(t2) {
- this._geometry = t2;
- }
- toJSON() {
- const t2 = { type: "Feature", geometry: this.geometry, properties: this.properties };
- void 0 !== this.id && (t2.id = this.id);
- for (const e2 of Kp)
- void 0 !== this[e2] && (t2[e2] = this[e2]);
- return t2;
- }
- }
- const Hp = 32, Wp = 33, Jp = new Uint16Array(8184);
- for (let t2 = 0; t2 < 2046; t2++) {
- let e2 = t2 + 2, r2 = 0, n2 = 0, i3 = 0, s2 = 0, a2 = 0, o2 = 0;
- for (1 & e2 ? i3 = s2 = a2 = Hp : r2 = n2 = o2 = Hp; (e2 >>= 1) > 1; ) {
- const t3 = r2 + i3 >> 1, l3 = n2 + s2 >> 1;
- 1 & e2 ? (i3 = r2, s2 = n2, r2 = a2, n2 = o2) : (r2 = i3, n2 = s2, i3 = a2, s2 = o2), a2 = t3, o2 = l3;
- }
- const l2 = 4 * t2;
- Jp[l2 + 0] = r2, Jp[l2 + 1] = n2, Jp[l2 + 2] = i3, Jp[l2 + 3] = s2;
- }
- const Qp = new Uint16Array(2178), tf = new Uint8Array(1089), ef = new Uint16Array(1089);
- function rf(t2) {
- return 0 === t2 ? -0.03125 : 32 === t2 ? 0.03125 : 0;
- }
- var nf = ks([{ name: "a_pos", type: "Int16", components: 2 }, { name: "a_texture_pos", type: "Int16", components: 2 }]);
- 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)]] };
- class af {
- constructor(t2, e2, r2, n2, i3) {
- 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);
- }
- registerFadeDuration(t2) {
- const e2 = t2 + this.timeAdded;
- e2 < N.now() || this.fadeEndTime && e2 < this.fadeEndTime || (this.fadeEndTime = e2);
- }
- wasRequested() {
- return "errored" === this.state || "loaded" === this.state || "reloading" === this.state;
- }
- get tileTransform() {
- return this._tileTransform || (this._tileTransform = Zp(this.tileID.canonical, this.projection)), this._tileTransform;
- }
- loadVectorData(t2, e2, r2) {
- if (this.unloadVectorData(), this.state = "loaded", t2) {
- 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) {
- const r3 = {};
- if (!e3)
- return r3;
- for (const n2 of t3) {
- const t4 = n2.layerIds.map((t5) => e3.getLayer(t5)).filter(Boolean);
- if (0 !== t4.length) {
- n2.layers = t4, n2.stateDependentLayerIds && (n2.stateDependentLayers = n2.stateDependentLayerIds.map((e4) => t4.filter((t5) => t5.id === e4)[0]));
- for (const e4 of t4)
- r3[e4.id] = n2;
- }
- }
- return r3;
- }(t2.buckets, e2.style), this.hasSymbolBuckets = false;
- for (const t3 in this.buckets) {
- const e3 = this.buckets[t3];
- if (e3 instanceof tp) {
- if (this.hasSymbolBuckets = true, !r2)
- break;
- e3.justReloaded = true;
- }
- }
- if (this.hasRTLText = false, this.hasSymbolBuckets)
- for (const t3 in this.buckets) {
- const e3 = this.buckets[t3];
- if (e3 instanceof tp && e3.hasRTLText) {
- this.hasRTLText = true, is.isLoading() || is.isLoaded() || "deferred" !== rs() || ns();
- break;
- }
- }
- this.queryPadding = 0;
- for (const t3 in this.buckets) {
- const r3 = this.buckets[t3];
- this.queryPadding = Math.max(this.queryPadding, e2.style.getLayer(t3).queryRadius(r3));
- }
- t2.imageAtlas && (this.imageAtlas = t2.imageAtlas), t2.glyphAtlasImage && (this.glyphAtlasImage = t2.glyphAtlasImage), t2.lineAtlas && (this.lineAtlas = t2.lineAtlas);
- } else
- this.collisionBoxArray = new ea();
- }
- unloadVectorData() {
- if (this.hasData()) {
- for (const t2 in this.buckets)
- this.buckets[t2].destroy();
- 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";
- }
- }
- getBucket(t2) {
- return this.buckets[t2.id];
- }
- upload(t2) {
- for (const e3 in this.buckets) {
- const r2 = this.buckets[e3];
- r2.uploadPending() && r2.upload(t2);
- }
- const e2 = t2.gl;
- 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);
- }
- prepare(t2) {
- this.imageAtlas && this.imageAtlas.patchUpdatedImages(t2, this.imageAtlasTexture);
- }
- queryRenderedFeatures(t2, e2, r2, n2, i3, s2, a2, o2) {
- return this.latestFeatureIndex && this.latestFeatureIndex.rawTileData ? this.latestFeatureIndex.query({ tileResult: n2, pixelPosMatrix: a2, transform: s2, params: i3, tileTransform: this.tileTransform }, t2, e2, r2) : {};
- }
- querySourceFeatures(t2, e2) {
- const r2 = this.latestFeatureIndex;
- if (!r2 || !r2.rawTileData)
- return;
- const n2 = r2.loadVTLayers(), i3 = e2 ? e2.sourceLayer : "", s2 = n2._geojsonTileLayer || n2[i3];
- if (!s2)
- return;
- const a2 = Sn(e2 && e2.filter), { z: o2, x: l2, y: u2 } = this.tileID.canonical, c2 = { z: o2, x: l2, y: u2 };
- for (let e3 = 0; e3 < s2.length; e3++) {
- const n3 = s2.feature(e3);
- if (a2.needGeometry) {
- const t3 = mo(n3, true);
- if (!a2.filter(new ss(this.tileID.overscaledZ), t3, this.tileID.canonical))
- continue;
- } else if (!a2.filter(new ss(this.tileID.overscaledZ), n3))
- continue;
- const h2 = r2.getId(n3, i3), p2 = new Yp(n3, o2, l2, u2, h2);
- p2.tile = c2, t2.push(p2);
- }
- }
- hasData() {
- return "loaded" === this.state || "reloading" === this.state || "expired" === this.state;
- }
- patternsLoaded() {
- return !!this.imageAtlas && !!Object.keys(this.imageAtlas.patternPositions).length;
- }
- setExpiryData(t2) {
- const e2 = this.expirationTime;
- if (t2.cacheControl) {
- const e3 = F(t2.cacheControl);
- e3["max-age"] && (this.expirationTime = Date.now() + 1e3 * e3["max-age"]);
- } else
- t2.expires && (this.expirationTime = new Date(t2.expires).getTime());
- if (this.expirationTime) {
- const t3 = Date.now();
- let r2 = false;
- if (this.expirationTime > t3)
- r2 = false;
- else if (e2)
- if (this.expirationTime < e2)
- r2 = true;
- else {
- const n2 = this.expirationTime - e2;
- n2 ? this.expirationTime = t3 + Math.max(n2, 3e4) : r2 = true;
- }
- else
- r2 = true;
- r2 ? (this.expiredRequestCount++, this.state = "expired") : this.expiredRequestCount = 0;
- }
- }
- getExpiryTimeout() {
- if (this.expirationTime)
- return this.expiredRequestCount ? 1e3 * (1 << Math.min(this.expiredRequestCount - 1, 31)) : Math.min(this.expirationTime - (/* @__PURE__ */ new Date()).getTime(), Math.pow(2, 31) - 1);
- }
- setFeatureState(t2, e2) {
- if (!this.latestFeatureIndex || !this.latestFeatureIndex.rawTileData || 0 === Object.keys(t2).length || !e2)
- return;
- const r2 = this.latestFeatureIndex.loadVTLayers(), n2 = e2.style.listImages();
- for (const i3 in this.buckets) {
- if (!e2.style.hasLayer(i3))
- continue;
- const s2 = this.buckets[i3], a2 = s2.layers[0].sourceLayer || "_geojsonTileLayer", o2 = r2[a2], l2 = t2[a2];
- if (!o2 || !l2 || 0 === Object.keys(l2).length)
- continue;
- if (s2.update(l2, o2, n2, this.imageAtlas && this.imageAtlas.patternPositions || {}), s2 instanceof Qu || s2 instanceof xu) {
- const t3 = e2.style._getSourceCache(s2.layers[0].source);
- e2._terrain && e2._terrain.enabled && t3 && s2.programConfigurations.needsUpload && e2._terrain._clearRenderCacheForTile(t3.id, this.tileID);
- }
- const u2 = e2 && e2.style && e2.style.getLayer(i3);
- u2 && (this.queryPadding = Math.max(this.queryPadding, u2.queryRadius(s2)));
- }
- }
- holdingForFade() {
- return void 0 !== this.symbolFadeHoldUntil;
- }
- symbolFadeFinished() {
- return !this.symbolFadeHoldUntil || this.symbolFadeHoldUntil < N.now();
- }
- clearFadeHold() {
- this.symbolFadeHoldUntil = void 0;
- }
- setHoldDuration(t2) {
- this.symbolFadeHoldUntil = N.now() + t2;
- }
- setTexture(t2, e2) {
- const r2 = e2.context, n2 = r2.gl;
- 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));
- }
- setDependencies(t2, e2) {
- const r2 = {};
- for (const t3 of e2)
- r2[t3] = true;
- this.dependencies[t2] = r2;
- }
- hasDependency(t2, e2) {
- for (const r2 of t2) {
- const t3 = this.dependencies[r2];
- if (t3) {
- for (const r3 of e2)
- if (t3[r3])
- return true;
- }
- }
- return false;
- }
- clearQueryDebugViz() {
- }
- _makeDebugTileBoundsBuffers(t2, e2) {
- if (!e2 || "mercator" === e2.name || this._tileDebugBuffer)
- return;
- const r2 = yo(sf, this.tileID.canonical, this.tileTransform)[0], n2 = new Is(), i3 = new Ys();
- for (let t3 = 0; t3 < r2.length; t3++) {
- const { x: e3, y: s2 } = r2[t3];
- n2.emplaceBack(e3, s2), i3.emplaceBack(t3);
- }
- 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);
- }
- _makeTileBoundsBuffers(t2, e2) {
- if (this._tileBoundsBuffer || !e2 || "mercator" === e2.name)
- return;
- const r2 = yo(sf, this.tileID.canonical, this.tileTransform)[0];
- let n2, i3;
- if (this.isRaster) {
- const t3 = function(t4, e3) {
- const r3 = Zp(t4, e3), n3 = Math.pow(2, t4.z);
- for (let i5 = 0; i5 < Wp; i5++)
- for (let s3 = 0; s3 < Wp; s3++) {
- 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;
- 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);
- }
- tf.fill(0), ef.fill(0);
- for (let t5 = 2045; t5 >= 0; t5--) {
- 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;
- if (tf[p2] = tf[p2] || (f2 ? 1 : 0), t5 < 1022) {
- const t6 = (n4 + u2 >> 1) * Wp + (r4 + l3 >> 1), e5 = (s3 + u2 >> 1) * Wp + (i5 + l3 >> 1);
- tf[p2] = tf[p2] || tf[t6] || tf[e5];
- }
- }
- const i4 = new Ts(), s2 = new js();
- let a2 = 0;
- function o2(t5, e4) {
- const r4 = e4 * Wp + t5;
- 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;
- }
- function l2(t5, e4, r4, n4, i5, a3) {
- const u2 = t5 + r4 >> 1, c2 = e4 + n4 >> 1;
- if (Math.abs(t5 - i5) + Math.abs(e4 - a3) > 1 && tf[c2 * Wp + u2])
- l2(i5, a3, t5, e4, u2, c2), l2(r4, n4, i5, a3, u2, c2);
- else {
- const l3 = o2(t5, e4), u3 = o2(r4, n4), c3 = o2(i5, a3);
- s2.emplaceBack(l3, u3, c3);
- }
- }
- return l2(0, 0, Hp, Hp, Hp, 0), l2(Hp, Hp, 0, 0, 0, Hp), { vertices: i4, indices: s2 };
- }(this.tileID.canonical, e2);
- n2 = t3.vertices, i3 = t3.indices;
- } else {
- n2 = new Ts(), i3 = new js();
- for (const { x: t4, y: e3 } of r2)
- n2.emplaceBack(t4, e3, 0, 0);
- const t3 = Fl(n2.int16, void 0, 4);
- for (let e3 = 0; e3 < t3.length; e3 += 3)
- i3.emplaceBack(t3[e3], t3[e3 + 1], t3[e3 + 2]);
- }
- this._tileBoundsBuffer = t2.createVertexBuffer(n2, nf.members), this._tileBoundsIndexBuffer = t2.createIndexBuffer(i3), this._tileBoundsSegments = Ka.simpleSegment(0, 0, n2.length, i3.length);
- }
- _makeGlobeTileDebugBuffers(t2, e2) {
- if (this._globeTileDebugBorderBuffer || this._globeTileDebugTextBuffer || !e2 || "globe" !== e2.name)
- return;
- const r2 = this.tileID.canonical, n2 = Vp(Tp(r2));
- this._makeGlobeTileDebugBorderBuffer(t2, r2, n2), this._makeGlobeTileDebugTextBuffer(t2, r2, n2);
- }
- _makeGlobeTileDebugBorderBuffer(t2, e2, r2) {
- const n2 = new Is(), i3 = new Ys(), s2 = new Ms(), a2 = (t3, a3, o3, l2, u2) => {
- const c2 = (o3 - t3) / (u2 - 1), h2 = (l2 - a3) / (u2 - 1), p2 = n2.length;
- for (let o4 = 0; o4 < u2; o4++) {
- const l3 = t3 + o4 * c2, u3 = a3 + o4 * h2;
- n2.emplaceBack(l3, u3);
- const f2 = Dp(l3, u3, e2), d2 = ll(f2, f2, r2);
- s2.emplaceBack(d2[0], d2[1], d2[2]), i3.emplaceBack(p2 + o4);
- }
- }, o2 = Ya;
- 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);
- }
- _makeGlobeTileDebugTextBuffer(t2, e2, r2) {
- const n2 = new Is(), i3 = new js(), s2 = new Ms(), a2 = 25;
- i3.reserve(32), n2.reserve(a2), s2.reserve(a2);
- const o2 = (t3, e3) => a2 * t3 + e3;
- for (let t3 = 0; t3 < a2; t3++) {
- const i4 = 2048 * t3;
- for (let t4 = 0; t4 < a2; t4++) {
- const a3 = 2048 * t4;
- n2.emplaceBack(a3, i4);
- const o3 = Dp(a3, i4, e2), l2 = ll(o3, o3, r2);
- s2.emplaceBack(l2[0], l2[1], l2[2]);
- }
- }
- for (let t3 = 0; t3 < 4; t3++)
- for (let e3 = 0; e3 < 4; e3++) {
- const r3 = o2(t3, e3), n3 = o2(t3, e3 + 1), s3 = o2(t3 + 1, e3), a3 = o2(t3 + 1, e3 + 1);
- i3.emplaceBack(r3, n3, s3), i3.emplaceBack(s3, n3, a3);
- }
- 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);
- }
- }
- class of {
- constructor() {
- this.state = {}, this.stateChanges = {}, this.deletedStates = {};
- }
- updateState(t2, e2, r2) {
- const n2 = String(e2);
- 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]) {
- this.deletedStates[t2] = {};
- for (const e3 in this.state[t2])
- e3 !== n2 && (this.deletedStates[t2][e3] = null);
- } else if (this.deletedStates[t2] && null === this.deletedStates[t2][n2]) {
- this.deletedStates[t2][n2] = {};
- for (const e3 in this.state[t2][n2])
- r2[e3] || (this.deletedStates[t2][n2][e3] = null);
- } else
- for (const e3 in r2)
- this.deletedStates[t2] && this.deletedStates[t2][n2] && null === this.deletedStates[t2][n2][e3] && delete this.deletedStates[t2][n2][e3];
- }
- removeFeatureState(t2, e2, r2) {
- if (null === this.deletedStates[t2])
- return;
- const n2 = String(e2);
- if (this.deletedStates[t2] = this.deletedStates[t2] || {}, r2 && void 0 !== e2)
- null !== this.deletedStates[t2][n2] && (this.deletedStates[t2][n2] = this.deletedStates[t2][n2] || {}, this.deletedStates[t2][n2][r2] = null);
- else if (void 0 !== e2)
- if (this.stateChanges[t2] && this.stateChanges[t2][n2])
- for (r2 in this.deletedStates[t2][n2] = {}, this.stateChanges[t2][n2])
- this.deletedStates[t2][n2][r2] = null;
- else
- this.deletedStates[t2][n2] = null;
- else
- this.deletedStates[t2] = null;
- }
- getState(t2, e2) {
- const r2 = String(e2), n2 = b({}, (this.state[t2] || {})[r2], (this.stateChanges[t2] || {})[r2]);
- if (null === this.deletedStates[t2])
- return {};
- if (this.deletedStates[t2]) {
- const r3 = this.deletedStates[t2][e2];
- if (null === r3)
- return {};
- for (const t3 in r3)
- delete n2[t3];
- }
- return n2;
- }
- initializeTileState(t2, e2) {
- t2.setFeatureState(this.state, e2);
- }
- coalesceChanges(t2, e2) {
- const r2 = {};
- for (const t3 in this.stateChanges) {
- this.state[t3] = this.state[t3] || {};
- const e3 = {};
- for (const r3 in this.stateChanges[t3])
- this.state[t3][r3] || (this.state[t3][r3] = {}), b(this.state[t3][r3], this.stateChanges[t3][r3]), e3[r3] = this.state[t3][r3];
- r2[t3] = e3;
- }
- for (const t3 in this.deletedStates) {
- this.state[t3] = this.state[t3] || {};
- const e3 = {};
- if (null === this.deletedStates[t3])
- for (const r3 in this.state[t3])
- e3[r3] = {}, this.state[t3][r3] = {};
- else
- for (const r3 in this.deletedStates[t3]) {
- if (null === this.deletedStates[t3][r3])
- this.state[t3][r3] = {};
- else
- for (const e4 of Object.keys(this.deletedStates[t3][r3]))
- delete this.state[t3][r3][e4];
- e3[r3] = this.state[t3][r3];
- }
- r2[t3] = r2[t3] || {}, b(r2[t3], e3);
- }
- if (this.stateChanges = {}, this.deletedStates = {}, 0 !== Object.keys(r2).length)
- for (const n2 in t2)
- t2[n2].setFeatureState(r2, e2);
- }
- }
- class lf {
- constructor(t2) {
- this.size = t2, this.minimums = [], this.maximums = [], this.leaves = [];
- }
- getElevation(t2, e2) {
- const r2 = this.toIdx(t2, e2);
- return { min: this.minimums[r2], max: this.maximums[r2] };
- }
- isLeaf(t2, e2) {
- return this.leaves[this.toIdx(t2, e2)];
- }
- toIdx(t2, e2) {
- return e2 * this.size + t2;
- }
- }
- function uf(t2, e2, r2, n2) {
- let i3 = 0, s2 = Number.MAX_VALUE;
- for (let a2 = 0; a2 < 3; a2++)
- if (Math.abs(n2[a2]) < 1e-15) {
- if (r2[a2] < t2[a2] || r2[a2] > e2[a2])
- return null;
- } else {
- const o2 = 1 / n2[a2];
- let l2 = (t2[a2] - r2[a2]) * o2, u2 = (e2[a2] - r2[a2]) * o2;
- if (l2 > u2) {
- const t3 = l2;
- l2 = u2, u2 = t3;
- }
- if (l2 > i3 && (i3 = l2), u2 < s2 && (s2 = u2), i3 > s2)
- return null;
- }
- return i3;
- }
- function cf(t2, e2, r2, n2, i3, s2, a2, o2, l2, u2, c2) {
- 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;
- if (Math.abs(b2) < 1e-15)
- return null;
- const _2 = 1 / b2, w2 = u2[0] - t2, A2 = u2[1] - e2, k2 = u2[2] - r2, S2 = (w2 * g2 + A2 * x2 + k2 * v2) * _2;
- if (S2 < 0 || S2 > 1)
- return null;
- 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;
- return z2 < 0 || S2 + z2 > 1 ? null : (d2 * I2 + y2 * M2 + m2 * T2) * _2;
- }
- function hf(t2, e2, r2) {
- return (t2 - e2) / (r2 - e2);
- }
- function pf(t2, e2, r2, n2, i3, s2, a2, o2, l2) {
- 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;
- o2[0] = (t2 + 0) / u2 * c2 + n2, o2[1] = f2, l2[0] = p2, l2[1] = d2;
- }
- class ff {
- constructor(t2) {
- 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)
- return;
- const e2 = function(t3) {
- const e3 = Math.ceil(Math.log2(t3.dim / 8)), r3 = [];
- let n3 = Math.ceil(Math.pow(2, e3));
- const i3 = 1 / n3, s2 = (t4, e4, r4, n4, i4) => {
- const s3 = n4 ? 1 : 0, a3 = (t4 + 1) * r4 - s3, o3 = e4 * r4, l2 = (e4 + 1) * r4 - s3;
- i4[0] = t4 * r4, i4[1] = o3, i4[2] = a3, i4[3] = l2;
- };
- let a2 = new lf(n3);
- const o2 = [];
- for (let e4 = 0; e4 < n3 * n3; e4++) {
- s2(e4 % n3, Math.floor(e4 / n3), i3, false, o2);
- 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);
- a2.minimums.push(Math.min(r4, l2, u2, c2)), a2.maximums.push(Math.max(r4, l2, u2, c2)), a2.leaves.push(1);
- }
- for (r3.push(a2), n3 /= 2; n3 >= 1; n3 /= 2) {
- const t4 = r3[r3.length - 1];
- a2 = new lf(n3);
- for (let e4 = 0; e4 < n3 * n3; e4++) {
- s2(e4 % n3, Math.floor(e4 / n3), 2, true, o2);
- 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;
- a2.maximums.push(y2), a2.minimums.push(d2), a2.leaves.push(y2 - d2 <= 5 && m2 ? 1 : 0);
- }
- r3.push(a2);
- }
- return r3;
- }(this.dem), r2 = e2.length - 1, n2 = e2[r2];
- this._addNode(n2.minimums[0], n2.maximums[0], n2.leaves[0]), this._construct(e2, 0, 0, r2, 0);
- }
- raycastRoot(t2, e2, r2, n2, i3, s2, a2 = 1) {
- return uf([t2, e2, -100], [r2, n2, this.maximums[0] * a2], i3, s2);
- }
- raycast(t2, e2, r2, n2, i3, s2, a2 = 1) {
- if (!this.nodeCount)
- return null;
- const o2 = this.raycastRoot(t2, e2, r2, n2, i3, s2, a2);
- if (null == o2)
- return null;
- const l2 = [], u2 = [], c2 = [], h2 = [], p2 = [{ idx: 0, t: o2, nodex: 0, nodey: 0, depth: 0 }];
- for (; p2.length > 0; ) {
- const { idx: o3, t: f2, nodex: d2, nodey: y2, depth: m2 } = p2.pop();
- if (this.leaves[o3]) {
- pf(d2, y2, m2, t2, e2, r2, n2, c2, h2);
- 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);
- if (k2 !== Number.MAX_VALUE)
- return k2;
- {
- const t3 = il([], i3, s2, f2);
- if (df(x2, v2, _2, b2, hf(t3[0], c2[0], h2[0]), hf(t3[1], c2[1], h2[1])) >= t3[2])
- return f2;
- }
- continue;
- }
- let g2 = 0;
- for (let p3 = 0; p3 < this._siblingOffset.length; p3++) {
- 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;
- const f3 = uf(c2, h2, i3, s2);
- if (null != f3) {
- const t3 = f3;
- l2[p3] = t3;
- let e3 = false;
- for (let r3 = 0; r3 < g2 && !e3; r3++)
- t3 >= l2[u2[r3]] && (u2.splice(r3, 0, p3), e3 = true);
- e3 || (u2[g2] = p3), g2++;
- }
- }
- for (let t3 = 0; t3 < g2; t3++) {
- const e3 = u2[t3];
- 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 });
- }
- }
- return null;
- }
- _addNode(t2, e2, r2) {
- return this.minimums.push(t2), this.maximums.push(e2), this.leaves.push(r2), this.childOffsets.push(0), this.nodeCount++;
- }
- _construct(t2, e2, r2, n2, i3) {
- if (1 === t2[n2].isLeaf(e2, r2))
- return;
- this.childOffsets[i3] || (this.childOffsets[i3] = this.nodeCount);
- const s2 = n2 - 1, a2 = t2[s2];
- let o2 = 0, l2 = 0;
- for (let t3 = 0; t3 < this._siblingOffset.length; t3++) {
- 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);
- u2 && (o2 |= 1 << t3), l2 || (l2 = c2);
- }
- for (let n3 = 0; n3 < this._siblingOffset.length; n3++)
- o2 & 1 << n3 || this._construct(t2, 2 * e2 + this._siblingOffset[n3][0], 2 * r2 + this._siblingOffset[n3][1], s2, l2 + n3);
- }
- }
- function df(t2, e2, r2, n2, i3, s2) {
- return rr(rr(t2, r2, s2), rr(e2, n2, s2), i3);
- }
- function yf(t2, e2, r2) {
- 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);
- return df(r2.get(a2, o2), r2.get(l2, o2), r2.get(a2, u2), r2.get(l2, u2), i3 - a2, s2 - o2);
- }
- const mf = { mapbox: [6553.6, 25.6, 0.1, 1e4], terrarium: [256, 1, 1 / 256, 32768] };
- class gf {
- get tree() {
- return this._tree || this._buildQuadTree(), this._tree;
- }
- constructor(t2, e2, r2, n2 = false, i3 = false) {
- if (this.uid = t2, e2.height !== e2.width)
- throw new RangeError("DEM tiles must be square");
- if (r2 && "mapbox" !== r2 && "terrarium" !== r2)
- return C(`"${r2}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);
- this.stride = e2.height;
- const s2 = this.dim = e2.height - 2, a2 = new Uint32Array(e2.data.buffer);
- if (this.pixels = new Uint8Array(e2.data.buffer), this.encoding = r2 || "mapbox", this.borderReady = n2, !n2) {
- for (let t3 = 0; t3 < s2; t3++)
- 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)];
- 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();
- }
- }
- _buildQuadTree() {
- this._tree = new ff(this);
- }
- get(t2, e2, r2 = false) {
- r2 && (t2 = y(t2, -1, this.dim), e2 = y(e2, -1, this.dim));
- const n2 = 4 * this._idx(t2, e2);
- return ("terrarium" === this.encoding ? this._unpackTerrarium : this._unpackMapbox)(this.pixels[n2], this.pixels[n2 + 1], this.pixels[n2 + 2]);
- }
- static getUnpackVector(t2) {
- return mf[t2];
- }
- get unpackVector() {
- return mf[this.encoding];
- }
- _idx(t2, e2) {
- if (t2 < -1 || t2 >= this.dim + 1 || e2 < -1 || e2 >= this.dim + 1)
- throw new RangeError("out of range source coordinates for DEM data");
- return (e2 + 1) * this.stride + (t2 + 1);
- }
- _unpackMapbox(t2, e2, r2) {
- return (256 * t2 * 256 + 256 * e2 + r2) / 10 - 1e4;
- }
- _unpackTerrarium(t2, e2, r2) {
- return 256 * t2 + e2 + r2 / 256 - 32768;
- }
- static pack(t2, e2) {
- const r2 = [0, 0, 0, 0], n2 = gf.getUnpackVector(e2);
- let i3 = Math.floor((t2 + n2[3]) / n2[2]);
- return r2[2] = i3 % 256, i3 = Math.floor(i3 / 256), r2[1] = i3 % 256, i3 = Math.floor(i3 / 256), r2[0] = i3, r2;
- }
- getPixels() {
- return new Bl({ width: this.stride, height: this.stride }, this.pixels);
- }
- backfillBorder(t2, e2, r2) {
- if (this.dim !== t2.dim)
- throw new Error("dem dimension mismatch");
- let n2 = e2 * this.dim, i3 = e2 * this.dim + this.dim, s2 = r2 * this.dim, a2 = r2 * this.dim + this.dim;
- switch (e2) {
- case -1:
- n2 = i3 - 1;
- break;
- case 1:
- i3 = n2 + 1;
- }
- switch (r2) {
- case -1:
- s2 = a2 - 1;
- break;
- case 1:
- a2 = s2 + 1;
- }
- const o2 = -e2 * this.dim, l2 = -r2 * this.dim;
- for (let e3 = s2; e3 < a2; e3++)
- for (let r3 = n2; r3 < i3; r3++) {
- const n3 = 4 * this._idx(r3, e3), i4 = 4 * this._idx(r3 + o2, e3 + l2);
- 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];
- }
- }
- onDeserialize() {
- this._tree && (this._tree.dem = this);
- }
- }
- ai(gf, "DEMData"), ai(ff, "DemMinMaxQuadTree", { omit: ["dem"] });
- class xf {
- constructor(t2, e2) {
- this.max = t2, this.onRemove = e2, this.reset();
- }
- reset() {
- for (const t2 in this.data)
- for (const e2 of this.data[t2])
- e2.timeout && clearTimeout(e2.timeout), this.onRemove(e2.value);
- return this.data = {}, this.order = [], this;
- }
- add(t2, e2, r2) {
- const n2 = t2.wrapped().key;
- void 0 === this.data[n2] && (this.data[n2] = []);
- const i3 = { value: e2, timeout: void 0 };
- if (void 0 !== r2 && (i3.timeout = setTimeout(() => {
- this.remove(t2, i3);
- }, r2)), this.data[n2].push(i3), this.order.push(n2), this.order.length > this.max) {
- const t3 = this._getAndRemoveByKey(this.order[0]);
- t3 && this.onRemove(t3);
- }
- return this;
- }
- has(t2) {
- return t2.wrapped().key in this.data;
- }
- getAndRemove(t2) {
- return this.has(t2) ? this._getAndRemoveByKey(t2.wrapped().key) : null;
- }
- _getAndRemoveByKey(t2) {
- const e2 = this.data[t2].shift();
- 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;
- }
- getByKey(t2) {
- const e2 = this.data[t2];
- return e2 ? e2[0].value : null;
- }
- get(t2) {
- return this.has(t2) ? this.data[t2.wrapped().key][0].value : null;
- }
- remove(t2, e2) {
- if (!this.has(t2))
- return this;
- const r2 = t2.wrapped().key, n2 = void 0 === e2 ? 0 : this.data[r2].indexOf(e2), i3 = this.data[r2][n2];
- 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;
- }
- setMaxSize(t2) {
- for (this.max = t2; this.order.length > this.max; ) {
- const t3 = this._getAndRemoveByKey(this.order[0]);
- t3 && this.onRemove(t3);
- }
- return this;
- }
- filter(t2) {
- const e2 = [];
- for (const r2 in this.data)
- for (const n2 of this.data[r2])
- t2(n2.value) || e2.push(n2);
- for (const t3 of e2)
- this.remove(t3.value.tileID, t3);
- }
- }
- class vf {
- constructor(t2, e2, r2) {
- this.func = t2, this.mask = e2, this.range = r2;
- }
- }
- vf.ReadOnly = false, vf.ReadWrite = true, vf.disabled = new vf(519, vf.ReadOnly, [0, 1]);
- const bf = 7680;
- class _f {
- constructor(t2, e2, r2, n2, i3, s2) {
- this.test = t2, this.ref = e2, this.mask = r2, this.fail = n2, this.depthFail = i3, this.pass = s2;
- }
- }
- _f.disabled = new _f({ func: 519, mask: 0 }, 0, 0, bf, bf, bf);
- class wf {
- constructor(t2, e2, r2) {
- this.blendFunction = t2, this.blendColor = e2, this.mask = r2;
- }
- }
- 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]);
- const Af = 1029, kf = 2305;
- class Sf {
- constructor(t2, e2, r2) {
- this.enable = t2, this.mode = e2, this.frontFace = r2;
- }
- }
- 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);
- class If extends Ut {
- constructor(t2, e2, r2) {
- super(), this.id = t2, this._onlySymbols = r2, e2.on("data", (t3) => {
- "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));
- }), e2.on("error", () => {
- this._sourceErrored = true;
- }), 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;
- }
- onAdd(t2) {
- 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;
- }
- loaded() {
- if (this._sourceErrored)
- return true;
- if (!this._sourceLoaded)
- return false;
- if (!this._source.loaded())
- return false;
- for (const t2 in this._tiles) {
- const e2 = this._tiles[t2];
- if ("loaded" !== e2.state && "errored" !== e2.state)
- return false;
- }
- return true;
- }
- getSource() {
- return this._source;
- }
- pause() {
- this._paused = true;
- }
- resume() {
- if (!this._paused)
- return;
- const t2 = this._shouldReloadOnResume;
- this._paused = false, this._shouldReloadOnResume = false, t2 && this.reload(), this.transform && this.update(this.transform);
- }
- _loadTile(t2, e2) {
- return t2.isSymbolTile = this._onlySymbols, this._source.loadTile(t2, e2);
- }
- _unloadTile(t2) {
- if (this._source.unloadTile)
- return this._source.unloadTile(t2, () => {
- });
- }
- _abortTile(t2) {
- if (this._source.abortTile)
- return this._source.abortTile(t2, () => {
- });
- }
- serialize() {
- return this._source.serialize();
- }
- prepare(t2) {
- if (this._source.prepare && this._source.prepare(), this._state.coalesceChanges(this._tiles, this.map ? this.map.painter : null), this._source.prepareTile)
- for (const e2 in this._tiles) {
- const r2 = this._tiles[e2];
- 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);
- }
- else
- for (const e2 in this._tiles) {
- const r2 = this._tiles[e2];
- r2.upload(t2), r2.prepare(this.map.style.imageManager);
- }
- }
- getIds() {
- return v(this._tiles).map((t2) => t2.tileID).sort(Mf).map((t2) => t2.key);
- }
- getRenderableIds(t2) {
- const e2 = [];
- for (const r2 in this._tiles)
- this._isIdRenderable(+r2, t2) && e2.push(this._tiles[r2]);
- return t2 ? e2.sort((t3, e3) => {
- 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);
- return r2.overscaledZ - n2.overscaledZ || a2.y - s2.y || a2.x - s2.x;
- }).map((t3) => t3.tileID.key) : e2.map((t3) => t3.tileID).sort(Mf).map((t3) => t3.key);
- }
- hasRenderableParent(t2) {
- const e2 = this.findLoadedParent(t2, 0);
- return !!e2 && this._isIdRenderable(e2.tileID.key);
- }
- _isIdRenderable(t2, e2) {
- return this._tiles[t2] && this._tiles[t2].hasData() && !this._coveredTiles[t2] && (e2 || !this._tiles[t2].holdingForFade());
- }
- reload() {
- if (this._paused)
- this._shouldReloadOnResume = true;
- else {
- this._cache.reset();
- for (const t2 in this._tiles)
- "errored" !== this._tiles[t2].state && this._reloadTile(+t2, "reloading");
- }
- }
- _reloadTile(t2, e2) {
- const r2 = this._tiles[t2];
- r2 && ("loading" !== r2.state && (r2.state = e2), this._loadTile(r2, this._tileLoaded.bind(this, r2, t2, e2)));
- }
- _tileLoaded(t2, e2, r2, n2) {
- if (n2)
- if (t2.state = "errored", 404 !== n2.status)
- this._source.fire(new Rt(n2, { tile: t2 }));
- else if ("raster-dem" === this._source.type && this.usedForTerrain && this.map.painter.terrain) {
- const t3 = this.map.painter.terrain;
- this.update(this.transform, t3.getScaledDemTileSize(), true), t3.resetTileLookupCache(this.id);
- } else
- this.update(this.transform);
- else
- 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 }));
- }
- _backfillDEM(t2) {
- const e2 = this.getRenderableIds();
- for (let n2 = 0; n2 < e2.length; n2++) {
- const i3 = e2[n2];
- if (t2.neighboringTiles && t2.neighboringTiles[i3]) {
- const e3 = this.getTileByID(i3);
- r2(t2, e3), r2(e3, t2);
- }
- }
- function r2(t3, e3) {
- if (!t3.dem || t3.dem.borderReady)
- return;
- t3.needsHillshadePrepare = true, t3.needsDEMTextureUpload = true;
- let r3 = e3.tileID.canonical.x - t3.tileID.canonical.x;
- const n2 = e3.tileID.canonical.y - t3.tileID.canonical.y, i3 = Math.pow(2, t3.tileID.canonical.z), s2 = e3.tileID.key;
- 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)));
- }
- }
- getTile(t2) {
- return this.getTileByID(t2.key);
- }
- getTileByID(t2) {
- return this._tiles[t2];
- }
- _retainLoadedChildren(t2, e2, r2, n2) {
- for (const i3 in this._tiles) {
- let s2 = this._tiles[i3];
- if (n2[i3] || !s2.hasData() || s2.tileID.overscaledZ <= e2 || s2.tileID.overscaledZ > r2)
- continue;
- let a2 = s2.tileID;
- for (; s2 && s2.tileID.overscaledZ > e2 + 1; ) {
- const t3 = s2.tileID.scaledTo(s2.tileID.overscaledZ - 1);
- s2 = this._tiles[t3.key], s2 && s2.hasData() && (a2 = t3);
- }
- let o2 = a2;
- for (; o2.overscaledZ > e2; )
- if (o2 = o2.scaledTo(o2.overscaledZ - 1), t2[o2.key]) {
- n2[a2.key] = a2;
- break;
- }
- }
- }
- findLoadedParent(t2, e2) {
- if (t2.key in this._loadedParentTiles) {
- const r2 = this._loadedParentTiles[t2.key];
- return r2 && r2.tileID.overscaledZ >= e2 ? r2 : null;
- }
- for (let r2 = t2.overscaledZ - 1; r2 >= e2; r2--) {
- const e3 = t2.scaledTo(r2), n2 = this._getLoadedTile(e3);
- if (n2)
- return n2;
- }
- }
- _getLoadedTile(t2) {
- const e2 = this._tiles[t2.key];
- return e2 && e2.hasData() ? e2 : this._cache.getByKey(this._source.reparseOverscaled ? t2.wrapped().key : t2.canonical.key);
- }
- updateCacheSize(t2, e2) {
- e2 = e2 || this._source.tileSize;
- 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;
- this._cache.setMaxSize(a2);
- }
- handleWrapJump(t2) {
- const e2 = Math.round((t2 - (void 0 === this._prevLng ? t2 : this._prevLng)) / 360);
- if (this._prevLng = t2, e2) {
- const t3 = {};
- for (const r2 in this._tiles) {
- const n2 = this._tiles[r2];
- n2.tileID = n2.tileID.unwrapTo(n2.tileID.wrap + e2), t3[n2.tileID.key] = n2;
- }
- this._tiles = t3;
- for (const t4 in this._timers)
- clearTimeout(this._timers[t4]), delete this._timers[t4];
- for (const t4 in this._tiles)
- this._setTileReloadTimer(+t4, this._tiles[t4]);
- }
- }
- update(t2, e2, r2) {
- if (this.transform = t2, !this._sourceLoaded || this._paused || this.transform.freezeTileCoverage)
- return;
- if (this.usedForTerrain && !r2)
- return;
- let n2;
- 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 = [];
- const i3 = this._updateRetainedTiles(n2);
- if (Tf(this._source.type) && 0 !== n2.length) {
- const t3 = {}, e3 = {}, r3 = Object.keys(i3);
- for (const n3 of r3) {
- const r4 = i3[n3], s4 = this._tiles[n3];
- if (!s4 || s4.fadeEndTime && s4.fadeEndTime <= N.now())
- continue;
- const a2 = this.findLoadedParent(r4, Math.max(r4.overscaledZ - If.maxOverzooming, this._source.minzoom));
- a2 && (this._addTile(a2.tileID), t3[a2.tileID.key] = a2.tileID), e3[n3] = r4;
- }
- const s3 = n2[n2.length - 1].overscaledZ;
- for (const t4 in this._tiles) {
- const r4 = this._tiles[t4];
- if (i3[t4] || !r4.hasData())
- continue;
- let n3 = r4.tileID;
- for (; n3.overscaledZ > s3; ) {
- n3 = n3.scaledTo(n3.overscaledZ - 1);
- const s4 = this._tiles[n3.key];
- if (s4 && s4.hasData() && e3[n3.key]) {
- i3[t4] = r4.tileID;
- break;
- }
- }
- }
- for (const e4 in t3)
- i3[e4] || (this._coveredTiles[e4] = true, i3[e4] = t3[e4]);
- }
- for (const t3 in i3)
- this._tiles[t3].clearFadeHold();
- const s2 = function(t3, e3) {
- const r3 = [];
- for (const n3 in t3)
- n3 in e3 || r3.push(n3);
- return r3;
- }(this._tiles, i3);
- for (const t3 of s2) {
- const e3 = this._tiles[t3];
- e3.hasSymbolBuckets && !e3.holdingForFade() ? e3.setHoldDuration(this.map._fadeDuration) : e3.hasSymbolBuckets && !e3.symbolFadeFinished() || this._removeTile(+t3);
- }
- this._updateLoadedParentTileCache(), this._onlySymbols && this._source.afterUpdate && this._source.afterUpdate();
- }
- releaseSymbolFadeTiles() {
- for (const t2 in this._tiles)
- this._tiles[t2].holdingForFade() && this._removeTile(+t2);
- }
- _updateRetainedTiles(t2) {
- const e2 = {};
- if (0 === t2.length)
- return e2;
- 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 = {};
- for (const r3 of t2) {
- const t3 = this._addTile(r3);
- e2[r3.key] = r3, t3.hasData() || n2 < this._source.maxzoom && (o2[r3.key] = r3);
- }
- this._retainLoadedChildren(o2, n2, a2, e2);
- for (const n3 of t2) {
- let t3 = this._tiles[n3.key];
- if (t3.hasData())
- continue;
- if (n3.canonical.z >= this._source.maxzoom) {
- const t4 = n3.children(this._source.maxzoom)[0], r3 = this.getTile(t4);
- if (r3 && r3.hasData()) {
- e2[t4.key] = t4;
- continue;
- }
- } else {
- const t4 = n3.children(this._source.maxzoom);
- if (e2[t4[0].key] && e2[t4[1].key] && e2[t4[2].key] && e2[t4[3].key])
- continue;
- }
- let i4 = t3.wasRequested();
- for (let a3 = n3.overscaledZ - 1; a3 >= s2; --a3) {
- const s3 = n3.scaledTo(a3);
- if (r2[s3.key])
- break;
- 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()))
- break;
- }
- }
- return e2;
- }
- _updateLoadedParentTileCache() {
- this._loadedParentTiles = {};
- for (const t2 in this._tiles) {
- const e2 = [];
- let r2, n2 = this._tiles[t2].tileID;
- for (; n2.overscaledZ > 0; ) {
- if (n2.key in this._loadedParentTiles) {
- r2 = this._loadedParentTiles[n2.key];
- break;
- }
- e2.push(n2.key);
- const t3 = n2.scaledTo(n2.overscaledZ - 1);
- if (r2 = this._getLoadedTile(t3), r2)
- break;
- n2 = t3;
- }
- for (const t3 of e2)
- this._loadedParentTiles[t3] = r2;
- }
- }
- _addTile(t2) {
- let e2 = this._tiles[t2.key];
- if (e2)
- return this._source.prepareTile && this._source.prepareTile(e2), e2;
- 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)));
- const r2 = Boolean(e2);
- if (!r2) {
- const r3 = this.map ? this.map.painter : null;
- 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));
- }
- 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;
- }
- _setTileReloadTimer(t2, e2) {
- t2 in this._timers && (clearTimeout(this._timers[t2]), delete this._timers[t2]);
- const r2 = e2.getExpiryTimeout();
- r2 && (this._timers[t2] = setTimeout(() => {
- this._reloadTile(t2, "expired"), delete this._timers[t2];
- }, r2));
- }
- _removeTile(t2) {
- const e2 = this._tiles[t2];
- 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))));
- }
- clearTiles() {
- this._shouldReloadOnResume = false, this._paused = false;
- for (const t2 in this._tiles)
- this._removeTile(+t2);
- this._source._clear && this._source._clear(), this._cache.reset(), this.map && this.usedForTerrain && this.map.painter.terrain && this.map.painter.terrain.resetTileLookupCache(this.id);
- }
- tilesIn(t2, e2, r2) {
- const n2 = [], i3 = this.transform;
- if (!i3)
- return n2;
- for (const s2 in this._tiles) {
- const a2 = this._tiles[s2];
- if (r2 && a2.clearQueryDebugViz(), a2.holdingForFade())
- continue;
- const o2 = t2.containsTile(a2, i3, e2);
- o2 && n2.push(o2);
- }
- return n2;
- }
- getVisibleCoordinates(t2) {
- const e2 = this.getRenderableIds(t2).map((t3) => this._tiles[t3].tileID);
- for (const t3 of e2)
- t3.projMatrix = this.transform.calculateProjMatrix(t3.toUnwrapped());
- return e2;
- }
- hasTransition() {
- if (this._source.hasTransition())
- return true;
- if (Tf(this._source.type))
- for (const t2 in this._tiles) {
- const e2 = this._tiles[t2];
- if (void 0 !== e2.fadeEndTime && e2.fadeEndTime >= N.now())
- return true;
- }
- return false;
- }
- setFeatureState(t2, e2, r2) {
- this._state.updateState(t2 = t2 || "_geojsonTileLayer", e2, r2);
- }
- removeFeatureState(t2, e2, r2) {
- this._state.removeFeatureState(t2 = t2 || "_geojsonTileLayer", e2, r2);
- }
- getFeatureState(t2, e2) {
- return this._state.getState(t2 = t2 || "_geojsonTileLayer", e2);
- }
- setDependencies(t2, e2, r2) {
- const n2 = this._tiles[t2];
- n2 && n2.setDependencies(e2, r2);
- }
- reloadTilesForDependencies(t2, e2) {
- for (const r2 in this._tiles)
- this._tiles[r2].hasDependency(t2, e2) && this._reloadTile(+r2, "reloading");
- this._cache.filter((r2) => !r2.hasDependency(t2, e2));
- }
- _preloadTiles(t2, e2) {
- 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;
- for (const t3 of n2) {
- 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 });
- for (const t4 of e3)
- r2.set(t4.key, t4);
- this.usedForTerrain && t3.updateElevation(false);
- }
- x(Array.from(r2.values()), (t3, e3) => {
- const r3 = new af(t3, this._source.tileSize * t3.overscaleFactor(), this.transform.tileZoom, this.map.painter, this._isRaster);
- this._loadTile(r3, (t4) => {
- "raster-dem" === this._source.type && r3.dem && this._backfillDEM(r3), e3(t4, r3);
- });
- }, e2);
- }
- }
- function Mf(t2, e2) {
- const r2 = Math.abs(2 * t2.wrap) - +(t2.wrap < 0), n2 = Math.abs(2 * e2.wrap) - +(e2.wrap < 0);
- return t2.overscaledZ - e2.overscaledZ || n2 - r2 || e2.canonical.y - t2.canonical.y || e2.canonical.x - t2.canonical.x;
- }
- function Tf(t2) {
- return "raster" === t2 || "image" === t2 || "video" === t2;
- }
- If.maxOverzooming = 10, If.maxUnderzooming = 3;
- class zf {
- constructor(t2, e2, r2) {
- this._demTile = t2, this._dem = this._demTile.dem, this._scale = e2, this._offset = r2;
- }
- static create(t2, e2, r2) {
- const n2 = r2 || t2.findDEMTileFor(e2);
- if (!n2 || !n2.dem)
- return;
- const i3 = n2.dem, s2 = n2.tileID, a2 = 1 << e2.canonical.z - s2.canonical.z;
- 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]);
- }
- tileCoordToPixel(t2, e2) {
- const r2 = e2 * this._scale + this._offset[1], n2 = Math.floor(t2 * this._scale + this._offset[0]), s2 = Math.floor(r2);
- return new i2(n2, s2);
- }
- getElevationAt(t2, e2, r2, n2) {
- 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;
- 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);
- }
- getElevationAtPixel(t2, e2, r2) {
- return this._dem.get(t2, e2, !!r2);
- }
- getMeterToDEM(t2) {
- return (1 << this._demTile.tileID.canonical.z) * no(1, t2) * this._dem.stride;
- }
- }
- class Bf {
- constructor(t2, e2) {
- 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;
- }
- insert(t2, e2, r2, n2, i3, s2 = 0) {
- const a2 = this.featureIndexArray.length;
- this.featureIndexArray.emplaceBack(r2, n2, i3, s2);
- const o2 = this.grid;
- for (let t3 = 0; t3 < e2.length; t3++) {
- const r3 = e2[t3], n3 = [1 / 0, 1 / 0, -1 / 0, -1 / 0];
- for (let t4 = 0; t4 < r3.length; t4++) {
- const e3 = r3[t4];
- 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);
- }
- n3[0] < Ya && n3[1] < Ya && n3[2] >= 0 && n3[3] >= 0 && o2.insert(a2, n3[0], n3[1], n3[2], n3[3]);
- }
- }
- loadVTLayers() {
- if (!this.vtLayers) {
- this.vtLayers = new Du.VectorTile(new wc(this.rawTileData)).layers, this.sourceLayerCoder = new Xp(this.vtLayers ? Object.keys(this.vtLayers).sort() : ["_geojsonTileLayer"]), this.vtFeatures = {};
- for (const t2 in this.vtLayers)
- this.vtFeatures[t2] = [];
- }
- return this.vtLayers;
- }
- query(t2, e2, r2, n2) {
- this.loadVTLayers();
- 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));
- u2.sort(Cf);
- let c2 = null;
- o2.elevation && u2.length > 0 && (c2 = zf.create(o2.elevation, this.tileID));
- const h2 = {};
- let p2;
- for (let o3 = 0; o3 < u2.length; o3++) {
- const l3 = u2[o3];
- if (l3 === p2)
- continue;
- p2 = l3;
- const f2 = this.featureIndexArray.get(l3);
- let d2 = null;
- 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)));
- }
- return h2;
- }
- loadMatchingFeature(t2, e2, r2, n2, i3, s2, a2, o2, l2) {
- const { featureIndex: u2, bucketIndex: c2, sourceLayerIndex: h2, layoutVertexArrayOffset: p2 } = e2, f2 = this.bucketLayerIDs[c2];
- if (n2 && !function(t3, e3) {
- for (let r3 = 0; r3 < t3.length; r3++)
- if (e3.indexOf(t3[r3]) >= 0)
- return true;
- return false;
- }(n2, f2))
- return;
- const d2 = this.sourceLayerCoder.decode(h2), y2 = this.vtLayers[d2].feature(u2);
- if (r2.needGeometry) {
- const t3 = mo(y2, true);
- if (!r2.filter(new ss(this.tileID.overscaledZ), t3, this.tileID.canonical))
- return;
- } else if (!r2.filter(new ss(this.tileID.overscaledZ), y2))
- return;
- const m2 = this.getId(y2, d2);
- for (let e3 = 0; e3 < f2.length; e3++) {
- const r3 = f2[e3];
- if (n2 && n2.indexOf(r3) < 0)
- continue;
- const c3 = s2[r3];
- if (!c3)
- continue;
- let h3 = {};
- void 0 !== m2 && o2 && (h3 = o2.getState(c3.sourceLayer || "_geojsonTileLayer", m2));
- const d3 = b({}, a2[r3]);
- d3.paint = Ef(d3.paint, c3.paint, y2, h3, i3), d3.layout = Ef(d3.layout, c3.layout, y2, h3, i3);
- const g2 = !l2 || l2(y2, c3, h3, p2);
- if (!g2)
- continue;
- const x2 = new Yp(y2, this.z, this.x, this.y, m2);
- x2.layer = d3;
- let v2 = t2[r3];
- void 0 === v2 && (v2 = t2[r3] = []), v2.push({ featureIndex: u2, feature: x2, intersectionZ: g2 });
- }
- }
- lookupSymbolFeatures(t2, e2, r2, n2, i3, s2, a2, o2) {
- const l2 = {};
- this.loadVTLayers();
- const u2 = Sn(i3);
- for (const i4 of t2)
- this.loadMatchingFeature(l2, { bucketIndex: r2, sourceLayerIndex: n2, featureIndex: i4, layoutVertexArrayOffset: 0 }, u2, s2, a2, o2, e2);
- return l2;
- }
- loadFeature(t2) {
- const { featureIndex: e2, sourceLayerIndex: r2 } = t2;
- this.loadVTLayers();
- const n2 = this.sourceLayerCoder.decode(r2), i3 = this.vtFeatures[n2];
- if (i3[e2])
- return i3[e2];
- const s2 = this.vtLayers[n2].feature(e2);
- return i3[e2] = s2, s2;
- }
- hasLayer(t2) {
- for (const e2 of this.bucketLayerIDs)
- for (const r2 of e2)
- if (t2 === r2)
- return true;
- return false;
- }
- getId(t2, e2) {
- let r2 = t2.id;
- return this.promoteId && (r2 = t2.properties["string" == typeof this.promoteId ? this.promoteId : this.promoteId[e2]], "boolean" == typeof r2 && (r2 = Number(r2))), r2;
- }
- }
- function Ef(t2, e2, r2, n2, i3) {
- return T(t2, (t3, s2) => {
- const a2 = e2 instanceof fs ? e2.get(s2) : null;
- return a2 && a2.evaluate ? a2.evaluate(r2, n2, i3) : a2;
- });
- }
- function Cf(t2, e2) {
- return e2 - t2;
- }
- ai(Bf, "FeatureIndex", { omit: ["rawTileData", "sourceLayerCoder"] });
- class Df {
- constructor(t2) {
- const e2 = {}, r2 = [];
- for (const n3 in t2) {
- const i4 = t2[n3], s3 = e2[n3] = {};
- for (const t3 in i4.glyphs) {
- const e3 = i4.glyphs[+t3];
- if (!e3 || 0 === e3.bitmap.width || 0 === e3.bitmap.height)
- continue;
- const n4 = e3.metrics.localGlyph ? 2 : 1, a2 = { x: 0, y: 0, w: e3.bitmap.width + 2 * n4, h: e3.bitmap.height + 2 * n4 };
- r2.push(a2), s3[t3] = a2;
- }
- }
- const { w: n2, h: i3 } = Gc(r2), s2 = new zl({ width: n2 || 1, height: i3 || 1 });
- for (const r3 in t2) {
- const n3 = t2[r3];
- for (const t3 in n3.glyphs) {
- const i4 = n3.glyphs[+t3];
- if (!i4 || 0 === i4.bitmap.width || 0 === i4.bitmap.height)
- continue;
- const a2 = e2[r3][t3], o2 = i4.metrics.localGlyph ? 2 : 1;
- zl.copy(i4.bitmap, s2, { x: 0, y: 0 }, { x: a2.x + o2, y: a2.y + o2 }, i4.bitmap);
- }
- }
- this.image = s2, this.positions = e2;
- }
- }
- ai(Df, "GlyphAtlas");
- class Pf {
- constructor(t2) {
- 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;
- }
- parse(t2, e2, r2, n2, i3) {
- this.status = "parsing", this.data = t2, this.collisionBoxArray = new ea();
- const s2 = new Xp(Object.keys(t2.layers).sort()), a2 = new Bf(this.tileID, this.promoteId);
- a2.bucketLayerIDs = [];
- const o2 = {}, l2 = new pp(256, 256), u2 = { featureIndex: a2, iconDependencies: {}, patternDependencies: {}, glyphDependencies: {}, lineAtlas: l2, availableImages: r2 }, c2 = e2.familiesBySource[this.source];
- for (const e3 in c2) {
- const n3 = t2.layers[e3];
- if (!n3)
- continue;
- let i4 = false, l3 = false;
- for (const t3 of c2[e3])
- "symbol" === t3[0].type ? i4 = true : l3 = true;
- if (true === this.isSymbolTile && !i4)
- continue;
- if (false === this.isSymbolTile && !l3)
- continue;
- 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.`);
- const h3 = s2.encode(e3), p3 = [];
- for (let t3 = 0; t3 < n3.length; t3++) {
- const r3 = n3.feature(t3), i5 = a2.getId(r3, e3);
- p3.push({ feature: r3, id: i5, index: t3, sourceLayerIndex: h3 });
- }
- for (const t3 of c2[e3]) {
- const e4 = t3[0];
- 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)));
- }
- }
- let h2, p2, f2, d2;
- l2.trim();
- const y2 = { type: "maybePrepare", isSymbolTile: this.isSymbolTile, zoom: this.zoom }, m2 = T(u2.glyphDependencies, (t3) => Object.keys(t3).map(Number));
- Object.keys(m2).length ? n2.send("getGlyphs", { uid: this.uid, stacks: m2 }, (t3, e3) => {
- h2 || (h2 = t3, p2 = e3, b2.call(this));
- }, void 0, false, y2) : p2 = {};
- const g2 = Object.keys(u2.iconDependencies);
- g2.length ? n2.send("getImages", { icons: g2, source: this.source, tileID: this.tileID, type: "icons" }, (t3, e3) => {
- h2 || (h2 = t3, f2 = e3, b2.call(this));
- }, void 0, false, y2) : f2 = {};
- const x2 = Object.keys(u2.patternDependencies);
- function b2() {
- if (h2)
- return i3(h2);
- if (p2 && f2 && d2) {
- const t3 = new Df(p2), e3 = new Xc(f2, d2);
- for (const n3 in o2) {
- const i4 = o2[n3];
- 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));
- }
- 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 });
- }
- }
- x2.length ? n2.send("getImages", { icons: x2, source: this.source, tileID: this.tileID, type: "patterns" }, (t3, e3) => {
- h2 || (h2 = t3, d2 = e3, b2.call(this));
- }, void 0, false, y2) : d2 = {}, b2.call(this);
- }
- }
- function Vf(t2, e2, r2) {
- const n2 = new ss(e2);
- for (const e3 of t2)
- e3.recalculate(n2, r2);
- }
- class Ff {
- constructor(t2) {
- this.entries = {}, this.scheduler = t2;
- }
- request(t2, e2, r2, n2) {
- const i3 = this.entries[t2] = this.entries[t2] || { callbacks: [] };
- if (i3.result) {
- const [t3, r3] = i3.result;
- return this.scheduler ? this.scheduler.add(() => {
- n2(t3, r3);
- }, e2) : n2(t3, r3), () => {
- };
- }
- return i3.callbacks.push(n2), i3.cancel || (i3.cancel = r2((r3, n3) => {
- i3.result = [r3, n3];
- for (const t3 of i3.callbacks)
- this.scheduler ? this.scheduler.add(() => {
- t3(r3, n3);
- }, e2) : t3(r3, n3);
- setTimeout(() => delete this.entries[t2], 3e3);
- })), () => {
- i3.result || (i3.callbacks = i3.callbacks.filter((t3) => t3 !== n2), i3.callbacks.length || (i3.cancel(), delete this.entries[t2]));
- };
- }
- }
- function Lf(t2, e2, r2) {
- const n2 = JSON.stringify(t2.request);
- return t2.data && (this.deduped.entries[n2] = { result: [null, t2.data] }), this.deduped.request(n2, { type: "parseTile", isSymbolTile: t2.isSymbolTile, zoom: t2.tileZoom }, (e3) => {
- const n3 = Mt(t2.request, (t3, n4, i3, s2) => {
- t3 ? e3(t3) : n4 && e3(null, { vectorTile: r2 ? void 0 : new Du.VectorTile(new wc(n4)), rawData: n4, cacheControl: i3, expires: s2 });
- });
- return () => {
- n3.cancel(), e3();
- };
- }, e2);
- }
- const Rf = jo(new Float32Array(16));
- class Uf {
- constructor(t2) {
- 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];
- }
- project(t2, e2) {
- return { x: 0, y: 0, z: 0 };
- }
- unproject(t2, e2) {
- return new Ja(0, 0);
- }
- projectTilePoint(t2, e2, r2) {
- return { x: t2, y: e2, z: 0 };
- }
- locationPoint(t2, e2) {
- return t2._coordinatePoint(t2.locationCoordinate(e2), false);
- }
- pixelsPerMeter(t2, e2) {
- return no(1, t2) * e2;
- }
- farthestPixelDistance(t2) {
- return function(t3, e2) {
- 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;
- return Math.min(1.01 * a2, i3 * (1 / t3._horizonShift));
- }(t2, t2.pixelsPerMeter);
- }
- pointCoordinate(t2, e2, r2, n2) {
- const s2 = t2.horizonLineFromTop(false), a2 = new i2(e2, Math.max(s2, r2));
- return t2.rayIntersectionCoordinate(t2.pointRayIntersection(a2, n2));
- }
- createInversionMatrix(t2, e2) {
- return Rf;
- }
- createTileMatrix(t2, e2, r2) {
- let n2, i3, s2;
- const a2 = r2.canonical, o2 = jo(new Float64Array(16));
- if (this.isReprojectedInTileSpace) {
- const l2 = Zp(a2, this);
- n2 = 1, i3 = l2.x + r2.wrap * l2.scale, s2 = l2.y, No(o2, o2, [n2 / l2.scale, n2 / l2.scale, t2.pixelsPerMeter / e2]);
- } else
- n2 = e2 / t2.zoomScale(a2.z), i3 = (a2.x + Math.pow(2, a2.z) * r2.wrap) * n2, s2 = a2.y * n2;
- return qo(o2, o2, [i3, s2, 0]), No(o2, o2, [n2 / Ya, n2 / Ya, 1]), o2;
- }
- upVector(t2, e2, r2) {
- return [0, 0, 1];
- }
- upVectorScale(t2, e2, r2) {
- return { metersToTile: 1, metersToLabelSpace: 1 };
- }
- }
- class $f extends Uf {
- constructor(t2) {
- 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;
- }
- project(t2, e2) {
- return { x: eo(t2), y: ro(e2), z: 0 };
- }
- unproject(t2, e2) {
- const r2 = io(t2), n2 = so(e2);
- return new Ja(r2, n2);
- }
- }
- class jf extends Uf {
- constructor(t2) {
- super(t2), this.range = [4, 7], this.center = t2.center || [-96, 37.5];
- const [e2, r2] = this.parallels = t2.parallels || [29.5, 45.5], n2 = Math.sin(u(e2));
- this.n = (n2 + Math.sin(u(r2))) / 2, this.c = 1 + n2 * (2 * this.n - n2), this.r0 = Math.sqrt(this.c) / this.n;
- }
- project(t2, e2) {
- 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;
- return { x: o2 * Math.sin(s2 * r2), y: o2 * Math.cos(s2 * r2) - i3, z: 0 };
- }
- unproject(t2, e2) {
- const { n: r2, c: n2, r0: i3 } = this, s2 = i3 + e2;
- let a2 = Math.atan2(t2, Math.abs(s2)) * Math.sign(s2);
- s2 * r2 < 0 && (a2 -= Math.PI * Math.sign(t2) * Math.sign(s2));
- const o2 = u(this.center[0]) * r2;
- a2 = g(a2, -Math.PI - o2, Math.PI - o2);
- 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);
- return new Ja(l2, p2);
- }
- }
- const Of = 1.340264, qf = -0.081106, Nf = 893e-6, Gf = 3796e-6, Zf = Math.sqrt(3) / 2;
- class Xf extends Uf {
- project(t2, e2) {
- e2 = e2 / 180 * Math.PI, t2 = t2 / 180 * Math.PI;
- const r2 = Math.asin(Zf * Math.sin(e2)), n2 = r2 * r2, i3 = n2 * n2 * n2;
- 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 };
- }
- unproject(t2, e2) {
- t2 = (2 * t2 - 0.5) * Math.PI;
- let r2 = e2 = (2 * (1 - e2) - 1) * Math.PI, n2 = r2 * r2, i3 = n2 * n2 * n2;
- 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)
- ;
- 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);
- return new Ja(o2, l2);
- }
- }
- class Kf extends Uf {
- constructor(t2) {
- super(t2), this.wrap = true, this.supportsWorldCopies = true;
- }
- project(t2, e2) {
- return { x: 0.5 + t2 / 360, y: 0.5 - e2 / 360, z: 0 };
- }
- unproject(t2, e2) {
- const r2 = 360 * (t2 - 0.5), n2 = y(360 * (0.5 - e2), -85.051129, oo);
- return new Ja(r2, n2);
- }
- }
- const Yf = Math.PI / 2;
- function Hf(t2) {
- return Math.tan((Yf + t2) / 2);
- }
- class Wf extends Uf {
- constructor(t2) {
- super(t2), this.center = t2.center || [0, 30];
- const [e2, r2] = this.parallels = t2.parallels || [30, 30], n2 = u(e2), i3 = u(r2), s2 = Math.cos(n2);
- 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;
- }
- project(t2, e2) {
- e2 = u(e2), t2 = u(t2 - this.center[0]);
- const r2 = 1e-6, { n: n2, f: i3 } = this;
- i3 > 0 ? e2 < -Yf + r2 && (e2 = -Yf + r2) : e2 > Yf - r2 && (e2 = Yf - r2);
- const s2 = i3 / Math.pow(Hf(e2), n2), a2 = s2 * Math.sin(n2 * t2), o2 = i3 - s2 * Math.cos(n2 * t2);
- return { x: 0.5 * (a2 / Math.PI + 0.5), y: 1 - 0.5 * (o2 / Math.PI + 0.5), z: 0 };
- }
- unproject(t2, e2) {
- t2 = (2 * t2 - 0.5) * Math.PI, e2 = (2 * (1 - e2) - 0.5) * Math.PI;
- const { n: r2, f: n2 } = this, i3 = n2 - e2, s2 = Math.sign(i3), a2 = Math.sign(r2) * Math.sqrt(t2 * t2 + i3 * i3);
- let o2 = Math.atan2(t2, Math.abs(i3)) * s2;
- i3 * r2 < 0 && (o2 -= Math.PI * Math.sign(t2) * s2);
- 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);
- return new Ja(l2, u2);
- }
- }
- const Jf = u(oo);
- class Qf extends Uf {
- project(t2, e2) {
- const r2 = (e2 = u(e2)) * e2, n2 = r2 * r2;
- 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 };
- }
- unproject(t2, e2) {
- t2 = (2 * t2 - 0.5) * Math.PI;
- let r2 = e2 = (2 * (1 - e2) - 1) * Math.PI, n2 = 25, i3 = 0, s2 = r2 * r2;
- do {
- s2 = r2 * r2;
- const t3 = s2 * s2;
- 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);
- } while (Math.abs(i3) > 1e-6 && --n2 > 0);
- s2 = r2 * r2;
- 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);
- return new Ja(a2, o2);
- }
- }
- const td = u(oo);
- class ed extends Uf {
- project(t2, e2) {
- e2 = u(e2), t2 = u(t2);
- 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;
- return { x: 0.5 * (a2 / Math.PI + 0.5), y: 1 - 0.5 * (o2 / Math.PI + 1), z: 0 };
- }
- unproject(t2, e2) {
- let r2 = t2 = (2 * t2 - 0.5) * Math.PI, n2 = e2 = (2 * (1 - e2) - 1) * Math.PI, i3 = 25;
- const s2 = 1e-6;
- let a2 = 0, o2 = 0;
- do {
- 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;
- 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);
- } while ((Math.abs(a2) > s2 || Math.abs(o2) > s2) && --i3 > 0);
- return new Ja(c(r2), c(n2));
- }
- }
- class rd extends Uf {
- constructor(t2) {
- 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;
- }
- project(t2, e2) {
- const { scale: r2, cosPhi: n2 } = this;
- return { x: u(t2) * n2 * r2 + 0.5, y: -Math.sin(u(e2)) / n2 * r2 + 0.5, z: 0 };
- }
- unproject(t2, e2) {
- 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);
- return new Ja(s2, o2);
- }
- }
- t.ARRAY_TYPE = Uo, t.AUTH_ERR_MSG = tt, t.Aabb = vl, t.Actor = class {
- constructor(t2, e2, r2) {
- 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();
- }
- send(t2, e2, r2, n2, i3 = false, s2) {
- const a2 = Math.round(1e18 * Math.random()).toString(36).substring(0, 10);
- r2 && (r2.metadata = s2, this.callbacks[a2] = r2);
- const o2 = O(this.globalScope) ? void 0 : [];
- return this.target.postMessage({ id: a2, type: t2, hasCallback: !!r2, targetMapId: n2, mustQueue: i3, sourceMapId: this.mapId, data: ui(e2, o2) }, o2), { cancel: () => {
- r2 && delete this.callbacks[a2], this.target.postMessage({ id: a2, type: "<cancel>", targetMapId: n2, sourceMapId: this.mapId });
- } };
- }
- receive(t2) {
- const e2 = t2.data, r2 = e2.id;
- if (r2 && (!e2.targetMapId || this.mapId === e2.targetMapId))
- if ("<cancel>" === e2.type) {
- const t3 = this.cancelCallbacks[r2];
- delete this.cancelCallbacks[r2], t3 && t3.cancel();
- } else if (e2.mustQueue || V()) {
- const t3 = this.callbacks[r2];
- this.cancelCallbacks[r2] = this.scheduler.add(() => this.processTask(r2, e2), t3 && t3.metadata || { type: "message" });
- } else
- this.processTask(r2, e2);
- }
- processTask(t2, e2) {
- if ("<response>" === e2.type) {
- const r2 = this.callbacks[t2];
- delete this.callbacks[t2], r2 && (e2.error ? r2(ci(e2.error)) : r2(null, ci(e2.data)));
- } else {
- const r2 = O(this.globalScope) ? void 0 : [], n2 = e2.hasCallback ? (e3, n3) => {
- delete this.cancelCallbacks[t2], this.target.postMessage({ id: t2, type: "<response>", sourceMapId: this.mapId, error: e3 ? ui(e3) : null, data: ui(n3, r2) }, r2);
- } : (t3) => {
- }, i3 = ci(e2.data);
- if (this.parent[e2.type])
- this.parent[e2.type](e2.sourceMapId, i3, n2);
- else if (this.parent.getWorkerSource) {
- const t3 = e2.type.split(".");
- this.parent.getWorkerSource(e2.sourceMapId, t3[0], i3.source)[t3[1]](i3, n2);
- } else
- n2(new Error(`Could not find function ${e2.type}`));
- }
- }
- remove() {
- this.scheduler.remove(), this.target.removeEventListener("message", this.receive, false);
- }
- }, 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 {
- isDataAvailableAtPoint(t2) {
- const e2 = this._source();
- if (!e2 || t2.y < 0 || t2.y > 1)
- return false;
- 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));
- return !(!o2 || !o2.dem);
- }
- getAtPointOrZero(t2, e2 = 0) {
- return this.getAtPoint(t2, e2) || 0;
- }
- getAtPoint(t2, e2, r2 = true) {
- null == e2 && (e2 = null);
- const n2 = this._source();
- if (!n2)
- return e2;
- if (t2.y < 0 || t2.y > 1)
- return e2;
- 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);
- if (!u2 || !u2.dem)
- return e2;
- 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);
- 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);
- }
- getAtTileOffset(t2, e2, r2) {
- const n2 = 1 << t2.canonical.z;
- return this.getAtPointOrZero(new lo(t2.wrap + (t2.canonical.x + e2 / Ya) / n2, (t2.canonical.y + r2 / Ya) / n2));
- }
- getAtTileOffsetFunc(t2, e2, r2, n2) {
- return (i3) => {
- const s2 = this.getAtTileOffset(t2, i3.x, i3.y), a2 = n2.upVector(t2.canonical, i3.x, i3.y);
- return nl(a2, a2, s2 * n2.upVectorScale(t2.canonical, e2, r2).metersToTile), a2;
- };
- }
- getForTilePoints(t2, e2, r2, n2) {
- const i3 = zf.create(this, t2, n2);
- return !!i3 && (e2.forEach((t3) => {
- t3[2] = this.exaggeration() * i3.getElevationAt(t3[0], t3[1], r2);
- }), true);
- }
- getMinMaxForTile(t2) {
- const e2 = this.findDEMTileFor(t2);
- if (!e2 || !e2.dem)
- return null;
- const r2 = e2.dem.tree, n2 = e2.tileID, i3 = 1 << t2.canonical.z - n2.canonical.z;
- let s2 = t2.canonical.x / i3 - n2.canonical.x, a2 = t2.canonical.y / i3 - n2.canonical.y, o2 = 0;
- for (let e3 = 0; e3 < t2.canonical.z - n2.canonical.z && !r2.leaves[o2]; e3++) {
- s2 *= 2, a2 *= 2;
- const t3 = 2 * Math.floor(a2) + Math.floor(s2);
- o2 = r2.childOffsets[o2] + t3, s2 %= 1, a2 %= 1;
- }
- return { min: this.exaggeration() * r2.minimums[o2], max: this.exaggeration() * r2.maximums[o2] };
- }
- getMinElevationBelowMSL() {
- throw new Error("Pure virtual method called.");
- }
- raycast(t2, e2, r2) {
- throw new Error("Pure virtual method called.");
- }
- pointCoordinate(t2) {
- throw new Error("Pure virtual method called.");
- }
- _source() {
- throw new Error("Pure virtual method called.");
- }
- exaggeration() {
- throw new Error("Pure virtual method called.");
- }
- findDEMTileFor(t2) {
- throw new Error("Pure virtual method called.");
- }
- get visibleDemTiles() {
- throw new Error("Getter must be implemented in subclass.");
- }
- }, 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 {
- constructor(t2) {
- this._createGrid(t2), this._createPoles(t2), this._createAtmosphere(t2);
- }
- destroy() {
- this._poleIndexBuffer.destroy(), this._gridBuffer.destroy(), this._gridIndexBuffer.destroy(), this._poleNorthVertexBuffer.destroy(), this._poleSouthVertexBuffer.destroy();
- for (const t2 of this._poleSegments)
- t2.destroy();
- this._gridSegments.destroy(), this.atmosphereVertexBuffer.destroy(), this.atmosphereIndexBuffer.destroy(), this.atmosphereSegments.destroy(), this._wireframeIndexBuffer && (this._wireframeIndexBuffer.destroy(), this._wireframeSegments.destroy());
- }
- _createGrid(t2) {
- const e2 = new Is(), r2 = new js(), n2 = 65;
- for (let t3 = 0; t3 < n2; t3++)
- for (let r3 = 0; r3 < n2; r3++)
- e2.emplaceBack(r3, t3);
- for (let t3 = 0; t3 < 64; t3++)
- for (let e3 = 0; e3 < 64; e3++) {
- const i3 = t3 * n2 + e3;
- r2.emplaceBack(i3 + 1, i3, i3 + n2), r2.emplaceBack(i3 + n2, i3 + n2 + 1, i3 + 1);
- }
- this._gridBuffer = t2.createVertexBuffer(e2, _p.members), this._gridIndexBuffer = t2.createIndexBuffer(r2, true), this._gridSegments = Ka.simpleSegment(0, 0, 4225, 8192);
- }
- _createPoles(t2) {
- const e2 = new js();
- for (let t3 = 0; t3 <= 64; t3++)
- e2.emplaceBack(0, t3 + 1, t3 + 2);
- this._poleIndexBuffer = t2.createIndexBuffer(e2, true);
- const r2 = new Gs(), n2 = new Gs();
- this._poleSegments = [];
- for (let t3 = 0, e3 = 0; t3 < 5; t3++) {
- const i3 = 1 << t3, s2 = 512 * i3 / Math.PI / 2, a2 = 360 / i3;
- r2.emplaceBack(0, -s2, 0, 0, 0, 0.5, 0), n2.emplaceBack(0, -s2, 0, 0, 0, 0.5, 1);
- for (let t4 = 0; t4 <= 64; t4++) {
- const e4 = t4 / 64, i4 = rr(0, a2, e4), [o2, l2, u2] = Ep(Up, $p, i4, s2);
- r2.emplaceBack(o2, l2, u2, 0, 0, e4, 0), n2.emplaceBack(o2, l2, u2, 0, 0, e4, 1);
- }
- this._poleSegments.push(Ka.simpleSegment(e3, 0, 66, 64)), e3 += 66;
- }
- this._poleNorthVertexBuffer = t2.createVertexBuffer(r2, vp, false), this._poleSouthVertexBuffer = t2.createVertexBuffer(n2, vp, false);
- }
- _createAtmosphere(t2) {
- const e2 = new Zs();
- 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);
- const r2 = new js();
- 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);
- }
- getGridBuffers() {
- return [this._gridBuffer, this._gridIndexBuffer, this._gridSegments];
- }
- getPoleBuffers(t2) {
- return [this._poleNorthVertexBuffer, this._poleSouthVertexBuffer, this._poleIndexBuffer, this._poleSegments[t2]];
- }
- getWirefameBuffers(t2) {
- if (!this._wireframeSegments) {
- const e2 = new Ks(), r2 = 64, n2 = r2 + 1;
- for (let t3 = 0; t3 < r2; t3++)
- for (let i3 = 0; i3 < r2; i3++) {
- const r3 = t3 * n2 + i3;
- e2.emplaceBack(r3, r3 + 1), e2.emplaceBack(r3, r3 + n2), e2.emplaceBack(r3, r3 + n2 + 1);
- }
- this._wireframeIndexBuffer = t2.createIndexBuffer(e2), this._wireframeSegments = Ka.simpleSegment(0, 0, r2 * r2, e2.length);
- }
- return [this._gridBuffer, this._wireframeIndexBuffer, this._wireframeSegments];
- }
- }, 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 {
- constructor(t2, e2) {
- this.pos = t2, this.dir = e2;
- }
- intersectsPlane(t2, e2, r2) {
- const n2 = al(e2, this.dir);
- if (Math.abs(n2) < 1e-6)
- return false;
- const i3 = ((t2[0] - this.pos[0]) * e2[0] + (t2[1] - this.pos[1]) * e2[1] + (t2[2] - this.pos[2]) * e2[2]) / n2;
- 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;
- }
- closestPointOnSphere(t2, e2, r2) {
- if (function(t3, e3) {
- var r3 = t3[0], n3 = t3[1], i4 = t3[2], s3 = e3[0], a3 = e3[1], o3 = e3[2];
- 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));
- }(this.pos, t2) || 0 === e2)
- return r2[0] = r2[1] = r2[2] = 0, false;
- 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);
- if (h2 < 0) {
- 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);
- return r2[0] = u3 * e2 / f2, r2[1] = h3 * e2 / f2, r2[2] = p2 * e2 / f2, false;
- }
- {
- const t3 = (-c2 - Math.sqrt(h2)) / (2 * u2);
- if (t3 < 0) {
- const t4 = Math.hypot(a2, o2, l2);
- return r2[0] = a2 * e2 / t4, r2[1] = o2 * e2 / t4, r2[2] = l2 * e2 / t4, false;
- }
- return r2[0] = a2 + n2 * t3, r2[1] = o2 + i3 * t3, r2[2] = l2 + s2 * t3, true;
- }
- }
- }, t.RequestManager = class {
- constructor(t2, e2, r2) {
- this._transformRequestFn = t2, this._customAccessToken = e2, this._silenceAuthErrors = !!r2, this._createSkuToken();
- }
- _createSkuToken() {
- const t2 = function() {
- let t3 = "";
- for (let e2 = 0; e2 < 10; e2++)
- t3 += "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62 * Math.random())];
- return { token: ["1", Q, t3].join(""), tokenExpiresAt: Date.now() + 432e5 };
- }();
- this._skuToken = t2.token, this._skuTokenExpiresAt = t2.tokenExpiresAt;
- }
- _isSkuTokenExpired() {
- return Date.now() > this._skuTokenExpiresAt;
- }
- transformRequest(t2, e2) {
- return this._transformRequestFn && this._transformRequestFn(t2, e2) || { url: t2 };
- }
- normalizeStyleURL(t2, e2) {
- if (!et(t2))
- return t2;
- const r2 = it(t2);
- return r2.path = `/styles/v1${r2.path}`, this._makeAPIURL(r2, this._customAccessToken || e2);
- }
- normalizeGlyphsURL(t2, e2) {
- if (!et(t2))
- return t2;
- const r2 = it(t2);
- return r2.path = `/fonts/v1${r2.path}`, this._makeAPIURL(r2, this._customAccessToken || e2);
- }
- normalizeSourceURL(t2, e2) {
- if (!et(t2))
- return t2;
- const r2 = it(t2);
- return r2.path = `/v4/${r2.authority}.json`, r2.params.push("secure"), this._makeAPIURL(r2, this._customAccessToken || e2);
- }
- normalizeSpriteURL(t2, e2, r2, n2) {
- const i3 = it(t2);
- return et(t2) ? (i3.path = `/styles/v1${i3.path}/sprite${e2}${r2}`, this._makeAPIURL(i3, this._customAccessToken || n2)) : (i3.path += `${e2}${r2}`, st(i3));
- }
- normalizeTileURL(t2, e2, r2) {
- if (this._isSkuTokenExpired() && this._createSkuToken(), t2 && !et(t2))
- return t2;
- const n2 = it(t2);
- 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}`);
- const i3 = this._customAccessToken || function(t3) {
- for (const e3 of t3) {
- const t4 = e3.match(/^access_token=(.*)$/);
- if (t4)
- return t4[1];
- }
- return null;
- }(n2.params) || Z.ACCESS_TOKEN;
- return Z.REQUIRE_ACCESS_TOKEN && i3 && this._skuToken && n2.params.push(`sku=${this._skuToken}`), this._makeAPIURL(n2, i3);
- }
- canonicalizeTileURL(t2, e2) {
- const r2 = it(t2);
- if (!r2.path.match(/^(\/v4\/|\/raster\/v1\/)/) || !r2.path.match(/\.[\w]+$/))
- return t2;
- let n2 = "mapbox://";
- r2.path.match(/^\/raster\/v1\//) ? n2 += `raster/${r2.path.replace(`/${Z.RASTER_URL_PREFIX}/`, "")}` : n2 += `tiles/${r2.path.replace(`/${Z.TILE_URL_VERSION}/`, "")}`;
- let i3 = r2.params;
- return e2 && (i3 = i3.filter((t3) => !t3.match(/^access_token=/))), i3.length && (n2 += `?${i3.join("&")}`), n2;
- }
- canonicalizeTileset(t2, e2) {
- const r2 = !!e2 && et(e2), n2 = [];
- for (const e3 of t2.tiles || [])
- rt(e3) ? n2.push(this.canonicalizeTileURL(e3, r2)) : n2.push(e3);
- return n2;
- }
- _makeAPIURL(t2, e2) {
- const r2 = "See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes", n2 = it(Z.API_URL);
- if (t2.protocol = n2.protocol, t2.authority = n2.authority, "http" === t2.protocol) {
- const e3 = t2.params.indexOf("secure");
- e3 >= 0 && t2.params.splice(e3, 1);
- }
- if ("/" !== n2.path && (t2.path = `${n2.path}${t2.path}`), !Z.REQUIRE_ACCESS_TOKEN)
- return st(t2);
- if (e2 = e2 || Z.ACCESS_TOKEN, !this._silenceAuthErrors) {
- if (!e2)
- throw new Error(`An API access token is required to use Mapbox GL. ${r2}`);
- if ("s" === e2[0])
- throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${r2}`);
- }
- return t2.params = t2.params.filter((t3) => -1 === t3.indexOf("access_token")), t2.params.push(`access_token=${e2 || ""}`), st(t2);
- }
- }, 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 {
- constructor(t2, e2) {
- super(t2, e2), this.current = 0;
- }
- set(t2) {
- this.current !== t2 && (this.current = t2, this.gl.uniform1i(this.location, t2));
- }
- }, t.Uniform2f = class extends ka {
- constructor(t2, e2) {
- super(t2, e2), this.current = [0, 0];
- }
- set(t2) {
- t2[0] === this.current[0] && t2[1] === this.current[1] || (this.current = t2, this.gl.uniform2f(this.location, t2[0], t2[1]));
- }
- }, t.Uniform3f = class extends ka {
- constructor(t2, e2) {
- super(t2, e2), this.current = [0, 0, 0];
- }
- set(t2) {
- 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]));
- }
- }, t.Uniform4f = Ia, t.UniformColor = Ma, t.UniformMatrix2f = class extends ka {
- constructor(t2, e2) {
- super(t2, e2), this.current = Ba;
- }
- set(t2) {
- for (let e2 = 0; e2 < 4; e2++)
- if (t2[e2] !== this.current[e2]) {
- this.current = t2, this.gl.uniformMatrix2fv(this.location, false, t2);
- break;
- }
- }
- }, t.UniformMatrix3f = class extends ka {
- constructor(t2, e2) {
- super(t2, e2), this.current = za;
- }
- set(t2) {
- for (let e2 = 0; e2 < 9; e2++)
- if (t2[e2] !== this.current[e2]) {
- this.current = t2, this.gl.uniformMatrix3fv(this.location, false, t2);
- break;
- }
- }
- }, t.UniformMatrix4f = class extends ka {
- constructor(t2, e2) {
- super(t2, e2), this.current = Ta;
- }
- set(t2) {
- if (t2[12] !== this.current[12] || t2[0] !== this.current[0])
- return this.current = t2, void this.gl.uniformMatrix4fv(this.location, false, t2);
- for (let e2 = 1; e2 < 16; e2++)
- if (t2[e2] !== this.current[e2]) {
- this.current = t2, this.gl.uniformMatrix4fv(this.location, false, t2);
- break;
- }
- }
- }, t.UnwrappedTileID = qp, t.ValidationError = mn, t.VectorTileWorkerSource = class extends Ut {
- constructor(t2, e2, r2, n2, i3) {
- 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;
- }
- loadTile(t2, e2) {
- const r2 = t2.uid, n2 = t2 && t2.request, i3 = n2 && n2.collectResourceTiming, s2 = this.loading[r2] = new Pf(t2);
- s2.abort = this.loadVectorData(t2, (a2, o2) => {
- const l2 = !this.loading[r2];
- if (delete this.loading[r2], l2 || a2 || !o2)
- return s2.status = "done", l2 || (this.loaded[r2] = s2), e2(a2);
- const u2 = o2.rawData, c2 = {};
- o2.expires && (c2.expires = o2.expires), o2.cacheControl && (c2.cacheControl = o2.cacheControl), s2.vectorTile = o2.vectorTile || new Du.VectorTile(new wc(u2));
- const h2 = () => {
- s2.parse(s2.vectorTile, this.layerIndex, this.availableImages, this.actor, (t3, r3) => {
- if (t3 || !r3)
- return e2(t3);
- const s3 = {};
- if (i3) {
- const t4 = yp(n2);
- t4.length > 0 && (s3.resourceTiming = JSON.parse(JSON.stringify(t4)));
- }
- e2(null, b({ rawTileData: u2.slice(0) }, r3, c2, s3));
- });
- };
- this.isSpriteLoaded ? h2() : this.once("isSpriteLoaded", () => {
- this.scheduler ? this.scheduler.add(h2, { type: "parseTile", isSymbolTile: t2.isSymbolTile, zoom: t2.tileZoom }) : h2();
- }), this.loaded = this.loaded || {}, this.loaded[r2] = s2;
- });
- }
- reloadTile(t2, e2) {
- const r2 = this.loaded, n2 = t2.uid, i3 = this;
- if (r2 && r2[n2]) {
- const s2 = r2[n2];
- s2.showCollisionBoxes = t2.showCollisionBoxes, s2.enableTerrain = !!t2.enableTerrain, s2.projection = t2.projection, s2.tileTransform = Zp(t2.tileID.canonical, t2.projection);
- const a2 = (t3, r3) => {
- const n3 = s2.reloadCallback;
- n3 && (delete s2.reloadCallback, s2.parse(s2.vectorTile, i3.layerIndex, this.availableImages, i3.actor, n3)), e2(t3, r3);
- };
- "parsing" === s2.status ? s2.reloadCallback = a2 : "done" === s2.status && (s2.vectorTile ? s2.parse(s2.vectorTile, this.layerIndex, this.availableImages, this.actor, a2) : a2());
- }
- }
- abortTile(t2, e2) {
- const r2 = t2.uid, n2 = this.loading[r2];
- n2 && (n2.abort && n2.abort(), delete this.loading[r2]), e2();
- }
- removeTile(t2, e2) {
- const r2 = this.loaded, n2 = t2.uid;
- r2 && r2[n2] && delete r2[n2], e2();
- }
- }, t.WritingMode = Kc, t.ZoomHistory = hi, t.add = Jo, t.addDynamicAttributes = Hh, t.adjoint = function(t2, e2) {
- 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];
- 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;
- }, t.asyncAll = x, t.bezier = f, t.bindAll = I, t.boundsAttributes = nf, t.bufferConvexPolygon = function(t2, e2) {
- const r2 = [];
- for (let n2 = 0; n2 < t2.length; n2++) {
- 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));
- r2.push(a2.add(h2));
- }
- return r2;
- }, t.cacheEntryPossiblyAdded = function(t2) {
- wt++, wt > vt && (t2.getActor().send("enforceCacheSizeLimit", xt), wt = 0);
- }, t.calculateGlobeLabelMatrix = function(t2, e2) {
- const { lng: r2, lat: n2 } = t2._center, i3 = Fp(0, 0, t2.worldSize / t2._projectionScaler, r2, n2);
- return Oo(i3, i3, function(t3) {
- const e3 = jo(new Float64Array(16)), r3 = 1 / Pp(t3);
- return qo(e3, e3, t3.min), No(e3, e3, [r3, r3, r3]), e3;
- }(Tp(e2)));
- }, t.calculateGlobeMatrix = Lp, t.calculateGlobeMercatorMatrix = function(t2) {
- 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));
- return qo(a2, a2, [r2.x, r2.y, 0]), No(a2, a2, [s2, s2, i3]), Float32Array.from(a2);
- }, t.circumferenceAtLatitude = to, t.clamp = y, t.clearTileCache = function(t2) {
- const e2 = a.caches.delete(yt);
- t2 && e2.catch(t2).then(() => t2());
- }, t.clipLine = xh, t.clone = function(t2) {
- var e2 = new Uo(16);
- 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;
- }, t.clone$1 = B, t.collisionCircleLayout = uc, t.config = Z, t.conjugate = function(t2, e2) {
- return t2[0] = -e2[0], t2[1] = -e2[1], t2[2] = -e2[2], t2[3] = e2[3], t2;
- }, t.create = function() {
- var t2 = new Uo(16);
- 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;
- }, t.create$1 = $o, t.createExpression = cn, t.createLayout = ks, t.createStyleLayer = function(t2) {
- return "custom" === t2.type ? new op(t2) : new cp[t2.type](t2);
- }, t.cross = ol, t.degToRad = u, t.div = function(t2, e2, r2) {
- return t2[0] = e2[0] / r2[0], t2[1] = e2[1] / r2[1], t2[2] = e2[2] / r2[2], t2;
- }, t.dot = al, t.earthRadius = Wa, t.ease = d, t.easeCubicInOut = p, t.emitValidationErrors = ri, t.endsWith = M, t.enforceCacheSizeLimit = function(t2) {
- bt(), mt && mt.then((e2) => {
- e2.keys().then((r2) => {
- for (let n2 = 0; n2 < r2.length - t2; n2++)
- e2.delete(r2[n2]);
- });
- });
- }, t.evaluateSizeForFeature = fc, t.evaluateSizeForZoom = dc, t.evaluateVariableOffset = Lh, t.evented = es, t.exactEquals = function(t2, e2) {
- return t2[0] === e2[0] && t2[1] === e2[1] && t2[2] === e2[2] && t2[3] === e2[3];
- }, t.exactEquals$1 = function(t2, e2) {
- return t2[0] === e2[0] && t2[1] === e2[1] && t2[2] === e2[2];
- }, t.exported = N, t.exported$1 = X, t.extend = b, t.extend$1 = jt, t.filterObject = z, t.fromMat4 = function(t2, e2) {
- 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;
- }, t.fromQuat = function(t2, e2) {
- 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;
- 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;
- }, t.fromRotation = function(t2, e2) {
- var r2 = Math.sin(e2), n2 = Math.cos(e2);
- 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;
- }, t.fromScaling = function(t2, e2) {
- 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;
- }, t.furthestTileCorner = function(t2) {
- const e2 = Math.round((t2 + 45 + 360) % 360 / 90) % 4;
- return h[e2];
- }, t.getAABBPointSquareDist = function(t2, e2, r2) {
- let n2 = 0;
- for (let i3 = 0; i3 < 2; ++i3) {
- const s2 = r2 ? r2[i3] : 0;
- t2[i3] > s2 && (n2 += (t2[i3] - s2) * (t2[i3] - s2)), e2[i3] < s2 && (n2 += (s2 - e2[i3]) * (s2 - e2[i3]));
- }
- return n2;
- }, t.getAnchorAlignment = ah, t.getAnchorJustification = Uh, t.getBounds = function(t2) {
- let e2 = 1 / 0, r2 = 1 / 0, n2 = -1 / 0, s2 = -1 / 0;
- for (const i3 of t2)
- e2 = Math.min(e2, i3.x), r2 = Math.min(r2, i3.y), n2 = Math.max(n2, i3.x), s2 = Math.max(s2, i3.y);
- return { min: new i2(e2, r2), max: new i2(n2, s2) };
- }, t.getColumn = function(t2, e2) {
- return [t2[4 * e2], t2[4 * e2 + 1], t2[4 * e2 + 2], t2[4 * e2 + 3]];
- }, t.getGridMatrix = function(t2, e2) {
- const [r2, n2] = e2, i3 = 0.015625;
- return [0, (n2[1] - r2[1]) * i3, 1 << t2.z, (n2[0] - r2[0]) * i3, 0, t2.y, r2[0], r2[1], i3];
- }, t.getImage = Pt, t.getJSON = function(t2, e2) {
- return It(b(t2, { type: "json" }), e2);
- }, t.getMapSessionAPI = ft, t.getPerformanceMeasurement = yp, t.getProjection = function(t2) {
- const e2 = t2.parallels, r2 = !!e2 && Math.abs(e2[0] + e2[1]) < 0.01;
- switch (t2.name) {
- case "mercator":
- return new $f(t2);
- case "equirectangular":
- return new Kf(t2);
- case "naturalEarth":
- return new Qf(t2);
- case "equalEarth":
- return new Xf(t2);
- case "winkelTripel":
- return new ed(t2);
- case "albers":
- return r2 ? new rd(t2) : new jf(t2);
- case "lambertConformalConic":
- return r2 ? new rd(t2) : new Wf(t2);
- }
- throw new Error(`Invalid projection name: ${t2.name}`);
- }, t.getRTLTextPluginStatus = rs, t.getReferrer = St, t.getTilePoint = function(t2, { x: e2, y: r2 }, n2 = 0) {
- return new i2(((e2 - n2) * t2.scale - t2.x) * Ya, (r2 * t2.scale - t2.y) * Ya);
- }, t.getTileVec3 = function(t2, e2, r2 = 0) {
- return Wo(((e2.x - r2) * t2.scale - t2.x) * Ya, (e2.y * t2.scale - t2.y) * Ya, ao(e2.z, e2.y));
- }, t.getVideo = function(t2, e2) {
- const r2 = a.document.createElement("video");
- r2.muted = true, r2.onloadstart = function() {
- e2(null, r2);
- };
- for (let e3 = 0; e3 < t2.length; e3++) {
- const n2 = a.document.createElement("source");
- Bt(t2[e3]) || (r2.crossOrigin = "Anonymous"), n2.src = t2[e3], r2.appendChild(n2);
- }
- return { cancel: () => {
- } };
- }, t.globeECEFOrigin = function(t2, e2) {
- const r2 = [0, 0, 0];
- return ll(r2, r2, Vp(Tp(e2.canonical))), ll(r2, r2, t2), r2;
- }, t.globePixelsToTileUnits = function(t2, e2) {
- return Ya / (512 * Math.pow(2, t2)) * Pp(Tp(e2));
- }, t.globePoleMatrixForTile = function(t2, e2, r2) {
- const n2 = jo(new Float64Array(16)), i3 = 1 << t2, s2 = 360 * (e2 / i3 - 0.5), a2 = r2.point, o2 = r2.worldSize / (r2.tileSize * i3);
- 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);
- }, t.globeTileLatLngCorners = Bp, t.globeToMercatorTransition = function(t2) {
- return m(5, 6, t2);
- }, t.identity = jo, t.identity$1 = ml, t.invert = function(t2, e2) {
- 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;
- 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;
- }, t.isMapAuthenticated = function(t2) {
- return dt.has(t2);
- }, t.isMapboxURL = et, t.isSafariWithAntialiasingBug = function(t2) {
- const e2 = t2.navigator ? t2.navigator.userAgent : null;
- 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/));
- }, t.latFromMercatorY = so, t.len = fl, t.length = Ho, t.length$1 = function(t2) {
- return Math.hypot(t2[0], t2[1], t2[2], t2[3]);
- }, 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) {
- 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];
- 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;
- }, t.multiply$1 = Oo, t.multiply$2 = tl, t.nextPowerOfTwo = k, t.normalize = sl, t.normalize$1 = function(t2, e2) {
- var r2 = e2[0], n2 = e2[1], i3 = e2[2], s2 = e2[3], a2 = r2 * r2 + n2 * n2 + i3 * i3 + s2 * s2;
- 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;
- }, t.number = rr, t.ortho = function(t2, e2, r2, n2, i3, s2, a2) {
- var o2 = 1 / (e2 - r2), l2 = 1 / (n2 - i3), u2 = 1 / (s2 - a2);
- 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;
- }, t.pbf = wc, t.perspective = function(t2, e2, r2, n2, i3) {
- var s2, a2 = 1 / Math.tan(e2 / 2);
- 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;
- }, t.pick = function(t2, e2) {
- const r2 = {};
- for (let n2 = 0; n2 < e2.length; n2++) {
- const i3 = e2[n2];
- i3 in t2 && (r2[i3] = t2[i3]);
- }
- return r2;
- }, t.plugin = is, t.pointGeometry = i2, t.polygonIntersectsBox = Bo, t.polygonIntersectsPolygon = bo, t.polygonizeBounds = function(t2, e2, r2 = 0, n2 = true) {
- 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)];
- return n2 && l2.push(a2), l2;
- }, t.posAttributes = _p, t.postMapLoadEvent = ht, t.postTurnstileEvent = ut, t.potpack = Gc, t.prevPowerOfTwo = function(t2) {
- return t2 <= 1 ? 1 : Math.pow(2, Math.floor(Math.log(t2) / Math.LN2));
- }, t.radToDeg = c, t.refProperties = ["type", "source", "source-layer", "minzoom", "maxzoom", "filter", "layout"], t.registerForPluginStateChange = function(t2) {
- return t2({ pluginStatus: Wi, pluginURL: Ji }), es.on("pluginStateChange", t2), t2;
- }, t.removeAuthState = function(t2) {
- dt.delete(t2);
- }, t.renderColorRamp = Cl, t.rotateX = Go, t.rotateX$1 = gl, t.rotateY = Zo, t.rotateZ = function(t2, e2, r2) {
- 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];
- 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;
- }, t.rotateZ$1 = function(t2, e2, r2) {
- r2 *= 0.5;
- var n2 = e2[0], i3 = e2[1], s2 = e2[2], a2 = e2[3], o2 = Math.sin(r2), l2 = Math.cos(r2);
- 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;
- }, t.scale = No, t.scale$1 = function(t2, e2, r2) {
- return t2[0] = e2[0] * r2, t2[1] = e2[1] * r2, t2[2] = e2[2] * r2, t2[3] = e2[3] * r2, t2;
- }, t.scale$2 = nl, t.scaleAndAdd = il, t.setCacheLimits = function(t2, e2) {
- xt = t2, vt = e2;
- }, t.setColumn = function(t2, e2, r2) {
- t2[4 * e2 + 0] = r2[0], t2[4 * e2 + 1] = r2[1], t2[4 * e2 + 2] = r2[2], t2[4 * e2 + 3] = r2[3];
- }, t.setRTLTextPlugin = function(t2, e2, r2 = false) {
- if (Wi === Xi || Wi === Ki || Wi === Yi)
- throw new Error("setRTLTextPlugin cannot be called multiple times.");
- Ji = N.resolveURL(t2), Wi = Xi, Hi = e2, ts(), r2 || ns();
- }, t.smoothstep = m, t.spec = $t, t.storeAuthState = function(t2, e2) {
- e2 ? dt.add(t2) : dt.delete(t2);
- }, t.sub = hl, t.subtract = Qo, t.symbolSize = yc, t.tileAABB = function(t2, e2, r2, n2, i3, s2, a2, o2, l2) {
- if ("globe" === l2.name)
- return zp(t2, e2, new Op(r2, n2, i3));
- const u2 = Zp({ z: r2, x: n2, y: i3 }, l2);
- 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]);
- }, t.tileTransform = Zp, t.transformMat3 = function(t2, e2, r2) {
- var n2 = e2[0], i3 = e2[1], s2 = e2[2];
- 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;
- }, t.transformMat4 = ll, t.transformMat4$1 = dl, t.transformQuat = ul, t.translate = qo, t.transpose = function(t2, e2) {
- if (t2 === e2) {
- var r2 = e2[1], n2 = e2[2], i3 = e2[5];
- t2[1] = e2[3], t2[2] = e2[6], t2[3] = r2, t2[5] = e2[7], t2[6] = n2, t2[7] = i3;
- } else
- 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];
- return t2;
- }, t.triggerPluginCompletionEvent = Qi, t.uniqueId = w, t.validateCustomStyleLayer = function(t2) {
- const e2 = [], r2 = t2.id;
- 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;
- }, 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;
- });
- define(["./shared"], function(e) {
- function t(e2) {
- if ("number" == typeof e2 || "boolean" == typeof e2 || "string" == typeof e2 || null == e2)
- return JSON.stringify(e2);
- if (Array.isArray(e2)) {
- let r3 = "[";
- for (const o2 of e2)
- r3 += `${t(o2)},`;
- return `${r3}]`;
- }
- let r2 = "{";
- for (const o2 of Object.keys(e2).sort())
- r2 += `${o2}:${t(e2[o2])},`;
- return `${r2}}`;
- }
- function r(r2) {
- let o2 = "";
- for (const n2 of e.refProperties)
- o2 += `/${t(r2[n2])}`;
- return o2;
- }
- class o {
- constructor(e2) {
- this.keyCache = {}, e2 && this.replace(e2);
- }
- replace(e2) {
- this._layerConfigs = {}, this._layers = {}, this.update(e2, []);
- }
- update(t2, o2) {
- for (const r2 of t2)
- this._layerConfigs[r2.id] = r2, (this._layers[r2.id] = e.createStyleLayer(r2)).compileFilter(), this.keyCache[r2.id] && delete this.keyCache[r2.id];
- for (const e2 of o2)
- delete this.keyCache[e2], delete this._layerConfigs[e2], delete this._layers[e2];
- this.familiesBySource = {};
- const n2 = function(e2, t3) {
- const o3 = {};
- for (let n4 = 0; n4 < e2.length; n4++) {
- const i3 = t3 && t3[e2[n4].id] || r(e2[n4]);
- t3 && (t3[e2[n4].id] = i3);
- let s2 = o3[i3];
- s2 || (s2 = o3[i3] = []), s2.push(e2[n4]);
- }
- const n3 = [];
- for (const e3 in o3)
- n3.push(o3[e3]);
- return n3;
- }(e.values(this._layerConfigs), this.keyCache);
- for (const e2 of n2) {
- const t3 = e2.map((e3) => this._layers[e3.id]), r2 = t3[0];
- if ("none" === r2.visibility)
- continue;
- const o3 = r2.source || "";
- let n3 = this.familiesBySource[o3];
- n3 || (n3 = this.familiesBySource[o3] = {});
- const i3 = r2.sourceLayer || "_geojsonTileLayer";
- let s2 = n3[i3];
- s2 || (s2 = n3[i3] = []), s2.push(t3);
- }
- }
- }
- class n {
- loadTile(t2, r2) {
- 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;
- r2(null, new e.DEMData(o2, l2, n2, s2 < 1, a2));
- }
- getImageData(e2, t2) {
- 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);
- const r2 = this.offscreenCanvasContext.getImageData(-t2, -t2, e2.width + 2 * t2, e2.height + 2 * t2);
- return this.offscreenCanvasContext.clearRect(0, 0, this.offscreenCanvas.width, this.offscreenCanvas.height), r2;
- }
- }
- var i2 = function e2(t2, r2) {
- var o2, n2 = t2 && t2.type;
- if ("FeatureCollection" === n2)
- for (o2 = 0; o2 < t2.features.length; o2++)
- e2(t2.features[o2], r2);
- else if ("GeometryCollection" === n2)
- for (o2 = 0; o2 < t2.geometries.length; o2++)
- e2(t2.geometries[o2], r2);
- else if ("Feature" === n2)
- e2(t2.geometry, r2);
- else if ("Polygon" === n2)
- s(t2.coordinates, r2);
- else if ("MultiPolygon" === n2)
- for (o2 = 0; o2 < t2.coordinates.length; o2++)
- s(t2.coordinates[o2], r2);
- return t2;
- };
- function s(e2, t2) {
- if (0 !== e2.length) {
- a(e2[0], t2);
- for (var r2 = 1; r2 < e2.length; r2++)
- a(e2[r2], !t2);
- }
- }
- function a(e2, t2) {
- for (var r2 = 0, o2 = 0, n2 = 0, i3 = e2.length, s2 = i3 - 1; n2 < i3; s2 = n2++) {
- var a2 = (e2[n2][0] - e2[s2][0]) * (e2[s2][1] + e2[n2][1]), l2 = r2 + a2;
- o2 += Math.abs(r2) >= Math.abs(a2) ? r2 - l2 + a2 : a2 - l2 + r2, r2 = l2;
- }
- r2 + o2 >= 0 != !!t2 && e2.reverse();
- }
- const l = e.vectorTile.VectorTileFeature.prototype.toGeoJSON;
- class u {
- constructor(t2) {
- 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));
- }
- loadGeometry() {
- if (1 === this._feature.type) {
- const t2 = [];
- for (const r2 of this._feature.geometry)
- t2.push([new e.pointGeometry(r2[0], r2[1])]);
- return t2;
- }
- {
- const t2 = [];
- for (const r2 of this._feature.geometry) {
- const o2 = [];
- for (const t3 of r2)
- o2.push(new e.pointGeometry(t3[0], t3[1]));
- t2.push(o2);
- }
- return t2;
- }
- }
- toGeoJSON(e2, t2, r2) {
- return l.call(this, e2, t2, r2);
- }
- }
- class h {
- constructor(t2) {
- this.layers = { _geojsonTileLayer: this }, this.name = "_geojsonTileLayer", this.extent = e.EXTENT, this.length = t2.length, this._features = t2;
- }
- feature(e2) {
- return new u(this._features[e2]);
- }
- }
- var c = e.vectorTile.VectorTileFeature, f = p;
- function p(e2, t2) {
- this.options = t2 || {}, this.features = e2, this.length = e2.length;
- }
- function g(e2, t2) {
- 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;
- }
- p.prototype.feature = function(e2) {
- return new g(this.features[e2], this.options.extent);
- }, g.prototype.loadGeometry = function() {
- var t2 = this.rawGeometry;
- this.geometry = [];
- for (var r2 = 0; r2 < t2.length; r2++) {
- for (var o2 = t2[r2], n2 = [], i3 = 0; i3 < o2.length; i3++)
- n2.push(new e.pointGeometry(o2[i3][0], o2[i3][1]));
- this.geometry.push(n2);
- }
- return this.geometry;
- }, g.prototype.bbox = function() {
- this.geometry || this.loadGeometry();
- for (var e2 = this.geometry, t2 = 1 / 0, r2 = -1 / 0, o2 = 1 / 0, n2 = -1 / 0, i3 = 0; i3 < e2.length; i3++)
- for (var s2 = e2[i3], a2 = 0; a2 < s2.length; a2++) {
- var l2 = s2[a2];
- t2 = Math.min(t2, l2.x), r2 = Math.max(r2, l2.x), o2 = Math.min(o2, l2.y), n2 = Math.max(n2, l2.y);
- }
- return [t2, o2, r2, n2];
- }, g.prototype.toGeoJSON = c.prototype.toGeoJSON;
- var d = y, m = f;
- function y(t2) {
- var r2 = new e.pbf();
- return function(e2, t3) {
- for (var r3 in e2.layers)
- t3.writeMessage(3, v, e2.layers[r3]);
- }(t2, r2), r2.finish();
- }
- function v(e2, t2) {
- var r2;
- t2.writeVarintField(15, e2.version || 1), t2.writeStringField(1, e2.name || ""), t2.writeVarintField(5, e2.extent || 4096);
- var o2 = { keys: [], values: [], keycache: {}, valuecache: {} };
- for (r2 = 0; r2 < e2.length; r2++)
- o2.feature = e2.feature(r2), t2.writeMessage(2, x, o2);
- var n2 = o2.keys;
- for (r2 = 0; r2 < n2.length; r2++)
- t2.writeStringField(3, n2[r2]);
- var i3 = o2.values;
- for (r2 = 0; r2 < i3.length; r2++)
- t2.writeMessage(4, b, i3[r2]);
- }
- function x(e2, t2) {
- var r2 = e2.feature;
- void 0 !== r2.id && t2.writeVarintField(1, r2.id), t2.writeMessage(2, w, e2), t2.writeVarintField(3, r2.type), t2.writeMessage(4, P, r2);
- }
- function w(e2, t2) {
- var r2 = e2.feature, o2 = e2.keys, n2 = e2.values, i3 = e2.keycache, s2 = e2.valuecache;
- for (var a2 in r2.properties) {
- var l2 = r2.properties[a2], u2 = i3[a2];
- if (null !== l2) {
- void 0 === u2 && (o2.push(a2), i3[a2] = u2 = o2.length - 1), t2.writeVarint(u2);
- var h2 = typeof l2;
- "string" !== h2 && "boolean" !== h2 && "number" !== h2 && (l2 = JSON.stringify(l2));
- var c2 = h2 + ":" + l2, f2 = s2[c2];
- void 0 === f2 && (n2.push(l2), s2[c2] = f2 = n2.length - 1), t2.writeVarint(f2);
- }
- }
- }
- function S(e2, t2) {
- return (t2 << 3) + (7 & e2);
- }
- function M(e2) {
- return e2 << 1 ^ e2 >> 31;
- }
- function P(e2, t2) {
- for (var r2 = e2.loadGeometry(), o2 = e2.type, n2 = 0, i3 = 0, s2 = r2.length, a2 = 0; a2 < s2; a2++) {
- var l2 = r2[a2], u2 = 1;
- 1 === o2 && (u2 = l2.length), t2.writeVarint(S(1, u2));
- for (var h2 = 3 === o2 ? l2.length - 1 : l2.length, c2 = 0; c2 < h2; c2++) {
- 1 === c2 && 1 !== o2 && t2.writeVarint(S(2, h2 - 1));
- var f2 = l2[c2].x - n2, p2 = l2[c2].y - i3;
- t2.writeVarint(M(f2)), t2.writeVarint(M(p2)), n2 += f2, i3 += p2;
- }
- 3 === o2 && t2.writeVarint(S(7, 1));
- }
- }
- function b(e2, t2) {
- var r2 = typeof e2;
- "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));
- }
- function T(e2, t2, r2, o2, n2, i3) {
- if (n2 - o2 <= r2)
- return;
- const s2 = o2 + n2 >> 1;
- 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);
- }
- function k(e2, t2, r2, o2, n2, i3) {
- for (; n2 > o2; ) {
- if (n2 - o2 > 600) {
- 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);
- 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);
- }
- const s2 = t2[2 * r2 + i3];
- let a2 = o2, l2 = n2;
- for (I(e2, t2, o2, r2), t2[2 * n2 + i3] > s2 && I(e2, t2, o2, n2); a2 < l2; ) {
- for (I(e2, t2, a2, l2), a2++, l2--; t2[2 * a2 + i3] < s2; )
- a2++;
- for (; t2[2 * l2 + i3] > s2; )
- l2--;
- }
- 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);
- }
- }
- function I(e2, t2, r2, o2) {
- _(e2, r2, o2), _(t2, 2 * r2, 2 * o2), _(t2, 2 * r2 + 1, 2 * o2 + 1);
- }
- function _(e2, t2, r2) {
- const o2 = e2[t2];
- e2[t2] = e2[r2], e2[r2] = o2;
- }
- function L(e2, t2, r2, o2) {
- const n2 = e2 - r2, i3 = t2 - o2;
- return n2 * n2 + i3 * i3;
- }
- d.fromVectorTileJs = y, d.fromGeojsonVt = function(e2, t2) {
- t2 = t2 || {};
- var r2 = {};
- for (var o2 in e2)
- r2[o2] = new f(e2[o2].features, t2), r2[o2].name = o2, r2[o2].version = t2.version, r2[o2].extent = t2.extent;
- return y({ layers: r2 });
- }, d.GeoJSONWrapper = m;
- const C = (e2) => e2[0], O = (e2) => e2[1];
- class z {
- constructor(e2, t2 = C, r2 = O, o2 = 64, n2 = Float64Array) {
- this.nodeSize = o2, this.points = e2;
- const i3 = e2.length < 65536 ? Uint16Array : Uint32Array, s2 = this.ids = new i3(e2.length), a2 = this.coords = new n2(2 * e2.length);
- for (let o3 = 0; o3 < e2.length; o3++)
- s2[o3] = o3, a2[2 * o3] = t2(e2[o3]), a2[2 * o3 + 1] = r2(e2[o3]);
- T(s2, a2, o2, 0, s2.length - 1, 0);
- }
- range(e2, t2, r2, o2) {
- return function(e3, t3, r3, o3, n2, i3, s2) {
- const a2 = [0, e3.length - 1, 0], l2 = [];
- let u2, h2;
- for (; a2.length; ) {
- const c2 = a2.pop(), f2 = a2.pop(), p2 = a2.pop();
- if (f2 - p2 <= s2) {
- for (let s3 = p2; s3 <= f2; s3++)
- u2 = t3[2 * s3], h2 = t3[2 * s3 + 1], u2 >= r3 && u2 <= n2 && h2 >= o3 && h2 <= i3 && l2.push(e3[s3]);
- continue;
- }
- const g2 = Math.floor((p2 + f2) / 2);
- u2 = t3[2 * g2], h2 = t3[2 * g2 + 1], u2 >= r3 && u2 <= n2 && h2 >= o3 && h2 <= i3 && l2.push(e3[g2]);
- const d2 = (c2 + 1) % 2;
- (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));
- }
- return l2;
- }(this.ids, this.coords, e2, t2, r2, o2, this.nodeSize);
- }
- within(e2, t2, r2) {
- return function(e3, t3, r3, o2, n2, i3) {
- const s2 = [0, e3.length - 1, 0], a2 = [], l2 = n2 * n2;
- for (; s2.length; ) {
- const u2 = s2.pop(), h2 = s2.pop(), c2 = s2.pop();
- if (h2 - c2 <= i3) {
- for (let n3 = c2; n3 <= h2; n3++)
- L(t3[2 * n3], t3[2 * n3 + 1], r3, o2) <= l2 && a2.push(e3[n3]);
- continue;
- }
- const f2 = Math.floor((c2 + h2) / 2), p2 = t3[2 * f2], g2 = t3[2 * f2 + 1];
- L(p2, g2, r3, o2) <= l2 && a2.push(e3[f2]);
- const d2 = (u2 + 1) % 2;
- (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));
- }
- return a2;
- }(this.ids, this.coords, e2, t2, r2, this.nodeSize);
- }
- }
- 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]));
- var N;
- class j {
- constructor(e2) {
- this.options = A(Object.create(E), e2), this.trees = new Array(this.options.maxZoom + 1);
- }
- load(e2) {
- const { log: t2, minZoom: r2, maxZoom: o2, nodeSize: n2 } = this.options;
- t2 && console.time("total time");
- const i3 = `prepare ${e2.length} points`;
- t2 && console.time(i3), this.points = e2;
- let s2 = [];
- for (let t3 = 0; t3 < e2.length; t3++)
- e2[t3].geometry && s2.push(G(e2[t3], t3));
- this.trees[o2 + 1] = new z(s2, D, $, n2, Float32Array), t2 && console.timeEnd(i3);
- for (let e3 = o2; e3 >= r2; e3--) {
- const r3 = +Date.now();
- 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);
- }
- return t2 && console.timeEnd("total time"), this;
- }
- getClusters(e2, t2) {
- let r2 = ((e2[0] + 180) % 360 + 360) % 360 - 180;
- const o2 = Math.max(-90, Math.min(90, e2[1]));
- let n2 = 180 === e2[2] ? 180 : ((e2[2] + 180) % 360 + 360) % 360 - 180;
- const i3 = Math.max(-90, Math.min(90, e2[3]));
- if (e2[2] - e2[0] >= 360)
- r2 = -180, n2 = 180;
- else if (r2 > n2) {
- const e3 = this.getClusters([r2, o2, 180, i3], t2), s3 = this.getClusters([-180, o2, n2, i3], t2);
- return e3.concat(s3);
- }
- const s2 = this.trees[this._limitZoom(t2)], a2 = s2.range(Y(r2), X(i3), Y(n2), X(o2)), l2 = [];
- for (const e3 of a2) {
- const t3 = s2.points[e3];
- l2.push(t3.numPoints ? J(t3) : this.points[t3.index]);
- }
- return l2;
- }
- getChildren(e2) {
- const t2 = this._getOriginId(e2), r2 = this._getOriginZoom(e2), o2 = "No cluster with the specified id.", n2 = this.trees[r2];
- if (!n2)
- throw new Error(o2);
- const i3 = n2.points[t2];
- if (!i3)
- throw new Error(o2);
- const s2 = this.options.radius / (this.options.extent * Math.pow(2, r2 - 1)), a2 = n2.within(i3.x, i3.y, s2), l2 = [];
- for (const t3 of a2) {
- const r3 = n2.points[t3];
- r3.parentId === e2 && l2.push(r3.numPoints ? J(r3) : this.points[r3.index]);
- }
- if (0 === l2.length)
- throw new Error(o2);
- return l2;
- }
- getLeaves(e2, t2, r2) {
- const o2 = [];
- return this._appendLeaves(o2, e2, t2 = t2 || 10, r2 = r2 || 0, 0), o2;
- }
- getTile(e2, t2, r2) {
- 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: [] };
- 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;
- }
- getClusterExpansionZoom(e2) {
- let t2 = this._getOriginZoom(e2) - 1;
- for (; t2 <= this.options.maxZoom; ) {
- const r2 = this.getChildren(e2);
- if (t2++, 1 !== r2.length)
- break;
- e2 = r2[0].properties.cluster_id;
- }
- return t2;
- }
- _appendLeaves(e2, t2, r2, o2, n2) {
- const i3 = this.getChildren(t2);
- for (const t3 of i3) {
- const i4 = t3.properties;
- 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)
- break;
- }
- return n2;
- }
- _addTileFeatures(e2, t2, r2, o2, n2, i3) {
- for (const s2 of e2) {
- const e3 = t2[s2], a2 = e3.numPoints;
- let l2, u2, h2;
- if (a2)
- l2 = W(e3), u2 = e3.x, h2 = e3.y;
- else {
- const t3 = this.points[e3.index];
- l2 = t3.properties, u2 = Y(t3.geometry.coordinates[0]), h2 = X(t3.geometry.coordinates[1]);
- }
- const c2 = { type: 1, geometry: [[Math.round(this.options.extent * (u2 * n2 - r2)), Math.round(this.options.extent * (h2 * n2 - o2))]], tags: l2 };
- let f2;
- 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);
- }
- }
- _limitZoom(e2) {
- return Math.max(this.options.minZoom, Math.min(+e2, this.options.maxZoom + 1));
- }
- _cluster(e2, t2) {
- const r2 = [], { radius: o2, extent: n2, reduce: i3, minPoints: s2 } = this.options, a2 = o2 / (n2 * Math.pow(2, t2));
- for (let o3 = 0; o3 < e2.length; o3++) {
- const n3 = e2[o3];
- if (n3.zoom <= t2)
- continue;
- n3.zoom = t2;
- const l2 = this.trees[t2 + 1], u2 = l2.within(n3.x, n3.y, a2), h2 = n3.numPoints || 1;
- let c2 = h2;
- for (const e3 of u2) {
- const r3 = l2.points[e3];
- r3.zoom > t2 && (c2 += r3.numPoints || 1);
- }
- if (c2 > h2 && c2 >= s2) {
- let e3 = n3.x * h2, s3 = n3.y * h2, a3 = i3 && h2 > 1 ? this._map(n3, true) : null;
- const f2 = (o3 << 5) + (t2 + 1) + this.points.length;
- for (const r3 of u2) {
- const o4 = l2.points[r3];
- if (o4.zoom <= t2)
- continue;
- o4.zoom = t2;
- const u3 = o4.numPoints || 1;
- e3 += o4.x * u3, s3 += o4.y * u3, o4.parentId = f2, i3 && (a3 || (a3 = this._map(n3, true)), i3(a3, this._map(o4)));
- }
- n3.parentId = f2, r2.push(Z(e3 / c2, s3 / c2, f2, c2, a3));
- } else if (r2.push(n3), c2 > 1)
- for (const e3 of u2) {
- const o4 = l2.points[e3];
- o4.zoom <= t2 || (o4.zoom = t2, r2.push(o4));
- }
- }
- return r2;
- }
- _getOriginId(e2) {
- return e2 - this.points.length >> 5;
- }
- _getOriginZoom(e2) {
- return (e2 - this.points.length) % 32;
- }
- _map(e2, t2) {
- if (e2.numPoints)
- return t2 ? A({}, e2.properties) : e2.properties;
- const r2 = this.points[e2.index].properties, o2 = this.options.map(r2);
- return t2 && o2 === r2 ? A({}, o2) : o2;
- }
- }
- function Z(e2, t2, r2, o2, n2) {
- return { x: F(e2), y: F(t2), zoom: 1 / 0, id: r2, parentId: -1, numPoints: o2, properties: n2 };
- }
- function G(e2, t2) {
- const [r2, o2] = e2.geometry.coordinates;
- return { x: F(Y(r2)), y: F(X(o2)), zoom: 1 / 0, index: t2, parentId: -1 };
- }
- function J(e2) {
- return { type: "Feature", id: e2.id, properties: W(e2), geometry: { type: "Point", coordinates: [(t2 = e2.x, 360 * (t2 - 0.5)), V(e2.y)] } };
- var t2;
- }
- function W(e2) {
- const t2 = e2.numPoints, r2 = t2 >= 1e4 ? `${Math.round(t2 / 1e3)}k` : t2 >= 1e3 ? Math.round(t2 / 100) / 10 + "k" : t2;
- return A(A({}, e2.properties), { cluster: true, cluster_id: e2.id, point_count: t2, point_count_abbreviated: r2 });
- }
- function Y(e2) {
- return e2 / 360 + 0.5;
- }
- function X(e2) {
- const t2 = Math.sin(e2 * Math.PI / 180), r2 = 0.5 - 0.25 * Math.log((1 + t2) / (1 - t2)) / Math.PI;
- return r2 < 0 ? 0 : r2 > 1 ? 1 : r2;
- }
- function V(e2) {
- const t2 = (180 - 360 * e2) * Math.PI / 180;
- return 360 * Math.atan(Math.exp(t2)) / Math.PI - 90;
- }
- function A(e2, t2) {
- for (const r2 in t2)
- e2[r2] = t2[r2];
- return e2;
- }
- function D(e2) {
- return e2.x;
- }
- function $(e2) {
- return e2.y;
- }
- function B(e2, t2, r2, o2) {
- 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) {
- var p2 = R(e2[f2], e2[f2 + 1], l2, u2, h2, c2);
- if (p2 > i3)
- n2 = f2, i3 = p2;
- else if (p2 === i3) {
- var g2 = Math.abs(f2 - s2);
- g2 < a2 && (n2 = f2, a2 = g2);
- }
- }
- i3 > o2 && (n2 - t2 > 3 && B(e2, t2, n2, o2), e2[n2 + 2] = i3, r2 - n2 > 3 && B(e2, n2, r2, o2));
- }
- function R(e2, t2, r2, o2, n2, i3) {
- var s2 = n2 - r2, a2 = i3 - o2;
- if (0 !== s2 || 0 !== a2) {
- var l2 = ((e2 - r2) * s2 + (t2 - o2) * a2) / (s2 * s2 + a2 * a2);
- l2 > 1 ? (r2 = n2, o2 = i3) : l2 > 0 && (r2 += s2 * l2, o2 += a2 * l2);
- }
- return (s2 = e2 - r2) * s2 + (a2 = t2 - o2) * a2;
- }
- function q(e2, t2, r2, o2) {
- 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 };
- return function(e3) {
- var t3 = e3.geometry, r3 = e3.type;
- if ("Point" === r3 || "MultiPoint" === r3 || "LineString" === r3)
- U(e3, t3);
- else if ("Polygon" === r3 || "MultiLineString" === r3)
- for (var o3 = 0; o3 < t3.length; o3++)
- U(e3, t3[o3]);
- else if ("MultiPolygon" === r3)
- for (o3 = 0; o3 < t3.length; o3++)
- for (var n3 = 0; n3 < t3[o3].length; n3++)
- U(e3, t3[o3][n3]);
- }(n2), n2;
- }
- function U(e2, t2) {
- for (var r2 = 0; r2 < t2.length; r2 += 3)
- 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]);
- }
- function Q(e2, t2, r2, o2) {
- if (t2.geometry) {
- var n2 = t2.geometry.coordinates, i3 = t2.geometry.type, s2 = Math.pow(r2.tolerance / ((1 << r2.maxZoom) * r2.extent), 2), a2 = [], l2 = t2.id;
- if (r2.promoteId ? l2 = t2.properties[r2.promoteId] : r2.generateId && (l2 = o2 || 0), "Point" === i3)
- H(n2, a2);
- else if ("MultiPoint" === i3)
- for (var u2 = 0; u2 < n2.length; u2++)
- H(n2[u2], a2);
- else if ("LineString" === i3)
- K(n2, a2, s2, false);
- else if ("MultiLineString" === i3) {
- if (r2.lineMetrics) {
- for (u2 = 0; u2 < n2.length; u2++)
- K(n2[u2], a2 = [], s2, false), e2.push(q(l2, "LineString", a2, t2.properties));
- return;
- }
- ee(n2, a2, s2, false);
- } else if ("Polygon" === i3)
- ee(n2, a2, s2, true);
- else {
- if ("MultiPolygon" !== i3) {
- if ("GeometryCollection" === i3) {
- for (u2 = 0; u2 < t2.geometry.geometries.length; u2++)
- Q(e2, { id: l2, geometry: t2.geometry.geometries[u2], properties: t2.properties }, r2, o2);
- return;
- }
- throw new Error("Input data is not a valid GeoJSON object.");
- }
- for (u2 = 0; u2 < n2.length; u2++) {
- var h2 = [];
- ee(n2[u2], h2, s2, true), a2.push(h2);
- }
- }
- e2.push(q(l2, i3, a2, t2.properties));
- }
- }
- function H(e2, t2) {
- t2.push(te(e2[0])), t2.push(re(e2[1])), t2.push(0);
- }
- function K(e2, t2, r2, o2) {
- for (var n2, i3, s2 = 0, a2 = 0; a2 < e2.length; a2++) {
- var l2 = te(e2[a2][0]), u2 = re(e2[a2][1]);
- 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;
- }
- var h2 = t2.length - 3;
- t2[2] = 1, B(t2, 0, h2, r2), t2[h2 + 2] = 1, t2.size = Math.abs(s2), t2.start = 0, t2.end = t2.size;
- }
- function ee(e2, t2, r2, o2) {
- for (var n2 = 0; n2 < e2.length; n2++) {
- var i3 = [];
- K(e2[n2], i3, r2, o2), t2.push(i3);
- }
- }
- function te(e2) {
- return e2 / 360 + 0.5;
- }
- function re(e2) {
- var t2 = Math.sin(e2 * Math.PI / 180), r2 = 0.5 - 0.25 * Math.log((1 + t2) / (1 - t2)) / Math.PI;
- return r2 < 0 ? 0 : r2 > 1 ? 1 : r2;
- }
- function oe(e2, t2, r2, o2, n2, i3, s2, a2) {
- if (o2 /= t2, i3 >= (r2 /= t2) && s2 < o2)
- return e2;
- if (s2 < r2 || i3 >= o2)
- return null;
- for (var l2 = [], u2 = 0; u2 < e2.length; u2++) {
- var h2 = e2[u2], c2 = h2.geometry, f2 = h2.type, p2 = 0 === n2 ? h2.minX : h2.minY, g2 = 0 === n2 ? h2.maxX : h2.maxY;
- if (p2 >= r2 && g2 < o2)
- l2.push(h2);
- else if (!(g2 < r2 || p2 >= o2)) {
- var d2 = [];
- if ("Point" === f2 || "MultiPoint" === f2)
- ne(c2, d2, r2, o2, n2);
- else if ("LineString" === f2)
- ie(c2, d2, r2, o2, n2, false, a2.lineMetrics);
- else if ("MultiLineString" === f2)
- ae(c2, d2, r2, o2, n2, false);
- else if ("Polygon" === f2)
- ae(c2, d2, r2, o2, n2, true);
- else if ("MultiPolygon" === f2)
- for (var m2 = 0; m2 < c2.length; m2++) {
- var y2 = [];
- ae(c2[m2], y2, r2, o2, n2, true), y2.length && d2.push(y2);
- }
- if (d2.length) {
- if (a2.lineMetrics && "LineString" === f2) {
- for (m2 = 0; m2 < d2.length; m2++)
- l2.push(q(h2.id, f2, d2[m2], h2.tags));
- continue;
- }
- "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));
- }
- }
- }
- return l2.length ? l2 : null;
- }
- function ne(e2, t2, r2, o2, n2) {
- for (var i3 = 0; i3 < e2.length; i3 += 3) {
- var s2 = e2[i3 + n2];
- s2 >= r2 && s2 <= o2 && (t2.push(e2[i3]), t2.push(e2[i3 + 1]), t2.push(e2[i3 + 2]));
- }
- }
- function ie(e2, t2, r2, o2, n2, i3, s2) {
- for (var a2, l2, u2 = se(e2), h2 = 0 === n2 ? ue : he, c2 = e2.start, f2 = 0; f2 < e2.length - 3; f2 += 3) {
- 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;
- 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);
- }
- var S2 = e2.length - 3;
- 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);
- }
- function se(e2) {
- var t2 = [];
- return t2.size = e2.size, t2.start = e2.start, t2.end = e2.end, t2;
- }
- function ae(e2, t2, r2, o2, n2, i3) {
- for (var s2 = 0; s2 < e2.length; s2++)
- ie(e2[s2], t2, r2, o2, n2, i3, false);
- }
- function le(e2, t2, r2, o2) {
- e2.push(t2), e2.push(r2), e2.push(o2);
- }
- function ue(e2, t2, r2, o2, n2, i3) {
- var s2 = (i3 - t2) / (o2 - t2);
- return e2.push(i3), e2.push(r2 + (n2 - r2) * s2), e2.push(1), s2;
- }
- function he(e2, t2, r2, o2, n2, i3) {
- var s2 = (i3 - r2) / (n2 - r2);
- return e2.push(t2 + (o2 - t2) * s2), e2.push(i3), e2.push(1), s2;
- }
- function ce(e2, t2) {
- for (var r2 = [], o2 = 0; o2 < e2.length; o2++) {
- var n2, i3 = e2[o2], s2 = i3.type;
- if ("Point" === s2 || "MultiPoint" === s2 || "LineString" === s2)
- n2 = fe(i3.geometry, t2);
- else if ("MultiLineString" === s2 || "Polygon" === s2) {
- n2 = [];
- for (var a2 = 0; a2 < i3.geometry.length; a2++)
- n2.push(fe(i3.geometry[a2], t2));
- } else if ("MultiPolygon" === s2)
- for (n2 = [], a2 = 0; a2 < i3.geometry.length; a2++) {
- for (var l2 = [], u2 = 0; u2 < i3.geometry[a2].length; u2++)
- l2.push(fe(i3.geometry[a2][u2], t2));
- n2.push(l2);
- }
- r2.push(q(i3.id, s2, n2, i3.tags));
- }
- return r2;
- }
- function fe(e2, t2) {
- var r2 = [];
- r2.size = e2.size, void 0 !== e2.start && (r2.start = e2.start, r2.end = e2.end);
- for (var o2 = 0; o2 < e2.length; o2 += 3)
- r2.push(e2[o2] + t2, e2[o2 + 1], e2[o2 + 2]);
- return r2;
- }
- function pe(e2, t2) {
- if (e2.transformed)
- return e2;
- var r2, o2, n2, i3 = 1 << e2.z, s2 = e2.x, a2 = e2.y;
- for (r2 = 0; r2 < e2.features.length; r2++) {
- var l2 = e2.features[r2], u2 = l2.geometry, h2 = l2.type;
- if (l2.geometry = [], 1 === h2)
- for (o2 = 0; o2 < u2.length; o2 += 2)
- l2.geometry.push(ge(u2[o2], u2[o2 + 1], t2, i3, s2, a2));
- else
- for (o2 = 0; o2 < u2.length; o2++) {
- var c2 = [];
- for (n2 = 0; n2 < u2[o2].length; n2 += 2)
- c2.push(ge(u2[o2][n2], u2[o2][n2 + 1], t2, i3, s2, a2));
- l2.geometry.push(c2);
- }
- }
- return e2.transformed = true, e2;
- }
- function ge(e2, t2, r2, o2, n2, i3) {
- return [Math.round(r2 * (e2 * o2 - n2)), Math.round(r2 * (t2 * o2 - i3))];
- }
- function de(e2, t2, r2, o2, n2) {
- 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++) {
- s2.numFeatures++, me(s2, e2[a2], i3, n2);
- var l2 = e2[a2].minX, u2 = e2[a2].minY, h2 = e2[a2].maxX, c2 = e2[a2].maxY;
- l2 < s2.minX && (s2.minX = l2), u2 < s2.minY && (s2.minY = u2), h2 > s2.maxX && (s2.maxX = h2), c2 > s2.maxY && (s2.maxY = c2);
- }
- return s2;
- }
- function me(e2, t2, r2, o2) {
- var n2 = t2.geometry, i3 = t2.type, s2 = [];
- if ("Point" === i3 || "MultiPoint" === i3)
- for (var a2 = 0; a2 < n2.length; a2 += 3)
- s2.push(n2[a2]), s2.push(n2[a2 + 1]), e2.numPoints++, e2.numSimplified++;
- else if ("LineString" === i3)
- ye(s2, n2, e2, r2, false, false);
- else if ("MultiLineString" === i3 || "Polygon" === i3)
- for (a2 = 0; a2 < n2.length; a2++)
- ye(s2, n2[a2], e2, r2, "Polygon" === i3, 0 === a2);
- else if ("MultiPolygon" === i3)
- for (var l2 = 0; l2 < n2.length; l2++) {
- var u2 = n2[l2];
- for (a2 = 0; a2 < u2.length; a2++)
- ye(s2, u2[a2], e2, r2, true, 0 === a2);
- }
- if (s2.length) {
- var h2 = t2.tags || null;
- if ("LineString" === i3 && o2.lineMetrics) {
- for (var c2 in h2 = {}, t2.tags)
- h2[c2] = t2.tags[c2];
- h2.mapbox_clip_start = n2.start / n2.size, h2.mapbox_clip_end = n2.end / n2.size;
- }
- var f2 = { geometry: s2, type: "Polygon" === i3 || "MultiPolygon" === i3 ? 3 : "LineString" === i3 || "MultiLineString" === i3 ? 2 : 1, tags: h2 };
- null !== t2.id && (f2.id = t2.id), e2.features.push(f2);
- }
- }
- function ye(e2, t2, r2, o2, n2, i3) {
- var s2 = o2 * o2;
- if (o2 > 0 && t2.size < (n2 ? s2 : o2))
- r2.numPoints += t2.length / 3;
- else {
- for (var a2 = [], l2 = 0; l2 < t2.length; l2 += 3)
- (0 === o2 || t2[l2 + 2] > s2) && (r2.numSimplified++, a2.push(t2[l2]), a2.push(t2[l2 + 1])), r2.numPoints++;
- n2 && function(e3, t3) {
- for (var r3 = 0, o3 = 0, n3 = e3.length, i4 = n3 - 2; o3 < n3; i4 = o3, o3 += 2)
- r3 += (e3[o3] - e3[i4]) * (e3[o3 + 1] + e3[i4 + 1]);
- if (r3 > 0 === t3)
- for (o3 = 0, n3 = e3.length; o3 < n3 / 2; o3 += 2) {
- var s3 = e3[o3], a3 = e3[o3 + 1];
- e3[o3] = e3[n3 - 2 - o3], e3[o3 + 1] = e3[n3 - 1 - o3], e3[n3 - 2 - o3] = s3, e3[n3 - 1 - o3] = a3;
- }
- }(a2, i3), e2.push(a2);
- }
- }
- function ve(e2, t2) {
- var r2 = (t2 = this.options = function(e3, t3) {
- for (var r3 in t3)
- e3[r3] = t3[r3];
- return e3;
- }(Object.create(this.options), t2)).debug;
- if (r2 && console.time("preprocess data"), t2.maxZoom < 0 || t2.maxZoom > 24)
- throw new Error("maxZoom should be in the 0-24 range");
- if (t2.promoteId && t2.generateId)
- throw new Error("promoteId and generateId cannot be used together.");
- var o2 = function(e3, t3) {
- var r3 = [];
- if ("FeatureCollection" === e3.type)
- for (var o3 = 0; o3 < e3.features.length; o3++)
- Q(r3, e3.features[o3], t3, o3);
- else
- Q(r3, "Feature" === e3.type ? e3 : { geometry: e3 }, t3);
- return r3;
- }(e2, t2);
- 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) {
- 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);
- 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;
- }(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)));
- }
- function xe(e2, t2, r2) {
- return 32 * ((1 << e2) * r2 + t2) + e2;
- }
- function we(e2, t2) {
- const r2 = e2.tileID.canonical;
- if (!this._geoJSONIndex)
- return t2(null, null);
- const o2 = this._geoJSONIndex.getTile(r2.z, r2.x, r2.y);
- if (!o2)
- return t2(null, null);
- const n2 = new h(o2.features);
- let i3 = d(n2);
- 0 === i3.byteOffset && i3.byteLength === i3.buffer.byteLength || (i3 = new Uint8Array(i3)), t2(null, { vectorTile: n2, rawData: i3.buffer });
- }
- 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) {
- for (var a2 = [e2, t2, r2, o2], l2 = this.options, u2 = l2.debug; a2.length; ) {
- o2 = a2.pop(), r2 = a2.pop(), t2 = a2.pop(), e2 = a2.pop();
- var h2 = 1 << t2, c2 = xe(t2, r2, o2), f2 = this.tiles[c2];
- 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)) {
- 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"));
- var p2 = "z" + t2;
- this.stats[p2] = (this.stats[p2] || 0) + 1, this.total++;
- }
- if (f2.source = e2, n2) {
- if (t2 === l2.maxZoom || t2 === n2)
- continue;
- var g2 = 1 << n2 - t2;
- if (r2 !== Math.floor(i3 / g2) || o2 !== Math.floor(s2 / g2))
- continue;
- } else if (t2 === l2.indexMaxZoom || f2.numPoints <= l2.indexMaxPoints)
- continue;
- if (f2.source = null, 0 !== e2.length) {
- u2 > 1 && console.time("clipping");
- 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;
- 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);
- }
- }
- }, ve.prototype.getTile = function(e2, t2, r2) {
- var o2 = this.options, n2 = o2.extent, i3 = o2.debug;
- if (e2 < 0 || e2 > 24)
- return null;
- var s2 = 1 << e2, a2 = xe(e2, t2 = (t2 % s2 + s2) % s2, r2);
- if (this.tiles[a2])
- return pe(this.tiles[a2], n2);
- i3 > 1 && console.log("drilling down to z%d-%d-%d", e2, t2, r2);
- for (var l2, u2 = e2, h2 = t2, c2 = r2; !l2 && u2 > 0; )
- u2--, h2 = Math.floor(h2 / 2), c2 = Math.floor(c2 / 2), l2 = this.tiles[xe(u2, h2, c2)];
- 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;
- };
- class Se extends e.VectorTileWorkerSource {
- constructor(e2, t2, r2, o2, n2) {
- super(e2, t2, r2, o2, we), n2 && (this.loadGeoJSON = n2);
- }
- loadData(t2, r2) {
- const o2 = t2 && t2.request, n2 = o2 && o2.collectResourceTiming;
- this.loadGeoJSON(t2, (s2, a2) => {
- if (s2 || !a2)
- return r2(s2);
- if ("object" != typeof a2)
- return r2(new Error(`Input data given to '${t2.source}' is not a valid GeoJSON object.`));
- {
- i2(a2, true);
- try {
- if (t2.filter) {
- const r3 = e.createExpression(t2.filter, { type: "boolean", "property-type": "data-driven", overridable: false, transition: false });
- if ("error" === r3.result)
- throw new Error(r3.value.map((e2) => `${e2.key}: ${e2.message}`).join(", "));
- const o3 = a2.features.filter((e2) => r3.value.evaluate({ zoom: 0 }, e2));
- a2 = { type: "FeatureCollection", features: o3 };
- }
- this._geoJSONIndex = t2.cluster ? new j(function({ superclusterOptions: t3, clusterProperties: r3 }) {
- if (!r3 || !t3)
- return t3;
- const o3 = {}, n3 = {}, i3 = { accumulated: null, zoom: 0 }, s3 = { properties: null }, a3 = Object.keys(r3);
- for (const t4 of a3) {
- const [i4, s4] = r3[t4], a4 = e.createExpression(s4), l3 = e.createExpression("string" == typeof i4 ? [i4, ["accumulated"], ["get", t4]] : i4);
- o3[t4] = a4.value, n3[t4] = l3.value;
- }
- return t3.map = (e2) => {
- s3.properties = e2;
- const t4 = {};
- for (const e3 of a3)
- t4[e3] = o3[e3].evaluate(i3, s3);
- return t4;
- }, t3.reduce = (e2, t4) => {
- s3.properties = t4;
- for (const t5 of a3)
- i3.accumulated = e2[t5], e2[t5] = n3[t5].evaluate(i3, s3);
- }, t3;
- }(t2)).load(a2.features) : function(e2, t3) {
- return new ve(e2, t3);
- }(a2, t2.geojsonVtOptions);
- } catch (s3) {
- return r2(s3);
- }
- this.loaded = {};
- const l2 = {};
- if (n2) {
- const r3 = e.getPerformanceMeasurement(o2);
- r3 && (l2.resourceTiming = {}, l2.resourceTiming[t2.source] = JSON.parse(JSON.stringify(r3)));
- }
- r2(null, l2);
- }
- });
- }
- reloadTile(e2, t2) {
- const r2 = this.loaded;
- return r2 && r2[e2.uid] ? super.reloadTile(e2, t2) : this.loadTile(e2, t2);
- }
- loadGeoJSON(t2, r2) {
- if (t2.request)
- e.getJSON(t2.request, r2);
- else {
- if ("string" != typeof t2.data)
- return r2(new Error(`Input data given to '${t2.source}' is not a valid GeoJSON object.`));
- try {
- return r2(null, JSON.parse(t2.data));
- } catch (e2) {
- return r2(new Error(`Input data given to '${t2.source}' is not a valid GeoJSON object.`));
- }
- }
- }
- getClusterExpansionZoom(e2, t2) {
- try {
- t2(null, this._geoJSONIndex.getClusterExpansionZoom(e2.clusterId));
- } catch (e3) {
- t2(e3);
- }
- }
- getClusterChildren(e2, t2) {
- try {
- t2(null, this._geoJSONIndex.getChildren(e2.clusterId));
- } catch (e3) {
- t2(e3);
- }
- }
- getClusterLeaves(e2, t2) {
- try {
- t2(null, this._geoJSONIndex.getLeaves(e2.clusterId, e2.limit, e2.offset));
- } catch (e3) {
- t2(e3);
- }
- }
- }
- class Me {
- constructor(t2) {
- 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) => {
- if (this.workerSourceTypes[e2])
- throw new Error(`Worker source with name "${e2}" already registered.`);
- this.workerSourceTypes[e2] = t3;
- }, this.self.registerRTLTextPlugin = (t3) => {
- if (e.plugin.isParsed())
- throw new Error("RTL text plugin already registered.");
- e.plugin.applyArabicShaping = t3.applyArabicShaping, e.plugin.processBidirectionalText = t3.processBidirectionalText, e.plugin.processStyledBidirectionalText = t3.processStyledBidirectionalText;
- };
- }
- clearCaches(e2, t2, r2) {
- delete this.layerIndexes[e2], delete this.availableImages[e2], delete this.workerSources[e2], delete this.demWorkerSources[e2], r2();
- }
- checkIfReady(e2, t2, r2) {
- r2();
- }
- setReferrer(e2, t2) {
- this.referrer = t2;
- }
- spriteLoaded(t2, r2) {
- this.isSpriteLoaded[t2] = r2;
- for (const o2 in this.workerSources[t2]) {
- const n2 = this.workerSources[t2][o2];
- for (const t3 in n2)
- n2[t3] instanceof e.VectorTileWorkerSource && (n2[t3].isSpriteLoaded = r2, n2[t3].fire(new e.Event("isSpriteLoaded")));
- }
- }
- setImages(e2, t2, r2) {
- this.availableImages[e2] = t2;
- for (const r3 in this.workerSources[e2]) {
- const o2 = this.workerSources[e2][r3];
- for (const e3 in o2)
- o2[e3].availableImages = t2;
- }
- r2();
- }
- enableTerrain(e2, t2, r2) {
- this.terrain = t2, r2();
- }
- setProjection(t2, r2) {
- this.projections[t2] = e.getProjection(r2);
- }
- setLayers(e2, t2, r2) {
- this.getLayerIndex(e2).replace(t2), r2();
- }
- updateLayers(e2, t2, r2) {
- this.getLayerIndex(e2).update(t2.layers, t2.removedIds), r2();
- }
- loadTile(t2, r2, o2) {
- const n2 = this.enableTerrain ? e.extend({ enableTerrain: this.terrain }, r2) : r2;
- n2.projection = this.projections[t2] || this.defaultProjection, this.getWorkerSource(t2, r2.type, r2.source).loadTile(n2, o2);
- }
- loadDEMTile(t2, r2, o2) {
- const n2 = this.enableTerrain ? e.extend({ buildQuadTree: this.terrain }, r2) : r2;
- this.getDEMWorkerSource(t2, r2.source).loadTile(n2, o2);
- }
- reloadTile(t2, r2, o2) {
- const n2 = this.enableTerrain ? e.extend({ enableTerrain: this.terrain }, r2) : r2;
- n2.projection = this.projections[t2] || this.defaultProjection, this.getWorkerSource(t2, r2.type, r2.source).reloadTile(n2, o2);
- }
- abortTile(e2, t2, r2) {
- this.getWorkerSource(e2, t2.type, t2.source).abortTile(t2, r2);
- }
- removeTile(e2, t2, r2) {
- this.getWorkerSource(e2, t2.type, t2.source).removeTile(t2, r2);
- }
- removeSource(e2, t2, r2) {
- if (!this.workerSources[e2] || !this.workerSources[e2][t2.type] || !this.workerSources[e2][t2.type][t2.source])
- return;
- const o2 = this.workerSources[e2][t2.type][t2.source];
- delete this.workerSources[e2][t2.type][t2.source], void 0 !== o2.removeSource ? o2.removeSource(t2, r2) : r2();
- }
- loadWorkerSource(e2, t2, r2) {
- try {
- this.self.importScripts(t2.url), r2();
- } catch (e3) {
- r2(e3.toString());
- }
- }
- syncRTLPluginState(t2, r2, o2) {
- try {
- e.plugin.setState(r2);
- const t3 = e.plugin.getPluginURL();
- if (e.plugin.isLoaded() && !e.plugin.isParsed() && null != t3) {
- this.self.importScripts(t3);
- const r3 = e.plugin.isParsed();
- o2(r3 ? void 0 : new Error(`RTL Text Plugin failed to import scripts from ${t3}`), r3);
- }
- } catch (e2) {
- o2(e2.toString());
- }
- }
- getAvailableImages(e2) {
- let t2 = this.availableImages[e2];
- return t2 || (t2 = []), t2;
- }
- getLayerIndex(e2) {
- let t2 = this.layerIndexes[e2];
- return t2 || (t2 = this.layerIndexes[e2] = new o()), t2;
- }
- getWorkerSource(e2, t2, r2) {
- 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) => {
- this.actor.send(t3, r3, o2, e2, i3, s2);
- }, scheduler: this.actor.scheduler }, this.getLayerIndex(e2), this.getAvailableImages(e2), this.isSpriteLoaded[e2])), this.workerSources[e2][t2][r2];
- }
- getDEMWorkerSource(e2, t2) {
- return this.demWorkerSources[e2] || (this.demWorkerSources[e2] = {}), this.demWorkerSources[e2][t2] || (this.demWorkerSources[e2][t2] = new n()), this.demWorkerSources[e2][t2];
- }
- enforceCacheSizeLimit(t2, r2) {
- e.enforceCacheSizeLimit(r2);
- }
- getWorkerPerformanceMetrics(e2, t2, r2) {
- r2(void 0, void 0);
- }
- }
- return "undefined" != typeof WorkerGlobalScope && "undefined" != typeof self && self instanceof WorkerGlobalScope && (self.worker = new Me(self)), Me;
- });
- define(["./shared"], function(e) {
- var t = i2;
- function i2(e2) {
- return !function(e3) {
- 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() {
- if (!("Worker" in window && "Blob" in window && "URL" in window))
- return false;
- var e4, t3, i3 = new Blob([""], { type: "text/javascript" }), o2 = URL.createObjectURL(i3);
- try {
- t3 = new Worker(o2), e4 = true;
- } catch (t4) {
- e4 = false;
- }
- return t3 && t3.terminate(), URL.revokeObjectURL(o2), e4;
- }() ? "Uint8ClampedArray" in window ? ArrayBuffer.isView ? function() {
- var e4 = document.createElement("canvas");
- e4.width = e4.height = 1;
- var t3 = e4.getContext("2d");
- if (!t3)
- return false;
- var i3 = t3.getImageData(0, 0, 1, 1);
- return i3 && i3.width === e4.width;
- }() ? (void 0 === o[t2 = e3 && e3.failIfMajorPerformanceCaveat] && (o[t2] = function(e4) {
- var t3, o2 = function(e5) {
- var t4 = document.createElement("canvas"), o3 = Object.create(i2.webGLContextAttributes);
- return o3.failIfMajorPerformanceCaveat = e5, t4.getContext("webgl", o3) || t4.getContext("experimental-webgl", o3);
- }(e4);
- if (!o2)
- return false;
- try {
- t3 = o2.createShader(o2.VERTEX_SHADER);
- } catch (e5) {
- return false;
- }
- return !(!t3 || o2.isContextLost()) && (o2.shaderSource(t3, "void main() {}"), o2.compileShader(t3), true === o2.getShaderParameter(t3, o2.COMPILE_STATUS));
- }(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";
- var t2;
- }(e2);
- }
- var o = {};
- function r(e2, t2) {
- if (Array.isArray(e2)) {
- if (!Array.isArray(t2) || e2.length !== t2.length)
- return false;
- for (let i3 = 0; i3 < e2.length; i3++)
- if (!r(e2[i3], t2[i3]))
- return false;
- return true;
- }
- if ("object" == typeof e2 && null !== e2 && null !== t2) {
- if ("object" != typeof t2)
- return false;
- if (Object.keys(e2).length !== Object.keys(t2).length)
- return false;
- for (const i3 in e2)
- if (!r(e2[i3], t2[i3]))
- return false;
- return true;
- }
- return e2 === t2;
- }
- function n(t2, i3, o2) {
- const r2 = e.window.document.createElement(t2);
- return void 0 !== i3 && (r2.className = i3), o2 && o2.appendChild(r2), r2;
- }
- function a(t2, i3, o2) {
- const r2 = e.window.document.createElementNS("http://www.w3.org/2000/svg", t2);
- for (const e2 of Object.keys(i3))
- r2.setAttributeNS(null, e2, i3[e2]);
- return o2 && o2.appendChild(r2), r2;
- }
- i2.webGLContextAttributes = { antialias: false, alpha: true, stencil: true, depth: true };
- const s = e.window.document && e.window.document.documentElement.style, l = s && void 0 !== s.userSelect ? "userSelect" : "WebkitUserSelect";
- let c;
- function h() {
- s && l && (c = s[l], s[l] = "none");
- }
- function _() {
- s && l && (s[l] = c);
- }
- function u(t2) {
- t2.preventDefault(), t2.stopPropagation(), e.window.removeEventListener("click", u, true);
- }
- function d() {
- e.window.addEventListener("click", u, true), e.window.setTimeout(() => {
- e.window.removeEventListener("click", u, true);
- }, 0);
- }
- function p(e2, t2) {
- const i3 = e2.getBoundingClientRect();
- return g(e2, i3, t2);
- }
- function m(e2, t2) {
- const i3 = e2.getBoundingClientRect(), o2 = [];
- for (let r2 = 0; r2 < t2.length; r2++)
- o2.push(g(e2, i3, t2[r2]));
- return o2;
- }
- function f(t2) {
- return void 0 !== e.window.InstallTrigger && 2 === t2.button && t2.ctrlKey && e.window.navigator.platform.toUpperCase().indexOf("MAC") >= 0 ? 0 : t2.button;
- }
- function g(t2, i3, o2) {
- const r2 = t2.offsetWidth === i3.width ? 1 : t2.offsetWidth / i3.width;
- return new e.pointGeometry((o2.clientX - i3.left) * r2, (o2.clientY - i3.top) * r2);
- }
- function v(e2, t2) {
- var i3 = t2[0], o2 = t2[1], r2 = t2[2], n2 = t2[3], a2 = i3 * n2 - r2 * o2;
- return a2 ? (e2[0] = n2 * (a2 = 1 / a2), e2[1] = -o2 * a2, e2[2] = -r2 * a2, e2[3] = i3 * a2, e2) : null;
- }
- function x(e2) {
- const { userImage: t2 } = e2;
- return !!(t2 && t2.render && t2.render()) && (e2.data.replace(new Uint8Array(t2.data.buffer)), true);
- }
- class y extends e.Evented {
- constructor() {
- 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;
- }
- isLoaded() {
- return this.loaded;
- }
- setLoaded(e2) {
- if (this.loaded !== e2 && (this.loaded = e2, e2)) {
- for (const { ids: e3, callback: t2 } of this.requestors)
- this._notify(e3, t2);
- this.requestors = [];
- }
- }
- hasImage(e2) {
- return !!this.getImage(e2);
- }
- getImage(e2) {
- return this.images[e2];
- }
- addImage(e2, t2) {
- this._validate(e2, t2) && (this.images[e2] = t2);
- }
- _validate(t2, i3) {
- let o2 = true;
- 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;
- }
- _validateStretch(e2, t2) {
- if (!e2)
- return true;
- let i3 = 0;
- for (const o2 of e2) {
- if (o2[0] < i3 || o2[1] < o2[0] || t2 < o2[1])
- return false;
- i3 = o2[1];
- }
- return true;
- }
- _validateContent(e2, t2) {
- 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]));
- }
- updateImage(e2, t2) {
- t2.version = this.images[e2].version + 1, this.images[e2] = t2, this.updatedImages[e2] = true;
- }
- removeImage(e2) {
- const t2 = this.images[e2];
- delete this.images[e2], delete this.patterns[e2], t2.userImage && t2.userImage.onRemove && t2.userImage.onRemove();
- }
- listImages() {
- return Object.keys(this.images);
- }
- getImages(e2, t2) {
- let i3 = true;
- if (!this.isLoaded())
- for (const t3 of e2)
- this.images[t3] || (i3 = false);
- this.isLoaded() || i3 ? this._notify(e2, t2) : this.requestors.push({ ids: e2, callback: t2 });
- }
- _notify(t2, i3) {
- const o2 = {};
- for (const i4 of t2) {
- this.images[i4] || this.fire(new e.Event("styleimagemissing", { id: i4 }));
- const t3 = this.images[i4];
- 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.`);
- }
- i3(null, o2);
- }
- getPixelSize() {
- const { width: e2, height: t2 } = this.atlasImage;
- return { width: e2, height: t2 };
- }
- getPattern(t2) {
- const i3 = this.patterns[t2], o2 = this.getImage(t2);
- if (!o2)
- return null;
- if (i3 && i3.position.version === o2.version)
- return i3.position;
- if (i3)
- i3.position.version = o2.version;
- else {
- const i4 = { w: o2.data.width + 2, h: o2.data.height + 2, x: 0, y: 0 }, r2 = new e.ImagePosition(i4, o2);
- this.patterns[t2] = { bin: i4, position: r2 };
- }
- return this._updatePatternAtlas(), this.patterns[t2].position;
- }
- bind(t2) {
- const i3 = t2.gl;
- 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);
- }
- _updatePatternAtlas() {
- const t2 = [];
- for (const e2 in this.patterns)
- t2.push(this.patterns[e2].bin);
- const { w: i3, h: o2 } = e.potpack(t2), r2 = this.atlasImage;
- r2.resize({ width: i3 || 1, height: o2 || 1 });
- for (const t3 in this.patterns) {
- 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;
- 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 });
- }
- this.dirty = true;
- }
- beginFrame() {
- this.callbackDispatchedThisFrame = {};
- }
- dispatchRenderCallbacks(e2) {
- for (const t2 of e2) {
- if (this.callbackDispatchedThisFrame[t2])
- continue;
- this.callbackDispatchedThisFrame[t2] = true;
- const e3 = this.images[t2];
- x(e3) && this.updateImage(t2, e3);
- }
- }
- }
- const b = new e.Properties({ anchor: new e.DataConstantProperty(e.spec.light.anchor), position: new class {
- constructor() {
- this.specification = e.spec.light.position;
- }
- possiblyEvaluate(t2, i3) {
- return function([t3, i4, o2]) {
- const r2 = e.degToRad(i4 + 90), n2 = e.degToRad(o2);
- 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 };
- }(t2.expression.evaluate(i3));
- }
- interpolate(t2, i3, o2) {
- 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) };
- }
- }(), color: new e.DataConstantProperty(e.spec.light.color), intensity: new e.DataConstantProperty(e.spec.light.intensity) }), w = "-transition";
- class T extends e.Evented {
- constructor(t2) {
- super(), this._transitionable = new e.Transitionable(b), this.setLight(t2), this._transitioning = this._transitionable.untransitioned();
- }
- getLight() {
- return this._transitionable.serialize();
- }
- setLight(t2, i3 = {}) {
- if (!this._validate(e.validateLight, t2, i3))
- for (const i4 in t2) {
- const o2 = t2[i4];
- e.endsWith(i4, w) ? this._transitionable.setTransition(i4.slice(0, -w.length), o2) : this._transitionable.setValue(i4, o2);
- }
- }
- updateTransitions(e2) {
- this._transitioning = this._transitionable.transitioned(e2, this._transitioning);
- }
- hasTransition() {
- return this._transitioning.hasTransition();
- }
- recalculate(e2) {
- this.properties = this._transitioning.possiblyEvaluate(e2);
- }
- _validate(t2, i3, o2) {
- return (!o2 || false !== o2.validate) && e.emitValidationErrors(this, t2.call(e.validateStyle, e.extend({ value: i3, style: { glyphs: true, sprite: true }, styleSpec: e.spec })));
- }
- }
- const E = new e.Properties({ source: new e.DataConstantProperty(e.spec.terrain.source), exaggeration: new e.DataConstantProperty(e.spec.terrain.exaggeration) }), C = "-transition";
- class I extends e.Evented {
- constructor(t2, i3) {
- super(), this._transitionable = new e.Transitionable(E), this.set(t2), this._transitioning = this._transitionable.untransitioned(), this.drapeRenderMode = i3;
- }
- get() {
- return this._transitionable.serialize();
- }
- set(t2) {
- for (const i3 in t2) {
- const o2 = t2[i3];
- e.endsWith(i3, C) ? this._transitionable.setTransition(i3.slice(0, -C.length), o2) : this._transitionable.setValue(i3, o2);
- }
- }
- updateTransitions(e2) {
- this._transitioning = this._transitionable.transitioned(e2, this._transitioning);
- }
- hasTransition() {
- return this._transitioning.hasTransition();
- }
- recalculate(e2) {
- this.properties = this._transitioning.possiblyEvaluate(e2);
- }
- }
- function M(t2, i3, o2, r2) {
- const n2 = e.smoothstep(45, 65, o2), [a2, s2] = S(t2, r2), l2 = e.length(i3);
- let c2 = 1 - Math.min(1, Math.exp((l2 - a2) / (s2 - a2) * -6));
- return c2 *= c2 * c2, c2 = Math.min(1, 1.00747 * c2), c2 * n2 * t2.alpha;
- }
- function S(e2, t2) {
- const i3 = 0.5 / Math.tan(0.5 * t2);
- return [e2.range[0] + i3, e2.range[1] + i3];
- }
- 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";
- class P extends e.Evented {
- constructor(t2, i3) {
- super(), this._transitionable = new e.Transitionable(z), this.set(t2), this._transitioning = this._transitionable.untransitioned(), this._transform = i3;
- }
- get state() {
- return { range: this.properties.get("range"), horizonBlend: this.properties.get("horizon-blend"), alpha: this.properties.get("color").a };
- }
- get() {
- return this._transitionable.serialize();
- }
- set(t2, i3 = {}) {
- if (!this._validate(e.validateFog, t2, i3))
- for (const i4 in t2) {
- const o2 = t2[i4];
- e.endsWith(i4, D) ? this._transitionable.setTransition(i4.slice(0, -D.length), o2) : this._transitionable.setValue(i4, o2);
- }
- }
- getOpacity(t2) {
- if (!this._transform.projection.supportsFog)
- return 0;
- const i3 = this.properties && this.properties.get("color") || 1;
- return e.smoothstep(45, 65, t2) * i3.a;
- }
- getOpacityAtLatLng(t2, i3) {
- return this._transform.projection.supportsFog ? function(t3, i4, o2) {
- const r2 = e.MercatorCoordinate.fromLngLat(i4), n2 = o2.elevation ? o2.elevation.getAtPointOrZero(r2) : 0, a2 = [r2.x, r2.y, n2];
- return e.transformMat4(a2, a2, o2.mercatorFogMatrix), M(t3, a2, o2.pitch, o2._fov);
- }(this.state, t2, i3) : 0;
- }
- getFovAdjustedRange(e2) {
- return this._transform.projection.supportsFog ? S(this.state, e2) : [0, 1];
- }
- updateTransitions(e2) {
- this._transitioning = this._transitionable.transitioned(e2, this._transitioning);
- }
- hasTransition() {
- return this._transitioning.hasTransition();
- }
- recalculate(e2) {
- this.properties = this._transitioning.possiblyEvaluate(e2);
- }
- _validate(t2, i3, o2) {
- return (!o2 || false !== o2.validate) && e.emitValidationErrors(this, t2.call(e.validateStyle, e.extend({ value: i3, style: { glyphs: true, sprite: true }, styleSpec: e.spec })));
- }
- }
- class A {
- constructor(t2, i3) {
- this.workerPool = t2, this.actors = [], this.currentActor = 0, this.id = e.uniqueId();
- const o2 = this.workerPool.acquire(this.id);
- for (let e2 = 0; e2 < o2.length; e2++) {
- const t3 = new A.Actor(o2[e2], i3, this.id);
- t3.name = `Worker ${e2}`, this.actors.push(t3);
- }
- this.ready = false, this.broadcast("checkIfReady", null, () => {
- this.ready = true;
- });
- }
- broadcast(t2, i3, o2) {
- e.asyncAll(this.actors, (e2, o3) => {
- e2.send(t2, i3, o3);
- }, o2 = o2 || function() {
- });
- }
- getActor() {
- return this.currentActor = (this.currentActor + 1) % this.actors.length, this.actors[this.currentActor];
- }
- remove() {
- this.actors.forEach((e2) => {
- e2.remove();
- }), this.actors = [], this.workerPool.release(this.id);
- }
- }
- function L(t2, i3, o2) {
- return i3 * (e.EXTENT / (t2.tileSize * Math.pow(2, o2 - t2.tileID.overscaledZ)));
- }
- A.Actor = e.Actor;
- class R {
- constructor(e2, t2, i3, o2) {
- 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);
- }
- static createFromScreenPoints(t2, i3) {
- let o2, r2;
- if (t2 instanceof e.pointGeometry || "number" == typeof t2[0]) {
- const n2 = e.pointGeometry.convert(t2);
- o2 = [e.pointGeometry.convert(t2)], r2 = i3.isPointAboveHorizon(n2);
- } else {
- const n2 = e.pointGeometry.convert(t2[0]), a2 = e.pointGeometry.convert(t2[1]);
- o2 = [n2, a2], r2 = e.polygonizeBounds(n2, a2).every((e2) => i3.isPointAboveHorizon(e2));
- }
- return new R(o2, i3.getCameraPoint(), r2, i3);
- }
- isPointQuery() {
- return 1 === this.screenBounds.length;
- }
- bufferedScreenGeometry(t2) {
- return e.polygonizeBounds(this.screenBounds[0], 1 === this.screenBounds.length ? this.screenBounds[0] : this.screenBounds[1], t2);
- }
- bufferedCameraGeometry(t2) {
- 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);
- 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);
- }
- containsTile(t2, i3, o2) {
- 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) => {
- const i4 = e.sub(t3, t3, h2);
- return e.normalize(i4, i4), new e.Ray(h2, i4);
- }), u2 = L(t2, 1, i3.zoom);
- if (e.polygonIntersectsBox(a2, 0, 0, e.EXTENT, e.EXTENT))
- 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 };
- var d2;
- }
- _bufferedScreenMercator(e2, t2) {
- const i3 = k(e2);
- if (this._screenRaycastCache[i3])
- return this._screenRaycastCache[i3];
- {
- const o2 = this.bufferedScreenGeometry(e2).map((e3) => t2.pointCoordinate3D(e3));
- return this._screenRaycastCache[i3] = o2, o2;
- }
- }
- _bufferedCameraMercator(e2, t2) {
- const i3 = k(e2);
- if (this._cameraRaycastCache[i3])
- return this._cameraRaycastCache[i3];
- {
- const o2 = this.bufferedCameraGeometry(e2).map((e3) => t2.pointCoordinate3D(e3));
- return this._cameraRaycastCache[i3] = o2, o2;
- }
- }
- }
- function k(e2) {
- return 100 * e2 | 0;
- }
- function O(t2, i3, o2) {
- const r2 = function(r3, n2) {
- if (r3)
- return o2(r3);
- if (n2) {
- const r4 = e.pick(e.extend(n2, t2), ["tiles", "minzoom", "maxzoom", "attribution", "mapbox_logo", "bounds", "scheme", "tileSize", "encoding"]);
- 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);
- }
- };
- return t2.url ? e.getJSON(i3.transformRequest(i3.normalizeSourceURL(t2.url), e.ResourceType.Source), r2) : e.exported.frame(() => r2(null, t2));
- }
- class B {
- constructor(t2, i3, o2) {
- this.bounds = e.LngLatBounds.convert(this.validateBounds(t2)), this.minzoom = i3 || 0, this.maxzoom = o2 || 24;
- }
- validateBounds(e2) {
- 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];
- }
- contains(t2) {
- 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);
- return t2.x >= o2 && t2.x < n2 && t2.y >= r2 && t2.y < a2;
- }
- }
- class F {
- constructor(e2, t2, i3) {
- this.context = e2;
- const o2 = e2.gl;
- 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();
- }
- bind() {
- this.context.bindElementBuffer.set(this.buffer);
- }
- updateData(e2) {
- const t2 = this.context.gl;
- this.context.unbindVAO(), this.bind(), t2.bufferSubData(t2.ELEMENT_ARRAY_BUFFER, 0, e2.arrayBuffer);
- }
- destroy() {
- this.buffer && (this.context.gl.deleteBuffer(this.buffer), delete this.buffer);
- }
- }
- const U = { Int8: "BYTE", Uint8: "UNSIGNED_BYTE", Int16: "SHORT", Uint16: "UNSIGNED_SHORT", Int32: "INT", Uint32: "UNSIGNED_INT", Float32: "FLOAT" };
- class N {
- constructor(e2, t2, i3, o2) {
- this.length = t2.length, this.attributes = i3, this.itemSize = t2.bytesPerElement, this.dynamicDraw = o2, this.context = e2;
- const r2 = e2.gl;
- 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();
- }
- bind() {
- this.context.bindVertexBuffer.set(this.buffer);
- }
- updateData(e2) {
- const t2 = this.context.gl;
- this.bind(), t2.bufferSubData(t2.ARRAY_BUFFER, 0, e2.arrayBuffer);
- }
- enableAttributes(e2, t2) {
- for (let i3 = 0; i3 < this.attributes.length; i3++) {
- const o2 = t2.attributes[this.attributes[i3].name];
- void 0 !== o2 && e2.enableVertexAttribArray(o2);
- }
- }
- setVertexAttribPointers(e2, t2, i3) {
- for (let o2 = 0; o2 < this.attributes.length; o2++) {
- const r2 = this.attributes[o2], n2 = t2.attributes[r2.name];
- void 0 !== n2 && e2.vertexAttribPointer(n2, r2.components, e2[U[r2.type]], false, this.itemSize, r2.offset + this.itemSize * (i3 || 0));
- }
- }
- destroy() {
- this.buffer && (this.context.gl.deleteBuffer(this.buffer), delete this.buffer);
- }
- }
- class G {
- constructor(e2) {
- this.gl = e2.gl, this.default = this.getDefault(), this.current = this.default, this.dirty = false;
- }
- get() {
- return this.current;
- }
- set(e2) {
- }
- getDefault() {
- return this.default;
- }
- setDefault() {
- this.set(this.default);
- }
- }
- class j extends G {
- getDefault() {
- return e.Color.transparent;
- }
- set(e2) {
- const t2 = this.current;
- (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);
- }
- }
- class Z extends G {
- getDefault() {
- return 1;
- }
- set(e2) {
- (e2 !== this.current || this.dirty) && (this.gl.clearDepth(e2), this.current = e2, this.dirty = false);
- }
- }
- class V extends G {
- getDefault() {
- return 0;
- }
- set(e2) {
- (e2 !== this.current || this.dirty) && (this.gl.clearStencil(e2), this.current = e2, this.dirty = false);
- }
- }
- class W extends G {
- getDefault() {
- return [true, true, true, true];
- }
- set(e2) {
- const t2 = this.current;
- (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);
- }
- }
- class q extends G {
- getDefault() {
- return true;
- }
- set(e2) {
- (e2 !== this.current || this.dirty) && (this.gl.depthMask(e2), this.current = e2, this.dirty = false);
- }
- }
- class X extends G {
- getDefault() {
- return 255;
- }
- set(e2) {
- (e2 !== this.current || this.dirty) && (this.gl.stencilMask(e2), this.current = e2, this.dirty = false);
- }
- }
- class $ extends G {
- getDefault() {
- return { func: this.gl.ALWAYS, ref: 0, mask: 255 };
- }
- set(e2) {
- const t2 = this.current;
- (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);
- }
- }
- class H extends G {
- getDefault() {
- const e2 = this.gl;
- return [e2.KEEP, e2.KEEP, e2.KEEP];
- }
- set(e2) {
- const t2 = this.current;
- (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);
- }
- }
- class K extends G {
- getDefault() {
- return false;
- }
- set(e2) {
- if (e2 === this.current && !this.dirty)
- return;
- const t2 = this.gl;
- e2 ? t2.enable(t2.STENCIL_TEST) : t2.disable(t2.STENCIL_TEST), this.current = e2, this.dirty = false;
- }
- }
- class Y extends G {
- getDefault() {
- return [0, 1];
- }
- set(e2) {
- const t2 = this.current;
- (e2[0] !== t2[0] || e2[1] !== t2[1] || this.dirty) && (this.gl.depthRange(e2[0], e2[1]), this.current = e2, this.dirty = false);
- }
- }
- class J extends G {
- getDefault() {
- return false;
- }
- set(e2) {
- if (e2 === this.current && !this.dirty)
- return;
- const t2 = this.gl;
- e2 ? t2.enable(t2.DEPTH_TEST) : t2.disable(t2.DEPTH_TEST), this.current = e2, this.dirty = false;
- }
- }
- class Q extends G {
- getDefault() {
- return this.gl.LESS;
- }
- set(e2) {
- (e2 !== this.current || this.dirty) && (this.gl.depthFunc(e2), this.current = e2, this.dirty = false);
- }
- }
- class ee extends G {
- getDefault() {
- return false;
- }
- set(e2) {
- if (e2 === this.current && !this.dirty)
- return;
- const t2 = this.gl;
- e2 ? t2.enable(t2.BLEND) : t2.disable(t2.BLEND), this.current = e2, this.dirty = false;
- }
- }
- class te extends G {
- getDefault() {
- const e2 = this.gl;
- return [e2.ONE, e2.ZERO];
- }
- set(e2) {
- const t2 = this.current;
- (e2[0] !== t2[0] || e2[1] !== t2[1] || this.dirty) && (this.gl.blendFunc(e2[0], e2[1]), this.current = e2, this.dirty = false);
- }
- }
- class ie extends G {
- getDefault() {
- return e.Color.transparent;
- }
- set(e2) {
- const t2 = this.current;
- (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);
- }
- }
- class oe extends G {
- getDefault() {
- return this.gl.FUNC_ADD;
- }
- set(e2) {
- (e2 !== this.current || this.dirty) && (this.gl.blendEquation(e2), this.current = e2, this.dirty = false);
- }
- }
- class re extends G {
- getDefault() {
- return false;
- }
- set(e2) {
- if (e2 === this.current && !this.dirty)
- return;
- const t2 = this.gl;
- e2 ? t2.enable(t2.CULL_FACE) : t2.disable(t2.CULL_FACE), this.current = e2, this.dirty = false;
- }
- }
- class ne extends G {
- getDefault() {
- return this.gl.BACK;
- }
- set(e2) {
- (e2 !== this.current || this.dirty) && (this.gl.cullFace(e2), this.current = e2, this.dirty = false);
- }
- }
- class ae extends G {
- getDefault() {
- return this.gl.CCW;
- }
- set(e2) {
- (e2 !== this.current || this.dirty) && (this.gl.frontFace(e2), this.current = e2, this.dirty = false);
- }
- }
- class se extends G {
- getDefault() {
- return null;
- }
- set(e2) {
- (e2 !== this.current || this.dirty) && (this.gl.useProgram(e2), this.current = e2, this.dirty = false);
- }
- }
- class le extends G {
- getDefault() {
- return this.gl.TEXTURE0;
- }
- set(e2) {
- (e2 !== this.current || this.dirty) && (this.gl.activeTexture(e2), this.current = e2, this.dirty = false);
- }
- }
- class ce extends G {
- getDefault() {
- const e2 = this.gl;
- return [0, 0, e2.drawingBufferWidth, e2.drawingBufferHeight];
- }
- set(e2) {
- const t2 = this.current;
- (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);
- }
- }
- class he extends G {
- getDefault() {
- return null;
- }
- set(e2) {
- if (e2 === this.current && !this.dirty)
- return;
- const t2 = this.gl;
- t2.bindFramebuffer(t2.FRAMEBUFFER, e2), this.current = e2, this.dirty = false;
- }
- }
- class _e extends G {
- getDefault() {
- return null;
- }
- set(e2) {
- if (e2 === this.current && !this.dirty)
- return;
- const t2 = this.gl;
- t2.bindRenderbuffer(t2.RENDERBUFFER, e2), this.current = e2, this.dirty = false;
- }
- }
- class ue extends G {
- getDefault() {
- return null;
- }
- set(e2) {
- if (e2 === this.current && !this.dirty)
- return;
- const t2 = this.gl;
- t2.bindTexture(t2.TEXTURE_2D, e2), this.current = e2, this.dirty = false;
- }
- }
- class de extends G {
- getDefault() {
- return null;
- }
- set(e2) {
- if (e2 === this.current && !this.dirty)
- return;
- const t2 = this.gl;
- t2.bindBuffer(t2.ARRAY_BUFFER, e2), this.current = e2, this.dirty = false;
- }
- }
- class pe extends G {
- getDefault() {
- return null;
- }
- set(e2) {
- const t2 = this.gl;
- t2.bindBuffer(t2.ELEMENT_ARRAY_BUFFER, e2), this.current = e2, this.dirty = false;
- }
- }
- class me extends G {
- constructor(e2) {
- super(e2), this.vao = e2.extVertexArrayObject;
- }
- getDefault() {
- return null;
- }
- set(e2) {
- this.vao && (e2 !== this.current || this.dirty) && (this.vao.bindVertexArrayOES(e2), this.current = e2, this.dirty = false);
- }
- }
- class fe extends G {
- getDefault() {
- return 4;
- }
- set(e2) {
- if (e2 === this.current && !this.dirty)
- return;
- const t2 = this.gl;
- t2.pixelStorei(t2.UNPACK_ALIGNMENT, e2), this.current = e2, this.dirty = false;
- }
- }
- class ge extends G {
- getDefault() {
- return false;
- }
- set(e2) {
- if (e2 === this.current && !this.dirty)
- return;
- const t2 = this.gl;
- t2.pixelStorei(t2.UNPACK_PREMULTIPLY_ALPHA_WEBGL, e2), this.current = e2, this.dirty = false;
- }
- }
- class ve extends G {
- getDefault() {
- return false;
- }
- set(e2) {
- if (e2 === this.current && !this.dirty)
- return;
- const t2 = this.gl;
- t2.pixelStorei(t2.UNPACK_FLIP_Y_WEBGL, e2), this.current = e2, this.dirty = false;
- }
- }
- class xe extends G {
- constructor(e2, t2) {
- super(e2), this.context = e2, this.parent = t2;
- }
- getDefault() {
- return null;
- }
- }
- class ye extends xe {
- setDirty() {
- this.dirty = true;
- }
- set(e2) {
- if (e2 === this.current && !this.dirty)
- return;
- this.context.bindFramebuffer.set(this.parent);
- const t2 = this.gl;
- t2.framebufferTexture2D(t2.FRAMEBUFFER, t2.COLOR_ATTACHMENT0, t2.TEXTURE_2D, e2, 0), this.current = e2, this.dirty = false;
- }
- }
- class be extends xe {
- attachment() {
- return this.gl.DEPTH_ATTACHMENT;
- }
- set(e2) {
- if (e2 === this.current && !this.dirty)
- return;
- this.context.bindFramebuffer.set(this.parent);
- const t2 = this.gl;
- t2.framebufferRenderbuffer(t2.FRAMEBUFFER, this.attachment(), t2.RENDERBUFFER, e2), this.current = e2, this.dirty = false;
- }
- }
- class we extends be {
- attachment() {
- return this.gl.DEPTH_STENCIL_ATTACHMENT;
- }
- }
- class Te {
- constructor(e2, t2, i3, o2) {
- this.context = e2, this.width = t2, this.height = i3;
- const r2 = this.framebuffer = e2.gl.createFramebuffer();
- this.colorAttachment = new ye(e2, r2), o2 && (this.depthAttachment = new be(e2, r2));
- }
- destroy() {
- const e2 = this.context.gl, t2 = this.colorAttachment.get();
- if (t2 && e2.deleteTexture(t2), this.depthAttachment) {
- const t3 = this.depthAttachment.get();
- t3 && e2.deleteRenderbuffer(t3);
- }
- e2.deleteFramebuffer(this.framebuffer);
- }
- }
- class Ee {
- constructor(e2) {
- 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);
- }
- setDefault() {
- 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();
- }
- setDirty() {
- 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;
- }
- createIndexBuffer(e2, t2) {
- return new F(this, e2, t2);
- }
- createVertexBuffer(e2, t2, i3) {
- return new N(this, e2, t2, i3);
- }
- createRenderbuffer(e2, t2, i3) {
- const o2 = this.gl, r2 = o2.createRenderbuffer();
- return this.bindRenderbuffer.set(r2), o2.renderbufferStorage(o2.RENDERBUFFER, e2, t2, i3), this.bindRenderbuffer.set(null), r2;
- }
- createFramebuffer(e2, t2, i3) {
- return new Te(this, e2, t2, i3);
- }
- clear({ color: e2, depth: t2, stencil: i3 }) {
- const o2 = this.gl;
- let r2 = 0;
- 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);
- }
- setCullFace(e2) {
- false === e2.enable ? this.cullFace.set(false) : (this.cullFace.set(true), this.cullFaceSide.set(e2.mode), this.frontFace.set(e2.frontFace));
- }
- setDepthMode(e2) {
- 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);
- }
- setStencilMode(e2) {
- 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);
- }
- setColorMode(t2) {
- 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);
- }
- unbindVAO() {
- this.extVertexArrayObject && this.bindVertexArrayOES.set(null);
- }
- }
- class Ce extends e.Evented {
- constructor(t2, i3, o2, r2) {
- 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"]));
- }
- load() {
- this._loaded = false, this.fire(new e.Event("dataloading", { dataType: "source" })), this._tileJSONRequest = O(this._options, this.map._requestManager, (t2, i3) => {
- 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" })));
- });
- }
- loaded() {
- return this._loaded;
- }
- onAdd(e2) {
- this.map = e2, this.load();
- }
- onRemove() {
- this._tileJSONRequest && (this._tileJSONRequest.cancel(), this._tileJSONRequest = null);
- }
- serialize() {
- return e.extend({}, this._options);
- }
- hasTile(e2) {
- return !this.tileBounds || this.tileBounds.contains(e2.canonical);
- }
- loadTile(t2, i3) {
- const o2 = e.exported.devicePixelRatio >= 2, r2 = this.map._requestManager.normalizeTileURL(t2.tileID.canonical.url(this.tiles, this.scheme), o2, this.tileSize);
- 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)));
- }
- static loadTileData(e2, t2, i3) {
- e2.setTexture(t2, i3);
- }
- static unloadTileData(e2, t2) {
- e2.texture && t2.saveTileTexture(e2.texture);
- }
- abortTile(e2, t2) {
- e2.request && (e2.request.cancel(), delete e2.request), t2();
- }
- unloadTile(e2, t2) {
- e2.texture && this.map.painter.saveTileTexture(e2.texture), t2();
- }
- hasTransition() {
- return false;
- }
- }
- let Ie;
- function Me(t2, i3, o2, r2, n2, a2, s2, l2) {
- 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));
- return e.multiply(c2, [u2, 0, 0, 0, d2, 0, 0, 0, p2], c2);
- }
- class Se extends e.Evented {
- constructor(e2, t2, i3, o2) {
- 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;
- }
- load(t2) {
- 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) => {
- if (this._loaded = true, i3)
- this.fire(new e.ErrorEvent(i3));
- else if (o2) {
- const { HTMLImageElement: i4 } = e.window;
- 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();
- }
- });
- }
- loaded() {
- return this._loaded;
- }
- updateImage(e2) {
- return this.image && e2.url ? (this.options.url = e2.url, this.load(e2.coordinates), this) : this;
- }
- _finishLoading() {
- this.map && (this.setCoordinates(this.coordinates), this.fire(new e.Event("data", { dataType: "source", sourceDataType: "metadata" })));
- }
- onAdd(e2) {
- this.map = e2, this.load();
- }
- onRemove() {
- this.texture && this.texture.destroy();
- }
- setCoordinates(t2) {
- this.coordinates = t2, this._boundsArray = void 0;
- const i3 = t2.map(e.MercatorCoordinate.fromLngLat);
- return this.tileID = function(t3) {
- let i4 = 1 / 0, o2 = 1 / 0, r2 = -1 / 0, n2 = -1 / 0;
- for (const e2 of t3)
- i4 = Math.min(i4, e2.x), o2 = Math.min(o2, e2.y), r2 = Math.max(r2, e2.x), n2 = Math.max(n2, e2.y);
- const a2 = Math.max(r2 - i4, n2 - o2), s2 = Math.max(0, Math.floor(-Math.log(a2) / Math.LN2)), l2 = Math.pow(2, s2);
- return new e.CanonicalTileID(s2, Math.floor((i4 + r2) / 2 * l2), Math.floor((o2 + n2) / 2 * l2));
- }(i3), this.minzoom = this.maxzoom = this.tileID.z, this.fire(new e.Event("data", { dataType: "source", sourceDataType: "content" })), this;
- }
- _clear() {
- this._boundsArray = void 0;
- }
- _prepareData(t2) {
- for (const e2 in this.tiles) {
- const t3 = this.tiles[e2];
- "loaded" !== t3.state && (t3.state = "loaded", t3.texture = this.texture);
- }
- if (this._boundsArray)
- return;
- const i3 = e.tileTransform(this.tileID, this.map.transform.projection), [o2, r2, n2, a2] = this.coordinates.map((t3) => {
- const o3 = i3.projection.project(t3[0], t3[1]);
- return e.getTilePoint(i3, o3)._round();
- });
- this.perspectiveTransform = function(t3, i4, o3, r3, n3, a3, s3, l2, c2, h2) {
- const _2 = Me(0, 0, t3, 0, 0, i4, t3, i4), u2 = Me(o3, r3, n3, a3, s3, l2, c2, h2);
- return e.multiply(u2, e.adjoint(_2, _2), u2), [u2[6] / u2[8] * t3 / e.EXTENT, u2[7] / u2[8] * i4 / e.EXTENT];
- }(this.width, this.height, o2.x, o2.y, r2.x, r2.y, a2.x, a2.y, n2.x, n2.y);
- const s2 = this._boundsArray = new e.StructArrayLayout4i8();
- 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);
- }
- prepare() {
- if (0 === Object.keys(this.tiles).length || !this.image)
- return;
- const t2 = this.map.painter.context, i3 = t2.gl;
- 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);
- }
- loadTile(e2, t2) {
- this.tileID && this.tileID.equals(e2.tileID.canonical) ? (this.tiles[String(e2.tileID.wrap)] = e2, e2.buckets = {}, t2(null)) : (e2.state = "errored", t2(null));
- }
- serialize() {
- return { type: "image", url: this.options.url, coordinates: this.coordinates };
- }
- hasTransition() {
- return false;
- }
- }
- const ze = { vector: class extends e.Evented {
- constructor(t2, i3, o2, r2) {
- 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)
- throw new Error("vector tile sources must have a tileSize of 512");
- this.setEventedParent(r2), this._tileWorkers = {}, this._deduped = new e.DedupedRequest();
- }
- load() {
- this._loaded = false, this.fire(new e.Event("dataloading", { dataType: "source" })), this._tileJSONRequest = O(this._options, this.map._requestManager, (t2, i3) => {
- 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" })));
- });
- }
- loaded() {
- return this._loaded;
- }
- hasTile(e2) {
- return !this.tileBounds || this.tileBounds.contains(e2.canonical);
- }
- onAdd(e2) {
- this.map = e2, this.load();
- }
- setSourceProperty(e2) {
- this._tileJSONRequest && this._tileJSONRequest.cancel(), e2();
- const t2 = this.map.style._getSourceCaches(this.id);
- for (const e3 of t2)
- e3.clearTiles();
- this.load();
- }
- setTiles(e2) {
- return this.setSourceProperty(() => {
- this._options.tiles = e2;
- }), this;
- }
- setUrl(e2) {
- return this.setSourceProperty(() => {
- this.url = e2, this._options.url = e2;
- }), this;
- }
- onRemove() {
- this._tileJSONRequest && (this._tileJSONRequest.cancel(), this._tileJSONRequest = null);
- }
- serialize() {
- return e.extend({}, this._options);
- }
- loadTile(t2, i3) {
- 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 };
- if (r2.request.collectResourceTiming = this._collectResourceTiming, t2.actor && "expired" !== t2.state)
- "loading" === t2.state ? t2.reloadCallback = i3 : t2.request = t2.actor.send("reloadTile", r2, n2.bind(this));
- else if (t2.actor = this._tileWorkers[o2] = this._tileWorkers[o2] || this.dispatcher.getActor(), this.dispatcher.ready)
- t2.request = t2.actor.send("loadTile", r2, n2.bind(this), void 0, true);
- else {
- const i4 = e.loadVectorTile.call({ deduped: this._deduped }, r2, (e2, i5) => {
- 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));
- }, true);
- t2.request = { cancel: i4 };
- }
- function n2(o3, r3) {
- 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)));
- }
- }
- abortTile(e2) {
- e2.request && (e2.request.cancel(), delete e2.request), e2.actor && e2.actor.send("abortTile", { uid: e2.uid, type: this.type, source: this.id });
- }
- unloadTile(e2) {
- e2.unloadVectorData(), e2.actor && e2.actor.send("removeTile", { uid: e2.uid, type: this.type, source: this.id });
- }
- hasTransition() {
- return false;
- }
- afterUpdate() {
- this._tileWorkers = {};
- }
- }, raster: Ce, "raster-dem": class extends Ce {
- constructor(t2, i3, o2, r2) {
- 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";
- }
- loadTile(t2, i3) {
- const o2 = this.map._requestManager.normalizeTileURL(t2.tileID.canonical.url(this.tiles, this.scheme), false, this.tileSize);
- function r2(e2, o3) {
- e2 && (t2.state = "errored", i3(e2)), o3 && (t2.dem = o3, t2.dem.onDeserialize(), t2.needsHillshadePrepare = true, t2.needsDEMTextureUpload = true, t2.state = "loaded", i3(null));
- }
- t2.request = e.getImage(this.map._requestManager.transformRequest(o2, e.ResourceType.Tile), function(o3, n2, a2, s2) {
- if (delete t2.request, t2.aborted)
- t2.state = "unloaded", i3(null);
- else if (o3)
- t2.state = "errored", i3(o3);
- else if (n2) {
- this.map._refreshExpiredTiles && t2.setExpiryData({ cacheControl: a2, expires: s2 });
- 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;
- o4 < 1 || t2.neighboringTiles || (t2.neighboringTiles = this._getNeighboringTiles(t2.tileID));
- 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 };
- t2.actor && "expired" !== t2.state || (t2.actor = this.dispatcher.getActor(), t2.actor.send("loadDEMTile", c2, r2.bind(this), void 0, true));
- }
- }.bind(this));
- }
- _getNeighboringTiles(t2) {
- 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 = {};
- 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;
- }
- unloadTile(e2) {
- 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";
- }
- }, geojson: class extends e.Evented {
- constructor(t2, i3, o2, r2) {
- 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;
- const n2 = e.EXTENT / this.tileSize;
- 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);
- }
- onAdd(e2) {
- this.map = e2, this.setData(this._data);
- }
- setData(e2) {
- return this._data = e2, this._updateWorkerData(), this;
- }
- getClusterExpansionZoom(e2, t2) {
- return this.actor.send("geojson.getClusterExpansionZoom", { clusterId: e2, source: this.id }, t2), this;
- }
- getClusterChildren(e2, t2) {
- return this.actor.send("geojson.getClusterChildren", { clusterId: e2, source: this.id }, t2), this;
- }
- getClusterLeaves(e2, t2, i3, o2) {
- return this.actor.send("geojson.getClusterLeaves", { source: this.id, clusterId: e2, limit: t2, offset: i3 }, o2), this;
- }
- _updateWorkerData() {
- if (this._pendingLoad)
- return void (this._coalesce = true);
- this.fire(new e.Event("dataloading", { dataType: "source" })), this._loaded = false;
- const t2 = e.extend({}, this.workerOptions), i3 = this._data;
- "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) => {
- if (this._loaded = true, this._pendingLoad = null, t3)
- this.fire(new e.ErrorEvent(t3));
- else {
- const t4 = { dataType: "source", sourceDataType: this._metadataFired ? "content" : "metadata" };
- 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;
- }
- this._coalesce && (this._updateWorkerData(), this._coalesce = false);
- });
- }
- loaded() {
- return this._loaded;
- }
- loadTile(t2, i3) {
- const o2 = t2.actor ? "reloadTile" : "loadTile";
- 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);
- }
- abortTile(e2) {
- e2.request && (e2.request.cancel(), delete e2.request), e2.aborted = true;
- }
- unloadTile(e2) {
- e2.unloadVectorData(), this.actor.send("removeTile", { uid: e2.uid, type: this.type, source: this.id });
- }
- onRemove() {
- this._pendingLoad && this._pendingLoad.cancel();
- }
- serialize() {
- return e.extend({}, this._options, { type: this.type, data: this._data });
- }
- hasTransition() {
- return false;
- }
- }, video: class extends Se {
- constructor(e2, t2, i3, o2) {
- super(e2, t2, i3, o2), this.roundZoom = true, this.type = "video", this.options = t2;
- }
- load() {
- this._loaded = false;
- const t2 = this.options;
- this.urls = [];
- for (const i3 of t2.urls)
- this.urls.push(this.map._requestManager.transformRequest(i3, e.ResourceType.Source).url);
- e.getVideo(this.urls, (t3, i3) => {
- 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", () => {
- this.map.triggerRepaint();
- }), this.map && this.video.play(), this._finishLoading());
- });
- }
- pause() {
- this.video && this.video.pause();
- }
- play() {
- this.video && this.video.play();
- }
- seek(t2) {
- if (this.video) {
- const i3 = this.video.seekable;
- 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;
- }
- }
- getVideo() {
- return this.video;
- }
- onAdd(e2) {
- this.map || (this.map = e2, this.load(), this.video && (this.video.play(), this.setCoordinates(this.coordinates)));
- }
- prepare() {
- if (0 === Object.keys(this.tiles).length || this.video.readyState < 2)
- return;
- const t2 = this.map.painter.context, i3 = t2.gl;
- 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);
- }
- serialize() {
- return { type: "video", urls: this.urls, coordinates: this.coordinates };
- }
- hasTransition() {
- return this.video && !this.video.paused;
- }
- }, image: Se, canvas: class extends Se {
- constructor(t2, i3, o2, r2) {
- 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;
- }
- load() {
- 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() {
- this._playing = true, this.map.triggerRepaint();
- }, this.pause = function() {
- this._playing && (this.prepare(), this._playing = false);
- }, this._finishLoading());
- }
- getCanvas() {
- return this.canvas;
- }
- onAdd(e2) {
- this.map = e2, this.load(), this.canvas && this.animate && this.play();
- }
- onRemove() {
- this.pause();
- }
- prepare() {
- let t2 = false;
- 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())
- return;
- if (0 === Object.keys(this.tiles).length)
- return;
- const i3 = this.map.painter.context;
- 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);
- }
- serialize() {
- return { type: "canvas", coordinates: this.coordinates };
- }
- hasTransition() {
- return this._playing;
- }
- _hasInvalidDimensions() {
- for (const e2 of [this.canvas.width, this.canvas.height])
- if (isNaN(e2) || e2 <= 0)
- return true;
- return false;
- }
- }, custom: class extends e.Evented {
- constructor(t2, i3, o2, r2) {
- 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"]));
- }
- serialize() {
- return e.pick(this, ["type", "scheme", "minzoom", "maxzoom", "tileSize", "attribution"]);
- }
- load() {
- this._loaded = true, this.fire(new e.Event("data", { dataType: "source", sourceDataType: "metadata" })), this.fire(new e.Event("data", { dataType: "source", sourceDataType: "content" }));
- }
- loaded() {
- return this._loaded;
- }
- onAdd(t2) {
- this._map = t2, this._loaded = false, this.fire(new e.Event("dataloading", { dataType: "source" })), this._implementation.onAdd && this._implementation.onAdd(t2), this.load();
- }
- onRemove(e2) {
- this._implementation.onRemove && this._implementation.onRemove(e2);
- }
- hasTile(e2) {
- if (this._implementation.hasTile) {
- const { x: t2, y: i3, z: o2 } = e2.canonical;
- return this._implementation.hasTile({ x: t2, y: i3, z: o2 });
- }
- return !this.tileBounds || this.tileBounds.contains(e2.canonical);
- }
- loadTile(t2, i3) {
- 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 });
- if (!s2)
- return this.loadTileData(t2, { width: this.tileSize, height: this.tileSize, data: null }), t2.state = "loaded", i3(null);
- s2.cancel = () => a2.abort(), t2.request = s2.then(function(o3) {
- return delete t2.request, t2.aborted ? (t2.state = "unloaded", i3(null)) : o3 ? function(t3) {
- return t3 instanceof e.window.ImageData || t3 instanceof e.window.ImageBitmap || t3 instanceof e.window.HTMLCanvasElement;
- }(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));
- }.bind(this)).catch((e2) => {
- 20 !== e2.code && (t2.state = "errored", i3(e2));
- });
- }
- loadTileData(e2, t2) {
- Ce.loadTileData(e2, t2, this._map.painter);
- }
- unloadTileData(e2) {
- Ce.unloadTileData(e2, this._map.painter);
- }
- prepareTile(e2) {
- if (!this._implementation.prepareTile)
- return null;
- const { x: t2, y: i3, z: o2 } = e2.tileID.canonical, r2 = this._implementation.prepareTile({ x: t2, y: i3, z: o2 });
- return r2 ? (this.loadTileData(e2, r2), e2.state = "loaded", r2) : null;
- }
- unloadTile(e2, t2) {
- if (this.unloadTileData(e2), this._implementation.unloadTile) {
- const { x: t3, y: i3, z: o2 } = e2.tileID.canonical;
- this._implementation.unloadTile({ x: t3, y: i3, z: o2 });
- }
- t2();
- }
- abortTile(e2, t2) {
- e2.request && e2.request.cancel && (e2.request.cancel(), delete e2.request), t2();
- }
- hasTransition() {
- return false;
- }
- _coveringTiles() {
- 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 }));
- }
- _update() {
- this.fire(new e.Event("data", { dataType: "source", sourceDataType: "content" }));
- }
- } }, De = function(t2, i3, o2, r2) {
- const n2 = new ze[i3.type](t2, i3, o2, r2);
- if (n2.id !== t2)
- throw new Error(`Expected Source id to be ${t2} instead of ${n2.id}`);
- return e.bindAll(["load", "abort", "unload", "serialize", "prepare"], n2), n2;
- };
- function Pe(t2, i3) {
- const o2 = e.identity([]);
- 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);
- }
- function Ae(e2, t2, i3, o2, r2, n2, a2, s2 = false) {
- const l2 = e2.tilesIn(o2, a2, s2);
- l2.sort(Re);
- const c2 = [];
- for (const o3 of l2)
- 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) });
- const h2 = function(e3) {
- const t3 = {}, i4 = {};
- for (const o3 of e3) {
- const e4 = o3.queryResults, r3 = o3.wrappedTileID, n3 = i4[r3] = i4[r3] || {};
- for (const i5 in e4) {
- const o4 = e4[i5], r4 = n3[i5] = n3[i5] || {}, a3 = t3[i5] = t3[i5] || [];
- for (const e5 of o4)
- r4[e5.featureIndex] || (r4[e5.featureIndex] = true, a3.push(e5));
- }
- }
- return t3;
- }(c2);
- for (const t3 in h2)
- h2[t3].forEach((t4) => {
- const i4 = t4.feature, o3 = i4.layer;
- 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) : {});
- });
- return h2;
- }
- function Le(e2, t2) {
- const i3 = e2.getRenderableIds().map((t3) => e2.getTileByID(t3)), o2 = [], r2 = {};
- for (let e3 = 0; e3 < i3.length; e3++) {
- const n2 = i3[e3], a2 = n2.tileID.canonical.key;
- r2[a2] || (r2[a2] = true, n2.querySourceFeatures(o2, t2));
- }
- return o2;
- }
- function Re(e2, t2) {
- const i3 = e2.tileID, o2 = t2.tileID;
- return i3.overscaledZ - o2.overscaledZ || i3.canonical.y - o2.canonical.y || i3.wrap - o2.wrap || i3.canonical.x - o2.canonical.x;
- }
- function ke() {
- return null != ln.workerClass ? new ln.workerClass() : new e.window.Worker(ln.workerUrl);
- }
- const Oe = "mapboxgl_preloaded_worker_pool";
- class Be {
- constructor() {
- this.active = {};
- }
- acquire(e2) {
- if (!this.workers)
- for (this.workers = []; this.workers.length < Be.workerCount; )
- this.workers.push(new ke());
- return this.active[e2] = true, this.workers.slice();
- }
- release(e2) {
- delete this.active[e2], 0 === this.numActive() && (this.workers.forEach((e3) => {
- e3.terminate();
- }), this.workers = null);
- }
- isPreloaded() {
- return !!this.active[Oe];
- }
- numActive() {
- return Object.keys(this.active).length;
- }
- }
- let Fe;
- function Ue() {
- return Fe || (Fe = new Be()), Fe;
- }
- function Ne(t2, i3) {
- const o2 = {};
- for (const e2 in t2)
- "ref" !== e2 && (o2[e2] = t2[e2]);
- return e.refProperties.forEach((e2) => {
- e2 in i3 && (o2[e2] = i3[e2]);
- }), o2;
- }
- function Ge(e2) {
- e2 = e2.slice();
- const t2 = /* @__PURE__ */ Object.create(null);
- for (let i3 = 0; i3 < e2.length; i3++)
- t2[e2[i3].id] = e2[i3];
- for (let i3 = 0; i3 < e2.length; i3++)
- "ref" in e2[i3] && (e2[i3] = Ne(e2[i3], t2[e2[i3].ref]));
- return e2;
- }
- Be.workerCount = 2;
- 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" };
- function Ze(e2, t2, i3) {
- i3.push({ command: je.addSource, args: [e2, t2[e2]] });
- }
- function Ve(e2, t2, i3) {
- t2.push({ command: je.removeSource, args: [e2] }), i3[e2] = true;
- }
- function We(e2, t2, i3, o2) {
- Ve(e2, i3, o2), Ze(e2, t2, i3);
- }
- function qe(e2, t2, i3) {
- let o2;
- for (o2 in e2[i3])
- if (e2[i3].hasOwnProperty(o2) && "data" !== o2 && !r(e2[i3][o2], t2[i3][o2]))
- return false;
- for (o2 in t2[i3])
- if (t2[i3].hasOwnProperty(o2) && "data" !== o2 && !r(e2[i3][o2], t2[i3][o2]))
- return false;
- return true;
- }
- function Xe(e2, t2, i3, o2, n2, a2) {
- let s2;
- for (s2 in t2 = t2 || {}, e2 = e2 || {})
- e2.hasOwnProperty(s2) && (r(e2[s2], t2[s2]) || i3.push({ command: a2, args: [o2, s2, t2[s2], n2] }));
- for (s2 in t2)
- t2.hasOwnProperty(s2) && !e2.hasOwnProperty(s2) && (r(e2[s2], t2[s2]) || i3.push({ command: a2, args: [o2, s2, t2[s2], n2] }));
- }
- function $e(e2) {
- return e2.id;
- }
- function He(e2, t2) {
- return e2[t2.id] = t2, e2;
- }
- class Ke {
- constructor(e2, t2) {
- this.reset(e2, t2);
- }
- reset(e2, t2) {
- this.points = e2 || [], this._distances = [0];
- for (let e3 = 1; e3 < this.points.length; e3++)
- this._distances[e3] = this._distances[e3 - 1] + this.points[e3].dist(this.points[e3 - 1]);
- 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;
- }
- lerp(t2) {
- if (1 === this.points.length)
- return this.points[0];
- t2 = e.clamp(t2, 0, 1);
- let i3 = 1, o2 = this._distances[i3];
- const r2 = t2 * this.paddedLength + this.padding;
- for (; o2 < r2 && i3 < this._distances.length; )
- o2 = this._distances[++i3];
- const n2 = i3 - 1, a2 = this._distances[n2], s2 = o2 - a2, l2 = s2 > 0 ? (r2 - a2) / s2 : 0;
- return this.points[n2].mult(1 - l2).add(this.points[i3].mult(l2));
- }
- }
- class Ye {
- constructor(e2, t2, i3) {
- const o2 = this.boxCells = [], r2 = this.circleCells = [];
- this.xCellCount = Math.ceil(e2 / i3), this.yCellCount = Math.ceil(t2 / i3);
- for (let e3 = 0; e3 < this.xCellCount * this.yCellCount; e3++)
- o2.push([]), r2.push([]);
- 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;
- }
- keysLength() {
- return this.boxKeys.length + this.circleKeys.length;
- }
- insert(e2, t2, i3, o2, r2) {
- 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);
- }
- insertCircle(e2, t2, i3, o2) {
- 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);
- }
- _insertBoxCell(e2, t2, i3, o2, r2, n2) {
- this.boxCells[r2].push(n2);
- }
- _insertCircleCell(e2, t2, i3, o2, r2, n2) {
- this.circleCells[r2].push(n2);
- }
- _query(e2, t2, i3, o2, r2, n2) {
- if (i3 < 0 || e2 > this.width || o2 < 0 || t2 > this.height)
- return !r2 && [];
- const a2 = [];
- if (e2 <= 0 && t2 <= 0 && this.width <= i3 && this.height <= o2) {
- if (r2)
- return true;
- for (let e3 = 0; e3 < this.boxKeys.length; e3++)
- 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] });
- for (let e3 = 0; e3 < this.circleKeys.length; e3++) {
- const t3 = this.circles[3 * e3], i4 = this.circles[3 * e3 + 1], o3 = this.circles[3 * e3 + 2];
- a2.push({ key: this.circleKeys[e3], x1: t3 - o3, y1: i4 - o3, x2: t3 + o3, y2: i4 + o3 });
- }
- return n2 ? a2.filter(n2) : a2;
- }
- return this._forEachCell(e2, t2, i3, o2, this._queryCell, a2, { hitTest: r2, seenUids: { box: {}, circle: {} } }, n2), r2 ? a2.length > 0 : a2;
- }
- _queryCircle(e2, t2, i3, o2, r2) {
- const n2 = e2 - i3, a2 = e2 + i3, s2 = t2 - i3, l2 = t2 + i3;
- if (a2 < 0 || n2 > this.width || l2 < 0 || s2 > this.height)
- return !o2 && [];
- const c2 = [];
- 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;
- }
- query(e2, t2, i3, o2, r2) {
- return this._query(e2, t2, i3, o2, false, r2);
- }
- hitTest(e2, t2, i3, o2, r2) {
- return this._query(e2, t2, i3, o2, true, r2);
- }
- hitTestCircle(e2, t2, i3, o2) {
- return this._queryCircle(e2, t2, i3, true, o2);
- }
- _queryCell(e2, t2, i3, o2, r2, n2, a2, s2) {
- const l2 = a2.seenUids, c2 = this.boxCells[r2];
- if (null !== c2) {
- const r3 = this.bboxes;
- for (const h3 of c2)
- if (!l2.box[h3]) {
- l2.box[h3] = true;
- const c3 = 4 * h3;
- if (e2 <= r3[c3 + 2] && t2 <= r3[c3 + 3] && i3 >= r3[c3 + 0] && o2 >= r3[c3 + 1] && (!s2 || s2(this.boxKeys[h3]))) {
- if (a2.hitTest)
- return n2.push(true), true;
- n2.push({ key: this.boxKeys[h3], x1: r3[c3], y1: r3[c3 + 1], x2: r3[c3 + 2], y2: r3[c3 + 3] });
- }
- }
- }
- const h2 = this.circleCells[r2];
- if (null !== h2) {
- const r3 = this.circles;
- for (const c3 of h2)
- if (!l2.circle[c3]) {
- l2.circle[c3] = true;
- const h3 = 3 * c3;
- if (this._circleAndRectCollide(r3[h3], r3[h3 + 1], r3[h3 + 2], e2, t2, i3, o2) && (!s2 || s2(this.circleKeys[c3]))) {
- if (a2.hitTest)
- return n2.push(true), true;
- {
- const e3 = r3[h3], t3 = r3[h3 + 1], i4 = r3[h3 + 2];
- n2.push({ key: this.circleKeys[c3], x1: e3 - i4, y1: t3 - i4, x2: e3 + i4, y2: t3 + i4 });
- }
- }
- }
- }
- }
- _queryCellCircle(e2, t2, i3, o2, r2, n2, a2, s2) {
- const l2 = a2.circle, c2 = a2.seenUids, h2 = this.boxCells[r2];
- if (null !== h2) {
- const e3 = this.bboxes;
- for (const t3 of h2)
- if (!c2.box[t3]) {
- c2.box[t3] = true;
- const i4 = 4 * t3;
- 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])))
- return n2.push(true), true;
- }
- }
- const _2 = this.circleCells[r2];
- if (null !== _2) {
- const e3 = this.circles;
- for (const t3 of _2)
- if (!c2.circle[t3]) {
- c2.circle[t3] = true;
- const i4 = 3 * t3;
- if (this._circlesCollide(e3[i4], e3[i4 + 1], e3[i4 + 2], l2.x, l2.y, l2.radius) && (!s2 || s2(this.circleKeys[t3])))
- return n2.push(true), true;
- }
- }
- }
- _forEachCell(e2, t2, i3, o2, r2, n2, a2, s2) {
- const l2 = this._convertToXCellCoord(e2), c2 = this._convertToYCellCoord(t2), h2 = this._convertToXCellCoord(i3), _2 = this._convertToYCellCoord(o2);
- for (let u2 = l2; u2 <= h2; u2++)
- for (let l3 = c2; l3 <= _2; l3++)
- if (r2.call(this, e2, t2, i3, o2, this.xCellCount * l3 + u2, n2, a2, s2))
- return;
- }
- _convertToXCellCoord(e2) {
- return Math.max(0, Math.min(this.xCellCount - 1, Math.floor(e2 * this.xScale)));
- }
- _convertToYCellCoord(e2) {
- return Math.max(0, Math.min(this.yCellCount - 1, Math.floor(e2 * this.yScale)));
- }
- _circlesCollide(e2, t2, i3, o2, r2, n2) {
- const a2 = o2 - e2, s2 = r2 - t2, l2 = i3 + n2;
- return l2 * l2 > a2 * a2 + s2 * s2;
- }
- _circleAndRectCollide(e2, t2, i3, o2, r2, n2, a2) {
- const s2 = (n2 - o2) / 2, l2 = Math.abs(e2 - (o2 + s2));
- if (l2 > s2 + i3)
- return false;
- const c2 = (a2 - r2) / 2, h2 = Math.abs(t2 - (r2 + c2));
- if (h2 > c2 + i3)
- return false;
- if (l2 <= s2 || h2 <= c2)
- return true;
- const _2 = l2 - s2, u2 = h2 - c2;
- return _2 * _2 + u2 * u2 <= i3 * i3;
- }
- }
- const Je = Math.tan(85 * Math.PI / 180);
- function Qe(t2, i3, o2, r2, n2, a2) {
- const s2 = e.create();
- if (o2) {
- if ("globe" === n2.projection.name)
- e.multiply$1(s2, s2, e.calculateGlobeLabelMatrix(n2, i3));
- else {
- const e2 = v([], a2);
- s2[0] = e2[0], s2[1] = e2[1], s2[4] = e2[2], s2[5] = e2[3];
- }
- r2 || e.rotateZ(s2, s2, n2.angle);
- } else
- e.multiply$1(s2, n2.labelPlaneMatrix, t2);
- return s2;
- }
- function et(t2, i3, o2, r2, n2, a2) {
- if (o2) {
- if ("globe" === n2.projection.name) {
- const s2 = Qe(t2, i3, o2, r2, n2, a2);
- return e.invert(s2, s2), e.multiply$1(s2, t2, s2), s2;
- }
- {
- const i4 = e.clone(t2), o3 = e.identity([]);
- 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;
- }
- }
- return n2.glCoordMatrix;
- }
- function tt(t2, i3, o2 = 0) {
- const r2 = [t2.x, t2.y, o2, 1];
- o2 ? e.transformMat4$1(r2, r2, i3) : pt(r2, r2, i3);
- const n2 = r2[3];
- return { point: new e.pointGeometry(r2[0] / n2, r2[1] / n2), signedDistanceFromCamera: n2 };
- }
- function it(t2, i3) {
- const o2 = [t2[0], t2[1], t2[2], 1];
- e.transformMat4$1(o2, o2, i3);
- const r2 = o2[3];
- return { point: new e.pointGeometry(o2[0] / r2, o2[1] / r2), signedDistanceFromCamera: r2 };
- }
- function ot(e2, t2) {
- return Math.min(0.5 + e2 / t2 * 0.5, 1.5);
- }
- function rt(e2, t2) {
- const i3 = e2[0] / e2[3], o2 = e2[1] / e2[3];
- return i3 >= -t2[0] && i3 <= t2[0] && o2 >= -t2[1] && o2 <= t2[1];
- }
- function nt(t2, i3, o2, r2, n2, a2, s2, l2, c2, h2) {
- 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;
- m2.clear();
- const f2 = t2.lineVertexArray, g2 = r2 ? t2.text.placedSymbolArray : t2.icon.placedSymbolArray, v2 = o2.transform.width / o2.transform.height;
- let x2 = false;
- for (let r3 = 0; r3 < g2.length; r3++) {
- const y2 = g2.get(r3);
- 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) {
- dt(y2.numGlyphs, m2);
- continue;
- }
- x2 = false;
- 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];
- if (e.transformMat4$1(C2, C2, i3), !rt(C2, p2)) {
- dt(y2.numGlyphs, m2);
- continue;
- }
- 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]);
- if (z2.signedDistanceFromCamera <= 0) {
- dt(y2.numGlyphs, m2);
- continue;
- }
- let D2 = {};
- 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);
- 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);
- }
- r2 ? t2.text.dynamicLayoutVertexBuffer.updateData(m2) : t2.icon.dynamicLayoutVertexBuffer.updateData(m2);
- }
- function at(e2, t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2, d2, p2) {
- 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);
- if (!y2)
- return null;
- const b2 = _t(e2 * x2, i3, o2, r2, n2, a2, s2.segment, f2, g2, l2, c2, h2, _2, u2, true, d2, p2);
- return b2 ? { first: y2, last: b2 } : null;
- }
- function st(t2, i3, o2, r2) {
- 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) {
- const o3 = (t3.x - e2.x) * i4;
- return 0 === o3 || Math.abs((t3.y - e2.y) / o3) > Je;
- }(i3, o2, r2) ? 1 === t2.flipState ? { needsFlipping: true } : null : i3.x > o2.x ? { needsFlipping: true } : null;
- }
- function lt(t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2, d2, p2, m2, f2, g2) {
- const v2 = i3 / 24, x2 = t2.lineOffsetX * v2, y2 = t2.lineOffsetY * v2;
- let b2;
- if (t2.numGlyphs > 1) {
- 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);
- if (!h3)
- return { notEnoughRoom: true };
- const w2 = tt(h3.first.point, s2).point, T2 = tt(h3.last.point, s2).point;
- if (r2 && !o2) {
- const e3 = st(t2, w2, T2, p2);
- if (t2.flipState = e3 && e3.needsFlipping ? 1 : 2, e3)
- return e3;
- }
- b2 = [h3.first];
- for (let r3 = t2.glyphStartIndex + 1; r3 < e2 - 1; r3++)
- b2.push(_t(v2 * l2.getoffsetX(r3), x2, y2, o2, _2, u2, t2.segment, i4, n3, c2, a2, d2, m2, false, false, f2, g2));
- b2.push(h3.last);
- } else {
- if (r2 && !o2) {
- 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);
- if (t2.flipState = s3 && s3.needsFlipping ? 1 : 2, s3)
- return s3;
- }
- 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);
- if (!i4)
- return { notEnoughRoom: true };
- b2 = [i4];
- }
- for (const t3 of b2)
- e.addDynamicAttributes(h2, t3.point, t3.angle);
- return {};
- }
- function ct(t2, i3, o2, r2, n2) {
- const a2 = r2.projectTilePoint(t2.x, t2.y, i3);
- if (!n2)
- return tt(a2, o2, a2.z);
- const s2 = n2(t2);
- return tt(new e.pointGeometry(a2.x + s2[0], a2.y + s2[1]), o2, a2.z + s2[2]);
- }
- function ht(e2, t2, i3, o2, r2, n2, a2, s2) {
- const l2 = ct(e2.add(e2.sub(t2)._unit()), s2, r2, a2, n2).point, c2 = i3.sub(l2);
- return i3.add(c2._mult(o2 / c2.mag()));
- }
- function _t(t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2, d2, p2, m2, f2, g2) {
- const v2 = r2 ? t2 - i3 : t2 + i3;
- let x2 = v2 > 0 ? 1 : -1, y2 = 0;
- r2 && (x2 *= -1, y2 = Math.PI), x2 < 0 && (y2 += Math.PI);
- let b2 = x2 > 0 ? l2 + s2 : l2 + s2 + 1, w2 = n2, T2 = n2, E2 = 0, C2 = 0;
- const I2 = Math.abs(v2), M2 = [], S2 = [];
- let z2 = a2;
- const D2 = () => {
- const t3 = b2 - x2;
- return 0 === E2 ? a2 : new e.pointGeometry(h2.getx(t3), h2.gety(t3));
- }, P2 = () => ht(D2(), z2, T2, I2 - E2 + 1, _2, d2, f2, g2.canonical);
- for (; E2 + C2 <= I2; ) {
- if (b2 += x2, b2 < l2 || b2 >= c2)
- return null;
- if (T2 = w2, M2.push(w2), p2 && S2.push(z2 || D2()), w2 = u2[b2], void 0 === w2) {
- z2 = new e.pointGeometry(h2.getx(b2), h2.gety(b2));
- const t3 = ct(z2, g2.canonical, _2, f2, d2);
- w2 = t3.signedDistanceFromCamera > 0 ? u2[b2] = t3.point : P2();
- } else
- z2 = null;
- E2 += C2, C2 = T2.dist(w2);
- }
- 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));
- const A2 = (I2 - E2) / C2, L2 = w2.sub(T2), R2 = L2.mult(A2)._add(T2);
- o2 && R2._add(L2._unit()._perp()._mult(o2 * x2));
- const k2 = y2 + Math.atan2(w2.y - T2.y, w2.x - T2.x);
- return M2.push(R2), p2 && (z2 = z2 || new e.pointGeometry(h2.getx(b2), h2.gety(b2)), S2.push(function(t3, i4, o3) {
- const r3 = 1 - o3;
- return new e.pointGeometry(t3.x * r3 + i4.x * o3, t3.y * r3 + i4.y * o3);
- }(S2.length > 0 ? S2[S2.length - 1] : z2, z2, A2))), { point: R2, angle: k2, path: M2, tilePath: S2 };
- }
- const ut = new Float32Array([-1 / 0, -1 / 0, 0, -1 / 0, -1 / 0, 0, -1 / 0, -1 / 0, 0, -1 / 0, -1 / 0, 0]);
- function dt(e2, t2) {
- for (let i3 = 0; i3 < e2; i3++) {
- const e3 = t2.length;
- t2.resize(e3 + 4), t2.float32.set(ut, 3 * e3);
- }
- }
- function pt(e2, t2, i3) {
- const o2 = t2[0], r2 = t2[1];
- 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;
- }
- const mt = 100;
- class ft {
- constructor(e2, t2, i3 = new Ye(e2.width + 200, e2.height + 200, 25), o2 = new Ye(e2.width + 200, e2.height + 200, 25)) {
- 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;
- }
- placeCollisionBox(e2, t2, i3, o2, r2, n2, a2) {
- let s2 = t2.projectedAnchorX, l2 = t2.projectedAnchorY, c2 = t2.projectedAnchorZ;
- const h2 = t2.elevation, _2 = t2.tileID;
- if (h2 && _2) {
- 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;
- s2 += e3[0] * h2 * i4, l2 += e3[1] * h2 * i4, c2 += e3[2] * h2 * i4;
- }
- 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;
- 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 };
- }
- placeCollisionCircles(t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2, d2, p2) {
- 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;
- let M2 = false, S2 = false, z2 = true;
- if (I2 && !w2.occluded) {
- 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;
- let h3 = [];
- for (let e2 = a3.path.length - 1; e2 >= 1; e2--)
- h3.push(a3.path[e2]);
- for (let e2 = 1; e2 < s3.path.length; e2++)
- h3.push(s3.path[e2]);
- const p3 = 2.5 * i4;
- if (l2) {
- const e2 = h3.map(f2 ? (e3, t3) => {
- const i5 = g2(t3 < a3.path.length - 1 ? a3.tilePath[a3.path.length - 1 - t3] : s3.tilePath[t3 - a3.path.length + 2]);
- return tt(e3, l2, i5[2]);
- } : (e3) => tt(e3, l2));
- h3 = e2.some((e3) => e3.signedDistanceFromCamera <= 0) ? [] : e2.map((e3) => e3.point);
- }
- let v3 = [];
- if (h3.length > 0) {
- const t3 = h3[0].clone(), i5 = h3[0].clone();
- for (let e2 = 1; e2 < h3.length; e2++)
- 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);
- 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);
- }
- for (const e2 of v3) {
- n3.reset(e2, 0.25 * i4);
- let o4 = 0;
- o4 = n3.length <= 0.5 * i4 ? 1 : Math.ceil(n3.paddedLength / p3) + 1;
- for (let e3 = 0; e3 < o4; e3++) {
- const r4 = e3 / Math.max(o4 - 1, 1), a4 = n3.lerp(r4), s4 = a4.x + mt, l3 = a4.y + mt;
- m2.push(s4, l3, i4, 0);
- const h4 = s4 - i4, u3 = l3 - i4, d3 = s4 + i4, p4 = l3 + i4;
- 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))
- return { circles: [], offscreen: false, collisionDetected: M2, occluded: false };
- }
- }
- }
- return { circles: !c2 && M2 || !S2 ? [] : m2, offscreen: z2, collisionDetected: M2, occluded: w2.occluded };
- }
- queryRenderedSymbols(t2) {
- if (0 === t2.length || 0 === this.grid.keysLength() && 0 === this.ignoredGrid.keysLength())
- return {};
- const i3 = [];
- let o2 = 1 / 0, r2 = 1 / 0, n2 = -1 / 0, a2 = -1 / 0;
- for (const s3 of t2) {
- const t3 = new e.pointGeometry(s3.x + mt, s3.y + mt);
- 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);
- }
- const s2 = this.grid.query(o2, r2, n2, a2).concat(this.ignoredGrid.query(o2, r2, n2, a2)), l2 = {}, c2 = {};
- for (const t3 of s2) {
- const o3 = t3.key;
- if (void 0 === l2[o3.bucketInstanceId] && (l2[o3.bucketInstanceId] = {}), l2[o3.bucketInstanceId][o3.featureIndex])
- continue;
- 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)];
- e.polygonIntersectsPolygon(i3, r3) && (l2[o3.bucketInstanceId][o3.featureIndex] = true, void 0 === c2[o3.bucketInstanceId] && (c2[o3.bucketInstanceId] = []), c2[o3.bucketInstanceId].push(o3.featureIndex));
- }
- return c2;
- }
- insertCollisionBox(e2, t2, i3, o2, r2) {
- (t2 ? this.ignoredGrid : this.grid).insert({ bucketInstanceId: i3, featureIndex: o2, collisionGroupID: r2 }, e2[0], e2[1], e2[2], e2[3]);
- }
- insertCollisionCircles(e2, t2, i3, o2, r2) {
- const n2 = t2 ? this.ignoredGrid : this.grid, a2 = { bucketInstanceId: i3, featureIndex: o2, collisionGroupID: r2 };
- for (let t3 = 0; t3 < e2.length; t3 += 4)
- n2.insertCircle(a2, e2[t3], e2[t3 + 1], e2[t3 + 2]);
- }
- projectAndGetPerspectiveRatio(t2, i3, o2, r2) {
- const n2 = [i3[0], i3[1], i3[2], 1];
- let a2 = false;
- return i3[2] || this.transform.pitch > 0 ? (e.transformMat4$1(n2, n2, t2), this.fogState && o2 && (a2 = function(t3, i4, o3, r3, n3, a3) {
- const s2 = a3.calculateFogTileMatrix(n3), l2 = [i4, o3, r3];
- return e.transformMat4(l2, l2, s2), M(t3, l2, a3.pitch, a3._fov);
- }(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 };
- }
- isOffscreen(e2, t2, i3, o2) {
- return i3 < mt || e2 >= this.screenRightBoundary || o2 < mt || t2 > this.screenBottomBoundary;
- }
- isInsideGrid(e2, t2, i3, o2) {
- return i3 >= 0 && e2 < this.gridRightBoundary && o2 >= 0 && t2 < this.gridBottomBoundary;
- }
- getViewportMatrix() {
- const t2 = e.identity([]);
- return e.translate(t2, t2, [-100, -100, 0]), t2;
- }
- }
- class gt {
- constructor(e2, t2, i3, o2) {
- this.opacity = e2 ? Math.max(0, Math.min(1, e2.opacity + (e2.placed ? t2 : -t2))) : o2 && i3 ? 1 : 0, this.placed = i3;
- }
- isHidden() {
- return 0 === this.opacity && !this.placed;
- }
- }
- class vt {
- constructor(e2, t2, i3, o2, r2, n2 = false) {
- 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;
- }
- isHidden() {
- return this.text.isHidden() && this.icon.isHidden();
- }
- }
- class xt {
- constructor(e2, t2, i3, o2 = false) {
- this.text = e2, this.icon = t2, this.skipFade = i3, this.clipped = o2;
- }
- }
- class yt {
- constructor() {
- this.invProjMatrix = e.create(), this.viewportMatrix = e.create(), this.circles = [];
- }
- }
- class bt {
- constructor(e2, t2, i3, o2, r2) {
- this.bucketInstanceId = e2, this.featureIndex = t2, this.sourceLayerIndex = i3, this.bucketIndex = o2, this.tileID = r2;
- }
- }
- class wt {
- constructor(e2) {
- this.crossSourceCollisions = e2, this.maxGroupID = 0, this.collisionGroups = {};
- }
- get(e2) {
- if (this.crossSourceCollisions)
- return { ID: 0, predicate: null };
- if (!this.collisionGroups[e2]) {
- const t2 = ++this.maxGroupID;
- this.collisionGroups[e2] = { ID: t2, predicate: (e3) => e3.collisionGroupID === t2 };
- }
- return this.collisionGroups[e2];
- }
- }
- function Tt(t2, i3, o2, r2, n2) {
- const { horizontalAlign: a2, verticalAlign: s2 } = e.getAnchorAlignment(t2), l2 = -(a2 - 0.5) * i3, c2 = -(s2 - 0.5) * o2, h2 = e.evaluateVariableOffset(t2, r2);
- return new e.pointGeometry(l2 + h2[0] * n2, c2 + h2[1] * n2);
- }
- function Et(t2, i3, o2, r2, n2) {
- const a2 = new e.pointGeometry(t2, i3);
- return o2 && a2._rotate(r2 ? n2 : -n2), a2;
- }
- class Ct {
- constructor(e2, t2, i3, o2, r2) {
- 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 = {};
- }
- getBucketParts(t2, i3, o2, r2) {
- const n2 = o2.getBucket(i3), a2 = o2.latestFeatureIndex;
- if (!n2 || !a2 || i3.id !== n2.layerIds[0])
- return;
- 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");
- i3.compileFilter();
- const m2 = i3.dynamicFilter(), f2 = i3.dynamicFilterNeedsFeature(), g2 = this.transform.calculatePixelsToTileUnitsMatrix(o2), v2 = Qe(u2, o2.tileID.canonical, d2, p2, this.transform, g2);
- let x2 = null;
- if (d2) {
- const t3 = et(u2, o2.tileID.canonical, d2, p2, this.transform, g2);
- x2 = e.multiply$1([], this.transform.labelPlaneMatrix, t3);
- }
- let y2 = null;
- 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);
- 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) };
- if (r2)
- for (const e2 of n2.sortKeyRanges) {
- const { sortKey: i4, symbolInstanceStart: o3, symbolInstanceEnd: r3 } = e2;
- t2.push({ sortKey: i4, symbolInstanceStart: o3, symbolInstanceEnd: r3, parameters: b2 });
- }
- else
- t2.push({ symbolInstanceStart: 0, symbolInstanceEnd: n2.symbolInstances.length, parameters: b2 });
- }
- attemptAnchorPlacement(e2, t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2, d2, p2, m2, f2, g2) {
- 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);
- 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) {
- let t3;
- 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 };
- }
- }
- placeLayerBucketPart(t2, i3, o2, r2) {
- 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");
- let C2 = x2 && (y2 || !n2.hasIconData() || v2), I2 = y2 && (x2 || !n2.hasTextData() || g2);
- !n2.collisionArrays && d2 && n2.deserializeCollisionBoxes(d2), o2 && r2 && n2.updateCollisionDebugBuffers(this.transform.zoom, d2);
- const M2 = (t3, r3, d3) => {
- if (h2) {
- const o3 = { zoom: this.transform.zoom, pitch: this.transform.pitch };
- let r4 = null;
- if (h2.dynamicFilterNeedsFeature) {
- const e2 = this.retainedQueryData[n2.bucketInstanceId];
- r4 = h2.featureIndex.loadFeature({ featureIndex: t3.featureIndex, bucketIndex: e2.bucketIndex, sourceLayerIndex: e2.sourceLayerIndex, layoutVertexArrayOffset: 0 });
- }
- if (!(0, h2.dynamicFilter)(o3, r4, this.retainedQueryData[n2.bucketInstanceId].tileID.canonical, new e.pointGeometry(t3.tileAnchorX, t3.tileAnchorY), this.transform.calculateDistanceTileData(h2.unwrappedTileID)))
- return this.placements[t3.crossTileID] = new xt(false, false, false, true), void (i3[t3.crossTileID] = true);
- }
- if (i3[t3.crossTileID])
- return;
- if (u2)
- return void (this.placements[t3.crossTileID] = new xt(false, false, false));
- 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;
- d3.textFeatureIndex ? B2 = d3.textFeatureIndex : t3.useRuntimeCollisionCircles && (B2 = t3.featureIndex), d3.verticalTextFeatureIndex && (F2 = d3.verticalTextFeatureIndex);
- const N2 = (e2) => {
- 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);
- }, G2 = d3.textBox;
- if (G2) {
- N2(G2);
- const i4 = (i5) => {
- let o4 = e.WritingMode.horizontal;
- if (n2.allowVerticalPlacement && !i5 && this.prevPlacement) {
- const e2 = this.prevPlacement.placedOrientations[t3.crossTileID];
- e2 && (this.placedOrientations[t3.crossTileID] = e2, o4 = e2, this.markUsedOrientation(n2, o4, t3));
- }
- return o4;
- }, o3 = (i5, o4) => {
- if (n2.allowVerticalPlacement && t3.numVerticalGlyphVertices > 0 && d3.verticalTextBox) {
- for (const t4 of n2.writingModes)
- if (t4 === e.WritingMode.vertical ? (A2 = o4(), L2 = A2) : A2 = i5(), A2 && A2.box && A2.box.length)
- break;
- } else
- A2 = i5();
- };
- if (a2.get("text-variable-anchor")) {
- let l3 = a2.get("text-variable-anchor");
- if (this.prevPlacement && this.prevPlacement.variableOffsets[t3.crossTileID]) {
- const e2 = this.prevPlacement.variableOffsets[t3.crossTileID];
- l3.indexOf(e2.anchor) > 0 && (l3 = l3.filter((t4) => t4 !== e2.anchor), l3.unshift(e2.anchor));
- }
- const c3 = (e2, i5, o4) => {
- 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;
- u3 && N2(u3);
- let d4 = { box: [], offscreen: false, occluded: false };
- const g3 = x2 ? 2 * l3.length : l3.length;
- for (let i6 = 0; i6 < g3; ++i6) {
- 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);
- if (g4 && (d4 = g4.placedGlyphBoxes, d4 && d4.box && d4.box.length)) {
- E3 = true, P2 = g4.shift;
- break;
- }
- }
- return d4;
- };
- o3(() => c3(G2, d3.iconBox, e.WritingMode.horizontal), () => {
- const i5 = d3.verticalTextBox;
- 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 };
- }), A2 && (E3 = A2.box, S2 = A2.offscreen, z2 = A2.occluded);
- const h3 = i4(A2 && A2.box);
- if (!E3 && this.prevPlacement) {
- const e2 = this.prevPlacement.variableOffsets[t3.crossTileID];
- e2 && (this.variableOffsets[t3.crossTileID] = e2, this.markUsedJustification(n2, e2.anchor, t3, h3));
- }
- } else {
- const a3 = (i5, o4) => {
- 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);
- return l3 && l3.box && l3.box.length && (this.markUsedOrientation(n2, o4, t3), this.placedOrientations[t3.crossTileID] = o4), l3;
- };
- o3(() => a3(G2, e.WritingMode.horizontal), () => {
- const i5 = d3.verticalTextBox;
- return n2.allowVerticalPlacement && t3.numVerticalGlyphVertices > 0 && i5 ? (N2(i5), a3(i5, e.WritingMode.vertical)) : { box: null, offscreen: null, occluded: null };
- }), i4(A2 && A2.box && A2.box.length);
- }
- }
- if (R2 = A2, E3 = R2 && R2.box && R2.box.length > 0, S2 = R2 && R2.offscreen, z2 = R2 && R2.occluded, t3.useRuntimeCollisionCircles) {
- 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");
- 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;
- }
- if (d3.iconFeatureIndex && (U2 = d3.iconFeatureIndex), d3.iconBox) {
- const t4 = (t5) => {
- N2(t5);
- 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);
- return this.collisionIndex.placeCollisionBox(o3, t5, i4, y2, _2, s2, f2.predicate);
- };
- 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;
- }
- const j2 = g2 || 0 === t3.numHorizontalGlyphVertices && 0 === t3.numVerticalGlyphVertices, Z2 = v2 || 0 === t3.numIconVertices;
- 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)) {
- const e2 = n2.bucketInstanceId;
- let t4 = this.collisionCircleArrays[e2];
- void 0 === t4 && (t4 = this.collisionCircleArrays[e2] = new yt());
- for (let e3 = 0; e3 < k2.circles.length; e3 += 4)
- 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);
- }
- const V2 = "globe" !== this.transform.projection.name;
- 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;
- };
- if (E2) {
- const e2 = n2.getSortedSymbolIndexes(this.transform.angle);
- for (let t3 = e2.length - 1; t3 >= 0; --t3) {
- const i4 = e2[t3];
- M2(n2.symbolInstances.get(i4), i4, n2.collisionArrays[i4]);
- }
- } else
- for (let e2 = t2.symbolInstanceStart; e2 < t2.symbolInstanceEnd; e2++)
- M2(n2.symbolInstances.get(e2), e2, n2.collisionArrays[e2]);
- if (o2 && n2.bucketInstanceId in this.collisionCircleArrays) {
- const t3 = this.collisionCircleArrays[n2.bucketInstanceId];
- e.invert(t3.invProjMatrix, s2), t3.viewportMatrix = this.collisionIndex.getViewportMatrix();
- }
- n2.justReloaded = false;
- }
- markUsedJustification(t2, i3, o2, r2) {
- let n2;
- n2 = r2 === e.WritingMode.vertical ? o2.verticalPlacedTextSymbolIndex : { left: o2.leftJustifiedTextSymbolIndex, center: o2.centerJustifiedTextSymbolIndex, right: o2.rightJustifiedTextSymbolIndex }[e.getAnchorJustification(i3)];
- const a2 = [o2.leftJustifiedTextSymbolIndex, o2.centerJustifiedTextSymbolIndex, o2.rightJustifiedTextSymbolIndex, o2.verticalPlacedTextSymbolIndex];
- for (const e2 of a2)
- e2 >= 0 && (t2.text.placedSymbolArray.get(e2).crossTileID = n2 >= 0 && e2 !== n2 ? 0 : o2.crossTileID);
- }
- markUsedOrientation(t2, i3, o2) {
- 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];
- for (const e2 of a2)
- t2.text.placedSymbolArray.get(e2).placedOrientation = r2;
- o2.verticalPlacedTextSymbolIndex && (t2.text.placedSymbolArray.get(o2.verticalPlacedTextSymbolIndex).placedOrientation = n2);
- }
- commit(e2) {
- this.commitTime = e2, this.zoomAtLastRecencyCheck = this.transform.zoom;
- const t2 = this.prevPlacement;
- let i3 = false;
- this.prevZoomAdjustment = t2 ? t2.zoomAdjustment(this.transform.zoom) : 0;
- const o2 = t2 ? t2.symbolFadeChange(e2) : 1, r2 = t2 ? t2.opacities : {}, n2 = t2 ? t2.variableOffsets : {}, a2 = t2 ? t2.placedOrientations : {};
- for (const e3 in this.placements) {
- const t3 = this.placements[e3], n3 = r2[e3];
- 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);
- }
- for (const e3 in r2) {
- const t3 = r2[e3];
- if (!this.opacities[e3]) {
- const r3 = new vt(t3, o2, false, false);
- r3.isHidden() || (this.opacities[e3] = r3, i3 = i3 || t3.text.placed || t3.icon.placed);
- }
- }
- for (const e3 in n2)
- this.variableOffsets[e3] || !this.opacities[e3] || this.opacities[e3].isHidden() || (this.variableOffsets[e3] = n2[e3]);
- for (const e3 in a2)
- this.placedOrientations[e3] || !this.opacities[e3] || this.opacities[e3].isHidden() || (this.placedOrientations[e3] = a2[e3]);
- i3 ? this.lastPlacementChangeTime = e2 : "number" != typeof this.lastPlacementChangeTime && (this.lastPlacementChangeTime = t2 ? t2.lastPlacementChangeTime : e2);
- }
- updateLayerOpacities(e2, t2) {
- const i3 = {};
- for (const o2 of t2) {
- const t3 = o2.getBucket(e2);
- t3 && o2.latestFeatureIndex && e2.id === t3.layerIds[0] && this.updateBucketOpacities(t3, i3, o2.collisionBoxArray);
- }
- }
- updateBucketOpacities(t2, i3, o2) {
- t2.hasTextData() && t2.text.opacityVertexArray.clear(), t2.hasIconData() && t2.icon.opacityVertexArray.clear(), t2.hasIconCollisionBoxData() && t2.iconCollisionBox.collisionVertexArray.clear(), t2.hasTextCollisionBoxData() && t2.textCollisionBox.collisionVertexArray.clear();
- 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);
- !t2.collisionArrays && o2 && (t2.hasIconCollisionBoxData() || t2.hasTextCollisionBoxData()) && t2.deserializeCollisionBoxes(o2);
- const p2 = (e2, t3, i4) => {
- for (let o3 = 0; o3 < t3 / 4; o3++)
- e2.opacityVertexArray.emplaceBack(i4);
- };
- let m2 = 0;
- for (let o3 = 0; o3 < t2.symbolInstances.length; o3++) {
- const r3 = t2.symbolInstances.get(o3), { numHorizontalGlyphVertices: s3, numVerticalGlyphVertices: l3, crossTileID: f2 } = r3;
- let g2 = this.opacities[f2];
- i3[f2] ? g2 = a2 : g2 || (g2 = d2, this.opacities[f2] = g2), i3[f2] = true;
- 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;
- if (!v2 && !x2 || g2.isHidden() || m2++, v2) {
- const e2 = Rt(g2.text);
- p2(t2.text, s3, b2 ? kt : e2), p2(t2.text, l3, w2 ? kt : e2);
- const i4 = g2.text.isHidden();
- [r3.rightJustifiedTextSymbolIndex, r3.centerJustifiedTextSymbolIndex, r3.leftJustifiedTextSymbolIndex].forEach((e3) => {
- e3 >= 0 && (t2.text.placedSymbolArray.get(e3).hidden = i4 || b2 ? 1 : 0);
- }), r3.verticalPlacedTextSymbolIndex >= 0 && (t2.text.placedSymbolArray.get(r3.verticalPlacedTextSymbolIndex).hidden = i4 || w2 ? 1 : 0);
- const o4 = this.variableOffsets[r3.crossTileID];
- o4 && this.markUsedJustification(t2, o4.anchor, r3, y2);
- const n3 = this.placedOrientations[r3.crossTileID];
- n3 && (this.markUsedJustification(t2, "left", r3, n3), this.markUsedOrientation(t2, n3, r3));
- }
- if (x2) {
- const e2 = Rt(g2.icon);
- 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());
- }
- if (t2.hasIconCollisionBoxData() || t2.hasTextCollisionBoxData()) {
- const i4 = t2.collisionArrays[o3];
- if (i4) {
- let o4 = new e.pointGeometry(0, 0), r4 = true;
- if (i4.textBox || i4.verticalTextBox) {
- if (c2) {
- const e2 = this.variableOffsets[f2];
- 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;
- }
- 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);
- }
- const a3 = r4 && Boolean(!w2 && i4.verticalIconBox);
- 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);
- }
- }
- }
- 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) {
- const e2 = this.collisionCircleArrays[t2.bucketInstanceId];
- t2.placementInvProjMatrix = e2.invProjMatrix, t2.placementViewportMatrix = e2.viewportMatrix, t2.collisionCircleArray = e2.circles, delete this.collisionCircleArrays[t2.bucketInstanceId];
- }
- }
- symbolFadeChange(e2) {
- return 0 === this.fadeDuration ? 1 : (e2 - this.commitTime) / this.fadeDuration + this.prevZoomAdjustment;
- }
- zoomAdjustment(e2) {
- return Math.max(0, (this.transform.zoom - e2) / 1.5);
- }
- hasTransitions(e2) {
- return this.stale || e2 - this.lastPlacementChangeTime < this.fadeDuration;
- }
- stillRecent(e2, t2) {
- const i3 = this.zoomAtLastRecencyCheck === t2 ? 1 - this.zoomAdjustment(t2) : 1;
- return this.zoomAtLastRecencyCheck = t2, this.commitTime + this.fadeDuration * i3 > e2;
- }
- setStale() {
- this.stale = true;
- }
- }
- function It(e2, t2, i3, o2, r2) {
- 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);
- }
- 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);
- function Rt(e2) {
- if (0 === e2.opacity && !e2.placed)
- return 0;
- if (1 === e2.opacity && e2.placed)
- return 4294967295;
- const t2 = e2.placed ? 1 : 0, i3 = Math.floor(127 * e2.opacity);
- return i3 * Mt + t2 * St + i3 * zt + t2 * Dt + i3 * Pt + t2 * At + i3 * Lt + t2;
- }
- const kt = 0;
- class Ot {
- constructor(e2) {
- 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 = [];
- }
- continuePlacement(e2, t2, i3, o2, r2) {
- const n2 = this._bucketParts;
- for (; this._currentTileIndex < e2.length; )
- if (t2.getBucketParts(n2, o2, e2[this._currentTileIndex], this._sortAcrossTiles), this._currentTileIndex++, r2())
- return true;
- for (this._sortAcrossTiles && (this._sortAcrossTiles = false, n2.sort((e3, t3) => e3.sortKey - t3.sortKey)); this._currentPartIndex < n2.length; ) {
- const e3 = n2[this._currentPartIndex];
- if (t2.placeLayerBucketPart(e3, this._seenCrossTileIDs, i3, 0 === e3.symbolInstanceStart), this._currentPartIndex++, r2())
- return true;
- }
- return false;
- }
- }
- class Bt {
- constructor(e2, t2, i3, o2, r2, n2, a2, s2) {
- this.placement = new Ct(e2, r2, n2, a2, s2), this._currentPlacementIndex = t2.length - 1, this._forceFullPlacement = i3, this._showCollisionBoxes = o2, this._done = false;
- }
- isDone() {
- return this._done;
- }
- continuePlacement(t2, i3, o2) {
- const r2 = e.exported.now(), n2 = () => {
- const t3 = e.exported.now() - r2;
- return !this._forceFullPlacement && t3 > 2;
- };
- for (; this._currentPlacementIndex >= 0; ) {
- const e2 = i3[t2[this._currentPlacementIndex]], r3 = this.placement.collisionIndex.transform.zoom;
- if ("symbol" === e2.type && (!e2.minzoom || e2.minzoom <= r3) && (!e2.maxzoom || e2.maxzoom > r3)) {
- if (this._inProgressLayer || (this._inProgressLayer = new Ot(e2)), this._inProgressLayer.continuePlacement(o2[e2.source], this.placement, this._showCollisionBoxes, e2, n2))
- return;
- delete this._inProgressLayer;
- }
- this._currentPlacementIndex--;
- }
- this._done = true;
- }
- commit(e2) {
- return this.placement.commit(e2), this.placement;
- }
- }
- const Ft = 512 / e.EXTENT / 2;
- class Ut {
- constructor(e2, t2, i3) {
- this.tileID = e2, this.indexedSymbolInstances = {}, this.bucketInstanceId = i3;
- for (let i4 = 0; i4 < t2.length; i4++) {
- const o2 = t2.get(i4), r2 = o2.key;
- this.indexedSymbolInstances[r2] || (this.indexedSymbolInstances[r2] = []), this.indexedSymbolInstances[r2].push({ crossTileID: o2.crossTileID, coord: this.getScaledCoordinates(o2, e2) });
- }
- }
- getScaledCoordinates(t2, i3) {
- const o2 = Ft / Math.pow(2, i3.canonical.z - this.tileID.canonical.z);
- return { x: Math.floor((i3.canonical.x * e.EXTENT + t2.tileAnchorX) * o2), y: Math.floor((i3.canonical.y * e.EXTENT + t2.tileAnchorY) * o2) };
- }
- findMatches(e2, t2, i3) {
- const o2 = this.tileID.canonical.z < t2.canonical.z ? 1 : Math.pow(2, this.tileID.canonical.z - t2.canonical.z);
- for (let r2 = 0; r2 < e2.length; r2++) {
- const n2 = e2.get(r2);
- if (n2.crossTileID)
- continue;
- const a2 = this.indexedSymbolInstances[n2.key];
- if (!a2)
- continue;
- const s2 = this.getScaledCoordinates(n2, t2);
- for (const e3 of a2)
- if (Math.abs(e3.coord.x - s2.x) <= o2 && Math.abs(e3.coord.y - s2.y) <= o2 && !i3[e3.crossTileID]) {
- i3[e3.crossTileID] = true, n2.crossTileID = e3.crossTileID;
- break;
- }
- }
- }
- }
- class Nt {
- constructor() {
- this.maxCrossTileID = 0;
- }
- generate() {
- return ++this.maxCrossTileID;
- }
- }
- class Gt {
- constructor() {
- this.indexes = {}, this.usedCrossTileIDs = {}, this.lng = 0;
- }
- handleWrapJump(e2) {
- const t2 = Math.round((e2 - this.lng) / 360);
- if (0 !== t2)
- for (const e3 in this.indexes) {
- const i3 = this.indexes[e3], o2 = {};
- for (const e4 in i3) {
- const r2 = i3[e4];
- r2.tileID = r2.tileID.unwrapTo(r2.tileID.wrap + t2), o2[r2.tileID.key] = r2;
- }
- this.indexes[e3] = o2;
- }
- this.lng = e2;
- }
- addBucket(e2, t2, i3) {
- if (this.indexes[e2.overscaledZ] && this.indexes[e2.overscaledZ][e2.key]) {
- if (this.indexes[e2.overscaledZ][e2.key].bucketInstanceId === t2.bucketInstanceId)
- return false;
- this.removeBucketCrossTileIDs(e2.overscaledZ, this.indexes[e2.overscaledZ][e2.key]);
- }
- for (let e3 = 0; e3 < t2.symbolInstances.length; e3++)
- t2.symbolInstances.get(e3).crossTileID = 0;
- this.usedCrossTileIDs[e2.overscaledZ] || (this.usedCrossTileIDs[e2.overscaledZ] = {});
- const o2 = this.usedCrossTileIDs[e2.overscaledZ];
- for (const i4 in this.indexes) {
- const r2 = this.indexes[i4];
- if (Number(i4) > e2.overscaledZ)
- for (const i5 in r2) {
- const n2 = r2[i5];
- n2.tileID.isChildOf(e2) && n2.findMatches(t2.symbolInstances, e2, o2);
- }
- else {
- const n2 = r2[e2.scaledTo(Number(i4)).key];
- n2 && n2.findMatches(t2.symbolInstances, e2, o2);
- }
- }
- for (let e3 = 0; e3 < t2.symbolInstances.length; e3++) {
- const r2 = t2.symbolInstances.get(e3);
- r2.crossTileID || (r2.crossTileID = i3.generate(), o2[r2.crossTileID] = true);
- }
- 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;
- }
- removeBucketCrossTileIDs(e2, t2) {
- for (const i3 in t2.indexedSymbolInstances)
- for (const o2 of t2.indexedSymbolInstances[i3])
- delete this.usedCrossTileIDs[e2][o2.crossTileID];
- }
- removeStaleBuckets(e2) {
- let t2 = false;
- for (const i3 in this.indexes) {
- const o2 = this.indexes[i3];
- for (const r2 in o2)
- e2[o2[r2].bucketInstanceId] || (this.removeBucketCrossTileIDs(i3, o2[r2]), delete o2[r2], t2 = true);
- }
- return t2;
- }
- }
- class jt {
- constructor() {
- this.layerIndexes = {}, this.crossTileIDs = new Nt(), this.maxBucketInstanceId = 0, this.bucketsInCurrentPlacement = {};
- }
- addLayer(e2, t2, i3, o2) {
- let r2 = this.layerIndexes[e2.id];
- void 0 === r2 && (r2 = this.layerIndexes[e2.id] = new Gt());
- let n2 = false;
- const a2 = {};
- "globe" !== o2.name && r2.handleWrapJump(i3);
- for (const i4 of t2) {
- const t3 = i4.getBucket(e2);
- 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);
- }
- return r2.removeStaleBuckets(a2) && (n2 = true), n2;
- }
- pruneUnusedLayers(e2) {
- const t2 = {};
- e2.forEach((e3) => {
- t2[e3] = true;
- });
- for (const e3 in this.layerIndexes)
- t2[e3] || delete this.layerIndexes[e3];
- }
- }
- 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 };
- class $t extends e.Evented {
- constructor(t2, i3 = {}) {
- 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());
- const o2 = this;
- this._rtlTextPluginCallback = $t.registerForPluginStateChange((t3) => {
- o2.dispatcher.broadcast("syncRTLPluginState", { pluginStatus: t3.pluginStatus, pluginURL: t3.pluginURL }, (t4, i4) => {
- if (e.triggerPluginCompletionEvent(t4), i4 && i4.every((e2) => e2))
- for (const e2 in o2._sourceCaches) {
- const t5 = o2._sourceCaches[e2], i5 = t5.getSource().type;
- "vector" !== i5 && "geojson" !== i5 || t5.reload();
- }
- });
- }), this.on("data", (e2) => {
- if ("source" !== e2.dataType || "metadata" !== e2.sourceDataType)
- return;
- const t3 = this.getSource(e2.sourceId);
- if (t3 && t3.vectorLayerIds)
- for (const e3 in this._layers) {
- const i4 = this._layers[e3];
- i4.source === t3.id && this._validateLayer(i4);
- }
- });
- }
- loadURL(t2, i3 = {}) {
- this.fire(new e.Event("dataloading", { dataType: "style" }));
- const o2 = "boolean" == typeof i3.validate ? i3.validate : !e.isMapboxURL(t2);
- t2 = this.map._requestManager.normalizeStyleURL(t2, i3.accessToken);
- const r2 = this.map._requestManager.transformRequest(t2, e.ResourceType.Style);
- this._request = e.getJSON(r2, (t3, i4) => {
- this._request = null, t3 ? this.fire(new e.ErrorEvent(t3)) : i4 && this._load(i4, o2);
- });
- }
- loadJSON(t2, i3 = {}) {
- this.fire(new e.Event("dataloading", { dataType: "style" })), this._request = e.exported.frame(() => {
- this._request = null, this._load(t2, false !== i3.validate);
- });
- }
- loadEmpty() {
- this.fire(new e.Event("dataloading", { dataType: "style" })), this._load(qt, false);
- }
- _updateLayerCount(e2, t2) {
- const i3 = t2 ? 1 : -1;
- e2.is3D() && (this._num3DLayers += i3), "circle" === e2.type && (this._numCircleLayers += i3), "symbol" === e2.type && (this._numSymbolLayers += i3);
- }
- _load(t2, i3) {
- if (i3 && Zt(this, e.validateStyle(t2)))
- return;
- this._loaded = true, this.stylesheet = t2, this._updateMapProjection();
- for (const e2 in t2.sources)
- this.addSource(e2, t2.sources[e2], { validate: false });
- this._changed = false, t2.sprite ? this._loadSprite(t2.sprite) : (this.imageManager.setLoaded(true), this.dispatcher.broadcast("spriteLoaded", true)), this.glyphManager.setURL(t2.glyphs);
- const o2 = Ge(this.stylesheet.layers);
- this._order = o2.map((e2) => e2.id), this._layers = {}, this._serializedLayers = {};
- for (let t3 of o2)
- 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);
- 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"));
- }
- terrainSetForDrapingOnly() {
- return !!this.terrain && 0 === this.terrain.drapeRenderMode;
- }
- setProjection(e2) {
- e2 ? this.stylesheet.projection = e2 : delete this.stylesheet.projection, this.map._explicitProjection || this.map._updateProjection();
- }
- _updateMapProjection() {
- this.map._explicitProjection ? this.applyProjectionUpdate() : this.map._updateProjection();
- }
- applyProjectionUpdate() {
- 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));
- }
- _loadSprite(t2) {
- this._spriteRequest = function(t3, i3, o2) {
- let r2, n2, a2;
- const s2 = e.exported.devicePixelRatio > 1 ? "@2x" : "";
- let l2 = e.getJSON(i3.transformRequest(i3.normalizeSpriteURL(t3, s2, ".json"), e.ResourceType.SpriteJSON), (e2, t4) => {
- l2 = null, a2 || (a2 = e2, r2 = t4, h2());
- }), c2 = e.getImage(i3.transformRequest(i3.normalizeSpriteURL(t3, s2, ".png"), e.ResourceType.SpriteImage), (e2, t4) => {
- c2 = null, a2 || (a2 = e2, n2 = t4, h2());
- });
- function h2() {
- if (a2)
- o2(a2);
- else if (r2 && n2) {
- const t4 = e.exported.getImageData(n2), i4 = {};
- for (const o3 in r2) {
- 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 });
- 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 };
- }
- o2(null, i4);
- }
- }
- return { cancel() {
- l2 && (l2.cancel(), l2 = null), c2 && (c2.cancel(), c2 = null);
- } };
- }(t2, this.map._requestManager, (t3, i3) => {
- if (this._spriteRequest = null, t3)
- this.fire(new e.ErrorEvent(t3));
- else if (i3)
- for (const e2 in i3)
- this.imageManager.addImage(e2, i3[e2]);
- 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" }));
- });
- }
- _validateLayer(t2) {
- const i3 = this.getSource(t2.source);
- if (!i3)
- return;
- const o2 = t2.sourceLayer;
- 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}"`)));
- }
- loaded() {
- if (!this._loaded)
- return false;
- if (Object.keys(this._updatedSources).length)
- return false;
- for (const e2 in this._sourceCaches)
- if (!this._sourceCaches[e2].loaded())
- return false;
- return !!this.imageManager.isLoaded();
- }
- _serializeLayers(e2) {
- const t2 = [];
- for (const i3 of e2) {
- const e3 = this._layers[i3];
- "custom" !== e3.type && t2.push(e3.serialize());
- }
- return t2;
- }
- hasTransitions() {
- if (this.light && this.light.hasTransition())
- return true;
- if (this.fog && this.fog.hasTransition())
- return true;
- for (const e2 in this._sourceCaches)
- if (this._sourceCaches[e2].hasTransition())
- return true;
- for (const e2 in this._layers)
- if (this._layers[e2].hasTransition())
- return true;
- return false;
- }
- get order() {
- return this.map._optimizeForTerrain && this.terrain ? this._drapedFirstOrder : this._order;
- }
- isLayerDraped(e2) {
- return !!this.terrain && Xt[e2.type];
- }
- _checkLoaded() {
- if (!this._loaded)
- throw new Error("Style is not done loading");
- }
- update(t2) {
- if (!this._loaded)
- return;
- const i3 = this._changed;
- if (this._changed) {
- const e2 = Object.keys(this._updatedLayers), i4 = Object.keys(this._removedLayers);
- (e2.length || i4.length) && this._updateWorkerLayers(e2, i4);
- for (const e3 in this._updatedSources) {
- const t3 = this._updatedSources[e3];
- "reload" === t3 ? this._reloadSource(e3) : "clear" === t3 && this._clearSource(e3);
- }
- this._updateTilesForChangedImages();
- for (const e3 in this._updatedPaintProps)
- this._layers[e3].updateTransitions(t2);
- this.light.updateTransitions(t2), this.fog && this.fog.updateTransitions(t2), this._resetUpdates();
- }
- const o2 = {};
- for (const e2 in this._sourceCaches) {
- const t3 = this._sourceCaches[e2];
- o2[e2] = t3.used, t3.used = false;
- }
- for (const e2 of this._order) {
- const i4 = this._layers[e2];
- if (i4.recalculate(t2, this._availableImages), !i4.isHidden(t2.zoom)) {
- const e3 = this._getLayerSourceCache(i4);
- e3 && (e3.used = true);
- }
- const o3 = this.map.painter;
- if (o3) {
- const e3 = i4.getProgramIds();
- if (!e3)
- continue;
- const r2 = i4.getProgramConfiguration(t2.zoom);
- for (const t3 of e3)
- o3.useProgram(t3, r2);
- }
- }
- for (const t3 in o2) {
- const i4 = this._sourceCaches[t3];
- o2[t3] !== i4.used && i4.getSource().fire(new e.Event("data", { sourceDataType: "visibility", dataType: "source", sourceId: i4.getSource().id }));
- }
- 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" }));
- }
- _updateTilesForChangedImages() {
- const e2 = Object.keys(this._changedImages);
- if (e2.length) {
- for (const t2 in this._sourceCaches)
- this._sourceCaches[t2].reloadTilesForDependencies(["icons", "patterns"], e2);
- this._changedImages = {};
- }
- }
- _updateWorkerLayers(e2, t2) {
- this.dispatcher.broadcast("updateLayers", { layers: this._serializeLayers(e2), removedIds: t2 });
- }
- _resetUpdates() {
- this._changed = false, this._updatedLayers = {}, this._removedLayers = {}, this._updatedSources = {}, this._updatedPaintProps = {}, this._changedImages = {};
- }
- setState(t2) {
- if (this._checkLoaded(), Zt(this, e.validateStyle(t2)))
- return false;
- (t2 = e.clone$1(t2)).layers = Ge(t2.layers);
- const i3 = function(e2, t3) {
- if (!e2)
- return [{ command: je.setStyle, args: [t3] }];
- let i4 = [];
- try {
- if (!r(e2.version, t3.version))
- return [{ command: je.setStyle, args: [t3] }];
- 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] });
- const o3 = {}, n2 = [];
- !function(e3, t4, i5, o4) {
- let n3;
- for (n3 in t4 = t4 || {}, e3 = e3 || {})
- e3.hasOwnProperty(n3) && (t4.hasOwnProperty(n3) || Ve(n3, i5, o4));
- for (n3 in t4)
- 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));
- }(e2.sources, t3.sources, n2, o3);
- const a2 = [];
- e2.layers && e2.layers.forEach((e3) => {
- e3.source && o3[e3.source] ? i4.push({ command: je.removeLayer, args: [e3.id] }) : a2.push(e3);
- });
- let s2 = e2.terrain;
- 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) {
- t4 = t4 || [];
- 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);
- let h2, _2, u2, d2, p2, m2, f2;
- for (h2 = 0, _2 = 0; h2 < o4.length; h2++)
- u2 = o4[h2], s3.hasOwnProperty(u2) ? _2++ : (i5.push({ command: je.removeLayer, args: [u2] }), l2.splice(l2.indexOf(u2, _2), 1));
- for (h2 = 0, _2 = 0; h2 < n3.length; h2++)
- 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);
- for (h2 = 0; h2 < n3.length; h2++)
- if (u2 = n3[h2], d2 = a3[u2], p2 = s3[u2], !c2[u2] && !r(d2, p2))
- if (r(d2.source, p2.source) && r(d2["source-layer"], p2["source-layer"]) && r(d2.type, p2.type)) {
- 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)
- 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]] }));
- for (f2 in p2)
- 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]] }));
- } else
- i5.push({ command: je.removeLayer, args: [u2] }), m2 = l2[l2.lastIndexOf(u2) + 1], i5.push({ command: je.addLayer, args: [p2, m2] });
- }(a2, t3.layers, i4);
- } catch (e3) {
- console.warn("Unable to compute style diff:", e3), i4 = [{ command: je.setStyle, args: [t3] }];
- }
- return i4;
- }(this.serialize(), t2).filter((e2) => !(e2.command in Wt));
- if (0 === i3.length)
- return false;
- const o2 = i3.filter((e2) => !(e2.command in Vt));
- if (o2.length > 0)
- throw new Error(`Unimplemented: ${o2.map((e2) => e2.command).join(", ")}.`);
- return i3.forEach((e2) => {
- "setTransition" !== e2.command && this[e2.command].apply(this, e2.args);
- }), this.stylesheet = t2, this._updateMapProjection(), true;
- }
- addImage(t2, i3) {
- 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);
- }
- updateImage(e2, t2) {
- this.imageManager.updateImage(e2, t2);
- }
- getImage(e2) {
- return this.imageManager.getImage(e2);
- }
- removeImage(t2) {
- 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.")));
- }
- _afterImageUpdated(t2) {
- 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" }));
- }
- listImages() {
- return this._checkLoaded(), this._availableImages.slice();
- }
- addSource(t2, i3, o2 = {}) {
- if (this._checkLoaded(), void 0 !== this.getSource(t2))
- throw new Error("There is already a source with this ID");
- if (!i3.type)
- throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i3).join(", ")}.`);
- if (["vector", "raster", "geojson", "video", "image"].indexOf(i3.type) >= 0 && this._validate(e.validateSource, `sources.${t2}`, i3, null, o2))
- return;
- this.map && this.map._collectResourceTiming && (i3.collectResourceTiming = true);
- const r2 = De(t2, i3, this.dispatcher, this);
- r2.setEventedParent(this, () => ({ isSourceLoaded: this._isSourceCacheLoaded(t2), source: r2.serialize(), sourceId: t2 }));
- const n2 = (i4) => {
- const o3 = (i4 ? "symbol:" : "other:") + t2, n3 = this._sourceCaches[o3] = new e.SourceCache(o3, r2, i4);
- (i4 ? this._symbolSourceCaches : this._otherSourceCaches)[t2] = n3, n3.style = this, n3.onAdd(this.map);
- };
- n2(false), "vector" !== i3.type && "geojson" !== i3.type || n2(true), r2.onAdd && r2.onAdd(this.map), this._changed = true;
- }
- removeSource(t2) {
- this._checkLoaded();
- const i3 = this.getSource(t2);
- if (!i3)
- throw new Error("There is no source with this ID");
- for (const i4 in this._layers)
- if (this._layers[i4].source === t2)
- return this.fire(new e.ErrorEvent(new Error(`Source "${t2}" cannot be removed while layer "${i4}" is using it.`)));
- if (this.terrain && this.terrain.get().source === t2)
- return this.fire(new e.ErrorEvent(new Error(`Source "${t2}" cannot be removed while terrain is using it.`)));
- const o2 = this._getSourceCaches(t2);
- for (const t3 of o2)
- 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();
- return delete this._otherSourceCaches[t2], delete this._symbolSourceCaches[t2], i3.setEventedParent(null), i3.onRemove && i3.onRemove(this.map), this._changed = true, this;
- }
- setGeoJSONSourceData(e2, t2) {
- this._checkLoaded(), this.getSource(e2).setData(t2), this._changed = true;
- }
- getSource(e2) {
- const t2 = this._getSourceCache(e2);
- return t2 && t2.getSource();
- }
- addLayer(t2, i3, o2 = {}) {
- this._checkLoaded();
- const r2 = t2.id;
- if (this.getLayer(r2))
- return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${r2}" already exists on this map`)));
- let n2;
- if ("custom" === t2.type) {
- if (Zt(this, e.validateCustomStyleLayer(t2)))
- return;
- n2 = e.createStyleLayer(t2);
- } else {
- 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))
- return;
- n2 = e.createStyleLayer(t2), this._validateLayer(n2), n2.setEventedParent(this, { layer: { id: r2 } }), this._serializedLayers[n2.id] = n2.serialize(), this._updateLayerCount(n2, true);
- }
- const a2 = i3 ? this._order.indexOf(i3) : this._order.length;
- if (i3 && -1 === a2)
- return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${i3}" does not exist on this map.`)));
- this._order.splice(a2, 0, r2), this._layerOrderChanged = true, this._layers[r2] = n2;
- const s2 = this._getLayerSourceCache(n2);
- if (this._removedLayers[r2] && n2.source && s2 && "custom" !== n2.type) {
- const e2 = this._removedLayers[r2];
- delete this._removedLayers[r2], e2.type !== n2.type ? this._updatedSources[n2.source] = "clear" : (this._updatedSources[n2.source] = "reload", s2.pause());
- }
- this._updateLayer(n2), n2.onAdd && n2.onAdd(this.map), this._updateDrapeFirstLayers();
- }
- moveLayer(t2, i3) {
- if (this._checkLoaded(), this._changed = true, !this._layers[t2])
- return void this.fire(new e.ErrorEvent(new Error(`The layer '${t2}' does not exist in the map's style and cannot be moved.`)));
- if (t2 === i3)
- return;
- const o2 = this._order.indexOf(t2);
- this._order.splice(o2, 1);
- const r2 = i3 ? this._order.indexOf(i3) : this._order.length;
- 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());
- }
- removeLayer(t2) {
- this._checkLoaded();
- const i3 = this._layers[t2];
- if (!i3)
- return void this.fire(new e.ErrorEvent(new Error(`The layer '${t2}' does not exist in the map's style and cannot be removed.`)));
- i3.setEventedParent(null), this._updateLayerCount(i3, false);
- const o2 = this._order.indexOf(t2);
- 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();
- }
- getLayer(e2) {
- return this._layers[e2];
- }
- hasLayer(e2) {
- return e2 in this._layers;
- }
- hasLayerType(e2) {
- for (const t2 in this._layers)
- if (this._layers[t2].type === e2)
- return true;
- return false;
- }
- setLayerZoomRange(t2, i3, o2) {
- this._checkLoaded();
- const r2 = this.getLayer(t2);
- 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.`)));
- }
- setFilter(t2, i3, o2 = {}) {
- this._checkLoaded();
- const n2 = this.getLayer(t2);
- if (n2) {
- if (!r(n2.filter, i3))
- 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)));
- } else
- this.fire(new e.ErrorEvent(new Error(`The layer '${t2}' does not exist in the map's style and cannot be filtered.`)));
- }
- getFilter(t2) {
- const i3 = this.getLayer(t2);
- return i3 && e.clone$1(i3.filter);
- }
- setLayoutProperty(t2, i3, o2, n2 = {}) {
- this._checkLoaded();
- const a2 = this.getLayer(t2);
- 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.`)));
- }
- getLayoutProperty(t2, i3) {
- const o2 = this.getLayer(t2);
- if (o2)
- return o2.getLayoutProperty(i3);
- this.fire(new e.ErrorEvent(new Error(`The layer '${t2}' does not exist in the map's style.`)));
- }
- setPaintProperty(t2, i3, o2, n2 = {}) {
- this._checkLoaded();
- const a2 = this.getLayer(t2);
- 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.`)));
- }
- getPaintProperty(e2, t2) {
- const i3 = this.getLayer(e2);
- return i3 && i3.getPaintProperty(t2);
- }
- setFeatureState(t2, i3) {
- this._checkLoaded();
- const o2 = t2.source, r2 = t2.sourceLayer, n2 = this.getSource(o2);
- if (!n2)
- return void this.fire(new e.ErrorEvent(new Error(`The source '${o2}' does not exist in the map's style.`)));
- const a2 = n2.type;
- if ("geojson" === a2 && r2)
- return void this.fire(new e.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));
- if ("vector" === a2 && !r2)
- return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));
- void 0 === t2.id && this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided.")));
- const s2 = this._getSourceCaches(o2);
- for (const e2 of s2)
- e2.setFeatureState(r2, t2.id, i3);
- }
- removeFeatureState(t2, i3) {
- this._checkLoaded();
- const o2 = t2.source, r2 = this.getSource(o2);
- if (!r2)
- return void this.fire(new e.ErrorEvent(new Error(`The source '${o2}' does not exist in the map's style.`)));
- const n2 = r2.type, a2 = "vector" === n2 ? t2.sourceLayer : void 0;
- if ("vector" === n2 && !a2)
- return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));
- if (i3 && "string" != typeof t2.id && "number" != typeof t2.id)
- return void this.fire(new e.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));
- const s2 = this._getSourceCaches(o2);
- for (const e2 of s2)
- e2.removeFeatureState(a2, t2.id, i3);
- }
- getFeatureState(t2) {
- this._checkLoaded();
- const i3 = t2.source, o2 = t2.sourceLayer, r2 = this.getSource(i3);
- if (r2) {
- if ("vector" !== r2.type || o2)
- 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);
- this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));
- } else
- this.fire(new e.ErrorEvent(new Error(`The source '${i3}' does not exist in the map's style.`)));
- }
- getTransition() {
- return e.extend({ duration: 300, delay: 0 }, this.stylesheet && this.stylesheet.transition);
- }
- serialize() {
- const t2 = {};
- for (const e2 in this._sourceCaches) {
- const i3 = this._sourceCaches[e2].getSource();
- t2[i3.id] || (t2[i3.id] = i3.serialize());
- }
- 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);
- }
- _updateLayer(e2) {
- this._updatedLayers[e2.id] = true;
- const t2 = this._getLayerSourceCache(e2);
- e2.source && !this._updatedSources[e2.source] && t2 && "raster" !== t2.getSource().type && (this._updatedSources[e2.source] = "reload", t2.pause()), this._changed = true, e2.invalidateCompiledFilter();
- }
- _flattenAndSortRenderedFeatures(e2) {
- const t2 = (e3) => "fill-extrusion" === this._layers[e3].type, i3 = {}, o2 = [];
- for (let r3 = this._order.length - 1; r3 >= 0; r3--) {
- const n2 = this._order[r3];
- if (t2(n2)) {
- i3[n2] = r3;
- for (const t3 of e2) {
- const e3 = t3[n2];
- if (e3)
- for (const t4 of e3)
- o2.push(t4);
- }
- }
- }
- o2.sort((e3, t3) => t3.intersectionZ - e3.intersectionZ);
- const r2 = [];
- for (let n2 = this._order.length - 1; n2 >= 0; n2--) {
- const a2 = this._order[n2];
- if (t2(a2))
- for (let e3 = o2.length - 1; e3 >= 0; e3--) {
- const t3 = o2[e3].feature;
- if (i3[t3.layer.id] < n2)
- break;
- r2.push(t3), o2.pop();
- }
- else
- for (const t3 of e2) {
- const e3 = t3[a2];
- if (e3)
- for (const t4 of e3)
- r2.push(t4.feature);
- }
- }
- return r2;
- }
- queryRenderedFeatures(t2, i3, o2) {
- i3 && i3.filter && this._validate(e.validateFilter, "queryRenderedFeatures.filter", i3.filter, null, i3);
- const r2 = {};
- if (i3 && i3.layers) {
- if (!Array.isArray(i3.layers))
- return this.fire(new e.ErrorEvent(new Error("parameters.layers must be an Array."))), [];
- for (const t3 of i3.layers) {
- const i4 = this._layers[t3];
- if (!i4)
- 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.`))), [];
- r2[i4.source] = true;
- }
- }
- const n2 = [];
- i3.availableImages = this._availableImages;
- const a2 = i3 && i3.layers ? i3.layers.some((e2) => {
- const t3 = this.getLayer(e2);
- return t3 && t3.is3D();
- }) : this.has3DLayers(), s2 = R.createFromScreenPoints(t2, o2);
- for (const e2 in this._sourceCaches) {
- const t3 = this._sourceCaches[e2].getSource().id;
- i3.layers && !r2[t3] || n2.push(Ae(this._sourceCaches[e2], this._layers, this._serializedLayers, s2, i3, o2, a2, !!this.map._showQueryGeometry));
- }
- return this.placement && n2.push(function(e2, t3, i4, o3, r3, n3, a3) {
- const s3 = {}, l2 = n3.queryRenderedSymbols(o3), c2 = [];
- for (const e3 of Object.keys(l2).map(Number))
- c2.push(a3[e3]);
- c2.sort(Re);
- for (const i5 of c2) {
- const o4 = i5.featureIndex.lookupSymbolFeatures(l2[i5.bucketInstanceId], t3, i5.bucketIndex, i5.sourceLayerIndex, r3.filter, r3.layers, r3.availableImages, e2);
- for (const e3 in o4) {
- const t4 = s3[e3] = s3[e3] || [], r4 = o4[e3];
- r4.sort((e4, t5) => {
- const o5 = i5.featureSortOrder;
- if (o5) {
- const i6 = o5.indexOf(e4.featureIndex);
- return o5.indexOf(t5.featureIndex) - i6;
- }
- return t5.featureIndex - e4.featureIndex;
- });
- for (const e4 of r4)
- t4.push(e4);
- }
- }
- for (const t4 in s3)
- s3[t4].forEach((o4) => {
- const r4 = o4.feature, n4 = i4(e2[t4]).getFeatureState(r4.layer["source-layer"], r4.id);
- r4.source = r4.layer.source, r4.layer["source-layer"] && (r4.sourceLayer = r4.layer["source-layer"]), r4.state = n4;
- });
- return s3;
- }(this._layers, this._serializedLayers, this._getLayerSourceCache.bind(this), s2.screenGeometry, i3, this.placement.collisionIndex, this.placement.retainedQueryData)), this._flattenAndSortRenderedFeatures(n2);
- }
- querySourceFeatures(t2, i3) {
- i3 && i3.filter && this._validate(e.validateFilter, "querySourceFeatures.filter", i3.filter, null, i3);
- const o2 = this._getSourceCaches(t2);
- let r2 = [];
- for (const e2 of o2)
- r2 = r2.concat(Le(e2, i3));
- return r2;
- }
- addSourceType(e2, t2, i3) {
- 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));
- }
- getLight() {
- return this.light.getLight();
- }
- setLight(t2, i3 = {}) {
- this._checkLoaded();
- const o2 = this.light.getLight();
- let n2 = false;
- for (const e2 in t2)
- if (!r(t2[e2], o2[e2])) {
- n2 = true;
- break;
- }
- if (!n2)
- return;
- const a2 = { now: e.exported.now(), transition: e.extend({ duration: 300, delay: 0 }, this.stylesheet.transition) };
- this.light.setLight(t2, i3), this.light.updateTransitions(a2);
- }
- getTerrain() {
- return this.terrain && 1 === this.terrain.drapeRenderMode ? this.terrain.get() : null;
- }
- setTerrainForDraping() {
- this.setTerrain({ source: "", exaggeration: 0 }, 0);
- }
- setTerrain(t2, i3 = 1) {
- if (this._checkLoaded(), !t2)
- return delete this.terrain, delete this.stylesheet.terrain, this.dispatcher.broadcast("enableTerrain", false), this._force3DLayerUpdate(), void (this._markersNeedUpdate = true);
- if (1 === i3) {
- if ("object" == typeof t2.source) {
- const i4 = "terrain-dem-src";
- this.addSource(i4, t2.source), t2 = e.clone$1(t2), t2 = e.extend(t2, { source: i4 });
- }
- if (this._validate(e.validateTerrain, "terrain", t2))
- return;
- }
- if (!this.terrain || this.terrain && i3 !== this.terrain.drapeRenderMode)
- this._createTerrain(t2, i3);
- else {
- const i4 = this.terrain, o2 = i4.get();
- for (const n2 in t2)
- if (!r(t2[n2], o2[n2])) {
- i4.set(t2), this.stylesheet.terrain = t2;
- const o3 = { now: e.exported.now(), transition: e.extend({ duration: 0 }, this.stylesheet.transition) };
- i4.updateTransitions(o3);
- break;
- }
- }
- this._updateDrapeFirstLayers(), this._markersNeedUpdate = true;
- }
- _createFog(t2) {
- const i3 = this.fog = new P(t2, this.map.transform);
- this.stylesheet.fog = t2;
- const o2 = { now: e.exported.now(), transition: e.extend({ duration: 0 }, this.stylesheet.transition) };
- i3.updateTransitions(o2);
- }
- _updateMarkersOpacity() {
- 0 !== this.map._markers.length && this.map._requestDomTask(() => {
- for (const e2 of this.map._markers)
- e2._evaluateOpacity();
- });
- }
- getFog() {
- return this.fog ? this.fog.get() : null;
- }
- setFog(t2) {
- if (this._checkLoaded(), !t2)
- return delete this.fog, delete this.stylesheet.fog, void (this._markersNeedUpdate = true);
- if (this.fog) {
- const i3 = this.fog, o2 = i3.get();
- for (const n2 in t2)
- if (!r(t2[n2], o2[n2])) {
- i3.set(t2), this.stylesheet.fog = t2;
- const o3 = { now: e.exported.now(), transition: e.extend({ duration: 0 }, this.stylesheet.transition) };
- i3.updateTransitions(o3);
- break;
- }
- } else
- this._createFog(t2);
- this._markersNeedUpdate = true;
- }
- _updateDrapeFirstLayers() {
- if (!this.map._optimizeForTerrain || !this.terrain)
- return;
- const e2 = this._order.filter((e3) => this.isLayerDraped(this._layers[e3])), t2 = this._order.filter((e3) => !this.isLayerDraped(this._layers[e3]));
- this._drapedFirstOrder = [], this._drapedFirstOrder.push(...e2), this._drapedFirstOrder.push(...t2);
- }
- _createTerrain(t2, i3) {
- const o2 = this.terrain = new I(t2, i3);
- this.stylesheet.terrain = t2, this.dispatcher.broadcast("enableTerrain", !this.terrainSetForDrapingOnly()), this._force3DLayerUpdate();
- const r2 = { now: e.exported.now(), transition: e.extend({ duration: 0 }, this.stylesheet.transition) };
- o2.updateTransitions(r2);
- }
- _force3DLayerUpdate() {
- for (const e2 in this._layers) {
- const t2 = this._layers[e2];
- "fill-extrusion" === t2.type && this._updateLayer(t2);
- }
- }
- _forceSymbolLayerUpdate() {
- for (const e2 in this._layers) {
- const t2 = this._layers[e2];
- "symbol" === t2.type && this._updateLayer(t2);
- }
- }
- _validate(t2, i3, o2, r2, n2 = {}) {
- return (!n2 || false !== n2.validate) && Zt(this, t2.call(e.validateStyle, e.extend({ key: i3, style: this.serialize(), value: o2, styleSpec: e.spec }, r2)));
- }
- _remove() {
- this._request && (this._request.cancel(), this._request = null), this._spriteRequest && (this._spriteRequest.cancel(), this._spriteRequest = null), e.evented.off("pluginStateChange", this._rtlTextPluginCallback);
- for (const e2 in this._layers)
- this._layers[e2].setEventedParent(null);
- for (const e2 in this._sourceCaches)
- this._sourceCaches[e2].clearTiles(), this._sourceCaches[e2].setEventedParent(null);
- this.imageManager.setEventedParent(null), this.setEventedParent(null), this.dispatcher.remove();
- }
- _clearSource(e2) {
- const t2 = this._getSourceCaches(e2);
- for (const e3 of t2)
- e3.clearTiles();
- }
- _reloadSource(e2) {
- const t2 = this._getSourceCaches(e2);
- for (const e3 of t2)
- e3.resume(), e3.reload();
- }
- _updateSources(e2) {
- for (const t2 in this._sourceCaches)
- this._sourceCaches[t2].update(e2);
- }
- _generateCollisionBoxes() {
- for (const e2 in this._sourceCaches) {
- const t2 = this._sourceCaches[e2];
- t2.resume(), t2.reload();
- }
- }
- _updatePlacement(t2, i3, o2, r2, n2 = false) {
- let a2 = false, s2 = false;
- const l2 = {};
- for (const e2 of this._order) {
- const i4 = this._layers[e2];
- if ("symbol" !== i4.type)
- continue;
- if (!l2[i4.source]) {
- const e3 = this._getLayerSourceCache(i4);
- if (!e3)
- continue;
- 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));
- }
- const o3 = this.crossTileSymbolIndex.addLayer(i4, l2[i4.source], t2.center.lng, t2.projection);
- a2 = a2 || o3;
- }
- 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)
- for (const e2 of this._order) {
- const t3 = this._layers[e2];
- "symbol" === t3.type && this.placement.updateLayerOpacities(t3, l2[t3.source]);
- }
- return !this.pauseablePlacement.isDone() || this.placement.hasTransitions(e.exported.now());
- }
- _releaseSymbolFadeTiles() {
- for (const e2 in this._sourceCaches)
- this._sourceCaches[e2].releaseSymbolFadeTiles();
- }
- getImages(e2, t2, i3) {
- this.imageManager.getImages(t2.icons, i3), this._updateTilesForChangedImages();
- const o2 = (e3) => {
- e3 && e3.setDependencies(t2.tileID.key, t2.type, t2.icons);
- };
- o2(this._otherSourceCaches[t2.source]), o2(this._symbolSourceCaches[t2.source]);
- }
- getGlyphs(e2, t2, i3) {
- this.glyphManager.getGlyphs(t2.stacks, i3);
- }
- getResource(t2, i3, o2) {
- return e.makeRequest(i3, o2);
- }
- _getSourceCache(e2) {
- return this._otherSourceCaches[e2];
- }
- _getLayerSourceCache(e2) {
- return "symbol" === e2.type ? this._symbolSourceCaches[e2.source] : this._otherSourceCaches[e2.source];
- }
- _getSourceCaches(e2) {
- const t2 = [];
- return this._otherSourceCaches[e2] && t2.push(this._otherSourceCaches[e2]), this._symbolSourceCaches[e2] && t2.push(this._symbolSourceCaches[e2]), t2;
- }
- _isSourceCacheLoaded(t2) {
- const i3 = this._getSourceCaches(t2);
- return 0 === i3.length ? (this.fire(new e.ErrorEvent(new Error(`There is no source with ID '${t2}'`))), false) : i3.every((e2) => e2.loaded());
- }
- has3DLayers() {
- return this._num3DLayers > 0;
- }
- hasSymbolLayers() {
- return this._numSymbolLayers > 0;
- }
- hasCircleLayers() {
- return this._numCircleLayers > 0;
- }
- _clearWorkerCaches() {
- this.dispatcher.broadcast("clearCaches");
- }
- destroy() {
- this._clearWorkerCaches(), this.terrainSetForDrapingOnly() && (delete this.terrain, delete this.stylesheet.terrain);
- }
- }
- $t.getSourceType = function(e2) {
- return ze[e2];
- }, $t.setSourceType = function(e2, t2) {
- ze[e2] = t2;
- }, $t.registerForPluginStateChange = e.registerForPluginStateChange;
- 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;}";
- let Yt = {}, Jt = {};
- 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);
- 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;
- 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);}") };
- function ii(e2, t2, i3) {
- 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);
- let c2 = s2 ? s2.concat(a2) : a2;
- i3 || (Yt.staticUniforms && (c2 = Yt.staticUniforms.concat(c2)), Jt.staticUniforms && (c2 = Jt.staticUniforms.concat(c2))), c2 && (c2 = c2.concat(l2));
- const h2 = {};
- return { fragmentSource: e2 = e2.replace(o2, (e3, t3, i4, o3, r3) => (h2[r3] = true, "define" === t3 ? `
- #ifndef HAS_UNIFORM_u_${r3}
- varying ${i4} ${o3} ${r3};
- #else
- uniform ${i4} ${o3} u_${r3};
- #endif
- ` : `
- #ifdef HAS_UNIFORM_u_${r3}
- ${i4} ${o3} ${r3} = u_${r3};
- #endif
- `)), vertexSource: t2 = t2.replace(o2, (e3, t3, i4, o3, r3) => {
- const n3 = "float" === o3 ? "vec2" : "vec4", a3 = r3.match(/color/) ? "color" : n3;
- return h2[r3] ? "define" === t3 ? `
- #ifndef HAS_UNIFORM_u_${r3}
- uniform lowp float u_${r3}_t;
- attribute ${i4} ${n3} a_${r3};
- varying ${i4} ${o3} ${r3};
- #else
- uniform ${i4} ${o3} u_${r3};
- #endif
- ` : "vec4" === a3 ? `
- #ifndef HAS_UNIFORM_u_${r3}
- ${r3} = a_${r3};
- #else
- ${i4} ${o3} ${r3} = u_${r3};
- #endif
- ` : `
- #ifndef HAS_UNIFORM_u_${r3}
- ${r3} = unpack_mix_${a3}(a_${r3}, u_${r3}_t);
- #else
- ${i4} ${o3} ${r3} = u_${r3};
- #endif
- ` : "define" === t3 ? `
- #ifndef HAS_UNIFORM_u_${r3}
- uniform lowp float u_${r3}_t;
- attribute ${i4} ${n3} a_${r3};
- #else
- uniform ${i4} ${o3} u_${r3};
- #endif
- ` : "vec4" === a3 ? `
- #ifndef HAS_UNIFORM_u_${r3}
- ${i4} ${o3} ${r3} = a_${r3};
- #else
- ${i4} ${o3} ${r3} = u_${r3};
- #endif
- ` : `
- #ifndef HAS_UNIFORM_u_${r3}
- ${i4} ${o3} ${r3} = unpack_mix_${a3}(a_${r3}, u_${r3}_t);
- #else
- ${i4} ${o3} ${r3} = u_${r3};
- #endif
- `;
- }), staticAttributes: n2, staticUniforms: c2 };
- }
- class oi {
- constructor() {
- this.boundProgram = null, this.boundLayoutVertexBuffer = null, this.boundPaintVertexBuffers = [], this.boundIndexBuffer = null, this.boundVertexOffset = null, this.boundDynamicVertexBuffer = null, this.vao = null;
- }
- bind(e2, t2, i3, o2, r2, n2, a2, s2) {
- this.context = e2;
- let l2 = this.boundPaintVertexBuffers.length !== o2.length;
- for (let e3 = 0; !l2 && e3 < o2.length; e3++)
- this.boundPaintVertexBuffers[e3] !== o2[e3] && (l2 = true);
- 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);
- }
- freshBind(e2, t2, i3, o2, r2, n2, a2) {
- let s2;
- const l2 = e2.numAttributes, c2 = this.context, h2 = c2.gl;
- if (c2.extVertexArrayObject)
- 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;
- else {
- s2 = c2.currentNumAttributes || 0;
- for (let e3 = l2; e3 < s2; e3++)
- h2.disableVertexAttribArray(e3);
- }
- t2.enableAttributes(h2, e2);
- for (const t3 of i3)
- t3.enableAttributes(h2, e2);
- n2 && n2.enableAttributes(h2, e2), a2 && a2.enableAttributes(h2, e2), t2.bind(), t2.setVertexAttribPointers(h2, e2, r2);
- for (const t3 of i3)
- t3.bind(), t3.setVertexAttribPointers(h2, e2, r2);
- n2 && (n2.bind(), n2.setVertexAttribPointers(h2, e2, r2)), o2 && o2.bind(), a2 && (a2.bind(), a2.setVertexAttribPointers(h2, e2, r2)), c2.currentNumAttributes = l2;
- }
- destroy() {
- this.vao && (this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao), this.vao = null);
- }
- }
- function ri(t2, i3) {
- const o2 = Math.pow(2, i3.canonical.z), r2 = i3.canonical.y;
- return [new e.MercatorCoordinate(0, r2 / o2).toLngLat().lat, new e.MercatorCoordinate(0, (r2 + 1) / o2).toLngLat().lat];
- }
- function ni(t2, i3, o2, r2, n2, a2, s2) {
- const l2 = t2.context, c2 = l2.gl, h2 = o2.fbo;
- if (!h2)
- return;
- t2.prepareDrawTile();
- const _2 = t2.useProgram("hillshade");
- l2.activeTexture.set(c2.TEXTURE0), c2.bindTexture(c2.TEXTURE_2D, h2.colorAttachment.get());
- const u2 = ((e2, t3, i4, o3) => {
- const r3 = i4.paint.get("hillshade-shadow-color"), n3 = i4.paint.get("hillshade-highlight-color"), a3 = i4.paint.get("hillshade-accent-color");
- let s3 = i4.paint.get("hillshade-illumination-direction") * (Math.PI / 180);
- "viewport" === i4.paint.get("hillshade-illumination-anchor") && (s3 -= e2.transform.angle);
- const l3 = !e2.options.moving;
- 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 };
- })(t2, o2, r2, t2.terrain ? i3.projMatrix : null);
- t2.prepareDrawProgram(l2, _2, i3.toUnwrapped());
- const { tileBoundsBuffer: d2, tileBoundsIndexBuffer: p2, tileBoundsSegments: m2 } = t2.getTileBoundsBuffers(o2);
- _2.draw(l2, c2.TRIANGLES, n2, a2, s2, e.CullFaceMode.disabled, u2, r2.id, d2, p2, m2);
- }
- function ai(t2, i3, o2) {
- if (!i3.needsDEMTextureUpload)
- return;
- const r2 = t2.context, n2 = r2.gl;
- r2.pixelStoreUnpackPremultiplyAlpha.set(false), i3.demTexture = i3.demTexture || t2.getTileTexture(o2.stride);
- const a2 = o2.getPixels();
- i3.demTexture ? i3.demTexture.update(a2, { premultiply: false }) : i3.demTexture = new e.Texture(r2, a2, n2.RGBA, { premultiply: false }), i3.needsDEMTextureUpload = false;
- }
- function si(t2, i3, o2, r2, n2, a2) {
- const s2 = t2.context, l2 = s2.gl;
- if (!i3.dem)
- return;
- const c2 = i3.dem;
- if (s2.activeTexture.set(l2.TEXTURE1), ai(t2, i3, c2), !i3.demTexture)
- return;
- i3.demTexture.bind(l2.NEAREST, l2.CLAMP_TO_EDGE);
- const h2 = c2.dim;
- s2.activeTexture.set(l2.TEXTURE0);
- let _2 = i3.fbo;
- if (!_2) {
- const t3 = new e.Texture(s2, { width: h2, height: h2, data: null }, l2.RGBA);
- t3.bind(l2.LINEAR, l2.CLAMP_TO_EDGE), _2 = i3.fbo = s2.createFramebuffer(h2, h2, true), _2.colorAttachment.set(t3.texture);
- }
- s2.bindFramebuffer.set(_2.framebuffer), s2.viewport.set([0, 0, h2, h2]);
- const { tileBoundsBuffer: u2, tileBoundsIndexBuffer: d2, tileBoundsSegments: p2 } = t2.getMercatorTileBoundsBuffers();
- t2.useProgram("hillshadePrepare").draw(s2, l2.TRIANGLES, r2, n2, a2, e.CullFaceMode.disabled, ((t3, i4) => {
- const o3 = i4.stride, r3 = e.create();
- 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 };
- })(i3.tileID, c2), o2.id, u2, d2, p2), i3.needsHillshadePrepare = false;
- }
- 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) });
- function _i(e2, t2) {
- return null != e2 && null != t2 && !(!e2.hasData() || !t2.hasData()) && null != e2.demTexture && null != t2.demTexture && e2.tileID.key !== t2.tileID.key;
- }
- const ui = new class {
- constructor() {
- this.operations = {};
- }
- newMorphing(e2, t2, i3, o2, r2) {
- if (e2 in this.operations) {
- const t3 = this.operations[e2];
- t3.to.tileID.key !== i3.tileID.key && (t3.queued = i3);
- } else
- this.operations[e2] = { startTime: o2, phase: 0, duration: r2, from: t2, to: i3, queued: null };
- }
- getMorphValuesForProxy(e2) {
- if (!(e2 in this.operations))
- return null;
- const t2 = this.operations[e2];
- return { from: t2.from, to: t2.to, phase: t2.phase };
- }
- update(e2) {
- for (const t2 in this.operations) {
- const i3 = this.operations[t2];
- for (i3.phase = (e2 - i3.startTime) / i3.duration; i3.phase >= 1 || !this._validOp(i3); )
- if (!this._nextOp(i3, e2)) {
- delete this.operations[t2];
- break;
- }
- }
- }
- _nextOp(e2, t2) {
- return !!e2.queued && (e2.from = e2.to, e2.to = e2.queued, e2.queued = null, e2.phase = 0, e2.startTime = t2, true);
- }
- _validOp(e2) {
- return e2.from.hasData() && e2.to.hasData();
- }
- }(), di = { 0: null, 1: "TERRAIN_VERTEX_MORPHING", 2: "TERRAIN_WIREFRAME" };
- function pi(e2, t2) {
- const i3 = 1 << e2.z;
- return !t2 && (0 === e2.x || e2.x === i3 - 1) || 0 === e2.y || e2.y === i3 - 1;
- }
- const mi = (e2) => ({ u_matrix: e2 });
- function fi(t2, i3, o2, r2, n2) {
- if (n2 > 0) {
- 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);
- return t2.refreshedUponExpiration && s2 >= 1 && (t2.refreshedUponExpiration = false), i3 ? { opacity: 1, mix: 1 - u2 } : { opacity: u2, mix: 0 };
- }
- return { opacity: 1, mix: 0 };
- }
- const gi = 2 * e.mercatorZfromAltitude(1, 0) * e.GLOBE_RADIUS * Math.PI;
- class vi extends e.SourceCache {
- constructor(e2) {
- const t2 = { type: "raster-dem", maxzoom: e2.transform.maxZoom }, i3 = new A(Ue(), null), o2 = De("mock-dem", t2, i3, e2.style);
- super("mock-dem", o2, false), o2.setEventedParent(this), this._sourceLoaded = true;
- }
- _loadTile(e2, t2) {
- e2.state = "loaded", t2(null);
- }
- }
- class xi extends e.SourceCache {
- constructor(e2) {
- const t2 = De("proxy", { type: "geojson", maxzoom: e2.transform.maxZoom }, new A(Ue(), null), e2.style);
- super("proxy", t2, false), t2.setEventedParent(this), this.map = this.getSource().map = e2, this.used = this._sourceLoaded = true, this.renderCache = [], this.renderCachePool = [], this.proxyCachedFBO = {};
- }
- update(t2, i3, o2) {
- if (t2.freezeTileCoverage)
- return;
- this.transform = t2;
- 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) => {
- if (i4[o3.key] = "", !this._tiles[o3.key]) {
- const i5 = new e.Tile(o3, this._source.tileSize * o3.overscaleFactor(), t2.tileZoom);
- i5.state = "loaded", this._tiles[o3.key] = i5;
- }
- return i4;
- }, {});
- for (const e2 in this._tiles)
- e2 in r2 || (this.freeFBO(e2), this._tiles[e2].unloadVectorData(), delete this._tiles[e2]);
- }
- freeFBO(e2) {
- const t2 = this.proxyCachedFBO[e2];
- if (void 0 !== t2) {
- const i3 = Object.values(t2);
- this.renderCachePool.push(...i3), delete this.proxyCachedFBO[e2];
- }
- }
- deallocRenderCache() {
- this.renderCache.forEach((e2) => e2.fb.destroy()), this.renderCache = [], this.renderCachePool = [], this.proxyCachedFBO = {};
- }
- }
- class yi extends e.OverscaledTileID {
- constructor(e2, t2, i3) {
- super(e2.overscaledZ, e2.wrap, e2.canonical.z, e2.canonical.x, e2.canonical.y), this.proxyTileKey = t2, this.projMatrix = i3;
- }
- }
- class bi extends e.Elevation {
- constructor(t2, i3) {
- super(), this.painter = t2, this.terrainTileForTile = {}, this.prevTerrainTileForTile = {};
- const [o2, r2, n2] = function(t3) {
- const i4 = new e.StructArrayLayout4i8(), o3 = new e.StructArrayLayout3ui6(), r3 = 131;
- i4.reserve(17161), o3.reserve(33800);
- const n3 = e.EXTENT / 128, a3 = e.EXTENT + n3 / 2, s3 = a3 + n3;
- for (let t4 = -n3; t4 < s3; t4 += n3)
- for (let o4 = -n3; o4 < s3; o4 += n3) {
- 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);
- i4.emplaceBack(n4 + r4, s4, n4, s4);
- }
- const l2 = (e2, t4) => {
- const i5 = t4 * r3 + e2;
- o3.emplaceBack(i5 + 1, i5, i5 + r3), o3.emplaceBack(i5 + r3, i5 + r3 + 1, i5 + 1);
- };
- for (let e2 = 1; e2 < 129; e2++)
- for (let t4 = 1; t4 < 129; t4++)
- l2(t4, e2);
- return [0, 129].forEach((e2) => {
- for (let t4 = 0; t4 < 130; t4++)
- l2(t4, e2), l2(e2, t4);
- }), [i4, o3, 32768];
- }(), a2 = t2.context;
- 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);
- const s2 = a2.gl;
- 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);
- }
- set style(e2) {
- e2.on("data", this._onStyleDataEvent.bind(this)), e2.on("neworder", this._checkRenderCacheEfficiency.bind(this)), this._style = e2, this._checkRenderCacheEfficiency();
- }
- update(t2, i3, o2) {
- if (t2 && t2.terrain) {
- this._style !== t2 && (this.style = t2), this.enabled = true;
- const r2 = t2.terrain.properties;
- this.sourceCache = 0 === t2.terrain.drapeRenderMode ? this._mockSourceCache : t2._getSourceCache(r2.get("source")), this._exaggeration = r2.get("exaggeration");
- const n2 = () => {
- this.sourceCache.used && e.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.
- This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);
- const t3 = this.getScaledDemTileSize();
- this.sourceCache.update(i3, t3, true), this.resetTileLookupCache(this.sourceCache.id);
- };
- 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;
- } else
- this._disable();
- }
- resetTileLookupCache(e2) {
- this._findCoveringTileCache[e2] = {};
- }
- getScaledDemTileSize() {
- return this.sourceCache.getSource().tileSize / 128 * this.proxySourceCache.getSource().tileSize;
- }
- _checkRenderCacheEfficiency() {
- const t2 = this.renderCacheEfficiency(this._style);
- this._style.map._optimizeForTerrain || 100 !== t2.efficiency && e.warnOnce(`Terrain render cache efficiency is not optimal (${t2.efficiency}%) and performance
- may be affected negatively, consider placing all background, fill and line layers before layer
- with id '${t2.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`);
- }
- _onStyleDataEvent(e2) {
- e2.coord && "source" === e2.dataType ? this._clearRenderCacheForTile(e2.sourceCacheId, e2.coord) : "style" === e2.dataType && (this._invalidateRenderCache = true);
- }
- _disable() {
- if (this.enabled && (this.enabled = false, this._sharedDepthStencil = void 0, this.proxySourceCache.deallocRenderCache(), this._style))
- for (const e2 in this._style._sourceCaches)
- this._style._sourceCaches[e2].usedForTerrain = false;
- }
- destroy() {
- 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);
- }
- _source() {
- return this.enabled ? this.sourceCache : null;
- }
- exaggeration() {
- return this._exaggeration;
- }
- get visibleDemTiles() {
- return this._visibleDemTiles;
- }
- get drapeBufferSize() {
- const e2 = 2 * this.proxySourceCache.getSource().tileSize;
- return [e2, e2];
- }
- set useVertexMorphing(e2) {
- this._useVertexMorphing = e2;
- }
- updateTileBinding(t2) {
- if (!this.enabled)
- return;
- this.prevTerrainTileForTile = this.terrainTileForTile;
- const i3 = this.proxySourceCache, o2 = this.painter.transform;
- this._initializing && (this._initializing = 0 === o2._centerAltitude && -1 === this.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(o2.center), -1), this._emptyDEMTextureDirty = !this._initializing);
- const r2 = this.proxyCoords = i3.getIds().map((e2) => {
- const t3 = i3.getTileByID(e2).tileID;
- return t3.projMatrix = o2.calculateProjMatrix(t3.toUnwrapped()), t3;
- });
- !function(t3, i4) {
- const o3 = i4.transform.pointCoordinate(i4.transform.getCameraPoint()), r3 = new e.pointGeometry(o3.x, o3.y);
- t3.sort((t4, i5) => {
- if (i5.overscaledZ - t4.overscaledZ)
- return i5.overscaledZ - t4.overscaledZ;
- 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);
- return a3.x -= 0.5, a3.y -= 0.5, a3.distSqr(o4) - a3.distSqr(n3);
- });
- }(r2, this.painter), this._previousZoom = o2.zoom;
- const n2 = this.proxyToSource || {};
- this.proxyToSource = {}, r2.forEach((e2) => {
- this.proxyToSource[e2.key] = {};
- }), this.terrainTileForTile = {};
- const a2 = this._style._sourceCaches;
- for (const e2 in a2) {
- const i4 = a2[e2];
- if (!i4.used)
- continue;
- if (i4 !== this.sourceCache && this.resetTileLookupCache(i4.id), this._setupProxiedCoordsForOrtho(i4, t2[e2], n2), i4.usedForTerrain)
- continue;
- const o3 = t2[e2];
- i4.getSource().reparseOverscaled && this._assignTerrainTiles(o3);
- }
- 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();
- const s2 = {};
- this._visibleDemTiles = [];
- for (const e2 of this.proxyCoords) {
- const t3 = this.terrainTileForTile[e2.key];
- if (!t3)
- continue;
- const i4 = t3.tileID.key;
- i4 in s2 || (this._visibleDemTiles.push(t3), s2[i4] = i4);
- }
- }
- _assignTerrainTiles(e2) {
- this._initializing || e2.forEach((e3) => {
- if (this.terrainTileForTile[e3.key])
- return;
- const t2 = this._findTileCoveringTileID(e3, this.sourceCache);
- t2 && (this.terrainTileForTile[e3.key] = t2);
- });
- }
- _prepareDEMTextures() {
- const e2 = this.painter.context, t2 = e2.gl;
- for (const i3 in this.terrainTileForTile) {
- const o2 = this.terrainTileForTile[i3], r2 = o2.dem;
- !r2 || o2.demTexture && !o2.needsDEMTextureUpload || (e2.activeTexture.set(t2.TEXTURE1), ai(this.painter, o2, r2));
- }
- }
- _prepareDemTileUniforms(e2, t2, i3, o2) {
- if (!t2 || null == t2.demTexture)
- return false;
- const r2 = e2.tileID.canonical, n2 = Math.pow(2, t2.tileID.canonical.z - r2.z), a2 = o2 || "";
- return i3[`u_dem_tl${a2}`] = [r2.x * n2 % 1, r2.y * n2 % 1], i3[`u_dem_scale${a2}`] = n2, true;
- }
- get emptyDEMTexture() {
- return !this._emptyDEMTextureDirty && this._emptyDEMTexture ? this._emptyDEMTexture : this._updateEmptyDEMTexture();
- }
- get emptyDepthBufferTexture() {
- const t2 = this.painter.context, i3 = t2.gl;
- if (!this._emptyDepthBufferTexture) {
- const o2 = new e.RGBAImage({ width: 1, height: 1 }, Uint8Array.of(255, 255, 255, 255));
- this._emptyDepthBufferTexture = new e.Texture(t2, o2, i3.RGBA, { premultiply: false });
- }
- return this._emptyDepthBufferTexture;
- }
- _getLoadedAreaMinimum() {
- let e2 = 0;
- const t2 = this._visibleDemTiles.reduce((t3, i3) => {
- if (!i3.dem)
- return t3;
- const o2 = i3.dem.tree.minimums[0];
- return o2 > 0 && e2++, t3 + o2;
- }, 0);
- return e2 ? t2 / e2 : 0;
- }
- _updateEmptyDEMTexture() {
- const t2 = this.painter.context, i3 = t2.gl;
- t2.activeTexture.set(i3.TEXTURE2);
- const o2 = this._getLoadedAreaMinimum(), r2 = new e.RGBAImage({ width: 1, height: 1 }, new Uint8Array(e.DEMData.pack(o2, this.sourceCache.getSource().encoding)));
- this._emptyDEMTextureDirty = false;
- let n2 = this._emptyDEMTexture;
- return n2 ? n2.update(r2, { premultiply: false }) : n2 = this._emptyDEMTexture = new e.Texture(t2, r2, i3.RGBA, { premultiply: false }), n2;
- }
- setupElevationDraw(t2, i3, o2) {
- 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 });
- var s2;
- a2.u_dem_size = this.sourceCache.getSource().tileSize, a2.u_exaggeration = this.exaggeration();
- const l2 = this.painter.transform, c2 = l2.projection, h2 = t2.tileID.canonical;
- 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;
- let _2 = null, u2 = null, d2 = 1;
- if (o2 && o2.morphing && this._useVertexMorphing) {
- const e2 = o2.morphing.srcDemTile, i4 = o2.morphing.dstDemTile;
- d2 = o2.morphing.phase, e2 && i4 && (this._prepareDemTileUniforms(t2, e2, a2, "_prev") && (u2 = e2), this._prepareDemTileUniforms(t2, i4, a2) && (_2 = i4));
- }
- 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) {
- const t3 = (1 << _2.tileID.canonical.z) * e.mercatorZfromAltitude(1, this.painter.transform.center.lat) * this.sourceCache.getSource().tileSize;
- a2.u_meter_to_dem = t3;
- }
- o2 && o2.labelPlaneMatrixInv && (a2.u_label_plane_matrix_inv = o2.labelPlaneMatrixInv), i3.setTerrainUniformValues(r2, a2);
- }
- renderToBackBuffer(t2) {
- const i3 = this.painter, o2 = this.painter.context;
- 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) {
- if ("globe" === t3.transform.projection.name)
- !function(t4, i5, o4, r3, n3) {
- const a2 = t4.context, s2 = a2.gl;
- let l2, c2;
- const h2 = t4.options.showTerrainWireframe ? 2 : 0, _2 = (e2, i6) => {
- if (c2 === e2)
- return;
- const o5 = [di[e2], "PROJECTION_GLOBE_VIEW"];
- i6 && o5.push(di[h2]), l2 = t4.useProgram("globeRaster", null, o5), c2 = e2;
- }, u2 = t4.colorModeForRenderPass(), d2 = new e.DepthMode(s2.LEQUAL, e.DepthMode.ReadWrite, t4.depthRangeFor3D);
- ui.update(n3);
- const p2 = t4.transform, m2 = e.calculateGlobeMercatorMatrix(p2), f2 = [e.mercatorXfromLng(p2.center.lng), e.mercatorYfromLat(p2.center.lat)], g2 = t4.globeSharedBuffers;
- if ((h2 ? [false, true] : [false]).forEach((h3) => {
- c2 = -1;
- const v2 = h3 ? s2.LINES : s2.TRIANGLES;
- for (const c3 of r3) {
- const r4 = o4.getTile(c3), x2 = e.StencilMode.disabled, y2 = i5.prevTerrainTileForTile[c3.key], b2 = i5.terrainTileForTile[c3.key];
- _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);
- const w2 = ui.getMorphValuesForProxy(c3.key), T2 = w2 ? 1 : 0, E2 = { useDenormalizedUpVectorScale: true };
- w2 && e.extend$1(E2, { morphing: { srcDemTile: w2.from, dstDemTile: w2.to, phase: e.easeCubicInOut(w2.phase) } });
- 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);
- if (_2(T2, h3), i5.setupElevationDraw(r4, l2, E2), t4.prepareDrawProgram(a2, l2, c3.toUnwrapped()), g2) {
- const [i6, o5, r5] = h3 ? g2.getWirefameBuffers(t4.context) : g2.getGridBuffers();
- l2.draw(a2, v2, d2, x2, u2, e.CullFaceMode.backCCW, S2, "globe_raster", i6, o5, r5);
- }
- }
- }), g2) {
- l2 = t4.useProgram("globeRaster", null, ["GLOBE_POLES", "PROJECTION_GLOBE_VIEW"]);
- for (const n4 of r3) {
- const { x: r4, y: c3, z: h3 } = n4.canonical, _3 = 0 === c3, m3 = c3 === (1 << h3) - 1, [v2, x2, y2, b2] = g2.getPoleBuffers(h3);
- if (b2 && (_3 || m3)) {
- const c4 = o4.getTile(n4);
- a2.activeTexture.set(s2.TEXTURE0), c4.texture.bind(s2.LINEAR, s2.CLAMP_TO_EDGE);
- let g3 = e.globePoleMatrixForTile(h3, r4, p2);
- 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);
- 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));
- }
- }
- }
- }(t3, i4, o3, r2, n2);
- else {
- const a2 = t3.context, s2 = a2.gl;
- let l2, c2;
- const h2 = t3.options.showTerrainWireframe ? 2 : 0, _2 = (e2, i5) => {
- if (c2 === e2)
- return;
- const o4 = [di[e2]];
- i5 && o4.push(di[h2]), l2 = t3.useProgram("terrainRaster", null, o4), c2 = e2;
- }, u2 = t3.colorModeForRenderPass(), d2 = new e.DepthMode(s2.LEQUAL, e.DepthMode.ReadWrite, t3.depthRangeFor3D);
- ui.update(n2);
- const p2 = t3.transform, m2 = 6 * Math.pow(1.5, 22 - p2.zoom) * i4.exaggeration();
- (h2 ? [false, true] : [false]).forEach((h3) => {
- c2 = -1;
- const f2 = h3 ? s2.LINES : s2.TRIANGLES, [g2, v2] = h3 ? i4.getWirefameBuffer() : [i4.gridIndexBuffer, i4.gridSegments];
- for (const c3 of r2) {
- const r3 = o3.getTile(c3), x2 = e.StencilMode.disabled, y2 = i4.prevTerrainTileForTile[c3.key], b2 = i4.terrainTileForTile[c3.key];
- _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);
- const w2 = ui.getMorphValuesForProxy(c3.key), T2 = w2 ? 1 : 0;
- let E2;
- w2 && (E2 = { morphing: { srcDemTile: w2.from, dstDemTile: w2.to, phase: e.easeCubicInOut(w2.phase) } });
- const C2 = ci(c3.projMatrix, pi(c3.canonical, p2.renderWorldCopies) ? m2 / 10 : m2);
- _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);
- }
- });
- }
- }(i3, this, this.proxySourceCache, t2, this._updateTimestamp), this.renderingToTexture = true, t2.splice(0, t2.length));
- }
- renderBatch(t2) {
- if (0 === this._drapedRenderBatches.length)
- return t2 + 1;
- this.renderingToTexture = true;
- 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;
- let c2 = 0;
- for (const h2 of n2) {
- 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;
- if (n3.texture = u2.tex, d2 && !u2.dirty) {
- s2.push(n3.tileID);
- continue;
- }
- let p2;
- o2.bindFramebuffer.set(u2.fb.framebuffer), this.renderedToTile = false, u2.dirty && (o2.clear({ color: e.Color.transparent, stencil: 0 }), u2.dirty = false);
- for (let e2 = a2.start; e2 <= a2.end; ++e2) {
- const t3 = i3.style._layers[l2[e2]];
- if (t3.isHidden(i3.transform.zoom))
- continue;
- const r3 = i3.style._getLayerSourceCache(t3), n4 = r3 ? this.proxyToSource[h2.key][r3.id] : [h2];
- if (!n4)
- continue;
- const a3 = n4;
- 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);
- }
- this.renderedToTile ? (u2.dirty = true, s2.push(n3.tileID)) : d2 || --c2, 5 === c2 && (c2 = 0, this.renderToBackBuffer(s2));
- }
- return this.renderToBackBuffer(s2), this.renderingToTexture = false, o2.bindFramebuffer.set(null), o2.viewport.set([0, 0, i3.width, i3.height]), a2.end + 1;
- }
- postRender() {
- }
- renderCacheEfficiency(e2) {
- const t2 = e2.order.length;
- if (0 === t2)
- return { efficiency: 100 };
- let i3, o2 = 0, r2 = 0, n2 = false;
- for (let a2 = 0; a2 < t2; ++a2) {
- const t3 = e2._layers[e2.order[a2]];
- this._style.isLayerDraped(t3) ? (n2 && ++o2, ++r2) : n2 || (n2 = true, i3 = t3.id);
- }
- return 0 === r2 ? { efficiency: 100 } : { efficiency: 100 * (1 - o2 / r2), firstUndrapedLayer: i3 };
- }
- getMinElevationBelowMSL() {
- let e2 = 0;
- return this._visibleDemTiles.filter((e3) => e3.dem).forEach((t2) => {
- e2 = Math.min(e2, t2.dem.tree.minimums[0]);
- }), 0 === e2 ? e2 : (e2 - 30) * this._exaggeration;
- }
- raycast(e2, t2, i3) {
- if (!this._visibleDemTiles)
- return null;
- const o2 = this._visibleDemTiles.filter((e3) => e3.dem).map((o3) => {
- 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;
- return { minx: l2, miny: h2, maxx: c2, maxy: _2, t: o3.dem.tree.raycastRoot(l2, h2, c2, _2, e2, t2, i3), tile: o3 };
- });
- o2.sort((e3, t3) => (null !== e3.t ? e3.t : Number.MAX_VALUE) - (null !== t3.t ? t3.t : Number.MAX_VALUE));
- for (const r2 of o2) {
- if (null == r2.t)
- return null;
- const o3 = r2.tile.dem.tree.raycast(r2.minx, r2.miny, r2.maxx, r2.maxy, e2, t2, i3);
- if (null != o3)
- return o3;
- }
- return null;
- }
- _createFBO() {
- const t2 = this.painter.context, i3 = t2.gl, o2 = this.drapeBufferSize;
- t2.activeTexture.set(i3.TEXTURE0);
- const r2 = new e.Texture(t2, { width: o2[0], height: o2[1], data: null }, i3.RGBA);
- r2.bind(i3.LINEAR, i3.CLAMP_TO_EDGE);
- const n2 = t2.createFramebuffer(o2[0], o2[1], false);
- 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 };
- }
- _initFBOPool() {
- for (; this.pool.length < Math.min(5, this.proxyCoords.length); )
- this.pool.push(this._createFBO());
- }
- _shouldDisableRenderCache() {
- if (this._style.light && this._style.light.hasTransition())
- return true;
- for (const e2 in this._style._sourceCaches)
- if (this._style._sourceCaches[e2].hasTransition())
- return true;
- return this._style.order.some((e2) => {
- const t2 = this._style._layers[e2], i3 = t2.isHidden(this.painter.transform.zoom), o2 = t2.getCrossfadeParameters(), r2 = !!o2 && 1 !== o2.t, n2 = t2.hasTransition();
- return "custom" !== t2.type && !i3 && (r2 || n2);
- });
- }
- _clearRasterFadeFromRenderCache() {
- let e2 = false;
- for (const t2 in this._style._sourceCaches)
- if (this._style._sourceCaches[t2]._source instanceof Ce) {
- e2 = true;
- break;
- }
- if (e2)
- for (let e3 = 0; e3 < this._style.order.length; ++e3) {
- const t2 = this._style._layers[this._style.order[e3]], i3 = t2.isHidden(this.painter.transform.zoom), o2 = this._style._getLayerSourceCache(t2);
- if ("raster" !== t2.type || i3 || !o2)
- continue;
- const r2 = t2.paint.get("raster-fade-duration");
- for (const e4 of this.proxyCoords) {
- const t3 = this.proxyToSource[e4.key][o2.id];
- if (t3)
- for (const e5 of t3) {
- const t4 = fi(o2.getTile(e5), o2.findLoadedParent(e5, 0), o2, this.painter.transform, r2);
- (1 !== t4.opacity || 0 !== t4.mix) && this._clearRenderCacheForTile(o2.id, e5);
- }
- }
- }
- }
- _setupDrapedRenderBatches() {
- const e2 = this._style.order, t2 = e2.length;
- if (0 === t2)
- return;
- const i3 = [];
- let o2, r2 = 0, n2 = this._style._layers[e2[r2]];
- for (; !this._style.isLayerDraped(n2) && n2.isHidden(this.painter.transform.zoom) && ++r2 < t2; )
- n2 = this._style._layers[e2[r2]];
- for (; r2 < t2; ++r2) {
- const t3 = this._style._layers[e2[r2]];
- 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));
- }
- void 0 !== o2 && i3.push({ start: o2, end: r2 - 1 }), this._drapedRenderBatches = i3;
- }
- _setupRenderCache(e2) {
- const t2 = this.proxySourceCache;
- if (this._shouldDisableRenderCache() || this._invalidateRenderCache) {
- if (this._invalidateRenderCache = false, t2.renderCache.length > t2.renderCachePool.length) {
- const e3 = Object.values(t2.proxyCachedFBO);
- t2.proxyCachedFBO = {};
- for (let i4 = 0; i4 < e3.length; ++i4) {
- const o3 = Object.values(e3[i4]);
- t2.renderCachePool.push(...o3);
- }
- }
- return;
- }
- this._clearRasterFadeFromRenderCache();
- const i3 = this.proxyCoords, o2 = this._tilesDirty;
- for (let r3 = i3.length - 1; r3 >= 0; r3--) {
- const n2 = i3[r3];
- if (t2.getTileByID(n2.key), void 0 !== t2.proxyCachedFBO[n2.key]) {
- const i4 = e2[n2.key], r4 = this.proxyToSource[n2.key];
- let a2 = 0;
- for (const e3 in r4) {
- const t3 = r4[e3], n3 = i4[e3];
- if (!n3 || n3.length !== t3.length || t3.some((t4, i5) => t4 !== n3[i5] || o2[e3] && o2[e3].hasOwnProperty(t4.key))) {
- a2 = -1;
- break;
- }
- ++a2;
- }
- for (const e3 in t2.proxyCachedFBO[n2.key])
- t2.renderCache[t2.proxyCachedFBO[n2.key][e3]].dirty = a2 < 0 || a2 !== Object.values(i4).length;
- }
- }
- const r2 = [...this._drapedRenderBatches];
- r2.sort((e3, t3) => t3.end - t3.start - (e3.end - e3.start));
- for (const e3 of r2)
- for (const o3 of i3) {
- if (t2.proxyCachedFBO[o3.key])
- continue;
- let i4 = t2.renderCachePool.pop();
- 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);
- }
- this._tilesDirty = {};
- }
- _setupStencil(e2, t2, i3, o2) {
- if (!o2 || !this._sourceTilesOverlap[o2.id])
- return void (this._overlapStencilType && (this._overlapStencilType = false));
- const r2 = this.painter.context, n2 = r2.gl;
- if (t2.length <= 1)
- return void (this._overlapStencilType = false);
- let a2;
- if (i3.isTileClipped())
- a2 = t2.length, this._overlapStencilMode.test = { func: n2.EQUAL, mask: 255 }, this._overlapStencilType = "Clip";
- else {
- if (!(t2[0].overscaledZ > t2[t2.length - 1].overscaledZ))
- return void (this._overlapStencilType = false);
- a2 = 1, this._overlapStencilMode.test = { func: n2.GREATER, mask: 255 }, this._overlapStencilType = "Mask";
- }
- 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);
- }
- clipOrMaskOverlapStencilType() {
- return "Clip" === this._overlapStencilType || "Mask" === this._overlapStencilType;
- }
- stencilModeForRTTOverlap(t2) {
- return this.renderingToTexture && this._overlapStencilType ? ("Clip" === this._overlapStencilType && (this._overlapStencilMode.ref = this.painter._tileClippingMaskIDs.get(t2.key) || 0), this._overlapStencilMode) : e.StencilMode.disabled;
- }
- _renderTileClippingMasks(t2, i3) {
- const o2 = this.painter, r2 = this.painter.context, n2 = r2.gl;
- o2._tileClippingMaskIDs.clear(), r2.setColorMode(e.ColorMode.disabled), r2.setDepthMode(e.DepthMode.disabled);
- const a2 = o2.useProgram("clippingMask");
- for (const s2 of t2) {
- const t3 = --i3;
- 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);
- }
- }
- pointCoordinate(t2) {
- const i3 = this.painter.transform;
- if (t2.x < 0 || t2.x > i3.width || t2.y < 0 || t2.y > i3.height)
- return null;
- const o2 = [t2.x, t2.y, 1, 1];
- e.transformMat4$1(o2, o2, i3.pixelMatrixInverse), e.scale$1(o2, o2, 1 / o2[3]), o2[0] /= i3.worldSize, o2[1] /= i3.worldSize;
- 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);
- e.normalize(s2, s2);
- const l2 = this.raycast(a2, s2, this._exaggeration);
- return null !== l2 && l2 ? (e.scaleAndAdd(a2, a2, s2, l2), a2[3] = a2[2], a2[2] *= n2, a2) : null;
- }
- drawDepth() {
- const t2 = this.painter, i3 = t2.context, o2 = this.proxySourceCache, r2 = Math.ceil(t2.width), n2 = Math.ceil(t2.height);
- if (!this._depthFBO || this._depthFBO.width === r2 && this._depthFBO.height === n2 || (this._depthFBO.destroy(), this._depthFBO = void 0, this._depthTexture = void 0), !this._depthFBO) {
- const t3 = i3.gl, o3 = i3.createFramebuffer(r2, n2, true);
- i3.activeTexture.set(t3.TEXTURE0);
- const a2 = new e.Texture(i3, { width: r2, height: n2, data: null }, t3.RGBA);
- a2.bind(t3.NEAREST, t3.CLAMP_TO_EDGE), o3.colorAttachment.set(a2.texture);
- const s2 = i3.createRenderbuffer(i3.gl.DEPTH_COMPONENT16, r2, n2);
- o3.depthAttachment.set(s2), this._depthFBO = o3, this._depthTexture = a2;
- }
- i3.bindFramebuffer.set(this._depthFBO.framebuffer), i3.viewport.set([0, 0, r2, n2]), function(t3, i4, o3, r3) {
- if ("globe" === t3.transform.projection.name)
- return;
- const n3 = t3.context, a2 = n3.gl;
- n3.clear({ depth: 1 });
- const s2 = t3.useProgram("terrainDepth"), l2 = new e.DepthMode(a2.LESS, e.DepthMode.ReadWrite, t3.depthRangeFor3D);
- for (const t4 of r3) {
- const r4 = o3.getTile(t4), c2 = ci(t4.projMatrix, 0);
- 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);
- }
- }(t2, this, o2, this.proxyCoords);
- }
- _setupProxiedCoordsForOrtho(e2, t2, i3) {
- if (e2.getSource() instanceof Se)
- return this._setupProxiedCoordsForImageSource(e2, t2, i3);
- this._findCoveringTileCache[e2.id] = this._findCoveringTileCache[e2.id] || {};
- const o2 = this.proxiedCoords[e2.id] = [], r2 = this.proxyCoords;
- for (let t3 = 0; t3 < r2.length; t3++) {
- const n3 = r2[t3], a2 = this._findTileCoveringTileID(n3, e2);
- if (a2) {
- const t4 = this._createProxiedId(n3, a2, i3[n3.key] && i3[n3.key][e2.id]);
- o2.push(t4), this.proxyToSource[n3.key][e2.id] = [t4];
- }
- }
- let n2 = false;
- for (let r3 = 0; r3 < t2.length; r3++) {
- const a2 = e2.getTile(t2[r3]);
- if (!a2 || !a2.hasData())
- continue;
- const s2 = this._findTileCoveringTileID(a2.tileID, this.proxySourceCache);
- if (s2 && s2.tileID.canonical.z !== a2.tileID.canonical.z) {
- 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]);
- t3 ? t3.splice(t3.length - 1, 0, r4) : this.proxyToSource[s2.tileID.key][e2.id] = [r4], o2.push(r4), n2 = true;
- }
- }
- this._sourceTilesOverlap[e2.id] = n2;
- }
- _setupProxiedCoordsForImageSource(t2, i3, o2) {
- if (!t2.getSource().loaded())
- return;
- 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) => {
- 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);
- return o3 + n3 < a3 + l2.min.x || o3 > a3 + l2.max.x || r3 + n3 < s3 + l2.min.y || r3 > s3 + l2.max.y;
- };
- for (let e2 = 0; e2 < n2.length; e2++) {
- const a3 = n2[e2];
- for (let e3 = 0; e3 < i3.length; e3++) {
- const n3 = t2.getTile(i3[e3]);
- if (!n3 || !n3.hasData())
- continue;
- if (c2(a3, n3.tileID))
- continue;
- const s3 = this._createProxiedId(a3, n3, o2[a3.key] && o2[a3.key][t2.id]), l3 = this.proxyToSource[a3.key][t2.id];
- l3 ? l3.push(s3) : this.proxyToSource[a3.key][t2.id] = [s3], r2.push(s3);
- }
- }
- }
- _createProxiedId(t2, i3, o2) {
- let r2 = this.orthoMatrix;
- if (o2) {
- const e2 = o2.find((e3) => e3.key === i3.tileID.key);
- if (e2)
- return e2;
- }
- if (i3.tileID.key !== t2.key) {
- const o3 = t2.canonical.z - i3.tileID.canonical.z;
- let n2, a2, s2;
- r2 = e.create();
- const l2 = i3.tileID.wrap - t2.wrap << t2.overscaledZ;
- 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]);
- }
- return new yi(i3.tileID, t2.key, r2);
- }
- _findTileCoveringTileID(t2, i3) {
- let o2 = i3.getTile(t2);
- if (o2 && o2.hasData())
- return o2;
- const r2 = this._findCoveringTileCache[i3.id], n2 = r2[t2.key];
- if (o2 = n2 ? i3.getTileByID(n2) : null, o2 && o2.hasData() || null === n2)
- return o2;
- let a2 = o2 ? o2.tileID : t2, s2 = a2.overscaledZ;
- const l2 = i3.getSource().minzoom, c2 = [];
- if (!n2) {
- const r3 = i3.getSource().maxzoom;
- if (t2.canonical.z >= r3) {
- const o3 = t2.canonical.z - r3;
- 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));
- }
- a2.key !== t2.key && (c2.push(a2.key), o2 = i3.getTile(a2));
- }
- const h2 = (e2) => {
- c2.forEach((t3) => {
- r2[t3] = e2;
- }), c2.length = 0;
- };
- for (s2 -= 1; s2 >= l2 && (!o2 || !o2.hasData()); s2--) {
- o2 && h2(o2.tileID.key);
- const e2 = a2.calculateScaledKey(s2);
- if (o2 = i3.getTileByID(e2), o2 && o2.hasData())
- break;
- const t3 = r2[e2];
- if (null === t3)
- break;
- void 0 === t3 ? c2.push(e2) : o2 = i3.getTileByID(t3);
- }
- return h2(o2 ? o2.tileID.key : null), o2 && o2.hasData() ? o2 : null;
- }
- findDEMTileFor(e2) {
- return this.enabled ? this._findTileCoveringTileID(e2, this.sourceCache) : null;
- }
- prepareDrawTile() {
- this.renderedToTile = true;
- }
- _clearRenderCacheForTile(e2, t2) {
- let i3 = this._tilesDirty[e2];
- i3 || (i3 = this._tilesDirty[e2] = {}), i3[t2.key] = true;
- }
- getWirefameBuffer() {
- if (!this.wireframeSegments) {
- const t2 = function(t3) {
- let i3 = 0;
- const o2 = new e.StructArrayLayout2ui4(), r2 = 131;
- for (let e2 = 1; e2 < 129; e2++) {
- for (let t4 = 1; t4 < 129; t4++)
- 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);
- o2.emplaceBack(i3 + 1, i3 + 1 + r2);
- }
- return o2;
- }();
- this.wireframeIndexBuffer = this.painter.context.createIndexBuffer(t2), this.wireframeSegments = e.SegmentVector.simpleSegment(0, 0, this.gridBuffer.length, t2.length);
- }
- return [this.wireframeIndexBuffer, this.wireframeSegments];
- }
- }
- function wi(e2) {
- const t2 = [];
- for (let i3 = 0; i3 < e2.length; i3++) {
- if (null === e2[i3])
- continue;
- const o2 = e2[i3].split(" ");
- t2.push(o2.pop());
- }
- return t2;
- }
- class Ti {
- static cacheKey(e2, t2, i3) {
- let o2 = `${e2}${i3 ? i3.cacheKey : ""}`;
- for (const e3 of t2)
- o2 += `/${e3}`;
- return o2;
- }
- constructor(t2, i3, o2, r2, n2, a2) {
- const s2 = t2.gl;
- this.program = s2.createProgram();
- 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 = [];
- for (const e2 of d2)
- p2.indexOf(e2) < 0 && p2.push(e2);
- let m2 = r2 ? r2.defines() : [];
- m2 = m2.concat(a2.map((e2) => `#define ${e2}`));
- 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);
- if (s2.isContextLost())
- return void (this.failedToCreate = true);
- s2.shaderSource(v2, f2), s2.compileShader(v2), s2.attachShader(this.program, v2);
- const x2 = s2.createShader(s2.VERTEX_SHADER);
- if (s2.isContextLost())
- return void (this.failedToCreate = true);
- s2.shaderSource(x2, g2), s2.compileShader(x2), s2.attachShader(this.program, x2), this.attributes = {};
- const y2 = {};
- this.numAttributes = h2.length;
- for (let e2 = 0; e2 < this.numAttributes; e2++)
- h2[e2] && (s2.bindAttribLocation(this.program, e2, h2[e2]), this.attributes[h2[e2]] = e2);
- s2.linkProgram(this.program), s2.deleteShader(x2), s2.deleteShader(v2);
- for (let e2 = 0; e2 < p2.length; e2++) {
- const t3 = p2[e2];
- if (t3 && !y2[t3]) {
- const e3 = s2.getUniformLocation(this.program, t3);
- e3 && (y2[t3] = e3);
- }
- }
- 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));
- }
- setTerrainUniformValues(e2, t2) {
- if (!this.terrainUniforms)
- return;
- const i3 = this.terrainUniforms;
- if (!this.failedToCreate) {
- e2.program.set(this.program);
- for (const e3 in t2)
- i3[e3].set(t2[e3]);
- }
- }
- setFogUniformValues(e2, t2) {
- if (!this.fogUniforms)
- return;
- const i3 = this.fogUniforms;
- if (!this.failedToCreate) {
- e2.program.set(this.program);
- for (const e3 in t2)
- i3[e3].location && i3[e3].set(t2[e3]);
- }
- }
- draw(e2, t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2, d2, p2, m2) {
- const f2 = e2.gl;
- if (this.failedToCreate)
- return;
- e2.program.set(this.program), e2.setDepthMode(i3), e2.setStencilMode(o2), e2.setColorMode(r2), e2.setCullFace(n2);
- for (const e3 of Object.keys(this.fixedUniforms))
- this.fixedUniforms[e3].set(a2[e3]);
- d2 && d2.setUniforms(e2, this.binderUniforms, _2, { zoom: u2 });
- const g2 = { [f2.LINES]: 2, [f2.TRIANGLES]: 3, [f2.LINE_STRIP]: 1 }[t2];
- for (const i4 of h2.get()) {
- const o3 = i4.vaos || (i4.vaos = {});
- (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);
- }
- }
- }
- function Ei(e2, t2, i3) {
- 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;
- 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] };
- }
- const Ci = e.create(), Ii = (t2, i3, o2, r2, n2, a2, s2, l2, c2) => {
- const h2 = i3.style.light, _2 = h2.properties.get("position"), u2 = [_2.x, _2.y, _2.z], d2 = e.create$1();
- "viewport" === h2.properties.get("anchor") && (e.fromRotation(d2, -i3.transform.angle), e.transformMat3(u2, u2, d2));
- 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 };
- 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;
- }, Mi = (t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2) => {
- const u2 = Ii(t2, i3, o2, r2, n2, l2, c2, h2, _2), d2 = { u_height_factor: -Math.pow(2, n2.overscaledZ) / s2.tileSize / 8 };
- return e.extend(u2, Ei(a2, i3, s2), d2);
- }, 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) => {
- const s2 = t2.transform, l2 = "globe" === s2.projection.name;
- let c2;
- if ("map" === a2.paint.get("circle-pitch-alignment"))
- if (l2) {
- const t3 = e.globePixelsToTileUnits(s2.zoom, i3.canonical);
- c2 = Float32Array.from([t3, 0, 0, t3]);
- } else
- c2 = s2.calculatePixelsToTileUnitsMatrix(o2);
- else
- c2 = new Float32Array([s2.pixelsToGLUnits[0], 0, 0, s2.pixelsToGLUnits[1]]);
- 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] };
- 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;
- }, Ri = (e2) => {
- const t2 = [];
- 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;
- }, ki = (t2, i3, o2) => {
- const r2 = e.EXTENT / o2.tileSize;
- return { u_matrix: t2, u_camera_to_center_distance: i3.cameraToCenterDistance, u_extrude_scale: [i3.pixelsToGLUnits[0] / r2, i3.pixelsToGLUnits[1] / r2] };
- }, 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) => {
- 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] };
- 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;
- }, Ui = (e2, t2, i3, o2, r2, n2, a2) => {
- 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 };
- if (Zi(i3)) {
- const i4 = Gi(t2, e2.transform);
- c2.u_texsize = t2.lineAtlasTexture.size, c2.u_scale = [i4, o2.fromScale, o2.toScale], c2.u_mix = o2.t;
- }
- return c2;
- }, Ni = (e2, t2, i3, o2, r2, n2) => {
- const a2 = e2.transform, s2 = Gi(t2, a2);
- 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 };
- };
- function Gi(e2, t2) {
- return 1 / L(e2, 1, t2.tileZoom);
- }
- function ji(e2, t2, i3, o2) {
- return e2.translatePosMatrix(o2 || t2.tileID.projMatrix, t2, i3.paint.get("line-translate"), i3.paint.get("line-translate-anchor"));
- }
- function Zi(e2) {
- const t2 = e2.paint.get("line-dasharray").value;
- return t2.value || "constant" !== t2.kind;
- }
- const Vi = (e2, t2, i3, o2, r2, n2) => {
- 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 };
- var a2, s2;
- };
- function Wi(e2) {
- e2 *= Math.PI / 180;
- const t2 = Math.sin(e2), i3 = Math.cos(e2);
- return [(2 * i3 + 1) / 3, (-Math.sqrt(3) * t2 - i3 + 1) / 3, (Math.sqrt(3) * t2 - i3 + 1) / 3];
- }
- const qi = e.create(), Xi = (t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2, d2, p2) => {
- 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 };
- 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;
- }, $i = (t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2, d2, p2, m2) => {
- const { cameraToCenterDistance: f2, _pitch: g2 } = n2.transform;
- 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 });
- }, 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) {
- 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;
- 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] };
- }(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) }) };
- let Qi;
- function eo(t2, i3, o2, r2, n2, a2, s2) {
- const l2 = t2.context, c2 = l2.gl, h2 = t2.useProgram("collisionBox"), _2 = [];
- let u2 = 0, d2 = 0;
- for (let p3 = 0; p3 < r2.length; p3++) {
- const m3 = r2[p3], f3 = i3.getTile(m3), g3 = f3.getBucket(o2);
- if (!g3)
- continue;
- let v3 = m3.projMatrix;
- 0 === n2[0] && 0 === n2[1] || (v3 = t2.translatePosMatrix(m3.projMatrix, f3, n2, a2));
- const x3 = s2 ? g3.textCollisionBox : g3.iconCollisionBox, y2 = g3.collisionCircleArray;
- if (y2.length > 0) {
- const i4 = e.create(), o3 = v3;
- 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;
- }
- 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));
- }
- if (!s2 || !_2.length)
- return;
- const p2 = t2.useProgram("collisionCircle"), m2 = new e.StructArrayLayout2f1f2i16();
- m2.resize(4 * u2), m2._trim();
- let f2 = 0;
- for (const e2 of _2)
- for (let t3 = 0; t3 < e2.circleArray.length / 4; t3++) {
- const i4 = 4 * t3, o3 = e2.circleArray[i4 + 0], r3 = e2.circleArray[i4 + 1], n3 = e2.circleArray[i4 + 2], a3 = e2.circleArray[i4 + 3];
- 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);
- }
- (!Qi || Qi.length < 2 * u2) && (Qi = function(t3) {
- const i4 = 2 * t3, o3 = new e.StructArrayLayout3ui6();
- o3.resize(i4), o3._trim();
- for (let e2 = 0; e2 < i4; e2++) {
- const t4 = 6 * e2;
- 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;
- }
- return o3;
- }(u2));
- const g2 = l2.createIndexBuffer(Qi, true), v2 = l2.createVertexBuffer(m2, e.collisionCircleLayout.members, true);
- for (const i4 of _2) {
- 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] };
- 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);
- }
- var x2;
- v2.destroy(), g2.destroy();
- }
- const to = e.create();
- function io(t2, i3, o2, r2, n2, a2) {
- const { horizontalAlign: s2, verticalAlign: l2 } = e.getAnchorAlignment(t2), c2 = -(s2 - 0.5) * i3, h2 = -(l2 - 0.5) * o2, _2 = e.evaluateVariableOffset(t2, r2);
- return new e.pointGeometry((c2 / n2 + _2[0]) * a2, (h2 / n2 + _2[1]) * a2);
- }
- function oo(t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2) {
- 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);
- p2.clear();
- for (let m3 = 0; m3 < d2.length; m3++) {
- const y2 = d2.get(m3), b2 = t2.allowVerticalPlacement && !y2.placedOrientation, w2 = y2.hidden || !y2.crossTileID || b2 ? null : r2[y2.crossTileID];
- if (w2) {
- 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);
- let E2 = n2.evaluateSizeForFeature(t2.textSizeData, h2, y2) * T2 / e.ONE_EM;
- o2 && (E2 *= t2.tilePixelRatio / c2);
- 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;
- for (let t3 = 0; t3 < y2.numGlyphs; t3++)
- e.addDynamicAttributes(p2, P2, A2);
- _2 && y2.associatedIconIndex >= 0 && (f2[y2.associatedIconIndex] = { shiftedAnchor: P2, angle: A2 });
- } else
- dt(y2.numGlyphs, p2);
- }
- if (_2) {
- m2.clear();
- const i4 = t2.icon.placedSymbolArray;
- for (let t3 = 0; t3 < i4.length; t3++) {
- const o3 = i4.get(t3);
- if (o3.hidden)
- dt(o3.numGlyphs, m2);
- else {
- const i5 = f2[t3];
- if (i5)
- for (let t4 = 0; t4 < o3.numGlyphs; t4++)
- e.addDynamicAttributes(m2, i5.shiftedAnchor, i5.angle);
- else
- dt(o3.numGlyphs, m2);
- }
- }
- t2.icon.dynamicLayoutVertexBuffer.updateData(m2);
- }
- t2.text.dynamicLayoutVertexBuffer.updateData(p2);
- }
- function ro(e2, t2, i3) {
- return i3.iconsInText && t2 ? "symbolTextAndIcon" : e2 ? "symbolSDF" : "symbolIcon";
- }
- function no(t2, i3, o2, r2, n2, a2, s2, l2, c2, h2, _2, u2) {
- 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);
- let b2 = false;
- 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 = [];
- t2.terrain && g2 && S2.push("PITCH_WITH_MAP_TERRAIN"), C2 && S2.push("PROJECTION_GLOBE_VIEW");
- for (const l3 of r2) {
- const r3 = i3.getTile(l3), c3 = r3.getBucket(o2);
- if (!c3 || c3.projection !== m2.projection.name)
- continue;
- const _3 = n2 ? c3.text : c3.icon;
- if (!_3 || c3.fullyClipped || !_3.segments.get().length)
- continue;
- 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);
- let D2, P2, A2, L2, R2 = [0, 0], k2 = null;
- if (n2) {
- if (P2 = r3.glyphAtlasTexture, A2 = p2.LINEAR, D2 = r3.glyphAtlasTexture.size, c3.iconsInText) {
- R2 = r3.imageAtlasTexture.size, k2 = r3.imageAtlasTexture;
- const e2 = "composite" === w3.kind || "camera" === w3.kind;
- L2 = C3 || t2.options.rotating || t2.options.zooming || e2 ? p2.LINEAR : p2.NEAREST;
- }
- } else {
- const e2 = 1 !== o2.layout.get("icon-size").constantOr(0) || c3.iconsNeedLinear;
- P2 = r3.imageAtlasTexture, A2 = d3 || t2.options.rotating || t2.options.zooming || e2 || C3 ? p2.LINEAR : p2.NEAREST, D2 = r3.imageAtlasTexture.size;
- }
- 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();
- if (v2) {
- const e2 = m2.elevation, i4 = e2 ? e2.getAtTileOffsetFunc(l3, m2.center.lat, m2.worldSize, m2.projection) : (e3) => [0, 0, 0];
- nt(c3, l3.projMatrix, t2, n2, B2, U2, g2, h2, i4, l3);
- }
- 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);
- let H2;
- 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);
- 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 };
- if (y2 && c3.canOverlap) {
- b2 = true;
- const t3 = _3.segments.get();
- for (const i4 of t3)
- M2.push({ segments: new e.SegmentVector([i4]), sortKey: i4.sortKey, state: K2 });
- } else
- M2.push({ segments: _3.segments, sortKey: 0, state: K2 });
- }
- b2 && M2.sort((e2, t3) => e2.sortKey - t3.sortKey);
- for (const e2 of M2) {
- const i4 = e2.state;
- 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) {
- const r3 = i4.uniformValues;
- 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;
- }
- ao(i4.buffers, e2.segments, o2, t2, i4.program, w2, _2, u2, i4.uniformValues);
- }
- }
- function ao(t2, i3, o2, r2, n2, a2, s2, l2, c2) {
- const h2 = r2.context;
- 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);
- }
- function so(t2, i3, o2, r2, n2, a2, s2) {
- const l2 = t2.context.gl, c2 = o2.paint.get("fill-pattern"), h2 = c2 && c2.constantOr(1), _2 = o2.getCrossfadeParameters();
- let u2, d2, p2, m2, f2;
- s2 ? (d2 = h2 && !o2.getPaintProperty("fill-outline-color") ? "fillOutlinePattern" : "fillOutline", u2 = l2.LINES) : (d2 = h2 ? "fillPattern" : "fill", u2 = l2.TRIANGLES);
- for (const g2 of r2) {
- const r3 = i3.getTile(g2);
- if (h2 && !r3.patternsLoaded())
- continue;
- const v2 = r3.getBucket(o2);
- if (!v2)
- continue;
- t2.prepareDrawTile();
- const x2 = v2.programConfigurations.get(o2.id), y2 = t2.useProgram(d2, x2);
- h2 && (t2.context.activeTexture.set(l2.TEXTURE0), r3.imageAtlasTexture.bind(l2.LINEAR, l2.CLAMP_TO_EDGE), x2.updatePaintBuffers(_2));
- const b2 = c2.constantOr(null);
- if (b2 && r3.imageAtlas) {
- const e2 = r3.imageAtlas, t3 = e2.patternPositions[b2.to.toString()], i4 = e2.patternPositions[b2.from.toString()];
- t3 && i4 && x2.setConstantPatternPositions(t3, i4);
- }
- const w2 = t2.translatePosMatrix(g2.projMatrix, r3, o2.paint.get("fill-translate"), o2.paint.get("fill-translate-anchor"));
- if (s2) {
- m2 = v2.indexBuffer2, f2 = v2.segments2;
- const e2 = t2.terrain && t2.terrain.renderingToTexture ? t2.terrain.drapeBufferSize : [l2.drawingBufferWidth, l2.drawingBufferHeight];
- p2 = "fillOutlinePattern" === d2 && h2 ? Pi(w2, t2, _2, r3, e2) : Di(w2, e2);
- } else
- m2 = v2.indexBuffer, f2 = v2.segments, p2 = h2 ? zi(w2, t2, _2, r3) : Si(w2);
- 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);
- }
- }
- function lo(t2, i3, o2, r2, n2, a2, s2) {
- 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) {
- if ("globe" !== t3.projection.name)
- return 0;
- const i4 = Math.PI / 32, o3 = Math.tan(i4), r3 = e.earthRadius;
- return r3 * Math.sqrt(1 + 2 * o3 * o3) - r3;
- }(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 = [];
- f2 && x2.push("PROJECTION_GLOBE_VIEW");
- for (const y2 of r2) {
- const r3 = i3.getTile(y2), b2 = r3.getBucket(o2);
- if (!b2 || b2.projection !== h2.projection.name)
- continue;
- const w2 = b2.programConfigurations.get(o2.id), T2 = t2.useProgram(u2 ? "fillExtrusionPattern" : "fillExtrusion", w2, x2);
- if (t2.terrain) {
- const e2 = t2.terrain;
- if (t2.style.terrainSetForDrapingOnly())
- e2.setupElevationDraw(r3, T2, { useMeterToDem: true });
- else {
- if (!b2.enableTerrain)
- continue;
- if (e2.setupElevationDraw(r3, T2, { useMeterToDem: true }), co(l2, i3, y2, b2, o2, e2), !b2.centroidVertexBuffer) {
- const e3 = T2.attributes.a_centroid_pos;
- void 0 !== e3 && c2.vertexAttrib2f(e3, 0, 0);
- }
- }
- }
- u2 && (t2.context.activeTexture.set(c2.TEXTURE0), r3.imageAtlasTexture.bind(c2.LINEAR, c2.CLAMP_TO_EDGE), w2.updatePaintBuffers(d2));
- const E2 = _2.constantOr(null);
- if (E2 && r3.imageAtlas) {
- const e2 = r3.imageAtlas, t3 = e2.patternPositions[E2.to.toString()], i4 = e2.patternPositions[E2.from.toString()];
- t3 && i4 && w2.setConstantPatternPositions(t3, i4);
- }
- 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);
- 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);
- }
- }
- function co(t2, i3, o2, r2, n2, a2) {
- const s2 = [(t3) => {
- let i4 = t3.canonical.x - 1, o3 = t3.wrap;
- return i4 < 0 && (i4 = (1 << t3.canonical.z) - 1, o3--), new e.OverscaledTileID(t3.overscaledZ, o3, t3.canonical.z, i4, t3.canonical.y);
- }, (t3) => {
- let i4 = t3.canonical.x + 1, o3 = t3.wrap;
- return i4 === 1 << t3.canonical.z && (i4 = 0, o3++), new e.OverscaledTileID(t3.overscaledZ, o3, t3.canonical.z, i4, t3.canonical.y);
- }, (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) => {
- const t3 = i3.getSource().minzoom, o3 = (e3) => {
- const t4 = i3.getTileByID(e3);
- if (t4 && t4.hasData())
- return t4.getBucket(n2);
- }, r3 = [0, -1, 1];
- for (const i4 of r3) {
- if (e2.overscaledZ + i4 < t3)
- continue;
- const r4 = o3(e2.calculateScaledKey(e2.overscaledZ + i4));
- if (r4)
- return r4;
- }
- }, 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);
- let p2, m2, f2;
- const g2 = (t3, i4, r3, n3, s3) => {
- 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];
- 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();
- };
- for (let t3 = 0; t3 < 4; t3++) {
- const i4 = (t3 < 2 ? 1 : 5) - t3, n3 = r2.borders[t3];
- if (0 === n3.length)
- continue;
- const c3 = f2 = s2[t3](o2), h3 = l2(c3);
- if (!(h3 && h3 instanceof e.FillExtrusionBucket && h3.enableTerrain))
- continue;
- if (r2.borderDoneWithNeighborZ[t3] === h3.canonical.z && h3.borderDoneWithNeighborZ[i4] === r2.canonical.z)
- continue;
- if (m2 = a2.findDEMTileFor(c3), !m2 || !m2.dem)
- continue;
- if (!p2) {
- const e2 = a2.findDEMTileFor(o2);
- if (!e2 || !e2.dem)
- return;
- p2 = e2;
- }
- const _3 = h3.borders[i4];
- let v2 = 0;
- const x2 = h3.borderDoneWithNeighborZ[i4] !== r2.canonical.z;
- if (r2.canonical.z === h3.canonical.z) {
- for (let o3 = 0; o3 < n3.length; o3++) {
- const a3 = r2.featuresOnBorder[n3[o3]], s3 = a3.borders[t3];
- let l3;
- for (; v2 < _3.length && (l3 = h3.featuresOnBorder[_3[v2]], !(l3.borders[i4][1] > s3[0] + 3)); )
- x2 && h3.encodeCentroid(void 0, l3, false), v2++;
- if (l3 && v2 < _3.length) {
- const o4 = v2;
- let n4 = 0;
- for (; !(l3.borders[i4][0] > s3[1] - 3) && (n4++, ++v2 !== _3.length); )
- l3 = h3.featuresOnBorder[_3[v2]];
- if (l3 = h3.featuresOnBorder[_3[o4]], a3.intersectsCount() > 1 || l3.intersectsCount() > 1 || 1 !== n4) {
- 1 !== n4 && (v2 = o4), r2.encodeCentroid(void 0, a3, false), x2 && h3.encodeCentroid(void 0, l3, false);
- continue;
- }
- const c4 = u2[t3](a3, l3), p3 = t3 % 2 ? e.EXTENT - 1 : 0;
- 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);
- } else
- r2.encodeCentroid(void 0, a3, false);
- }
- r2.borderDoneWithNeighborZ[t3] = h3.canonical.z, r2.needsCentroidUpdate = true, x2 && (h3.borderDoneWithNeighborZ[i4] = r2.canonical.z, h3.needsCentroidUpdate = true);
- } else {
- for (const e2 of n3)
- r2.encodeCentroid(void 0, r2.featuresOnBorder[e2], false);
- if (x2) {
- for (const e2 of _3)
- h3.encodeCentroid(void 0, h3.featuresOnBorder[e2], false);
- h3.borderDoneWithNeighborZ[i4] = r2.canonical.z, h3.needsCentroidUpdate = true;
- }
- r2.borderDoneWithNeighborZ[t3] = h3.canonical.z, r2.needsCentroidUpdate = true;
- }
- }
- (r2.needsCentroidUpdate || !r2.centroidVertexBuffer && 0 !== r2.centroidVertexArray.length) && r2.uploadCentroid(t2);
- }
- 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);
- function fo(e2, t2, i3, o2) {
- vo(e2, 0, t2 + i3 / 2, e2.transform.width, i3, o2);
- }
- function go(e2, t2, i3, o2) {
- vo(e2, t2 - i3 / 2, 0, i3, e2.transform.height, o2);
- }
- function vo(t2, i3, o2, r2, n2, a2) {
- const s2 = t2.context, l2 = s2.gl;
- 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);
- }
- function xo(t2, i3, o2) {
- 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);
- t2.terrain && t2.terrain.setupElevationDraw(c2, l2);
- const h2 = e.DepthMode.disabled, _2 = e.StencilMode.disabled, u2 = t2.colorModeForRenderPass(), d2 = "$debug";
- 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);
- const p2 = c2._tileDebugBuffer || t2.debugBuffer, m2 = c2._tileDebugIndexBuffer || t2.debugIndexBuffer, f2 = c2._tileDebugSegments || t2.debugSegments;
- 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);
- 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;
- let b2 = o2.canonical.toString();
- o2.overscaledZ !== o2.canonical.z && (b2 += ` => ${o2.overscaledZ}`), function(e2, t3) {
- e2.initDebugOverlayCanvas();
- const i4 = e2.debugOverlayCanvas, o3 = e2.context.gl, r3 = e2.debugOverlayCanvas.getContext("2d");
- 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);
- }(t2, `${b2} ${v2}kb`);
- const w2 = c2._tileDebugTextBuffer || t2.debugBuffer, T2 = c2._tileDebugTextIndexBuffer || t2.quadTriangleIndexBuffer, E2 = c2._tileDebugTextSegments || t2.debugSegments;
- 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);
- }
- const yo = e.createLayout([{ name: "a_pos_3f", components: 3, type: "Float32" }]), { members: bo } = yo;
- function wo(e2, t2, i3, o2) {
- e2.emplaceBack(t2, i3, o2);
- }
- class To {
- constructor(t2) {
- 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);
- }
- }
- function Eo(t2, i3, o2, r2, n2, a2) {
- 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);
- 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);
- }
- function Co(t2, i3) {
- return e.transformMat4(t2, t2, i3);
- }
- const Io = { symbol: function(t2, i3, o2, r2, n2) {
- if ("translucent" !== t2.renderPass)
- return;
- const a2 = e.StencilMode.disabled, s2 = t2.colorModeForRenderPass();
- o2.layout.get("text-variable-anchor") && function(t3, i4, o3, r3, n3, a3, s3) {
- const l2 = i4.transform, c2 = "map" === n3, h2 = "map" === a3;
- for (const n4 of t3) {
- const t4 = r3.getTile(n4), a4 = t4.getBucket(o3);
- if (!a4 || a4.projection !== l2.projection.name || !a4.text || !a4.text.segments.get().length)
- continue;
- 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();
- if (_2) {
- const i5 = Math.pow(2, l2.zoom - t4.tileID.overscaledZ);
- oo(a4, c2, h2, s3, e.symbolSize, l2, d2, n4, i5, _2, p2, l2.projection);
- }
- }
- }(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));
- }, circle: function(t2, i3, o2, r2) {
- if ("translucent" !== t2.renderPass)
- return;
- 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);
- if (0 === n2.constantOr(1) && (0 === a2.constantOr(1) || 0 === s2.constantOr(1)))
- return;
- 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 = [];
- for (let n3 = 0; n3 < r2.length; n3++) {
- const a3 = r2[n3], s3 = i3.getTile(a3), c3 = s3.getBucket(o2);
- if (!c3)
- continue;
- const h3 = c3.programConfigurations.get(o2.id), u3 = Ri(o2);
- m2 && u3.push("PROJECTION_GLOBE_VIEW");
- 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 };
- if (l2) {
- const t3 = c3.segments.get();
- for (const i4 of t3)
- g2.push({ segments: new e.SegmentVector([i4]), sortKey: i4.sortKey, state: b2 });
- } else
- g2.push({ segments: c3.segments, sortKey: 0, state: b2 });
- }
- l2 && g2.sort((e2, t3) => e2.sortKey - t3.sortKey);
- const v2 = { useDepthForOcclusion: !m2 };
- for (const i4 of g2) {
- const { programConfiguration: r3, program: n3, layoutVertexBuffer: a3, globeExtVertexBuffer: s3, indexBuffer: l3, uniformValues: f3, tile: g3 } = i4.state, x2 = i4.segments;
- 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);
- }
- }, heatmap: function(t2, i3, o2, r2) {
- if (0 !== o2.paint.get("heatmap-opacity"))
- if ("offscreen" === t2.renderPass) {
- 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]);
- !function(e2, t3, i4) {
- const o3 = e2.gl;
- e2.activeTexture.set(o3.TEXTURE1), e2.viewport.set([0, 0, t3.width / 4, t3.height / 4]);
- let r3 = i4.heatmapFbo;
- if (r3)
- o3.bindTexture(o3.TEXTURE_2D, r3.colorAttachment.get()), e2.bindFramebuffer.set(r3.framebuffer);
- else {
- const n3 = o3.createTexture();
- 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) {
- const r4 = e3.gl;
- 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);
- }(e2, t3, n3, r3);
- }
- }(n2, t2, o2), n2.clear({ color: e.Color.transparent });
- 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)];
- for (let d2 = 0; d2 < r2.length; d2++) {
- const p2 = r2[d2];
- if (i3.hasRenderableParent(p2))
- continue;
- const m2 = i3.getTile(p2), f2 = m2.getBucket(o2);
- if (!f2)
- continue;
- const g2 = f2.programConfigurations.get(o2.id), v2 = t2.useProgram("heatmap", g2, _2), { zoom: x2 } = t2.transform;
- t2.terrain && t2.terrain.setupElevationDraw(m2, v2), t2.prepareDrawProgram(n2, v2, p2.toUnwrapped());
- const y2 = c2.projection.createInversionMatrix(c2, p2.canonical);
- 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);
- }
- n2.viewport.set([0, 0, t2.width, t2.height]);
- } else
- "translucent" === t2.renderPass && (t2.context.setColorMode(t2.colorModeForRenderPass()), function(t3, i4) {
- const o3 = t3.context, r3 = o3.gl, n2 = i4.heatmapFbo;
- if (!n2)
- return;
- o3.activeTexture.set(r3.TEXTURE0), r3.bindTexture(r3.TEXTURE_2D, n2.colorAttachment.get()), o3.activeTexture.set(r3.TEXTURE1);
- let a2 = i4.colorRampTexture;
- 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);
- }(t2, o2));
- }, line: function(t2, i3, o2, r2) {
- if ("translucent" !== t2.renderPass)
- return;
- const n2 = o2.paint.get("line-opacity"), a2 = o2.paint.get("line-width");
- if (0 === n2.constantOr(1) || 0 === a2.constantOr(1))
- return;
- 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) => {
- const t3 = [];
- Zi(e2) && t3.push("RENDER_LINE_DASH"), e2.paint.get("line-gradient") && t3.push("RENDER_LINE_GRADIENT");
- const i4 = e2.paint.get("line-pattern").constantOr(1), o3 = 1 !== e2.paint.get("line-opacity").constantOr(1);
- return !i4 && o3 && t3.push("RENDER_LINE_ALPHA_DISCARD"), t3;
- })(o2);
- let b2 = y2.includes("RENDER_LINE_ALPHA_DISCARD");
- t2.terrain && t2.terrain.clipOrMaskOverlapStencilType() && (b2 = false);
- for (const n3 of r2) {
- const r3 = i3.getTile(n3);
- if (p2 && !r3.patternsLoaded())
- continue;
- const a3 = r3.getBucket(o2);
- if (!a3)
- continue;
- t2.prepareDrawTile();
- const w2 = a3.programConfigurations.get(o2.id), T2 = t2.useProgram(g2, w2, y2), E2 = d2.constantOr(null);
- if (E2 && r3.imageAtlas) {
- const e2 = r3.imageAtlas, t3 = e2.patternPositions[E2.to.toString()], i4 = e2.patternPositions[E2.from.toString()];
- t3 && i4 && w2.setConstantPatternPositions(t3, i4);
- }
- const C2 = h2.constantOr(null), I2 = u2.constantOr(null);
- if (!p2 && C2 && I2 && r3.lineAtlas) {
- const e2 = r3.lineAtlas, t3 = e2.getDash(C2.to, I2), i4 = e2.getDash(C2.from, I2);
- t3 && i4 && w2.setConstantPatternPositions(t3, i4);
- }
- 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);
- if (m2) {
- const r4 = a3.gradients[o2.id];
- let s3 = r4.texture;
- if (o2.gradientVersion !== r4.version) {
- let l3 = 256;
- if (o2.stepInterpolant) {
- const o3 = i3.getSource().maxzoom, r5 = n3.canonical.z === o3 ? Math.ceil(1 << t2.transform.maxZoom - n3.canonical.z) : 1;
- l3 = e.clamp(e.nextPowerOfTwo(a3.maxLineLength / e.EXTENT * 1024 * r5), 256, v2.maxTextureSize);
- }
- 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;
- }
- v2.activeTexture.set(x2.TEXTURE1), s3.bind(o2.stepInterpolant ? x2.NEAREST : x2.LINEAR, x2.CLAMP_TO_EDGE);
- }
- _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());
- const z2 = (i4) => {
- 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);
- };
- if (b2) {
- const i4 = t2.stencilModeForClipping(n3).ref;
- 0 === i4 && t2.terrain && v2.clear({ stencil: 0 });
- const o3 = { func: x2.EQUAL, mask: 255 };
- 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));
- } else
- z2(t2.stencilModeForClipping(n3));
- }
- b2 && (t2.resetStencilClippingMasks(), t2.terrain && v2.clear({ stencil: 0 }));
- }, fill: function(t2, i3, o2, r2) {
- const n2 = o2.paint.get("fill-color"), a2 = o2.paint.get("fill-opacity");
- if (0 === a2.constantOr(1))
- return;
- 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";
- if (t2.renderPass === c2) {
- const n3 = t2.depthModeForSublayer(1, "opaque" === t2.renderPass ? e.DepthMode.ReadWrite : e.DepthMode.ReadOnly);
- so(t2, i3, o2, r2, n3, s2, false);
- }
- if ("translucent" === t2.renderPass && o2.paint.get("fill-antialias")) {
- const n3 = t2.depthModeForSublayer(o2.getPaintProperty("fill-outline-color") ? 2 : 0, e.DepthMode.ReadOnly);
- so(t2, i3, o2, r2, n3, s2, true);
- }
- }, "fill-extrusion": function(t2, i3, o2, r2) {
- const n2 = o2.paint.get("fill-extrusion-opacity");
- if (0 !== n2 && "translucent" === t2.renderPass) {
- const a2 = new e.DepthMode(t2.context.gl.LEQUAL, e.DepthMode.ReadWrite, t2.depthRangeFor3D);
- if (1 !== n2 || o2.paint.get("fill-extrusion-pattern").constantOr(1))
- lo(t2, i3, o2, r2, a2, e.StencilMode.disabled, e.ColorMode.disabled), lo(t2, i3, o2, r2, a2, t2.stencilModeFor3D(), t2.colorModeForRenderPass()), t2.resetStencilClippingMasks();
- else {
- const n3 = t2.colorModeForRenderPass();
- lo(t2, i3, o2, r2, a2, e.StencilMode.disabled, n3);
- }
- }
- }, hillshade: function(t2, i3, o2, r2) {
- if ("offscreen" !== t2.renderPass && "translucent" !== t2.renderPass)
- return;
- 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);
- for (const r3 of h2) {
- const n3 = i3.getTile(r3);
- if (n3.needsHillshadePrepare && "offscreen" === t2.renderPass)
- si(t2, n3, o2, a2, e.StencilMode.disabled, s2);
- else if ("translucent" === t2.renderPass) {
- const e2 = l2 && t2.terrain ? t2.terrain.stencilModeForRTTOverlap(r3) : c2[r3.overscaledZ];
- ni(t2, r3, n3, o2, a2, e2, s2);
- }
- }
- n2.viewport.set([0, 0, t2.width, t2.height]), t2.resetStencilClippingMasks();
- }, raster: function(t2, i3, o2, r2, n2, a2) {
- if ("translucent" !== t2.renderPass)
- return;
- if (0 === o2.paint.get("raster-opacity"))
- return;
- if (!r2.length)
- return;
- 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;
- for (const r3 of p2) {
- 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);
- if (u2 && (!g2 || !g2.hasData()))
- continue;
- 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");
- g2.registerFadeDuration(y2);
- const b2 = i3.findLoadedParent(r3, 0), w2 = fi(g2, b2, i3, t2.transform, y2);
- let T2, E2;
- t2.terrain && t2.terrain.prepareDrawTile();
- const C2 = "nearest" === o2.paint.get("raster-resampling") ? l2.NEAREST : l2.LINEAR;
- 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);
- const I2 = Vi(v2, E2 || [0, 0], T2 || 1, w2, o2, c2 instanceof Se ? c2.perspectiveTransform : [0, 0]);
- if (t2.prepareDrawProgram(s2, h2, p3), c2 instanceof Se)
- 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);
- else {
- const { tileBoundsBuffer: i4, tileBoundsIndexBuffer: r4, tileBoundsSegments: a3 } = t2.getTileBoundsBuffers(g2);
- h2.draw(s2, l2.TRIANGLES, n3, x2, _2, e.CullFaceMode.disabled, I2, o2.id, i4, r4, a3);
- }
- }
- t2.resetStencilClippingMasks();
- }, background: function(t2, i3, o2, r2) {
- const n2 = o2.paint.get("background-color"), a2 = o2.paint.get("background-opacity");
- if (0 === a2)
- return;
- const s2 = t2.context, l2 = s2.gl, c2 = t2.transform, h2 = c2.tileSize, _2 = o2.paint.get("background-pattern");
- if (t2.isPatternMissing(_2))
- return;
- const u2 = !_2 && 1 === n2.a && 1 === a2 && t2.opaquePassEnabledForLayer() ? "opaque" : "translucent";
- if (t2.renderPass !== u2)
- return;
- 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");
- let g2, v2 = r2;
- v2 || (g2 = t2.getBackgroundTiles(), v2 = Object.values(g2).map((e2) => e2.tileID)), _2 && (s2.activeTexture.set(l2.TEXTURE0), t2.imageManager.bind(t2.context));
- const x2 = o2.getCrossfadeParameters();
- for (const u3 of v2) {
- const v3 = u3.toUnwrapped(), y2 = r2 ? u3.projMatrix : t2.transform.calculateProjMatrix(v3);
- t2.prepareDrawTile();
- 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);
- t2.prepareDrawProgram(s2, f2, v3);
- const { tileBoundsBuffer: T2, tileBoundsIndexBuffer: E2, tileBoundsSegments: C2 } = t2.getTileBoundsBuffers(b2);
- f2.draw(s2, l2.TRIANGLES, p2, d2, m2, e.CullFaceMode.disabled, w2, o2.id, T2, E2, C2);
- }
- }, sky: function(t2, i3, o2) {
- 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;
- if (0 === a2)
- return;
- 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;
- "atmosphere" === l2 ? "offscreen" === t2.renderPass ? o2.needsSkyboxCapture(t2) && (function(t3, i4, o3, r3) {
- const n3 = t3.context, a3 = n3.gl;
- let s3 = i4.skyboxFbo;
- if (!s3) {
- 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);
- for (let e2 = 0; e2 < 6; ++e2)
- a3.texImage2D(a3.TEXTURE_CUBE_MAP_POSITIVE_X + e2, 0, a3.RGBA, 32, 32, 0, a3.RGBA, a3.UNSIGNED_BYTE, null);
- }
- n3.bindFramebuffer.set(s3.framebuffer), n3.viewport.set([0, 0, 32, 32]);
- const l3 = i4.getCenter(t3, true), c3 = t3.useProgram("skyboxCapture"), h3 = new Float64Array(16);
- 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]);
- }(t2, o2), o2.markSkyboxValid(t2)) : "sky" === t2.renderPass && function(t3, i4, o3, r3, n3) {
- const a3 = t3.context, s3 = a3.gl, l3 = t3.transform, c3 = t3.useProgram("skybox");
- a3.activeTexture.set(s3.TEXTURE0), s3.bindTexture(s3.TEXTURE_CUBE_MAP, i4.skyboxTexture);
- 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);
- 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);
- }(t2, o2, c2, a2, h2) : "gradient" === l2 && "sky" === t2.renderPass && function(t3, i4, o3, r3, n3) {
- const a3 = t3.context, s3 = a3.gl, l3 = t3.transform, c3 = t3.useProgram("skyboxGradient");
- i4.skyboxGeometry || (i4.skyboxGeometry = new To(a3)), a3.activeTexture.set(s3.TEXTURE0);
- let h3 = i4.colorRampTexture;
- h3 || (h3 = i4.colorRampTexture = new e.Texture(a3, i4.colorRamp, s3.RGBA)), h3.bind(s3.LINEAR, s3.CLAMP_TO_EDGE);
- 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);
- 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);
- }(t2, o2, c2, a2, h2);
- }, debug: function(e2, t2, i3) {
- for (let o2 = 0; o2 < i3.length; o2++)
- xo(e2, t2, i3[o2]);
- }, custom: function(t2, i3, o2) {
- const r2 = t2.context, n2 = o2.implementation;
- if (t2.transform.projection.unsupportedLayers && t2.transform.projection.unsupportedLayers.includes("custom"))
- e.warnOnce("Custom layers are not yet supported with non-mercator projections. Use mercator to enable custom layers.");
- else if ("offscreen" === t2.renderPass) {
- const e2 = n2.prerender;
- e2 && (t2.setCustomLayerDefaults(), r2.setColorMode(t2.colorModeForRenderPass()), e2.call(n2, r2.gl, t2.transform.customLayerMatrix()), r2.setDirty(), t2.setBaseState());
- } else if ("translucent" === t2.renderPass) {
- t2.setCustomLayerDefaults(), r2.setColorMode(t2.colorModeForRenderPass()), r2.setStencilMode(e.StencilMode.disabled);
- const i4 = "3d" === n2.renderingMode ? new e.DepthMode(t2.context.gl.LEQUAL, e.DepthMode.ReadWrite, t2.depthRangeFor3D) : t2.depthModeForSublayer(0, e.DepthMode.ReadOnly);
- r2.setDepthMode(i4), n2.render(r2.gl, t2.transform.customLayerMatrix()), r2.setDirty(), t2.setBaseState(), r2.bindFramebuffer.set(null);
- }
- } };
- class Mo {
- constructor(t2, i3) {
- 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();
- }
- updateTerrain(e2, t2) {
- const i3 = !!e2 && !!e2.terrain && this.transform.projection.supportsTerrain;
- if (!(i3 || this._terrain && this._terrain.enabled))
- return;
- this._terrain || (this._terrain = new bi(this, e2));
- const o2 = this._terrain;
- this.transform.elevation = i3 ? o2 : null, o2.update(e2, this.transform, t2);
- }
- _updateFog(e2) {
- const t2 = e2.fog;
- if (!t2 || t2.getOpacity(this.transform.pitch) < 1 || t2.properties.get("horizon-blend") < 0.03)
- return void (this.transform.fogCullDistSq = null);
- const [i3, o2] = t2.getFovAdjustedRange(this.transform._fov);
- if (i3 > o2)
- return void (this.transform.fogCullDistSq = null);
- const r2 = i3 + 0.78 * (o2 - i3);
- this.transform.fogCullDistSq = r2 * r2;
- }
- get terrain() {
- return this.transform._terrainEnabled() && this._terrain && this._terrain.enabled ? this._terrain : null;
- }
- resize(t2, i3) {
- 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)
- for (const e2 of this.style.order)
- this.style._layers[e2].resize();
- }
- setup() {
- const t2 = this.context, i3 = new e.StructArrayLayout2i4();
- 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);
- const o2 = new e.StructArrayLayout2i4();
- 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);
- const r2 = new e.StructArrayLayout2i4();
- 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);
- const n2 = new e.StructArrayLayout4i8();
- 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);
- const a2 = new e.StructArrayLayout3ui6();
- a2.emplaceBack(0, 1, 2), a2.emplaceBack(2, 1, 3), this.quadTriangleIndexBuffer = t2.createIndexBuffer(a2);
- const s2 = new e.StructArrayLayout1ui2();
- for (const e2 of [0, 1, 3, 2, 0])
- s2.emplaceBack(e2);
- 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();
- const l2 = this.context.gl;
- 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());
- }
- getMercatorTileBoundsBuffers() {
- return { tileBoundsBuffer: this.mercatorBoundsBuffer, tileBoundsIndexBuffer: this.quadTriangleIndexBuffer, tileBoundsSegments: this.mercatorBoundsSegments };
- }
- getTileBoundsBuffers(e2) {
- return e2._makeTileBoundsBuffers(this.context, this.transform.projection), e2._tileBoundsBuffer ? { tileBoundsBuffer: e2._tileBoundsBuffer, tileBoundsIndexBuffer: e2._tileBoundsIndexBuffer, tileBoundsSegments: e2._tileBoundsSegments } : this.getMercatorTileBoundsBuffers();
- }
- clearStencil() {
- const t2 = this.context, i3 = t2.gl;
- 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);
- }
- resetStencilClippingMasks() {
- this.terrain || (this.currentStencilSource = void 0, this._tileClippingMaskIDs.clear(), this._skippedStencilTileIDs.clear());
- }
- _renderTileClippingMasks(t2, i3, o2) {
- if (!i3 || this.currentStencilSource === i3.id || !t2.isTileClipped() || !o2 || 0 === o2.length)
- return;
- const r2 = [];
- let n2 = false;
- if (this._tileClippingMaskIDs && !this.terrain) {
- for (const e2 of o2)
- if (this._tileClippingMaskIDs.has(e2.key) || (n2 = true), this._skippedStencilTileIDs.has(e2.key)) {
- if (!i3.getTile(e2).getBucket(t2))
- continue;
- this._skippedStencilTileIDs.delete(e2.key), r2.push(e2);
- }
- if (!n2 && 0 === r2.length)
- return;
- }
- const a2 = this.context, s2 = a2.gl;
- a2.setColorMode(e.ColorMode.disabled), a2.setDepthMode(e.DepthMode.disabled);
- const l2 = this.useProgram("clippingMask"), c2 = (t3) => {
- const o3 = i3.getTile(t3), { tileBoundsBuffer: r3, tileBoundsIndexBuffer: n3, tileBoundsSegments: c3 } = this.getTileBoundsBuffers(o3);
- 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);
- };
- if (!n2 && r2.length > 0)
- for (const e2 of r2)
- c2(e2);
- else {
- (0 === this._tileClippingMaskIDs.size || this.nextStencilID + o2.length > 256) && this.clearStencil(), this._tileClippingMaskIDs.clear(), this._skippedStencilTileIDs.clear();
- for (const e2 of o2)
- this._tileClippingMaskIDs.set(e2.key, this.nextStencilID++), i3.getTile(e2).getBucket(t2) ? c2(e2) : this._skippedStencilTileIDs.add(e2.key);
- }
- 0 === this._skippedStencilTileIDs.size && (this.currentStencilSource = i3.id);
- }
- stencilModeFor3D() {
- this.currentStencilSource = void 0, this.nextStencilID + 1 > 256 && this.clearStencil();
- const t2 = this.nextStencilID++, i3 = this.context.gl;
- return new e.StencilMode({ func: i3.NOTEQUAL, mask: 255 }, t2, 255, i3.KEEP, i3.KEEP, i3.REPLACE);
- }
- stencilModeForClipping(t2) {
- if (this.terrain)
- return this.terrain.stencilModeForRTTOverlap(t2);
- const i3 = this.context.gl;
- return new e.StencilMode({ func: i3.EQUAL, mask: 255 }, this._tileClippingMaskIDs.get(t2.key) || 0, 0, i3.KEEP, i3.KEEP, i3.REPLACE);
- }
- stencilConfigForOverlap(t2) {
- 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;
- if (n2 > 1) {
- this.currentStencilSource = void 0, this.nextStencilID + n2 > 256 && this.clearStencil();
- const t3 = {};
- for (let o3 = 0; o3 < n2; o3++)
- t3[o3 + r2] = new e.StencilMode({ func: i3.GEQUAL, mask: 255 }, o3 + this.nextStencilID, 255, i3.KEEP, i3.KEEP, i3.REPLACE);
- return this.nextStencilID += n2, [t3, o2];
- }
- return [{ [r2]: e.StencilMode.disabled }, o2];
- }
- colorModeForRenderPass() {
- const t2 = this.context.gl;
- if (this._showOverdrawInspector) {
- const i3 = 1 / 8;
- return new e.ColorMode([t2.CONSTANT_COLOR, t2.ONE], new e.Color(i3, i3, i3, 0), [true, true, true, true]);
- }
- return "opaque" === this.renderPass ? e.ColorMode.unblended : e.ColorMode.alphaBlended;
- }
- depthModeForSublayer(t2, i3, o2) {
- if (!this.opaquePassEnabledForLayer())
- return e.DepthMode.disabled;
- const r2 = 1 - ((1 + this.currentLayer) * this.numSublayers + t2) * this.depthEpsilon;
- return new e.DepthMode(o2 || this.context.gl.LEQUAL, i3, [r2, r2]);
- }
- opaquePassEnabledForLayer() {
- return this.currentLayer < this.opaquePassCutoff;
- }
- render(t2, i3) {
- 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();
- const o2 = this.style.order, r2 = this.style._sourceCaches;
- for (const e2 in r2) {
- const t3 = r2[e2];
- t3.used && t3.prepare(this.context);
- }
- const n2 = {}, a2 = {}, s2 = {};
- for (const e2 in r2) {
- const t3 = r2[e2];
- n2[e2] = t3.getVisibleCoordinates(), a2[e2] = n2[e2].slice().reverse(), s2[e2] = t3.getVisibleCoordinates(true).reverse();
- }
- this.opaquePassCutoff = 1 / 0;
- for (let e2 = 0; e2 < o2.length; e2++)
- if (this.style._layers[o2[e2]].is3D()) {
- this.opaquePassCutoff = e2;
- break;
- }
- 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))
- return;
- this.renderPass = "offscreen";
- for (const e2 of o2) {
- const i4 = this.style._layers[e2], o3 = t2._getLayerSourceCache(i4);
- if (!i4.hasOffscreenPass() || i4.isHidden(this.transform.zoom))
- continue;
- const r3 = o3 ? a2[o3.id] : void 0;
- ("custom" === i4.type || i4.isSky() || r3 && r3.length) && this.renderLayer(this, o3, i4, r3);
- }
- 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]);
- let l2 = e.Color.transparent;
- 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)
- for (this.currentLayer = o2.length - 1; this.currentLayer >= 0; this.currentLayer--) {
- const e2 = this.style._layers[o2[this.currentLayer]], i4 = t2._getLayerSourceCache(e2);
- if (e2.isSky())
- continue;
- const r3 = i4 ? a2[i4.id] : void 0;
- this._renderTileClippingMasks(e2, i4, r3), this.renderLayer(this, i4, e2, r3);
- }
- if (this.renderPass = "sky", (e.globeToMercatorTransition(this.transform.zoom) > 0 || "globe" !== this.transform.projection.name) && this.transform.isHorizonVisible())
- for (this.currentLayer = 0; this.currentLayer < o2.length; this.currentLayer++) {
- const e2 = this.style._layers[o2[this.currentLayer]], i4 = t2._getLayerSourceCache(e2);
- e2.isSky() && this.renderLayer(this, i4, e2, i4 ? a2[i4.id] : void 0);
- }
- for ("globe" === this.transform.projection.name && function(t3) {
- 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);
- l3[8] = 2 * -s3.x / r3.width, l3[9] = 2 * s3.y / r3.height;
- 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] };
- t3.prepareDrawProgram(i4, a3);
- const u2 = t3.globeSharedBuffers;
- u2 && a3.draw(i4, o3.TRIANGLES, n3, e.StencilMode.disabled, e.ColorMode.alphaBlended, e.CullFaceMode.backCW, _2, "skybox", u2.atmosphereVertexBuffer, u2.atmosphereIndexBuffer, u2.atmosphereSegments);
- }(this), this.renderPass = "translucent", this.currentLayer = 0; this.currentLayer < o2.length; ) {
- const e2 = this.style._layers[o2[this.currentLayer]], i4 = t2._getLayerSourceCache(e2);
- if (e2.isSky()) {
- ++this.currentLayer;
- continue;
- }
- if (this.terrain && this.style.isLayerDraped(e2)) {
- if (e2.isHidden(this.transform.zoom)) {
- ++this.currentLayer;
- continue;
- }
- this.currentLayer = this.terrain.renderBatch(this.currentLayer);
- continue;
- }
- const r3 = i4 ? ("symbol" === e2.type ? s2 : a2)[i4.id] : void 0;
- this._renderTileClippingMasks(e2, i4, i4 ? n2[i4.id] : void 0), this.renderLayer(this, i4, e2, r3), ++this.currentLayer;
- }
- if (this.terrain && this.terrain.postRender(), this.options.showTileBoundaries || this.options.showQueryGeometry) {
- let i4 = null;
- e.values(this.style._layers).forEach((e2) => {
- const o3 = t2._getLayerSourceCache(e2);
- o3 && !e2.isHidden(this.transform.zoom) && (!i4 || i4.getSource().maxzoom < o3.getSource().maxzoom) && (i4 = o3);
- }), i4 && this.options.showTileBoundaries && Io.debug(this, i4, i4.getVisibleCoordinates());
- }
- this.options.showPadding && function(e2) {
- const t3 = e2.transform.padding;
- 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);
- const i4 = e2.transform.centerPoint;
- !function(e3, t4, i5, o3) {
- vo(e3, t4 - 1, i5 - 10, 2, 20, o3), vo(e3, t4 - 10, i5 - 1, 20, 2, o3);
- }(e2, i4.x, e2.transform.height - i4.y, mo);
- }(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());
- }
- renderLayer(e2, t2, i3, o2) {
- 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());
- }
- gpuTimingStart(e2) {
- if (!this.options.gpuTiming)
- return;
- const t2 = this.context.extTimerQuery;
- let i3 = this.gpuTimers[e2.id];
- i3 || (i3 = this.gpuTimers[e2.id] = { calls: 0, cpuTime: 0, query: t2.createQueryEXT() }), i3.calls++, t2.beginQueryEXT(t2.TIME_ELAPSED_EXT, i3.query);
- }
- gpuTimingEnd() {
- if (!this.options.gpuTiming)
- return;
- const e2 = this.context.extTimerQuery;
- e2.endQueryEXT(e2.TIME_ELAPSED_EXT);
- }
- collectGpuTimers() {
- const e2 = this.gpuTimers;
- return this.gpuTimers = {}, e2;
- }
- queryGpuTimers(e2) {
- const t2 = {};
- for (const i3 in e2) {
- const o2 = e2[i3], r2 = this.context.extTimerQuery, n2 = r2.getQueryObjectEXT(o2.query, r2.QUERY_RESULT_EXT) / 1e6;
- r2.deleteQueryEXT(o2.query), t2[i3] = n2;
- }
- return t2;
- }
- translatePosMatrix(t2, i3, o2, r2, n2) {
- if (!o2[0] && !o2[1])
- return t2;
- const a2 = n2 ? "map" === r2 ? this.transform.angle : 0 : "viewport" === r2 ? -this.transform.angle : 0;
- if (a2) {
- const e2 = Math.sin(a2), t3 = Math.cos(a2);
- o2 = [o2[0] * t3 - o2[1] * e2, o2[0] * e2 + o2[1] * t3];
- }
- 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);
- return e.translate(l2, t2, s2), l2;
- }
- saveTileTexture(e2) {
- const t2 = this._tileTextures[e2.size[0]];
- t2 ? t2.push(e2) : this._tileTextures[e2.size[0]] = [e2];
- }
- getTileTexture(e2) {
- const t2 = this._tileTextures[e2];
- return t2 && t2.length > 0 ? t2.pop() : null;
- }
- isPatternMissing(e2) {
- if (!e2)
- return false;
- if (!e2.from || !e2.to)
- return true;
- const t2 = this.imageManager.getPattern(e2.from.toString()), i3 = this.imageManager.getPattern(e2.to.toString());
- return !t2 || !i3;
- }
- currentGlobalDefines() {
- const e2 = this.terrain && this.terrain.renderingToTexture, t2 = this.style && this.style.fog, i3 = [];
- 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;
- }
- useProgram(e2, t2, i3) {
- this.cache = this.cache || {};
- const o2 = i3 || [], r2 = this.currentGlobalDefines().concat(o2), n2 = Ti.cacheKey(e2, r2, t2);
- return this.cache[n2] || (this.cache[n2] = new Ti(this.context, e2, ti[e2], t2, Ji[e2], r2)), this.cache[n2];
- }
- setCustomLayerDefaults() {
- 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();
- }
- setBaseState() {
- const e2 = this.context.gl;
- this.context.cullFace.set(false), this.context.viewport.set([0, 0, this.width, this.height]), this.context.blendEquation.set(e2.FUNC_ADD);
- }
- initDebugOverlayCanvas() {
- 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));
- }
- destroy() {
- this._terrain && this._terrain.destroy(), this.globeSharedBuffers && this.globeSharedBuffers.destroy(), this.emptyTexture.destroy(), this.debugOverlayTexture && this.debugOverlayTexture.destroy();
- }
- prepareDrawTile() {
- this.terrain && this.terrain.prepareDrawTile();
- }
- prepareDrawProgram(e2, t2, i3) {
- if (this.terrain && this.terrain.renderingToTexture)
- return;
- const o2 = this.style.fog;
- if (o2) {
- const r2 = o2.getOpacity(this.transform.pitch);
- 0 !== r2 && t2.setFogUniformValues(e2, ((e3, t3, i4, o3) => {
- 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];
- 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 };
- })(this, o2, i3, r2));
- }
- }
- setTileLoadedFlag(e2) {
- this.tileLoaded = e2;
- }
- saveCanvasCopy() {
- this.frameCopies.push(this.canvasCopy()), this.tileLoaded = false;
- }
- canvasCopy() {
- const e2 = this.context.gl, t2 = e2.createTexture();
- return e2.bindTexture(e2.TEXTURE_2D, t2), e2.copyTexImage2D(e2.TEXTURE_2D, 0, e2.RGBA, 0, 0, e2.drawingBufferWidth, e2.drawingBufferHeight, 0), t2;
- }
- getCanvasCopiesAndTimestamps() {
- return { canvasCopies: this.frameCopies, timeStamps: this.loadTimeStamps };
- }
- averageElevationNeedsEasing() {
- if (!this.transform._elevation)
- return false;
- const e2 = this.style && this.style.fog;
- return !!e2 && 0 !== e2.getOpacity(this.transform.pitch);
- }
- getBackgroundTiles() {
- const t2 = this._backgroundTiles, i3 = this._backgroundTiles = {}, o2 = this.transform.coveringTiles({ tileSize: 512 });
- for (const r2 of o2)
- i3[r2.key] = t2[r2.key] || new e.Tile(r2, 512, this.transform.tileZoom, this);
- return i3;
- }
- clearBackgroundTiles() {
- this._backgroundTiles = {};
- }
- }
- class So {
- constructor(e2 = 0, t2 = 0, i3 = 0, o2 = 0) {
- if (isNaN(e2) || e2 < 0 || isNaN(t2) || t2 < 0 || isNaN(i3) || i3 < 0 || isNaN(o2) || o2 < 0)
- throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");
- this.top = e2, this.bottom = t2, this.left = i3, this.right = o2;
- }
- interpolate(t2, i3, o2) {
- 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;
- }
- getCenter(t2, i3) {
- const o2 = e.clamp((this.left + t2 - this.right) / 2, 0, t2), r2 = e.clamp((this.top + i3 - this.bottom) / 2, 0, i3);
- return new e.pointGeometry(o2, r2);
- }
- equals(e2) {
- return this.top === e2.top && this.bottom === e2.bottom && this.left === e2.left && this.right === e2.right;
- }
- clone() {
- return new So(this.top, this.bottom, this.left, this.right);
- }
- toJSON() {
- return { top: this.top, bottom: this.bottom, left: this.left, right: this.right };
- }
- }
- function zo(t2, i3) {
- const o2 = e.getColumn(t2, 3);
- e.fromQuat(t2, i3), e.setColumn(t2, 3, o2);
- }
- function Do(t2, i3) {
- const o2 = e.identity$1([]);
- return e.rotateZ$1(o2, o2, -i3), e.rotateX$1(o2, o2, -t2), o2;
- }
- function Po(t2, i3) {
- const o2 = [t2[0], t2[1], 0], r2 = [i3[0], i3[1], 0];
- if (e.length(o2) >= 1e-15) {
- const t3 = e.normalize([], o2);
- e.scale$2(r2, t3, e.dot(r2, t3)), i3[0] = r2[0], i3[1] = r2[1];
- }
- const n2 = e.cross([], i3, t2);
- if (e.len(n2) < 1e-15)
- return null;
- const a2 = Math.atan2(-n2[1], n2[0]);
- return Do(Math.atan2(Math.sqrt(t2[0] * t2[0] + t2[1] * t2[1]), -t2[2]), a2);
- }
- class Ao {
- constructor(e2, t2) {
- this.position = e2, this.orientation = t2;
- }
- get position() {
- return this._position;
- }
- set position(t2) {
- if (t2) {
- const i3 = t2 instanceof e.MercatorCoordinate ? t2 : new e.MercatorCoordinate(t2[0], t2[1], t2[2]);
- this._renderWorldCopies && (i3.x = e.wrap(i3.x, 0, 1)), this._position = i3;
- } else
- this._position = null;
- }
- lookAtPoint(t2, i3) {
- if (this.orientation = null, !this.position)
- return;
- 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];
- i3 || (i3 = [0, 0, 1]), i3[2] = Math.abs(i3[2]), this.orientation = Po(a2, i3);
- }
- setPitchBearing(t2, i3) {
- this.orientation = Do(e.degToRad(t2), e.degToRad(-i3));
- }
- }
- class Lo {
- constructor(t2, i3) {
- this._transform = e.identity([]), this.orientation = i3, this.position = t2;
- }
- get mercatorPosition() {
- const t2 = this.position;
- return new e.MercatorCoordinate(t2[0], t2[1], t2[2]);
- }
- get position() {
- const t2 = e.getColumn(this._transform, 3);
- return [t2[0], t2[1], t2[2]];
- }
- set position(t2) {
- var i3;
- t2 && e.setColumn(this._transform, 3, [(i3 = t2)[0], i3[1], i3[2], 1]);
- }
- get orientation() {
- return this._orientation;
- }
- set orientation(t2) {
- this._orientation = t2 || e.identity$1([]), t2 && zo(this._transform, this._orientation);
- }
- getPitchBearing() {
- const e2 = this.forward(), t2 = this.right();
- return { bearing: Math.atan2(-t2[1], t2[0]), pitch: Math.atan2(Math.sqrt(e2[0] * e2[0] + e2[1] * e2[1]), -e2[2]) };
- }
- setPitchBearing(e2, t2) {
- this._orientation = Do(e2, t2), zo(this._transform, this._orientation);
- }
- forward() {
- const t2 = e.getColumn(this._transform, 2);
- return [-t2[0], -t2[1], -t2[2]];
- }
- up() {
- const t2 = e.getColumn(this._transform, 1);
- return [-t2[0], -t2[1], -t2[2]];
- }
- right() {
- const t2 = e.getColumn(this._transform, 0);
- return [t2[0], t2[1], t2[2]];
- }
- getCameraToWorld(t2, i3) {
- const o2 = new Float64Array(16);
- return e.invert(o2, this.getWorldToCamera(t2, i3)), o2;
- }
- getWorldToCameraPosition(t2, i3, o2) {
- const r2 = this.position;
- e.scale$2(r2, r2, -t2);
- const n2 = new Float64Array(16);
- return e.fromScaling(n2, [o2, o2, o2]), e.translate(n2, n2, r2), n2[10] *= i3, n2;
- }
- getWorldToCamera(t2, i3) {
- const o2 = new Float64Array(16), r2 = new Float64Array(4), n2 = this.position;
- 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;
- }
- getCameraToClipPerspective(t2, i3, o2, r2) {
- const n2 = new Float64Array(16);
- return e.perspective(n2, t2, i3, o2, r2), n2;
- }
- getDistanceToElevation(t2) {
- const i3 = 0 === t2 ? 0 : e.mercatorZfromAltitude(t2, this.position[1]), o2 = this.forward();
- return (i3 - this.position[2]) / o2[2];
- }
- clone() {
- return new Lo([...this.position], [...this.orientation]);
- }
- }
- function Ro(t2, i3) {
- const o2 = Oo(t2), r2 = function(t3, i4, o3, r3, n3) {
- 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);
- _2.y = e.clamp(_2.y, -0.999975, 0.999975);
- const u2 = _2.toLngLat(), d2 = t3.project(u2.lng, u2.lat), p2 = e.MercatorCoordinate.fromLngLat(u2);
- p2.x += Bo;
- 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);
- v2.y += Bo;
- 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([]);
- e.rotateZ(T2, T2, -h2 * (1 - (n3 ? 0 : r3)));
- const E2 = e.identity([]);
- 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;
- }(t2.projection, 0, t2.center, o2, i3), n2 = ko(t2);
- return e.scale(r2, r2, [n2, n2, 1]), r2;
- }
- function ko(t2) {
- const i3 = t2.projection, o2 = Oo(t2), r2 = Fo(i3, t2.center), n2 = Fo(i3, e.LngLat.convert(i3.center));
- return Math.pow(2, r2 * o2 + (1 - o2) * n2);
- }
- function Oo(t2) {
- const i3 = t2.projection.range;
- if (!i3)
- return 0;
- const o2 = Math.max(t2.width, t2.height), r2 = Math.log(o2 / 1024) / Math.LN2;
- return e.smoothstep(i3[0] + r2, i3[1] + r2, t2.zoom);
- }
- const Bo = 1 / 4e4;
- function Fo(t2, i3) {
- 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));
- return Math.log(p2) / Math.LN2;
- }
- function Uo(e2, t2, i3) {
- const o2 = Math.cos(i3), r2 = Math.sin(i3);
- return { x: e2 * o2 - t2 * r2, y: e2 * r2 + t2 * o2 };
- }
- class No {
- constructor(t2, i3, o2, r2, n2, a2, s2) {
- 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;
- }
- clone() {
- const e2 = new No(this._minZoom, this._maxZoom, this._minPitch, this.maxPitch, this._renderWorldCopies, this.getProjection());
- 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;
- }
- get elevation() {
- return this._elevation;
- }
- set elevation(e2) {
- this._elevation !== e2 && (this._elevation = e2, this._updateCameraOnTerrain(), this._calcMatrices());
- }
- updateElevation(e2) {
- const t2 = this._elevation && this._elevation.exaggeration() !== this._centerAltitudeValidForExaggeration;
- (null == this._seaLevelZoom || t2) && this._updateCameraOnTerrain(), (e2 || t2) && this._constrainCameraAltitude(), this._calcMatrices();
- }
- getProjection() {
- return e.pick(this.projection, ["name", "center", "parallels"]);
- }
- setProjection(t2) {
- null == t2 && (t2 = { name: "mercator" }), this.projectionOptions = t2;
- const i3 = this.projection ? this.getProjection() : void 0;
- this.projection = e.getProjection(t2);
- const o2 = this.getProjection();
- return r(i3, o2) ? null : (this._calcMatrices(), o2);
- }
- get minZoom() {
- return this._minZoom;
- }
- set minZoom(e2) {
- this._minZoom !== e2 && (this._minZoom = e2, this.zoom = Math.max(this.zoom, e2));
- }
- get maxZoom() {
- return this._maxZoom;
- }
- set maxZoom(e2) {
- this._maxZoom !== e2 && (this._maxZoom = e2, this.zoom = Math.min(this.zoom, e2));
- }
- get minPitch() {
- return this._minPitch;
- }
- set minPitch(e2) {
- this._minPitch !== e2 && (this._minPitch = e2, this.pitch = Math.max(this.pitch, e2));
- }
- get maxPitch() {
- return this._maxPitch;
- }
- set maxPitch(e2) {
- this._maxPitch !== e2 && (this._maxPitch = e2, this.pitch = Math.min(this.pitch, e2));
- }
- get renderWorldCopies() {
- return this._renderWorldCopies && true === this.projection.supportsWorldCopies;
- }
- set renderWorldCopies(e2) {
- void 0 === e2 ? e2 = true : null === e2 && (e2 = false), this._renderWorldCopies = e2;
- }
- get worldSize() {
- return this.tileSize * this.scale;
- }
- get cameraWorldSize() {
- const e2 = Math.max(this._camera.getDistanceToElevation(this._averageElevation), Number.EPSILON);
- return this._worldSizeFromZoom(this._zoomFromMercatorZ(e2));
- }
- get pixelsPerMeter() {
- return this.projection.pixelsPerMeter(this.center.lat, this.worldSize);
- }
- get cameraPixelsPerMeter() {
- return this.projection.pixelsPerMeter(this.center.lat, this.cameraWorldSize);
- }
- get centerOffset() {
- return this.centerPoint._sub(this.size._div(2));
- }
- get size() {
- return new e.pointGeometry(this.width, this.height);
- }
- get bearing() {
- return e.wrap(this.rotation, -180, 180);
- }
- set bearing(e2) {
- this.rotation = e2;
- }
- get rotation() {
- return -this.angle / Math.PI * 180;
- }
- set rotation(t2) {
- const i3 = -t2 * Math.PI / 180;
- var o2;
- 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) {
- var o3 = t3[0], r2 = t3[1], n2 = t3[2], a2 = t3[3], s2 = Math.sin(i4), l2 = Math.cos(i4);
- e2[0] = o3 * l2 + n2 * s2, e2[1] = r2 * l2 + a2 * s2, e2[2] = o3 * -s2 + n2 * l2, e2[3] = r2 * -s2 + a2 * l2;
- }(this.rotationMatrix, this.rotationMatrix, this.angle));
- }
- get pitch() {
- return this._pitch / Math.PI * 180;
- }
- set pitch(t2) {
- const i3 = e.clamp(t2, this.minPitch, this.maxPitch) / 180 * Math.PI;
- this._pitch !== i3 && (this._unmodified = false, this._pitch = i3, this._calcMatrices());
- }
- get fov() {
- return this._fov / Math.PI * 180;
- }
- set fov(e2) {
- e2 = Math.max(0.01, Math.min(60, e2)), this._fov !== e2 && (this._unmodified = false, this._fov = e2 / 180 * Math.PI, this._calcMatrices());
- }
- get averageElevation() {
- return this._averageElevation;
- }
- set averageElevation(e2) {
- this._averageElevation = e2, this._calcFogMatrices(), this._distanceTileDataCache = {};
- }
- get zoom() {
- return this._zoom;
- }
- set zoom(e2) {
- const t2 = Math.min(Math.max(e2, this.minZoom), this.maxZoom);
- this._zoom !== t2 && (this._unmodified = false, this._setZoom(t2), this._updateSeaLevelZoom(), this._constrain(), this._calcMatrices());
- }
- _setZoom(e2) {
- this._zoom = e2, this.scale = this.zoomScale(e2), this.tileZoom = Math.floor(e2), this.zoomFraction = e2 - this.tileZoom;
- }
- _updateCameraOnTerrain() {
- if (!this._elevation || !this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))
- return this._centerAltitude = 0, this._seaLevelZoom = null, void (this._centerAltitudeValidForExaggeration = 0);
- const e2 = this._elevation;
- this._centerAltitude = e2.getAtPointOrZero(this.locationCoordinate(this.center)), this._centerAltitudeValidForExaggeration = e2.exaggeration(), this._updateSeaLevelZoom();
- }
- _updateSeaLevelZoom() {
- 0 !== this._centerAltitudeValidForExaggeration && (this._seaLevelZoom = this._zoomFromMercatorZ((this.pixelsPerMeter * this._centerAltitude + this.cameraToCenterDistance) / this.worldSize));
- }
- sampleAverageElevation() {
- if (!this._elevation)
- return 0;
- 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();
- let r2 = 0, n2 = 0;
- for (let a2 = 0; a2 < i3.length; a2++) {
- const s2 = new e.pointGeometry(i3[a2][0] * this.width, o2 + i3[a2][1] * (this.height - o2)), l2 = t2.pointCoordinate(s2);
- if (!l2)
- continue;
- const c2 = 1 / Math.hypot(l2[0] - this._camera.position[0], l2[1] - this._camera.position[1]);
- r2 += l2[3] * c2, n2 += c2;
- }
- return 0 === n2 ? NaN : r2 / n2;
- }
- get center() {
- return this._center;
- }
- set center(e2) {
- 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());
- }
- _updateZoomFromElevation() {
- if (null == this._seaLevelZoom || !this._elevation)
- return;
- 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);
- this._setZoom(this._zoomFromMercatorZ(n2));
- }
- get padding() {
- return this._edgeInsets.toJSON();
- }
- set padding(e2) {
- this._edgeInsets.equals(e2) || (this._unmodified = false, this._edgeInsets.interpolate(this._edgeInsets, e2, 1), this._calcMatrices());
- }
- computeZoomRelativeTo(t2) {
- const i3 = this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint, t2.toAltitude()));
- let o2;
- o2 = t2.z < this._camera.position[2] ? [i3.x, i3.y, i3.z] : [t2.x, t2.y, t2.z];
- const r2 = e.length(e.sub([], this._camera.position, o2));
- return e.clamp(this._zoomFromMercatorZ(r2), this._minZoom, this._maxZoom);
- }
- setFreeCameraOptions(t2) {
- if (!this.height)
- return;
- if (!t2.position && !t2.orientation)
- return;
- this._updateCameraState();
- let i3 = false;
- if (t2.orientation && !e.exactEquals(t2.orientation, this._camera.orientation) && (i3 = this._setCameraOrientation(t2.orientation)), t2.position) {
- const o2 = [t2.position.x, t2.position.y, t2.position.z];
- e.exactEquals$1(o2, this._camera.position) || (this._setCameraPosition(o2), i3 = true);
- }
- i3 && (this._updateStateFromCamera(), this.recenterOnTerrain());
- }
- getFreeCameraOptions() {
- this._updateCameraState();
- const t2 = this._camera.position, i3 = new Ao();
- 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;
- }
- _setCameraOrientation(t2) {
- if (!e.length$1(t2))
- return false;
- e.normalize$1(t2, t2);
- const i3 = e.transformQuat([], [0, 0, -1], t2), o2 = e.transformQuat([], [0, -1, 0], t2);
- if (o2[2] < 0)
- return false;
- const r2 = Po(i3, o2);
- return !!r2 && (this._camera.orientation = r2, true);
- }
- _setCameraPosition(t2) {
- const i3 = this.zoomScale(this.minZoom) * this.tileSize, o2 = this.zoomScale(this.maxZoom) * this.tileSize, r2 = this.cameraToCenterDistance;
- t2[2] = e.clamp(t2[2], r2 / o2, r2 / i3), this._camera.position = t2;
- }
- get centerPoint() {
- return this._edgeInsets.getCenter(this.width, this.height);
- }
- get fovAboveCenter() {
- return this._fov * (0.5 + this.centerOffset.y / this.height);
- }
- isPaddingEqual(e2) {
- return this._edgeInsets.equals(e2);
- }
- interpolatePadding(e2, t2, i3) {
- this._unmodified = false, this._edgeInsets.interpolate(e2, t2, i3), this._constrain(), this._calcMatrices();
- }
- coveringZoomLevel(e2) {
- const t2 = (e2.roundZoom ? Math.round : Math.floor)(this.zoom + this.scaleZoom(this.tileSize / e2.tileSize));
- return Math.max(0, t2);
- }
- getVisibleUnwrappedCoordinates(t2) {
- const i3 = [new e.UnwrappedTileID(0, t2)];
- if (this.renderWorldCopies) {
- 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;
- for (let o3 = s2 - c2; o3 <= l2 + c2; o3++)
- 0 !== o3 && i3.push(new e.UnwrappedTileID(o3, t2));
- }
- return i3;
- }
- coveringTiles(t2) {
- let i3 = this.coveringZoomLevel(t2);
- const o2 = i3, r2 = this.elevation && !t2.isTerrainDEM, n2 = "mercator" === this.projection.name;
- if (void 0 !== t2.minzoom && i3 < t2.minzoom)
- return [];
- void 0 !== t2.maxzoom && i3 > t2.maxzoom && (i3 = t2.maxzoom);
- 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) => {
- 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);
- return Math.sqrt(_3 * u3) * b2 / i4;
- }, T2 = (t3) => {
- const i4 = x2, o3 = y2;
- 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 };
- }, E2 = [];
- let C2 = [];
- const I2 = i3, M2 = t2.reparseOverscaled ? o2 : i3, S2 = (e2) => e2 * e2, z2 = S2((m2 - this._centerAltitude) * p2), D2 = (e2) => {
- if (!this._elevation || !e2.tileID || !n2)
- return;
- const t3 = this._elevation.getMinMaxForTile(e2.tileID), i4 = e2.aabb;
- 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));
- }, P2 = (t3) => {
- if (t3.zoom < v2)
- return true;
- if (t3.zoom === I2)
- return false;
- if (null != t3.shouldSplit)
- return t3.shouldSplit;
- const i4 = t3.aabb.distanceX(f2), n3 = t3.aabb.distanceY(f2);
- let a3 = z2, l3 = 1;
- if (h2) {
- a3 = S2(t3.aabb.distanceZ(f2));
- 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);
- l3 = Math.min(c4, 1);
- } else if (r2 && (a3 = S2(t3.aabb.distanceZ(f2) * p2)), this.projection.isReprojectedInTileSpace && o2 <= 5) {
- const i5 = Math.pow(2, t3.zoom), o3 = w2(new e.MercatorCoordinate((t3.x + 0.5) / i5, (t3.y + 0.5) / i5));
- l3 = o3 > 0.85 ? 1 : o3;
- }
- const c3 = i4 * i4 + n3 * n3 + a3;
- return c3 < S2((1 << I2 - t3.zoom) * g2 * l3 * ((e2, t4) => {
- if (t4 * S2(0.707) < e2)
- return 1;
- const i5 = Math.sqrt(t4 / e2);
- return i5 / (1.4144271570014144 + (Math.pow(1.1, i5 - 1.4144271570014144 + 1) - 1) / (1.1 - 1) - 1);
- })(Math.max(a3, z2), c3));
- };
- if (this.renderWorldCopies)
- for (let e2 = 1; e2 <= 3; e2++)
- E2.push(T2(-e2)), E2.push(T2(e2));
- for (E2.push(T2(0)); E2.length > 0; ) {
- const o3 = E2.pop(), a3 = o3.x, s3 = o3.y;
- let _3 = o3.fullyVisible;
- if (!_3) {
- const e2 = o3.aabb.intersects(u2);
- if (0 === e2)
- continue;
- _3 = 2 === e2;
- }
- if (o3.zoom !== I2 && P2(o3))
- for (let t3 = 0; t3 < 4; t3++) {
- 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 };
- 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);
- }
- else {
- const r3 = o3.zoom === I2 ? M2 : o3.zoom;
- if (t2.minzoom && t2.minzoom > r3)
- continue;
- 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);
- C2.push({ tileID: h3, distanceSq: n3 * n3 + l3 * l3 });
- }
- }
- if (this.fogCullDistSq) {
- const i4 = this.fogCullDistSq, o3 = this.horizonLineFromTop();
- C2 = C2.filter((r3) => {
- const n3 = [0, 0, 0, 1], a3 = [e.EXTENT, e.EXTENT, 0, 1], s3 = this.calculateFogTileMatrix(r3.tileID.toUnwrapped());
- e.transformMat4$1(n3, n3, s3), e.transformMat4$1(a3, a3, s3);
- const l3 = e.getAABBPointSquareDist(n3, a3);
- if (0 === l3)
- return true;
- let c3 = false;
- const h3 = this._elevation;
- if (h3 && l3 > i4 && 0 !== o3) {
- const i5 = this.calculateProjMatrix(r3.tileID.toUnwrapped());
- let n4;
- t2.isTerrainDEM || (n4 = h3.getMinMaxForTile(r3.tileID)), n4 || (n4 = { min: y2, max: x2 });
- const a4 = e.furthestTileCorner(this.rotation), s4 = [a4[0] * e.EXTENT, a4[1] * e.EXTENT, n4.max];
- e.transformMat4(s4, s4, i5), c3 = (1 - s4[1]) * this.height * 0.5 < o3;
- }
- return l3 < i4 || c3;
- });
- }
- return C2.sort((e2, t3) => e2.distanceSq - t3.distanceSq).map((e2) => e2.tileID);
- }
- resize(e2, t2) {
- this.width = e2, this.height = t2, this.pixelsToGLUnits = [2 / e2, -2 / t2], this._constrain(), this._calcMatrices();
- }
- get unmodified() {
- return this._unmodified;
- }
- zoomScale(e2) {
- return Math.pow(2, e2);
- }
- scaleZoom(e2) {
- return Math.log(e2) / Math.LN2;
- }
- project(t2) {
- const i3 = e.clamp(t2.lat, -e.MAX_MERCATOR_LATITUDE, e.MAX_MERCATOR_LATITUDE), o2 = this.projection.project(t2.lng, i3);
- return new e.pointGeometry(o2.x * this.worldSize, o2.y * this.worldSize);
- }
- unproject(e2) {
- return this.projection.unproject(e2.x / this.worldSize, e2.y / this.worldSize);
- }
- get point() {
- return this.project(this.center);
- }
- setLocationAtPoint(t2, i3) {
- let o2, r2;
- const n2 = this.centerPoint;
- if ("globe" === this.projection.name) {
- const e2 = this.worldSize;
- o2 = (i3.x - n2.x) / e2, r2 = (i3.y - n2.y) / e2;
- } else {
- const e2 = this.pointCoordinate(i3), t3 = this.pointCoordinate(n2);
- o2 = e2.x - t3.x, r2 = e2.y - t3.y;
- }
- const a2 = this.locationCoordinate(t2);
- this.setLocation(new e.MercatorCoordinate(a2.x - o2, a2.y - r2));
- }
- setLocation(e2) {
- this.center = this.coordinateLocation(e2), this.projection.wrap && (this.center = this.center.wrap());
- }
- locationPoint(e2) {
- return this.projection.locationPoint(this, e2);
- }
- locationPoint3D(e2) {
- return this._coordinatePoint(this.locationCoordinate(e2), true);
- }
- pointLocation(e2) {
- return this.coordinateLocation(this.pointCoordinate(e2));
- }
- pointLocation3D(e2) {
- return this.coordinateLocation(this.pointCoordinate3D(e2));
- }
- locationCoordinate(t2, i3) {
- const o2 = i3 ? e.mercatorZfromAltitude(i3, t2.lat) : void 0, r2 = this.projection.project(t2.lng, t2.lat);
- return new e.MercatorCoordinate(r2.x, r2.y, o2);
- }
- coordinateLocation(e2) {
- return this.projection.unproject(e2.x, e2.y);
- }
- pointRayIntersection(t2, i3) {
- const o2 = null != i3 ? i3 : this._centerAltitude, r2 = [t2.x, t2.y, 0, 1], n2 = [t2.x, t2.y, 1, 1];
- e.transformMat4$1(r2, r2, this.pixelMatrixInverse), e.transformMat4$1(n2, n2, this.pixelMatrixInverse);
- const a2 = n2[3];
- e.scale$1(r2, r2, 1 / r2[3]), e.scale$1(n2, n2, 1 / a2);
- const s2 = r2[2], l2 = n2[2];
- return { p0: r2, p1: n2, t: s2 === l2 ? 0 : (o2 - s2) / (l2 - s2) };
- }
- screenPointToMercatorRay(t2) {
- const i3 = [t2.x, t2.y, 0, 1], o2 = [t2.x, t2.y, 1, 1];
- 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)));
- }
- rayIntersectionCoordinate(t2) {
- const { p0: i3, p1: o2, t: r2 } = t2, n2 = e.mercatorZfromAltitude(i3[2], this._center.lat), a2 = e.mercatorZfromAltitude(o2[2], this._center.lat);
- 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));
- }
- pointCoordinate(e2, t2 = this._centerAltitude) {
- return this.projection.pointCoordinate(this, e2.x, e2.y, t2);
- }
- pointCoordinate3D(t2) {
- if (!this.elevation)
- return this.pointCoordinate(t2);
- const i3 = this.elevation;
- let o2 = this.elevation.pointCoordinate(t2);
- if (o2)
- return new e.MercatorCoordinate(o2[0], o2[1], o2[2]);
- let r2 = 0, n2 = this.horizonLineFromTop();
- if (t2.y > n2)
- return this.pointCoordinate(t2);
- const a2 = 0.02 * n2, s2 = t2.clone();
- for (let t3 = 0; t3 < 10 && n2 - r2 > a2; t3++) {
- s2.y = e.number(r2, n2, 0.66);
- const t4 = i3.pointCoordinate(s2);
- t4 ? (n2 = s2.y, o2 = t4) : r2 = s2.y;
- }
- return o2 ? new e.MercatorCoordinate(o2[0], o2[1], o2[2]) : this.pointCoordinate(t2);
- }
- isPointAboveHorizon(e2) {
- if (this.elevation)
- return !this.elevation.pointCoordinate(e2);
- {
- const t2 = this.horizonLineFromTop();
- return e2.y < t2;
- }
- }
- _coordinatePoint(t2, i3) {
- 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];
- 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);
- }
- _getBounds(t2, i3) {
- 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);
- let s2 = this.pointCoordinate(o2, t2), l2 = this.pointCoordinate(r2, t2);
- const c2 = this.pointCoordinate(n2, i3), h2 = this.pointCoordinate(a2, i3), _2 = (e2, t3) => (t3.y - e2.y) / (t3.x - e2.x);
- 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));
- }
- _getBounds3D() {
- const e2 = this.elevation;
- if (!e2.visibleDemTiles.length)
- return this._getBounds(0, 0);
- const t2 = e2.visibleDemTiles.reduce((e3, t3) => {
- if (t3.dem) {
- const i3 = t3.dem.tree;
- e3.min = Math.min(e3.min, i3.minimums[0]), e3.max = Math.max(e3.max, i3.maximums[0]);
- }
- return e3;
- }, { min: Number.MAX_VALUE, max: 0 });
- return this._getBounds(t2.min * e2.exaggeration(), t2.max * e2.exaggeration());
- }
- getBounds() {
- return this._terrainEnabled() ? this._getBounds3D() : this._getBounds(0, 0);
- }
- horizonLineFromTop(e2 = true) {
- 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);
- return e2 ? Math.max(0, i3) : i3;
- }
- getMaxBounds() {
- return this.maxBounds;
- }
- setMaxBounds(t2) {
- 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();
- }
- calculatePosMatrix(e2, t2) {
- return this.projection.createTileMatrix(this, t2, e2);
- }
- calculateDistanceTileData(t2) {
- const i3 = t2.key, o2 = this._distanceTileDataCache;
- if (o2[i3])
- return o2[i3];
- 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);
- return o2[i3] = { bearing: [_2, u2], center: [(c2.x - s2) * n2, (c2.y - l2) * n2], scale: a2 / e.EXTENT * n2 }, o2[i3];
- }
- calculateFogTileMatrix(t2) {
- const i3 = t2.key, o2 = this._fogTileMatrixCache;
- if (o2[i3])
- return o2[i3];
- const r2 = this.calculatePosMatrix(t2, this.cameraWorldSize);
- return e.multiply$1(r2, this.worldToFogMatrix, r2), o2[i3] = new Float32Array(r2), o2[i3];
- }
- calculateProjMatrix(t2, i3 = false) {
- const o2 = t2.key, r2 = i3 ? this._alignedProjMatrixCache : this._projMatrixCache;
- if (r2[o2])
- return r2[o2];
- const n2 = this.calculatePosMatrix(t2, this.worldSize);
- return e.multiply$1(n2, this.projection.isReprojectedInTileSpace ? this.mercatorMatrix : i3 ? this.alignedProjMatrix : this.projMatrix, n2), r2[o2] = new Float32Array(n2), r2[o2];
- }
- calculatePixelsToTileUnitsMatrix(t2) {
- const i3 = t2.tileID.key, o2 = this._pixelsToTileUnitsCache;
- if (o2[i3])
- return o2[i3];
- const r2 = function(t3, i4) {
- const { scale: o3 } = t3.tileTransform, r3 = o3 * e.EXTENT / (t3.tileSize * Math.pow(2, i4.zoom - t3.tileID.overscaledZ + t3.tileID.canonical.z));
- 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;
- var n2, a2, s2, l2, c2, h2, _2, u2;
- }(t2, this);
- return o2[i3] = r2, o2[i3];
- }
- customLayerMatrix() {
- return this.mercatorMatrix.slice();
- }
- recenterOnTerrain() {
- if (!this._elevation)
- return;
- const t2 = this._elevation;
- this._updateCameraState();
- 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);
- o2[2] /= n2, r2[2] /= n2, e.normalize(r2, r2);
- const a2 = t2.raycast(o2, r2, t2.exaggeration());
- if (a2) {
- 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;
- this._seaLevelZoom = this._zoomFromMercatorZ(s2), this._centerAltitude = i4.toAltitude(), this._center = this.coordinateLocation(i4), this._updateZoomFromElevation(), this._constrain(), this._calcMatrices();
- }
- }
- _constrainCameraAltitude() {
- if (!this._elevation)
- return;
- const t2 = this._elevation;
- this._updateCameraState();
- 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;
- if (a2 < n2) {
- 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);
- i4[2] -= (n2 - a2) / this._projectionScaler;
- const s2 = e.length(i4);
- if (0 === s2)
- return;
- 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();
- }
- }
- _constrain() {
- if (!this.center || !this.width || !this.height || this._constraining)
- return;
- if (this._constraining = true, this.projection.isReprojectedInTileSpace) {
- const t3 = this.center;
- 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);
- }
- const t2 = this._unmodified, { x: i3, y: o2 } = this.point;
- let r2 = 0, n2 = i3, a2 = o2;
- const s2 = this.width / 2, l2 = this.height / 2, c2 = this.worldMinY * this.scale, h2 = this.worldMaxY * this.scale;
- 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) {
- const e2 = this.worldMinX * this.scale, t3 = this.worldMaxX * this.scale, o3 = this.worldSize / 2 - (e2 + t3) / 2;
- 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);
- }
- 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;
- }
- _minZoomForBounds() {
- let e2 = Math.max(0, this.scaleZoom(this.height / (this.worldMaxY - this.worldMinY)));
- return this.maxBounds && (e2 = Math.max(e2, this.scaleZoom(this.width / (this.worldMaxX - this.worldMinX)))), e2;
- }
- _maxCameraBoundsDistance() {
- return this._mercatorZfromZoom(this._minZoomForBounds());
- }
- _calcMatrices() {
- if (!this.height)
- return;
- const t2 = this._fov / 2, i3 = this.centerOffset, o2 = this.pixelsPerMeter;
- 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;
- 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);
- n2[8] = 2 * -i3.x / this.width, n2[9] = 2 * i3.y / this.height;
- let a2 = e.mul([], n2, r2);
- if (this.projection.isReprojectedInTileSpace) {
- const t3 = this.locationCoordinate(this.center), i4 = e.identity([]);
- 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) {
- const t4 = Ro(e2, true);
- return v([], [t4[0], t4[1], t4[4], t4[5]]);
- }(this);
- } else
- this.inverseAdjustmentMatrix = [1, 0, 0, 1];
- 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);
- const s2 = new Float32Array(16);
- e.identity(s2), e.scale(s2, s2, [1, -1, 1]), e.rotateX(s2, s2, this._pitch), e.rotateZ(s2, s2, this.angle);
- 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;
- l2[8] = 2 * -i3.x / this.width, l2[9] = 2 * (i3.y + c2) / this.height, this.skyboxMatrix = e.multiply$1(s2, l2, s2);
- 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);
- 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)
- throw new Error("failed to invert matrix");
- this.pixelMatrixInverse = a2, this.globeMatrix = "globe" === this.projection.name ? e.calculateGlobeMatrix(this) : a2, this._projMatrixCache = {}, this._alignedProjMatrixCache = {}, this._pixelsToTileUnitsCache = {};
- }
- _calcFogMatrices() {
- this._fogTileMatrixCache = {};
- const t2 = this.cameraWorldSize, i3 = this.cameraPixelsPerMeter, o2 = this._camera.position, r2 = 1 / this.height, n2 = [t2, t2, i3];
- e.scale$2(n2, n2, r2), e.scale$2(o2, o2, -1), e.multiply$2(o2, o2, n2);
- const a2 = e.create();
- e.translate(a2, a2, o2), e.scale(a2, a2, n2), this.mercatorFogMatrix = a2, this.worldToFogMatrix = this._camera.getWorldToCameraPosition(t2, i3, r2);
- }
- _computeCameraPosition(e2) {
- 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;
- return [o2.x / this.worldSize - i3[0] * r2, o2.y / this.worldSize - i3[1] * r2, e2 / this.worldSize * this._centerAltitude - i3[2] * r2];
- }
- _updateCameraState() {
- this.height && (this._camera.setPitchBearing(this._pitch, this.angle), this._camera.position = this._computeCameraPosition());
- }
- _translateCameraConstrained(t2) {
- const i3 = this._maxCameraBoundsDistance() * Math.cos(this._pitch), o2 = t2[2];
- let r2 = 1;
- 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());
- }
- _updateStateFromCamera() {
- 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);
- 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();
- }
- _worldSizeFromZoom(e2) {
- return Math.pow(2, e2) * this.tileSize;
- }
- _mercatorZfromZoom(e2) {
- return this.cameraToCenterDistance / this._worldSizeFromZoom(e2);
- }
- _minimumHeightOverTerrain() {
- const e2 = Math.min((null != this._seaLevelZoom ? this._seaLevelZoom : this._zoom) + 2, this._maxZoom);
- return this._mercatorZfromZoom(e2);
- }
- _zoomFromMercatorZ(e2) {
- return this.scaleZoom(this.cameraToCenterDistance / (e2 * this.tileSize));
- }
- _terrainEnabled() {
- return !(!this._elevation || !this.projection.supportsTerrain && (e.warnOnce("Terrain is not yet supported with alternate projections. Use mercator to enable terrain."), 1));
- }
- anyCornerOffEdge(t2, i3) {
- 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);
- if (n2 < this.horizonLineFromTop(false))
- return true;
- if ("mercator" !== this.projection.name)
- return false;
- 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;
- for (const e2 of s2) {
- const t3 = this.pointRayIntersection(e2);
- if (t3.t < 0)
- return true;
- const i4 = this.rayIntersectionCoordinate(t3);
- if (i4.x < l2 || i4.y < 0 || i4.x > c2 || i4.y > 1)
- return true;
- }
- return false;
- }
- isHorizonVisible() {
- return this.pitch + e.radToDeg(this.fovAboveCenter) > 88 || this.anyCornerOffEdge(new e.pointGeometry(0, 0), new e.pointGeometry(this.width, this.height));
- }
- zoomDeltaToMovement(t2, i3) {
- const o2 = e.length(e.sub([], this._camera.position, t2)), r2 = this._zoomFromMercatorZ(o2) + i3;
- return o2 - this._mercatorZfromZoom(r2);
- }
- getCameraPoint() {
- const t2 = Math.tan(this._pitch) * (this.cameraToCenterDistance || 1);
- return this.centerPoint.add(new e.pointGeometry(0, t2));
- }
- }
- function Go(e2, t2) {
- let i3 = false, o2 = null;
- const r2 = () => {
- o2 = null, i3 && (e2(), o2 = setTimeout(r2, t2), i3 = false);
- };
- return () => (i3 = true, o2 || r2(), o2);
- }
- class jo {
- constructor(t2) {
- this._hashName = t2 && encodeURIComponent(t2), e.bindAll(["_getCurrentHash", "_onHashChange", "_updateHash"], this), this._updateHash = Go(this._updateHashUnthrottled.bind(this), 300);
- }
- addTo(t2) {
- return this._map = t2, e.window.addEventListener("hashchange", this._onHashChange, false), t2.on("moveend", this._updateHash), this;
- }
- remove() {
- 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;
- }
- getHashString(t2) {
- const i3 = this._map;
- if (!i3)
- return "";
- 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();
- let _2 = "";
- if (_2 += t2 ? `/${s2}/${l2}/${r2}` : `${r2}/${l2}/${s2}`, (c2 || h2) && (_2 += "/" + Math.round(10 * c2) / 10), h2 && (_2 += `/${Math.round(h2)}`), this._hashName) {
- const t3 = this._hashName;
- let i4 = false;
- const o3 = e.window.location.hash.slice(1).split("&").map((e2) => {
- const o4 = e2.split("=")[0];
- return o4 === t3 ? (i4 = true, `${o4}=${_2}`) : e2;
- }).filter((e2) => e2);
- return i4 || o3.push(`${t3}=${_2}`), `#${o3.join("&")}`;
- }
- return `#${_2}`;
- }
- _getCurrentHash() {
- const t2 = e.window.location.hash.replace("#", "");
- if (this._hashName) {
- let e2;
- return t2.split("&").map((e3) => e3.split("=")).forEach((t3) => {
- t3[0] === this._hashName && (e2 = t3);
- }), (e2 && e2[1] || "").split("/");
- }
- return t2.split("/");
- }
- _onHashChange() {
- const e2 = this._map;
- if (!e2)
- return false;
- const t2 = this._getCurrentHash();
- if (t2.length >= 3 && !t2.some((e3) => isNaN(e3))) {
- const i3 = e2.dragRotate.isEnabled() && e2.touchZoomRotate.isEnabled() ? +(t2[3] || 0) : e2.getBearing();
- return e2.jumpTo({ center: [+t2[2], +t2[1]], zoom: +t2[0], bearing: i3, pitch: +(t2[4] || 0) }), true;
- }
- return false;
- }
- _updateHashUnthrottled() {
- const t2 = e.window.location.href.replace(/(#.+)?$/, this.getHashString());
- e.window.history.replaceState(e.window.history.state, null, t2);
- }
- }
- 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);
- class $o {
- constructor(e2) {
- this._map = e2, this.clear();
- }
- clear() {
- this._inertiaBuffer = [];
- }
- record(t2) {
- this._drainInertiaBuffer(), this._inertiaBuffer.push({ time: e.exported.now(), settings: t2 });
- }
- _drainInertiaBuffer() {
- const t2 = this._inertiaBuffer, i3 = e.exported.now();
- for (; t2.length > 0 && i3 - t2[0].time > 160; )
- t2.shift();
- }
- _onMoveEnd(t2) {
- if (this._drainInertiaBuffer(), this._inertiaBuffer.length < 2)
- return;
- const i3 = { zoom: 0, bearing: 0, pitch: 0, pan: new e.pointGeometry(0, 0), pinchAround: void 0, around: void 0 };
- for (const { settings: e2 } of this._inertiaBuffer)
- 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);
- const o2 = this._inertiaBuffer[this._inertiaBuffer.length - 1].time - this._inertiaBuffer[0].time, r2 = {};
- if (i3.pan.mag()) {
- const n2 = Ko(i3.pan.mag(), o2, e.extend({}, Vo, t2 || {}));
- r2.offset = i3.pan.mult(n2.amount / i3.pan.mag()), r2.center = this._map.transform.center, Ho(r2, n2);
- }
- if (i3.zoom) {
- const e2 = Ko(i3.zoom, o2, Wo);
- r2.zoom = this._map.transform.zoom + e2.amount, Ho(r2, e2);
- }
- if (i3.bearing) {
- const t3 = Ko(i3.bearing, o2, qo);
- r2.bearing = this._map.transform.bearing + e.clamp(t3.amount, -179, 179), Ho(r2, t3);
- }
- if (i3.pitch) {
- const e2 = Ko(i3.pitch, o2, Xo);
- r2.pitch = this._map.transform.pitch + e2.amount, Ho(r2, e2);
- }
- if (r2.zoom || r2.bearing) {
- const e2 = void 0 === i3.pinchAround ? i3.around : i3.pinchAround;
- r2.around = e2 ? this._map.unproject(e2) : this._map.getCenter();
- }
- return this.clear(), r2.noMoveStart = true, r2;
- }
- }
- function Ho(e2, t2) {
- (!e2.duration || e2.duration < t2.duration) && (e2.duration = t2.duration, e2.easing = t2.easing);
- }
- function Ko(t2, i3, o2) {
- const { maxSpeed: r2, linearity: n2, deceleration: a2 } = o2, s2 = e.clamp(t2 * n2 / (i3 / 1e3), -r2, r2), l2 = Math.abs(s2) / (a2 * n2);
- return { easing: o2.easing, duration: 1e3 * l2, amount: s2 * (l2 / 2) };
- }
- class Yo extends e.Event {
- preventDefault() {
- this._defaultPrevented = true;
- }
- get defaultPrevented() {
- return this._defaultPrevented;
- }
- constructor(t2, i3, o2, r2 = {}) {
- const n2 = p(i3.getCanvasContainer(), o2), a2 = i3.unproject(n2);
- super(t2, e.extend({ point: n2, lngLat: a2, originalEvent: o2 }, r2)), this._defaultPrevented = false, this.target = i3;
- }
- }
- class Jo extends e.Event {
- preventDefault() {
- this._defaultPrevented = true;
- }
- get defaultPrevented() {
- return this._defaultPrevented;
- }
- constructor(t2, i3, o2) {
- 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));
- super(t2, { points: n2, point: s2, lngLats: a2, lngLat: i3.unproject(s2), originalEvent: o2 }), this._defaultPrevented = false;
- }
- }
- class Qo extends e.Event {
- preventDefault() {
- this._defaultPrevented = true;
- }
- get defaultPrevented() {
- return this._defaultPrevented;
- }
- constructor(e2, t2, i3) {
- super(e2, { originalEvent: i3 }), this._defaultPrevented = false;
- }
- }
- class er {
- constructor(e2, t2) {
- this._map = e2, this._clickTolerance = t2.clickTolerance;
- }
- reset() {
- this._mousedownPos = void 0;
- }
- wheel(e2) {
- return this._firePreventable(new Qo(e2.type, this._map, e2));
- }
- mousedown(e2, t2) {
- return this._mousedownPos = t2, this._firePreventable(new Yo(e2.type, this._map, e2));
- }
- mouseup(e2) {
- this._map.fire(new Yo(e2.type, this._map, e2));
- }
- preclick(t2) {
- const i3 = e.extend({}, t2);
- i3.type = "preclick", this._map.fire(new Yo(i3.type, this._map, i3));
- }
- click(e2, t2) {
- this._mousedownPos && this._mousedownPos.dist(t2) >= this._clickTolerance || (this.preclick(e2), this._map.fire(new Yo(e2.type, this._map, e2)));
- }
- dblclick(e2) {
- return this._firePreventable(new Yo(e2.type, this._map, e2));
- }
- mouseover(e2) {
- this._map.fire(new Yo(e2.type, this._map, e2));
- }
- mouseout(e2) {
- this._map.fire(new Yo(e2.type, this._map, e2));
- }
- touchstart(e2) {
- return this._firePreventable(new Jo(e2.type, this._map, e2));
- }
- touchmove(e2) {
- this._map.fire(new Jo(e2.type, this._map, e2));
- }
- touchend(e2) {
- this._map.fire(new Jo(e2.type, this._map, e2));
- }
- touchcancel(e2) {
- this._map.fire(new Jo(e2.type, this._map, e2));
- }
- _firePreventable(e2) {
- if (this._map.fire(e2), e2.defaultPrevented)
- return {};
- }
- isEnabled() {
- return true;
- }
- isActive() {
- return false;
- }
- enable() {
- }
- disable() {
- }
- }
- class tr {
- constructor(e2) {
- this._map = e2;
- }
- reset() {
- this._delayContextMenu = false, this._contextMenuEvent = void 0;
- }
- mousemove(e2) {
- this._map.fire(new Yo(e2.type, this._map, e2));
- }
- mousedown() {
- this._delayContextMenu = true;
- }
- mouseup() {
- this._delayContextMenu = false, this._contextMenuEvent && (this._map.fire(new Yo("contextmenu", this._map, this._contextMenuEvent)), delete this._contextMenuEvent);
- }
- contextmenu(e2) {
- this._delayContextMenu ? this._contextMenuEvent = e2 : this._map.fire(new Yo(e2.type, this._map, e2)), this._map.listens("contextmenu") && e2.preventDefault();
- }
- isEnabled() {
- return true;
- }
- isActive() {
- return false;
- }
- enable() {
- }
- disable() {
- }
- }
- class ir {
- constructor(e2, t2) {
- this._map = e2, this._el = e2.getCanvasContainer(), this._container = e2.getContainer(), this._clickTolerance = t2.clickTolerance || 1;
- }
- isEnabled() {
- return !!this._enabled;
- }
- isActive() {
- return !!this._active;
- }
- enable() {
- this.isEnabled() || (this._enabled = true);
- }
- disable() {
- this.isEnabled() && (this._enabled = false);
- }
- mousedown(e2, t2) {
- this.isEnabled() && e2.shiftKey && 0 === e2.button && (h(), this._startPos = this._lastPos = t2, this._active = true);
- }
- mousemoveWindow(e2, t2) {
- if (!this._active)
- return;
- const i3 = t2;
- if (this._lastPos.equals(i3) || !this._box && i3.dist(this._startPos) < this._clickTolerance)
- return;
- const o2 = this._startPos;
- this._lastPos = i3, this._box || (this._box = n("div", "mapboxgl-boxzoom", this._container), this._container.classList.add("mapboxgl-crosshair"), this._fireEvent("boxzoomstart", e2));
- 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);
- this._map._requestDomTask(() => {
- 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");
- });
- }
- mouseupWindow(t2, i3) {
- if (!this._active)
- return;
- if (0 !== t2.button)
- return;
- const o2 = this._startPos, r2 = i3;
- if (this.reset(), d(), o2.x !== r2.x || o2.y !== r2.y)
- return this._map.fire(new e.Event("boxzoomend", { originalEvent: t2 })), { cameraAnimation: (e2) => e2.fitScreenCoordinates(o2, r2, this._map.getBearing(), { linear: false }) };
- this._fireEvent("boxzoomcancel", t2);
- }
- keydown(e2) {
- this._active && 27 === e2.keyCode && (this.reset(), this._fireEvent("boxzoomcancel", e2));
- }
- blur() {
- this.reset();
- }
- reset() {
- this._active = false, this._container.classList.remove("mapboxgl-crosshair"), this._box && (this._box.remove(), this._box = null), _(), delete this._startPos, delete this._lastPos;
- }
- _fireEvent(t2, i3) {
- return this._map.fire(new e.Event(t2, { originalEvent: i3 }));
- }
- }
- function or(e2, t2) {
- const i3 = {};
- for (let o2 = 0; o2 < e2.length; o2++)
- i3[e2[o2].identifier] = t2[o2];
- return i3;
- }
- class rr {
- constructor(e2) {
- this.reset(), this.numTouches = e2.numTouches;
- }
- reset() {
- this.centroid = void 0, this.startTime = 0, this.touches = {}, this.aborted = false;
- }
- touchstart(t2, i3, o2) {
- (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) {
- const i4 = new e.pointGeometry(0, 0);
- for (const e2 of t3)
- i4._add(e2);
- return i4.div(t3.length);
- }(i3), this.touches = or(o2, i3)));
- }
- touchmove(e2, t2, i3) {
- if (this.aborted || !this.centroid)
- return;
- const o2 = or(i3, t2);
- for (const e3 in this.touches) {
- const t3 = this.touches[e3], i4 = o2[e3];
- (!i4 || i4.dist(t3) > 30) && (this.aborted = true);
- }
- }
- touchend(e2, t2, i3) {
- if ((!this.centroid || e2.timeStamp - this.startTime > 500) && (this.aborted = true), 0 === i3.length) {
- const e3 = !this.aborted && this.centroid;
- if (this.reset(), e3)
- return e3;
- }
- }
- }
- class nr {
- constructor(e2) {
- this.singleTap = new rr(e2), this.numTaps = e2.numTaps, this.reset();
- }
- reset() {
- this.lastTime = 1 / 0, this.lastTap = void 0, this.count = 0, this.singleTap.reset();
- }
- touchstart(e2, t2, i3) {
- this.singleTap.touchstart(e2, t2, i3);
- }
- touchmove(e2, t2, i3) {
- this.singleTap.touchmove(e2, t2, i3);
- }
- touchend(e2, t2, i3) {
- const o2 = this.singleTap.touchend(e2, t2, i3);
- if (o2) {
- const t3 = e2.timeStamp - this.lastTime < 500, i4 = !this.lastTap || this.lastTap.dist(o2) < 30;
- if (t3 && i4 || this.reset(), this.count++, this.lastTime = e2.timeStamp, this.lastTap = o2, this.count === this.numTaps)
- return this.reset(), o2;
- }
- }
- }
- class ar {
- constructor() {
- this._zoomIn = new nr({ numTouches: 1, numTaps: 2 }), this._zoomOut = new nr({ numTouches: 2, numTaps: 1 }), this.reset();
- }
- reset() {
- this._active = false, this._zoomIn.reset(), this._zoomOut.reset();
- }
- touchstart(e2, t2, i3) {
- this._zoomIn.touchstart(e2, t2, i3), this._zoomOut.touchstart(e2, t2, i3);
- }
- touchmove(e2, t2, i3) {
- this._zoomIn.touchmove(e2, t2, i3), this._zoomOut.touchmove(e2, t2, i3);
- }
- touchend(e2, t2, i3) {
- const o2 = this._zoomIn.touchend(e2, t2, i3), r2 = this._zoomOut.touchend(e2, t2, i3);
- 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;
- }
- touchcancel() {
- this.reset();
- }
- enable() {
- this._enabled = true;
- }
- disable() {
- this._enabled = false, this.reset();
- }
- isEnabled() {
- return this._enabled;
- }
- isActive() {
- return this._active;
- }
- }
- const sr = { 0: 1, 2: 2 };
- class lr {
- constructor(e2) {
- this.reset(), this._clickTolerance = e2.clickTolerance || 1;
- }
- blur() {
- this.reset();
- }
- reset() {
- this._active = false, this._moved = false, this._lastPoint = void 0, this._eventButton = void 0;
- }
- _correctButton(e2, t2) {
- return false;
- }
- _move(e2, t2) {
- return {};
- }
- mousedown(e2, t2) {
- if (this._lastPoint)
- return;
- const i3 = f(e2);
- this._correctButton(e2, i3) && (this._lastPoint = t2, this._eventButton = i3);
- }
- mousemoveWindow(e2, t2) {
- const i3 = this._lastPoint;
- if (i3) {
- if (e2.preventDefault(), null != this._eventButton && function(e3, t3) {
- const i4 = sr[t3];
- return void 0 === e3.buttons || (e3.buttons & i4) !== i4;
- }(e2, this._eventButton))
- this.reset();
- else if (this._moved || !(t2.dist(i3) < this._clickTolerance))
- return this._moved = true, this._lastPoint = t2, this._move(i3, t2);
- }
- }
- mouseupWindow(e2) {
- this._lastPoint && f(e2) === this._eventButton && (this._moved && d(), this.reset());
- }
- enable() {
- this._enabled = true;
- }
- disable() {
- this._enabled = false, this.reset();
- }
- isEnabled() {
- return this._enabled;
- }
- isActive() {
- return this._active;
- }
- }
- class cr extends lr {
- mousedown(e2, t2) {
- super.mousedown(e2, t2), this._lastPoint && (this._active = true);
- }
- _correctButton(e2, t2) {
- return 0 === t2 && !e2.ctrlKey;
- }
- _move(e2, t2) {
- return { around: t2, panDelta: t2.sub(e2) };
- }
- }
- class hr extends lr {
- _correctButton(e2, t2) {
- return 0 === t2 && e2.ctrlKey || 2 === t2;
- }
- _move(e2, t2) {
- const i3 = 0.8 * (t2.x - e2.x);
- if (i3)
- return this._active = true, { bearingDelta: i3 };
- }
- contextmenu(e2) {
- e2.preventDefault();
- }
- }
- class _r extends lr {
- _correctButton(e2, t2) {
- return 0 === t2 && e2.ctrlKey || 2 === t2;
- }
- _move(e2, t2) {
- const i3 = -0.5 * (t2.y - e2.y);
- if (i3)
- return this._active = true, { pitchDelta: i3 };
- }
- contextmenu(e2) {
- e2.preventDefault();
- }
- }
- class ur {
- constructor(t2, i3) {
- this._map = t2, this._el = t2.getCanvasContainer(), this._minTouches = 1, this._clickTolerance = i3.clickTolerance || 1, this.reset(), e.bindAll(["_addTouchPanBlocker", "_showTouchPanBlockerAlert"], this);
- }
- reset() {
- this._active = false, this._touches = {}, this._sum = new e.pointGeometry(0, 0);
- }
- touchstart(e2, t2, i3) {
- return this._calculateTransform(e2, t2, i3);
- }
- touchmove(e2, t2, i3) {
- if (this._active && !(i3.length < this._minTouches)) {
- if (this._map._cooperativeGestures && !this._map.isMoving()) {
- if (1 === i3.length)
- return void this._showTouchPanBlockerAlert();
- "hidden" !== this._alertContainer.style.visibility && (this._alertContainer.style.visibility = "hidden", clearTimeout(this._alertTimer));
- }
- return e2.preventDefault(), this._calculateTransform(e2, t2, i3);
- }
- }
- touchend(e2, t2, i3) {
- this._calculateTransform(e2, t2, i3), this._active && i3.length < this._minTouches && this.reset();
- }
- touchcancel() {
- this.reset();
- }
- _calculateTransform(t2, i3, o2) {
- o2.length > 0 && (this._active = true);
- const r2 = or(o2, i3), n2 = new e.pointGeometry(0, 0), a2 = new e.pointGeometry(0, 0);
- let s2 = 0;
- for (const e2 in r2) {
- const t3 = r2[e2], i4 = this._touches[e2];
- i4 && (n2._add(t3), a2._add(t3.sub(i4)), s2++, r2[e2] = t3);
- }
- if (this._touches = r2, s2 < this._minTouches || !a2.mag())
- return;
- const l2 = a2.div(s2);
- return this._sum._add(l2), this._sum.mag() < this._clickTolerance ? void 0 : { around: n2.div(s2), panDelta: l2 };
- }
- enable() {
- this._enabled = true, this._map._cooperativeGestures && (this._addTouchPanBlocker(), this._el.classList.add("mapboxgl-touch-pan-blocker-override", "mapboxgl-scrollable-page"));
- }
- disable() {
- 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();
- }
- isEnabled() {
- return this._enabled;
- }
- isActive() {
- return this._active;
- }
- _addTouchPanBlocker() {
- 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`);
- }
- _showTouchPanBlockerAlert() {
- "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(() => {
- this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show");
- }, 500);
- }
- }
- class dr {
- constructor() {
- this.reset();
- }
- reset() {
- this._active = false, this._firstTwoTouches = void 0;
- }
- _start(e2) {
- }
- _move(e2, t2, i3) {
- return {};
- }
- touchstart(e2, t2, i3) {
- this._firstTwoTouches || i3.length < 2 || (this._firstTwoTouches = [i3[0].identifier, i3[1].identifier], this._start([t2[0], t2[1]]));
- }
- touchmove(e2, t2, i3) {
- const o2 = this._firstTwoTouches;
- if (!o2)
- return;
- e2.preventDefault();
- const [r2, n2] = o2, a2 = pr(i3, t2, r2), s2 = pr(i3, t2, n2);
- if (!a2 || !s2)
- return;
- const l2 = this._aroundCenter ? null : a2.add(s2).div(2);
- return this._move([a2, s2], l2, e2);
- }
- touchend(e2, t2, i3) {
- if (!this._firstTwoTouches)
- return;
- const [o2, r2] = this._firstTwoTouches, n2 = pr(i3, t2, o2), a2 = pr(i3, t2, r2);
- n2 && a2 || (this._active && d(), this.reset());
- }
- touchcancel() {
- this.reset();
- }
- enable(e2) {
- this._enabled = true, this._aroundCenter = !!e2 && "center" === e2.around;
- }
- disable() {
- this._enabled = false, this.reset();
- }
- isEnabled() {
- return this._enabled;
- }
- isActive() {
- return this._active;
- }
- }
- function pr(e2, t2, i3) {
- for (let o2 = 0; o2 < e2.length; o2++)
- if (e2[o2].identifier === i3)
- return t2[o2];
- }
- function mr(e2, t2) {
- return Math.log(e2 / t2) / Math.LN2;
- }
- class fr extends dr {
- reset() {
- super.reset(), this._distance = 0, this._startDistance = 0;
- }
- _start(e2) {
- this._startDistance = this._distance = e2[0].dist(e2[1]);
- }
- _move(e2, t2) {
- const i3 = this._distance;
- if (this._distance = e2[0].dist(e2[1]), this._active || !(Math.abs(mr(this._distance, this._startDistance)) < 0.1))
- return this._active = true, { zoomDelta: mr(this._distance, i3), pinchAround: t2 };
- }
- }
- function gr(e2, t2) {
- return 180 * e2.angleWith(t2) / Math.PI;
- }
- class vr extends dr {
- reset() {
- super.reset(), this._minDiameter = 0, this._startVector = void 0, this._vector = void 0;
- }
- _start(e2) {
- this._startVector = this._vector = e2[0].sub(e2[1]), this._minDiameter = e2[0].dist(e2[1]);
- }
- _move(e2, t2) {
- const i3 = this._vector;
- if (this._vector = e2[0].sub(e2[1]), this._active || !this._isBelowThreshold(this._vector))
- return this._active = true, { bearingDelta: gr(this._vector, i3), pinchAround: t2 };
- }
- _isBelowThreshold(e2) {
- this._minDiameter = Math.min(this._minDiameter, e2.mag());
- const t2 = 25 / (Math.PI * this._minDiameter) * 360, i3 = gr(e2, this._startVector);
- return Math.abs(i3) < t2;
- }
- }
- function xr(e2) {
- return Math.abs(e2.y) > Math.abs(e2.x);
- }
- class yr extends dr {
- constructor(e2) {
- super(), this._map = e2;
- }
- reset() {
- super.reset(), this._valid = void 0, this._firstMove = void 0, this._lastPoints = void 0;
- }
- _start(e2) {
- this._lastPoints = e2, xr(e2[0].sub(e2[1])) && (this._valid = false);
- }
- _move(e2, t2, i3) {
- const o2 = this._lastPoints;
- if (!o2)
- return;
- const r2 = e2[0].sub(o2[0]), n2 = e2[1].sub(o2[1]);
- 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 });
- }
- gestureBeginsVertically(e2, t2, i3) {
- if (void 0 !== this._valid)
- return this._valid;
- const o2 = e2.mag() >= 2, r2 = t2.mag() >= 2;
- if (!o2 && !r2)
- return;
- if (!o2 || !r2)
- return null == this._firstMove && (this._firstMove = i3), i3 - this._firstMove < 100 && void 0;
- const n2 = e2.y > 0 == t2.y > 0;
- return xr(e2) && xr(t2) && n2;
- }
- }
- const br = { panStep: 100, bearingStep: 15, pitchStep: 10 };
- class wr {
- constructor() {
- const e2 = br;
- this._panStep = e2.panStep, this._bearingStep = e2.bearingStep, this._pitchStep = e2.pitchStep, this._rotationDisabled = false;
- }
- blur() {
- this.reset();
- }
- reset() {
- this._active = false;
- }
- keydown(e2) {
- if (e2.altKey || e2.ctrlKey || e2.metaKey)
- return;
- let t2 = 0, i3 = 0, o2 = 0, r2 = 0, n2 = 0;
- switch (e2.keyCode) {
- case 61:
- case 107:
- case 171:
- case 187:
- t2 = 1;
- break;
- case 189:
- case 109:
- case 173:
- t2 = -1;
- break;
- case 37:
- e2.shiftKey ? i3 = -1 : (e2.preventDefault(), r2 = -1);
- break;
- case 39:
- e2.shiftKey ? i3 = 1 : (e2.preventDefault(), r2 = 1);
- break;
- case 38:
- e2.shiftKey ? o2 = 1 : (e2.preventDefault(), n2 = -1);
- break;
- case 40:
- e2.shiftKey ? o2 = -1 : (e2.preventDefault(), n2 = 1);
- break;
- default:
- return;
- }
- return this._rotationDisabled && (i3 = 0, o2 = 0), { cameraAnimation: (a2) => {
- const s2 = a2.getZoom();
- 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 });
- } };
- }
- enable() {
- this._enabled = true;
- }
- disable() {
- this._enabled = false, this.reset();
- }
- isEnabled() {
- return this._enabled;
- }
- isActive() {
- return this._active;
- }
- disableRotation() {
- this._rotationDisabled = true;
- }
- enableRotation() {
- this._rotationDisabled = false;
- }
- }
- function Tr(e2) {
- return e2 * (2 - e2);
- }
- const Er = 4.000244140625;
- class Cr {
- constructor(t2, i3) {
- 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);
- }
- setZoomRate(e2) {
- this._defaultZoomRate = e2;
- }
- setWheelZoomRate(e2) {
- this._wheelZoomRate = e2;
- }
- isEnabled() {
- return !!this._enabled;
- }
- isActive() {
- return !!this._active || void 0 !== this._finishTimeout;
- }
- isZooming() {
- return !!this._zooming;
- }
- enable(e2) {
- this.isEnabled() || (this._enabled = true, this._aroundCenter = !!e2 && "center" === e2.around, this._map._cooperativeGestures && this._addScrollZoomBlocker());
- }
- disable() {
- this.isEnabled() && (this._enabled = false, this._map._cooperativeGestures && (clearTimeout(this._alertTimer), this._alertContainer.remove()));
- }
- wheel(t2) {
- if (!this.isEnabled())
- return;
- if (this._map._cooperativeGestures) {
- if (!(t2.ctrlKey || t2.metaKey || this.isZooming() || this._isFullscreen()))
- return void this._showBlockerAlert();
- "hidden" !== this._alertContainer.style.visibility && (this._alertContainer.style.visibility = "hidden", clearTimeout(this._alertTimer));
- }
- let i3 = t2.deltaMode === e.window.WheelEvent.DOM_DELTA_LINE ? 40 * t2.deltaY : t2.deltaY;
- const o2 = e.exported.now(), r2 = o2 - (this._lastWheelEventTime || 0);
- 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();
- }
- _onTimeout(e2) {
- this._type = "wheel", this._delta -= this._lastValue, this._active || this._start(e2);
- }
- _start(e2) {
- if (!this._delta)
- return;
- this._frameId && (this._frameId = null), this._active = true, this.isZooming() || (this._zooming = true), this._finishTimeout && (clearTimeout(this._finishTimeout), delete this._finishTimeout);
- const t2 = p(this._el, e2);
- 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());
- }
- renderFrame() {
- if (!this._frameId)
- return;
- if (this._frameId = null, !this.isActive())
- return;
- const t2 = this._map.transform, i3 = () => t2._terrainEnabled() && this._aroundCoord ? t2.computeZoomRelativeTo(this._aroundCoord) : t2.zoom;
- if (0 !== this._delta) {
- const e2 = "wheel" === this._type && Math.abs(this._delta) > Er ? this._wheelZoomRate : this._defaultZoomRate;
- let o3 = 2 / (1 + Math.exp(-Math.abs(this._delta * e2)));
- this._delta < 0 && 0 !== o3 && (o3 = 1 / o3);
- const r3 = i3(), n3 = Math.pow(2, r3), a3 = "number" == typeof this._targetZoom ? t2.zoomScale(this._targetZoom) : n3;
- 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;
- }
- const o2 = "number" == typeof this._targetZoom ? this._targetZoom : i3(), r2 = this._startZoom, n2 = this._easing;
- let a2, s2 = false;
- if ("wheel" === this._type && r2 && n2) {
- const t3 = Math.min((e.exported.now() - this._lastWheelEventTime) / 200, 1), i4 = n2(t3);
- a2 = e.number(r2, o2, i4), t3 < 1 ? this._frameId || (this._frameId = true) : s2 = true;
- } else
- a2 = o2, s2 = true;
- return this._active = true, s2 && (this._active = false, this._finishTimeout = setTimeout(() => {
- this._zooming = false, this._handler._triggerRenderFrame(), delete this._targetZoom, delete this._finishTimeout;
- }, 200)), { noInertia: true, needsRenderFrame: !s2, zoomDelta: a2 - i3(), around: this._aroundPoint, aroundCoord: this._aroundCoord, originalEvent: this._lastWheelEvent };
- }
- _smoothOutEasing(t2) {
- let i3 = e.ease;
- if (this._prevEase) {
- 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);
- i3 = e.bezier(n2, a2, 0.25, 1);
- }
- return this._prevEase = { start: e.exported.now(), duration: t2, easing: i3 }, i3;
- }
- blur() {
- this.reset();
- }
- reset() {
- this._active = false;
- }
- _addScrollZoomBlocker() {
- 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`);
- }
- _isFullscreen() {
- return !!e.window.document.fullscreenElement || !!e.window.document.webkitFullscreenElement;
- }
- _showBlockerAlert() {
- "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(() => {
- this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show");
- }, 200);
- }
- }
- class Ir {
- constructor(e2, t2) {
- this._clickZoom = e2, this._tapZoom = t2;
- }
- enable() {
- this._clickZoom.enable(), this._tapZoom.enable();
- }
- disable() {
- this._clickZoom.disable(), this._tapZoom.disable();
- }
- isEnabled() {
- return this._clickZoom.isEnabled() && this._tapZoom.isEnabled();
- }
- isActive() {
- return this._clickZoom.isActive() || this._tapZoom.isActive();
- }
- }
- class Mr {
- constructor() {
- this.reset();
- }
- reset() {
- this._active = false;
- }
- blur() {
- this.reset();
- }
- dblclick(e2, t2) {
- return e2.preventDefault(), { cameraAnimation: (i3) => {
- i3.easeTo({ duration: 300, zoom: i3.getZoom() + (e2.shiftKey ? -1 : 1), around: i3.unproject(t2) }, { originalEvent: e2 });
- } };
- }
- enable() {
- this._enabled = true;
- }
- disable() {
- this._enabled = false, this.reset();
- }
- isEnabled() {
- return this._enabled;
- }
- isActive() {
- return this._active;
- }
- }
- class Sr {
- constructor() {
- this._tap = new nr({ numTouches: 1, numTaps: 1 }), this.reset();
- }
- reset() {
- this._active = false, this._swipePoint = void 0, this._swipeTouch = 0, this._tapTime = 0, this._tap.reset();
- }
- touchstart(e2, t2, i3) {
- 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));
- }
- touchmove(e2, t2, i3) {
- if (this._tapTime) {
- if (this._swipePoint) {
- if (i3[0].identifier !== this._swipeTouch)
- return;
- const o2 = t2[0], r2 = o2.y - this._swipePoint.y;
- return this._swipePoint = o2, e2.preventDefault(), this._active = true, { zoomDelta: r2 / 128 };
- }
- } else
- this._tap.touchmove(e2, t2, i3);
- }
- touchend(e2, t2, i3) {
- this._tapTime ? this._swipePoint && 0 === i3.length && this.reset() : this._tap.touchend(e2, t2, i3) && (this._tapTime = e2.timeStamp);
- }
- touchcancel() {
- this.reset();
- }
- enable() {
- this._enabled = true;
- }
- disable() {
- this._enabled = false, this.reset();
- }
- isEnabled() {
- return this._enabled;
- }
- isActive() {
- return this._active;
- }
- }
- class zr {
- constructor(e2, t2, i3) {
- this._el = e2, this._mousePan = t2, this._touchPan = i3;
- }
- enable(e2) {
- this._inertiaOptions = e2 || {}, this._mousePan.enable(), this._touchPan.enable(), this._el.classList.add("mapboxgl-touch-drag-pan");
- }
- disable() {
- this._mousePan.disable(), this._touchPan.disable(), this._el.classList.remove("mapboxgl-touch-drag-pan");
- }
- isEnabled() {
- return this._mousePan.isEnabled() && this._touchPan.isEnabled();
- }
- isActive() {
- return this._mousePan.isActive() || this._touchPan.isActive();
- }
- }
- class Dr {
- constructor(e2, t2, i3) {
- this._pitchWithRotate = e2.pitchWithRotate, this._mouseRotate = t2, this._mousePitch = i3;
- }
- enable() {
- this._mouseRotate.enable(), this._pitchWithRotate && this._mousePitch.enable();
- }
- disable() {
- this._mouseRotate.disable(), this._mousePitch.disable();
- }
- isEnabled() {
- return this._mouseRotate.isEnabled() && (!this._pitchWithRotate || this._mousePitch.isEnabled());
- }
- isActive() {
- return this._mouseRotate.isActive() || this._mousePitch.isActive();
- }
- }
- class Pr {
- constructor(e2, t2, i3, o2) {
- this._el = e2, this._touchZoom = t2, this._touchRotate = i3, this._tapDragZoom = o2, this._rotationDisabled = false, this._enabled = true;
- }
- enable(e2) {
- this._touchZoom.enable(e2), this._rotationDisabled || this._touchRotate.enable(e2), this._tapDragZoom.enable(), this._el.classList.add("mapboxgl-touch-zoom-rotate");
- }
- disable() {
- this._touchZoom.disable(), this._touchRotate.disable(), this._tapDragZoom.disable(), this._el.classList.remove("mapboxgl-touch-zoom-rotate");
- }
- isEnabled() {
- return this._touchZoom.isEnabled() && (this._rotationDisabled || this._touchRotate.isEnabled()) && this._tapDragZoom.isEnabled();
- }
- isActive() {
- return this._touchZoom.isActive() || this._touchRotate.isActive() || this._tapDragZoom.isActive();
- }
- disableRotation() {
- this._rotationDisabled = true, this._touchRotate.disable();
- }
- enableRotation() {
- this._rotationDisabled = false, this._touchZoom.isEnabled() && this._touchRotate.enable();
- }
- }
- const Ar = (e2) => e2.zoom || e2.drag || e2.pitch || e2.rotate;
- class Lr extends e.Event {
- }
- class Rr {
- constructor() {
- this.constants = [1, 1, 0.01], this.radius = 0;
- }
- setup(t2, i3) {
- const o2 = e.sub([], i3, t2);
- this.radius = e.length(o2[2] < 0 ? e.div([], o2, this.constants) : [o2[0], o2[1], 0]);
- }
- projectRay(t2) {
- e.div(t2, t2, this.constants), e.normalize(t2, t2), e.mul$1(t2, t2, this.constants);
- const i3 = e.scale$2([], t2, this.radius);
- if (i3[2] > 0) {
- 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));
- i3[0] = r2[0], i3[1] = r2[1];
- }
- return i3;
- }
- }
- function kr(e2) {
- return e2.panDelta && e2.panDelta.mag() || e2.zoomDelta || e2.bearingDelta || e2.pitchDelta;
- }
- class Or {
- constructor(t2, i3) {
- 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);
- const o2 = this._el;
- 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]];
- for (const [t3, i4, o3] of this._listeners)
- t3.addEventListener(i4, t3 === e.window.document ? this.handleWindowEvent : this.handleEvent, o3);
- }
- destroy() {
- for (const [t2, i3, o2] of this._listeners)
- t2.removeEventListener(i3, t2 === e.window.document ? this.handleWindowEvent : this.handleEvent, o2);
- }
- _addDefaultHandlers(e2) {
- const t2 = this._map, i3 = t2.getCanvasContainer();
- this._add("mapEvent", new er(t2, e2));
- const o2 = t2.boxZoom = new ir(t2, e2);
- this._add("boxZoom", o2);
- const r2 = new ar(), n2 = new Mr();
- t2.doubleClickZoom = new Ir(n2, r2), this._add("tapZoom", r2), this._add("clickZoom", n2);
- const a2 = new Sr();
- this._add("tapDragZoom", a2);
- const s2 = t2.touchPitch = new yr(t2);
- this._add("touchPitch", s2);
- const l2 = new hr(e2), c2 = new _r(e2);
- t2.dragRotate = new Dr(e2, l2, c2), this._add("mouseRotate", l2, ["mousePitch"]), this._add("mousePitch", c2, ["mouseRotate"]);
- const h2 = new cr(e2), _2 = new ur(t2, e2);
- t2.dragPan = new zr(i3, h2, _2), this._add("mousePan", h2), this._add("touchPan", _2, ["touchZoom", "touchRotate"]);
- const u2 = new vr(), d2 = new fr();
- 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));
- const p2 = t2.scrollZoom = new Cr(t2, this);
- this._add("scrollZoom", p2, ["mousePan"]);
- const m2 = t2.keyboard = new wr();
- this._add("keyboard", m2);
- for (const i4 of ["boxZoom", "doubleClickZoom", "tapDragZoom", "touchPitch", "dragRotate", "dragPan", "touchZoomRotate", "scrollZoom", "keyboard"])
- e2.interactive && e2[i4] && t2[i4].enable(e2[i4]);
- }
- _add(e2, t2, i3) {
- this._handlers.push({ handlerName: e2, handler: t2, allowed: i3 }), this._handlersById[e2] = t2;
- }
- stop(e2) {
- if (!this._updatingCamera) {
- for (const { handler: e3 } of this._handlers)
- e3.reset();
- this._inertia.clear(), this._fireEvents({}, {}, e2), this._changes = [];
- }
- }
- isActive() {
- for (const { handler: e2 } of this._handlers)
- if (e2.isActive())
- return true;
- return false;
- }
- isZooming() {
- return !!this._eventsInProgress.zoom || this._map.scrollZoom.isZooming();
- }
- isRotating() {
- return !!this._eventsInProgress.rotate;
- }
- isMoving() {
- return !!Ar(this._eventsInProgress) || this.isZooming();
- }
- _blockedByActive(e2, t2, i3) {
- for (const o2 in e2)
- if (o2 !== i3 && (!t2 || t2.indexOf(o2) < 0))
- return true;
- return false;
- }
- handleWindowEvent(e2) {
- this.handleEvent(e2, `${e2.type}Window`);
- }
- _getMapTouches(e2) {
- const t2 = [];
- for (const i3 of e2)
- this._el.contains(i3.target) && t2.push(i3);
- return t2;
- }
- handleEvent(e2, t2) {
- this._updatingCamera = true;
- 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);
- for (const { handlerName: i4, handler: c3, allowed: h3 } of this._handlers) {
- if (!c3.isEnabled())
- continue;
- let _2;
- 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);
- }
- const c2 = {};
- for (const e3 in this._previousActiveHandlers)
- a2[e3] || (c2[e3] = o2);
- 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;
- const { cameraAnimation: h2 } = r2;
- h2 && (this._inertia.clear(), this._fireEvents({}, {}, true), this._changes = [], h2(this._map));
- }
- mergeHandlerResult(t2, i3, o2, r2, n2) {
- if (!o2)
- return;
- e.extend(t2, o2);
- const a2 = { handlerName: r2, originalEvent: o2.originalEvent || n2 };
- 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);
- }
- _applyChanges() {
- const t2 = {}, i3 = {}, o2 = {};
- for (const [r2, n2, a2] of this._changes)
- 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);
- this._updateMapTransform(t2, i3, o2), this._changes = [];
- }
- _updateMapTransform(t2, i3, o2) {
- const r2 = this._map, n2 = r2.transform, a2 = (e2) => [e2.x, e2.y, e2.z];
- if (((e2) => {
- const t3 = this._eventsInProgress.drag;
- return t3 && !this._handlersById[t3.handlerName].isActive();
- })() && !kr(t2)) {
- const e2 = n2.zoom;
- n2.cameraElevationReference = "sea", n2.recenterOnTerrain(), n2.cameraElevationReference = "ground", e2 !== n2.zoom && this._map._update(true);
- }
- if (!kr(t2))
- return void this._fireEvents(i3, o2, true);
- let { panDelta: s2, zoomDelta: l2, bearingDelta: c2, pitchDelta: h2, around: _2, aroundCoord: u2, pinchAround: d2 } = t2;
- 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();
- const p2 = [0, 0, 0];
- if (s2) {
- const t3 = n2.pointCoordinate(_2);
- if ("globe" === n2.projection.name) {
- const i4 = e.latFromMercatorY(t3.y), o3 = n2.center.lat, r3 = Math.min(e.mercatorZfromAltitude(1, i4) / e.mercatorZfromAltitude(1, o3), 2);
- s2 = s2.rotate(-n2.angle), p2[0] = -s2.x / n2.worldSize * r3, p2[1] = -s2.y / n2.worldSize * r3;
- } else {
- const e2 = n2.pointCoordinate(_2.sub(s2));
- t3 && e2 && (p2[0] = e2.x - t3.x, p2[1] = e2.y - t3.y);
- }
- }
- const m2 = n2.zoom, f2 = [0, 0, 0];
- if (l2) {
- const t3 = a2(u2 || n2.pointCoordinate3D(_2)), i4 = { dir: e.normalize([], e.sub([], t3, n2._camera.position)) };
- if (i4.dir[2] < 0) {
- const o3 = n2.zoomDeltaToMovement(t3, l2);
- e.scale$2(f2, i4.dir, o3);
- }
- }
- const g2 = e.add(p2, p2, f2);
- 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);
- }
- _fireEvents(t2, i3, o2) {
- const r2 = Ar(this._eventsInProgress), n2 = Ar(t2), a2 = {};
- for (const e2 in t2) {
- const { originalEvent: i4 } = t2[e2];
- this._eventsInProgress[e2] || (a2[`${e2}start`] = i4), this._eventsInProgress[e2] = t2[e2];
- }
- !r2 && n2 && this._fireEvent("movestart", n2.originalEvent);
- for (const e2 in a2)
- this._fireEvent(e2, a2[e2]);
- n2 && this._fireEvent("move", n2.originalEvent);
- for (const e2 in t2) {
- const { originalEvent: i4 } = t2[e2];
- this._fireEvent(e2, i4);
- }
- const s2 = {};
- let l2;
- for (const e2 in this._eventsInProgress) {
- const { handlerName: t3, originalEvent: o3 } = this._eventsInProgress[e2];
- this._handlersById[t3].isActive() || (delete this._eventsInProgress[e2], l2 = i3[t3] || o3, s2[`${e2}end`] = l2);
- }
- for (const e2 in s2)
- this._fireEvent(e2, s2[e2]);
- const c2 = Ar(this._eventsInProgress);
- if (o2 && (r2 || n2) && !c2) {
- this._updatingCamera = true;
- const t3 = this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions), i4 = (e2) => 0 !== e2 && -this._bearingSnap < e2 && e2 < this._bearingSnap;
- 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;
- }
- }
- _fireEvent(t2, i3) {
- this._map.fire(new e.Event(t2, i3 ? { originalEvent: i3 } : {}));
- }
- _requestFrame() {
- return this._map.triggerRepaint(), this._map._renderTaskQueue.add((e2) => {
- this._frameId = void 0, this.handleEvent(new Lr("renderFrame", { timeStamp: e2 })), this._applyChanges();
- });
- }
- _triggerRenderFrame() {
- void 0 === this._frameId && (this._frameId = this._requestFrame());
- }
- }
- const Br = "map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";
- class Fr extends e.Evented {
- constructor(t2, i3) {
- super(), this._moving = false, this._zooming = false, this.transform = t2, this._bearingSnap = i3.bearingSnap, e.bindAll(["_renderFrameCallback"], this);
- }
- getCenter() {
- return new e.LngLat(this.transform.center.lng, this.transform.center.lat);
- }
- setCenter(e2, t2) {
- return this.jumpTo({ center: e2 }, t2);
- }
- panBy(t2, i3, o2) {
- return t2 = e.pointGeometry.convert(t2).mult(-1), this.panTo(this.transform.center, e.extend({ offset: t2 }, i3), o2);
- }
- panTo(t2, i3, o2) {
- return this.easeTo(e.extend({ center: t2 }, i3), o2);
- }
- getZoom() {
- return this.transform.zoom;
- }
- setZoom(e2, t2) {
- return this.jumpTo({ zoom: e2 }, t2), this;
- }
- zoomTo(t2, i3, o2) {
- return this.easeTo(e.extend({ zoom: t2 }, i3), o2);
- }
- zoomIn(e2, t2) {
- return this.zoomTo(this.getZoom() + 1, e2, t2), this;
- }
- zoomOut(e2, t2) {
- return this.zoomTo(this.getZoom() - 1, e2, t2), this;
- }
- getBearing() {
- return this.transform.bearing;
- }
- setBearing(e2, t2) {
- return this.jumpTo({ bearing: e2 }, t2), this;
- }
- getPadding() {
- return this.transform.padding;
- }
- setPadding(e2, t2) {
- return this.jumpTo({ padding: e2 }, t2), this;
- }
- rotateTo(t2, i3, o2) {
- return this.easeTo(e.extend({ bearing: t2 }, i3), o2);
- }
- resetNorth(t2, i3) {
- return this.rotateTo(0, e.extend({ duration: 1e3 }, t2), i3), this;
- }
- resetNorthPitch(t2, i3) {
- return this.easeTo(e.extend({ bearing: 0, pitch: 0, duration: 1e3 }, t2), i3), this;
- }
- snapToNorth(e2, t2) {
- return Math.abs(this.getBearing()) < this._bearingSnap ? this.resetNorth(e2, t2) : this;
- }
- getPitch() {
- return this.transform.pitch;
- }
- setPitch(e2, t2) {
- return this.jumpTo({ pitch: e2 }, t2), this;
- }
- cameraForBounds(t2, i3) {
- t2 = e.LngLatBounds.convert(t2);
- const o2 = i3 && i3.bearing || 0;
- return this._cameraForBoxAndBearing(t2.getNorthWest(), t2.getSouthEast(), o2, i3);
- }
- _extendCameraOptions(t2) {
- const i3 = { top: 0, bottom: 0, right: 0, left: 0 };
- if ("number" == typeof (t2 = e.extend({ padding: i3, offset: [0, 0], maxZoom: this.transform.maxZoom }, t2)).padding) {
- const e2 = t2.padding;
- t2.padding = { top: e2, bottom: e2, right: e2, left: e2 };
- }
- return t2.padding = e.extend(i3, t2.padding), t2;
- }
- _cameraForBoxAndBearing(t2, i3, o2, r2) {
- 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;
- if (b2 < 0 || y2 < 0)
- return void e.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");
- 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));
- return { center: a2.unproject(l2.add(c2).div(2).sub(C2)), zoom: w2, bearing: o2 };
- }
- _cameraForBox(t2, i3, o2, r2, n2) {
- const a2 = this._extendCameraOptions(n2);
- o2 = o2 || 0, r2 = r2 || 0, t2 = e.LngLat.convert(t2), i3 = e.LngLat.convert(i3);
- const s2 = this.transform.clone();
- s2.padding = a2.padding;
- 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);
- if (s2._camera.position[2] < e.mercatorZfromAltitude(h2, c2.lat))
- return void e.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");
- l2.lookAtPoint(c2), s2.setFreeCameraOptions(l2);
- 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];
- var m2;
- const f2 = s2.screenPointToMercatorRay(s2.centerPoint), g2 = "globe" !== s2.projection.name;
- let v2, x2 = 0;
- do {
- 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);
- if (2 !== h3.intersects(d3)) {
- v2 && (s2._camera.position = e.scaleAndAdd([], s2._camera.position, f2.dir, -v2), s2._updateStateFromCamera());
- break;
- }
- const m3 = e.sub([], s2._camera.position, p2);
- v2 = 0.5 * e.length(m3), s2._camera.position = e.scaleAndAdd([], s2._camera.position, f2.dir, v2);
- try {
- s2._updateStateFromCamera();
- } catch (t4) {
- return void e.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");
- }
- } while (++x2 < 10);
- return { center: s2.center, zoom: s2.zoom, bearing: s2.bearing, pitch: s2.pitch };
- }
- fitBounds(e2, t2, i3) {
- return this._fitInternal(this.cameraForBounds(e2, t2), t2, i3);
- }
- _raycastElevationBox(t2, i3) {
- const o2 = this.transform.elevation;
- if (!o2)
- return;
- const r2 = new e.pointGeometry(t2.x, i3.y), n2 = new e.pointGeometry(i3.x, t2.y), a2 = o2.pointCoordinate(t2);
- if (!a2)
- return;
- const s2 = o2.pointCoordinate(i3);
- if (!s2)
- return;
- const l2 = o2.pointCoordinate(r2);
- if (!l2)
- return;
- const c2 = o2.pointCoordinate(n2);
- if (!c2)
- return;
- 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])));
- return { minLngLat: new e.LngLat(p2, m2), maxLngLat: new e.LngLat(f2, g2), minAltitude: v2, maxAltitude: x2 };
- }
- fitScreenCoordinates(t2, i3, o2, r2, n2) {
- let a2, s2, l2, c2;
- const h2 = e.pointGeometry.convert(t2), _2 = e.pointGeometry.convert(i3), u2 = this._raycastElevationBox(h2, _2);
- if (u2)
- a2 = u2.minLngLat, s2 = u2.maxLngLat, l2 = u2.minAltitude, c2 = u2.maxAltitude;
- else {
- if (this.transform.anyCornerOffEdge(h2, _2))
- return this;
- a2 = this.transform.pointLocation(h2), s2 = this.transform.pointLocation(_2);
- }
- 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);
- }
- _fitInternal(t2, i3, o2) {
- return t2 ? (delete (i3 = e.extend(t2, i3)).padding, i3.linear ? this.easeTo(i3, o2) : this.flyTo(i3, o2)) : this;
- }
- jumpTo(t2, i3) {
- this.stop();
- const o2 = t2.preloadOnly ? this.transform.clone() : this.transform;
- let r2 = false, n2 = false, a2 = false;
- 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)));
- }
- getFreeCameraOptions() {
- return this.transform.projection.supportsFreeCamera || e.warnOnce(Br), this.transform.getFreeCameraOptions();
- }
- setFreeCameraOptions(t2, i3) {
- const o2 = this.transform;
- if (!o2.projection.supportsFreeCamera)
- return e.warnOnce(Br), this;
- this.stop();
- const r2 = o2.zoom, n2 = o2.pitch, a2 = o2.bearing;
- o2.setFreeCameraOptions(t2);
- const s2 = r2 !== o2.zoom, l2 = n2 !== o2.pitch, c2 = a2 !== o2.bearing;
- 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;
- }
- easeTo(t2, i3) {
- 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);
- 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);
- let d2, p2, m2;
- if ("globe" === o2.projection.name) {
- const i4 = e.MercatorCoordinate.fromLngLat(o2.center), r3 = u2.rotate(-o2.angle);
- i4.x += r3.x / o2.worldSize, i4.y += r3.y / o2.worldSize;
- const n3 = i4.toLngLat(), a3 = e.LngLat.convert(t2.center || n3);
- 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);
- } else {
- d2 = o2.centerPoint.add(u2);
- const i4 = o2.pointLocation(d2), r3 = e.LngLat.convert(t2.center || i4);
- this._normalizeCenter(r3), p2 = o2.project(i4), m2 = o2.project(r3).sub(p2);
- }
- const f2 = o2.zoomScale(l2 - r2);
- let g2, v2;
- t2.around && (g2 = e.LngLat.convert(t2.around), v2 = o2.locationPoint(g2));
- const x2 = this._zooming || l2 !== r2, y2 = this._rotating || n2 !== c2, b2 = this._pitching || h2 !== a2, w2 = !o2.isPaddingEqual(_2), T2 = (o3) => (T3) => {
- 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)
- o3.setLocationAtPoint(g2, v2);
- else {
- 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));
- o3.setLocationAtPoint(o3.renderWorldCopies ? n3.wrap() : n3, d2);
- }
- return t2.preloadOnly || this._fireMoveEvents(i3), o3;
- };
- if (t2.preloadOnly) {
- const e2 = this._emulate(T2, t2.duration, o2);
- return this._preloadTiles(e2), this;
- }
- const E2 = { moving: this._moving, zooming: this._zooming, rotating: this._rotating, pitching: this._pitching };
- 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) => {
- o2.recenterOnTerrain(), this._afterEase(i3, e2);
- }, t2), this;
- }
- _prepareEase(t2, i3, o2 = {}) {
- 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));
- }
- _fireMoveEvents(t2) {
- 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));
- }
- _afterEase(t2, i3) {
- if (this._easeId && i3 && this._easeId === i3)
- return;
- this._easeId = void 0, this.transform.cameraElevationReference = "ground";
- const o2 = this._zooming, r2 = this._rotating, n2 = this._pitching;
- 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));
- }
- flyTo(t2, i3) {
- if (!t2.essential && e.exported.prefersReducedMotion) {
- const o3 = e.pick(t2, ["center", "zoom", "bearing", "pitch", "around"]);
- return this.jumpTo(o3, i3);
- }
- this.stop(), t2 = e.extend({ offset: [0, 0], speed: 1.2, curve: 1.42, easing: e.ease }, t2);
- 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);
- let p2 = o2.centerPoint.add(d2);
- const m2 = o2.pointLocation(p2), f2 = e.LngLat.convert(t2.center || m2);
- this._normalizeCenter(f2);
- const g2 = o2.project(m2), v2 = o2.project(f2).sub(g2);
- let x2 = t2.curve;
- const y2 = Math.max(o2.width, o2.height), b2 = y2 / u2, w2 = v2.mag();
- if ("minZoom" in t2) {
- const i4 = e.clamp(Math.min(t2.minZoom, r2, l2), o2.minZoom, o2.maxZoom), n3 = y2 / o2.zoomScale(i4 - r2);
- x2 = Math.sqrt(n3 / w2 * 2);
- }
- const T2 = x2 * x2;
- function E2(e2) {
- const t3 = (b2 * b2 - y2 * y2 + (e2 ? -1 : 1) * T2 * T2 * w2 * w2) / (2 * (e2 ? b2 : y2) * T2 * w2);
- return Math.log(Math.sqrt(t3 * t3 + 1) - t3);
- }
- function C2(e2) {
- return (Math.exp(e2) - Math.exp(-e2)) / 2;
- }
- function I2(e2) {
- return (Math.exp(e2) + Math.exp(-e2)) / 2;
- }
- const M2 = E2(0);
- let S2 = function(e2) {
- return I2(M2) / I2(M2 + x2 * e2);
- }, z2 = function(e2) {
- return y2 * ((I2(M2) * (C2(t3 = M2 + x2 * e2) / I2(t3)) - C2(M2)) / T2) / w2;
- var t3;
- }, D2 = (E2(1) - M2) / x2;
- if (Math.abs(w2) < 1e-6 || !isFinite(D2)) {
- if (Math.abs(y2 - b2) < 1e-6)
- return this.easeTo(t2, i3);
- const e2 = b2 < y2 ? -1 : 1;
- D2 = Math.abs(Math.log(b2 / y2)) / x2, z2 = function() {
- return 0;
- }, S2 = function(t3) {
- return Math.exp(e2 * x2 * t3);
- };
- }
- 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);
- const P2 = n2 !== c2, A2 = h2 !== a2, L2 = !o2.isPaddingEqual(_2), R2 = (o3) => (u3) => {
- const m3 = u3 * D2, x3 = 1 / S2(m3);
- 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));
- const y3 = 1 === u3 ? f2 : o3.unproject(g2.add(v2.mult(z2(m3))).mult(x3));
- return o3.setLocationAtPoint(o3.renderWorldCopies ? y3.wrap() : y3, p2), o3._updateCameraOnTerrain(), t2.preloadOnly || this._fireMoveEvents(i3), o3;
- };
- if (t2.preloadOnly) {
- const e2 = this._emulate(R2, t2.duration, o2);
- return this._preloadTiles(e2), this;
- }
- 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;
- }
- isEasing() {
- return !!this._easeFrameId;
- }
- stop() {
- return this._stop();
- }
- _stop(e2, t2) {
- if (this._easeFrameId && (this._cancelRenderFrame(this._easeFrameId), this._easeFrameId = void 0, this._onEaseFrame = void 0), this._onEaseEnd) {
- const e3 = this._onEaseEnd;
- this._onEaseEnd = void 0, e3.call(this, t2);
- }
- if (!e2) {
- const e3 = this.handlers;
- e3 && e3.stop(false);
- }
- return this;
- }
- _ease(t2, i3, o2) {
- 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));
- }
- _renderFrameCallback() {
- const t2 = Math.min((e.exported.now() - this._easeStart) / this._easeOptions.duration, 1), i3 = this._onEaseFrame;
- i3 && i3(this._easeOptions.easing(t2)), t2 < 1 ? this._easeFrameId = this._requestRenderFrame(this._renderFrameCallback) : this.stop();
- }
- _normalizeBearing(t2, i3) {
- t2 = e.wrap(t2, -180, 180);
- const o2 = Math.abs(t2 - i3);
- return Math.abs(t2 - 360 - i3) < o2 && (t2 -= 360), Math.abs(t2 + 360 - i3) < o2 && (t2 += 360), t2;
- }
- _normalizeCenter(e2) {
- const t2 = this.transform;
- if (!t2.renderWorldCopies || t2.maxBounds)
- return;
- const i3 = e2.lng - t2.center.lng;
- e2.lng += i3 > 180 ? -360 : i3 < -180 ? 360 : 0;
- }
- _emulate(e2, t2, i3) {
- const o2 = Math.ceil(15 * t2 / 1e3), r2 = [], n2 = e2(i3.clone());
- for (let e3 = 0; e3 <= o2; e3++) {
- const t3 = n2(e3 / o2);
- r2.push(t3.clone());
- }
- return r2;
- }
- }
- class Ur {
- constructor(t2 = {}) {
- this.options = t2, e.bindAll(["_toggleAttribution", "_updateEditLink", "_updateData", "_updateCompact"], this);
- }
- getDefaultPosition() {
- return "bottom-right";
- }
- onAdd(e2) {
- const t2 = this.options && this.options.compact;
- 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;
- }
- onRemove() {
- 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;
- }
- _setElementTitle(e2, t2) {
- const i3 = this._map._getUIString(`AttributionControl.${t2}`);
- e2.setAttribute("aria-label", i3), e2.removeAttribute("title"), e2.firstElementChild && e2.firstElementChild.setAttribute("title", i3);
- }
- _toggleAttribution() {
- 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"));
- }
- _updateEditLink() {
- let t2 = this._editLink;
- t2 || (t2 = this._editLink = this._container.querySelector(".mapbox-improve-map"));
- const i3 = [{ key: "owner", value: this.styleOwner }, { key: "id", value: this.styleId }, { key: "access_token", value: this._map._requestManager._customAccessToken || e.config.ACCESS_TOKEN }];
- if (t2) {
- const o2 = i3.reduce((e2, t3, o3) => (t3.value && (e2 += `${t3.key}=${t3.value}${o3 < i3.length - 1 ? "&" : ""}`), e2), "?");
- t2.href = `${e.config.FEEDBACK_URL}/${o2}${this._map._hash ? this._map._hash.getHashString(true) : ""}`, t2.rel = "noopener nofollow", this._setElementTitle(t2, "MapFeedback");
- }
- }
- _updateData(e2) {
- !e2 || "metadata" !== e2.sourceDataType && "visibility" !== e2.sourceDataType && "style" !== e2.dataType || (this._updateAttributions(), this._updateEditLink());
- }
- _updateAttributions() {
- if (!this._map.style)
- return;
- let e2 = [];
- if (this._map.style.stylesheet) {
- const e3 = this._map.style.stylesheet;
- this.styleOwner = e3.owner, this.styleId = e3.id;
- }
- const t2 = this._map.style._sourceCaches;
- for (const i4 in t2) {
- const o2 = t2[i4];
- if (o2.used) {
- const t3 = o2.getSource();
- t3.attribution && e2.indexOf(t3.attribution) < 0 && e2.push(t3.attribution);
- }
- }
- e2.sort((e3, t3) => e3.length - t3.length), e2 = e2.filter((t3, i4) => {
- for (let o2 = i4 + 1; o2 < e2.length; o2++)
- if (e2[o2].indexOf(t3) >= 0)
- return false;
- return true;
- }), this.options.customAttribution && (Array.isArray(this.options.customAttribution) ? e2 = [...this.options.customAttribution, ...e2] : e2.unshift(this.options.customAttribution));
- const i3 = e2.join(" | ");
- 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);
- }
- _updateCompact() {
- this._map.getCanvasContainer().offsetWidth <= 640 ? this._container.classList.add("mapboxgl-compact") : this._container.classList.remove("mapboxgl-compact", "mapboxgl-compact-show");
- }
- }
- class Nr {
- constructor() {
- e.bindAll(["_updateLogo", "_updateCompact"], this);
- }
- onAdd(e2) {
- this._map = e2, this._container = n("div", "mapboxgl-ctrl");
- const t2 = n("a", "mapboxgl-ctrl-logo");
- 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;
- }
- onRemove() {
- this._container.remove(), this._map.off("sourcedata", this._updateLogo), this._map.off("resize", this._updateCompact);
- }
- getDefaultPosition() {
- return "bottom-left";
- }
- _updateLogo(e2) {
- e2 && "metadata" !== e2.sourceDataType || (this._container.style.display = this._logoRequired() ? "block" : "none");
- }
- _logoRequired() {
- if (!this._map.style)
- return true;
- const e2 = this._map.style._sourceCaches;
- if (0 === Object.entries(e2).length)
- return true;
- for (const t2 in e2) {
- const i3 = e2[t2].getSource();
- if (i3.hasOwnProperty("mapbox_logo") && !i3.mapbox_logo)
- return false;
- }
- return true;
- }
- _updateCompact() {
- const e2 = this._container.children;
- if (e2.length) {
- const t2 = e2[0];
- this._map.getCanvasContainer().offsetWidth < 250 ? t2.classList.add("mapboxgl-compact") : t2.classList.remove("mapboxgl-compact");
- }
- }
- }
- class Gr {
- constructor() {
- this._queue = [], this._id = 0, this._cleared = false, this._currentlyRunning = false;
- }
- add(e2) {
- const t2 = ++this._id;
- return this._queue.push({ callback: e2, id: t2, cancelled: false }), t2;
- }
- remove(e2) {
- const t2 = this._currentlyRunning, i3 = t2 ? this._queue.concat(t2) : this._queue;
- for (const t3 of i3)
- if (t3.id === e2)
- return void (t3.cancelled = true);
- }
- run(e2 = 0) {
- const t2 = this._currentlyRunning = this._queue;
- this._queue = [];
- for (const i3 of t2)
- if (!i3.cancelled && (i3.callback(e2), this._cleared))
- break;
- this._cleared = false, this._currentlyRunning = false;
- }
- clear() {
- this._currentlyRunning && (this._cleared = true), this._queue = [];
- }
- }
- function jr(t2, i3, o2) {
- if (t2 = new e.LngLat(t2.lng, t2.lat), i3) {
- 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;
- 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);
- }
- for (; Math.abs(t2.lng - o2.center.lng) > 180; ) {
- const e2 = o2.locationPoint(t2);
- if (e2.x >= 0 && e2.y >= 0 && e2.x <= o2.width && e2.y <= o2.height)
- break;
- t2.lng > o2.center.lng ? t2.lng -= 360 : t2.lng += 360;
- }
- return t2;
- }
- 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%)" };
- class Vr extends e.Evented {
- constructor(t2, i3) {
- 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)
- this._element = t2.element, this._offset = e.pointGeometry.convert(t2 && t2.offset || [0, 0]);
- else {
- this._defaultMarker = true, this._element = n("div");
- 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));
- 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]);
- }
- this._element.hasAttribute("aria-label") || this._element.setAttribute("aria-label", "Map marker"), this._element.classList.add("mapboxgl-marker"), this._element.addEventListener("dragstart", (e2) => {
- e2.preventDefault();
- }), this._element.addEventListener("mousedown", (e2) => {
- e2.preventDefault();
- });
- const o2 = this._element.classList;
- for (const e2 in Zr)
- o2.remove(`mapboxgl-marker-anchor-${e2}`);
- o2.add(`mapboxgl-marker-anchor-${this._anchor}`), this._popup = null;
- }
- addTo(e2) {
- 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;
- }
- remove() {
- const e2 = this._map;
- 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;
- }
- getLngLat() {
- return this._lngLat;
- }
- setLngLat(t2) {
- return this._lngLat = e.LngLat.convert(t2), this._pos = null, this._popup && this._popup.setLngLat(this._lngLat), this._update(true), this;
- }
- getElement() {
- return this._element;
- }
- setPopup(e2) {
- 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) {
- if (!("offset" in e2.options)) {
- const t2 = 38.1, i3 = 13.5, o2 = Math.sqrt(Math.pow(i3, 2) / 2);
- 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;
- }
- 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");
- }
- return this;
- }
- _onKeyPress(e2) {
- const t2 = e2.code, i3 = e2.charCode || e2.keyCode;
- "Space" !== t2 && "Enter" !== t2 && 32 !== i3 && 13 !== i3 || this.togglePopup();
- }
- _onMapClick(e2) {
- const t2 = e2.originalEvent.target, i3 = this._element;
- this._popup && (t2 === i3 || i3.contains(t2)) && this.togglePopup();
- }
- getPopup() {
- return this._popup;
- }
- togglePopup() {
- const e2 = this._popup;
- 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;
- }
- _evaluateOpacity() {
- const e2 = this._map;
- if (!e2)
- return;
- const t2 = this._pos;
- if (!t2 || t2.x < 0 || t2.x > e2.transform.width || t2.y < 0 || t2.y > e2.transform.height)
- return void this._clearFadeTimer();
- const i3 = e2.unproject(t2);
- let o2 = false;
- if (e2.transform._terrainEnabled() && e2.getTerrain()) {
- const t3 = e2.getFreeCameraOptions();
- if (t3.position) {
- const e3 = t3.position.toLngLat();
- o2 = e3.distanceTo(i3) < 0.9 * e3.distanceTo(this._lngLat);
- }
- }
- const r2 = (1 - e2._queryFogOpacity(i3)) * (o2 ? 0.2 : 1);
- this._element.style.opacity = `${r2}`, this._popup && this._popup._setOpacity(`${r2}`), this._fadeTimer = null;
- }
- _clearFadeTimer() {
- this._fadeTimer && (clearTimeout(this._fadeTimer), this._fadeTimer = null);
- }
- _updateDOM() {
- const e2 = this._pos;
- if (!e2)
- return;
- const t2 = this._offset.mult(this._scale), i3 = this._calculatePitch(), o2 = this._calculateRotation();
- this._element.style.transform = `
- translate(${e2.x}px, ${e2.y}px) ${Zr[this._anchor]}
- rotateX(${i3}deg) rotateZ(${o2}deg)
- translate(${t2.x}px, ${t2.y}px)
- `;
- }
- _calculatePitch() {
- return "viewport" === this._pitchAlignment || "auto" === this._pitchAlignment ? 0 : this._map && "map" === this._pitchAlignment ? this._map.getPitch() : 0;
- }
- _calculateRotation() {
- return "viewport" === this._rotationAlignment || "auto" === this._rotationAlignment ? this._rotation : this._map && "map" === this._rotationAlignment ? this._rotation - this._map.getBearing() : 0;
- }
- _update(t2) {
- e.window.cancelAnimationFrame(this._updateFrameId);
- const i3 = this._map;
- 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(() => {
- this._element && this._pos && this._anchor && (this._pos = this._pos.round(), this._updateDOM());
- }) : this._pos = this._pos.round(), i3._requestDomTask(() => {
- this._map && (this._element && this._pos && this._anchor && this._updateDOM(), !i3.getTerrain() && !i3.getFog() || this._fadeTimer || (this._fadeTimer = setTimeout(this._evaluateOpacity.bind(this), 60)));
- }));
- }
- getOffset() {
- return this._offset;
- }
- setOffset(t2) {
- return this._offset = e.pointGeometry.convert(t2), this._update(), this;
- }
- _onMove(t2) {
- const i3 = this._map;
- if (i3) {
- if (!this._isDragging) {
- const e2 = this._clickTolerance || i3._clickTolerance;
- this._isDragging = t2.point.dist(this._pointerdownPos) >= e2;
- }
- 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")));
- }
- }
- _onUp() {
- this._element.style.pointerEvents = "auto", this._positionDelta = null, this._pointerdownPos = null, this._isDragging = false;
- const t2 = this._map;
- t2 && (t2.off("mousemove", this._onMove), t2.off("touchmove", this._onMove)), "active" === this._state && this.fire(new e.Event("dragend")), this._state = "inactive";
- }
- _addDragHandler(e2) {
- const t2 = this._map;
- 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));
- }
- setDraggable(e2) {
- this._draggable = !!e2;
- const t2 = this._map;
- return t2 && (e2 ? (t2.on("mousedown", this._addDragHandler), t2.on("touchstart", this._addDragHandler)) : (t2.off("mousedown", this._addDragHandler), t2.off("touchstart", this._addDragHandler))), this;
- }
- isDraggable() {
- return this._draggable;
- }
- setRotation(e2) {
- return this._rotation = e2 || 0, this._update(), this;
- }
- getRotation() {
- return this._rotation;
- }
- setRotationAlignment(e2) {
- return this._rotationAlignment = e2 || "auto", this._update(), this;
- }
- getRotationAlignment() {
- return this._rotationAlignment;
- }
- setPitchAlignment(e2) {
- return this._pitchAlignment = e2 && "auto" !== e2 ? e2 : this._rotationAlignment, this._update(), this;
- }
- getPitchAlignment() {
- return this._pitchAlignment;
- }
- }
- class Wr {
- constructor(e2) {
- this.jumpTo(e2);
- }
- getValue(t2) {
- if (t2 <= this._startTime)
- return this._start;
- if (t2 >= this._endTime)
- return this._end;
- const i3 = e.easeCubicInOut((t2 - this._startTime) / (this._endTime - this._startTime));
- return this._start * (1 - i3) + this._end * i3;
- }
- isEasing(e2) {
- return e2 >= this._startTime && e2 <= this._endTime;
- }
- jumpTo(e2) {
- this._startTime = -1 / 0, this._endTime = -1 / 0, this._start = e2, this._end = e2;
- }
- easeTo(e2, t2, i3) {
- this._start = this.getValue(t2), this._end = e2, this._startTime = t2, this._endTime = t2 + i3;
- }
- }
- 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 };
- function $r(e2) {
- e2.parentNode && e2.parentNode.removeChild(e2);
- }
- const Hr = { showCompass: true, showZoom: true, visualizePitch: false };
- class Kr {
- constructor(t2, i3, o2 = false) {
- 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);
- }
- down(e2, t2) {
- this.mouseRotate.mousedown(e2, t2), this.mousePitch && this.mousePitch.mousedown(e2, t2), h();
- }
- move(e2, t2) {
- const i3 = this.map, o2 = this.mouseRotate.mousemoveWindow(e2, t2), r2 = o2 && o2.bearingDelta;
- if (r2 && i3.setBearing(i3.getBearing() + r2), this.mousePitch) {
- const o3 = this.mousePitch.mousemoveWindow(e2, t2), r3 = o3 && o3.pitchDelta;
- r3 && i3.setPitch(i3.getPitch() + r3);
- }
- }
- off() {
- const e2 = this.element;
- 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();
- }
- offTemp() {
- _(), e.window.removeEventListener("mousemove", this.mousemove), e.window.removeEventListener("mouseup", this.mouseup);
- }
- mousedown(t2) {
- 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);
- }
- mousemove(e2) {
- this.move(e2, p(this.element, e2));
- }
- mouseup(e2) {
- this.mouseRotate.mouseupWindow(e2), this.mousePitch && this.mousePitch.mouseupWindow(e2), this.offTemp();
- }
- touchstart(e2) {
- 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));
- }
- touchmove(e2) {
- 1 !== e2.targetTouches.length ? this.reset() : (this._lastPos = m(this.element, e2.targetTouches)[0], this.move({ preventDefault: () => e2.preventDefault() }, this._lastPos));
- }
- touchend(e2) {
- 0 === e2.targetTouches.length && this._startPos && this._lastPos && this._startPos.dist(this._lastPos) < this._clickTolerance && this.element.click(), this.reset();
- }
- reset() {
- this.mouseRotate.reset(), this.mousePitch && this.mousePitch.reset(), delete this._startPos, delete this._lastPos, this.offTemp();
- }
- }
- const Yr = { positionOptions: { enableHighAccuracy: false, maximumAge: 0, timeout: 6e3 }, fitBoundsOptions: { maxZoom: 15 }, trackUserLocation: false, showAccuracyCircle: true, showUserLocation: true, showUserHeading: false };
- let Jr, Qr = 0, en = false;
- const tn = { maxWidth: 100, unit: "metric" };
- function on(e2, t2, i3) {
- 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);
- if (i3 && "imperial" === i3.unit) {
- const i4 = 3.2808 * l2;
- i4 > 5280 ? rn(t2, o2, i4 / 5280, e2._getUIString("ScaleControl.Miles"), e2) : rn(t2, o2, i4, e2._getUIString("ScaleControl.Feet"), e2);
- } else
- 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);
- }
- function rn(e2, t2, i3, o2, r2) {
- const n2 = function(e3) {
- const t3 = Math.pow(10, `${Math.floor(e3)}`.length - 1);
- let i4 = e3 / t3;
- return i4 = i4 >= 10 ? 10 : i4 >= 5 ? 5 : i4 >= 3 ? 3 : i4 >= 2 ? 2 : i4 >= 1 ? 1 : function(e4) {
- const t4 = Math.pow(10, Math.ceil(-Math.log(e4) / Math.LN10));
- return Math.round(e4 * t4) / t4;
- }(i4), t3 * i4;
- }(i3), a2 = n2 / i3;
- r2._requestDomTask(() => {
- e2.style.width = t2 * a2 + "px", e2.innerHTML = `${n2} ${o2}`;
- });
- }
- 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(", ");
- function sn(t2 = new e.pointGeometry(0, 0), i3 = "bottom") {
- if ("number" == typeof t2) {
- const o2 = Math.round(Math.sqrt(0.5 * Math.pow(t2, 2)));
- switch (i3) {
- case "top":
- return new e.pointGeometry(0, t2);
- case "top-left":
- return new e.pointGeometry(o2, o2);
- case "top-right":
- return new e.pointGeometry(-o2, o2);
- case "bottom":
- return new e.pointGeometry(0, -t2);
- case "bottom-left":
- return new e.pointGeometry(o2, -o2);
- case "bottom-right":
- return new e.pointGeometry(-o2, -o2);
- case "left":
- return new e.pointGeometry(t2, 0);
- case "right":
- return new e.pointGeometry(-t2, 0);
- }
- return new e.pointGeometry(0, 0);
- }
- return t2 instanceof e.pointGeometry || Array.isArray(t2) ? e.pointGeometry.convert(t2) : e.pointGeometry.convert(t2[i3] || [0, 0]);
- }
- const ln = { version: e.version, supported: t, setRTLTextPlugin: e.setRTLTextPlugin, getRTLTextPluginStatus: e.getRTLTextPluginStatus, Map: class extends Fr {
- constructor(t2) {
- if (null != (t2 = e.extend({}, Xr, t2)).minZoom && null != t2.maxZoom && t2.minZoom > t2.maxZoom)
- throw new Error("maxZoom must be greater than or equal to minZoom");
- if (null != t2.minPitch && null != t2.maxPitch && t2.minPitch > t2.maxPitch)
- throw new Error("maxPitch must be greater than or equal to minPitch");
- if (null != t2.minPitch && t2.minPitch < 0)
- throw new Error("minPitch must be greater than or equal to 0");
- if (null != t2.maxPitch && t2.maxPitch > 85)
- throw new Error("maxPitch must be less than or equal to 85");
- 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) {
- if (this._container = e.window.document.getElementById(t2.container), !this._container)
- throw new Error(`Container '${t2.container}' not found.`);
- } else {
- if (!(t2.container instanceof e.window.HTMLElement))
- throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
- this._container = t2.container;
- }
- 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)
- throw new Error("Failed to initialize WebGL.");
- 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", () => {
- this.transform.unmodified && this.jumpTo(this.style.stylesheet);
- }), this.on("data", (t3) => {
- this._update("style" === t3.dataType), this.fire(new e.Event(`${t3.dataType}data`, t3));
- }), this.on("dataloading", (t3) => {
- this.fire(new e.Event(`${t3.dataType}dataloading`, t3));
- });
- }
- _getMapId() {
- return this._mapId;
- }
- addControl(t2, i3) {
- if (void 0 === i3 && (i3 = t2.getDefaultPosition ? t2.getDefaultPosition() : "top-right"), !t2 || !t2.onAdd)
- return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));
- const o2 = t2.onAdd(this);
- this._controls.push(t2);
- const r2 = this._controlPositions[i3];
- return -1 !== i3.indexOf("bottom") ? r2.insertBefore(o2, r2.firstChild) : r2.appendChild(o2), this;
- }
- removeControl(t2) {
- if (!t2 || !t2.onRemove)
- return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));
- const i3 = this._controls.indexOf(t2);
- return i3 > -1 && this._controls.splice(i3, 1), t2.onRemove(this), this;
- }
- hasControl(e2) {
- return this._controls.indexOf(e2) > -1;
- }
- getContainer() {
- return this._container;
- }
- getCanvasContainer() {
- return this._canvasContainer;
- }
- getCanvas() {
- return this._canvas;
- }
- resize(t2) {
- if (this._updateContainerDimensions(), this._containerWidth === this.transform.width && this._containerHeight === this.transform.height)
- return this;
- this._resizeCanvas(this._containerWidth, this._containerHeight), this.transform.resize(this._containerWidth, this._containerHeight), this.painter.resize(Math.ceil(this._containerWidth), Math.ceil(this._containerHeight));
- const i3 = !this._moving;
- 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;
- }
- getBounds() {
- return this.transform.getBounds();
- }
- getMaxBounds() {
- return this.transform.getMaxBounds() || null;
- }
- setMaxBounds(t2) {
- return this.transform.setMaxBounds(e.LngLatBounds.convert(t2)), this._update();
- }
- setMinZoom(t2) {
- if ((t2 = null == t2 ? -2 : t2) >= -2 && t2 <= this.transform.maxZoom)
- 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;
- throw new Error("minZoom must be between -2 and the current maxZoom, inclusive");
- }
- getMinZoom() {
- return this.transform.minZoom;
- }
- setMaxZoom(t2) {
- if ((t2 = null == t2 ? 22 : t2) >= this.transform.minZoom)
- 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;
- throw new Error("maxZoom must be greater than the current minZoom");
- }
- getMaxZoom() {
- return this.transform.maxZoom;
- }
- setMinPitch(t2) {
- if ((t2 = null == t2 ? 0 : t2) < 0)
- throw new Error("minPitch must be greater than or equal to 0");
- if (t2 >= 0 && t2 <= this.transform.maxPitch)
- 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;
- throw new Error("minPitch must be between 0 and the current maxPitch, inclusive");
- }
- getMinPitch() {
- return this.transform.minPitch;
- }
- setMaxPitch(t2) {
- if ((t2 = null == t2 ? 85 : t2) > 85)
- throw new Error("maxPitch must be less than or equal to 85");
- if (t2 >= this.transform.minPitch)
- 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;
- throw new Error("maxPitch must be greater than the current minPitch");
- }
- getMaxPitch() {
- return this.transform.maxPitch;
- }
- getRenderWorldCopies() {
- return this.transform.renderWorldCopies;
- }
- setRenderWorldCopies(e2) {
- return this.transform.renderWorldCopies = e2, this._update();
- }
- getProjection() {
- return this._explicitProjection ? this._explicitProjection : this.style && this.style.stylesheet && this.style.stylesheet.projection ? this.style.stylesheet.projection : { name: "mercator", center: [0, 0] };
- }
- setProjection(e2) {
- return this._lazyInitEmptyStyle(), e2 ? "string" == typeof e2 && (e2 = { name: e2 }) : e2 = null, this._updateProjection(e2);
- }
- _updateProjection(e2) {
- null === e2 && (this._explicitProjection = null);
- const t2 = e2 || this.getProjection(), i3 = this.transform.setProjection(t2);
- if (e2 && (this._explicitProjection = this.transform.getProjection()), i3) {
- this.painter.clearBackgroundTiles();
- for (const e3 in this.style._sourceCaches)
- this.style._sourceCaches[e3].clearTiles();
- this.style.applyProjectionUpdate(), this._update(true);
- }
- return this;
- }
- project(t2) {
- return this.transform.locationPoint3D(e.LngLat.convert(t2));
- }
- unproject(t2) {
- return this.transform.pointLocation3D(e.pointGeometry.convert(t2));
- }
- isMoving() {
- return this._moving || this.handlers && this.handlers.isMoving() || false;
- }
- isZooming() {
- return this._zooming || this.handlers && this.handlers.isZooming() || false;
- }
- isRotating() {
- return this._rotating || this.handlers && this.handlers.isRotating() || false;
- }
- _createDelegatedListener(e2, t2, i3) {
- if ("mouseenter" === e2 || "mouseover" === e2) {
- let o2 = false;
- const r2 = (r3) => {
- const n3 = t2.filter((e3) => this.getLayer(e3)), a2 = n3.length ? this.queryRenderedFeatures(r3.point, { layers: n3 }) : [];
- a2.length ? o2 || (o2 = true, i3.call(this, new Yo(e2, this, r3.originalEvent, { features: a2 }))) : o2 = false;
- }, n2 = () => {
- o2 = false;
- };
- return { layers: new Set(t2), listener: i3, delegates: { mousemove: r2, mouseout: n2 } };
- }
- if ("mouseleave" === e2 || "mouseout" === e2) {
- let o2 = false;
- const r2 = (r3) => {
- const n3 = t2.filter((e3) => this.getLayer(e3));
- (n3.length ? this.queryRenderedFeatures(r3.point, { layers: n3 }) : []).length ? o2 = true : o2 && (o2 = false, i3.call(this, new Yo(e2, this, r3.originalEvent)));
- }, n2 = (t3) => {
- o2 && (o2 = false, i3.call(this, new Yo(e2, this, t3.originalEvent)));
- };
- return { layers: new Set(t2), listener: i3, delegates: { mousemove: r2, mouseout: n2 } };
- }
- {
- const o2 = (e3) => {
- const o3 = t2.filter((e4) => this.getLayer(e4)), r2 = o3.length ? this.queryRenderedFeatures(e3.point, { layers: o3 }) : [];
- r2.length && (e3.features = r2, i3.call(this, e3), delete e3.features);
- };
- return { layers: new Set(t2), listener: i3, delegates: { [e2]: o2 } };
- }
- }
- on(e2, t2, i3) {
- if (void 0 === i3)
- return super.on(e2, t2);
- Array.isArray(t2) || (t2 = [t2]);
- const o2 = this._createDelegatedListener(e2, t2, i3);
- this._delegatedListeners = this._delegatedListeners || {}, this._delegatedListeners[e2] = this._delegatedListeners[e2] || [], this._delegatedListeners[e2].push(o2);
- for (const e3 in o2.delegates)
- this.on(e3, o2.delegates[e3]);
- return this;
- }
- once(e2, t2, i3) {
- if (void 0 === i3)
- return super.once(e2, t2);
- Array.isArray(t2) || (t2 = [t2]);
- const o2 = this._createDelegatedListener(e2, t2, i3);
- for (const e3 in o2.delegates)
- this.once(e3, o2.delegates[e3]);
- return this;
- }
- off(e2, t2, i3) {
- if (void 0 === i3)
- return super.off(e2, t2);
- t2 = new Set(Array.isArray(t2) ? t2 : [t2]);
- const o2 = (e3, t3) => {
- if (e3.size !== t3.size)
- return false;
- for (const i4 of e3)
- if (!t3.has(i4))
- return false;
- return true;
- }, r2 = this._delegatedListeners ? this._delegatedListeners[e2] : void 0;
- return r2 && ((e3) => {
- for (let r3 = 0; r3 < e3.length; r3++) {
- const n2 = e3[r3];
- if (n2.listener === i3 && o2(n2.layers, t2)) {
- for (const e4 in n2.delegates)
- this.off(e4, n2.delegates[e4]);
- return e3.splice(r3, 1), this;
- }
- }
- })(r2), this;
- }
- queryRenderedFeatures(t2, i3) {
- 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)) : [];
- }
- querySourceFeatures(e2, t2) {
- return this.style.querySourceFeatures(e2, t2);
- }
- queryTerrainElevation(t2, i3) {
- const o2 = this.transform.elevation;
- return o2 ? (i3 = e.extend({}, { exaggerated: true }, i3), o2.getAtPoint(e.MercatorCoordinate.fromLngLat(t2), null, i3.exaggerated)) : null;
- }
- setStyle(t2, i3) {
- 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));
- }
- _getUIString(e2) {
- const t2 = this._locale[e2];
- if (null == t2)
- throw new Error(`Missing UI string '${e2}'`);
- return t2;
- }
- _updateStyle(e2, t2) {
- 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;
- }
- _lazyInitEmptyStyle() {
- this.style || (this.style = new $t(this, {}), this.style.setEventedParent(this, { style: this.style }), this.style.loadEmpty());
- }
- _diffStyle(t2, i3) {
- if ("string" == typeof t2) {
- const o2 = this._requestManager.normalizeStyleURL(t2), r2 = this._requestManager.transformRequest(o2, e.ResourceType.Style);
- e.getJSON(r2, (t3, o3) => {
- t3 ? this.fire(new e.ErrorEvent(t3)) : o3 && this._updateDiff(o3, i3);
- });
- } else
- "object" == typeof t2 && this._updateDiff(t2, i3);
- }
- _updateDiff(t2, i3) {
- try {
- this.style.setState(t2) && this._update(true);
- } catch (o2) {
- e.warnOnce(`Unable to perform style diff: ${o2.message || o2.error || o2}. Rebuilding the style from scratch.`), this._updateStyle(t2, i3);
- }
- }
- getStyle() {
- if (this.style)
- return this.style.serialize();
- }
- isStyleLoaded() {
- return this.style ? this.style.loaded() : (e.warnOnce("There is no style added to the map."), false);
- }
- addSource(e2, t2) {
- return this._lazyInitEmptyStyle(), this.style.addSource(e2, t2), this._update(true);
- }
- isSourceLoaded(e2) {
- return !!this.style && this.style._isSourceCacheLoaded(e2);
- }
- areTilesLoaded() {
- const e2 = this.style && this.style._sourceCaches;
- for (const t2 in e2) {
- const i3 = e2[t2]._tiles;
- for (const e3 in i3) {
- const t3 = i3[e3];
- if ("loaded" !== t3.state && "errored" !== t3.state)
- return false;
- }
- }
- return true;
- }
- addSourceType(e2, t2, i3) {
- this._lazyInitEmptyStyle(), this.style.addSourceType(e2, t2, i3);
- }
- removeSource(e2) {
- return this.style.removeSource(e2), this._updateTerrain(), this._update(true);
- }
- getSource(e2) {
- return this.style.getSource(e2);
- }
- addImage(t2, i3, { pixelRatio: o2 = 1, sdf: r2 = false, stretchX: n2, stretchY: a2, content: s2 } = {}) {
- if (this._lazyInitEmptyStyle(), i3 instanceof e.window.HTMLImageElement || e.window.ImageBitmap && i3 instanceof e.window.ImageBitmap) {
- const { width: l2, height: c2, data: h2 } = e.exported.getImageData(i3);
- 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 });
- } else if (void 0 === i3.width || void 0 === i3.height)
- 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`")));
- else {
- const { width: l2, height: c2 } = i3, h2 = i3;
- 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);
- }
- }
- updateImage(t2, i3) {
- const o2 = this.style.getImage(t2);
- if (!o2)
- 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.")));
- 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;
- 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`")));
- }
- hasImage(t2) {
- return t2 ? !!this.style.getImage(t2) : (this.fire(new e.ErrorEvent(new Error("Missing required image id"))), false);
- }
- removeImage(e2) {
- this.style.removeImage(e2);
- }
- loadImage(t2, i3) {
- e.getImage(this._requestManager.transformRequest(t2, e.ResourceType.Image), (t3, o2) => {
- i3(t3, o2 instanceof e.window.HTMLImageElement ? e.exported.getImageData(o2) : o2);
- });
- }
- listImages() {
- return this.style.listImages();
- }
- addLayer(e2, t2) {
- return this._lazyInitEmptyStyle(), this.style.addLayer(e2, t2), this._update(true);
- }
- moveLayer(e2, t2) {
- return this.style.moveLayer(e2, t2), this._update(true);
- }
- removeLayer(e2) {
- return this.style.removeLayer(e2), this._update(true);
- }
- getLayer(e2) {
- return this.style.getLayer(e2);
- }
- setLayerZoomRange(e2, t2, i3) {
- return this.style.setLayerZoomRange(e2, t2, i3), this._update(true);
- }
- setFilter(e2, t2, i3 = {}) {
- return this.style.setFilter(e2, t2, i3), this._update(true);
- }
- getFilter(e2) {
- return this.style.getFilter(e2);
- }
- setPaintProperty(e2, t2, i3, o2 = {}) {
- return this.style.setPaintProperty(e2, t2, i3, o2), this._update(true);
- }
- getPaintProperty(e2, t2) {
- return this.style.getPaintProperty(e2, t2);
- }
- setLayoutProperty(e2, t2, i3, o2 = {}) {
- return this.style.setLayoutProperty(e2, t2, i3, o2), this._update(true);
- }
- getLayoutProperty(e2, t2) {
- return this.style.getLayoutProperty(e2, t2);
- }
- setLight(e2, t2 = {}) {
- return this._lazyInitEmptyStyle(), this.style.setLight(e2, t2), this._update(true);
- }
- getLight() {
- return this.style.getLight();
- }
- setTerrain(e2) {
- return this._lazyInitEmptyStyle(), !e2 && this.transform.projection.requiresDraping ? this.style.setTerrainForDraping() : this.style.setTerrain(e2), this._averageElevationLastSampledAt = -1 / 0, this._update(true);
- }
- getTerrain() {
- return this.style ? this.style.getTerrain() : null;
- }
- setFog(e2) {
- return this._lazyInitEmptyStyle(), this.style.setFog(e2), this._update(true);
- }
- getFog() {
- return this.style ? this.style.getFog() : null;
- }
- _queryFogOpacity(t2) {
- return this.style && this.style.fog ? this.style.fog.getOpacityAtLatLng(e.LngLat.convert(t2), this.transform) : 0;
- }
- setFeatureState(e2, t2) {
- return this.style.setFeatureState(e2, t2), this._update();
- }
- removeFeatureState(e2, t2) {
- return this.style.removeFeatureState(e2, t2), this._update();
- }
- getFeatureState(e2) {
- return this.style.getFeatureState(e2);
- }
- _updateContainerDimensions() {
- if (!this._container)
- return;
- const t2 = this._container.getBoundingClientRect().width || 400, i3 = this._container.getBoundingClientRect().height || 300;
- let o2, r2, n2, a2 = this._container;
- for (; a2 && (!r2 || !n2); ) {
- const t3 = e.window.getComputedStyle(a2).transform;
- 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;
- }
- this._containerWidth = r2 ? Math.abs(t2 / r2) : t2, this._containerHeight = n2 ? Math.abs(i3 / n2) : i3;
- }
- _detectMissingCSS() {
- "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/.");
- }
- _setupContainer() {
- const e2 = this._container;
- e2.classList.add("mapboxgl-map"), (this._missingCSSCanary = n("div", "mapboxgl-canary", e2)).style.visibility = "hidden", this._detectMissingCSS();
- const t2 = this._canvasContainer = n("div", "mapboxgl-canvas-container", e2);
- 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);
- const i3 = this._controlContainer = n("div", "mapboxgl-control-container", e2), o2 = this._controlPositions = {};
- ["top-left", "top-right", "bottom-left", "bottom-right"].forEach((e3) => {
- o2[e3] = n("div", `mapboxgl-ctrl-${e3}`, i3);
- }), this._container.addEventListener("scroll", this._onMapScroll, false);
- }
- _resizeCanvas(t2, i3) {
- const o2 = e.exported.devicePixelRatio || 1;
- 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`;
- }
- _addMarker(e2) {
- this._markers.push(e2);
- }
- _removeMarker(e2) {
- const t2 = this._markers.indexOf(e2);
- -1 !== t2 && this._markers.splice(t2, 1);
- }
- _setupPainter() {
- 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);
- o2 ? (e.storeAuthState(o2, true), this.painter = new Mo(o2, this.transform), this.on("data", (e2) => {
- "source" === e2.dataType && this.painter.setTileLoadedFlag(true);
- }), e.exported$1.testSupport(o2)) : this.fire(new e.ErrorEvent(new Error("Failed to initialize WebGL")));
- }
- _contextLost(t2) {
- t2.preventDefault(), this._frame && (this._frame.cancel(), this._frame = null), this.fire(new e.Event("webglcontextlost", { originalEvent: t2 }));
- }
- _contextRestored(t2) {
- this._setupPainter(), this.resize(), this._update(), this.fire(new e.Event("webglcontextrestored", { originalEvent: t2 }));
- }
- _onMapScroll(e2) {
- if (e2.target === this._container)
- return this._container.scrollTop = 0, this._container.scrollLeft = 0, false;
- }
- loaded() {
- return !this._styleDirty && !this._sourcesDirty && !!this.style && this.style.loaded();
- }
- _update(e2) {
- return this.style ? (this._styleDirty = this._styleDirty || e2, this._sourcesDirty = true, this.triggerRepaint(), this) : this;
- }
- _requestRenderFrame(e2) {
- return this._update(), this._renderTaskQueue.add(e2);
- }
- _cancelRenderFrame(e2) {
- this._renderTaskQueue.remove(e2);
- }
- _requestDomTask(e2) {
- !this.loaded() || this.loaded() && !this.isMoving() ? e2() : this._domRenderTaskQueue.add(e2);
- }
- _render(t2) {
- let i3;
- const o2 = this.painter.context.extTimerQuery, r2 = e.exported.now();
- 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)
- return;
- let n2 = false;
- const a2 = this._isInitialLoad ? 0 : this._fadeDuration;
- if (this.style && this._styleDirty) {
- this._styleDirty = false;
- const t3 = this.transform.zoom, i4 = this.transform.pitch, o3 = e.exported.now();
- this.style.zoomHistory.update(t3, o3);
- const r3 = new e.EvaluationParameters(t3, { now: o3, fadeDuration: a2, pitch: i4, zoomHistory: this.style.zoomHistory, transition: this.style.getTransition() }), s3 = r3.crossFadingFactor();
- 1 === s3 && s3 === this._crossFadingFactor || (n2 = true, this._crossFadingFactor = s3), this.style.update(r3);
- }
- this.style && this.style.fog && this.style.fog.hasTransition() && (this.style._markersNeedUpdate = true, this._sourcesDirty = true);
- let s2 = false;
- 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")) {
- const t3 = e.exported.now() - r2;
- o2.endQueryEXT(o2.TIME_ELAPSED_EXT, i3), setTimeout(() => {
- const r3 = o2.getQueryObjectEXT(i3, o2.QUERY_RESULT_EXT) / 1e6;
- o2.deleteQueryEXT(i3), this.fire(new e.Event("gpu-timing-frame", { cpuTime: t3, gpuTime: r3 }));
- }, 50);
- }
- if (this.listens("gpu-timing-layer")) {
- const t3 = this.painter.collectGpuTimers();
- setTimeout(() => {
- const i4 = this.painter.queryGpuTimers(t3);
- this.fire(new e.Event("gpu-timing-layer", { layerTimes: i4 }));
- }, 50);
- }
- const l2 = this._sourcesDirty || this._styleDirty || this._placementDirty || s2;
- if (l2 || this._repaint)
- this.triggerRepaint();
- else {
- const t3 = !this.isMoving() && this.loaded();
- if (t3 && (s2 = this._updateAverageElevation(r2, true)), s2)
- this.triggerRepaint();
- else if (this._triggerFrame(false), t3 && (this.fire(new e.Event("idle")), this._isInitialLoad = false, this.speedIndexTiming)) {
- const t4 = this._calculateSpeedIndex();
- this.fire(new e.Event("speedindexcompleted", { speedIndex: t4 })), this.speedIndexTiming = false;
- }
- }
- !this._loaded || this._fullyLoaded || l2 || (this._fullyLoaded = true, this._authenticate());
- }
- _forceMarkerUpdate() {
- for (const e2 of this._markers)
- e2._update();
- }
- _updateAverageElevation(e2, t2 = false) {
- const i3 = (e3) => (this.transform.averageElevation = e3, this._update(false), true);
- if (!this.painter.averageElevationNeedsEasing())
- return 0 !== this.transform.averageElevation && i3(0);
- if ((t2 || e2 - this._averageElevationLastSampledAt > 500) && !this._averageElevation.isEasing(e2)) {
- const t3 = this.transform.averageElevation;
- let o2 = this.transform.sampleAverageElevation(), r2 = false;
- this.transform.elevation && (r2 = this.transform.elevation.exaggeration() !== this._averageElevationExaggeration, this._averageElevationExaggeration = this.transform.elevation.exaggeration()), isNaN(o2) ? o2 = 0 : this._averageElevationLastSampledAt = e2;
- const n2 = Math.abs(t3 - o2);
- if (n2 > 1) {
- if (this._isInitialLoad || r2)
- return this._averageElevation.jumpTo(o2), i3(o2);
- this._averageElevation.easeTo(o2, e2, 300);
- } else if (n2 > 1e-4)
- return this._averageElevation.jumpTo(o2), i3(o2);
- }
- return !!this._averageElevation.isEasing(e2) && i3(this._averageElevation.getValue(e2));
- }
- _authenticate() {
- e.getMapSessionAPI(this._getMapId(), this._requestManager._skuToken, this._requestManager._customAccessToken, (t2) => {
- if (t2 && (t2.message === e.AUTH_ERR_MSG || 401 === t2.status)) {
- const t3 = this.painter.context.gl;
- 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/")));
- }
- }), e.postMapLoadEvent(this._getMapId(), this._requestManager._skuToken, this._requestManager._customAccessToken, () => {
- });
- }
- _updateTerrain() {
- this.painter.updateTerrain(this.style, this.isMoving() || this.isRotating() || this.isZooming());
- }
- _calculateSpeedIndex() {
- const e2 = this.painter.canvasCopy(), t2 = this.painter.getCanvasCopiesAndTimestamps();
- t2.timeStamps.push(performance.now());
- const i3 = this.painter.context.gl, o2 = i3.createFramebuffer();
- function r2(e3) {
- i3.framebufferTexture2D(i3.FRAMEBUFFER, i3.COLOR_ATTACHMENT0, i3.TEXTURE_2D, e3, 0);
- const t3 = new Uint8Array(i3.drawingBufferWidth * i3.drawingBufferHeight * 4);
- return i3.readPixels(0, 0, i3.drawingBufferWidth, i3.drawingBufferHeight, i3.RGBA, i3.UNSIGNED_BYTE, t3), t3;
- }
- return i3.bindFramebuffer(i3.FRAMEBUFFER, o2), this._canvasPixelComparison(r2(e2), t2.canvasCopies.map(r2), t2.timeStamps);
- }
- _canvasPixelComparison(e2, t2, i3) {
- let o2 = i3[1] - i3[0];
- const r2 = e2.length / 4;
- for (let n2 = 0; n2 < t2.length; n2++) {
- const a2 = t2[n2];
- let s2 = 0;
- for (let t3 = 0; t3 < a2.length; t3 += 4)
- a2[t3] === e2[t3] && a2[t3 + 1] === e2[t3 + 1] && a2[t3 + 2] === e2[t3 + 2] && a2[t3 + 3] === e2[t3 + 3] && (s2 += 1);
- o2 += (i3[n2 + 2] - i3[n2 + 1]) * (1 - s2 / r2);
- }
- return o2;
- }
- remove() {
- this._hash && this._hash.remove();
- for (const e2 of this._controls)
- e2.onRemove(this);
- 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));
- const t2 = this.painter.context.gl.getExtension("WEBGL_lose_context");
- 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"));
- }
- triggerRepaint() {
- this._triggerFrame(true);
- }
- _triggerFrame(t2) {
- this._renderNextFrame = this._renderNextFrame || t2, this.style && !this._frame && (this._frame = e.exported.frame((e2) => {
- const t3 = !!this._renderNextFrame;
- this._frame = null, this._renderNextFrame = null, t3 && this._render(e2);
- }));
- }
- _preloadTiles(t2) {
- const i3 = this.style ? Object.values(this.style._sourceCaches) : [];
- return e.asyncAll(i3, (e2, i4) => e2._preloadTiles(t2, i4), () => {
- this.triggerRepaint();
- }), this;
- }
- _onWindowOnline() {
- this._update();
- }
- _onWindowResize(e2) {
- this._trackResize && this.resize({ originalEvent: e2 })._update();
- }
- get showTileBoundaries() {
- return !!this._showTileBoundaries;
- }
- set showTileBoundaries(e2) {
- this._showTileBoundaries !== e2 && (this._showTileBoundaries = e2, this._update());
- }
- get showTerrainWireframe() {
- return !!this._showTerrainWireframe;
- }
- set showTerrainWireframe(e2) {
- this._showTerrainWireframe !== e2 && (this._showTerrainWireframe = e2, this._update());
- }
- get speedIndexTiming() {
- return !!this._speedIndexTiming;
- }
- set speedIndexTiming(e2) {
- this._speedIndexTiming !== e2 && (this._speedIndexTiming = e2, this._update());
- }
- get showPadding() {
- return !!this._showPadding;
- }
- set showPadding(e2) {
- this._showPadding !== e2 && (this._showPadding = e2, this._update());
- }
- get showCollisionBoxes() {
- return !!this._showCollisionBoxes;
- }
- set showCollisionBoxes(e2) {
- this._showCollisionBoxes !== e2 && (this._showCollisionBoxes = e2, e2 ? this.style._generateCollisionBoxes() : this._update());
- }
- get showOverdrawInspector() {
- return !!this._showOverdrawInspector;
- }
- set showOverdrawInspector(e2) {
- this._showOverdrawInspector !== e2 && (this._showOverdrawInspector = e2, this._update());
- }
- get repaint() {
- return !!this._repaint;
- }
- set repaint(e2) {
- this._repaint !== e2 && (this._repaint = e2, this.triggerRepaint());
- }
- get vertices() {
- return !!this._vertices;
- }
- set vertices(e2) {
- this._vertices = e2, this._update();
- }
- _setCacheLimits(t2, i3) {
- e.setCacheLimits(t2, i3);
- }
- get version() {
- return e.version;
- }
- }, NavigationControl: class {
- constructor(t2) {
- 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) => {
- this._map && this._map.zoomIn({}, { originalEvent: e2 });
- }), n("span", "mapboxgl-ctrl-icon", this._zoomInButton).setAttribute("aria-hidden", "true"), this._zoomOutButton = this._createButton("mapboxgl-ctrl-zoom-out", (e2) => {
- this._map && this._map.zoomOut({}, { originalEvent: e2 });
- }), 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) => {
- const t3 = this._map;
- t3 && (this.options.visualizePitch ? t3.resetNorthPitch({}, { originalEvent: e2 }) : t3.resetNorth({}, { originalEvent: e2 }));
- }), this._compassIcon = n("span", "mapboxgl-ctrl-icon", this._compass), this._compassIcon.setAttribute("aria-hidden", "true"));
- }
- _updateZoomButtons() {
- const e2 = this._map;
- if (!e2)
- return;
- const t2 = e2.getZoom(), i3 = t2 === e2.getMaxZoom(), o2 = t2 === e2.getMinZoom();
- this._zoomInButton.disabled = i3, this._zoomOutButton.disabled = o2, this._zoomInButton.setAttribute("aria-disabled", i3.toString()), this._zoomOutButton.setAttribute("aria-disabled", o2.toString());
- }
- _rotateCompassArrow() {
- const e2 = this._map;
- if (!e2)
- return;
- 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)`;
- e2._requestDomTask(() => {
- this._compassIcon && (this._compassIcon.style.transform = t2);
- });
- }
- onAdd(e2) {
- 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;
- }
- onRemove() {
- const e2 = this._map;
- 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);
- }
- _createButton(e2, t2) {
- const i3 = n("button", e2, this._container);
- return i3.type = "button", i3.addEventListener("click", t2), i3;
- }
- _setButtonTitle(e2, t2) {
- if (!this._map)
- return;
- const i3 = this._map._getUIString(`NavigationControl.${t2}`);
- e2.setAttribute("aria-label", i3), e2.firstElementChild && e2.firstElementChild.setAttribute("title", i3);
- }
- }, GeolocateControl: class extends e.Evented {
- constructor(t2) {
- 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);
- }
- onAdd(t2) {
- var i3;
- 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) => {
- Jr = "denied" !== e2.state, i3(Jr);
- }) : (Jr = !!e.window.navigator.geolocation, i3(Jr)), this._container;
- }
- onRemove() {
- 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;
- }
- _isOutOfMapMaxBounds(e2) {
- const t2 = this._map.getMaxBounds(), i3 = e2.coords;
- return !!t2 && (i3.longitude < t2.getWest() || i3.longitude > t2.getEast() || i3.latitude < t2.getSouth() || i3.latitude > t2.getNorth());
- }
- _setErrorState() {
- switch (this._watchState) {
- case "WAITING_ACTIVE":
- this._watchState = "ACTIVE_ERROR", this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"), this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");
- break;
- case "ACTIVE_LOCK":
- 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");
- break;
- case "BACKGROUND":
- 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");
- }
- }
- _onSuccess(t2) {
- if (this._map) {
- if (this._isOutOfMapMaxBounds(t2))
- return this._setErrorState(), this.fire(new e.Event("outofmaxbounds", t2)), this._updateMarker(), void this._finish();
- if (this.options.trackUserLocation)
- switch (this._lastKnownPosition = t2, this._watchState) {
- case "WAITING_ACTIVE":
- case "ACTIVE_LOCK":
- case "ACTIVE_ERROR":
- 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");
- break;
- case "BACKGROUND":
- case "BACKGROUND_ERROR":
- 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");
- }
- 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();
- }
- }
- _updateCamera(t2) {
- 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);
- this._map.fitBounds(i3.toBounds(o2), n2, { geolocateSource: true });
- }
- _updateMarker(t2) {
- if (t2) {
- const i3 = new e.LngLat(t2.coords.longitude, t2.coords.latitude);
- 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();
- } else
- this._userLocationDotMarker.remove(), this._accuracyCircleMarker.remove();
- }
- _updateCircleRadius() {
- 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);
- this._circleElement.style.width = `${r2}px`, this._circleElement.style.height = `${r2}px`;
- }
- _onZoom() {
- this.options.showUserLocation && this.options.showAccuracyCircle && this._updateCircleRadius();
- }
- _updateMarkerRotation() {
- 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));
- }
- _onError(t2) {
- if (this._map) {
- if (this.options.trackUserLocation)
- if (1 === t2.code) {
- 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;
- const e2 = this._map._getUIString("GeolocateControl.LocationNotAvailable");
- this._geolocateButton.setAttribute("aria-label", e2), this._geolocateButton.firstElementChild && this._geolocateButton.firstElementChild.setAttribute("title", e2), void 0 !== this._geolocationWatchID && this._clearWatch();
- } else {
- if (3 === t2.code && en)
- return;
- this._setErrorState();
- }
- "OFF" !== this._watchState && this.options.showUserLocation && this._dotElement.classList.add("mapboxgl-user-location-dot-stale"), this.fire(new e.Event("error", t2)), this._finish();
- }
- }
- _finish() {
- this._timeoutId && clearTimeout(this._timeoutId), this._timeoutId = void 0;
- }
- _setupUI(t2) {
- 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) {
- e.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");
- const t3 = this._map._getUIString("GeolocateControl.LocationNotAvailable");
- this._geolocateButton.disabled = true, this._geolocateButton.setAttribute("aria-label", t3), this._geolocateButton.firstElementChild && this._geolocateButton.firstElementChild.setAttribute("title", t3);
- } else {
- const e2 = this._map._getUIString("GeolocateControl.FindMyLocation");
- this._geolocateButton.setAttribute("aria-label", e2), this._geolocateButton.firstElementChild && this._geolocateButton.firstElementChild.setAttribute("title", e2);
- }
- 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) => {
- 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")));
- });
- }
- _onDeviceOrientation(e2) {
- this._userLocationDotMarker && (e2.webkitCompassHeading ? this._heading = e2.webkitCompassHeading : true === e2.absolute && (this._heading = -1 * e2.alpha), this._updateMarkerRotationThrottled());
- }
- trigger() {
- if (!this._setup)
- return e.warnOnce("Geolocate control triggered before added to a map"), false;
- if (this.options.trackUserLocation) {
- switch (this._watchState) {
- case "OFF":
- this._watchState = "WAITING_ACTIVE", this.fire(new e.Event("trackuserlocationstart"));
- break;
- case "WAITING_ACTIVE":
- case "ACTIVE_LOCK":
- case "ACTIVE_ERROR":
- case "BACKGROUND_ERROR":
- 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"));
- break;
- case "BACKGROUND":
- this._watchState = "ACTIVE_LOCK", this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"), this._lastKnownPosition && this._updateCamera(this._lastKnownPosition), this.fire(new e.Event("trackuserlocationstart"));
- }
- switch (this._watchState) {
- case "WAITING_ACTIVE":
- this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"), this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");
- break;
- case "ACTIVE_LOCK":
- this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");
- break;
- case "ACTIVE_ERROR":
- this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"), this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");
- break;
- case "BACKGROUND":
- this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");
- break;
- case "BACKGROUND_ERROR":
- this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"), this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error");
- }
- if ("OFF" === this._watchState && void 0 !== this._geolocationWatchID)
- this._clearWatch();
- else if (void 0 === this._geolocationWatchID) {
- let t2;
- 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();
- }
- } else
- e.window.navigator.geolocation.getCurrentPosition(this._onSuccess, this._onError, this.options.positionOptions), this._timeoutId = setTimeout(this._finish, 1e4);
- return true;
- }
- _addDeviceOrientationListener() {
- const t2 = () => {
- e.window.addEventListener("ondeviceorientationabsolute" in e.window ? "deviceorientationabsolute" : "deviceorientation", this._onDeviceOrientation);
- };
- void 0 !== e.window.DeviceMotionEvent && "function" == typeof e.window.DeviceMotionEvent.requestPermission ? DeviceOrientationEvent.requestPermission().then((e2) => {
- "granted" === e2 && t2();
- }).catch(console.error) : t2();
- }
- _clearWatch() {
- 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);
- }
- }, AttributionControl: Ur, ScaleControl: class {
- constructor(t2) {
- this.options = e.extend({}, tn, t2), e.bindAll(["_onMove", "setUnit"], this);
- }
- getDefaultPosition() {
- return "bottom-left";
- }
- _onMove() {
- on(this._map, this._container, this.options);
- }
- onAdd(e2) {
- 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;
- }
- onRemove() {
- this._container.remove(), this._map.off("move", this._onMove), this._map = void 0;
- }
- setUnit(e2) {
- this.options.unit = e2, on(this._map, this._container, this.options);
- }
- }, FullscreenControl: class {
- constructor(t2) {
- 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");
- }
- onAdd(t2) {
- 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;
- }
- onRemove() {
- this._controlContainer.remove(), this._map = null, e.window.document.removeEventListener(this._fullscreenchange, this._changeIcon);
- }
- _checkFullscreenSupport() {
- return !(!e.window.document.fullscreenEnabled && !e.window.document.webkitFullscreenEnabled);
- }
- _setupUI() {
- const t2 = this._fullscreenButton = n("button", "mapboxgl-ctrl-fullscreen", this._controlContainer);
- 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);
- }
- _updateTitle() {
- const e2 = this._getTitle();
- this._fullscreenButton.setAttribute("aria-label", e2), this._fullscreenButton.firstElementChild && this._fullscreenButton.firstElementChild.setAttribute("title", e2);
- }
- _getTitle() {
- return this._map._getUIString(this._isFullscreen() ? "FullscreenControl.Exit" : "FullscreenControl.Enter");
- }
- _isFullscreen() {
- return this._fullscreen;
- }
- _changeIcon() {
- (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());
- }
- _onClickFullscreen() {
- 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();
- }
- }, Popup: class extends e.Evented {
- constructor(t2) {
- 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+/) : []);
- }
- addTo(t2) {
- 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;
- }
- isOpen() {
- return !!this._map;
- }
- remove() {
- this._content && this._content.remove(), this._container && (this._container.remove(), this._container = void 0);
- const t2 = this._map;
- 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;
- }
- getLngLat() {
- return this._lngLat;
- }
- setLngLat(t2) {
- this._lngLat = e.LngLat.convert(t2), this._pos = null, this._trackPointer = false, this._update();
- const i3 = this._map;
- return i3 && (i3.on("move", this._update), i3.off("mousemove", this._onMouseEvent), i3._canvasContainer.classList.remove("mapboxgl-track-pointer")), this;
- }
- trackPointer() {
- this._trackPointer = true, this._pos = null, this._update();
- const e2 = this._map;
- 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;
- }
- getElement() {
- return this._container;
- }
- setText(t2) {
- return this.setDOMContent(e.window.document.createTextNode(t2));
- }
- setHTML(t2) {
- const i3 = e.window.document.createDocumentFragment(), o2 = e.window.document.createElement("body");
- let r2;
- for (o2.innerHTML = t2; r2 = o2.firstChild, r2; )
- i3.appendChild(r2);
- return this.setDOMContent(i3);
- }
- getMaxWidth() {
- return this._container && this._container.style.maxWidth;
- }
- setMaxWidth(e2) {
- return this.options.maxWidth = e2, this._update(), this;
- }
- setDOMContent(e2) {
- let t2 = this._content;
- if (t2)
- for (; t2.hasChildNodes(); )
- t2.firstChild && t2.removeChild(t2.firstChild);
- else
- t2 = this._content = n("div", "mapboxgl-popup-content", this._container || void 0);
- if (t2.appendChild(e2), this.options.closeButton) {
- const e3 = this._closeButton = n("button", "mapboxgl-popup-close-button", t2);
- e3.type = "button", e3.setAttribute("aria-label", "Close popup"), e3.setAttribute("aria-hidden", "true"), e3.innerHTML = "×", e3.addEventListener("click", this._onClose);
- }
- return this._update(), this._focusFirstElement(), this;
- }
- addClassName(e2) {
- return this._classList.add(e2), this._updateClassList(), this;
- }
- removeClassName(e2) {
- return this._classList.delete(e2), this._updateClassList(), this;
- }
- setOffset(e2) {
- return this.options.offset = e2, this._update(), this;
- }
- toggleClassName(e2) {
- let t2;
- return this._classList.delete(e2) ? t2 = false : (this._classList.add(e2), t2 = true), this._updateClassList(), t2;
- }
- _onMouseEvent(e2) {
- this._update(e2.point);
- }
- _getAnchor(e2) {
- if (this.options.anchor)
- return this.options.anchor;
- const t2 = this._map, i3 = this._container, o2 = this._pos;
- if (!t2 || !i3 || !o2)
- return "bottom";
- const r2 = i3.offsetWidth, n2 = i3.offsetHeight, a2 = o2.x < r2 / 2, s2 = o2.x > t2.transform.width - r2 / 2;
- if (o2.y + e2 < n2)
- return a2 ? "top-left" : s2 ? "top-right" : "top";
- if (o2.y > t2.transform.height - n2) {
- if (a2)
- return "bottom-left";
- if (s2)
- return "bottom-right";
- }
- return a2 ? "left" : s2 ? "right" : "bottom";
- }
- _updateClassList() {
- const e2 = this._container;
- if (!e2)
- return;
- const t2 = [...this._classList];
- 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(" ");
- }
- _update(e2) {
- const t2 = this._map, i3 = this._content;
- if (!t2 || !this._lngLat && !this._trackPointer || !i3)
- return;
- let o2 = this._container;
- 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) {
- 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();
- t2._requestDomTask(() => {
- this._container && r2 && (this._container.style.transform = `${Zr[r2]} translate(${a2.x}px,${a2.y}px)`);
- });
- }
- this._updateClassList();
- }
- _focusFirstElement() {
- if (!this.options.focusAfterOpen || !this._container)
- return;
- const e2 = this._container.querySelector(an);
- e2 && e2.focus();
- }
- _onClose() {
- this.remove();
- }
- _setOpacity(e2) {
- this._content && (this._content.style.opacity = e2), this._tip && (this._tip.style.opacity = e2);
- }
- }, 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() {
- Ue().acquire(Oe);
- }, clearPrewarmedResources: function() {
- const e2 = Fe;
- 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()"));
- }, get accessToken() {
- return e.config.ACCESS_TOKEN;
- }, set accessToken(t2) {
- e.config.ACCESS_TOKEN = t2;
- }, get baseApiUrl() {
- return e.config.API_URL;
- }, set baseApiUrl(t2) {
- e.config.API_URL = t2;
- }, get workerCount() {
- return Be.workerCount;
- }, set workerCount(e2) {
- Be.workerCount = e2;
- }, get maxParallelImageRequests() {
- return e.config.MAX_PARALLEL_IMAGE_REQUESTS;
- }, set maxParallelImageRequests(t2) {
- e.config.MAX_PARALLEL_IMAGE_REQUESTS = t2;
- }, clearStorage(t2) {
- e.clearTileCache(t2);
- }, workerUrl: "", workerClass: null, setNow: e.exported.setNow, restoreNow: e.exported.restoreNow };
- return ln;
- });
- var mapboxgl$1 = mapboxgl2;
- return mapboxgl$1;
- });
- })(mapboxGl);
- var mapboxGlExports = mapboxGl.exports;
- const mapboxgl = /* @__PURE__ */ getDefaultExportFromCjs(mapboxGlExports);
- const ThirdPartyMaps = {
- /** 加载天地图普通地图 */
- tdtsl() {
- return {
- layers: [
- ["tdtsl", "TianDiTu.Normal.Map"],
- ["tdtslzj", "TianDiTu.Normal.Annotion"]
- ],
- key: "fb258b4c0bbf60ff7a0205b519ad9a96"
- };
- },
- /** 天地图影像 */
- tdtyx() {
- return {
- layers: [
- ["tdtyx", "TianDiTu.Satellite.Map"],
- ["tdtyxzj", "TianDiTu.Satellite.Annotion"]
- ],
- key: "fb258b4c0bbf60ff7a0205b519ad9a96"
- };
- },
- /** 天地图地形 */
- tdtdx() {
- return {
- layers: [
- ["tdtdx", "TianDiTu.Terrain.Map"],
- ["tdtdxzj", "TianDiTu.Terrain.Annotion"]
- ],
- key: "fb258b4c0bbf60ff7a0205b519ad9a96"
- };
- },
- /** 高德矢量 */
- gdsl() {
- return { layers: [["gdsl", "GaoDe.Normal.Map"]] };
- },
- /** 高德矢量,无注记版 */
- gdslwzj() {
- return { layers: [["gdslwzj", "GaoDe.Normal_NoTag.Map"]] };
- },
- /** 高德影像*/
- gdyx() {
- return {
- layers: [
- ["gdyx", "GaoDe.Satellite.Map"],
- ["gdyxzj", "GaoDe.Satellite.Annotion"]
- ]
- };
- },
- /** 百度矢量*/
- bdsl() {
- return { layers: [["bdsl", "Baidu.Normal.Map"]] };
- },
- /** 百度影像*/
- bdyx() {
- return {
- layers: [
- ["bdyx", "Baidu.Satellite.Map"],
- ["bdyxzj", "Baidu.Satellite.Annotion"]
- ]
- };
- },
- /** OSM地图 */
- osm() {
- return { layers: [["osm", "OSM.Normal.Map"]] };
- },
- /** GeoQ普通地图 */
- geoq() {
- return { layers: [["geoq", "Geoq.Normal.Map"]] };
- },
- /** GeoQ深蓝色地图 */
- geoqPurplishBlue() {
- return { layers: [["geoqPurplishBlue", "Geoq.Normal.PurplishBlue"]] };
- },
- /** GeoQ浅色地图 */
- geoqGray() {
- return { layers: [["geoqGray", "Geoq.Normal.Gray"]] };
- },
- /** GeoQ暖色调地图 */
- geoqWarm() {
- return { layers: [["geoqWarm", "Geoq.Normal.Warm"]] };
- },
- /** GeoQ冷色调地图 */
- geoqCold() {
- return { layers: [["geoqCold", "Geoq.Normal.Cold"]] };
- }
- };
- function mxtest_addTtifRaster(map2) {
- const url = "./gis/radar.tiff";
- console.log(url);
- let w = (114.06825863001939 - 104.18084906665138) * 5e-3;
- let h = (32.396413467808586 - 22.54283198132819) * 5e-3;
- let cenx = 114.07867152431874;
- let ceny = 22.563727343812303;
- map2.addSource("radar", {
- "type": "image",
- "url": url,
- //加载的tiff文件路径
- "coordinates": [
- [cenx - w * 0.5, ceny + h * 0.5],
- [cenx + w * 0.5, ceny + h * 0.5],
- [cenx + w * 0.5, ceny - h * 0.5],
- [cenx - w * 0.5, ceny - h * 0.5]
- ]
- //文件展示的经纬度(四个角/顺时针)
- });
- map2.addLayer({
- id: "radar-layer",
- "type": "raster",
- "source": "radar",
- "paint": {
- "raster-fade-duration": 0
- }
- });
- }
- function add_geoserver_wmts_EPSG900913_ttif(map2) {
- 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}";
- map2.addSource("wmts-source", {
- "type": "raster",
- "tiles": [
- vectorLayerUrl
- ],
- "tileSize": 256
- });
- map2.addLayer({
- "id": "wmts-layer",
- "type": "raster",
- "source": "wmts-source",
- "paint": {
- "raster-opacity": 0.95
- }
- });
- }
- let map;
- let mxmap;
- function init_mouse_coord_tip(isLoad_googlecn_map2) {
- map.on("click", function(e) {
- return __async(this, null, function* () {
- let { lng, lat } = e.lngLat;
- if (isLoad_googlecn_map2) {
- let gps84 = mxcad2.mx_gcj02_To_gps84(lng, lat);
- lng = gps84.lng;
- lat = gps84.lat;
- }
- console.log("经纬度坐标:", JSON.stringify([lng, lat]));
- let pt = mapboxgl.MercatorCoordinate.fromLngLat(
- [lng, lat],
- 0
- );
- console.log("墨卡托坐标:", JSON.stringify(mxmap.map_lnglat_to_meters(lng, lat)));
- let ptCAD = mxmap.mercatorCoord2CAD(pt.x, pt.y);
- console.log("CAD坐标:", JSON.stringify(ptCAD));
- });
- });
- }
- let isLoad_googlecn_map = false;
- let isLoad_geoserver_wmts_EPSG900913_ttif = true;
- isLoad_geoserver_wmts_EPSG900913_ttif = false;
- if (isLoad_geoserver_wmts_EPSG900913_ttif)
- isLoad_googlecn_map = false;
- function getMapDefaultData() {
- let map_default_data = new mxcad2.MxCADPluginMapDefaultData();
- map_default_data.cadOrigin = [116275.977014, 19273.279085];
- map_default_data.mapOrigin = [114.06825863001939, 22.54283198132819];
- map_default_data.meterInCADUnits = 1;
- map_default_data.openFile = "./demo/road.dwg.mxweb";
- let mapType = mxdraw.MxFun.getQueryString("maptype");
- if (!isLoad_geoserver_wmts_EPSG900913_ttif) {
- if (mapType == "google") {
- let hx = mxcad2.mx_gps84_To_gcj02(map_default_data.mapOrigin[0], map_default_data.mapOrigin[1]);
- map_default_data.mapOrigin = [hx.lng, hx.lat];
- isLoad_googlecn_map = true;
- map_default_data.viewColor = { red: 0, green: 0, blue: 0 };
- } else {
- let rastermap = ThirdPartyMaps.gdslwzj();
- if (mapType == "gdslwzj") {
- rastermap = ThirdPartyMaps.gdslwzj();
- } else if (mapType == "gdyx") {
- rastermap = ThirdPartyMaps.gdyx();
- } else if (mapType == "tdtsl") {
- rastermap = ThirdPartyMaps.tdtsl();
- } else if (mapType == "bdsl") {
- rastermap = ThirdPartyMaps.bdsl();
- } else if (mapType == "geoq") {
- rastermap = ThirdPartyMaps.geoq();
- }
- map_default_data.rasterTileLayerList = rastermap.layers;
- if (rastermap.key)
- map_default_data.rasterTileKey = rastermap.key;
- }
- }
- return map_default_data;
- }
- function init$1(map_val) {
- mxmap = map_val;
- map = map_val.getMapbox();
- if (isLoad_googlecn_map) {
- mxcad2.MxMapAddGoogleCnLayer(map, ["Image", "Lable"]);
- }
- init_mouse_coord_tip(isLoad_googlecn_map);
- if (isLoad_geoserver_wmts_EPSG900913_ttif) {
- add_geoserver_wmts_EPSG900913_ttif(map);
- } else {
- mxtest_addTtifRaster(map);
- }
- }
- function MxTest_Map_Download() {
- return __async(this, null, function* () {
- let getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.setMessage("\n指定下载范围第一点:");
- let pt1 = yield getPoint.go();
- if (!pt1)
- return;
- getPoint.setMessage("\n指定下载范围第二点:");
- getPoint.setUserDraw((currentPoint, worldDraw) => {
- worldDraw.setColor(16711680);
- let pl = new mxcad2.McDbPolyline();
- pl.addVertexAt(pt1);
- pl.addVertexAt(new mxcad2.McGePoint3d(pt1.x, currentPoint.y));
- pl.addVertexAt(currentPoint);
- pl.addVertexAt(new mxcad2.McGePoint3d(currentPoint.x, pt1.y));
- pl.constantWidth = mxdraw.MxFun.screenCoordLong2Doc(2);
- pl.isClosed = true;
- worldDraw.drawMcDbEntity(pl);
- let points = [];
- points.push(pt1.toVector3());
- points.push(new THREE.Vector3(pt1.x, currentPoint.y));
- points.push(currentPoint.toVector3());
- points.push(new THREE.Vector3(currentPoint.x, pt1.y));
- worldDraw.setColor(12868);
- worldDraw.drawSolid(points, 0.5);
- });
- getPoint.setDisableOsnap(true);
- getPoint.setDisableOrthoTrace(true);
- getPoint.setDynamicInputType(mxdraw.DynamicInputType.kXYCoordInput);
- let pt2 = yield getPoint.go();
- if (!pt2) {
- return;
- }
- let lnglat1 = mxmap.cadTolnglat(pt1.toVector3());
- let lnglat2 = mxmap.cadTolnglat(pt2.toVector3());
- let map_pt1 = mxmap.map_lnglat_to_meters(lnglat1[0], lnglat1[1]);
- let map_pt2 = mxmap.map_lnglat_to_meters(lnglat2[0], lnglat2[1]);
- if (isLoad_googlecn_map) {
- if (!(mxmap.outOfChina(lnglat1[0], lnglat1[1]) && mxmap.outOfChina(lnglat2[0], lnglat2[1]))) {
- let lnglat_gps841 = mxcad2.mx_gcj02_To_gps84(lnglat1[0], lnglat1[1]);
- let lnglat_gps842 = mxcad2.mx_gcj02_To_gps84(lnglat2[0], lnglat2[1]);
- map_pt1 = mxmap.map_lnglat_to_meters(lnglat_gps841.lng, lnglat_gps841.lat);
- map_pt2 = mxmap.map_lnglat_to_meters(lnglat_gps842.lng, lnglat_gps842.lat);
- }
- }
- let map_download_param = {
- url: "https://gac-geo.googlecnapps.cn/maps/vt?lyrs=s&x={x}&y={y}&z={z}",
- polygon: [map_pt1[0], map_pt1[1], map_pt2[0], map_pt2[1]],
- zoom: 18,
- auto_close: false,
- no_repeated_download: true,
- download_dir: "",
- thread_count: 32
- };
- mxdraw.MxFun.acutPrintf("\n 使用教程:https://help.mxdraw.com/?pid=111");
- mxdraw.MxFun.acutPrintf("\n 复制下面的范围,到下载器下载地图,下载范围:");
- let sbound = "\n" + JSON.stringify([map_pt1[0], map_pt1[1], map_pt2[0], map_pt2[1]]);
- mxdraw.MxFun.acutPrintf(sbound);
- mxdraw.MxFun.acutPrintf("\n");
- axios2({
- method: "post",
- url: "http://localhost:1337/users/mxgis/download",
- data: map_download_param
- }).then((ret) => {
- console.log(ret.data);
- alert(JSON.stringify(ret.data));
- }).catch((err) => {
- console.log("网络错误");
- });
- });
- }
- 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) {
- var t = (t = document.getElementsByTagName("script"))[t.length - 1], e = t.getAttribute("data-injectcss"), t = t.getAttribute("data-disable-injectsvg");
- if (!t) {
- var n, i2, l, o, h, d = function(t2, e2) {
- e2.parentNode.insertBefore(t2, e2);
- };
- if (e && !a.__iconfont__svg__cssinject__) {
- a.__iconfont__svg__cssinject__ = true;
- try {
- document.write("<style>.svgfont {display: inline-block;width: 1em;height: 1em;fill: currentColor;vertical-align: -0.1em;font-size:16px;}</style>");
- } catch (t2) {
- console && console.log(t2);
- }
- }
- n = function() {
- var t2, e2 = document.createElement("div");
- 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));
- }, document.addEventListener ? ~["complete", "loaded", "interactive"].indexOf(document.readyState) ? setTimeout(n, 0) : (i2 = function() {
- document.removeEventListener("DOMContentLoaded", i2, false), n();
- }, document.addEventListener("DOMContentLoaded", i2, false)) : document.attachEvent && (l = n, o = a.document, h = false, s(), o.onreadystatechange = function() {
- "complete" == o.readyState && (o.onreadystatechange = null, c());
- });
- }
- function c() {
- h || (h = true, l());
- }
- function s() {
- try {
- o.documentElement.doScroll("left");
- } catch (t2) {
- return void setTimeout(s, 50);
- }
- c();
- }
- }(window);
- var GLTFLoader = function() {
- function GLTFLoader2(manager) {
- Loader.call(this, manager);
- this.dracoLoader = null;
- this.ddsLoader = null;
- }
- GLTFLoader2.prototype = Object.assign(Object.create(Loader.prototype), {
- constructor: GLTFLoader2,
- load: function(url, onLoad, onProgress, onError) {
- var scope = this;
- var resourcePath;
- if (this.resourcePath !== "") {
- resourcePath = this.resourcePath;
- } else if (this.path !== "") {
- resourcePath = this.path;
- } else {
- resourcePath = LoaderUtils.extractUrlBase(url);
- }
- scope.manager.itemStart(url);
- var _onError = function(e) {
- if (onError) {
- onError(e);
- } else {
- console.error(e);
- }
- scope.manager.itemError(url);
- scope.manager.itemEnd(url);
- };
- var loader = new FileLoader(scope.manager);
- loader.setPath(this.path);
- loader.setResponseType("arraybuffer");
- if (scope.crossOrigin === "use-credentials") {
- loader.setWithCredentials(true);
- }
- loader.load(url, function(data) {
- try {
- scope.parse(data, resourcePath, function(gltf) {
- onLoad(gltf);
- scope.manager.itemEnd(url);
- }, _onError);
- } catch (e) {
- _onError(e);
- }
- }, onProgress, _onError);
- },
- setDRACOLoader: function(dracoLoader) {
- this.dracoLoader = dracoLoader;
- return this;
- },
- setDDSLoader: function(ddsLoader) {
- this.ddsLoader = ddsLoader;
- return this;
- },
- parse: function(data, path, onLoad, onError) {
- var content;
- var extensions = {};
- if (typeof data === "string") {
- content = data;
- } else {
- var magic = LoaderUtils.decodeText(new Uint8Array(data, 0, 4));
- if (magic === BINARY_EXTENSION_HEADER_MAGIC) {
- try {
- extensions[EXTENSIONS.KHR_BINARY_GLTF] = new GLTFBinaryExtension(data);
- } catch (error) {
- if (onError)
- onError(error);
- return;
- }
- content = extensions[EXTENSIONS.KHR_BINARY_GLTF].content;
- } else {
- content = LoaderUtils.decodeText(new Uint8Array(data));
- }
- }
- var json = JSON.parse(content);
- if (json.asset === void 0 || json.asset.version[0] < 2) {
- if (onError)
- onError(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
- return;
- }
- if (json.extensionsUsed) {
- for (var i2 = 0; i2 < json.extensionsUsed.length; ++i2) {
- var extensionName = json.extensionsUsed[i2];
- var extensionsRequired = json.extensionsRequired || [];
- switch (extensionName) {
- case EXTENSIONS.KHR_LIGHTS_PUNCTUAL:
- extensions[extensionName] = new GLTFLightsExtension(json);
- break;
- case EXTENSIONS.KHR_MATERIALS_UNLIT:
- extensions[extensionName] = new GLTFMaterialsUnlitExtension();
- break;
- case EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:
- extensions[extensionName] = new GLTFMaterialsPbrSpecularGlossinessExtension();
- break;
- case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:
- extensions[extensionName] = new GLTFDracoMeshCompressionExtension(json, this.dracoLoader);
- break;
- case EXTENSIONS.MSFT_TEXTURE_DDS:
- extensions[extensionName] = new GLTFTextureDDSExtension(this.ddsLoader);
- break;
- case EXTENSIONS.KHR_TEXTURE_TRANSFORM:
- extensions[extensionName] = new GLTFTextureTransformExtension();
- break;
- case EXTENSIONS.KHR_MESH_QUANTIZATION:
- extensions[extensionName] = new GLTFMeshQuantizationExtension();
- break;
- default:
- if (extensionsRequired.indexOf(extensionName) >= 0) {
- console.warn('THREE.GLTFLoader: Unknown extension "' + extensionName + '".');
- }
- }
- }
- }
- var parser = new GLTFParser(json, extensions, {
- path: path || this.resourcePath || "",
- crossOrigin: this.crossOrigin,
- manager: this.manager
- });
- parser.parse(onLoad, onError);
- }
- });
- function GLTFRegistry() {
- var objects = {};
- return {
- get: function(key) {
- return objects[key];
- },
- add: function(key, object) {
- objects[key] = object;
- },
- remove: function(key) {
- delete objects[key];
- },
- removeAll: function() {
- objects = {};
- }
- };
- }
- var EXTENSIONS = {
- KHR_BINARY_GLTF: "KHR_binary_glTF",
- KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
- KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
- KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: "KHR_materials_pbrSpecularGlossiness",
- KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
- KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
- KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
- MSFT_TEXTURE_DDS: "MSFT_texture_dds"
- };
- function GLTFTextureDDSExtension(ddsLoader) {
- if (!ddsLoader) {
- throw new Error("THREE.GLTFLoader: Attempting to load .dds texture without importing DDSLoader");
- }
- this.name = EXTENSIONS.MSFT_TEXTURE_DDS;
- this.ddsLoader = ddsLoader;
- }
- function GLTFLightsExtension(json) {
- this.name = EXTENSIONS.KHR_LIGHTS_PUNCTUAL;
- var extension = json.extensions && json.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL] || {};
- this.lightDefs = extension.lights || [];
- }
- GLTFLightsExtension.prototype.loadLight = function(lightIndex) {
- var lightDef = this.lightDefs[lightIndex];
- var lightNode;
- var color = new Color(16777215);
- if (lightDef.color !== void 0)
- color.fromArray(lightDef.color);
- var range = lightDef.range !== void 0 ? lightDef.range : 0;
- switch (lightDef.type) {
- case "directional":
- lightNode = new DirectionalLight(color);
- lightNode.target.position.set(0, 0, -1);
- lightNode.add(lightNode.target);
- break;
- case "point":
- lightNode = new PointLight(color);
- lightNode.distance = range;
- break;
- case "spot":
- lightNode = new SpotLight(color);
- lightNode.distance = range;
- lightDef.spot = lightDef.spot || {};
- lightDef.spot.innerConeAngle = lightDef.spot.innerConeAngle !== void 0 ? lightDef.spot.innerConeAngle : 0;
- lightDef.spot.outerConeAngle = lightDef.spot.outerConeAngle !== void 0 ? lightDef.spot.outerConeAngle : Math.PI / 4;
- lightNode.angle = lightDef.spot.outerConeAngle;
- lightNode.penumbra = 1 - lightDef.spot.innerConeAngle / lightDef.spot.outerConeAngle;
- lightNode.target.position.set(0, 0, -1);
- lightNode.add(lightNode.target);
- break;
- default:
- throw new Error('THREE.GLTFLoader: Unexpected light type, "' + lightDef.type + '".');
- }
- lightNode.position.set(0, 0, 0);
- lightNode.decay = 2;
- if (lightDef.intensity !== void 0)
- lightNode.intensity = lightDef.intensity;
- lightNode.name = lightDef.name || "light_" + lightIndex;
- return Promise.resolve(lightNode);
- };
- function GLTFMaterialsUnlitExtension() {
- this.name = EXTENSIONS.KHR_MATERIALS_UNLIT;
- }
- GLTFMaterialsUnlitExtension.prototype.getMaterialType = function() {
- return MeshBasicMaterial;
- };
- GLTFMaterialsUnlitExtension.prototype.extendParams = function(materialParams, materialDef, parser) {
- var pending = [];
- materialParams.color = new Color(1, 1, 1);
- materialParams.opacity = 1;
- var metallicRoughness = materialDef.pbrMetallicRoughness;
- if (metallicRoughness) {
- if (Array.isArray(metallicRoughness.baseColorFactor)) {
- var array = metallicRoughness.baseColorFactor;
- materialParams.color.fromArray(array);
- materialParams.opacity = array[3];
- }
- if (metallicRoughness.baseColorTexture !== void 0) {
- pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture));
- }
- }
- return Promise.all(pending);
- };
- var BINARY_EXTENSION_HEADER_MAGIC = "glTF";
- var BINARY_EXTENSION_HEADER_LENGTH = 12;
- var BINARY_EXTENSION_CHUNK_TYPES = { JSON: 1313821514, BIN: 5130562 };
- function GLTFBinaryExtension(data) {
- this.name = EXTENSIONS.KHR_BINARY_GLTF;
- this.content = null;
- this.body = null;
- var headerView = new DataView(data, 0, BINARY_EXTENSION_HEADER_LENGTH);
- this.header = {
- magic: LoaderUtils.decodeText(new Uint8Array(data.slice(0, 4))),
- version: headerView.getUint32(4, true),
- length: headerView.getUint32(8, true)
- };
- if (this.header.magic !== BINARY_EXTENSION_HEADER_MAGIC) {
- throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
- } else if (this.header.version < 2) {
- throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
- }
- var chunkView = new DataView(data, BINARY_EXTENSION_HEADER_LENGTH);
- var chunkIndex = 0;
- while (chunkIndex < chunkView.byteLength) {
- var chunkLength = chunkView.getUint32(chunkIndex, true);
- chunkIndex += 4;
- var chunkType = chunkView.getUint32(chunkIndex, true);
- chunkIndex += 4;
- if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON) {
- var contentArray = new Uint8Array(data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength);
- this.content = LoaderUtils.decodeText(contentArray);
- } else if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN) {
- var byteOffset = BINARY_EXTENSION_HEADER_LENGTH + chunkIndex;
- this.body = data.slice(byteOffset, byteOffset + chunkLength);
- }
- chunkIndex += chunkLength;
- }
- if (this.content === null) {
- throw new Error("THREE.GLTFLoader: JSON content not found.");
- }
- }
- function GLTFDracoMeshCompressionExtension(json, dracoLoader) {
- if (!dracoLoader) {
- throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
- }
- this.name = EXTENSIONS.KHR_DRACO_MESH_COMPRESSION;
- this.json = json;
- this.dracoLoader = dracoLoader;
- this.dracoLoader.preload();
- }
- GLTFDracoMeshCompressionExtension.prototype.decodePrimitive = function(primitive, parser) {
- var json = this.json;
- var dracoLoader = this.dracoLoader;
- var bufferViewIndex = primitive.extensions[this.name].bufferView;
- var gltfAttributeMap = primitive.extensions[this.name].attributes;
- var threeAttributeMap = {};
- var attributeNormalizedMap = {};
- var attributeTypeMap = {};
- for (var attributeName in gltfAttributeMap) {
- var threeAttributeName = ATTRIBUTES[attributeName] || attributeName.toLowerCase();
- threeAttributeMap[threeAttributeName] = gltfAttributeMap[attributeName];
- }
- for (attributeName in primitive.attributes) {
- var threeAttributeName = ATTRIBUTES[attributeName] || attributeName.toLowerCase();
- if (gltfAttributeMap[attributeName] !== void 0) {
- var accessorDef = json.accessors[primitive.attributes[attributeName]];
- var componentType = WEBGL_COMPONENT_TYPES[accessorDef.componentType];
- attributeTypeMap[threeAttributeName] = componentType;
- attributeNormalizedMap[threeAttributeName] = accessorDef.normalized === true;
- }
- }
- return parser.getDependency("bufferView", bufferViewIndex).then(function(bufferView) {
- return new Promise(function(resolve) {
- dracoLoader.decodeDracoFile(bufferView, function(geometry) {
- for (var attributeName2 in geometry.attributes) {
- var attribute = geometry.attributes[attributeName2];
- var normalized = attributeNormalizedMap[attributeName2];
- if (normalized !== void 0)
- attribute.normalized = normalized;
- }
- resolve(geometry);
- }, threeAttributeMap, attributeTypeMap);
- });
- });
- };
- function GLTFTextureTransformExtension() {
- this.name = EXTENSIONS.KHR_TEXTURE_TRANSFORM;
- }
- GLTFTextureTransformExtension.prototype.extendTexture = function(texture, transform) {
- texture = texture.clone();
- if (transform.offset !== void 0) {
- texture.offset.fromArray(transform.offset);
- }
- if (transform.rotation !== void 0) {
- texture.rotation = transform.rotation;
- }
- if (transform.scale !== void 0) {
- texture.repeat.fromArray(transform.scale);
- }
- if (transform.texCoord !== void 0) {
- console.warn('THREE.GLTFLoader: Custom UV sets in "' + this.name + '" extension not yet supported.');
- }
- texture.needsUpdate = true;
- return texture;
- };
- function GLTFMeshStandardSGMaterial(params) {
- MeshStandardMaterial.call(this);
- this.isGLTFSpecularGlossinessMaterial = true;
- var specularMapParsFragmentChunk = [
- "#ifdef USE_SPECULARMAP",
- " uniform sampler2D specularMap;",
- "#endif"
- ].join("\n");
- var glossinessMapParsFragmentChunk = [
- "#ifdef USE_GLOSSINESSMAP",
- " uniform sampler2D glossinessMap;",
- "#endif"
- ].join("\n");
- var specularMapFragmentChunk = [
- "vec3 specularFactor = specular;",
- "#ifdef USE_SPECULARMAP",
- " vec4 texelSpecular = texture2D( specularMap, vUv );",
- " texelSpecular = sRGBToLinear( texelSpecular );",
- " // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture",
- " specularFactor *= texelSpecular.rgb;",
- "#endif"
- ].join("\n");
- var glossinessMapFragmentChunk = [
- "float glossinessFactor = glossiness;",
- "#ifdef USE_GLOSSINESSMAP",
- " vec4 texelGlossiness = texture2D( glossinessMap, vUv );",
- " // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture",
- " glossinessFactor *= texelGlossiness.a;",
- "#endif"
- ].join("\n");
- var lightPhysicalFragmentChunk = [
- "PhysicalMaterial material;",
- "material.diffuseColor = diffuseColor.rgb;",
- "vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );",
- "float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );",
- "material.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.",
- "material.specularRoughness += geometryRoughness;",
- "material.specularRoughness = min( material.specularRoughness, 1.0 );",
- "material.specularColor = specularFactor.rgb;"
- ].join("\n");
- var uniforms = {
- specular: { value: new Color().setHex(16777215) },
- glossiness: { value: 1 },
- specularMap: { value: null },
- glossinessMap: { value: null }
- };
- this._extraUniforms = uniforms;
- this.onBeforeCompile = function(shader) {
- for (var uniformName in uniforms) {
- shader.uniforms[uniformName] = uniforms[uniformName];
- }
- shader.fragmentShader = shader.fragmentShader.replace("uniform float roughness;", "uniform vec3 specular;");
- shader.fragmentShader = shader.fragmentShader.replace("uniform float metalness;", "uniform float glossiness;");
- shader.fragmentShader = shader.fragmentShader.replace("#include <roughnessmap_pars_fragment>", specularMapParsFragmentChunk);
- shader.fragmentShader = shader.fragmentShader.replace("#include <metalnessmap_pars_fragment>", glossinessMapParsFragmentChunk);
- shader.fragmentShader = shader.fragmentShader.replace("#include <roughnessmap_fragment>", specularMapFragmentChunk);
- shader.fragmentShader = shader.fragmentShader.replace("#include <metalnessmap_fragment>", glossinessMapFragmentChunk);
- shader.fragmentShader = shader.fragmentShader.replace("#include <lights_physical_fragment>", lightPhysicalFragmentChunk);
- };
- Object.defineProperties(
- this,
- {
- specular: {
- get: function() {
- return uniforms.specular.value;
- },
- set: function(v) {
- uniforms.specular.value = v;
- }
- },
- specularMap: {
- get: function() {
- return uniforms.specularMap.value;
- },
- set: function(v) {
- uniforms.specularMap.value = v;
- }
- },
- glossiness: {
- get: function() {
- return uniforms.glossiness.value;
- },
- set: function(v) {
- uniforms.glossiness.value = v;
- }
- },
- glossinessMap: {
- get: function() {
- return uniforms.glossinessMap.value;
- },
- set: function(v) {
- uniforms.glossinessMap.value = v;
- if (v) {
- this.defines.USE_GLOSSINESSMAP = "";
- this.defines.USE_ROUGHNESSMAP = "";
- } else {
- delete this.defines.USE_ROUGHNESSMAP;
- delete this.defines.USE_GLOSSINESSMAP;
- }
- }
- }
- }
- );
- delete this.metalness;
- delete this.roughness;
- delete this.metalnessMap;
- delete this.roughnessMap;
- this.setValues(params);
- }
- GLTFMeshStandardSGMaterial.prototype = Object.create(MeshStandardMaterial.prototype);
- GLTFMeshStandardSGMaterial.prototype.constructor = GLTFMeshStandardSGMaterial;
- GLTFMeshStandardSGMaterial.prototype.copy = function(source) {
- MeshStandardMaterial.prototype.copy.call(this, source);
- this.specularMap = source.specularMap;
- this.specular.copy(source.specular);
- this.glossinessMap = source.glossinessMap;
- this.glossiness = source.glossiness;
- delete this.metalness;
- delete this.roughness;
- delete this.metalnessMap;
- delete this.roughnessMap;
- return this;
- };
- function GLTFMaterialsPbrSpecularGlossinessExtension() {
- return {
- name: EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,
- specularGlossinessParams: [
- "color",
- "map",
- "lightMap",
- "lightMapIntensity",
- "aoMap",
- "aoMapIntensity",
- "emissive",
- "emissiveIntensity",
- "emissiveMap",
- "bumpMap",
- "bumpScale",
- "normalMap",
- "normalMapType",
- "displacementMap",
- "displacementScale",
- "displacementBias",
- "specularMap",
- "specular",
- "glossinessMap",
- "glossiness",
- "alphaMap",
- "envMap",
- "envMapIntensity",
- "refractionRatio"
- ],
- getMaterialType: function() {
- return GLTFMeshStandardSGMaterial;
- },
- extendParams: function(materialParams, materialDef, parser) {
- var pbrSpecularGlossiness = materialDef.extensions[this.name];
- materialParams.color = new Color(1, 1, 1);
- materialParams.opacity = 1;
- var pending = [];
- if (Array.isArray(pbrSpecularGlossiness.diffuseFactor)) {
- var array = pbrSpecularGlossiness.diffuseFactor;
- materialParams.color.fromArray(array);
- materialParams.opacity = array[3];
- }
- if (pbrSpecularGlossiness.diffuseTexture !== void 0) {
- pending.push(parser.assignTexture(materialParams, "map", pbrSpecularGlossiness.diffuseTexture));
- }
- materialParams.emissive = new Color(0, 0, 0);
- materialParams.glossiness = pbrSpecularGlossiness.glossinessFactor !== void 0 ? pbrSpecularGlossiness.glossinessFactor : 1;
- materialParams.specular = new Color(1, 1, 1);
- if (Array.isArray(pbrSpecularGlossiness.specularFactor)) {
- materialParams.specular.fromArray(pbrSpecularGlossiness.specularFactor);
- }
- if (pbrSpecularGlossiness.specularGlossinessTexture !== void 0) {
- var specGlossMapDef = pbrSpecularGlossiness.specularGlossinessTexture;
- pending.push(parser.assignTexture(materialParams, "glossinessMap", specGlossMapDef));
- pending.push(parser.assignTexture(materialParams, "specularMap", specGlossMapDef));
- }
- return Promise.all(pending);
- },
- createMaterial: function(materialParams) {
- var material = new GLTFMeshStandardSGMaterial(materialParams);
- material.fog = true;
- material.color = materialParams.color;
- material.map = materialParams.map === void 0 ? null : materialParams.map;
- material.lightMap = null;
- material.lightMapIntensity = 1;
- material.aoMap = materialParams.aoMap === void 0 ? null : materialParams.aoMap;
- material.aoMapIntensity = 1;
- material.emissive = materialParams.emissive;
- material.emissiveIntensity = 1;
- material.emissiveMap = materialParams.emissiveMap === void 0 ? null : materialParams.emissiveMap;
- material.bumpMap = materialParams.bumpMap === void 0 ? null : materialParams.bumpMap;
- material.bumpScale = 1;
- material.normalMap = materialParams.normalMap === void 0 ? null : materialParams.normalMap;
- material.normalMapType = TangentSpaceNormalMap;
- if (materialParams.normalScale)
- material.normalScale = materialParams.normalScale;
- material.displacementMap = null;
- material.displacementScale = 1;
- material.displacementBias = 0;
- material.specularMap = materialParams.specularMap === void 0 ? null : materialParams.specularMap;
- material.specular = materialParams.specular;
- material.glossinessMap = materialParams.glossinessMap === void 0 ? null : materialParams.glossinessMap;
- material.glossiness = materialParams.glossiness;
- material.alphaMap = null;
- material.envMap = materialParams.envMap === void 0 ? null : materialParams.envMap;
- material.envMapIntensity = 1;
- material.refractionRatio = 0.98;
- return material;
- }
- };
- }
- function GLTFMeshQuantizationExtension() {
- this.name = EXTENSIONS.KHR_MESH_QUANTIZATION;
- }
- function GLTFCubicSplineInterpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {
- Interpolant.call(this, parameterPositions, sampleValues, sampleSize, resultBuffer);
- }
- GLTFCubicSplineInterpolant.prototype = Object.create(Interpolant.prototype);
- GLTFCubicSplineInterpolant.prototype.constructor = GLTFCubicSplineInterpolant;
- GLTFCubicSplineInterpolant.prototype.copySampleValue_ = function(index) {
- var result = this.resultBuffer, values = this.sampleValues, valueSize = this.valueSize, offset = index * valueSize * 3 + valueSize;
- for (var i2 = 0; i2 !== valueSize; i2++) {
- result[i2] = values[offset + i2];
- }
- return result;
- };
- GLTFCubicSplineInterpolant.prototype.beforeStart_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_;
- GLTFCubicSplineInterpolant.prototype.afterEnd_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_;
- GLTFCubicSplineInterpolant.prototype.interpolate_ = function(i1, t0, t, t1) {
- var result = this.resultBuffer;
- var values = this.sampleValues;
- var stride = this.valueSize;
- var stride2 = stride * 2;
- var stride3 = stride * 3;
- var td = t1 - t0;
- var p = (t - t0) / td;
- var pp = p * p;
- var ppp = pp * p;
- var offset1 = i1 * stride3;
- var offset0 = offset1 - stride3;
- var s2 = -2 * ppp + 3 * pp;
- var s3 = ppp - pp;
- var s0 = 1 - s2;
- var s1 = s3 - pp + p;
- for (var i2 = 0; i2 !== stride; i2++) {
- var p0 = values[offset0 + i2 + stride];
- var m0 = values[offset0 + i2 + stride2] * td;
- var p1 = values[offset1 + i2 + stride];
- var m1 = values[offset1 + i2] * td;
- result[i2] = s0 * p0 + s1 * m0 + s2 * p1 + s3 * m1;
- }
- return result;
- };
- var WEBGL_CONSTANTS = {
- FLOAT: 5126,
- //FLOAT_MAT2: 35674,
- FLOAT_MAT3: 35675,
- FLOAT_MAT4: 35676,
- FLOAT_VEC2: 35664,
- FLOAT_VEC3: 35665,
- FLOAT_VEC4: 35666,
- LINEAR: 9729,
- REPEAT: 10497,
- SAMPLER_2D: 35678,
- POINTS: 0,
- LINES: 1,
- LINE_LOOP: 2,
- LINE_STRIP: 3,
- TRIANGLES: 4,
- TRIANGLE_STRIP: 5,
- TRIANGLE_FAN: 6,
- UNSIGNED_BYTE: 5121,
- UNSIGNED_SHORT: 5123
- };
- var WEBGL_COMPONENT_TYPES = {
- 5120: Int8Array,
- 5121: Uint8Array,
- 5122: Int16Array,
- 5123: Uint16Array,
- 5125: Uint32Array,
- 5126: Float32Array
- };
- var WEBGL_FILTERS = {
- 9728: NearestFilter,
- 9729: LinearFilter,
- 9984: NearestMipmapNearestFilter,
- 9985: LinearMipmapNearestFilter,
- 9986: NearestMipmapLinearFilter,
- 9987: LinearMipmapLinearFilter
- };
- var WEBGL_WRAPPINGS = {
- 33071: ClampToEdgeWrapping,
- 33648: MirroredRepeatWrapping,
- 10497: RepeatWrapping
- };
- var WEBGL_TYPE_SIZES = {
- "SCALAR": 1,
- "VEC2": 2,
- "VEC3": 3,
- "VEC4": 4,
- "MAT2": 4,
- "MAT3": 9,
- "MAT4": 16
- };
- var ATTRIBUTES = {
- POSITION: "position",
- NORMAL: "normal",
- TANGENT: "tangent",
- TEXCOORD_0: "uv",
- TEXCOORD_1: "uv2",
- COLOR_0: "color",
- WEIGHTS_0: "skinWeight",
- JOINTS_0: "skinIndex"
- };
- var PATH_PROPERTIES = {
- scale: "scale",
- translation: "position",
- rotation: "quaternion",
- weights: "morphTargetInfluences"
- };
- var INTERPOLATION = {
- CUBICSPLINE: void 0,
- // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
- // keyframe track will be initialized with a default interpolation type, then modified.
- LINEAR: InterpolateLinear,
- STEP: InterpolateDiscrete
- };
- var ALPHA_MODES = {
- OPAQUE: "OPAQUE",
- MASK: "MASK",
- BLEND: "BLEND"
- };
- var MIME_TYPE_FORMATS = {
- "image/png": RGBAFormat,
- "image/jpeg": RGBFormat
- };
- function resolveURL(url, path) {
- if (typeof url !== "string" || url === "")
- return "";
- if (/^https?:\/\//i.test(path) && /^\//.test(url)) {
- path = path.replace(/(^https?:\/\/[^\/]+).*/i, "$1");
- }
- if (/^(https?:)?\/\//i.test(url))
- return url;
- if (/^data:.*,.*$/i.test(url))
- return url;
- if (/^blob:.*$/i.test(url))
- return url;
- return path + url;
- }
- function createDefaultMaterial(cache) {
- if (cache["DefaultMaterial"] === void 0) {
- cache["DefaultMaterial"] = new MeshStandardMaterial({
- color: 16777215,
- emissive: 0,
- metalness: 1,
- roughness: 1,
- transparent: false,
- depthTest: true,
- side: FrontSide
- });
- }
- return cache["DefaultMaterial"];
- }
- function addUnknownExtensionsToUserData(knownExtensions, object, objectDef) {
- for (var name in objectDef.extensions) {
- if (knownExtensions[name] === void 0) {
- object.userData.gltfExtensions = object.userData.gltfExtensions || {};
- object.userData.gltfExtensions[name] = objectDef.extensions[name];
- }
- }
- }
- function assignExtrasToUserData(object, gltfDef) {
- if (gltfDef.extras !== void 0) {
- if (typeof gltfDef.extras === "object") {
- Object.assign(object.userData, gltfDef.extras);
- } else {
- console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + gltfDef.extras);
- }
- }
- }
- function addMorphTargets(geometry, targets, parser) {
- var hasMorphPosition = false;
- var hasMorphNormal = false;
- for (var i2 = 0, il = targets.length; i2 < il; i2++) {
- var target = targets[i2];
- if (target.POSITION !== void 0)
- hasMorphPosition = true;
- if (target.NORMAL !== void 0)
- hasMorphNormal = true;
- if (hasMorphPosition && hasMorphNormal)
- break;
- }
- if (!hasMorphPosition && !hasMorphNormal)
- return Promise.resolve(geometry);
- var pendingPositionAccessors = [];
- var pendingNormalAccessors = [];
- for (var i2 = 0, il = targets.length; i2 < il; i2++) {
- var target = targets[i2];
- if (hasMorphPosition) {
- var pendingAccessor = target.POSITION !== void 0 ? parser.getDependency("accessor", target.POSITION) : geometry.attributes.position;
- pendingPositionAccessors.push(pendingAccessor);
- }
- if (hasMorphNormal) {
- var pendingAccessor = target.NORMAL !== void 0 ? parser.getDependency("accessor", target.NORMAL) : geometry.attributes.normal;
- pendingNormalAccessors.push(pendingAccessor);
- }
- }
- return Promise.all([
- Promise.all(pendingPositionAccessors),
- Promise.all(pendingNormalAccessors)
- ]).then(function(accessors) {
- var morphPositions = accessors[0];
- var morphNormals = accessors[1];
- if (hasMorphPosition)
- geometry.morphAttributes.position = morphPositions;
- if (hasMorphNormal)
- geometry.morphAttributes.normal = morphNormals;
- geometry.morphTargetsRelative = true;
- return geometry;
- });
- }
- function updateMorphTargets(mesh, meshDef) {
- mesh.updateMorphTargets();
- if (meshDef.weights !== void 0) {
- for (var i2 = 0, il = meshDef.weights.length; i2 < il; i2++) {
- mesh.morphTargetInfluences[i2] = meshDef.weights[i2];
- }
- }
- if (meshDef.extras && Array.isArray(meshDef.extras.targetNames)) {
- var targetNames = meshDef.extras.targetNames;
- if (mesh.morphTargetInfluences.length === targetNames.length) {
- mesh.morphTargetDictionary = {};
- for (var i2 = 0, il = targetNames.length; i2 < il; i2++) {
- mesh.morphTargetDictionary[targetNames[i2]] = i2;
- }
- } else {
- console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
- }
- }
- }
- function createPrimitiveKey(primitiveDef) {
- var dracoExtension = primitiveDef.extensions && primitiveDef.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION];
- var geometryKey;
- if (dracoExtension) {
- geometryKey = "draco:" + dracoExtension.bufferView + ":" + dracoExtension.indices + ":" + createAttributesKey(dracoExtension.attributes);
- } else {
- geometryKey = primitiveDef.indices + ":" + createAttributesKey(primitiveDef.attributes) + ":" + primitiveDef.mode;
- }
- return geometryKey;
- }
- function createAttributesKey(attributes) {
- var attributesKey = "";
- var keys = Object.keys(attributes).sort();
- for (var i2 = 0, il = keys.length; i2 < il; i2++) {
- attributesKey += keys[i2] + ":" + attributes[keys[i2]] + ";";
- }
- return attributesKey;
- }
- function GLTFParser(json, extensions, options) {
- this.json = json || {};
- this.extensions = extensions || {};
- this.options = options || {};
- this.cache = new GLTFRegistry();
- this.primitiveCache = {};
- this.textureLoader = new TextureLoader(this.options.manager);
- this.textureLoader.setCrossOrigin(this.options.crossOrigin);
- this.fileLoader = new FileLoader(this.options.manager);
- this.fileLoader.setResponseType("arraybuffer");
- if (this.options.crossOrigin === "use-credentials") {
- this.fileLoader.setWithCredentials(true);
- }
- }
- GLTFParser.prototype.parse = function(onLoad, onError) {
- var parser = this;
- var json = this.json;
- var extensions = this.extensions;
- this.cache.removeAll();
- this.markDefs();
- Promise.all([
- this.getDependencies("scene"),
- this.getDependencies("animation"),
- this.getDependencies("camera")
- ]).then(function(dependencies) {
- var result = {
- scene: dependencies[0][json.scene || 0],
- scenes: dependencies[0],
- animations: dependencies[1],
- cameras: dependencies[2],
- asset: json.asset,
- parser,
- userData: {}
- };
- addUnknownExtensionsToUserData(extensions, result, json);
- assignExtrasToUserData(result, json);
- onLoad(result);
- }).catch(onError);
- };
- GLTFParser.prototype.markDefs = function() {
- var nodeDefs = this.json.nodes || [];
- var skinDefs = this.json.skins || [];
- var meshDefs = this.json.meshes || [];
- var meshReferences = {};
- var meshUses = {};
- for (var skinIndex = 0, skinLength = skinDefs.length; skinIndex < skinLength; skinIndex++) {
- var joints = skinDefs[skinIndex].joints;
- for (var i2 = 0, il = joints.length; i2 < il; i2++) {
- nodeDefs[joints[i2]].isBone = true;
- }
- }
- for (var nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex++) {
- var nodeDef = nodeDefs[nodeIndex];
- if (nodeDef.mesh !== void 0) {
- if (meshReferences[nodeDef.mesh] === void 0) {
- meshReferences[nodeDef.mesh] = meshUses[nodeDef.mesh] = 0;
- }
- meshReferences[nodeDef.mesh]++;
- if (nodeDef.skin !== void 0) {
- meshDefs[nodeDef.mesh].isSkinnedMesh = true;
- }
- }
- }
- this.json.meshReferences = meshReferences;
- this.json.meshUses = meshUses;
- };
- GLTFParser.prototype.getDependency = function(type, index) {
- var cacheKey = type + ":" + index;
- var dependency = this.cache.get(cacheKey);
- if (!dependency) {
- switch (type) {
- case "scene":
- dependency = this.loadScene(index);
- break;
- case "node":
- dependency = this.loadNode(index);
- break;
- case "mesh":
- dependency = this.loadMesh(index);
- break;
- case "accessor":
- dependency = this.loadAccessor(index);
- break;
- case "bufferView":
- dependency = this.loadBufferView(index);
- break;
- case "buffer":
- dependency = this.loadBuffer(index);
- break;
- case "material":
- dependency = this.loadMaterial(index);
- break;
- case "texture":
- dependency = this.loadTexture(index);
- break;
- case "skin":
- dependency = this.loadSkin(index);
- break;
- case "animation":
- dependency = this.loadAnimation(index);
- break;
- case "camera":
- dependency = this.loadCamera(index);
- break;
- case "light":
- dependency = this.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL].loadLight(index);
- break;
- default:
- throw new Error("Unknown type: " + type);
- }
- this.cache.add(cacheKey, dependency);
- }
- return dependency;
- };
- GLTFParser.prototype.getDependencies = function(type) {
- var dependencies = this.cache.get(type);
- if (!dependencies) {
- var parser = this;
- var defs = this.json[type + (type === "mesh" ? "es" : "s")] || [];
- dependencies = Promise.all(defs.map(function(def, index) {
- return parser.getDependency(type, index);
- }));
- this.cache.add(type, dependencies);
- }
- return dependencies;
- };
- GLTFParser.prototype.loadBuffer = function(bufferIndex) {
- var bufferDef = this.json.buffers[bufferIndex];
- var loader = this.fileLoader;
- if (bufferDef.type && bufferDef.type !== "arraybuffer") {
- throw new Error("THREE.GLTFLoader: " + bufferDef.type + " buffer type is not supported.");
- }
- if (bufferDef.uri === void 0 && bufferIndex === 0) {
- return Promise.resolve(this.extensions[EXTENSIONS.KHR_BINARY_GLTF].body);
- }
- var options = this.options;
- return new Promise(function(resolve, reject) {
- loader.load(resolveURL(bufferDef.uri, options.path), resolve, void 0, function() {
- reject(new Error('THREE.GLTFLoader: Failed to load buffer "' + bufferDef.uri + '".'));
- });
- });
- };
- GLTFParser.prototype.loadBufferView = function(bufferViewIndex) {
- var bufferViewDef = this.json.bufferViews[bufferViewIndex];
- return this.getDependency("buffer", bufferViewDef.buffer).then(function(buffer) {
- var byteLength = bufferViewDef.byteLength || 0;
- var byteOffset = bufferViewDef.byteOffset || 0;
- return buffer.slice(byteOffset, byteOffset + byteLength);
- });
- };
- GLTFParser.prototype.loadAccessor = function(accessorIndex) {
- var parser = this;
- var json = this.json;
- var accessorDef = this.json.accessors[accessorIndex];
- if (accessorDef.bufferView === void 0 && accessorDef.sparse === void 0) {
- return Promise.resolve(null);
- }
- var pendingBufferViews = [];
- if (accessorDef.bufferView !== void 0) {
- pendingBufferViews.push(this.getDependency("bufferView", accessorDef.bufferView));
- } else {
- pendingBufferViews.push(null);
- }
- if (accessorDef.sparse !== void 0) {
- pendingBufferViews.push(this.getDependency("bufferView", accessorDef.sparse.indices.bufferView));
- pendingBufferViews.push(this.getDependency("bufferView", accessorDef.sparse.values.bufferView));
- }
- return Promise.all(pendingBufferViews).then(function(bufferViews) {
- var bufferView = bufferViews[0];
- var itemSize = WEBGL_TYPE_SIZES[accessorDef.type];
- var TypedArray = WEBGL_COMPONENT_TYPES[accessorDef.componentType];
- var elementBytes = TypedArray.BYTES_PER_ELEMENT;
- var itemBytes = elementBytes * itemSize;
- var byteOffset = accessorDef.byteOffset || 0;
- var byteStride = accessorDef.bufferView !== void 0 ? json.bufferViews[accessorDef.bufferView].byteStride : void 0;
- var normalized = accessorDef.normalized === true;
- var array, bufferAttribute;
- if (byteStride && byteStride !== itemBytes) {
- var ibSlice = Math.floor(byteOffset / byteStride);
- var ibCacheKey = "InterleavedBuffer:" + accessorDef.bufferView + ":" + accessorDef.componentType + ":" + ibSlice + ":" + accessorDef.count;
- var ib = parser.cache.get(ibCacheKey);
- if (!ib) {
- array = new TypedArray(bufferView, ibSlice * byteStride, accessorDef.count * byteStride / elementBytes);
- ib = new InterleavedBuffer(array, byteStride / elementBytes);
- parser.cache.add(ibCacheKey, ib);
- }
- bufferAttribute = new InterleavedBufferAttribute(ib, itemSize, byteOffset % byteStride / elementBytes, normalized);
- } else {
- if (bufferView === null) {
- array = new TypedArray(accessorDef.count * itemSize);
- } else {
- array = new TypedArray(bufferView, byteOffset, accessorDef.count * itemSize);
- }
- bufferAttribute = new BufferAttribute(array, itemSize, normalized);
- }
- if (accessorDef.sparse !== void 0) {
- var itemSizeIndices = WEBGL_TYPE_SIZES.SCALAR;
- var TypedArrayIndices = WEBGL_COMPONENT_TYPES[accessorDef.sparse.indices.componentType];
- var byteOffsetIndices = accessorDef.sparse.indices.byteOffset || 0;
- var byteOffsetValues = accessorDef.sparse.values.byteOffset || 0;
- var sparseIndices = new TypedArrayIndices(bufferViews[1], byteOffsetIndices, accessorDef.sparse.count * itemSizeIndices);
- var sparseValues = new TypedArray(bufferViews[2], byteOffsetValues, accessorDef.sparse.count * itemSize);
- if (bufferView !== null) {
- bufferAttribute = new BufferAttribute(bufferAttribute.array.slice(), bufferAttribute.itemSize, bufferAttribute.normalized);
- }
- for (var i2 = 0, il = sparseIndices.length; i2 < il; i2++) {
- var index = sparseIndices[i2];
- bufferAttribute.setX(index, sparseValues[i2 * itemSize]);
- if (itemSize >= 2)
- bufferAttribute.setY(index, sparseValues[i2 * itemSize + 1]);
- if (itemSize >= 3)
- bufferAttribute.setZ(index, sparseValues[i2 * itemSize + 2]);
- if (itemSize >= 4)
- bufferAttribute.setW(index, sparseValues[i2 * itemSize + 3]);
- if (itemSize >= 5)
- throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
- }
- }
- return bufferAttribute;
- });
- };
- GLTFParser.prototype.loadTexture = function(textureIndex) {
- var parser = this;
- var json = this.json;
- var options = this.options;
- var textureLoader = this.textureLoader;
- var URL2 = window.URL || window.webkitURL;
- var textureDef = json.textures[textureIndex];
- var textureExtensions = textureDef.extensions || {};
- var source;
- if (textureExtensions[EXTENSIONS.MSFT_TEXTURE_DDS]) {
- source = json.images[textureExtensions[EXTENSIONS.MSFT_TEXTURE_DDS].source];
- } else {
- source = json.images[textureDef.source];
- }
- var sourceURI = source.uri;
- var isObjectURL = false;
- if (source.bufferView !== void 0) {
- sourceURI = parser.getDependency("bufferView", source.bufferView).then(function(bufferView) {
- isObjectURL = true;
- var blob = new Blob([bufferView], { type: source.mimeType });
- sourceURI = URL2.createObjectURL(blob);
- return sourceURI;
- });
- }
- return Promise.resolve(sourceURI).then(function(sourceURI2) {
- var loader = options.manager.getHandler(sourceURI2);
- if (!loader) {
- loader = textureExtensions[EXTENSIONS.MSFT_TEXTURE_DDS] ? parser.extensions[EXTENSIONS.MSFT_TEXTURE_DDS].ddsLoader : textureLoader;
- }
- return new Promise(function(resolve, reject) {
- loader.load(resolveURL(sourceURI2, options.path), resolve, void 0, reject);
- });
- }).then(function(texture) {
- if (isObjectURL === true) {
- URL2.revokeObjectURL(sourceURI);
- }
- texture.flipY = false;
- if (textureDef.name !== void 0)
- texture.name = textureDef.name;
- if (source.mimeType in MIME_TYPE_FORMATS) {
- texture.format = MIME_TYPE_FORMATS[source.mimeType];
- }
- var samplers = json.samplers || {};
- var sampler = samplers[textureDef.sampler] || {};
- texture.magFilter = WEBGL_FILTERS[sampler.magFilter] || LinearFilter;
- texture.minFilter = WEBGL_FILTERS[sampler.minFilter] || LinearMipmapLinearFilter;
- texture.wrapS = WEBGL_WRAPPINGS[sampler.wrapS] || RepeatWrapping;
- texture.wrapT = WEBGL_WRAPPINGS[sampler.wrapT] || RepeatWrapping;
- return texture;
- });
- };
- GLTFParser.prototype.assignTexture = function(materialParams, mapName, mapDef) {
- var parser = this;
- return this.getDependency("texture", mapDef.index).then(function(texture) {
- if (!texture.isCompressedTexture) {
- switch (mapName) {
- case "aoMap":
- case "emissiveMap":
- case "metalnessMap":
- case "normalMap":
- case "roughnessMap":
- texture.format = RGBFormat;
- break;
- }
- }
- if (mapDef.texCoord !== void 0 && mapDef.texCoord != 0 && !(mapName === "aoMap" && mapDef.texCoord == 1)) {
- console.warn("THREE.GLTFLoader: Custom UV set " + mapDef.texCoord + " for texture " + mapName + " not yet supported.");
- }
- if (parser.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]) {
- var transform = mapDef.extensions !== void 0 ? mapDef.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM] : void 0;
- if (transform) {
- texture = parser.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM].extendTexture(texture, transform);
- }
- }
- materialParams[mapName] = texture;
- });
- };
- GLTFParser.prototype.assignFinalMaterial = function(mesh) {
- var geometry = mesh.geometry;
- var material = mesh.material;
- this.extensions;
- var useVertexTangents = geometry.attributes.tangent !== void 0;
- var useVertexColors = geometry.attributes.color !== void 0;
- var useFlatShading = geometry.attributes.normal === void 0;
- var useSkinning = mesh.isSkinnedMesh === true;
- var useMorphTargets = Object.keys(geometry.morphAttributes).length > 0;
- var useMorphNormals = useMorphTargets && geometry.morphAttributes.normal !== void 0;
- if (mesh.isPoints) {
- var cacheKey = "PointsMaterial:" + material.uuid;
- var pointsMaterial = this.cache.get(cacheKey);
- if (!pointsMaterial) {
- pointsMaterial = new PointsMaterial();
- Material.prototype.copy.call(pointsMaterial, material);
- pointsMaterial.color.copy(material.color);
- pointsMaterial.map = material.map;
- pointsMaterial.sizeAttenuation = false;
- this.cache.add(cacheKey, pointsMaterial);
- }
- material = pointsMaterial;
- } else if (mesh.isLine) {
- var cacheKey = "LineBasicMaterial:" + material.uuid;
- var lineMaterial = this.cache.get(cacheKey);
- if (!lineMaterial) {
- lineMaterial = new LineBasicMaterial();
- Material.prototype.copy.call(lineMaterial, material);
- lineMaterial.color.copy(material.color);
- this.cache.add(cacheKey, lineMaterial);
- }
- material = lineMaterial;
- }
- if (useVertexTangents || useVertexColors || useFlatShading || useSkinning || useMorphTargets) {
- var cacheKey = "ClonedMaterial:" + material.uuid + ":";
- if (material.isGLTFSpecularGlossinessMaterial)
- cacheKey += "specular-glossiness:";
- if (useSkinning)
- cacheKey += "skinning:";
- if (useVertexTangents)
- cacheKey += "vertex-tangents:";
- if (useVertexColors)
- cacheKey += "vertex-colors:";
- if (useFlatShading)
- cacheKey += "flat-shading:";
- if (useMorphTargets)
- cacheKey += "morph-targets:";
- if (useMorphNormals)
- cacheKey += "morph-normals:";
- var cachedMaterial = this.cache.get(cacheKey);
- if (!cachedMaterial) {
- cachedMaterial = material.clone();
- if (useSkinning)
- cachedMaterial.skinning = true;
- if (useVertexTangents)
- cachedMaterial.vertexTangents = true;
- if (useVertexColors)
- cachedMaterial.vertexColors = VertexColors;
- if (useFlatShading)
- cachedMaterial.flatShading = true;
- if (useMorphTargets)
- cachedMaterial.morphTargets = true;
- if (useMorphNormals)
- cachedMaterial.morphNormals = true;
- this.cache.add(cacheKey, cachedMaterial);
- }
- material = cachedMaterial;
- }
- if (material.aoMap && geometry.attributes.uv2 === void 0 && geometry.attributes.uv !== void 0) {
- geometry.setAttribute("uv2", new BufferAttribute(geometry.attributes.uv.array, 2));
- }
- if (material.normalScale && !useVertexTangents) {
- material.normalScale.y = -material.normalScale.y;
- }
- mesh.material = material;
- };
- GLTFParser.prototype.loadMaterial = function(materialIndex) {
- var parser = this;
- var json = this.json;
- var extensions = this.extensions;
- var materialDef = json.materials[materialIndex];
- var materialType;
- var materialParams = {};
- var materialExtensions = materialDef.extensions || {};
- var pending = [];
- if (materialExtensions[EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]) {
- var sgExtension = extensions[EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];
- materialType = sgExtension.getMaterialType();
- pending.push(sgExtension.extendParams(materialParams, materialDef, parser));
- } else if (materialExtensions[EXTENSIONS.KHR_MATERIALS_UNLIT]) {
- var kmuExtension = extensions[EXTENSIONS.KHR_MATERIALS_UNLIT];
- materialType = kmuExtension.getMaterialType();
- pending.push(kmuExtension.extendParams(materialParams, materialDef, parser));
- } else {
- materialType = MeshStandardMaterial;
- var metallicRoughness = materialDef.pbrMetallicRoughness || {};
- materialParams.color = new Color(1, 1, 1);
- materialParams.opacity = 1;
- if (Array.isArray(metallicRoughness.baseColorFactor)) {
- var array = metallicRoughness.baseColorFactor;
- materialParams.color.fromArray(array);
- materialParams.opacity = array[3];
- }
- if (metallicRoughness.baseColorTexture !== void 0) {
- pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture));
- }
- materialParams.metalness = metallicRoughness.metallicFactor !== void 0 ? metallicRoughness.metallicFactor : 1;
- materialParams.roughness = metallicRoughness.roughnessFactor !== void 0 ? metallicRoughness.roughnessFactor : 1;
- if (metallicRoughness.metallicRoughnessTexture !== void 0) {
- pending.push(parser.assignTexture(materialParams, "metalnessMap", metallicRoughness.metallicRoughnessTexture));
- pending.push(parser.assignTexture(materialParams, "roughnessMap", metallicRoughness.metallicRoughnessTexture));
- }
- }
- if (materialDef.doubleSided === true) {
- materialParams.side = DoubleSide;
- }
- var alphaMode = materialDef.alphaMode || ALPHA_MODES.OPAQUE;
- if (alphaMode === ALPHA_MODES.BLEND) {
- materialParams.transparent = true;
- } else {
- materialParams.transparent = false;
- if (alphaMode === ALPHA_MODES.MASK) {
- materialParams.alphaTest = materialDef.alphaCutoff !== void 0 ? materialDef.alphaCutoff : 0.5;
- }
- }
- if (materialDef.normalTexture !== void 0 && materialType !== MeshBasicMaterial) {
- pending.push(parser.assignTexture(materialParams, "normalMap", materialDef.normalTexture));
- materialParams.normalScale = new Vector2(1, 1);
- if (materialDef.normalTexture.scale !== void 0) {
- materialParams.normalScale.set(materialDef.normalTexture.scale, materialDef.normalTexture.scale);
- }
- }
- if (materialDef.occlusionTexture !== void 0 && materialType !== MeshBasicMaterial) {
- pending.push(parser.assignTexture(materialParams, "aoMap", materialDef.occlusionTexture));
- if (materialDef.occlusionTexture.strength !== void 0) {
- materialParams.aoMapIntensity = materialDef.occlusionTexture.strength;
- }
- }
- if (materialDef.emissiveFactor !== void 0 && materialType !== MeshBasicMaterial) {
- materialParams.emissive = new Color().fromArray(materialDef.emissiveFactor);
- }
- if (materialDef.emissiveTexture !== void 0 && materialType !== MeshBasicMaterial) {
- pending.push(parser.assignTexture(materialParams, "emissiveMap", materialDef.emissiveTexture));
- }
- return Promise.all(pending).then(function() {
- var material;
- if (materialType === GLTFMeshStandardSGMaterial) {
- material = extensions[EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(materialParams);
- } else {
- material = new materialType(materialParams);
- }
- if (materialDef.name !== void 0)
- material.name = materialDef.name;
- if (material.map)
- material.map.encoding = sRGBEncoding;
- if (material.emissiveMap)
- material.emissiveMap.encoding = sRGBEncoding;
- assignExtrasToUserData(material, materialDef);
- if (materialDef.extensions)
- addUnknownExtensionsToUserData(extensions, material, materialDef);
- return material;
- });
- };
- function computeBounds(geometry, primitiveDef, parser) {
- var attributes = primitiveDef.attributes;
- var box = new Box3();
- if (attributes.POSITION !== void 0) {
- var accessor = parser.json.accessors[attributes.POSITION];
- var min = accessor.min;
- var max = accessor.max;
- if (min !== void 0 && max !== void 0) {
- box.set(
- new Vector3(min[0], min[1], min[2]),
- new Vector3(max[0], max[1], max[2])
- );
- } else {
- console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
- return;
- }
- } else {
- return;
- }
- var targets = primitiveDef.targets;
- if (targets !== void 0) {
- var vector = new Vector3();
- for (var i2 = 0, il = targets.length; i2 < il; i2++) {
- var target = targets[i2];
- if (target.POSITION !== void 0) {
- var accessor = parser.json.accessors[target.POSITION];
- var min = accessor.min;
- var max = accessor.max;
- if (min !== void 0 && max !== void 0) {
- vector.setX(Math.max(Math.abs(min[0]), Math.abs(max[0])));
- vector.setY(Math.max(Math.abs(min[1]), Math.abs(max[1])));
- vector.setZ(Math.max(Math.abs(min[2]), Math.abs(max[2])));
- box.expandByVector(vector);
- } else {
- console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
- }
- }
- }
- }
- geometry.boundingBox = box;
- var sphere = new Sphere();
- box.getCenter(sphere.center);
- sphere.radius = box.min.distanceTo(box.max) / 2;
- geometry.boundingSphere = sphere;
- }
- function addPrimitiveAttributes(geometry, primitiveDef, parser) {
- var attributes = primitiveDef.attributes;
- var pending = [];
- function assignAttributeAccessor(accessorIndex, attributeName) {
- return parser.getDependency("accessor", accessorIndex).then(function(accessor2) {
- geometry.setAttribute(attributeName, accessor2);
- });
- }
- for (var gltfAttributeName in attributes) {
- var threeAttributeName = ATTRIBUTES[gltfAttributeName] || gltfAttributeName.toLowerCase();
- if (threeAttributeName in geometry.attributes)
- continue;
- pending.push(assignAttributeAccessor(attributes[gltfAttributeName], threeAttributeName));
- }
- if (primitiveDef.indices !== void 0 && !geometry.index) {
- var accessor = parser.getDependency("accessor", primitiveDef.indices).then(function(accessor2) {
- geometry.setIndex(accessor2);
- });
- pending.push(accessor);
- }
- assignExtrasToUserData(geometry, primitiveDef);
- computeBounds(geometry, primitiveDef, parser);
- return Promise.all(pending).then(function() {
- return primitiveDef.targets !== void 0 ? addMorphTargets(geometry, primitiveDef.targets, parser) : geometry;
- });
- }
- function toTrianglesDrawMode(geometry, drawMode) {
- var index = geometry.getIndex();
- if (index === null) {
- var indices = [];
- var position = geometry.getAttribute("position");
- if (position !== void 0) {
- for (var i2 = 0; i2 < position.count; i2++) {
- indices.push(i2);
- }
- geometry.setIndex(indices);
- index = geometry.getIndex();
- } else {
- console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.");
- return geometry;
- }
- }
- var numberOfTriangles = index.count - 2;
- var newIndices = [];
- if (drawMode === TriangleFanDrawMode) {
- for (var i2 = 1; i2 <= numberOfTriangles; i2++) {
- newIndices.push(index.getX(0));
- newIndices.push(index.getX(i2));
- newIndices.push(index.getX(i2 + 1));
- }
- } else {
- for (var i2 = 0; i2 < numberOfTriangles; i2++) {
- if (i2 % 2 === 0) {
- newIndices.push(index.getX(i2));
- newIndices.push(index.getX(i2 + 1));
- newIndices.push(index.getX(i2 + 2));
- } else {
- newIndices.push(index.getX(i2 + 2));
- newIndices.push(index.getX(i2 + 1));
- newIndices.push(index.getX(i2));
- }
- }
- }
- if (newIndices.length / 3 !== numberOfTriangles) {
- console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
- }
- var newGeometry = geometry.clone();
- newGeometry.setIndex(newIndices);
- return newGeometry;
- }
- GLTFParser.prototype.loadGeometries = function(primitives) {
- var parser = this;
- var extensions = this.extensions;
- var cache = this.primitiveCache;
- function createDracoPrimitive(primitive2) {
- return extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(primitive2, parser).then(function(geometry) {
- return addPrimitiveAttributes(geometry, primitive2, parser);
- });
- }
- var pending = [];
- for (var i2 = 0, il = primitives.length; i2 < il; i2++) {
- var primitive = primitives[i2];
- var cacheKey = createPrimitiveKey(primitive);
- var cached = cache[cacheKey];
- if (cached) {
- pending.push(cached.promise);
- } else {
- var geometryPromise;
- if (primitive.extensions && primitive.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]) {
- geometryPromise = createDracoPrimitive(primitive);
- } else {
- geometryPromise = addPrimitiveAttributes(new BufferGeometry(), primitive, parser);
- }
- cache[cacheKey] = { primitive, promise: geometryPromise };
- pending.push(geometryPromise);
- }
- }
- return Promise.all(pending);
- };
- GLTFParser.prototype.loadMesh = function(meshIndex) {
- var parser = this;
- var json = this.json;
- var meshDef = json.meshes[meshIndex];
- var primitives = meshDef.primitives;
- var pending = [];
- for (var i2 = 0, il = primitives.length; i2 < il; i2++) {
- var material = primitives[i2].material === void 0 ? createDefaultMaterial(this.cache) : this.getDependency("material", primitives[i2].material);
- pending.push(material);
- }
- pending.push(parser.loadGeometries(primitives));
- return Promise.all(pending).then(function(results) {
- var materials = results.slice(0, results.length - 1);
- var geometries = results[results.length - 1];
- var meshes = [];
- for (var i3 = 0, il2 = geometries.length; i3 < il2; i3++) {
- var geometry = geometries[i3];
- var primitive = primitives[i3];
- var mesh;
- var material2 = materials[i3];
- if (primitive.mode === WEBGL_CONSTANTS.TRIANGLES || primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP || primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN || primitive.mode === void 0) {
- mesh = meshDef.isSkinnedMesh === true ? new SkinnedMesh(geometry, material2) : new Mesh(geometry, material2);
- if (mesh.isSkinnedMesh === true && !mesh.geometry.attributes.skinWeight.normalized) {
- mesh.normalizeSkinWeights();
- }
- if (primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP) {
- mesh.geometry = toTrianglesDrawMode(mesh.geometry, TriangleStripDrawMode);
- } else if (primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN) {
- mesh.geometry = toTrianglesDrawMode(mesh.geometry, TriangleFanDrawMode);
- }
- } else if (primitive.mode === WEBGL_CONSTANTS.LINES) {
- mesh = new LineSegments(geometry, material2);
- } else if (primitive.mode === WEBGL_CONSTANTS.LINE_STRIP) {
- mesh = new Line(geometry, material2);
- } else if (primitive.mode === WEBGL_CONSTANTS.LINE_LOOP) {
- mesh = new LineLoop(geometry, material2);
- } else if (primitive.mode === WEBGL_CONSTANTS.POINTS) {
- mesh = new Points(geometry, material2);
- } else {
- throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + primitive.mode);
- }
- if (Object.keys(mesh.geometry.morphAttributes).length > 0) {
- updateMorphTargets(mesh, meshDef);
- }
- mesh.name = meshDef.name || "mesh_" + meshIndex;
- if (geometries.length > 1)
- mesh.name += "_" + i3;
- assignExtrasToUserData(mesh, meshDef);
- parser.assignFinalMaterial(mesh);
- meshes.push(mesh);
- }
- if (meshes.length === 1) {
- return meshes[0];
- }
- var group = new Group();
- for (var i3 = 0, il2 = meshes.length; i3 < il2; i3++) {
- group.add(meshes[i3]);
- }
- return group;
- });
- };
- GLTFParser.prototype.loadCamera = function(cameraIndex) {
- var camera;
- var cameraDef = this.json.cameras[cameraIndex];
- var params = cameraDef[cameraDef.type];
- if (!params) {
- console.warn("THREE.GLTFLoader: Missing camera parameters.");
- return;
- }
- if (cameraDef.type === "perspective") {
- camera = new PerspectiveCamera(MathUtils.radToDeg(params.yfov), params.aspectRatio || 1, params.znear || 1, params.zfar || 2e6);
- } else if (cameraDef.type === "orthographic") {
- camera = new OrthographicCamera(params.xmag / -2, params.xmag / 2, params.ymag / 2, params.ymag / -2, params.znear, params.zfar);
- }
- if (cameraDef.name !== void 0)
- camera.name = cameraDef.name;
- assignExtrasToUserData(camera, cameraDef);
- return Promise.resolve(camera);
- };
- GLTFParser.prototype.loadSkin = function(skinIndex) {
- var skinDef = this.json.skins[skinIndex];
- var skinEntry = { joints: skinDef.joints };
- if (skinDef.inverseBindMatrices === void 0) {
- return Promise.resolve(skinEntry);
- }
- return this.getDependency("accessor", skinDef.inverseBindMatrices).then(function(accessor) {
- skinEntry.inverseBindMatrices = accessor;
- return skinEntry;
- });
- };
- GLTFParser.prototype.loadAnimation = function(animationIndex) {
- var json = this.json;
- var animationDef = json.animations[animationIndex];
- var pendingNodes = [];
- var pendingInputAccessors = [];
- var pendingOutputAccessors = [];
- var pendingSamplers = [];
- var pendingTargets = [];
- for (var i2 = 0, il = animationDef.channels.length; i2 < il; i2++) {
- var channel = animationDef.channels[i2];
- var sampler = animationDef.samplers[channel.sampler];
- var target = channel.target;
- var name = target.node !== void 0 ? target.node : target.id;
- var input = animationDef.parameters !== void 0 ? animationDef.parameters[sampler.input] : sampler.input;
- var output = animationDef.parameters !== void 0 ? animationDef.parameters[sampler.output] : sampler.output;
- pendingNodes.push(this.getDependency("node", name));
- pendingInputAccessors.push(this.getDependency("accessor", input));
- pendingOutputAccessors.push(this.getDependency("accessor", output));
- pendingSamplers.push(sampler);
- pendingTargets.push(target);
- }
- return Promise.all([
- Promise.all(pendingNodes),
- Promise.all(pendingInputAccessors),
- Promise.all(pendingOutputAccessors),
- Promise.all(pendingSamplers),
- Promise.all(pendingTargets)
- ]).then(function(dependencies) {
- var nodes = dependencies[0];
- var inputAccessors = dependencies[1];
- var outputAccessors = dependencies[2];
- var samplers = dependencies[3];
- var targets = dependencies[4];
- var tracks = [];
- for (var i3 = 0, il2 = nodes.length; i3 < il2; i3++) {
- var node = nodes[i3];
- var inputAccessor = inputAccessors[i3];
- var outputAccessor = outputAccessors[i3];
- var sampler2 = samplers[i3];
- var target2 = targets[i3];
- if (node === void 0)
- continue;
- node.updateMatrix();
- node.matrixAutoUpdate = true;
- var TypedKeyframeTrack;
- switch (PATH_PROPERTIES[target2.path]) {
- case PATH_PROPERTIES.weights:
- TypedKeyframeTrack = NumberKeyframeTrack;
- break;
- case PATH_PROPERTIES.rotation:
- TypedKeyframeTrack = QuaternionKeyframeTrack;
- break;
- case PATH_PROPERTIES.position:
- case PATH_PROPERTIES.scale:
- default:
- TypedKeyframeTrack = VectorKeyframeTrack;
- break;
- }
- var targetName = node.name ? node.name : node.uuid;
- var interpolation = sampler2.interpolation !== void 0 ? INTERPOLATION[sampler2.interpolation] : InterpolateLinear;
- var targetNames = [];
- if (PATH_PROPERTIES[target2.path] === PATH_PROPERTIES.weights) {
- node.traverse(function(object) {
- if (object.isMesh === true && object.morphTargetInfluences) {
- targetNames.push(object.name ? object.name : object.uuid);
- }
- });
- } else {
- targetNames.push(targetName);
- }
- var outputArray = outputAccessor.array;
- if (outputAccessor.normalized) {
- var scale;
- if (outputArray.constructor === Int8Array) {
- scale = 1 / 127;
- } else if (outputArray.constructor === Uint8Array) {
- scale = 1 / 255;
- } else if (outputArray.constructor == Int16Array) {
- scale = 1 / 32767;
- } else if (outputArray.constructor === Uint16Array) {
- scale = 1 / 65535;
- } else {
- throw new Error("THREE.GLTFLoader: Unsupported output accessor component type.");
- }
- var scaled = new Float32Array(outputArray.length);
- for (var j = 0, jl = outputArray.length; j < jl; j++) {
- scaled[j] = outputArray[j] * scale;
- }
- outputArray = scaled;
- }
- for (var j = 0, jl = targetNames.length; j < jl; j++) {
- var track = new TypedKeyframeTrack(
- targetNames[j] + "." + PATH_PROPERTIES[target2.path],
- inputAccessor.array,
- outputArray,
- interpolation
- );
- if (sampler2.interpolation === "CUBICSPLINE") {
- track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline(result) {
- return new GLTFCubicSplineInterpolant(this.times, this.values, this.getValueSize() / 3, result);
- };
- track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true;
- }
- tracks.push(track);
- }
- }
- var name2 = animationDef.name !== void 0 ? animationDef.name : "animation_" + animationIndex;
- return new AnimationClip(name2, void 0, tracks);
- });
- };
- GLTFParser.prototype.loadNode = function(nodeIndex) {
- var json = this.json;
- var extensions = this.extensions;
- var parser = this;
- var meshReferences = json.meshReferences;
- var meshUses = json.meshUses;
- var nodeDef = json.nodes[nodeIndex];
- return function() {
- var pending = [];
- if (nodeDef.mesh !== void 0) {
- pending.push(parser.getDependency("mesh", nodeDef.mesh).then(function(mesh) {
- var node;
- if (meshReferences[nodeDef.mesh] > 1) {
- var instanceNum = meshUses[nodeDef.mesh]++;
- node = mesh.clone();
- node.name += "_instance_" + instanceNum;
- } else {
- node = mesh;
- }
- if (nodeDef.weights !== void 0) {
- node.traverse(function(o) {
- if (!o.isMesh)
- return;
- for (var i2 = 0, il = nodeDef.weights.length; i2 < il; i2++) {
- o.morphTargetInfluences[i2] = nodeDef.weights[i2];
- }
- });
- }
- return node;
- }));
- }
- if (nodeDef.camera !== void 0) {
- pending.push(parser.getDependency("camera", nodeDef.camera));
- }
- if (nodeDef.extensions && nodeDef.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL] && nodeDef.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL].light !== void 0) {
- pending.push(parser.getDependency("light", nodeDef.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL].light));
- }
- return Promise.all(pending);
- }().then(function(objects) {
- var node;
- if (nodeDef.isBone === true) {
- node = new Bone();
- } else if (objects.length > 1) {
- node = new Group();
- } else if (objects.length === 1) {
- node = objects[0];
- } else {
- node = new Object3D();
- }
- if (node !== objects[0]) {
- for (var i2 = 0, il = objects.length; i2 < il; i2++) {
- node.add(objects[i2]);
- }
- }
- if (nodeDef.name !== void 0) {
- node.userData.name = nodeDef.name;
- node.name = PropertyBinding.sanitizeNodeName(nodeDef.name);
- }
- assignExtrasToUserData(node, nodeDef);
- if (nodeDef.extensions)
- addUnknownExtensionsToUserData(extensions, node, nodeDef);
- if (nodeDef.matrix !== void 0) {
- var matrix = new Matrix4();
- matrix.fromArray(nodeDef.matrix);
- node.applyMatrix4(matrix);
- } else {
- if (nodeDef.translation !== void 0) {
- node.position.fromArray(nodeDef.translation);
- }
- if (nodeDef.rotation !== void 0) {
- node.quaternion.fromArray(nodeDef.rotation);
- }
- if (nodeDef.scale !== void 0) {
- node.scale.fromArray(nodeDef.scale);
- }
- }
- return node;
- });
- };
- GLTFParser.prototype.loadScene = function() {
- function buildNodeHierachy(nodeId, parentObject, json, parser) {
- var nodeDef = json.nodes[nodeId];
- return parser.getDependency("node", nodeId).then(function(node) {
- if (nodeDef.skin === void 0)
- return node;
- var skinEntry;
- return parser.getDependency("skin", nodeDef.skin).then(function(skin) {
- skinEntry = skin;
- var pendingJoints = [];
- for (var i2 = 0, il = skinEntry.joints.length; i2 < il; i2++) {
- pendingJoints.push(parser.getDependency("node", skinEntry.joints[i2]));
- }
- return Promise.all(pendingJoints);
- }).then(function(jointNodes) {
- node.traverse(function(mesh) {
- if (!mesh.isMesh)
- return;
- var bones = [];
- var boneInverses = [];
- for (var j = 0, jl = jointNodes.length; j < jl; j++) {
- var jointNode = jointNodes[j];
- if (jointNode) {
- bones.push(jointNode);
- var mat = new Matrix4();
- if (skinEntry.inverseBindMatrices !== void 0) {
- mat.fromArray(skinEntry.inverseBindMatrices.array, j * 16);
- }
- boneInverses.push(mat);
- } else {
- console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', skinEntry.joints[j]);
- }
- }
- mesh.bind(new Skeleton(bones, boneInverses), mesh.matrixWorld);
- });
- return node;
- });
- }).then(function(node) {
- parentObject.add(node);
- var pending = [];
- if (nodeDef.children) {
- var children = nodeDef.children;
- for (var i2 = 0, il = children.length; i2 < il; i2++) {
- var child = children[i2];
- pending.push(buildNodeHierachy(child, node, json, parser));
- }
- }
- return Promise.all(pending);
- });
- }
- return function loadScene(sceneIndex) {
- var json = this.json;
- var extensions = this.extensions;
- var sceneDef = this.json.scenes[sceneIndex];
- var parser = this;
- var scene = new Scene();
- if (sceneDef.name !== void 0)
- scene.name = sceneDef.name;
- assignExtrasToUserData(scene, sceneDef);
- if (sceneDef.extensions)
- addUnknownExtensionsToUserData(extensions, scene, sceneDef);
- var nodeIds = sceneDef.nodes || [];
- var pending = [];
- for (var i2 = 0, il = nodeIds.length; i2 < il; i2++) {
- pending.push(buildNodeHierachy(nodeIds[i2], scene, json, parser));
- }
- return Promise.all(pending).then(function() {
- return scene;
- });
- };
- }();
- return GLTFLoader2;
- }();
- function mxtest_add_3d_model(mxdraw2) {
- const loader = new GLTFLoader();
- loader.load(
- "./gis/34M_17.gltf",
- (gltf) => {
- gltf.scene.position.set(116577.28779765591, 19632.646909285337, 0);
- gltf.scene.rotateX(Math.PI / 2);
- gltf.scene.scale.set(2, 2, 2);
- mxdraw2.addObject(gltf.scene);
- }
- );
- }
- {
- const ws = new WebSocket("ws://localhost:24678");
- ws.addEventListener("message", (event) => {
- const info = JSON.parse(event.data);
- if (info.type === "full-reload")
- location.reload();
- });
- }
- class MxCADPlugin extends mxcad2.MxCADPluginBase {
- constructor() {
- super();
- this.map_default_data = getMapDefaultData();
- }
- }
- let mxcadui;
- const { showModal, hideModal } = useModalVisible();
- function My_PluginTest() {
- return __async(this, null, function* () {
- showModal({
- title: "My Test Draw",
- text: "测试Modal",
- oncancel: () => {
- hideModal();
- },
- onsubmit: () => {
- hideModal();
- },
- ongetallentity: () => {
- hideModal();
- mxdraw.MxFun.sendStringToExecute("TestGetAllEntity");
- },
- ondrawline: () => {
- hideModal();
- mxdraw.MxFun.sendStringToExecute("Mx_Circle");
- },
- docommand: (cmd) => {
- hideModal();
- mxdraw.MxFun.sendStringToExecute(cmd);
- }
- });
- });
- }
- const div = document.createElement("div");
- document.body.appendChild(div);
- const app = vue.createApp(_sfc_main);
- app.mount(div);
- init$p();
- mxdraw.MxFun.on("mxcadApplicationStart", (mxcaduiimp) => {
- mxcadui = mxcaduiimp;
- mxcadui.init(new MxCADPlugin());
- });
- mxdraw.MxFun.on("mxcadApplicationInitMap", () => {
- init$1(mxcadui.mxmap);
- });
- mxdraw.MxFun.on("mxcadApplicationCreatedMxCADObject", (param) => {
- let mxcad$1 = param.mxcad;
- mxcad$1.on("selectChange", (ids) => {
- if (ids.length == 0)
- return;
- let id = ids[0];
- let mxent = id.getMxDbEntity();
- if (mxent !== null) {
- console.log(mxent.getTypeName());
- if (mxent instanceof mxdraw.MxDbRectBoxLeadComment) {
- let comment = mxent;
- console.log(comment.text);
- }
- return;
- }
- let ent = id.getMcDbEntity();
- if (ent !== null) {
- console.log(ent.objectName);
- if (ent instanceof mxcad2.McDbText) {
- let text = ent;
- console.log(text.textString);
- } else if (ent instanceof mxcad2.McDbBlockReference) {
- let blkRef = ent;
- let aryId = blkRef.getAllAttribute();
- aryId.forEach((id2) => {
- let attribt = id2.getMcDbEntity();
- console.log(attribt.textString);
- console.log(attribt.tag);
- });
- }
- }
- });
- mxcad2.MxCpp.PropertiesWindow.onEvent_getProperties((id) => {
- let ent = id.getMcDbEntity();
- if (!ent)
- return [];
- let dn = ent.getxDataDouble("DN");
- let len = ent.getxDataDouble("LEN");
- let ret = [];
- if (dn.ret) {
- ret.push({
- sVarName: "DN",
- iVarType: mxcad2.MxPropertiesWindowCustomValueType.kDouble,
- val: dn.val,
- isOnlyRead: false
- });
- }
- if (len.ret) {
- ret.push({
- sVarName: "LEN",
- iVarType: mxcad2.MxPropertiesWindowCustomValueType.kDouble,
- val: len.val,
- isOnlyRead: false
- });
- }
- return ret;
- });
- mxcad2.MxCpp.PropertiesWindow.onEvent_setProperties((id, prop) => {
- let ent = id.getMcDbEntity();
- if (!ent)
- return;
- if (prop.sVarName == "DN") {
- ent.setxDataDouble("DN", prop.val);
- } else if (prop.sVarName == "LEN") {
- ent.setxDataDouble("LEN", prop.val);
- }
- });
- });
- function getMxCADUi() {
- return mxcadui;
- }
- function McGePoint3dToString(pt) {
- return "x=" + pt.x + ",y=" + pt.y + ",z=" + pt.z;
- }
- function Mx_Open_DemoCode() {
- window.open("https://demo.mxdraw3d.com:3562/MxCADCode.7z");
- }
- function Mx_Open_DevInstall() {
- window.open(
- "https://demo.mxdraw3d.com:3562/MxDrawCloudServer1.0TryVersion.7z"
- );
- }
- function getMapUrl(type) {
- var url = window.location.href;
- if (url.indexOf("?") != -1) {
- url = url.replace(/(\?|#)[^'"]*/, "");
- }
- return `${url}?map=true&maptype=${type}`;
- }
- function Mx_Open_Map_gdslwzj() {
- window.open(getMapUrl("gdslwzj"));
- }
- function Mx_Open_Map_googlecn() {
- window.open(getMapUrl("google"));
- }
- function Mx_Open_Map_gdyx() {
- window.open(getMapUrl("gdyx"));
- }
- function Mx_Open_Map_tdtsl() {
- window.open(getMapUrl("tdtsl"));
- }
- function Mx_Open_Map_bdsl() {
- window.open(getMapUrl("bdsl"));
- }
- function Mx_Open_Map_geoq() {
- window.open(getMapUrl("geoq"));
- }
- function Mx_ViewBackgroundColor() {
- mxcad2.MxCpp.getCurrentMxCAD().setViewBackgroundColor(255, 255, 255);
- mxdraw.MxFun.callEvent("updateBackgroundColor", new mxcad2.McCmColor(255, 255, 255));
- }
- function Mx_TestExProp() {
- return __async(this, null, function* () {
- let selEntity1 = new mxcad2.MxCADUiPrEntity();
- selEntity1.setMessage("选择要需要开启自定义属性的对象");
- let idText = yield selEntity1.go();
- if (!idText.isValid())
- return;
- let ent = idText.getMcDbEntity();
- mxcad2.MxCpp.PropertiesWindow.setEntitySupportCustom(idText);
- ent.setxDataDouble("DN", 100);
- ent.setxDataDouble("LEN", 2e3);
- });
- }
- function Mx_Test_OpenFile() {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.openWebFile(
- "http://localhost:1337/mxcad/file/a9cbed3d3a351b79f24484e87bd78338.DWG.mxweb"
- );
- }
- function Mx_Test_GetFile() {
- return __async(this, null, function* () {
- });
- }
- function Mx_SelectEntitHideLayer() {
- return __async(this, null, function* () {
- let selEntity1 = new mxcad2.MxCADUiPrEntity();
- selEntity1.setMessage("选择要隐藏的对象");
- let id = yield selEntity1.go();
- if (!id.isValid())
- return;
- let ent = id.getMcDbEntity();
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- let layerTable = mxcad$1.getDatabase().getLayerTable();
- let layerId = layerTable.get(ent.layer);
- let layerRec = layerId.getMcDbLayerTableRecord();
- if (layerRec === null)
- return;
- layerRec.isOff = true;
- mxcad$1.updateLayerDisplayStatus();
- mxcad$1.updateDisplay();
- });
- }
- function getCurrentPagePath() {
- return window.location.origin + window.location.pathname;
- }
- function Mx_Test_DrawImage() {
- return __async(this, null, function* () {
- const getPoint = new mxcad2.MxCADUiPrPoint();
- getPoint.setMessage("\n指定插入点:");
- let pt = yield getPoint.go();
- if (!pt)
- return;
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- let imagUrl = getCurrentPagePath() + "mxcad.jpg";
- mxcad$1.loadImage(imagUrl, (image) => {
- if (!image) {
- console.log("loadImage failed");
- return;
- }
- let width = mxcad$1.mxdraw.viewCoordLong2Cad(100);
- let height = image.height / image.width * width;
- mxcad$1.drawImage(pt.x, pt.y, width, height, 0, imagUrl);
- mxcad$1.updateDisplay();
- });
- });
- }
- function MxTest_TestAddCurrentSelect() {
- return __async(this, null, function* () {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- let getPoint = new mxcad2.MxCADUiPrPoint();
- let pt1 = yield getPoint.go();
- if (pt1 == null)
- return;
- getPoint.setBasePt(pt1);
- let pt2 = yield getPoint.go();
- if (pt2 == null)
- return;
- let id = mxcad$1.drawLine(pt1.x, pt1.y, pt2.x, pt2.y);
- mxcad$1.addCurrentSelect(id);
- });
- }
- let lAng = 0;
- function MxTest_TestSetViewAngle() {
- return __async(this, null, function* () {
- lAng += Math.PI * 0.5;
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.zoomAngle(lAng);
- });
- }
- function MxText_ZoomCenter() {
- let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
- mxcad$1.zoomCenter(900, 900);
- }
- mxdraw.MxFun.on("mxcadApplicationStartCreatingMxCADObject", (param) => {
- let mxdraw2 = param.mxdraw;
- mxdraw2.setViewMovementMethod(true);
- mxdraw2.on("openFileComplete", () => {
- console.log("MxTip:openFileComplete ");
- });
- mxdraw2.addControlsEvent("mousedown", (event) => {
- let x = event.offsetX;
- let y = event.offsetY;
- let pt = mxdraw2.viewCoord2Cad(x, y, 0);
- console.log("mousedown:", pt);
- return 0;
- });
- });
- mxdraw.MxFun.on("mxcadApplicationCreatedMxCADObject", (param) => {
- let mxcad$1 = param.mxcad;
- mxcad$1.on("selectChange", (ids) => {
- if (ids.length == 0)
- return;
- let id = ids[0];
- let mxent = id.getMxDbEntity();
- if (mxent !== null) {
- console.log(mxent.getTypeName());
- if (mxent instanceof mxdraw.MxDbRectBoxLeadComment) {
- let comment = mxent;
- console.log(comment.text);
- }
- return;
- }
- let ent = id.getMcDbEntity();
- if (ent !== null) {
- console.log(ent.objectName);
- if (ent instanceof mxcad2.McDbText) {
- let text = ent;
- console.log(text.textString);
- } else if (ent instanceof mxcad2.McDbBlockReference) {
- let blkRef = ent;
- let aryId = blkRef.getAllAttribute();
- aryId.forEach((id2) => {
- let attribt = id2.getMcDbEntity();
- console.log(attribt.textString);
- console.log(attribt.tag);
- });
- }
- }
- });
- mxcad2.MxCpp.PropertiesWindow.onEvent_getProperties((id) => {
- let ent = id.getMcDbEntity();
- if (!ent)
- return [];
- let dn = ent.getxDataDouble("DN");
- let len = ent.getxDataDouble("LEN");
- let ret = [];
- if (dn.ret) {
- ret.push({
- sVarName: "DN",
- iVarType: mxcad2.MxPropertiesWindowCustomValueType.kDouble,
- val: dn.val,
- isOnlyRead: false
- });
- }
- if (len.ret) {
- ret.push({
- sVarName: "LEN",
- iVarType: mxcad2.MxPropertiesWindowCustomValueType.kDouble,
- val: len.val,
- isOnlyRead: false
- });
- }
- return ret;
- });
- mxcad2.MxCpp.PropertiesWindow.onEvent_setProperties((id, prop) => {
- let ent = id.getMcDbEntity();
- if (!ent)
- return;
- if (prop.sVarName == "DN") {
- ent.setxDataDouble("DN", prop.val);
- } else if (prop.sVarName == "LEN") {
- ent.setxDataDouble("LEN", prop.val);
- }
- });
- init();
- });
- function init() {
- mxdraw.MxFun.addCommand("My_PluginTest", My_PluginTest);
- mxdraw.MxFun.addCommand("Mx_Open_DemoCode", Mx_Open_DemoCode);
- mxdraw.MxFun.addCommand("Mx_Open_DevInstall", Mx_Open_DevInstall);
- mxdraw.MxFun.addCommand("Mx_Open_Map_gdslwzj", Mx_Open_Map_gdslwzj);
- mxdraw.MxFun.addCommand("Mx_Open_Map_gdyx", Mx_Open_Map_gdyx);
- mxdraw.MxFun.addCommand("Mx_Open_Map_tdtsl", Mx_Open_Map_tdtsl);
- mxdraw.MxFun.addCommand("Mx_Open_Map_bdsl", Mx_Open_Map_bdsl);
- mxdraw.MxFun.addCommand("Mx_Open_Map_geoq", Mx_Open_Map_geoq);
- mxdraw.MxFun.addCommand("Mx_Open_Map_googlecn", Mx_Open_Map_googlecn);
- mxdraw.MxFun.addCommand("Mx_ViewBackgroundColor", Mx_ViewBackgroundColor);
- mxdraw.MxFun.addCommand("Mx_TestExProp", Mx_TestExProp);
- mxdraw.MxFun.addCommand("Mx_Test_OpenFile", Mx_Test_OpenFile);
- mxdraw.MxFun.addCommand("Mx_Test_GetFile", Mx_Test_GetFile);
- mxdraw.MxFun.addCommand("Mx_TestExProp", Mx_TestExProp);
- mxdraw.MxFun.addCommand("Mx_SelectEntitHideLayer", Mx_SelectEntitHideLayer);
- mxdraw.MxFun.addCommand("MxTest_TestAddCurrentSelect", MxTest_TestAddCurrentSelect);
- mxdraw.MxFun.addCommand("MxTest_TestSetViewAngle", MxTest_TestSetViewAngle);
- mxdraw.MxFun.addCommand("MxText_ZoomCenter", MxText_ZoomCenter);
- mxdraw.MxFun.addCommand("MxTest_Map_Download", MxTest_Map_Download);
- mxdraw.MxFun.addCommand("Mx_Test_DrawImage", Mx_Test_DrawImage);
- init$o();
- init$n();
- init$m();
- init$l();
- init$k();
- init$j();
- init$i();
- init$g();
- init$f();
- init$5();
- init$3();
- init$h();
- init$2();
- if (mxcadui.mxmap) {
- mxtest_add_3d_model(mxdraw.MxFun.getCurrentDraw());
- }
- }
- exports.McGePoint3dToString = McGePoint3dToString;
- exports.MxTest_TestAddCurrentSelect = MxTest_TestAddCurrentSelect;
- exports.MxTest_TestSetViewAngle = MxTest_TestSetViewAngle;
- exports.MxText_ZoomCenter = MxText_ZoomCenter;
- exports.getMxCADUi = getMxCADUi;
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
- return exports;
- }({}, Mx, mxcad, Vue, axios);
- //# sourceMappingURL=test.js.map
|