echarts-gl.min.js 1.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641
  1. !function (e, t) {
  2. "object" == typeof exports && "object" == typeof module ? module.exports = t(require("echarts")) : "function" == typeof define && define.amd ? define(["echarts"], t) : "object" == typeof exports ? exports["echarts-gl"] = t(require("echarts")) : e["echarts-gl"] = t(e.echarts)
  3. }(self, (function (e) {
  4. return (() => {
  5. "use strict";
  6. var t = {
  7. 468: (e, t, r) => {
  8. r.r(t);
  9. var i = r(83);
  10. function n(e, t, r) {
  11. "object" == typeof t && (r = t,
  12. t = null);
  13. var i, n = this;
  14. if (!(e instanceof Function))
  15. for (var s in i = [],
  16. e)
  17. e.hasOwnProperty(s) && i.push(s);
  18. var l = function (t) {
  19. if (n.apply(this, arguments),
  20. e instanceof Function ? a(this, e.call(this, t)) : o(this, e, i),
  21. this.constructor === l)
  22. for (var r = l.__initializers__, s = 0; s < r.length; s++)
  23. r[s].apply(this, arguments)
  24. };
  25. l.__super__ = n,
  26. n.__initializers__ ? l.__initializers__ = n.__initializers__.slice() : l.__initializers__ = [],
  27. t && l.__initializers__.push(t);
  28. var h = function () { };
  29. return h.prototype = n.prototype,
  30. l.prototype = new h,
  31. l.prototype.constructor = l,
  32. a(l.prototype, r),
  33. l.extend = n.extend,
  34. l.derive = n.extend,
  35. l
  36. }
  37. function a(e, t) {
  38. if (t)
  39. for (var r in t)
  40. t.hasOwnProperty(r) && (e[r] = t[r])
  41. }
  42. function o(e, t, r) {
  43. for (var i = 0; i < r.length; i++) {
  44. var n = r[i];
  45. e[n] = t[n]
  46. }
  47. }
  48. const s = {
  49. extend: n,
  50. derive: n
  51. };
  52. function l(e, t) {
  53. this.action = e,
  54. this.context = t
  55. }
  56. const h = {
  57. trigger: function (e) {
  58. if (this.hasOwnProperty("__handlers__") && this.__handlers__.hasOwnProperty(e)) {
  59. var t = this.__handlers__[e]
  60. , r = t.length
  61. , i = -1
  62. , n = arguments;
  63. switch (n.length) {
  64. case 1:
  65. for (; ++i < r;)
  66. t[i].action.call(t[i].context);
  67. return;
  68. case 2:
  69. for (; ++i < r;)
  70. t[i].action.call(t[i].context, n[1]);
  71. return;
  72. case 3:
  73. for (; ++i < r;)
  74. t[i].action.call(t[i].context, n[1], n[2]);
  75. return;
  76. case 4:
  77. for (; ++i < r;)
  78. t[i].action.call(t[i].context, n[1], n[2], n[3]);
  79. return;
  80. case 5:
  81. for (; ++i < r;)
  82. t[i].action.call(t[i].context, n[1], n[2], n[3], n[4]);
  83. return;
  84. default:
  85. for (; ++i < r;)
  86. t[i].action.apply(t[i].context, Array.prototype.slice.call(n, 1));
  87. return
  88. }
  89. }
  90. },
  91. on: function (e, t, r) {
  92. if (e && t) {
  93. var i = this.__handlers__ || (this.__handlers__ = {});
  94. if (i[e]) {
  95. if (this.has(e, t))
  96. return
  97. } else
  98. i[e] = [];
  99. var n = new l(t, r || this);
  100. return i[e].push(n),
  101. this
  102. }
  103. },
  104. once: function (e, t, r) {
  105. if (e && t) {
  106. var i = this;
  107. return this.on(e, (function r() {
  108. i.off(e, r),
  109. t.apply(this, arguments)
  110. }
  111. ), r)
  112. }
  113. },
  114. before: function (e, t, r) {
  115. if (e && t)
  116. return e = "before" + e,
  117. this.on(e, t, r)
  118. },
  119. after: function (e, t, r) {
  120. if (e && t)
  121. return e = "after" + e,
  122. this.on(e, t, r)
  123. },
  124. success: function (e, t) {
  125. return this.once("success", e, t)
  126. },
  127. error: function (e, t) {
  128. return this.once("error", e, t)
  129. },
  130. off: function (e, t) {
  131. var r = this.__handlers__ || (this.__handlers__ = {});
  132. if (t) {
  133. if (r[e]) {
  134. for (var i = r[e], n = [], a = 0; a < i.length; a++)
  135. t && i[a].action !== t && n.push(i[a]);
  136. r[e] = n
  137. }
  138. return this
  139. }
  140. r[e] = []
  141. },
  142. has: function (e, t) {
  143. var r = this.__handlers__;
  144. if (!r || !r[e])
  145. return !1;
  146. for (var i = r[e], n = 0; n < i.length; n++)
  147. if (i[n].action === t)
  148. return !0
  149. }
  150. };
  151. var u = 0
  152. , c = Array.prototype.forEach
  153. , d = {
  154. genGUID: function () {
  155. return ++u
  156. },
  157. relative2absolute: function (e, t) {
  158. if (!t || e.match(/^\//))
  159. return e;
  160. for (var r = e.split("/"), i = t.split("/"), n = r[0]; "." === n || ".." === n;)
  161. ".." === n && i.pop(),
  162. r.shift(),
  163. n = r[0];
  164. return i.join("/") + "/" + r.join("/")
  165. },
  166. extend: function (e, t) {
  167. if (t)
  168. for (var r in t)
  169. t.hasOwnProperty(r) && (e[r] = t[r]);
  170. return e
  171. },
  172. defaults: function (e, t) {
  173. if (t)
  174. for (var r in t)
  175. void 0 === e[r] && (e[r] = t[r]);
  176. return e
  177. },
  178. extendWithPropList: function (e, t, r) {
  179. if (t)
  180. for (var i = 0; i < r.length; i++) {
  181. var n = r[i];
  182. e[n] = t[n]
  183. }
  184. return e
  185. },
  186. defaultsWithPropList: function (e, t, r) {
  187. if (t)
  188. for (var i = 0; i < r.length; i++) {
  189. var n = r[i];
  190. null == e[n] && (e[n] = t[n])
  191. }
  192. return e
  193. },
  194. each: function (e, t, r) {
  195. if (e && t)
  196. if (e.forEach && e.forEach === c)
  197. e.forEach(t, r);
  198. else if (e.length === +e.length)
  199. for (var i = 0, n = e.length; i < n; i++)
  200. t.call(r, e[i], i, e);
  201. else
  202. for (var a in e)
  203. e.hasOwnProperty(a) && t.call(r, e[a], a, e)
  204. },
  205. isObject: function (e) {
  206. return e === Object(e)
  207. },
  208. isArray: function (e) {
  209. return Array.isArray(e)
  210. },
  211. isArrayLike: function (e) {
  212. return !!e && e.length === +e.length
  213. },
  214. clone: function (e) {
  215. if (d.isObject(e)) {
  216. if (d.isArray(e))
  217. return e.slice();
  218. if (d.isArrayLike(e)) {
  219. for (var t = new e.constructor(e.length), r = 0; r < e.length; r++)
  220. t[r] = e[r];
  221. return t
  222. }
  223. return d.extend({}, e)
  224. }
  225. return e
  226. }
  227. };
  228. const f = d;
  229. var p = function () {
  230. this.__uid__ = f.genGUID()
  231. };
  232. p.__initializers__ = [function (e) {
  233. f.extend(this, e)
  234. }
  235. ],
  236. f.extend(p, s),
  237. f.extend(p.prototype, h);
  238. const m = p;
  239. var g = ["OES_texture_float", "OES_texture_half_float", "OES_texture_float_linear", "OES_texture_half_float_linear", "OES_standard_derivatives", "OES_vertex_array_object", "OES_element_index_uint", "WEBGL_compressed_texture_s3tc", "WEBGL_depth_texture", "EXT_texture_filter_anisotropic", "EXT_shader_texture_lod", "WEBGL_draw_buffers", "EXT_frag_depth", "EXT_sRGB", "ANGLE_instanced_arrays"]
  240. , _ = ["MAX_TEXTURE_SIZE", "MAX_CUBE_MAP_TEXTURE_SIZE"];
  241. const v = function (e) {
  242. for (var t = {}, r = {}, i = 0; i < g.length; i++)
  243. a(g[i]);
  244. for (i = 0; i < _.length; i++) {
  245. var n = _[i];
  246. r[n] = e.getParameter(e[n])
  247. }
  248. function a(r) {
  249. if (e.getExtension) {
  250. var i = e.getExtension(r);
  251. i || (i = e.getExtension("MOZ_" + r)),
  252. i || (i = e.getExtension("WEBKIT_" + r)),
  253. t[r] = i
  254. }
  255. }
  256. this.getExtension = function (e) {
  257. return e in t || a(e),
  258. t[e]
  259. }
  260. ,
  261. this.getParameter = function (e) {
  262. return r[e]
  263. }
  264. }
  265. , y = 1028
  266. , x = 1029
  267. , b = 2304
  268. , w = 2305
  269. , T = 5121
  270. , S = 5126
  271. , M = 6402
  272. , A = 6408
  273. , E = 9728
  274. , C = 9729
  275. , D = 9984
  276. , L = 9985
  277. , P = 9986
  278. , O = 9987
  279. , N = 10497
  280. , I = 33071
  281. , R = 33306
  282. , B = {
  283. get: function (e) {
  284. var t = new XMLHttpRequest;
  285. t.open("get", e.url),
  286. t.responseType = e.responseType || "text",
  287. e.onprogress && (t.onprogress = function (t) {
  288. if (t.lengthComputable) {
  289. var r = t.loaded / t.total;
  290. e.onprogress(r, t.loaded, t.total)
  291. } else
  292. e.onprogress(null)
  293. }
  294. ),
  295. t.onload = function (r) {
  296. t.status >= 400 ? e.onerror && e.onerror() : e.onload && e.onload(t.response)
  297. }
  298. ,
  299. e.onerror && (t.onerror = e.onerror),
  300. t.send(null)
  301. }
  302. };
  303. var F, z = {
  304. supportWebGL: function () {
  305. if (null == F)
  306. try {
  307. var e = document.createElement("canvas");
  308. if (!e.getContext("webgl") && !e.getContext("experimental-webgl"))
  309. throw new Error
  310. } catch (e) {
  311. F = !1
  312. }
  313. return F
  314. }
  315. };
  316. z.Int8Array = "undefined" == typeof Int8Array ? Array : Int8Array,
  317. z.Uint8Array = "undefined" == typeof Uint8Array ? Array : Uint8Array,
  318. z.Uint16Array = "undefined" == typeof Uint16Array ? Array : Uint16Array,
  319. z.Uint32Array = "undefined" == typeof Uint32Array ? Array : Uint32Array,
  320. z.Int16Array = "undefined" == typeof Int16Array ? Array : Int16Array,
  321. z.Float32Array = "undefined" == typeof Float32Array ? Array : Float32Array,
  322. z.Float64Array = "undefined" == typeof Float64Array ? Array : Float64Array;
  323. var G = {};
  324. "undefined" != typeof window ? G = window : void 0 !== r.g && (G = r.g),
  325. z.requestAnimationFrame = G.requestAnimationFrame || G.msRequestAnimationFrame || G.mozRequestAnimationFrame || G.webkitRequestAnimationFrame || function (e) {
  326. setTimeout(e, 16)
  327. }
  328. ,
  329. z.createCanvas = function () {
  330. return document.createElement("canvas")
  331. }
  332. ,
  333. z.createImage = function () {
  334. return new G.Image
  335. }
  336. ,
  337. z.request = {
  338. get: B.get
  339. },
  340. z.addEventListener = function (e, t, r, i) {
  341. e.addEventListener(t, r, i)
  342. }
  343. ,
  344. z.removeEventListener = function (e, t, r) {
  345. e.removeEventListener(t, r)
  346. }
  347. ;
  348. const U = z;
  349. var k = function () {
  350. this.head = null,
  351. this.tail = null,
  352. this._length = 0
  353. };
  354. k.prototype.insert = function (e) {
  355. var t = new k.Entry(e);
  356. return this.insertEntry(t),
  357. t
  358. }
  359. ,
  360. k.prototype.insertAt = function (e, t) {
  361. if (!(e < 0)) {
  362. for (var r = this.head, i = 0; r && i != e;)
  363. r = r.next,
  364. i++;
  365. if (r) {
  366. var n = new k.Entry(t)
  367. , a = r.prev;
  368. a ? (a.next = n,
  369. n.prev = a) : this.head = n,
  370. n.next = r,
  371. r.prev = n
  372. } else
  373. this.insert(t)
  374. }
  375. }
  376. ,
  377. k.prototype.insertBeforeEntry = function (e, t) {
  378. var r = new k.Entry(e)
  379. , i = t.prev;
  380. i ? (i.next = r,
  381. r.prev = i) : this.head = r,
  382. r.next = t,
  383. t.prev = r,
  384. this._length++
  385. }
  386. ,
  387. k.prototype.insertEntry = function (e) {
  388. this.head ? (this.tail.next = e,
  389. e.prev = this.tail,
  390. this.tail = e) : this.head = this.tail = e,
  391. this._length++
  392. }
  393. ,
  394. k.prototype.remove = function (e) {
  395. var t = e.prev
  396. , r = e.next;
  397. t ? t.next = r : this.head = r,
  398. r ? r.prev = t : this.tail = t,
  399. e.next = e.prev = null,
  400. this._length--
  401. }
  402. ,
  403. k.prototype.removeAt = function (e) {
  404. if (!(e < 0)) {
  405. for (var t = this.head, r = 0; t && r != e;)
  406. t = t.next,
  407. r++;
  408. return t ? (this.remove(t),
  409. t.value) : void 0
  410. }
  411. }
  412. ,
  413. k.prototype.getHead = function () {
  414. if (this.head)
  415. return this.head.value
  416. }
  417. ,
  418. k.prototype.getTail = function () {
  419. if (this.tail)
  420. return this.tail.value
  421. }
  422. ,
  423. k.prototype.getAt = function (e) {
  424. if (!(e < 0)) {
  425. for (var t = this.head, r = 0; t && r != e;)
  426. t = t.next,
  427. r++;
  428. return t.value
  429. }
  430. }
  431. ,
  432. k.prototype.indexOf = function (e) {
  433. for (var t = this.head, r = 0; t;) {
  434. if (t.value === e)
  435. return r;
  436. t = t.next,
  437. r++
  438. }
  439. }
  440. ,
  441. k.prototype.length = function () {
  442. return this._length
  443. }
  444. ,
  445. k.prototype.isEmpty = function () {
  446. return 0 === this._length
  447. }
  448. ,
  449. k.prototype.forEach = function (e, t) {
  450. for (var r = this.head, i = 0, n = void 0 !== t; r;)
  451. n ? e.call(t, r.value, i) : e(r.value, i),
  452. r = r.next,
  453. i++
  454. }
  455. ,
  456. k.prototype.clear = function () {
  457. this.tail = this.head = null,
  458. this._length = 0
  459. }
  460. ,
  461. k.Entry = function (e) {
  462. this.value = e,
  463. this.next = null,
  464. this.prev = null
  465. }
  466. ;
  467. const V = k;
  468. var H = function (e) {
  469. this._list = new V,
  470. this._map = {},
  471. this._maxSize = e || 10
  472. };
  473. H.prototype.setMaxSize = function (e) {
  474. this._maxSize = e
  475. }
  476. ,
  477. H.prototype.put = function (e, t) {
  478. if (!this._map.hasOwnProperty(e)) {
  479. var r = this._list.length();
  480. if (r >= this._maxSize && r > 0) {
  481. var i = this._list.head;
  482. this._list.remove(i),
  483. delete this._map[i.key]
  484. }
  485. var n = this._list.insert(t);
  486. n.key = e,
  487. this._map[e] = n
  488. }
  489. }
  490. ,
  491. H.prototype.get = function (e) {
  492. var t = this._map[e];
  493. if (this._map.hasOwnProperty(e))
  494. return t !== this._list.tail && (this._list.remove(t),
  495. this._list.insertEntry(t)),
  496. t.value
  497. }
  498. ,
  499. H.prototype.remove = function (e) {
  500. var t = this._map[e];
  501. void 0 !== t && (delete this._map[e],
  502. this._list.remove(t))
  503. }
  504. ,
  505. H.prototype.clear = function () {
  506. this._list.clear(),
  507. this._map = {}
  508. }
  509. ;
  510. const W = H;
  511. var j = {}
  512. , X = {
  513. transparent: [0, 0, 0, 0],
  514. aliceblue: [240, 248, 255, 1],
  515. antiquewhite: [250, 235, 215, 1],
  516. aqua: [0, 255, 255, 1],
  517. aquamarine: [127, 255, 212, 1],
  518. azure: [240, 255, 255, 1],
  519. beige: [245, 245, 220, 1],
  520. bisque: [255, 228, 196, 1],
  521. black: [0, 0, 0, 1],
  522. blanchedalmond: [255, 235, 205, 1],
  523. blue: [0, 0, 255, 1],
  524. blueviolet: [138, 43, 226, 1],
  525. brown: [165, 42, 42, 1],
  526. burlywood: [222, 184, 135, 1],
  527. cadetblue: [95, 158, 160, 1],
  528. chartreuse: [127, 255, 0, 1],
  529. chocolate: [210, 105, 30, 1],
  530. coral: [255, 127, 80, 1],
  531. cornflowerblue: [100, 149, 237, 1],
  532. cornsilk: [255, 248, 220, 1],
  533. crimson: [220, 20, 60, 1],
  534. cyan: [0, 255, 255, 1],
  535. darkblue: [0, 0, 139, 1],
  536. darkcyan: [0, 139, 139, 1],
  537. darkgoldenrod: [184, 134, 11, 1],
  538. darkgray: [169, 169, 169, 1],
  539. darkgreen: [0, 100, 0, 1],
  540. darkgrey: [169, 169, 169, 1],
  541. darkkhaki: [189, 183, 107, 1],
  542. darkmagenta: [139, 0, 139, 1],
  543. darkolivegreen: [85, 107, 47, 1],
  544. darkorange: [255, 140, 0, 1],
  545. darkorchid: [153, 50, 204, 1],
  546. darkred: [139, 0, 0, 1],
  547. darksalmon: [233, 150, 122, 1],
  548. darkseagreen: [143, 188, 143, 1],
  549. darkslateblue: [72, 61, 139, 1],
  550. darkslategray: [47, 79, 79, 1],
  551. darkslategrey: [47, 79, 79, 1],
  552. darkturquoise: [0, 206, 209, 1],
  553. darkviolet: [148, 0, 211, 1],
  554. deeppink: [255, 20, 147, 1],
  555. deepskyblue: [0, 191, 255, 1],
  556. dimgray: [105, 105, 105, 1],
  557. dimgrey: [105, 105, 105, 1],
  558. dodgerblue: [30, 144, 255, 1],
  559. firebrick: [178, 34, 34, 1],
  560. floralwhite: [255, 250, 240, 1],
  561. forestgreen: [34, 139, 34, 1],
  562. fuchsia: [255, 0, 255, 1],
  563. gainsboro: [220, 220, 220, 1],
  564. ghostwhite: [248, 248, 255, 1],
  565. gold: [255, 215, 0, 1],
  566. goldenrod: [218, 165, 32, 1],
  567. gray: [128, 128, 128, 1],
  568. green: [0, 128, 0, 1],
  569. greenyellow: [173, 255, 47, 1],
  570. grey: [128, 128, 128, 1],
  571. honeydew: [240, 255, 240, 1],
  572. hotpink: [255, 105, 180, 1],
  573. indianred: [205, 92, 92, 1],
  574. indigo: [75, 0, 130, 1],
  575. ivory: [255, 255, 240, 1],
  576. khaki: [240, 230, 140, 1],
  577. lavender: [230, 230, 250, 1],
  578. lavenderblush: [255, 240, 245, 1],
  579. lawngreen: [124, 252, 0, 1],
  580. lemonchiffon: [255, 250, 205, 1],
  581. lightblue: [173, 216, 230, 1],
  582. lightcoral: [240, 128, 128, 1],
  583. lightcyan: [224, 255, 255, 1],
  584. lightgoldenrodyellow: [250, 250, 210, 1],
  585. lightgray: [211, 211, 211, 1],
  586. lightgreen: [144, 238, 144, 1],
  587. lightgrey: [211, 211, 211, 1],
  588. lightpink: [255, 182, 193, 1],
  589. lightsalmon: [255, 160, 122, 1],
  590. lightseagreen: [32, 178, 170, 1],
  591. lightskyblue: [135, 206, 250, 1],
  592. lightslategray: [119, 136, 153, 1],
  593. lightslategrey: [119, 136, 153, 1],
  594. lightsteelblue: [176, 196, 222, 1],
  595. lightyellow: [255, 255, 224, 1],
  596. lime: [0, 255, 0, 1],
  597. limegreen: [50, 205, 50, 1],
  598. linen: [250, 240, 230, 1],
  599. magenta: [255, 0, 255, 1],
  600. maroon: [128, 0, 0, 1],
  601. mediumaquamarine: [102, 205, 170, 1],
  602. mediumblue: [0, 0, 205, 1],
  603. mediumorchid: [186, 85, 211, 1],
  604. mediumpurple: [147, 112, 219, 1],
  605. mediumseagreen: [60, 179, 113, 1],
  606. mediumslateblue: [123, 104, 238, 1],
  607. mediumspringgreen: [0, 250, 154, 1],
  608. mediumturquoise: [72, 209, 204, 1],
  609. mediumvioletred: [199, 21, 133, 1],
  610. midnightblue: [25, 25, 112, 1],
  611. mintcream: [245, 255, 250, 1],
  612. mistyrose: [255, 228, 225, 1],
  613. moccasin: [255, 228, 181, 1],
  614. navajowhite: [255, 222, 173, 1],
  615. navy: [0, 0, 128, 1],
  616. oldlace: [253, 245, 230, 1],
  617. olive: [128, 128, 0, 1],
  618. olivedrab: [107, 142, 35, 1],
  619. orange: [255, 165, 0, 1],
  620. orangered: [255, 69, 0, 1],
  621. orchid: [218, 112, 214, 1],
  622. palegoldenrod: [238, 232, 170, 1],
  623. palegreen: [152, 251, 152, 1],
  624. paleturquoise: [175, 238, 238, 1],
  625. palevioletred: [219, 112, 147, 1],
  626. papayawhip: [255, 239, 213, 1],
  627. peachpuff: [255, 218, 185, 1],
  628. peru: [205, 133, 63, 1],
  629. pink: [255, 192, 203, 1],
  630. plum: [221, 160, 221, 1],
  631. powderblue: [176, 224, 230, 1],
  632. purple: [128, 0, 128, 1],
  633. red: [255, 0, 0, 1],
  634. rosybrown: [188, 143, 143, 1],
  635. royalblue: [65, 105, 225, 1],
  636. saddlebrown: [139, 69, 19, 1],
  637. salmon: [250, 128, 114, 1],
  638. sandybrown: [244, 164, 96, 1],
  639. seagreen: [46, 139, 87, 1],
  640. seashell: [255, 245, 238, 1],
  641. sienna: [160, 82, 45, 1],
  642. silver: [192, 192, 192, 1],
  643. skyblue: [135, 206, 235, 1],
  644. slateblue: [106, 90, 205, 1],
  645. slategray: [112, 128, 144, 1],
  646. slategrey: [112, 128, 144, 1],
  647. snow: [255, 250, 250, 1],
  648. springgreen: [0, 255, 127, 1],
  649. steelblue: [70, 130, 180, 1],
  650. tan: [210, 180, 140, 1],
  651. teal: [0, 128, 128, 1],
  652. thistle: [216, 191, 216, 1],
  653. tomato: [255, 99, 71, 1],
  654. turquoise: [64, 224, 208, 1],
  655. violet: [238, 130, 238, 1],
  656. wheat: [245, 222, 179, 1],
  657. white: [255, 255, 255, 1],
  658. whitesmoke: [245, 245, 245, 1],
  659. yellow: [255, 255, 0, 1],
  660. yellowgreen: [154, 205, 50, 1]
  661. };
  662. function q(e) {
  663. return (e = Math.round(e)) < 0 ? 0 : e > 255 ? 255 : e
  664. }
  665. function Z(e) {
  666. return e < 0 ? 0 : e > 1 ? 1 : e
  667. }
  668. function Y(e) {
  669. return e.length && "%" === e.charAt(e.length - 1) ? q(parseFloat(e) / 100 * 255) : q(parseInt(e, 10))
  670. }
  671. function K(e) {
  672. return e.length && "%" === e.charAt(e.length - 1) ? Z(parseFloat(e) / 100) : Z(parseFloat(e))
  673. }
  674. function Q(e, t, r) {
  675. return r < 0 ? r += 1 : r > 1 && (r -= 1),
  676. 6 * r < 1 ? e + (t - e) * r * 6 : 2 * r < 1 ? t : 3 * r < 2 ? e + (t - e) * (2 / 3 - r) * 6 : e
  677. }
  678. function J(e, t, r) {
  679. return e + (t - e) * r
  680. }
  681. function $(e, t, r, i, n) {
  682. return e[0] = t,
  683. e[1] = r,
  684. e[2] = i,
  685. e[3] = n,
  686. e
  687. }
  688. function ee(e, t) {
  689. return e[0] = t[0],
  690. e[1] = t[1],
  691. e[2] = t[2],
  692. e[3] = t[3],
  693. e
  694. }
  695. var te = new W(20)
  696. , re = null;
  697. function ie(e, t) {
  698. re && ee(re, t),
  699. re = te.put(e, re || t.slice())
  700. }
  701. function ne(e, t) {
  702. var r = (parseFloat(e[0]) % 360 + 360) % 360 / 360
  703. , i = K(e[1])
  704. , n = K(e[2])
  705. , a = n <= .5 ? n * (i + 1) : n + i - n * i
  706. , o = 2 * n - a;
  707. return $(t = t || [], q(255 * Q(o, a, r + 1 / 3)), q(255 * Q(o, a, r)), q(255 * Q(o, a, r - 1 / 3)), 1),
  708. 4 === e.length && (t[3] = e[3]),
  709. t
  710. }
  711. j.parse = function (e, t) {
  712. if (e) {
  713. t = t || [];
  714. var r = te.get(e);
  715. if (r)
  716. return ee(t, r);
  717. var i, n = (e += "").replace(/ /g, "").toLowerCase();
  718. if (n in X)
  719. return ee(t, X[n]),
  720. ie(e, t),
  721. t;
  722. if ("#" === n.charAt(0))
  723. return 4 === n.length ? (i = parseInt(n.substr(1), 16)) >= 0 && i <= 4095 ? ($(t, (3840 & i) >> 4 | (3840 & i) >> 8, 240 & i | (240 & i) >> 4, 15 & i | (15 & i) << 4, 1),
  724. ie(e, t),
  725. t) : void $(t, 0, 0, 0, 1) : 7 === n.length ? (i = parseInt(n.substr(1), 16)) >= 0 && i <= 16777215 ? ($(t, (16711680 & i) >> 16, (65280 & i) >> 8, 255 & i, 1),
  726. ie(e, t),
  727. t) : void $(t, 0, 0, 0, 1) : void 0;
  728. var a = n.indexOf("(")
  729. , o = n.indexOf(")");
  730. if (-1 !== a && o + 1 === n.length) {
  731. var s = n.substr(0, a)
  732. , l = n.substr(a + 1, o - (a + 1)).split(",")
  733. , h = 1;
  734. switch (s) {
  735. case "rgba":
  736. if (4 !== l.length)
  737. return void $(t, 0, 0, 0, 1);
  738. h = K(l.pop());
  739. case "rgb":
  740. return 3 !== l.length ? void $(t, 0, 0, 0, 1) : ($(t, Y(l[0]), Y(l[1]), Y(l[2]), h),
  741. ie(e, t),
  742. t);
  743. case "hsla":
  744. return 4 !== l.length ? void $(t, 0, 0, 0, 1) : (l[3] = K(l[3]),
  745. ne(l, t),
  746. ie(e, t),
  747. t);
  748. case "hsl":
  749. return 3 !== l.length ? void $(t, 0, 0, 0, 1) : (ne(l, t),
  750. ie(e, t),
  751. t);
  752. default:
  753. return
  754. }
  755. }
  756. $(t, 0, 0, 0, 1)
  757. }
  758. }
  759. ,
  760. j.parseToFloat = function (e, t) {
  761. if (t = j.parse(e, t))
  762. return t[0] /= 255,
  763. t[1] /= 255,
  764. t[2] /= 255,
  765. t
  766. }
  767. ,
  768. j.lift = function (e, t) {
  769. var r = j.parse(e);
  770. if (r) {
  771. for (var i = 0; i < 3; i++)
  772. r[i] = t < 0 ? r[i] * (1 - t) | 0 : (255 - r[i]) * t + r[i] | 0;
  773. return j.stringify(r, 4 === r.length ? "rgba" : "rgb")
  774. }
  775. }
  776. ,
  777. j.toHex = function (e) {
  778. var t = j.parse(e);
  779. if (t)
  780. return ((1 << 24) + (t[0] << 16) + (t[1] << 8) + +t[2]).toString(16).slice(1)
  781. }
  782. ,
  783. j.fastLerp = function (e, t, r) {
  784. if (t && t.length && e >= 0 && e <= 1) {
  785. r = r || [];
  786. var i = e * (t.length - 1)
  787. , n = Math.floor(i)
  788. , a = Math.ceil(i)
  789. , o = t[n]
  790. , s = t[a]
  791. , l = i - n;
  792. return r[0] = q(J(o[0], s[0], l)),
  793. r[1] = q(J(o[1], s[1], l)),
  794. r[2] = q(J(o[2], s[2], l)),
  795. r[3] = Z(J(o[3], s[3], l)),
  796. r
  797. }
  798. }
  799. ,
  800. j.fastMapToColor = j.fastLerp,
  801. j.lerp = function (e, t, r) {
  802. if (t && t.length && e >= 0 && e <= 1) {
  803. var i = e * (t.length - 1)
  804. , n = Math.floor(i)
  805. , a = Math.ceil(i)
  806. , o = j.parse(t[n])
  807. , s = j.parse(t[a])
  808. , l = i - n
  809. , h = j.stringify([q(J(o[0], s[0], l)), q(J(o[1], s[1], l)), q(J(o[2], s[2], l)), Z(J(o[3], s[3], l))], "rgba");
  810. return r ? {
  811. color: h,
  812. leftIndex: n,
  813. rightIndex: a,
  814. value: i
  815. } : h
  816. }
  817. }
  818. ,
  819. j.mapToColor = j.lerp,
  820. j.modifyHSL = function (e, t, r, i) {
  821. if (e = j.parse(e))
  822. return e = function (e) {
  823. if (e) {
  824. var t, r, i = e[0] / 255, n = e[1] / 255, a = e[2] / 255, o = Math.min(i, n, a), s = Math.max(i, n, a), l = s - o, h = (s + o) / 2;
  825. if (0 === l)
  826. t = 0,
  827. r = 0;
  828. else {
  829. r = h < .5 ? l / (s + o) : l / (2 - s - o);
  830. var u = ((s - i) / 6 + l / 2) / l
  831. , c = ((s - n) / 6 + l / 2) / l
  832. , d = ((s - a) / 6 + l / 2) / l;
  833. i === s ? t = d - c : n === s ? t = 1 / 3 + u - d : a === s && (t = 2 / 3 + c - u),
  834. t < 0 && (t += 1),
  835. t > 1 && (t -= 1)
  836. }
  837. var f = [360 * t, r, h];
  838. return null != e[3] && f.push(e[3]),
  839. f
  840. }
  841. }(e),
  842. null != t && (e[0] = (n = t,
  843. (n = Math.round(n)) < 0 ? 0 : n > 360 ? 360 : n)),
  844. null != r && (e[1] = K(r)),
  845. null != i && (e[2] = K(i)),
  846. j.stringify(ne(e), "rgba");
  847. var n
  848. }
  849. ,
  850. j.modifyAlpha = function (e, t) {
  851. if ((e = j.parse(e)) && null != t)
  852. return e[3] = Z(t),
  853. j.stringify(e, "rgba")
  854. }
  855. ,
  856. j.stringify = function (e, t) {
  857. if (e && e.length) {
  858. var r = e[0] + "," + e[1] + "," + e[2];
  859. return "rgba" !== t && "hsva" !== t && "hsla" !== t || (r += "," + e[3]),
  860. t + "(" + r + ")"
  861. }
  862. }
  863. ;
  864. var ae = j.parseToFloat
  865. , oe = {};
  866. function se(e) {
  867. var t = Object.keys(e);
  868. t.sort();
  869. for (var r = [], i = 0; i < t.length; i++) {
  870. var n = t[i]
  871. , a = e[n];
  872. null === a ? r.push(n) : r.push(n + " " + a.toString())
  873. }
  874. return r.join("\n")
  875. }
  876. const le = m.extend((function () {
  877. return {
  878. name: "",
  879. depthTest: !0,
  880. depthMask: !0,
  881. transparent: !1,
  882. blend: null,
  883. autoUpdateTextureStatus: !0,
  884. uniforms: {},
  885. vertexDefines: {},
  886. fragmentDefines: {},
  887. _textureStatus: {},
  888. _enabledUniforms: null
  889. }
  890. }
  891. ), (function () {
  892. this.name || (this.name = "MATERIAL_" + this.__uid__),
  893. this.shader && this.attachShader(this.shader, !0)
  894. }
  895. ), {
  896. precision: "highp",
  897. setUniform: function (e, t) {
  898. void 0 === t && console.warn('Uniform value "' + e + '" is undefined');
  899. var r = this.uniforms[e];
  900. r && ("string" == typeof t && (t = ae(t) || t),
  901. r.value = t,
  902. this.autoUpdateTextureStatus && "t" === r.type && (t ? this.enableTexture(e) : this.disableTexture(e)))
  903. },
  904. setUniforms: function (e) {
  905. for (var t in e) {
  906. var r = e[t];
  907. this.setUniform(t, r)
  908. }
  909. },
  910. isUniformEnabled: function (e) {
  911. return this._enabledUniforms.indexOf(e) >= 0
  912. },
  913. getEnabledUniforms: function () {
  914. return this._enabledUniforms
  915. },
  916. getTextureUniforms: function () {
  917. return this._textureUniforms
  918. },
  919. set: function (e, t) {
  920. if ("object" == typeof e)
  921. for (var r in e) {
  922. var i = e[r];
  923. this.setUniform(r, i)
  924. }
  925. else
  926. this.setUniform(e, t)
  927. },
  928. get: function (e) {
  929. var t = this.uniforms[e];
  930. if (t)
  931. return t.value
  932. },
  933. attachShader: function (e, t) {
  934. var r = this.uniforms;
  935. this.uniforms = e.createUniforms(),
  936. this.shader = e;
  937. var i = this.uniforms;
  938. this._enabledUniforms = Object.keys(i),
  939. this._enabledUniforms.sort(),
  940. this._textureUniforms = this._enabledUniforms.filter((function (e) {
  941. var t = this.uniforms[e].type;
  942. return "t" === t || "tv" === t
  943. }
  944. ), this);
  945. var n = this.vertexDefines
  946. , a = this.fragmentDefines;
  947. if (this.vertexDefines = f.clone(e.vertexDefines),
  948. this.fragmentDefines = f.clone(e.fragmentDefines),
  949. t) {
  950. for (var o in r)
  951. i[o] && (i[o].value = r[o].value);
  952. f.defaults(this.vertexDefines, n),
  953. f.defaults(this.fragmentDefines, a)
  954. }
  955. var s = {};
  956. for (var l in e.textures)
  957. s[l] = {
  958. shaderType: e.textures[l].shaderType,
  959. type: e.textures[l].type,
  960. enabled: !(!t || !this._textureStatus[l]) && this._textureStatus[l].enabled
  961. };
  962. this._textureStatus = s,
  963. this._programKey = ""
  964. },
  965. clone: function () {
  966. var e = new this.constructor({
  967. name: this.name,
  968. shader: this.shader
  969. });
  970. for (var t in this.uniforms)
  971. e.uniforms[t].value = this.uniforms[t].value;
  972. return e.depthTest = this.depthTest,
  973. e.depthMask = this.depthMask,
  974. e.transparent = this.transparent,
  975. e.blend = this.blend,
  976. e.vertexDefines = f.clone(this.vertexDefines),
  977. e.fragmentDefines = f.clone(this.fragmentDefines),
  978. e.enableTexture(this.getEnabledTextures()),
  979. e.precision = this.precision,
  980. e
  981. },
  982. define: function (e, t, r) {
  983. var i = this.vertexDefines
  984. , n = this.fragmentDefines;
  985. "vertex" !== e && "fragment" !== e && "both" !== e && arguments.length < 3 && (r = t,
  986. t = e,
  987. e = "both"),
  988. r = null != r ? r : null,
  989. "vertex" !== e && "both" !== e || i[t] !== r && (i[t] = r,
  990. this._programKey = ""),
  991. "fragment" !== e && "both" !== e || n[t] !== r && (n[t] = r,
  992. "both" !== e && (this._programKey = ""))
  993. },
  994. undefine: function (e, t) {
  995. "vertex" !== e && "fragment" !== e && "both" !== e && arguments.length < 2 && (t = e,
  996. e = "both"),
  997. "vertex" !== e && "both" !== e || this.isDefined("vertex", t) && (delete this.vertexDefines[t],
  998. this._programKey = ""),
  999. "fragment" !== e && "both" !== e || this.isDefined("fragment", t) && (delete this.fragmentDefines[t],
  1000. "both" !== e && (this._programKey = ""))
  1001. },
  1002. isDefined: function (e, t) {
  1003. switch (e) {
  1004. case "vertex":
  1005. return void 0 !== this.vertexDefines[t];
  1006. case "fragment":
  1007. return void 0 !== this.fragmentDefines[t]
  1008. }
  1009. },
  1010. getDefine: function (e, t) {
  1011. switch (e) {
  1012. case "vertex":
  1013. return this.vertexDefines[t];
  1014. case "fragment":
  1015. return this.fragmentDefines[t]
  1016. }
  1017. },
  1018. enableTexture: function (e) {
  1019. if (Array.isArray(e))
  1020. for (var t = 0; t < e.length; t++)
  1021. this.enableTexture(e[t]);
  1022. else {
  1023. var r = this._textureStatus[e];
  1024. r && (r.enabled || (r.enabled = !0,
  1025. this._programKey = ""))
  1026. }
  1027. },
  1028. enableTexturesAll: function () {
  1029. var e = this._textureStatus;
  1030. for (var t in e)
  1031. e[t].enabled = !0;
  1032. this._programKey = ""
  1033. },
  1034. disableTexture: function (e) {
  1035. if (Array.isArray(e))
  1036. for (var t = 0; t < e.length; t++)
  1037. this.disableTexture(e[t]);
  1038. else {
  1039. var r = this._textureStatus[e];
  1040. r && (!r.enabled || (r.enabled = !1,
  1041. this._programKey = ""))
  1042. }
  1043. },
  1044. disableTexturesAll: function () {
  1045. var e = this._textureStatus;
  1046. for (var t in e)
  1047. e[t].enabled = !1;
  1048. this._programKey = ""
  1049. },
  1050. isTextureEnabled: function (e) {
  1051. var t = this._textureStatus;
  1052. return !!t[e] && t[e].enabled
  1053. },
  1054. getEnabledTextures: function () {
  1055. var e = []
  1056. , t = this._textureStatus;
  1057. for (var r in t)
  1058. t[r].enabled && e.push(r);
  1059. return e
  1060. },
  1061. dirtyDefines: function () {
  1062. this._programKey = ""
  1063. },
  1064. getProgramKey: function () {
  1065. return this._programKey || (this._programKey = function (e, t, r) {
  1066. r.sort();
  1067. for (var i = [], n = 0; n < r.length; n++) {
  1068. var a = r[n];
  1069. i.push(a)
  1070. }
  1071. var o = se(e) + "\n" + se(t) + "\n" + i.join("\n");
  1072. if (oe[o])
  1073. return oe[o];
  1074. var s = f.genGUID();
  1075. return oe[o] = s,
  1076. s
  1077. }(this.vertexDefines, this.fragmentDefines, this.getEnabledTextures())),
  1078. this._programKey
  1079. }
  1080. });
  1081. var he, ue = 1e-6, ce = Array, de = Math.random, fe = {
  1082. create: function () {
  1083. var e = new ce(2);
  1084. return e[0] = 0,
  1085. e[1] = 0,
  1086. e
  1087. },
  1088. clone: function (e) {
  1089. var t = new ce(2);
  1090. return t[0] = e[0],
  1091. t[1] = e[1],
  1092. t
  1093. },
  1094. fromValues: function (e, t) {
  1095. var r = new ce(2);
  1096. return r[0] = e,
  1097. r[1] = t,
  1098. r
  1099. },
  1100. copy: function (e, t) {
  1101. return e[0] = t[0],
  1102. e[1] = t[1],
  1103. e
  1104. },
  1105. set: function (e, t, r) {
  1106. return e[0] = t,
  1107. e[1] = r,
  1108. e
  1109. },
  1110. add: function (e, t, r) {
  1111. return e[0] = t[0] + r[0],
  1112. e[1] = t[1] + r[1],
  1113. e
  1114. },
  1115. subtract: function (e, t, r) {
  1116. return e[0] = t[0] - r[0],
  1117. e[1] = t[1] - r[1],
  1118. e
  1119. }
  1120. };
  1121. fe.sub = fe.subtract,
  1122. fe.multiply = function (e, t, r) {
  1123. return e[0] = t[0] * r[0],
  1124. e[1] = t[1] * r[1],
  1125. e
  1126. }
  1127. ,
  1128. fe.mul = fe.multiply,
  1129. fe.divide = function (e, t, r) {
  1130. return e[0] = t[0] / r[0],
  1131. e[1] = t[1] / r[1],
  1132. e
  1133. }
  1134. ,
  1135. fe.div = fe.divide,
  1136. fe.min = function (e, t, r) {
  1137. return e[0] = Math.min(t[0], r[0]),
  1138. e[1] = Math.min(t[1], r[1]),
  1139. e
  1140. }
  1141. ,
  1142. fe.max = function (e, t, r) {
  1143. return e[0] = Math.max(t[0], r[0]),
  1144. e[1] = Math.max(t[1], r[1]),
  1145. e
  1146. }
  1147. ,
  1148. fe.scale = function (e, t, r) {
  1149. return e[0] = t[0] * r,
  1150. e[1] = t[1] * r,
  1151. e
  1152. }
  1153. ,
  1154. fe.scaleAndAdd = function (e, t, r, i) {
  1155. return e[0] = t[0] + r[0] * i,
  1156. e[1] = t[1] + r[1] * i,
  1157. e
  1158. }
  1159. ,
  1160. fe.distance = function (e, t) {
  1161. var r = t[0] - e[0]
  1162. , i = t[1] - e[1];
  1163. return Math.sqrt(r * r + i * i)
  1164. }
  1165. ,
  1166. fe.dist = fe.distance,
  1167. fe.squaredDistance = function (e, t) {
  1168. var r = t[0] - e[0]
  1169. , i = t[1] - e[1];
  1170. return r * r + i * i
  1171. }
  1172. ,
  1173. fe.sqrDist = fe.squaredDistance,
  1174. fe.length = function (e) {
  1175. var t = e[0]
  1176. , r = e[1];
  1177. return Math.sqrt(t * t + r * r)
  1178. }
  1179. ,
  1180. fe.len = fe.length,
  1181. fe.squaredLength = function (e) {
  1182. var t = e[0]
  1183. , r = e[1];
  1184. return t * t + r * r
  1185. }
  1186. ,
  1187. fe.sqrLen = fe.squaredLength,
  1188. fe.negate = function (e, t) {
  1189. return e[0] = -t[0],
  1190. e[1] = -t[1],
  1191. e
  1192. }
  1193. ,
  1194. fe.inverse = function (e, t) {
  1195. return e[0] = 1 / t[0],
  1196. e[1] = 1 / t[1],
  1197. e
  1198. }
  1199. ,
  1200. fe.normalize = function (e, t) {
  1201. var r = t[0]
  1202. , i = t[1]
  1203. , n = r * r + i * i;
  1204. return n > 0 && (n = 1 / Math.sqrt(n),
  1205. e[0] = t[0] * n,
  1206. e[1] = t[1] * n),
  1207. e
  1208. }
  1209. ,
  1210. fe.dot = function (e, t) {
  1211. return e[0] * t[0] + e[1] * t[1]
  1212. }
  1213. ,
  1214. fe.cross = function (e, t, r) {
  1215. var i = t[0] * r[1] - t[1] * r[0];
  1216. return e[0] = e[1] = 0,
  1217. e[2] = i,
  1218. e
  1219. }
  1220. ,
  1221. fe.lerp = function (e, t, r, i) {
  1222. var n = t[0]
  1223. , a = t[1];
  1224. return e[0] = n + i * (r[0] - n),
  1225. e[1] = a + i * (r[1] - a),
  1226. e
  1227. }
  1228. ,
  1229. fe.random = function (e, t) {
  1230. t = t || 1;
  1231. var r = 2 * GLMAT_RANDOM() * Math.PI;
  1232. return e[0] = Math.cos(r) * t,
  1233. e[1] = Math.sin(r) * t,
  1234. e
  1235. }
  1236. ,
  1237. fe.transformMat2 = function (e, t, r) {
  1238. var i = t[0]
  1239. , n = t[1];
  1240. return e[0] = r[0] * i + r[2] * n,
  1241. e[1] = r[1] * i + r[3] * n,
  1242. e
  1243. }
  1244. ,
  1245. fe.transformMat2d = function (e, t, r) {
  1246. var i = t[0]
  1247. , n = t[1];
  1248. return e[0] = r[0] * i + r[2] * n + r[4],
  1249. e[1] = r[1] * i + r[3] * n + r[5],
  1250. e
  1251. }
  1252. ,
  1253. fe.transformMat3 = function (e, t, r) {
  1254. var i = t[0]
  1255. , n = t[1];
  1256. return e[0] = r[0] * i + r[3] * n + r[6],
  1257. e[1] = r[1] * i + r[4] * n + r[7],
  1258. e
  1259. }
  1260. ,
  1261. fe.transformMat4 = function (e, t, r) {
  1262. var i = t[0]
  1263. , n = t[1];
  1264. return e[0] = r[0] * i + r[4] * n + r[12],
  1265. e[1] = r[1] * i + r[5] * n + r[13],
  1266. e
  1267. }
  1268. ,
  1269. fe.forEach = (he = fe.create(),
  1270. function (e, t, r, i, n, a) {
  1271. var o, s;
  1272. for (t || (t = 2),
  1273. r || (r = 0),
  1274. s = i ? Math.min(i * t + r, e.length) : e.length,
  1275. o = r; o < s; o += t)
  1276. he[0] = e[o],
  1277. he[1] = e[o + 1],
  1278. n(he, he, a),
  1279. e[o] = he[0],
  1280. e[o + 1] = he[1];
  1281. return e
  1282. }
  1283. );
  1284. const pe = fe;
  1285. var me = function (e, t) {
  1286. e = e || 0,
  1287. t = t || 0,
  1288. this.array = pe.fromValues(e, t),
  1289. this._dirty = !0
  1290. };
  1291. if (me.prototype = {
  1292. constructor: me,
  1293. add: function (e) {
  1294. return pe.add(this.array, this.array, e.array),
  1295. this._dirty = !0,
  1296. this
  1297. },
  1298. set: function (e, t) {
  1299. return this.array[0] = e,
  1300. this.array[1] = t,
  1301. this._dirty = !0,
  1302. this
  1303. },
  1304. setArray: function (e) {
  1305. return this.array[0] = e[0],
  1306. this.array[1] = e[1],
  1307. this._dirty = !0,
  1308. this
  1309. },
  1310. clone: function () {
  1311. return new me(this.x, this.y)
  1312. },
  1313. copy: function (e) {
  1314. return pe.copy(this.array, e.array),
  1315. this._dirty = !0,
  1316. this
  1317. },
  1318. cross: function (e, t) {
  1319. return pe.cross(e.array, this.array, t.array),
  1320. e._dirty = !0,
  1321. this
  1322. },
  1323. dist: function (e) {
  1324. return pe.dist(this.array, e.array)
  1325. },
  1326. distance: function (e) {
  1327. return pe.distance(this.array, e.array)
  1328. },
  1329. div: function (e) {
  1330. return pe.div(this.array, this.array, e.array),
  1331. this._dirty = !0,
  1332. this
  1333. },
  1334. divide: function (e) {
  1335. return pe.divide(this.array, this.array, e.array),
  1336. this._dirty = !0,
  1337. this
  1338. },
  1339. dot: function (e) {
  1340. return pe.dot(this.array, e.array)
  1341. },
  1342. len: function () {
  1343. return pe.len(this.array)
  1344. },
  1345. length: function () {
  1346. return pe.length(this.array)
  1347. },
  1348. lerp: function (e, t, r) {
  1349. return pe.lerp(this.array, e.array, t.array, r),
  1350. this._dirty = !0,
  1351. this
  1352. },
  1353. min: function (e) {
  1354. return pe.min(this.array, this.array, e.array),
  1355. this._dirty = !0,
  1356. this
  1357. },
  1358. max: function (e) {
  1359. return pe.max(this.array, this.array, e.array),
  1360. this._dirty = !0,
  1361. this
  1362. },
  1363. mul: function (e) {
  1364. return pe.mul(this.array, this.array, e.array),
  1365. this._dirty = !0,
  1366. this
  1367. },
  1368. multiply: function (e) {
  1369. return pe.multiply(this.array, this.array, e.array),
  1370. this._dirty = !0,
  1371. this
  1372. },
  1373. negate: function () {
  1374. return pe.negate(this.array, this.array),
  1375. this._dirty = !0,
  1376. this
  1377. },
  1378. normalize: function () {
  1379. return pe.normalize(this.array, this.array),
  1380. this._dirty = !0,
  1381. this
  1382. },
  1383. random: function (e) {
  1384. return pe.random(this.array, e),
  1385. this._dirty = !0,
  1386. this
  1387. },
  1388. scale: function (e) {
  1389. return pe.scale(this.array, this.array, e),
  1390. this._dirty = !0,
  1391. this
  1392. },
  1393. scaleAndAdd: function (e, t) {
  1394. return pe.scaleAndAdd(this.array, this.array, e.array, t),
  1395. this._dirty = !0,
  1396. this
  1397. },
  1398. sqrDist: function (e) {
  1399. return pe.sqrDist(this.array, e.array)
  1400. },
  1401. squaredDistance: function (e) {
  1402. return pe.squaredDistance(this.array, e.array)
  1403. },
  1404. sqrLen: function () {
  1405. return pe.sqrLen(this.array)
  1406. },
  1407. squaredLength: function () {
  1408. return pe.squaredLength(this.array)
  1409. },
  1410. sub: function (e) {
  1411. return pe.sub(this.array, this.array, e.array),
  1412. this._dirty = !0,
  1413. this
  1414. },
  1415. subtract: function (e) {
  1416. return pe.subtract(this.array, this.array, e.array),
  1417. this._dirty = !0,
  1418. this
  1419. },
  1420. transformMat2: function (e) {
  1421. return pe.transformMat2(this.array, this.array, e.array),
  1422. this._dirty = !0,
  1423. this
  1424. },
  1425. transformMat2d: function (e) {
  1426. return pe.transformMat2d(this.array, this.array, e.array),
  1427. this._dirty = !0,
  1428. this
  1429. },
  1430. transformMat3: function (e) {
  1431. return pe.transformMat3(this.array, this.array, e.array),
  1432. this._dirty = !0,
  1433. this
  1434. },
  1435. transformMat4: function (e) {
  1436. return pe.transformMat4(this.array, this.array, e.array),
  1437. this._dirty = !0,
  1438. this
  1439. },
  1440. toString: function () {
  1441. return "[" + Array.prototype.join.call(this.array, ",") + "]"
  1442. },
  1443. toArray: function () {
  1444. return Array.prototype.slice.call(this.array)
  1445. }
  1446. },
  1447. Object.defineProperty) {
  1448. var ge = me.prototype;
  1449. Object.defineProperty(ge, "x", {
  1450. get: function () {
  1451. return this.array[0]
  1452. },
  1453. set: function (e) {
  1454. this.array[0] = e,
  1455. this._dirty = !0
  1456. }
  1457. }),
  1458. Object.defineProperty(ge, "y", {
  1459. get: function () {
  1460. return this.array[1]
  1461. },
  1462. set: function (e) {
  1463. this.array[1] = e,
  1464. this._dirty = !0
  1465. }
  1466. })
  1467. }
  1468. me.add = function (e, t, r) {
  1469. return pe.add(e.array, t.array, r.array),
  1470. e._dirty = !0,
  1471. e
  1472. }
  1473. ,
  1474. me.set = function (e, t, r) {
  1475. return pe.set(e.array, t, r),
  1476. e._dirty = !0,
  1477. e
  1478. }
  1479. ,
  1480. me.copy = function (e, t) {
  1481. return pe.copy(e.array, t.array),
  1482. e._dirty = !0,
  1483. e
  1484. }
  1485. ,
  1486. me.cross = function (e, t, r) {
  1487. return pe.cross(e.array, t.array, r.array),
  1488. e._dirty = !0,
  1489. e
  1490. }
  1491. ,
  1492. me.distance = me.dist = function (e, t) {
  1493. return pe.distance(e.array, t.array)
  1494. }
  1495. ,
  1496. me.divide = me.div = function (e, t, r) {
  1497. return pe.divide(e.array, t.array, r.array),
  1498. e._dirty = !0,
  1499. e
  1500. }
  1501. ,
  1502. me.dot = function (e, t) {
  1503. return pe.dot(e.array, t.array)
  1504. }
  1505. ,
  1506. me.len = function (e) {
  1507. return pe.length(e.array)
  1508. }
  1509. ,
  1510. me.lerp = function (e, t, r, i) {
  1511. return pe.lerp(e.array, t.array, r.array, i),
  1512. e._dirty = !0,
  1513. e
  1514. }
  1515. ,
  1516. me.min = function (e, t, r) {
  1517. return pe.min(e.array, t.array, r.array),
  1518. e._dirty = !0,
  1519. e
  1520. }
  1521. ,
  1522. me.max = function (e, t, r) {
  1523. return pe.max(e.array, t.array, r.array),
  1524. e._dirty = !0,
  1525. e
  1526. }
  1527. ,
  1528. me.multiply = me.mul = function (e, t, r) {
  1529. return pe.multiply(e.array, t.array, r.array),
  1530. e._dirty = !0,
  1531. e
  1532. }
  1533. ,
  1534. me.negate = function (e, t) {
  1535. return pe.negate(e.array, t.array),
  1536. e._dirty = !0,
  1537. e
  1538. }
  1539. ,
  1540. me.normalize = function (e, t) {
  1541. return pe.normalize(e.array, t.array),
  1542. e._dirty = !0,
  1543. e
  1544. }
  1545. ,
  1546. me.random = function (e, t) {
  1547. return pe.random(e.array, t),
  1548. e._dirty = !0,
  1549. e
  1550. }
  1551. ,
  1552. me.scale = function (e, t, r) {
  1553. return pe.scale(e.array, t.array, r),
  1554. e._dirty = !0,
  1555. e
  1556. }
  1557. ,
  1558. me.scaleAndAdd = function (e, t, r, i) {
  1559. return pe.scaleAndAdd(e.array, t.array, r.array, i),
  1560. e._dirty = !0,
  1561. e
  1562. }
  1563. ,
  1564. me.squaredDistance = me.sqrDist = function (e, t) {
  1565. return pe.sqrDist(e.array, t.array)
  1566. }
  1567. ,
  1568. me.squaredLength = me.sqrLen = function (e) {
  1569. return pe.sqrLen(e.array)
  1570. }
  1571. ,
  1572. me.subtract = me.sub = function (e, t, r) {
  1573. return pe.subtract(e.array, t.array, r.array),
  1574. e._dirty = !0,
  1575. e
  1576. }
  1577. ,
  1578. me.transformMat2 = function (e, t, r) {
  1579. return pe.transformMat2(e.array, t.array, r.array),
  1580. e._dirty = !0,
  1581. e
  1582. }
  1583. ,
  1584. me.transformMat2d = function (e, t, r) {
  1585. return pe.transformMat2d(e.array, t.array, r.array),
  1586. e._dirty = !0,
  1587. e
  1588. }
  1589. ,
  1590. me.transformMat3 = function (e, t, r) {
  1591. return pe.transformMat3(e.array, t.array, r.array),
  1592. e._dirty = !0,
  1593. e
  1594. }
  1595. ,
  1596. me.transformMat4 = function (e, t, r) {
  1597. return pe.transformMat4(e.array, t.array, r.array),
  1598. e._dirty = !0,
  1599. e
  1600. }
  1601. ;
  1602. const _e = me;
  1603. var ve = {};
  1604. function ye(e) {
  1605. for (var t = e.split("\n"), r = 0, i = t.length; r < i; r++)
  1606. t[r] = r + 1 + ": " + t[r];
  1607. return t.join("\n")
  1608. }
  1609. function xe(e, t, r) {
  1610. if (!e.getShaderParameter(t, e.COMPILE_STATUS))
  1611. return [e.getShaderInfoLog(t), ye(r)].join("\n")
  1612. }
  1613. var be = new U.Float32Array(16);
  1614. const we = m.extend({
  1615. uniformSemantics: {},
  1616. attributes: {}
  1617. }, (function () {
  1618. this._locations = {},
  1619. this._textureSlot = 0,
  1620. this._program = null
  1621. }
  1622. ), {
  1623. bind: function (e) {
  1624. this._textureSlot = 0,
  1625. e.gl.useProgram(this._program)
  1626. },
  1627. hasUniform: function (e) {
  1628. return null != this._locations[e]
  1629. },
  1630. useTextureSlot: function (e, t, r) {
  1631. t && (e.gl.activeTexture(e.gl.TEXTURE0 + r),
  1632. t.isRenderable() ? t.bind(e) : t.unbind(e))
  1633. },
  1634. currentTextureSlot: function () {
  1635. return this._textureSlot
  1636. },
  1637. resetTextureSlot: function (e) {
  1638. this._textureSlot = e || 0
  1639. },
  1640. takeCurrentTextureSlot: function (e, t) {
  1641. var r = this._textureSlot;
  1642. return this.useTextureSlot(e, t, r),
  1643. this._textureSlot++,
  1644. r
  1645. },
  1646. setUniform: function (e, t, r, i) {
  1647. var n = this._locations[r];
  1648. if (null == n)
  1649. return !1;
  1650. switch (t) {
  1651. case "m4":
  1652. if (!(i instanceof Float32Array)) {
  1653. for (var a = 0; a < i.length; a++)
  1654. be[a] = i[a];
  1655. i = be
  1656. }
  1657. e.uniformMatrix4fv(n, !1, i);
  1658. break;
  1659. case "2i":
  1660. e.uniform2i(n, i[0], i[1]);
  1661. break;
  1662. case "2f":
  1663. e.uniform2f(n, i[0], i[1]);
  1664. break;
  1665. case "3i":
  1666. e.uniform3i(n, i[0], i[1], i[2]);
  1667. break;
  1668. case "3f":
  1669. e.uniform3f(n, i[0], i[1], i[2]);
  1670. break;
  1671. case "4i":
  1672. e.uniform4i(n, i[0], i[1], i[2], i[3]);
  1673. break;
  1674. case "4f":
  1675. e.uniform4f(n, i[0], i[1], i[2], i[3]);
  1676. break;
  1677. case "1i":
  1678. e.uniform1i(n, i);
  1679. break;
  1680. case "1f":
  1681. e.uniform1f(n, i);
  1682. break;
  1683. case "1fv":
  1684. e.uniform1fv(n, i);
  1685. break;
  1686. case "1iv":
  1687. e.uniform1iv(n, i);
  1688. break;
  1689. case "2iv":
  1690. e.uniform2iv(n, i);
  1691. break;
  1692. case "2fv":
  1693. e.uniform2fv(n, i);
  1694. break;
  1695. case "3iv":
  1696. e.uniform3iv(n, i);
  1697. break;
  1698. case "3fv":
  1699. e.uniform3fv(n, i);
  1700. break;
  1701. case "4iv":
  1702. e.uniform4iv(n, i);
  1703. break;
  1704. case "4fv":
  1705. e.uniform4fv(n, i);
  1706. break;
  1707. case "m2":
  1708. case "m2v":
  1709. e.uniformMatrix2fv(n, !1, i);
  1710. break;
  1711. case "m3":
  1712. case "m3v":
  1713. e.uniformMatrix3fv(n, !1, i);
  1714. break;
  1715. case "m4v":
  1716. if (Array.isArray(i) && Array.isArray(i[0])) {
  1717. var o = new U.Float32Array(16 * i.length)
  1718. , s = 0;
  1719. for (a = 0; a < i.length; a++)
  1720. for (var l = i[a], h = 0; h < 16; h++)
  1721. o[s++] = l[h];
  1722. e.uniformMatrix4fv(n, !1, o)
  1723. } else
  1724. e.uniformMatrix4fv(n, !1, i)
  1725. }
  1726. return !0
  1727. },
  1728. setUniformOfSemantic: function (e, t, r) {
  1729. var i = this.uniformSemantics[t];
  1730. return !!i && this.setUniform(e, i.type, i.symbol, r)
  1731. },
  1732. enableAttributes: function (e, t, r) {
  1733. var i, n = e.gl, a = this._program, o = this._locations;
  1734. (i = r ? r.__enabledAttributeList : ve[e.__uid__]) || (i = r ? r.__enabledAttributeList = [] : ve[e.__uid__] = []);
  1735. for (var s = [], l = 0; l < t.length; l++) {
  1736. var h = t[l];
  1737. if (this.attributes[h]) {
  1738. var u = o[h];
  1739. if (null == u) {
  1740. if (-1 === (u = n.getAttribLocation(a, h))) {
  1741. s[l] = -1;
  1742. continue
  1743. }
  1744. o[h] = u
  1745. }
  1746. s[l] = u,
  1747. i[u] ? i[u] = 2 : i[u] = 1
  1748. } else
  1749. s[l] = -1
  1750. }
  1751. for (l = 0; l < i.length; l++)
  1752. switch (i[l]) {
  1753. case 1:
  1754. n.enableVertexAttribArray(l),
  1755. i[l] = 3;
  1756. break;
  1757. case 2:
  1758. i[l] = 3;
  1759. break;
  1760. case 3:
  1761. n.disableVertexAttribArray(l),
  1762. i[l] = 0
  1763. }
  1764. return s
  1765. },
  1766. getAttribLocation: function (e, t) {
  1767. var r = this._locations
  1768. , i = r[t];
  1769. return null == i && (i = e.getAttribLocation(this._program, t),
  1770. r[t] = i),
  1771. i
  1772. },
  1773. buildProgram: function (e, t, r, i) {
  1774. var n = e.createShader(e.VERTEX_SHADER)
  1775. , a = e.createProgram();
  1776. e.shaderSource(n, r),
  1777. e.compileShader(n);
  1778. var o = e.createShader(e.FRAGMENT_SHADER);
  1779. e.shaderSource(o, i),
  1780. e.compileShader(o);
  1781. var s = xe(e, n, r);
  1782. if (s)
  1783. return s;
  1784. if (s = xe(e, o, i))
  1785. return s;
  1786. if (e.attachShader(a, n),
  1787. e.attachShader(a, o),
  1788. t.attributeSemantics.POSITION)
  1789. e.bindAttribLocation(a, 0, t.attributeSemantics.POSITION.symbol);
  1790. else {
  1791. var l = Object.keys(this.attributes);
  1792. e.bindAttribLocation(a, 0, l[0])
  1793. }
  1794. if (e.linkProgram(a),
  1795. e.deleteShader(n),
  1796. e.deleteShader(o),
  1797. this._program = a,
  1798. this.vertexCode = r,
  1799. this.fragmentCode = i,
  1800. !e.getProgramParameter(a, e.LINK_STATUS))
  1801. return "Could not link program\n" + e.getProgramInfoLog(a);
  1802. for (var h = 0; h < t.uniforms.length; h++) {
  1803. var u = t.uniforms[h];
  1804. this._locations[u] = e.getUniformLocation(a, u)
  1805. }
  1806. }
  1807. });
  1808. var Te = /for\s*?\(int\s*?_idx_\s*\=\s*([\w-]+)\;\s*_idx_\s*<\s*([\w-]+);\s*_idx_\s*\+\+\s*\)\s*\{\{([\s\S]+?)(?=\}\})\}\}/g;
  1809. function Se(e, t, r) {
  1810. var i = {};
  1811. for (var n in r)
  1812. i[n + "_COUNT"] = r[n];
  1813. return e.replace(Te, (function (e, r, n, a) {
  1814. var o = "";
  1815. isNaN(r) && (r = r in t ? t[r] : i[r]),
  1816. isNaN(n) && (n = n in t ? t[n] : i[n]);
  1817. for (var s = parseInt(r); s < parseInt(n); s++)
  1818. o += "{" + a.replace(/float\s*\(\s*_idx_\s*\)/g, s.toFixed(1)).replace(/_idx_/g, s) + "}";
  1819. return o
  1820. }
  1821. ))
  1822. }
  1823. function Me(e, t, r) {
  1824. var i = [];
  1825. if (t)
  1826. for (var n in t) {
  1827. var a = t[n];
  1828. a > 0 && i.push("#define " + n.toUpperCase() + "_COUNT " + a)
  1829. }
  1830. if (r)
  1831. for (var o = 0; o < r.length; o++) {
  1832. var s = r[o];
  1833. i.push("#define " + s.toUpperCase() + "_ENABLED")
  1834. }
  1835. for (var s in e) {
  1836. var l = e[s];
  1837. null === l ? i.push("#define " + s) : i.push("#define " + s + " " + l.toString())
  1838. }
  1839. return i.join("\n")
  1840. }
  1841. function Ae(e) {
  1842. this._renderer = e,
  1843. this._cache = {}
  1844. }
  1845. Ae.prototype.getProgram = function (e, t, r) {
  1846. var i = this._cache
  1847. , n = e.isSkinnedMesh && e.isSkinnedMesh()
  1848. , a = e.isInstancedMesh && e.isInstancedMesh()
  1849. , o = "s" + t.shader.shaderID + "m" + t.getProgramKey();
  1850. if (r && (o += "se" + r.getProgramKey(e.lightGroup)),
  1851. n && (o += ",sk" + e.joints.length),
  1852. a && (o += ",is"),
  1853. v = i[o])
  1854. return v;
  1855. var s = r ? r.getLightsNumbers(e.lightGroup) : {}
  1856. , l = this._renderer
  1857. , h = l.gl
  1858. , u = t.getEnabledTextures()
  1859. , c = "";
  1860. if (n) {
  1861. var d = {
  1862. SKINNING: null,
  1863. JOINT_COUNT: e.joints.length
  1864. };
  1865. e.joints.length > l.getMaxJointNumber() && (d.USE_SKIN_MATRICES_TEXTURE = null),
  1866. c += "\n" + Me(d) + "\n"
  1867. }
  1868. a && (c += "\n#define INSTANCING\n");
  1869. var f = c + Me(t.vertexDefines, s, u)
  1870. , p = c + Me(t.fragmentDefines, s, u)
  1871. , m = f + "\n" + t.shader.vertex
  1872. , g = ["OES_standard_derivatives", "EXT_shader_texture_lod"].filter((function (e) {
  1873. return null != l.getGLExtension(e)
  1874. }
  1875. ));
  1876. g.indexOf("EXT_shader_texture_lod") >= 0 && (p += "\n#define SUPPORT_TEXTURE_LOD"),
  1877. g.indexOf("OES_standard_derivatives") >= 0 && (p += "\n#define SUPPORT_STANDARD_DERIVATIVES");
  1878. var _, v, y = function (e) {
  1879. for (var t = [], r = 0; r < e.length; r++)
  1880. t.push("#extension GL_" + e[r] + " : enable");
  1881. return t.join("\n")
  1882. }(g) + "\n" + ["precision", _ = t.precision, "float"].join(" ") + ";\n" + ["precision", _, "int"].join(" ") + ";\n" + ["precision", _, "sampler2D"].join(" ") + ";\n\n" + p + "\n" + t.shader.fragment, x = Se(m, t.vertexDefines, s), b = Se(y, t.fragmentDefines, s);
  1883. (v = new we).uniformSemantics = t.shader.uniformSemantics,
  1884. v.attributes = t.shader.attributes;
  1885. var w = v.buildProgram(h, t.shader, x, b);
  1886. return v.__error = w,
  1887. i[o] = v,
  1888. v
  1889. }
  1890. ;
  1891. const Ee = Ae;
  1892. var Ce = /uniform\s+(bool|float|int|vec2|vec3|vec4|ivec2|ivec3|ivec4|mat2|mat3|mat4|sampler2D|samplerCube)\s+([\s\S]*?);/g
  1893. , De = /attribute\s+(float|int|vec2|vec3|vec4)\s+([\s\S]*?);/g
  1894. , Le = /#define\s+(\w+)?(\s+[\d-.]+)?\s*;?\s*\n/g
  1895. , Pe = {
  1896. bool: "1i",
  1897. int: "1i",
  1898. sampler2D: "t",
  1899. samplerCube: "t",
  1900. float: "1f",
  1901. vec2: "2f",
  1902. vec3: "3f",
  1903. vec4: "4f",
  1904. ivec2: "2i",
  1905. ivec3: "3i",
  1906. ivec4: "4i",
  1907. mat2: "m2",
  1908. mat3: "m3",
  1909. mat4: "m4"
  1910. };
  1911. function Oe(e) {
  1912. for (var t = [], r = 0; r < e; r++)
  1913. t[r] = 0;
  1914. return t
  1915. }
  1916. var Ne = {
  1917. bool: function () {
  1918. return !0
  1919. },
  1920. int: function () {
  1921. return 0
  1922. },
  1923. float: function () {
  1924. return 0
  1925. },
  1926. sampler2D: function () {
  1927. return null
  1928. },
  1929. samplerCube: function () {
  1930. return null
  1931. },
  1932. vec2: function () {
  1933. return Oe(2)
  1934. },
  1935. vec3: function () {
  1936. return Oe(3)
  1937. },
  1938. vec4: function () {
  1939. return Oe(4)
  1940. },
  1941. ivec2: function () {
  1942. return Oe(2)
  1943. },
  1944. ivec3: function () {
  1945. return Oe(3)
  1946. },
  1947. ivec4: function () {
  1948. return Oe(4)
  1949. },
  1950. mat2: function () {
  1951. return Oe(4)
  1952. },
  1953. mat3: function () {
  1954. return Oe(9)
  1955. },
  1956. mat4: function () {
  1957. return Oe(16)
  1958. },
  1959. array: function () {
  1960. return []
  1961. }
  1962. }
  1963. , Ie = ["POSITION", "NORMAL", "BINORMAL", "TANGENT", "TEXCOORD", "TEXCOORD_0", "TEXCOORD_1", "COLOR", "JOINT", "WEIGHT"]
  1964. , Re = ["SKIN_MATRIX", "VIEWPORT_SIZE", "VIEWPORT", "DEVICEPIXELRATIO", "WINDOW_SIZE", "NEAR", "FAR", "TIME"]
  1965. , Be = ["WORLD", "VIEW", "PROJECTION", "WORLDVIEW", "VIEWPROJECTION", "WORLDVIEWPROJECTION", "WORLDINVERSE", "VIEWINVERSE", "PROJECTIONINVERSE", "WORLDVIEWINVERSE", "VIEWPROJECTIONINVERSE", "WORLDVIEWPROJECTIONINVERSE", "WORLDTRANSPOSE", "VIEWTRANSPOSE", "PROJECTIONTRANSPOSE", "WORLDVIEWTRANSPOSE", "VIEWPROJECTIONTRANSPOSE", "WORLDVIEWPROJECTIONTRANSPOSE", "WORLDINVERSETRANSPOSE", "VIEWINVERSETRANSPOSE", "PROJECTIONINVERSETRANSPOSE", "WORLDVIEWINVERSETRANSPOSE", "VIEWPROJECTIONINVERSETRANSPOSE", "WORLDVIEWPROJECTIONINVERSETRANSPOSE"]
  1966. , Fe = {
  1967. vec4: 4,
  1968. vec3: 3,
  1969. vec2: 2,
  1970. float: 1
  1971. }
  1972. , ze = {}
  1973. , Ge = {};
  1974. function Ue(e) {
  1975. return e.replace(/[ \t]*\/\/.*\n/g, "").replace(/[ \t]*\/\*[\s\S]*?\*\//g, "")
  1976. }
  1977. function ke() {
  1978. console.error("Wrong uniform/attributes syntax")
  1979. }
  1980. function Ve(e, t) {
  1981. for (var r = /[,=\(\):]/, i = t.replace(/:\s*\[\s*(.*)\s*\]/g, "=" + e + "($1)").replace(/\s+/g, "").split(/(?=[,=\(\):])/g), n = [], a = 0; a < i.length; a++)
  1982. i[a].match(r) ? n.push(i[a].charAt(0), i[a].slice(1)) : n.push(i[a]);
  1983. var o, s = 0, l = {}, h = null;
  1984. function u(e) {
  1985. e || ke();
  1986. var t = e.match(/\[(.*?)\]/);
  1987. o = e.replace(/\[(.*?)\]/, ""),
  1988. l[o] = {},
  1989. t && (l[o].isArray = !0,
  1990. l[o].arraySize = t[1])
  1991. }
  1992. for (u((i = n)[0]),
  1993. a = 1; a < i.length; a++) {
  1994. var c = i[a];
  1995. if (c)
  1996. if ("=" !== c)
  1997. if (":" !== c)
  1998. if ("," !== c)
  1999. if (")" !== c)
  2000. if ("(" !== c)
  2001. if (c.indexOf("vec") >= 0) {
  2002. if (1 !== s && 4 !== s) {
  2003. ke();
  2004. break
  2005. }
  2006. s = 2,
  2007. h = []
  2008. } else if (1 !== s)
  2009. if (4 !== s)
  2010. u(c),
  2011. s = 0;
  2012. else {
  2013. var d = c;
  2014. Ie.indexOf(d) >= 0 || Re.indexOf(d) >= 0 || Be.indexOf(d) >= 0 ? l[o].semantic = d : "ignore" === d || "unconfigurable" === d ? l[o].ignore = !0 : l[o].value = "bool" === e ? "true" === d : parseFloat(d)
  2015. }
  2016. else
  2017. l[o].value = "bool" === e ? "true" === c : parseFloat(c),
  2018. h = null;
  2019. else {
  2020. if (2 !== s) {
  2021. ke();
  2022. break
  2023. }
  2024. if (!(h instanceof Array)) {
  2025. ke();
  2026. break
  2027. }
  2028. h.push(+i[++a])
  2029. }
  2030. else
  2031. l[o].value = new U.Float32Array(h),
  2032. h = null,
  2033. s = 5;
  2034. else if (2 === s) {
  2035. if (!(h instanceof Array)) {
  2036. ke();
  2037. break
  2038. }
  2039. h.push(+i[++a])
  2040. } else
  2041. s = 5;
  2042. else
  2043. s = 4;
  2044. else {
  2045. if (0 !== s && 3 !== s) {
  2046. ke();
  2047. break
  2048. }
  2049. s = 1
  2050. }
  2051. }
  2052. return l
  2053. }
  2054. function He(e, t) {
  2055. "object" == typeof e && (t = e.fragment,
  2056. e = e.vertex),
  2057. e = Ue(e),
  2058. t = Ue(t),
  2059. this._shaderID = function (e, t) {
  2060. var r = "vertex:" + e + "fragment:" + t;
  2061. if (ze[r])
  2062. return ze[r];
  2063. var i = f.genGUID();
  2064. return ze[r] = i,
  2065. Ge[i] = {
  2066. vertex: e,
  2067. fragment: t
  2068. },
  2069. i
  2070. }(e, t),
  2071. this._vertexCode = He.parseImport(e),
  2072. this._fragmentCode = He.parseImport(t),
  2073. this.attributeSemantics = {},
  2074. this.matrixSemantics = {},
  2075. this.uniformSemantics = {},
  2076. this.matrixSemanticKeys = [],
  2077. this.uniformTemplates = {},
  2078. this.attributes = {},
  2079. this.textures = {},
  2080. this.vertexDefines = {},
  2081. this.fragmentDefines = {},
  2082. this._parseAttributes(),
  2083. this._parseUniforms(),
  2084. this._parseDefines()
  2085. }
  2086. He.prototype = {
  2087. constructor: He,
  2088. createUniforms: function () {
  2089. var e = {};
  2090. for (var t in this.uniformTemplates) {
  2091. var r = this.uniformTemplates[t];
  2092. e[t] = {
  2093. type: r.type,
  2094. value: r.value()
  2095. }
  2096. }
  2097. return e
  2098. },
  2099. _parseImport: function () {
  2100. this._vertexCode = He.parseImport(this.vertex),
  2101. this._fragmentCode = He.parseImport(this.fragment)
  2102. },
  2103. _addSemanticUniform: function (e, t, r) {
  2104. if (Ie.indexOf(r) >= 0)
  2105. this.attributeSemantics[r] = {
  2106. symbol: e,
  2107. type: t
  2108. };
  2109. else if (Be.indexOf(r) >= 0) {
  2110. var i = !1
  2111. , n = r;
  2112. r.match(/TRANSPOSE$/) && (i = !0,
  2113. n = r.slice(0, -9)),
  2114. this.matrixSemantics[r] = {
  2115. symbol: e,
  2116. type: t,
  2117. isTranspose: i,
  2118. semanticNoTranspose: n
  2119. }
  2120. } else
  2121. Re.indexOf(r) >= 0 && (this.uniformSemantics[r] = {
  2122. symbol: e,
  2123. type: t
  2124. })
  2125. },
  2126. _addMaterialUniform: function (e, t, r, i, n, a) {
  2127. a[e] = {
  2128. type: r,
  2129. value: n ? Ne.array : i || Ne[t],
  2130. semantic: null
  2131. }
  2132. },
  2133. _parseUniforms: function () {
  2134. var e = {}
  2135. , t = this;
  2136. function r(e) {
  2137. return null != e ? function () {
  2138. return e
  2139. }
  2140. : null
  2141. }
  2142. function i(i, n, a) {
  2143. var o = Ve(n, a)
  2144. , s = [];
  2145. for (var l in o) {
  2146. var h = o[l]
  2147. , u = h.semantic
  2148. , c = l
  2149. , d = Pe[n]
  2150. , f = r(o[l].value);
  2151. o[l].isArray && (c += "[" + o[l].arraySize + "]",
  2152. d += "v"),
  2153. s.push(c),
  2154. t._uniformList.push(l),
  2155. h.ignore || ("sampler2D" !== n && "samplerCube" !== n || (t.textures[l] = {
  2156. shaderType: "fragment",
  2157. type: n
  2158. }),
  2159. u ? t._addSemanticUniform(l, d, u) : t._addMaterialUniform(l, n, d, f, o[l].isArray, e))
  2160. }
  2161. return s.length > 0 ? "uniform " + n + " " + s.join(",") + ";\n" : ""
  2162. }
  2163. this._uniformList = [],
  2164. this._vertexCode = this._vertexCode.replace(Ce, i),
  2165. this._fragmentCode = this._fragmentCode.replace(Ce, i),
  2166. t.matrixSemanticKeys = Object.keys(this.matrixSemantics),
  2167. this.uniformTemplates = e
  2168. },
  2169. _parseAttributes: function () {
  2170. var e = {}
  2171. , t = this;
  2172. this._vertexCode = this._vertexCode.replace(De, (function (r, i, n) {
  2173. var a = Ve(i, n)
  2174. , o = Fe[i] || 1
  2175. , s = [];
  2176. for (var l in a) {
  2177. var h = a[l].semantic;
  2178. if (e[l] = {
  2179. type: "float",
  2180. size: o,
  2181. semantic: h || null
  2182. },
  2183. h) {
  2184. if (Ie.indexOf(h) < 0)
  2185. throw new Error('Unkown semantic "' + h + '"');
  2186. t.attributeSemantics[h] = {
  2187. symbol: l,
  2188. type: i
  2189. }
  2190. }
  2191. s.push(l)
  2192. }
  2193. return "attribute " + i + " " + s.join(",") + ";\n"
  2194. }
  2195. )),
  2196. this.attributes = e
  2197. },
  2198. _parseDefines: function () {
  2199. var e = this;
  2200. function t(t, r, i) {
  2201. var n = e.fragmentDefines;
  2202. return n[r] || (n[r] = "false" !== i && ("true" === i || (i ? isNaN(parseFloat(i)) ? i.trim() : parseFloat(i) : null))),
  2203. ""
  2204. }
  2205. this._vertexCode = this._vertexCode.replace(Le, t),
  2206. this._fragmentCode = this._fragmentCode.replace(Le, t)
  2207. },
  2208. clone: function () {
  2209. var e = Ge[this._shaderID];
  2210. return new He(e.vertex, e.fragment)
  2211. }
  2212. },
  2213. Object.defineProperty && (Object.defineProperty(He.prototype, "shaderID", {
  2214. get: function () {
  2215. return this._shaderID
  2216. }
  2217. }),
  2218. Object.defineProperty(He.prototype, "vertex", {
  2219. get: function () {
  2220. return this._vertexCode
  2221. }
  2222. }),
  2223. Object.defineProperty(He.prototype, "fragment", {
  2224. get: function () {
  2225. return this._fragmentCode
  2226. }
  2227. }),
  2228. Object.defineProperty(He.prototype, "uniforms", {
  2229. get: function () {
  2230. return this._uniformList
  2231. }
  2232. }));
  2233. var We = /(@import)\s*([0-9a-zA-Z_\-\.]*)/g;
  2234. He.parseImport = function (e) {
  2235. return e.replace(We, (function (e, t, r) {
  2236. return (e = He.source(r)) ? He.parseImport(e) : (console.error('Shader chunk "' + r + '" not existed in library'),
  2237. "")
  2238. }
  2239. ))
  2240. }
  2241. ;
  2242. var je = /(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g;
  2243. He.import = function (e) {
  2244. e.replace(je, (function (e, t, r, i) {
  2245. if (i = i.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g, "")) {
  2246. for (var n, a = r.split("."), o = He.codes, s = 0; s < a.length - 1;)
  2247. o[n = a[s++]] || (o[n] = {}),
  2248. o = o[n];
  2249. o[n = a[s]] = i
  2250. }
  2251. return i
  2252. }
  2253. ))
  2254. }
  2255. ,
  2256. He.codes = {},
  2257. He.source = function (e) {
  2258. for (var t = e.split("."), r = He.codes, i = 0; r && i < t.length;)
  2259. r = r[t[i++]];
  2260. return "string" != typeof r ? (console.error('Shader "' + e + '" not existed in library'),
  2261. "") : r
  2262. }
  2263. ;
  2264. const Xe = He
  2265. , qe = "@export clay.prez.vertex\nuniform mat4 WVP : WORLDVIEWPROJECTION;\nattribute vec3 pos : POSITION;\nattribute vec2 uv : TEXCOORD_0;\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec2 v_Texcoord;\nvoid main()\n{\n vec4 P = vec4(pos, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n gl_Position = WVP * P;\n v_Texcoord = uv * uvRepeat + uvOffset;\n}\n@end\n@export clay.prez.fragment\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n gl_FragColor = vec4(0.0,0.0,0.0,1.0);\n}\n@end";
  2266. var Ze = {
  2267. create: function () {
  2268. var e = new ce(16);
  2269. return e[0] = 1,
  2270. e[1] = 0,
  2271. e[2] = 0,
  2272. e[3] = 0,
  2273. e[4] = 0,
  2274. e[5] = 1,
  2275. e[6] = 0,
  2276. e[7] = 0,
  2277. e[8] = 0,
  2278. e[9] = 0,
  2279. e[10] = 1,
  2280. e[11] = 0,
  2281. e[12] = 0,
  2282. e[13] = 0,
  2283. e[14] = 0,
  2284. e[15] = 1,
  2285. e
  2286. },
  2287. clone: function (e) {
  2288. var t = new ce(16);
  2289. return t[0] = e[0],
  2290. t[1] = e[1],
  2291. t[2] = e[2],
  2292. t[3] = e[3],
  2293. t[4] = e[4],
  2294. t[5] = e[5],
  2295. t[6] = e[6],
  2296. t[7] = e[7],
  2297. t[8] = e[8],
  2298. t[9] = e[9],
  2299. t[10] = e[10],
  2300. t[11] = e[11],
  2301. t[12] = e[12],
  2302. t[13] = e[13],
  2303. t[14] = e[14],
  2304. t[15] = e[15],
  2305. t
  2306. },
  2307. copy: function (e, t) {
  2308. return e[0] = t[0],
  2309. e[1] = t[1],
  2310. e[2] = t[2],
  2311. e[3] = t[3],
  2312. e[4] = t[4],
  2313. e[5] = t[5],
  2314. e[6] = t[6],
  2315. e[7] = t[7],
  2316. e[8] = t[8],
  2317. e[9] = t[9],
  2318. e[10] = t[10],
  2319. e[11] = t[11],
  2320. e[12] = t[12],
  2321. e[13] = t[13],
  2322. e[14] = t[14],
  2323. e[15] = t[15],
  2324. e
  2325. },
  2326. identity: function (e) {
  2327. return e[0] = 1,
  2328. e[1] = 0,
  2329. e[2] = 0,
  2330. e[3] = 0,
  2331. e[4] = 0,
  2332. e[5] = 1,
  2333. e[6] = 0,
  2334. e[7] = 0,
  2335. e[8] = 0,
  2336. e[9] = 0,
  2337. e[10] = 1,
  2338. e[11] = 0,
  2339. e[12] = 0,
  2340. e[13] = 0,
  2341. e[14] = 0,
  2342. e[15] = 1,
  2343. e
  2344. },
  2345. transpose: function (e, t) {
  2346. if (e === t) {
  2347. var r = t[1]
  2348. , i = t[2]
  2349. , n = t[3]
  2350. , a = t[6]
  2351. , o = t[7]
  2352. , s = t[11];
  2353. e[1] = t[4],
  2354. e[2] = t[8],
  2355. e[3] = t[12],
  2356. e[4] = r,
  2357. e[6] = t[9],
  2358. e[7] = t[13],
  2359. e[8] = i,
  2360. e[9] = a,
  2361. e[11] = t[14],
  2362. e[12] = n,
  2363. e[13] = o,
  2364. e[14] = s
  2365. } else
  2366. e[0] = t[0],
  2367. e[1] = t[4],
  2368. e[2] = t[8],
  2369. e[3] = t[12],
  2370. e[4] = t[1],
  2371. e[5] = t[5],
  2372. e[6] = t[9],
  2373. e[7] = t[13],
  2374. e[8] = t[2],
  2375. e[9] = t[6],
  2376. e[10] = t[10],
  2377. e[11] = t[14],
  2378. e[12] = t[3],
  2379. e[13] = t[7],
  2380. e[14] = t[11],
  2381. e[15] = t[15];
  2382. return e
  2383. },
  2384. invert: function (e, t) {
  2385. var r = t[0]
  2386. , i = t[1]
  2387. , n = t[2]
  2388. , a = t[3]
  2389. , o = t[4]
  2390. , s = t[5]
  2391. , l = t[6]
  2392. , h = t[7]
  2393. , u = t[8]
  2394. , c = t[9]
  2395. , d = t[10]
  2396. , f = t[11]
  2397. , p = t[12]
  2398. , m = t[13]
  2399. , g = t[14]
  2400. , _ = t[15]
  2401. , v = r * s - i * o
  2402. , y = r * l - n * o
  2403. , x = r * h - a * o
  2404. , b = i * l - n * s
  2405. , w = i * h - a * s
  2406. , T = n * h - a * l
  2407. , S = u * m - c * p
  2408. , M = u * g - d * p
  2409. , A = u * _ - f * p
  2410. , E = c * g - d * m
  2411. , C = c * _ - f * m
  2412. , D = d * _ - f * g
  2413. , L = v * D - y * C + x * E + b * A - w * M + T * S;
  2414. return L ? (L = 1 / L,
  2415. e[0] = (s * D - l * C + h * E) * L,
  2416. e[1] = (n * C - i * D - a * E) * L,
  2417. e[2] = (m * T - g * w + _ * b) * L,
  2418. e[3] = (d * w - c * T - f * b) * L,
  2419. e[4] = (l * A - o * D - h * M) * L,
  2420. e[5] = (r * D - n * A + a * M) * L,
  2421. e[6] = (g * x - p * T - _ * y) * L,
  2422. e[7] = (u * T - d * x + f * y) * L,
  2423. e[8] = (o * C - s * A + h * S) * L,
  2424. e[9] = (i * A - r * C - a * S) * L,
  2425. e[10] = (p * w - m * x + _ * v) * L,
  2426. e[11] = (c * x - u * w - f * v) * L,
  2427. e[12] = (s * M - o * E - l * S) * L,
  2428. e[13] = (r * E - i * M + n * S) * L,
  2429. e[14] = (m * y - p * b - g * v) * L,
  2430. e[15] = (u * b - c * y + d * v) * L,
  2431. e) : null
  2432. },
  2433. adjoint: function (e, t) {
  2434. var r = t[0]
  2435. , i = t[1]
  2436. , n = t[2]
  2437. , a = t[3]
  2438. , o = t[4]
  2439. , s = t[5]
  2440. , l = t[6]
  2441. , h = t[7]
  2442. , u = t[8]
  2443. , c = t[9]
  2444. , d = t[10]
  2445. , f = t[11]
  2446. , p = t[12]
  2447. , m = t[13]
  2448. , g = t[14]
  2449. , _ = t[15];
  2450. return e[0] = s * (d * _ - f * g) - c * (l * _ - h * g) + m * (l * f - h * d),
  2451. e[1] = -(i * (d * _ - f * g) - c * (n * _ - a * g) + m * (n * f - a * d)),
  2452. e[2] = i * (l * _ - h * g) - s * (n * _ - a * g) + m * (n * h - a * l),
  2453. e[3] = -(i * (l * f - h * d) - s * (n * f - a * d) + c * (n * h - a * l)),
  2454. e[4] = -(o * (d * _ - f * g) - u * (l * _ - h * g) + p * (l * f - h * d)),
  2455. e[5] = r * (d * _ - f * g) - u * (n * _ - a * g) + p * (n * f - a * d),
  2456. e[6] = -(r * (l * _ - h * g) - o * (n * _ - a * g) + p * (n * h - a * l)),
  2457. e[7] = r * (l * f - h * d) - o * (n * f - a * d) + u * (n * h - a * l),
  2458. e[8] = o * (c * _ - f * m) - u * (s * _ - h * m) + p * (s * f - h * c),
  2459. e[9] = -(r * (c * _ - f * m) - u * (i * _ - a * m) + p * (i * f - a * c)),
  2460. e[10] = r * (s * _ - h * m) - o * (i * _ - a * m) + p * (i * h - a * s),
  2461. e[11] = -(r * (s * f - h * c) - o * (i * f - a * c) + u * (i * h - a * s)),
  2462. e[12] = -(o * (c * g - d * m) - u * (s * g - l * m) + p * (s * d - l * c)),
  2463. e[13] = r * (c * g - d * m) - u * (i * g - n * m) + p * (i * d - n * c),
  2464. e[14] = -(r * (s * g - l * m) - o * (i * g - n * m) + p * (i * l - n * s)),
  2465. e[15] = r * (s * d - l * c) - o * (i * d - n * c) + u * (i * l - n * s),
  2466. e
  2467. },
  2468. determinant: function (e) {
  2469. var t = e[0]
  2470. , r = e[1]
  2471. , i = e[2]
  2472. , n = e[3]
  2473. , a = e[4]
  2474. , o = e[5]
  2475. , s = e[6]
  2476. , l = e[7]
  2477. , h = e[8]
  2478. , u = e[9]
  2479. , c = e[10]
  2480. , d = e[11]
  2481. , f = e[12]
  2482. , p = e[13]
  2483. , m = e[14]
  2484. , g = e[15];
  2485. return (t * o - r * a) * (c * g - d * m) - (t * s - i * a) * (u * g - d * p) + (t * l - n * a) * (u * m - c * p) + (r * s - i * o) * (h * g - d * f) - (r * l - n * o) * (h * m - c * f) + (i * l - n * s) * (h * p - u * f)
  2486. },
  2487. multiply: function (e, t, r) {
  2488. var i = t[0]
  2489. , n = t[1]
  2490. , a = t[2]
  2491. , o = t[3]
  2492. , s = t[4]
  2493. , l = t[5]
  2494. , h = t[6]
  2495. , u = t[7]
  2496. , c = t[8]
  2497. , d = t[9]
  2498. , f = t[10]
  2499. , p = t[11]
  2500. , m = t[12]
  2501. , g = t[13]
  2502. , _ = t[14]
  2503. , v = t[15]
  2504. , y = r[0]
  2505. , x = r[1]
  2506. , b = r[2]
  2507. , w = r[3];
  2508. return e[0] = y * i + x * s + b * c + w * m,
  2509. e[1] = y * n + x * l + b * d + w * g,
  2510. e[2] = y * a + x * h + b * f + w * _,
  2511. e[3] = y * o + x * u + b * p + w * v,
  2512. y = r[4],
  2513. x = r[5],
  2514. b = r[6],
  2515. w = r[7],
  2516. e[4] = y * i + x * s + b * c + w * m,
  2517. e[5] = y * n + x * l + b * d + w * g,
  2518. e[6] = y * a + x * h + b * f + w * _,
  2519. e[7] = y * o + x * u + b * p + w * v,
  2520. y = r[8],
  2521. x = r[9],
  2522. b = r[10],
  2523. w = r[11],
  2524. e[8] = y * i + x * s + b * c + w * m,
  2525. e[9] = y * n + x * l + b * d + w * g,
  2526. e[10] = y * a + x * h + b * f + w * _,
  2527. e[11] = y * o + x * u + b * p + w * v,
  2528. y = r[12],
  2529. x = r[13],
  2530. b = r[14],
  2531. w = r[15],
  2532. e[12] = y * i + x * s + b * c + w * m,
  2533. e[13] = y * n + x * l + b * d + w * g,
  2534. e[14] = y * a + x * h + b * f + w * _,
  2535. e[15] = y * o + x * u + b * p + w * v,
  2536. e
  2537. },
  2538. multiplyAffine: function (e, t, r) {
  2539. var i = t[0]
  2540. , n = t[1]
  2541. , a = t[2]
  2542. , o = t[4]
  2543. , s = t[5]
  2544. , l = t[6]
  2545. , h = t[8]
  2546. , u = t[9]
  2547. , c = t[10]
  2548. , d = t[12]
  2549. , f = t[13]
  2550. , p = t[14]
  2551. , m = r[0]
  2552. , g = r[1]
  2553. , _ = r[2];
  2554. return e[0] = m * i + g * o + _ * h,
  2555. e[1] = m * n + g * s + _ * u,
  2556. e[2] = m * a + g * l + _ * c,
  2557. m = r[4],
  2558. g = r[5],
  2559. _ = r[6],
  2560. e[4] = m * i + g * o + _ * h,
  2561. e[5] = m * n + g * s + _ * u,
  2562. e[6] = m * a + g * l + _ * c,
  2563. m = r[8],
  2564. g = r[9],
  2565. _ = r[10],
  2566. e[8] = m * i + g * o + _ * h,
  2567. e[9] = m * n + g * s + _ * u,
  2568. e[10] = m * a + g * l + _ * c,
  2569. m = r[12],
  2570. g = r[13],
  2571. _ = r[14],
  2572. e[12] = m * i + g * o + _ * h + d,
  2573. e[13] = m * n + g * s + _ * u + f,
  2574. e[14] = m * a + g * l + _ * c + p,
  2575. e
  2576. }
  2577. };
  2578. Ze.mul = Ze.multiply,
  2579. Ze.mulAffine = Ze.multiplyAffine,
  2580. Ze.translate = function (e, t, r) {
  2581. var i, n, a, o, s, l, h, u, c, d, f, p, m = r[0], g = r[1], _ = r[2];
  2582. return t === e ? (e[12] = t[0] * m + t[4] * g + t[8] * _ + t[12],
  2583. e[13] = t[1] * m + t[5] * g + t[9] * _ + t[13],
  2584. e[14] = t[2] * m + t[6] * g + t[10] * _ + t[14],
  2585. e[15] = t[3] * m + t[7] * g + t[11] * _ + t[15]) : (i = t[0],
  2586. n = t[1],
  2587. a = t[2],
  2588. o = t[3],
  2589. s = t[4],
  2590. l = t[5],
  2591. h = t[6],
  2592. u = t[7],
  2593. c = t[8],
  2594. d = t[9],
  2595. f = t[10],
  2596. p = t[11],
  2597. e[0] = i,
  2598. e[1] = n,
  2599. e[2] = a,
  2600. e[3] = o,
  2601. e[4] = s,
  2602. e[5] = l,
  2603. e[6] = h,
  2604. e[7] = u,
  2605. e[8] = c,
  2606. e[9] = d,
  2607. e[10] = f,
  2608. e[11] = p,
  2609. e[12] = i * m + s * g + c * _ + t[12],
  2610. e[13] = n * m + l * g + d * _ + t[13],
  2611. e[14] = a * m + h * g + f * _ + t[14],
  2612. e[15] = o * m + u * g + p * _ + t[15]),
  2613. e
  2614. }
  2615. ,
  2616. Ze.scale = function (e, t, r) {
  2617. var i = r[0]
  2618. , n = r[1]
  2619. , a = r[2];
  2620. return e[0] = t[0] * i,
  2621. e[1] = t[1] * i,
  2622. e[2] = t[2] * i,
  2623. e[3] = t[3] * i,
  2624. e[4] = t[4] * n,
  2625. e[5] = t[5] * n,
  2626. e[6] = t[6] * n,
  2627. e[7] = t[7] * n,
  2628. e[8] = t[8] * a,
  2629. e[9] = t[9] * a,
  2630. e[10] = t[10] * a,
  2631. e[11] = t[11] * a,
  2632. e[12] = t[12],
  2633. e[13] = t[13],
  2634. e[14] = t[14],
  2635. e[15] = t[15],
  2636. e
  2637. }
  2638. ,
  2639. Ze.rotate = function (e, t, r, i) {
  2640. var n, a, o, s, l, h, u, c, d, f, p, m, g, _, v, y, x, b, w, T, S, M, A, E, C = i[0], D = i[1], L = i[2], P = Math.sqrt(C * C + D * D + L * L);
  2641. return Math.abs(P) < ue ? null : (C *= P = 1 / P,
  2642. D *= P,
  2643. L *= P,
  2644. n = Math.sin(r),
  2645. o = 1 - (a = Math.cos(r)),
  2646. s = t[0],
  2647. l = t[1],
  2648. h = t[2],
  2649. u = t[3],
  2650. c = t[4],
  2651. d = t[5],
  2652. f = t[6],
  2653. p = t[7],
  2654. m = t[8],
  2655. g = t[9],
  2656. _ = t[10],
  2657. v = t[11],
  2658. y = C * C * o + a,
  2659. x = D * C * o + L * n,
  2660. b = L * C * o - D * n,
  2661. w = C * D * o - L * n,
  2662. T = D * D * o + a,
  2663. S = L * D * o + C * n,
  2664. M = C * L * o + D * n,
  2665. A = D * L * o - C * n,
  2666. E = L * L * o + a,
  2667. e[0] = s * y + c * x + m * b,
  2668. e[1] = l * y + d * x + g * b,
  2669. e[2] = h * y + f * x + _ * b,
  2670. e[3] = u * y + p * x + v * b,
  2671. e[4] = s * w + c * T + m * S,
  2672. e[5] = l * w + d * T + g * S,
  2673. e[6] = h * w + f * T + _ * S,
  2674. e[7] = u * w + p * T + v * S,
  2675. e[8] = s * M + c * A + m * E,
  2676. e[9] = l * M + d * A + g * E,
  2677. e[10] = h * M + f * A + _ * E,
  2678. e[11] = u * M + p * A + v * E,
  2679. t !== e && (e[12] = t[12],
  2680. e[13] = t[13],
  2681. e[14] = t[14],
  2682. e[15] = t[15]),
  2683. e)
  2684. }
  2685. ,
  2686. Ze.rotateX = function (e, t, r) {
  2687. var i = Math.sin(r)
  2688. , n = Math.cos(r)
  2689. , a = t[4]
  2690. , o = t[5]
  2691. , s = t[6]
  2692. , l = t[7]
  2693. , h = t[8]
  2694. , u = t[9]
  2695. , c = t[10]
  2696. , d = t[11];
  2697. return t !== e && (e[0] = t[0],
  2698. e[1] = t[1],
  2699. e[2] = t[2],
  2700. e[3] = t[3],
  2701. e[12] = t[12],
  2702. e[13] = t[13],
  2703. e[14] = t[14],
  2704. e[15] = t[15]),
  2705. e[4] = a * n + h * i,
  2706. e[5] = o * n + u * i,
  2707. e[6] = s * n + c * i,
  2708. e[7] = l * n + d * i,
  2709. e[8] = h * n - a * i,
  2710. e[9] = u * n - o * i,
  2711. e[10] = c * n - s * i,
  2712. e[11] = d * n - l * i,
  2713. e
  2714. }
  2715. ,
  2716. Ze.rotateY = function (e, t, r) {
  2717. var i = Math.sin(r)
  2718. , n = Math.cos(r)
  2719. , a = t[0]
  2720. , o = t[1]
  2721. , s = t[2]
  2722. , l = t[3]
  2723. , h = t[8]
  2724. , u = t[9]
  2725. , c = t[10]
  2726. , d = t[11];
  2727. return t !== e && (e[4] = t[4],
  2728. e[5] = t[5],
  2729. e[6] = t[6],
  2730. e[7] = t[7],
  2731. e[12] = t[12],
  2732. e[13] = t[13],
  2733. e[14] = t[14],
  2734. e[15] = t[15]),
  2735. e[0] = a * n - h * i,
  2736. e[1] = o * n - u * i,
  2737. e[2] = s * n - c * i,
  2738. e[3] = l * n - d * i,
  2739. e[8] = a * i + h * n,
  2740. e[9] = o * i + u * n,
  2741. e[10] = s * i + c * n,
  2742. e[11] = l * i + d * n,
  2743. e
  2744. }
  2745. ,
  2746. Ze.rotateZ = function (e, t, r) {
  2747. var i = Math.sin(r)
  2748. , n = Math.cos(r)
  2749. , a = t[0]
  2750. , o = t[1]
  2751. , s = t[2]
  2752. , l = t[3]
  2753. , h = t[4]
  2754. , u = t[5]
  2755. , c = t[6]
  2756. , d = t[7];
  2757. return t !== e && (e[8] = t[8],
  2758. e[9] = t[9],
  2759. e[10] = t[10],
  2760. e[11] = t[11],
  2761. e[12] = t[12],
  2762. e[13] = t[13],
  2763. e[14] = t[14],
  2764. e[15] = t[15]),
  2765. e[0] = a * n + h * i,
  2766. e[1] = o * n + u * i,
  2767. e[2] = s * n + c * i,
  2768. e[3] = l * n + d * i,
  2769. e[4] = h * n - a * i,
  2770. e[5] = u * n - o * i,
  2771. e[6] = c * n - s * i,
  2772. e[7] = d * n - l * i,
  2773. e
  2774. }
  2775. ,
  2776. Ze.fromRotationTranslation = function (e, t, r) {
  2777. var i = t[0]
  2778. , n = t[1]
  2779. , a = t[2]
  2780. , o = t[3]
  2781. , s = i + i
  2782. , l = n + n
  2783. , h = a + a
  2784. , u = i * s
  2785. , c = i * l
  2786. , d = i * h
  2787. , f = n * l
  2788. , p = n * h
  2789. , m = a * h
  2790. , g = o * s
  2791. , _ = o * l
  2792. , v = o * h;
  2793. return e[0] = 1 - (f + m),
  2794. e[1] = c + v,
  2795. e[2] = d - _,
  2796. e[3] = 0,
  2797. e[4] = c - v,
  2798. e[5] = 1 - (u + m),
  2799. e[6] = p + g,
  2800. e[7] = 0,
  2801. e[8] = d + _,
  2802. e[9] = p - g,
  2803. e[10] = 1 - (u + f),
  2804. e[11] = 0,
  2805. e[12] = r[0],
  2806. e[13] = r[1],
  2807. e[14] = r[2],
  2808. e[15] = 1,
  2809. e
  2810. }
  2811. ,
  2812. Ze.fromQuat = function (e, t) {
  2813. var r = t[0]
  2814. , i = t[1]
  2815. , n = t[2]
  2816. , a = t[3]
  2817. , o = r + r
  2818. , s = i + i
  2819. , l = n + n
  2820. , h = r * o
  2821. , u = i * o
  2822. , c = i * s
  2823. , d = n * o
  2824. , f = n * s
  2825. , p = n * l
  2826. , m = a * o
  2827. , g = a * s
  2828. , _ = a * l;
  2829. return e[0] = 1 - c - p,
  2830. e[1] = u + _,
  2831. e[2] = d - g,
  2832. e[3] = 0,
  2833. e[4] = u - _,
  2834. e[5] = 1 - h - p,
  2835. e[6] = f + m,
  2836. e[7] = 0,
  2837. e[8] = d + g,
  2838. e[9] = f - m,
  2839. e[10] = 1 - h - c,
  2840. e[11] = 0,
  2841. e[12] = 0,
  2842. e[13] = 0,
  2843. e[14] = 0,
  2844. e[15] = 1,
  2845. e
  2846. }
  2847. ,
  2848. Ze.frustum = function (e, t, r, i, n, a, o) {
  2849. var s = 1 / (r - t)
  2850. , l = 1 / (n - i)
  2851. , h = 1 / (a - o);
  2852. return e[0] = 2 * a * s,
  2853. e[1] = 0,
  2854. e[2] = 0,
  2855. e[3] = 0,
  2856. e[4] = 0,
  2857. e[5] = 2 * a * l,
  2858. e[6] = 0,
  2859. e[7] = 0,
  2860. e[8] = (r + t) * s,
  2861. e[9] = (n + i) * l,
  2862. e[10] = (o + a) * h,
  2863. e[11] = -1,
  2864. e[12] = 0,
  2865. e[13] = 0,
  2866. e[14] = o * a * 2 * h,
  2867. e[15] = 0,
  2868. e
  2869. }
  2870. ,
  2871. Ze.perspective = function (e, t, r, i, n) {
  2872. var a = 1 / Math.tan(t / 2)
  2873. , o = 1 / (i - n);
  2874. return e[0] = a / r,
  2875. e[1] = 0,
  2876. e[2] = 0,
  2877. e[3] = 0,
  2878. e[4] = 0,
  2879. e[5] = a,
  2880. e[6] = 0,
  2881. e[7] = 0,
  2882. e[8] = 0,
  2883. e[9] = 0,
  2884. e[10] = (n + i) * o,
  2885. e[11] = -1,
  2886. e[12] = 0,
  2887. e[13] = 0,
  2888. e[14] = 2 * n * i * o,
  2889. e[15] = 0,
  2890. e
  2891. }
  2892. ,
  2893. Ze.ortho = function (e, t, r, i, n, a, o) {
  2894. var s = 1 / (t - r)
  2895. , l = 1 / (i - n)
  2896. , h = 1 / (a - o);
  2897. return e[0] = -2 * s,
  2898. e[1] = 0,
  2899. e[2] = 0,
  2900. e[3] = 0,
  2901. e[4] = 0,
  2902. e[5] = -2 * l,
  2903. e[6] = 0,
  2904. e[7] = 0,
  2905. e[8] = 0,
  2906. e[9] = 0,
  2907. e[10] = 2 * h,
  2908. e[11] = 0,
  2909. e[12] = (t + r) * s,
  2910. e[13] = (n + i) * l,
  2911. e[14] = (o + a) * h,
  2912. e[15] = 1,
  2913. e
  2914. }
  2915. ,
  2916. Ze.lookAt = function (e, t, r, i) {
  2917. var n, a, o, s, l, h, u, c, d, f, p = t[0], m = t[1], g = t[2], _ = i[0], v = i[1], y = i[2], x = r[0], b = r[1], w = r[2];
  2918. return Math.abs(p - x) < ue && Math.abs(m - b) < ue && Math.abs(g - w) < ue ? Ze.identity(e) : (u = p - x,
  2919. c = m - b,
  2920. d = g - w,
  2921. n = v * (d *= f = 1 / Math.sqrt(u * u + c * c + d * d)) - y * (c *= f),
  2922. a = y * (u *= f) - _ * d,
  2923. o = _ * c - v * u,
  2924. (f = Math.sqrt(n * n + a * a + o * o)) ? (n *= f = 1 / f,
  2925. a *= f,
  2926. o *= f) : (n = 0,
  2927. a = 0,
  2928. o = 0),
  2929. s = c * o - d * a,
  2930. l = d * n - u * o,
  2931. h = u * a - c * n,
  2932. (f = Math.sqrt(s * s + l * l + h * h)) ? (s *= f = 1 / f,
  2933. l *= f,
  2934. h *= f) : (s = 0,
  2935. l = 0,
  2936. h = 0),
  2937. e[0] = n,
  2938. e[1] = s,
  2939. e[2] = u,
  2940. e[3] = 0,
  2941. e[4] = a,
  2942. e[5] = l,
  2943. e[6] = c,
  2944. e[7] = 0,
  2945. e[8] = o,
  2946. e[9] = h,
  2947. e[10] = d,
  2948. e[11] = 0,
  2949. e[12] = -(n * p + a * m + o * g),
  2950. e[13] = -(s * p + l * m + h * g),
  2951. e[14] = -(u * p + c * m + d * g),
  2952. e[15] = 1,
  2953. e)
  2954. }
  2955. ,
  2956. Ze.frob = function (e) {
  2957. return Math.sqrt(Math.pow(e[0], 2) + Math.pow(e[1], 2) + Math.pow(e[2], 2) + Math.pow(e[3], 2) + Math.pow(e[4], 2) + Math.pow(e[5], 2) + Math.pow(e[6], 2) + Math.pow(e[7], 2) + Math.pow(e[8], 2) + Math.pow(e[9], 2) + Math.pow(e[10], 2) + Math.pow(e[11], 2) + Math.pow(e[12], 2) + Math.pow(e[13], 2) + Math.pow(e[14], 2) + Math.pow(e[15], 2))
  2958. }
  2959. ;
  2960. const Ye = Ze;
  2961. var Ke = {
  2962. create: function () {
  2963. var e = new ce(3);
  2964. return e[0] = 0,
  2965. e[1] = 0,
  2966. e[2] = 0,
  2967. e
  2968. },
  2969. clone: function (e) {
  2970. var t = new ce(3);
  2971. return t[0] = e[0],
  2972. t[1] = e[1],
  2973. t[2] = e[2],
  2974. t
  2975. },
  2976. fromValues: function (e, t, r) {
  2977. var i = new ce(3);
  2978. return i[0] = e,
  2979. i[1] = t,
  2980. i[2] = r,
  2981. i
  2982. },
  2983. copy: function (e, t) {
  2984. return e[0] = t[0],
  2985. e[1] = t[1],
  2986. e[2] = t[2],
  2987. e
  2988. },
  2989. set: function (e, t, r, i) {
  2990. return e[0] = t,
  2991. e[1] = r,
  2992. e[2] = i,
  2993. e
  2994. },
  2995. add: function (e, t, r) {
  2996. return e[0] = t[0] + r[0],
  2997. e[1] = t[1] + r[1],
  2998. e[2] = t[2] + r[2],
  2999. e
  3000. },
  3001. subtract: function (e, t, r) {
  3002. return e[0] = t[0] - r[0],
  3003. e[1] = t[1] - r[1],
  3004. e[2] = t[2] - r[2],
  3005. e
  3006. }
  3007. };
  3008. Ke.sub = Ke.subtract,
  3009. Ke.multiply = function (e, t, r) {
  3010. return e[0] = t[0] * r[0],
  3011. e[1] = t[1] * r[1],
  3012. e[2] = t[2] * r[2],
  3013. e
  3014. }
  3015. ,
  3016. Ke.mul = Ke.multiply,
  3017. Ke.divide = function (e, t, r) {
  3018. return e[0] = t[0] / r[0],
  3019. e[1] = t[1] / r[1],
  3020. e[2] = t[2] / r[2],
  3021. e
  3022. }
  3023. ,
  3024. Ke.div = Ke.divide,
  3025. Ke.min = function (e, t, r) {
  3026. return e[0] = Math.min(t[0], r[0]),
  3027. e[1] = Math.min(t[1], r[1]),
  3028. e[2] = Math.min(t[2], r[2]),
  3029. e
  3030. }
  3031. ,
  3032. Ke.max = function (e, t, r) {
  3033. return e[0] = Math.max(t[0], r[0]),
  3034. e[1] = Math.max(t[1], r[1]),
  3035. e[2] = Math.max(t[2], r[2]),
  3036. e
  3037. }
  3038. ,
  3039. Ke.scale = function (e, t, r) {
  3040. return e[0] = t[0] * r,
  3041. e[1] = t[1] * r,
  3042. e[2] = t[2] * r,
  3043. e
  3044. }
  3045. ,
  3046. Ke.scaleAndAdd = function (e, t, r, i) {
  3047. return e[0] = t[0] + r[0] * i,
  3048. e[1] = t[1] + r[1] * i,
  3049. e[2] = t[2] + r[2] * i,
  3050. e
  3051. }
  3052. ,
  3053. Ke.distance = function (e, t) {
  3054. var r = t[0] - e[0]
  3055. , i = t[1] - e[1]
  3056. , n = t[2] - e[2];
  3057. return Math.sqrt(r * r + i * i + n * n)
  3058. }
  3059. ,
  3060. Ke.dist = Ke.distance,
  3061. Ke.squaredDistance = function (e, t) {
  3062. var r = t[0] - e[0]
  3063. , i = t[1] - e[1]
  3064. , n = t[2] - e[2];
  3065. return r * r + i * i + n * n
  3066. }
  3067. ,
  3068. Ke.sqrDist = Ke.squaredDistance,
  3069. Ke.length = function (e) {
  3070. var t = e[0]
  3071. , r = e[1]
  3072. , i = e[2];
  3073. return Math.sqrt(t * t + r * r + i * i)
  3074. }
  3075. ,
  3076. Ke.len = Ke.length,
  3077. Ke.squaredLength = function (e) {
  3078. var t = e[0]
  3079. , r = e[1]
  3080. , i = e[2];
  3081. return t * t + r * r + i * i
  3082. }
  3083. ,
  3084. Ke.sqrLen = Ke.squaredLength,
  3085. Ke.negate = function (e, t) {
  3086. return e[0] = -t[0],
  3087. e[1] = -t[1],
  3088. e[2] = -t[2],
  3089. e
  3090. }
  3091. ,
  3092. Ke.inverse = function (e, t) {
  3093. return e[0] = 1 / t[0],
  3094. e[1] = 1 / t[1],
  3095. e[2] = 1 / t[2],
  3096. e
  3097. }
  3098. ,
  3099. Ke.normalize = function (e, t) {
  3100. var r = t[0]
  3101. , i = t[1]
  3102. , n = t[2]
  3103. , a = r * r + i * i + n * n;
  3104. return a > 0 && (a = 1 / Math.sqrt(a),
  3105. e[0] = t[0] * a,
  3106. e[1] = t[1] * a,
  3107. e[2] = t[2] * a),
  3108. e
  3109. }
  3110. ,
  3111. Ke.dot = function (e, t) {
  3112. return e[0] * t[0] + e[1] * t[1] + e[2] * t[2]
  3113. }
  3114. ,
  3115. Ke.cross = function (e, t, r) {
  3116. var i = t[0]
  3117. , n = t[1]
  3118. , a = t[2]
  3119. , o = r[0]
  3120. , s = r[1]
  3121. , l = r[2];
  3122. return e[0] = n * l - a * s,
  3123. e[1] = a * o - i * l,
  3124. e[2] = i * s - n * o,
  3125. e
  3126. }
  3127. ,
  3128. Ke.lerp = function (e, t, r, i) {
  3129. var n = t[0]
  3130. , a = t[1]
  3131. , o = t[2];
  3132. return e[0] = n + i * (r[0] - n),
  3133. e[1] = a + i * (r[1] - a),
  3134. e[2] = o + i * (r[2] - o),
  3135. e
  3136. }
  3137. ,
  3138. Ke.random = function (e, t) {
  3139. t = t || 1;
  3140. var r = 2 * de() * Math.PI
  3141. , i = 2 * de() - 1
  3142. , n = Math.sqrt(1 - i * i) * t;
  3143. return e[0] = Math.cos(r) * n,
  3144. e[1] = Math.sin(r) * n,
  3145. e[2] = i * t,
  3146. e
  3147. }
  3148. ,
  3149. Ke.transformMat4 = function (e, t, r) {
  3150. var i = t[0]
  3151. , n = t[1]
  3152. , a = t[2]
  3153. , o = r[3] * i + r[7] * n + r[11] * a + r[15];
  3154. return o = o || 1,
  3155. e[0] = (r[0] * i + r[4] * n + r[8] * a + r[12]) / o,
  3156. e[1] = (r[1] * i + r[5] * n + r[9] * a + r[13]) / o,
  3157. e[2] = (r[2] * i + r[6] * n + r[10] * a + r[14]) / o,
  3158. e
  3159. }
  3160. ,
  3161. Ke.transformMat3 = function (e, t, r) {
  3162. var i = t[0]
  3163. , n = t[1]
  3164. , a = t[2];
  3165. return e[0] = i * r[0] + n * r[3] + a * r[6],
  3166. e[1] = i * r[1] + n * r[4] + a * r[7],
  3167. e[2] = i * r[2] + n * r[5] + a * r[8],
  3168. e
  3169. }
  3170. ,
  3171. Ke.transformQuat = function (e, t, r) {
  3172. var i = t[0]
  3173. , n = t[1]
  3174. , a = t[2]
  3175. , o = r[0]
  3176. , s = r[1]
  3177. , l = r[2]
  3178. , h = r[3]
  3179. , u = h * i + s * a - l * n
  3180. , c = h * n + l * i - o * a
  3181. , d = h * a + o * n - s * i
  3182. , f = -o * i - s * n - l * a;
  3183. return e[0] = u * h + f * -o + c * -l - d * -s,
  3184. e[1] = c * h + f * -s + d * -o - u * -l,
  3185. e[2] = d * h + f * -l + u * -s - c * -o,
  3186. e
  3187. }
  3188. ,
  3189. Ke.rotateX = function (e, t, r, i) {
  3190. var n = []
  3191. , a = [];
  3192. return n[0] = t[0] - r[0],
  3193. n[1] = t[1] - r[1],
  3194. n[2] = t[2] - r[2],
  3195. a[0] = n[0],
  3196. a[1] = n[1] * Math.cos(i) - n[2] * Math.sin(i),
  3197. a[2] = n[1] * Math.sin(i) + n[2] * Math.cos(i),
  3198. e[0] = a[0] + r[0],
  3199. e[1] = a[1] + r[1],
  3200. e[2] = a[2] + r[2],
  3201. e
  3202. }
  3203. ,
  3204. Ke.rotateY = function (e, t, r, i) {
  3205. var n = []
  3206. , a = [];
  3207. return n[0] = t[0] - r[0],
  3208. n[1] = t[1] - r[1],
  3209. n[2] = t[2] - r[2],
  3210. a[0] = n[2] * Math.sin(i) + n[0] * Math.cos(i),
  3211. a[1] = n[1],
  3212. a[2] = n[2] * Math.cos(i) - n[0] * Math.sin(i),
  3213. e[0] = a[0] + r[0],
  3214. e[1] = a[1] + r[1],
  3215. e[2] = a[2] + r[2],
  3216. e
  3217. }
  3218. ,
  3219. Ke.rotateZ = function (e, t, r, i) {
  3220. var n = []
  3221. , a = [];
  3222. return n[0] = t[0] - r[0],
  3223. n[1] = t[1] - r[1],
  3224. n[2] = t[2] - r[2],
  3225. a[0] = n[0] * Math.cos(i) - n[1] * Math.sin(i),
  3226. a[1] = n[0] * Math.sin(i) + n[1] * Math.cos(i),
  3227. a[2] = n[2],
  3228. e[0] = a[0] + r[0],
  3229. e[1] = a[1] + r[1],
  3230. e[2] = a[2] + r[2],
  3231. e
  3232. }
  3233. ,
  3234. Ke.forEach = function () {
  3235. var e = Ke.create();
  3236. return function (t, r, i, n, a, o) {
  3237. var s, l;
  3238. for (r || (r = 3),
  3239. i || (i = 0),
  3240. l = n ? Math.min(n * r + i, t.length) : t.length,
  3241. s = i; s < l; s += r)
  3242. e[0] = t[s],
  3243. e[1] = t[s + 1],
  3244. e[2] = t[s + 2],
  3245. a(e, e, o),
  3246. t[s] = e[0],
  3247. t[s + 1] = e[1],
  3248. t[s + 2] = e[2];
  3249. return t
  3250. }
  3251. }(),
  3252. Ke.angle = function (e, t) {
  3253. var r = Ke.fromValues(e[0], e[1], e[2])
  3254. , i = Ke.fromValues(t[0], t[1], t[2]);
  3255. Ke.normalize(r, r),
  3256. Ke.normalize(i, i);
  3257. var n = Ke.dot(r, i);
  3258. return n > 1 ? 0 : Math.acos(n)
  3259. }
  3260. ;
  3261. const Qe = Ke;
  3262. Xe.import(qe);
  3263. var Je = Ye.create
  3264. , $e = {};
  3265. function et(e) {
  3266. return e.material
  3267. }
  3268. function tt(e, t, r) {
  3269. return t.uniforms[r].value
  3270. }
  3271. function rt(e, t, r, i) {
  3272. return r !== i
  3273. }
  3274. function it(e) {
  3275. return !0
  3276. }
  3277. function nt() { }
  3278. var at = {
  3279. float: S,
  3280. byte: 5120,
  3281. ubyte: T,
  3282. short: 5122,
  3283. ushort: 5123
  3284. };
  3285. function ot(e, t, r) {
  3286. this.availableAttributes = e,
  3287. this.availableAttributeSymbols = t,
  3288. this.indicesBuffer = r,
  3289. this.vao = null
  3290. }
  3291. function st(e) {
  3292. var t, r;
  3293. this.bind = function (e) {
  3294. t || ((t = U.createCanvas()).width = t.height = 1,
  3295. t.getContext("2d"));
  3296. var i = e.gl
  3297. , n = !r;
  3298. n && (r = i.createTexture()),
  3299. i.bindTexture(i.TEXTURE_2D, r),
  3300. n && i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, i.RGBA, i.UNSIGNED_BYTE, t)
  3301. }
  3302. ,
  3303. this.unbind = function (e) {
  3304. e.gl.bindTexture(e.gl.TEXTURE_2D, null)
  3305. }
  3306. ,
  3307. this.isRenderable = function () {
  3308. return !0
  3309. }
  3310. }
  3311. var lt = m.extend((function () {
  3312. return {
  3313. canvas: null,
  3314. _width: 100,
  3315. _height: 100,
  3316. devicePixelRatio: "undefined" != typeof window && window.devicePixelRatio || 1,
  3317. clearColor: [0, 0, 0, 0],
  3318. clearBit: 17664,
  3319. alpha: !0,
  3320. depth: !0,
  3321. stencil: !1,
  3322. antialias: !0,
  3323. premultipliedAlpha: !0,
  3324. preserveDrawingBuffer: !1,
  3325. throwError: !0,
  3326. gl: null,
  3327. viewport: {},
  3328. maxJointNumber: 20,
  3329. __currentFrameBuffer: null,
  3330. _viewportStack: [],
  3331. _clearStack: [],
  3332. _sceneRendering: null
  3333. }
  3334. }
  3335. ), (function () {
  3336. this.canvas || (this.canvas = U.createCanvas());
  3337. var e = this.canvas;
  3338. try {
  3339. var t = {
  3340. alpha: this.alpha,
  3341. depth: this.depth,
  3342. stencil: this.stencil,
  3343. antialias: this.antialias,
  3344. premultipliedAlpha: this.premultipliedAlpha,
  3345. preserveDrawingBuffer: this.preserveDrawingBuffer
  3346. };
  3347. if (this.gl = e.getContext("webgl", t) || e.getContext("experimental-webgl", t),
  3348. !this.gl)
  3349. throw new Error;
  3350. this._glinfo = new v(this.gl),
  3351. this.gl.targetRenderer && console.error("Already created a renderer"),
  3352. this.gl.targetRenderer = this,
  3353. this.resize()
  3354. } catch (e) {
  3355. throw "Error creating WebGL Context " + e
  3356. }
  3357. this._programMgr = new Ee(this),
  3358. this._placeholderTexture = new st(this)
  3359. }
  3360. ), {
  3361. resize: function (e, t) {
  3362. var r = this.canvas
  3363. , i = this.devicePixelRatio;
  3364. null != e ? (r.style && (r.style.width = e + "px",
  3365. r.style.height = t + "px"),
  3366. r.width = e * i,
  3367. r.height = t * i,
  3368. this._width = e,
  3369. this._height = t) : (this._width = r.width / i,
  3370. this._height = r.height / i),
  3371. this.setViewport(0, 0, this._width, this._height)
  3372. },
  3373. getWidth: function () {
  3374. return this._width
  3375. },
  3376. getHeight: function () {
  3377. return this._height
  3378. },
  3379. getViewportAspect: function () {
  3380. var e = this.viewport;
  3381. return e.width / e.height
  3382. },
  3383. setDevicePixelRatio: function (e) {
  3384. this.devicePixelRatio = e,
  3385. this.resize(this._width, this._height)
  3386. },
  3387. getDevicePixelRatio: function () {
  3388. return this.devicePixelRatio
  3389. },
  3390. getGLExtension: function (e) {
  3391. return this._glinfo.getExtension(e)
  3392. },
  3393. getGLParameter: function (e) {
  3394. return this._glinfo.getParameter(e)
  3395. },
  3396. setViewport: function (e, t, r, i, n) {
  3397. if ("object" == typeof e) {
  3398. var a = e;
  3399. e = a.x,
  3400. t = a.y,
  3401. r = a.width,
  3402. i = a.height,
  3403. n = a.devicePixelRatio
  3404. }
  3405. n = n || this.devicePixelRatio,
  3406. this.gl.viewport(e * n, t * n, r * n, i * n),
  3407. this.viewport = {
  3408. x: e,
  3409. y: t,
  3410. width: r,
  3411. height: i,
  3412. devicePixelRatio: n
  3413. }
  3414. },
  3415. saveViewport: function () {
  3416. this._viewportStack.push(this.viewport)
  3417. },
  3418. restoreViewport: function () {
  3419. this._viewportStack.length > 0 && this.setViewport(this._viewportStack.pop())
  3420. },
  3421. saveClear: function () {
  3422. this._clearStack.push({
  3423. clearBit: this.clearBit,
  3424. clearColor: this.clearColor
  3425. })
  3426. },
  3427. restoreClear: function () {
  3428. if (this._clearStack.length > 0) {
  3429. var e = this._clearStack.pop();
  3430. this.clearColor = e.clearColor,
  3431. this.clearBit = e.clearBit
  3432. }
  3433. },
  3434. bindSceneRendering: function (e) {
  3435. this._sceneRendering = e
  3436. },
  3437. render: function (e, t, r, i) {
  3438. var n = this.gl
  3439. , a = this.clearColor;
  3440. if (this.clearBit) {
  3441. n.colorMask(!0, !0, !0, !0),
  3442. n.depthMask(!0);
  3443. var o = this.viewport
  3444. , s = !1
  3445. , l = o.devicePixelRatio;
  3446. (o.width !== this._width || o.height !== this._height || l && l !== this.devicePixelRatio || o.x || o.y) && (s = !0,
  3447. n.enable(n.SCISSOR_TEST),
  3448. n.scissor(o.x * l, o.y * l, o.width * l, o.height * l)),
  3449. n.clearColor(a[0], a[1], a[2], a[3]),
  3450. n.clear(this.clearBit),
  3451. s && n.disable(n.SCISSOR_TEST)
  3452. }
  3453. if (r || e.update(!1),
  3454. e.updateLights(),
  3455. t = t || e.getMainCamera()) {
  3456. t.update();
  3457. var h = e.updateRenderList(t, !0);
  3458. this._sceneRendering = e;
  3459. var u = h.opaque
  3460. , c = h.transparent
  3461. , d = e.material;
  3462. e.trigger("beforerender", this, e, t, h),
  3463. i ? (this.renderPreZ(u, e, t),
  3464. n.depthFunc(n.LEQUAL)) : n.depthFunc(n.LESS);
  3465. for (var f = Je(), p = Qe.create(), m = 0; m < c.length; m++) {
  3466. var g = c[m];
  3467. Ye.multiplyAffine(f, t.viewMatrix.array, g.worldTransform.array),
  3468. Qe.transformMat4(p, g.position.array, f),
  3469. g.__depth = p[2]
  3470. }
  3471. this.renderPass(u, t, {
  3472. getMaterial: function (e) {
  3473. return d || e.material
  3474. },
  3475. sortCompare: this.opaqueSortCompare
  3476. }),
  3477. this.renderPass(c, t, {
  3478. getMaterial: function (e) {
  3479. return d || e.material
  3480. },
  3481. sortCompare: this.transparentSortCompare
  3482. }),
  3483. e.trigger("afterrender", this, e, t, h),
  3484. this._sceneRendering = null
  3485. } else
  3486. console.error("Can't find camera in the scene.")
  3487. },
  3488. getProgram: function (e, t, r) {
  3489. return t = t || e.material,
  3490. this._programMgr.getProgram(e, t, r)
  3491. },
  3492. validateProgram: function (e) {
  3493. if (e.__error) {
  3494. var t = e.__error;
  3495. if ($e[e.__uid__])
  3496. return;
  3497. if ($e[e.__uid__] = !0,
  3498. this.throwError)
  3499. throw new Error(t);
  3500. this.trigger("error", t)
  3501. }
  3502. },
  3503. updatePrograms: function (e, t, r) {
  3504. var i = r && r.getMaterial || et;
  3505. t = t || null;
  3506. for (var n = 0; n < e.length; n++) {
  3507. var a = e[n]
  3508. , o = i.call(this, a);
  3509. if (n > 0) {
  3510. var s = e[n - 1]
  3511. , l = s.joints ? s.joints.length : 0;
  3512. if ((a.joints ? a.joints.length : 0) === l && a.material === s.material && a.lightGroup === s.lightGroup) {
  3513. a.__program = s.__program;
  3514. continue
  3515. }
  3516. }
  3517. var h = this._programMgr.getProgram(a, o, t);
  3518. this.validateProgram(h),
  3519. a.__program = h
  3520. }
  3521. },
  3522. renderPass: function (e, t, r) {
  3523. this.trigger("beforerenderpass", this, e, t, r),
  3524. (r = r || {}).getMaterial = r.getMaterial || et,
  3525. r.getUniform = r.getUniform || tt,
  3526. r.isMaterialChanged = r.isMaterialChanged || rt,
  3527. r.beforeRender = r.beforeRender || nt,
  3528. r.afterRender = r.afterRender || nt;
  3529. var i = r.ifRender || it;
  3530. this.updatePrograms(e, this._sceneRendering, r),
  3531. r.sortCompare && e.sort(r.sortCompare);
  3532. var n = this.viewport
  3533. , a = n.devicePixelRatio
  3534. , o = [n.x * a, n.y * a, n.width * a, n.height * a]
  3535. , s = this.devicePixelRatio
  3536. , l = this.__currentFrameBuffer ? [this.__currentFrameBuffer.getTextureWidth(), this.__currentFrameBuffer.getTextureHeight()] : [this._width * s, this._height * s]
  3537. , h = [o[2], o[3]]
  3538. , u = Date.now();
  3539. t ? (Ye.copy(ht.VIEW, t.viewMatrix.array),
  3540. Ye.copy(ht.PROJECTION, t.projectionMatrix.array),
  3541. Ye.copy(ht.VIEWINVERSE, t.worldTransform.array)) : (Ye.identity(ht.VIEW),
  3542. Ye.identity(ht.PROJECTION),
  3543. Ye.identity(ht.VIEWINVERSE)),
  3544. Ye.multiply(ht.VIEWPROJECTION, ht.PROJECTION, ht.VIEW),
  3545. Ye.invert(ht.PROJECTIONINVERSE, ht.PROJECTION),
  3546. Ye.invert(ht.VIEWPROJECTIONINVERSE, ht.VIEWPROJECTION);
  3547. for (var c, d, f, p, m, g, _, v, y, x, b, w, T = this.gl, S = this._sceneRendering, M = 0; M < e.length; M++) {
  3548. var A, E = e[M], C = null != E.worldTransform;
  3549. if (i(E)) {
  3550. C && (A = E.isSkinnedMesh && E.isSkinnedMesh() ? E.offsetMatrix ? E.offsetMatrix.array : ht.IDENTITY : E.worldTransform.array);
  3551. var D = E.geometry
  3552. , L = r.getMaterial.call(this, E)
  3553. , P = E.__program
  3554. , O = L.shader
  3555. , N = D.__uid__ + "-" + P.__uid__
  3556. , I = N !== x;
  3557. x = N,
  3558. C && (Ye.copy(ht.WORLD, A),
  3559. Ye.multiply(ht.WORLDVIEWPROJECTION, ht.VIEWPROJECTION, A),
  3560. Ye.multiplyAffine(ht.WORLDVIEW, ht.VIEW, A),
  3561. (O.matrixSemantics.WORLDINVERSE || O.matrixSemantics.WORLDINVERSETRANSPOSE) && Ye.invert(ht.WORLDINVERSE, A),
  3562. (O.matrixSemantics.WORLDVIEWINVERSE || O.matrixSemantics.WORLDVIEWINVERSETRANSPOSE) && Ye.invert(ht.WORLDVIEWINVERSE, ht.WORLDVIEW),
  3563. (O.matrixSemantics.WORLDVIEWPROJECTIONINVERSE || O.matrixSemantics.WORLDVIEWPROJECTIONINVERSETRANSPOSE) && Ye.invert(ht.WORLDVIEWPROJECTIONINVERSE, ht.WORLDVIEWPROJECTION)),
  3564. E.beforeRender && E.beforeRender(this),
  3565. r.beforeRender.call(this, E, L, c);
  3566. var R = P !== d;
  3567. R ? (P.bind(this),
  3568. P.setUniformOfSemantic(T, "VIEWPORT", o),
  3569. P.setUniformOfSemantic(T, "WINDOW_SIZE", l),
  3570. t && (P.setUniformOfSemantic(T, "NEAR", t.near),
  3571. P.setUniformOfSemantic(T, "FAR", t.far)),
  3572. P.setUniformOfSemantic(T, "DEVICEPIXELRATIO", a),
  3573. P.setUniformOfSemantic(T, "TIME", u),
  3574. P.setUniformOfSemantic(T, "VIEWPORT_SIZE", h),
  3575. S && S.setLightUniforms(P, E.lightGroup, this)) : P = d,
  3576. (R || r.isMaterialChanged(E, f, L, c)) && (L.depthTest !== p && (L.depthTest ? T.enable(T.DEPTH_TEST) : T.disable(T.DEPTH_TEST),
  3577. p = L.depthTest),
  3578. L.depthMask !== m && (T.depthMask(L.depthMask),
  3579. m = L.depthMask),
  3580. L.transparent !== y && (L.transparent ? T.enable(T.BLEND) : T.disable(T.BLEND),
  3581. y = L.transparent),
  3582. L.transparent && (L.blend ? L.blend(T) : (T.blendEquationSeparate(T.FUNC_ADD, T.FUNC_ADD),
  3583. T.blendFuncSeparate(T.SRC_ALPHA, T.ONE_MINUS_SRC_ALPHA, T.ONE, T.ONE_MINUS_SRC_ALPHA))),
  3584. w = this._bindMaterial(E, L, P, f || null, c || null, d || null, r.getUniform),
  3585. c = L);
  3586. var B = O.matrixSemanticKeys;
  3587. if (C)
  3588. for (var F = 0; F < B.length; F++) {
  3589. var z = B[F]
  3590. , G = O.matrixSemantics[z]
  3591. , U = ht[z];
  3592. if (G.isTranspose) {
  3593. var k = ht[G.semanticNoTranspose];
  3594. Ye.transpose(U, k)
  3595. }
  3596. P.setUniform(T, G.type, G.symbol, U)
  3597. }
  3598. E.cullFace !== _ && (_ = E.cullFace,
  3599. T.cullFace(_)),
  3600. E.frontFace !== v && (v = E.frontFace,
  3601. T.frontFace(v)),
  3602. E.culling !== g && ((g = E.culling) ? T.enable(T.CULL_FACE) : T.disable(T.CULL_FACE)),
  3603. this._updateSkeleton(E, P, w),
  3604. I && (b = this._bindVAO(null, O, D, P)),
  3605. this._renderObject(E, b, P),
  3606. r.afterRender(this, E),
  3607. E.afterRender && E.afterRender(this),
  3608. d = P,
  3609. f = E
  3610. }
  3611. }
  3612. this.trigger("afterrenderpass", this, e, t, r)
  3613. },
  3614. getMaxJointNumber: function () {
  3615. return this.maxJointNumber
  3616. },
  3617. _updateSkeleton: function (e, t, r) {
  3618. var i = this.gl
  3619. , n = e.skeleton;
  3620. if (n)
  3621. if (n.update(),
  3622. e.joints.length > this.getMaxJointNumber()) {
  3623. var a = n.getSubSkinMatricesTexture(e.__uid__, e.joints);
  3624. t.useTextureSlot(this, a, r),
  3625. t.setUniform(i, "1i", "skinMatricesTexture", r),
  3626. t.setUniform(i, "1f", "skinMatricesTextureSize", a.width)
  3627. } else {
  3628. var o = n.getSubSkinMatrices(e.__uid__, e.joints);
  3629. t.setUniformOfSemantic(i, "SKIN_MATRIX", o)
  3630. }
  3631. },
  3632. _renderObject: function (e, t, r) {
  3633. var i = this.gl
  3634. , n = e.geometry
  3635. , a = e.mode;
  3636. null == a && (a = 4);
  3637. var o = null
  3638. , s = e.isInstancedMesh && e.isInstancedMesh();
  3639. if (!s || (o = this.getGLExtension("ANGLE_instanced_arrays"))) {
  3640. var l;
  3641. if (s && (l = this._bindInstancedAttributes(e, r, o)),
  3642. t.indicesBuffer) {
  3643. var h = this.getGLExtension("OES_element_index_uint") && n.indices instanceof Uint32Array ? i.UNSIGNED_INT : i.UNSIGNED_SHORT;
  3644. s ? o.drawElementsInstancedANGLE(a, t.indicesBuffer.count, h, 0, e.getInstanceCount()) : i.drawElements(a, t.indicesBuffer.count, h, 0)
  3645. } else
  3646. s ? o.drawArraysInstancedANGLE(a, 0, n.vertexCount, e.getInstanceCount()) : i.drawArrays(a, 0, n.vertexCount);
  3647. if (s)
  3648. for (var u = 0; u < l.length; u++)
  3649. i.disableVertexAttribArray(l[u])
  3650. } else
  3651. console.warn("Device not support ANGLE_instanced_arrays extension")
  3652. },
  3653. _bindInstancedAttributes: function (e, t, r) {
  3654. for (var i = this.gl, n = e.getInstancedAttributesBuffers(this), a = [], o = 0; o < n.length; o++) {
  3655. var s = n[o]
  3656. , l = t.getAttribLocation(i, s.symbol);
  3657. if (!(l < 0)) {
  3658. var h = at[s.type] || i.FLOAT;
  3659. i.enableVertexAttribArray(l),
  3660. i.bindBuffer(i.ARRAY_BUFFER, s.buffer),
  3661. i.vertexAttribPointer(l, s.size, h, !1, 0, 0),
  3662. r.vertexAttribDivisorANGLE(l, s.divisor),
  3663. a.push(l)
  3664. }
  3665. }
  3666. return a
  3667. },
  3668. _bindMaterial: function (e, t, r, i, n, a, o) {
  3669. for (var s = this.gl, l = a === r, h = r.currentTextureSlot(), u = t.getEnabledUniforms(), c = t.getTextureUniforms(), d = this._placeholderTexture, f = 0; f < c.length; f++) {
  3670. var p = o(e, t, _ = c[f]);
  3671. if ("t" === (g = t.uniforms[_].type) && p)
  3672. p.__slot = -1;
  3673. else if ("tv" === g)
  3674. for (var m = 0; m < p.length; m++)
  3675. p[m] && (p[m].__slot = -1)
  3676. }
  3677. for (d.__slot = -1,
  3678. f = 0; f < u.length; f++) {
  3679. var g, _ = u[f], v = t.uniforms[_], y = (p = o(e, t, _),
  3680. "t" === (g = v.type));
  3681. if (y && (p && p.isRenderable() || (p = d)),
  3682. n && l) {
  3683. var x = o(i, n, _);
  3684. if (y && (x && x.isRenderable() || (x = d)),
  3685. x === p) {
  3686. if (y)
  3687. r.takeCurrentTextureSlot(this, null);
  3688. else if ("tv" === g && p)
  3689. for (m = 0; m < p.length; m++)
  3690. r.takeCurrentTextureSlot(this, null);
  3691. continue
  3692. }
  3693. }
  3694. if (null != p)
  3695. if (y)
  3696. if (p.__slot < 0) {
  3697. var b = r.currentTextureSlot();
  3698. r.setUniform(s, "1i", _, b) && (r.takeCurrentTextureSlot(this, p),
  3699. p.__slot = b)
  3700. } else
  3701. r.setUniform(s, "1i", _, p.__slot);
  3702. else if (Array.isArray(p)) {
  3703. if (0 === p.length)
  3704. continue;
  3705. if ("tv" === g) {
  3706. if (!r.hasUniform(_))
  3707. continue;
  3708. var w = [];
  3709. for (m = 0; m < p.length; m++) {
  3710. var T = p[m];
  3711. T.__slot < 0 ? (b = r.currentTextureSlot(),
  3712. w.push(b),
  3713. r.takeCurrentTextureSlot(this, T),
  3714. T.__slot = b) : w.push(T.__slot)
  3715. }
  3716. r.setUniform(s, "1iv", _, w)
  3717. } else
  3718. r.setUniform(s, v.type, _, p)
  3719. } else
  3720. r.setUniform(s, v.type, _, p)
  3721. }
  3722. var S = r.currentTextureSlot();
  3723. return r.resetTextureSlot(h),
  3724. S
  3725. },
  3726. _bindVAO: function (e, t, r, i) {
  3727. var n = !r.dynamic
  3728. , a = this.gl
  3729. , o = this.__uid__ + "-" + i.__uid__
  3730. , s = r.__vaoCache[o];
  3731. if (!s) {
  3732. var l = r.getBufferChunks(this);
  3733. if (!l || !l.length)
  3734. return;
  3735. for (var h = l[0], u = h.attributeBuffers, c = h.indicesBuffer, d = [], f = [], p = 0; p < u.length; p++) {
  3736. var m, g = (w = u[p]).name, _ = w.semantic;
  3737. if (_) {
  3738. var v = t.attributeSemantics[_];
  3739. m = v && v.symbol
  3740. } else
  3741. m = g;
  3742. m && i.attributes[m] && (d.push(w),
  3743. f.push(m))
  3744. }
  3745. s = new ot(d, f, c),
  3746. n && (r.__vaoCache[o] = s)
  3747. }
  3748. var y = !0;
  3749. if (e && n && (null == s.vao ? s.vao = e.createVertexArrayOES() : y = !1,
  3750. e.bindVertexArrayOES(s.vao)),
  3751. d = s.availableAttributes,
  3752. c = s.indicesBuffer,
  3753. y) {
  3754. var x = i.enableAttributes(this, s.availableAttributeSymbols, e && n && s);
  3755. for (p = 0; p < d.length; p++) {
  3756. var b = x[p];
  3757. if (-1 !== b) {
  3758. var w, T = (w = d[p]).buffer, S = w.size, M = at[w.type] || a.FLOAT;
  3759. a.bindBuffer(a.ARRAY_BUFFER, T),
  3760. a.vertexAttribPointer(b, S, M, !1, 0, 0)
  3761. }
  3762. }
  3763. r.isUseIndices() && a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, c.buffer)
  3764. }
  3765. return s
  3766. },
  3767. renderPreZ: function (e, t, r) {
  3768. var i = this.gl
  3769. , n = this._prezMaterial || new le({
  3770. shader: new Xe(Xe.source("clay.prez.vertex"), Xe.source("clay.prez.fragment"))
  3771. });
  3772. this._prezMaterial = n,
  3773. i.colorMask(!1, !1, !1, !1),
  3774. i.depthMask(!0),
  3775. this.renderPass(e, r, {
  3776. ifRender: function (e) {
  3777. return !e.ignorePreZ
  3778. },
  3779. isMaterialChanged: function (e, t) {
  3780. var r = e.material
  3781. , i = t.material;
  3782. return r.get("diffuseMap") !== i.get("diffuseMap") || (r.get("alphaCutoff") || 0) !== (i.get("alphaCutoff") || 0)
  3783. },
  3784. getUniform: function (e, t, r) {
  3785. return "alphaMap" === r ? e.material.get("diffuseMap") : "alphaCutoff" === r ? e.material.isDefined("fragment", "ALPHA_TEST") && e.material.get("diffuseMap") && e.material.get("alphaCutoff") || 0 : "uvRepeat" === r ? e.material.get("uvRepeat") : "uvOffset" === r ? e.material.get("uvOffset") : t.get(r)
  3786. },
  3787. getMaterial: function () {
  3788. return n
  3789. },
  3790. sort: this.opaqueSortCompare
  3791. }),
  3792. i.colorMask(!0, !0, !0, !0),
  3793. i.depthMask(!0)
  3794. },
  3795. disposeScene: function (e) {
  3796. this.disposeNode(e, !0, !0),
  3797. e.dispose()
  3798. },
  3799. disposeNode: function (e, t, r) {
  3800. e.getParent() && e.getParent().remove(e);
  3801. var i = {};
  3802. e.traverse((function (e) {
  3803. var n = e.material;
  3804. if (e.geometry && t && e.geometry.dispose(this),
  3805. r && n && !i[n.__uid__]) {
  3806. for (var a = n.getTextureUniforms(), o = 0; o < a.length; o++) {
  3807. var s = a[o]
  3808. , l = n.uniforms[s].value
  3809. , h = n.uniforms[s].type;
  3810. if (l)
  3811. if ("t" === h)
  3812. l.dispose && l.dispose(this);
  3813. else if ("tv" === h)
  3814. for (var u = 0; u < l.length; u++)
  3815. l[u] && l[u].dispose && l[u].dispose(this)
  3816. }
  3817. i[n.__uid__] = !0
  3818. }
  3819. e.dispose && e.dispose(this)
  3820. }
  3821. ), this)
  3822. },
  3823. disposeGeometry: function (e) {
  3824. e.dispose(this)
  3825. },
  3826. disposeTexture: function (e) {
  3827. e.dispose(this)
  3828. },
  3829. disposeFrameBuffer: function (e) {
  3830. e.dispose(this)
  3831. },
  3832. dispose: function () { },
  3833. screenToNDC: function (e, t, r) {
  3834. r || (r = new _e),
  3835. t = this._height - t;
  3836. var i = this.viewport
  3837. , n = r.array;
  3838. return n[0] = (e - i.x) / i.width,
  3839. n[0] = 2 * n[0] - 1,
  3840. n[1] = (t - i.y) / i.height,
  3841. n[1] = 2 * n[1] - 1,
  3842. r
  3843. }
  3844. });
  3845. lt.opaqueSortCompare = lt.prototype.opaqueSortCompare = function (e, t) {
  3846. return e.renderOrder === t.renderOrder ? e.__program === t.__program ? e.material === t.material ? e.geometry.__uid__ - t.geometry.__uid__ : e.material.__uid__ - t.material.__uid__ : e.__program && t.__program ? e.__program.__uid__ - t.__program.__uid__ : 0 : e.renderOrder - t.renderOrder
  3847. }
  3848. ,
  3849. lt.transparentSortCompare = lt.prototype.transparentSortCompare = function (e, t) {
  3850. return e.renderOrder === t.renderOrder ? e.__depth === t.__depth ? e.__program === t.__program ? e.material === t.material ? e.geometry.__uid__ - t.geometry.__uid__ : e.material.__uid__ - t.material.__uid__ : e.__program && t.__program ? e.__program.__uid__ - t.__program.__uid__ : 0 : e.__depth - t.__depth : e.renderOrder - t.renderOrder
  3851. }
  3852. ;
  3853. var ht = {
  3854. IDENTITY: Je(),
  3855. WORLD: Je(),
  3856. VIEW: Je(),
  3857. PROJECTION: Je(),
  3858. WORLDVIEW: Je(),
  3859. VIEWPROJECTION: Je(),
  3860. WORLDVIEWPROJECTION: Je(),
  3861. WORLDINVERSE: Je(),
  3862. VIEWINVERSE: Je(),
  3863. PROJECTIONINVERSE: Je(),
  3864. WORLDVIEWINVERSE: Je(),
  3865. VIEWPROJECTIONINVERSE: Je(),
  3866. WORLDVIEWPROJECTIONINVERSE: Je(),
  3867. WORLDTRANSPOSE: Je(),
  3868. VIEWTRANSPOSE: Je(),
  3869. PROJECTIONTRANSPOSE: Je(),
  3870. WORLDVIEWTRANSPOSE: Je(),
  3871. VIEWPROJECTIONTRANSPOSE: Je(),
  3872. WORLDVIEWPROJECTIONTRANSPOSE: Je(),
  3873. WORLDINVERSETRANSPOSE: Je(),
  3874. VIEWINVERSETRANSPOSE: Je(),
  3875. PROJECTIONINVERSETRANSPOSE: Je(),
  3876. WORLDVIEWINVERSETRANSPOSE: Je(),
  3877. VIEWPROJECTIONINVERSETRANSPOSE: Je(),
  3878. WORLDVIEWPROJECTIONINVERSETRANSPOSE: Je()
  3879. };
  3880. lt.COLOR_BUFFER_BIT = 16384,
  3881. lt.DEPTH_BUFFER_BIT = 256,
  3882. lt.STENCIL_BUFFER_BIT = 1024;
  3883. const ut = lt;
  3884. var ct = function (e, t, r) {
  3885. e = e || 0,
  3886. t = t || 0,
  3887. r = r || 0,
  3888. this.array = Qe.fromValues(e, t, r),
  3889. this._dirty = !0
  3890. };
  3891. ct.prototype = {
  3892. constructor: ct,
  3893. add: function (e) {
  3894. return Qe.add(this.array, this.array, e.array),
  3895. this._dirty = !0,
  3896. this
  3897. },
  3898. set: function (e, t, r) {
  3899. return this.array[0] = e,
  3900. this.array[1] = t,
  3901. this.array[2] = r,
  3902. this._dirty = !0,
  3903. this
  3904. },
  3905. setArray: function (e) {
  3906. return this.array[0] = e[0],
  3907. this.array[1] = e[1],
  3908. this.array[2] = e[2],
  3909. this._dirty = !0,
  3910. this
  3911. },
  3912. clone: function () {
  3913. return new ct(this.x, this.y, this.z)
  3914. },
  3915. copy: function (e) {
  3916. return Qe.copy(this.array, e.array),
  3917. this._dirty = !0,
  3918. this
  3919. },
  3920. cross: function (e, t) {
  3921. return Qe.cross(this.array, e.array, t.array),
  3922. this._dirty = !0,
  3923. this
  3924. },
  3925. dist: function (e) {
  3926. return Qe.dist(this.array, e.array)
  3927. },
  3928. distance: function (e) {
  3929. return Qe.distance(this.array, e.array)
  3930. },
  3931. div: function (e) {
  3932. return Qe.div(this.array, this.array, e.array),
  3933. this._dirty = !0,
  3934. this
  3935. },
  3936. divide: function (e) {
  3937. return Qe.divide(this.array, this.array, e.array),
  3938. this._dirty = !0,
  3939. this
  3940. },
  3941. dot: function (e) {
  3942. return Qe.dot(this.array, e.array)
  3943. },
  3944. len: function () {
  3945. return Qe.len(this.array)
  3946. },
  3947. length: function () {
  3948. return Qe.length(this.array)
  3949. },
  3950. lerp: function (e, t, r) {
  3951. return Qe.lerp(this.array, e.array, t.array, r),
  3952. this._dirty = !0,
  3953. this
  3954. },
  3955. min: function (e) {
  3956. return Qe.min(this.array, this.array, e.array),
  3957. this._dirty = !0,
  3958. this
  3959. },
  3960. max: function (e) {
  3961. return Qe.max(this.array, this.array, e.array),
  3962. this._dirty = !0,
  3963. this
  3964. },
  3965. mul: function (e) {
  3966. return Qe.mul(this.array, this.array, e.array),
  3967. this._dirty = !0,
  3968. this
  3969. },
  3970. multiply: function (e) {
  3971. return Qe.multiply(this.array, this.array, e.array),
  3972. this._dirty = !0,
  3973. this
  3974. },
  3975. negate: function () {
  3976. return Qe.negate(this.array, this.array),
  3977. this._dirty = !0,
  3978. this
  3979. },
  3980. normalize: function () {
  3981. return Qe.normalize(this.array, this.array),
  3982. this._dirty = !0,
  3983. this
  3984. },
  3985. random: function (e) {
  3986. return Qe.random(this.array, e),
  3987. this._dirty = !0,
  3988. this
  3989. },
  3990. scale: function (e) {
  3991. return Qe.scale(this.array, this.array, e),
  3992. this._dirty = !0,
  3993. this
  3994. },
  3995. scaleAndAdd: function (e, t) {
  3996. return Qe.scaleAndAdd(this.array, this.array, e.array, t),
  3997. this._dirty = !0,
  3998. this
  3999. },
  4000. sqrDist: function (e) {
  4001. return Qe.sqrDist(this.array, e.array)
  4002. },
  4003. squaredDistance: function (e) {
  4004. return Qe.squaredDistance(this.array, e.array)
  4005. },
  4006. sqrLen: function () {
  4007. return Qe.sqrLen(this.array)
  4008. },
  4009. squaredLength: function () {
  4010. return Qe.squaredLength(this.array)
  4011. },
  4012. sub: function (e) {
  4013. return Qe.sub(this.array, this.array, e.array),
  4014. this._dirty = !0,
  4015. this
  4016. },
  4017. subtract: function (e) {
  4018. return Qe.subtract(this.array, this.array, e.array),
  4019. this._dirty = !0,
  4020. this
  4021. },
  4022. transformMat3: function (e) {
  4023. return Qe.transformMat3(this.array, this.array, e.array),
  4024. this._dirty = !0,
  4025. this
  4026. },
  4027. transformMat4: function (e) {
  4028. return Qe.transformMat4(this.array, this.array, e.array),
  4029. this._dirty = !0,
  4030. this
  4031. },
  4032. transformQuat: function (e) {
  4033. return Qe.transformQuat(this.array, this.array, e.array),
  4034. this._dirty = !0,
  4035. this
  4036. },
  4037. applyProjection: function (e) {
  4038. var t = this.array;
  4039. if (0 === (e = e.array)[15]) {
  4040. var r = -1 / t[2];
  4041. t[0] = e[0] * t[0] * r,
  4042. t[1] = e[5] * t[1] * r,
  4043. t[2] = (e[10] * t[2] + e[14]) * r
  4044. } else
  4045. t[0] = e[0] * t[0] + e[12],
  4046. t[1] = e[5] * t[1] + e[13],
  4047. t[2] = e[10] * t[2] + e[14];
  4048. return this._dirty = !0,
  4049. this
  4050. },
  4051. eulerFromQuat: function (e, t) {
  4052. ct.eulerFromQuat(this, e, t)
  4053. },
  4054. eulerFromMat3: function (e, t) {
  4055. ct.eulerFromMat3(this, e, t)
  4056. },
  4057. toString: function () {
  4058. return "[" + Array.prototype.join.call(this.array, ",") + "]"
  4059. },
  4060. toArray: function () {
  4061. return Array.prototype.slice.call(this.array)
  4062. }
  4063. };
  4064. var dt = Object.defineProperty;
  4065. if (dt) {
  4066. var ft = ct.prototype;
  4067. dt(ft, "x", {
  4068. get: function () {
  4069. return this.array[0]
  4070. },
  4071. set: function (e) {
  4072. this.array[0] = e,
  4073. this._dirty = !0
  4074. }
  4075. }),
  4076. dt(ft, "y", {
  4077. get: function () {
  4078. return this.array[1]
  4079. },
  4080. set: function (e) {
  4081. this.array[1] = e,
  4082. this._dirty = !0
  4083. }
  4084. }),
  4085. dt(ft, "z", {
  4086. get: function () {
  4087. return this.array[2]
  4088. },
  4089. set: function (e) {
  4090. this.array[2] = e,
  4091. this._dirty = !0
  4092. }
  4093. })
  4094. }
  4095. function pt(e, t, r) {
  4096. return e < t ? t : e > r ? r : e
  4097. }
  4098. ct.add = function (e, t, r) {
  4099. return Qe.add(e.array, t.array, r.array),
  4100. e._dirty = !0,
  4101. e
  4102. }
  4103. ,
  4104. ct.set = function (e, t, r, i) {
  4105. Qe.set(e.array, t, r, i),
  4106. e._dirty = !0
  4107. }
  4108. ,
  4109. ct.copy = function (e, t) {
  4110. return Qe.copy(e.array, t.array),
  4111. e._dirty = !0,
  4112. e
  4113. }
  4114. ,
  4115. ct.cross = function (e, t, r) {
  4116. return Qe.cross(e.array, t.array, r.array),
  4117. e._dirty = !0,
  4118. e
  4119. }
  4120. ,
  4121. ct.distance = ct.dist = function (e, t) {
  4122. return Qe.distance(e.array, t.array)
  4123. }
  4124. ,
  4125. ct.divide = ct.div = function (e, t, r) {
  4126. return Qe.divide(e.array, t.array, r.array),
  4127. e._dirty = !0,
  4128. e
  4129. }
  4130. ,
  4131. ct.dot = function (e, t) {
  4132. return Qe.dot(e.array, t.array)
  4133. }
  4134. ,
  4135. ct.len = function (e) {
  4136. return Qe.length(e.array)
  4137. }
  4138. ,
  4139. ct.lerp = function (e, t, r, i) {
  4140. return Qe.lerp(e.array, t.array, r.array, i),
  4141. e._dirty = !0,
  4142. e
  4143. }
  4144. ,
  4145. ct.min = function (e, t, r) {
  4146. return Qe.min(e.array, t.array, r.array),
  4147. e._dirty = !0,
  4148. e
  4149. }
  4150. ,
  4151. ct.max = function (e, t, r) {
  4152. return Qe.max(e.array, t.array, r.array),
  4153. e._dirty = !0,
  4154. e
  4155. }
  4156. ,
  4157. ct.multiply = ct.mul = function (e, t, r) {
  4158. return Qe.multiply(e.array, t.array, r.array),
  4159. e._dirty = !0,
  4160. e
  4161. }
  4162. ,
  4163. ct.negate = function (e, t) {
  4164. return Qe.negate(e.array, t.array),
  4165. e._dirty = !0,
  4166. e
  4167. }
  4168. ,
  4169. ct.normalize = function (e, t) {
  4170. return Qe.normalize(e.array, t.array),
  4171. e._dirty = !0,
  4172. e
  4173. }
  4174. ,
  4175. ct.random = function (e, t) {
  4176. return Qe.random(e.array, t),
  4177. e._dirty = !0,
  4178. e
  4179. }
  4180. ,
  4181. ct.scale = function (e, t, r) {
  4182. return Qe.scale(e.array, t.array, r),
  4183. e._dirty = !0,
  4184. e
  4185. }
  4186. ,
  4187. ct.scaleAndAdd = function (e, t, r, i) {
  4188. return Qe.scaleAndAdd(e.array, t.array, r.array, i),
  4189. e._dirty = !0,
  4190. e
  4191. }
  4192. ,
  4193. ct.squaredDistance = ct.sqrDist = function (e, t) {
  4194. return Qe.sqrDist(e.array, t.array)
  4195. }
  4196. ,
  4197. ct.squaredLength = ct.sqrLen = function (e) {
  4198. return Qe.sqrLen(e.array)
  4199. }
  4200. ,
  4201. ct.subtract = ct.sub = function (e, t, r) {
  4202. return Qe.subtract(e.array, t.array, r.array),
  4203. e._dirty = !0,
  4204. e
  4205. }
  4206. ,
  4207. ct.transformMat3 = function (e, t, r) {
  4208. return Qe.transformMat3(e.array, t.array, r.array),
  4209. e._dirty = !0,
  4210. e
  4211. }
  4212. ,
  4213. ct.transformMat4 = function (e, t, r) {
  4214. return Qe.transformMat4(e.array, t.array, r.array),
  4215. e._dirty = !0,
  4216. e
  4217. }
  4218. ,
  4219. ct.transformQuat = function (e, t, r) {
  4220. return Qe.transformQuat(e.array, t.array, r.array),
  4221. e._dirty = !0,
  4222. e
  4223. }
  4224. ;
  4225. var mt = Math.atan2
  4226. , gt = Math.asin
  4227. , _t = Math.abs;
  4228. ct.eulerFromQuat = function (e, t, r) {
  4229. e._dirty = !0,
  4230. t = t.array;
  4231. var i = e.array
  4232. , n = t[0]
  4233. , a = t[1]
  4234. , o = t[2]
  4235. , s = t[3]
  4236. , l = n * n
  4237. , h = a * a
  4238. , u = o * o
  4239. , c = s * s;
  4240. switch (r = (r || "XYZ").toUpperCase()) {
  4241. case "XYZ":
  4242. i[0] = mt(2 * (n * s - a * o), c - l - h + u),
  4243. i[1] = gt(pt(2 * (n * o + a * s), -1, 1)),
  4244. i[2] = mt(2 * (o * s - n * a), c + l - h - u);
  4245. break;
  4246. case "YXZ":
  4247. i[0] = gt(pt(2 * (n * s - a * o), -1, 1)),
  4248. i[1] = mt(2 * (n * o + a * s), c - l - h + u),
  4249. i[2] = mt(2 * (n * a + o * s), c - l + h - u);
  4250. break;
  4251. case "ZXY":
  4252. i[0] = gt(pt(2 * (n * s + a * o), -1, 1)),
  4253. i[1] = mt(2 * (a * s - o * n), c - l - h + u),
  4254. i[2] = mt(2 * (o * s - n * a), c - l + h - u);
  4255. break;
  4256. case "ZYX":
  4257. i[0] = mt(2 * (n * s + o * a), c - l - h + u),
  4258. i[1] = gt(pt(2 * (a * s - n * o), -1, 1)),
  4259. i[2] = mt(2 * (n * a + o * s), c + l - h - u);
  4260. break;
  4261. case "YZX":
  4262. i[0] = mt(2 * (n * s - o * a), c - l + h - u),
  4263. i[1] = mt(2 * (a * s - n * o), c + l - h - u),
  4264. i[2] = gt(pt(2 * (n * a + o * s), -1, 1));
  4265. break;
  4266. case "XZY":
  4267. i[0] = mt(2 * (n * s + a * o), c - l + h - u),
  4268. i[1] = mt(2 * (n * o + a * s), c + l - h - u),
  4269. i[2] = gt(pt(2 * (o * s - n * a), -1, 1));
  4270. break;
  4271. default:
  4272. console.warn("Unkown order: " + r)
  4273. }
  4274. return e
  4275. }
  4276. ,
  4277. ct.eulerFromMat3 = function (e, t, r) {
  4278. var i = t.array
  4279. , n = i[0]
  4280. , a = i[3]
  4281. , o = i[6]
  4282. , s = i[1]
  4283. , l = i[4]
  4284. , h = i[7]
  4285. , u = i[2]
  4286. , c = i[5]
  4287. , d = i[8]
  4288. , f = e.array;
  4289. switch (r = (r || "XYZ").toUpperCase()) {
  4290. case "XYZ":
  4291. f[1] = gt(pt(o, -1, 1)),
  4292. _t(o) < .99999 ? (f[0] = mt(-h, d),
  4293. f[2] = mt(-a, n)) : (f[0] = mt(c, l),
  4294. f[2] = 0);
  4295. break;
  4296. case "YXZ":
  4297. f[0] = gt(-pt(h, -1, 1)),
  4298. _t(h) < .99999 ? (f[1] = mt(o, d),
  4299. f[2] = mt(s, l)) : (f[1] = mt(-u, n),
  4300. f[2] = 0);
  4301. break;
  4302. case "ZXY":
  4303. f[0] = gt(pt(c, -1, 1)),
  4304. _t(c) < .99999 ? (f[1] = mt(-u, d),
  4305. f[2] = mt(-a, l)) : (f[1] = 0,
  4306. f[2] = mt(s, n));
  4307. break;
  4308. case "ZYX":
  4309. f[1] = gt(-pt(u, -1, 1)),
  4310. _t(u) < .99999 ? (f[0] = mt(c, d),
  4311. f[2] = mt(s, n)) : (f[0] = 0,
  4312. f[2] = mt(-a, l));
  4313. break;
  4314. case "YZX":
  4315. f[2] = gt(pt(s, -1, 1)),
  4316. _t(s) < .99999 ? (f[0] = mt(-h, l),
  4317. f[1] = mt(-u, n)) : (f[0] = 0,
  4318. f[1] = mt(o, d));
  4319. break;
  4320. case "XZY":
  4321. f[2] = gt(-pt(a, -1, 1)),
  4322. _t(a) < .99999 ? (f[0] = mt(c, l),
  4323. f[1] = mt(o, n)) : (f[0] = mt(-h, d),
  4324. f[1] = 0);
  4325. break;
  4326. default:
  4327. console.warn("Unkown order: " + r)
  4328. }
  4329. return e._dirty = !0,
  4330. e
  4331. }
  4332. ,
  4333. Object.defineProperties(ct, {
  4334. POSITIVE_X: {
  4335. get: function () {
  4336. return new ct(1, 0, 0)
  4337. }
  4338. },
  4339. NEGATIVE_X: {
  4340. get: function () {
  4341. return new ct(-1, 0, 0)
  4342. }
  4343. },
  4344. POSITIVE_Y: {
  4345. get: function () {
  4346. return new ct(0, 1, 0)
  4347. }
  4348. },
  4349. NEGATIVE_Y: {
  4350. get: function () {
  4351. return new ct(0, -1, 0)
  4352. }
  4353. },
  4354. POSITIVE_Z: {
  4355. get: function () {
  4356. return new ct(0, 0, 1)
  4357. }
  4358. },
  4359. NEGATIVE_Z: {
  4360. get: function () {
  4361. return new ct(0, 0, -1)
  4362. }
  4363. },
  4364. UP: {
  4365. get: function () {
  4366. return new ct(0, 1, 0)
  4367. }
  4368. },
  4369. ZERO: {
  4370. get: function () {
  4371. return new ct
  4372. }
  4373. }
  4374. });
  4375. const vt = ct;
  4376. var yt, xt, bt, wt, Tt, St = function (e, t) {
  4377. this.origin = e || new vt,
  4378. this.direction = t || new vt
  4379. };
  4380. St.prototype = {
  4381. constructor: St,
  4382. intersectPlane: function (e, t) {
  4383. var r = e.normal.array
  4384. , i = e.distance
  4385. , n = this.origin.array
  4386. , a = this.direction.array
  4387. , o = Qe.dot(r, a);
  4388. if (0 === o)
  4389. return null;
  4390. t || (t = new vt);
  4391. var s = (Qe.dot(r, n) - i) / o;
  4392. return Qe.scaleAndAdd(t.array, n, a, -s),
  4393. t._dirty = !0,
  4394. t
  4395. },
  4396. mirrorAgainstPlane: function (e) {
  4397. var t = Qe.dot(e.normal.array, this.direction.array);
  4398. Qe.scaleAndAdd(this.direction.array, this.direction.array, e.normal.array, 2 * -t),
  4399. this.direction._dirty = !0
  4400. },
  4401. distanceToPoint: (Tt = Qe.create(),
  4402. function (e) {
  4403. Qe.sub(Tt, e, this.origin.array);
  4404. var t = Qe.dot(Tt, this.direction.array);
  4405. if (t < 0)
  4406. return Qe.distance(this.origin.array, e);
  4407. var r = Qe.lenSquared(Tt);
  4408. return Math.sqrt(r - t * t)
  4409. }
  4410. ),
  4411. intersectSphere: function () {
  4412. var e = Qe.create();
  4413. return function (t, r, i) {
  4414. var n = this.origin.array
  4415. , a = this.direction.array;
  4416. t = t.array,
  4417. Qe.sub(e, t, n);
  4418. var o = Qe.dot(e, a)
  4419. , s = Qe.squaredLength(e) - o * o
  4420. , l = r * r;
  4421. if (!(s > l)) {
  4422. var h = Math.sqrt(l - s)
  4423. , u = o - h
  4424. , c = o + h;
  4425. return i || (i = new vt),
  4426. u < 0 ? c < 0 ? null : (Qe.scaleAndAdd(i.array, n, a, c),
  4427. i) : (Qe.scaleAndAdd(i.array, n, a, u),
  4428. i)
  4429. }
  4430. }
  4431. }(),
  4432. intersectBoundingBox: function (e, t) {
  4433. var r, i, n, a, o, s, l = this.direction.array, h = this.origin.array, u = e.min.array, c = e.max.array, d = 1 / l[0], f = 1 / l[1], p = 1 / l[2];
  4434. if (d >= 0 ? (r = (u[0] - h[0]) * d,
  4435. i = (c[0] - h[0]) * d) : (i = (u[0] - h[0]) * d,
  4436. r = (c[0] - h[0]) * d),
  4437. f >= 0 ? (n = (u[1] - h[1]) * f,
  4438. a = (c[1] - h[1]) * f) : (a = (u[1] - h[1]) * f,
  4439. n = (c[1] - h[1]) * f),
  4440. r > a || n > i)
  4441. return null;
  4442. if ((n > r || r != r) && (r = n),
  4443. (a < i || i != i) && (i = a),
  4444. p >= 0 ? (o = (u[2] - h[2]) * p,
  4445. s = (c[2] - h[2]) * p) : (s = (u[2] - h[2]) * p,
  4446. o = (c[2] - h[2]) * p),
  4447. r > s || o > i)
  4448. return null;
  4449. if ((o > r || r != r) && (r = o),
  4450. (s < i || i != i) && (i = s),
  4451. i < 0)
  4452. return null;
  4453. var m = r >= 0 ? r : i;
  4454. return t || (t = new vt),
  4455. Qe.scaleAndAdd(t.array, h, l, m),
  4456. t
  4457. },
  4458. intersectTriangle: (yt = Qe.create(),
  4459. xt = Qe.create(),
  4460. bt = Qe.create(),
  4461. wt = Qe.create(),
  4462. function (e, t, r, i, n, a) {
  4463. var o = this.direction.array
  4464. , s = this.origin.array;
  4465. e = e.array,
  4466. t = t.array,
  4467. r = r.array,
  4468. Qe.sub(yt, t, e),
  4469. Qe.sub(xt, r, e),
  4470. Qe.cross(wt, xt, o);
  4471. var l = Qe.dot(yt, wt);
  4472. if (i) {
  4473. if (l > -1e-5)
  4474. return null
  4475. } else if (l > -1e-5 && l < 1e-5)
  4476. return null;
  4477. Qe.sub(bt, s, e);
  4478. var h = Qe.dot(wt, bt) / l;
  4479. if (h < 0 || h > 1)
  4480. return null;
  4481. Qe.cross(wt, yt, bt);
  4482. var u = Qe.dot(o, wt) / l;
  4483. if (u < 0 || u > 1 || h + u > 1)
  4484. return null;
  4485. Qe.cross(wt, yt, xt);
  4486. var c = -Qe.dot(bt, wt) / l;
  4487. return c < 0 ? null : (n || (n = new vt),
  4488. a && vt.set(a, 1 - h - u, h, u),
  4489. Qe.scaleAndAdd(n.array, s, o, c),
  4490. n)
  4491. }
  4492. ),
  4493. applyTransform: function (e) {
  4494. vt.add(this.direction, this.direction, this.origin),
  4495. vt.transformMat4(this.origin, this.origin, e),
  4496. vt.transformMat4(this.direction, this.direction, e),
  4497. vt.sub(this.direction, this.direction, this.origin),
  4498. vt.normalize(this.direction, this.direction)
  4499. },
  4500. copy: function (e) {
  4501. vt.copy(this.origin, e.origin),
  4502. vt.copy(this.direction, e.direction)
  4503. },
  4504. clone: function () {
  4505. var e = new St;
  4506. return e.copy(this),
  4507. e
  4508. }
  4509. };
  4510. const Mt = St;
  4511. var At = {
  4512. create: function () {
  4513. var e = new ce(4);
  4514. return e[0] = 0,
  4515. e[1] = 0,
  4516. e[2] = 0,
  4517. e[3] = 0,
  4518. e
  4519. },
  4520. clone: function (e) {
  4521. var t = new ce(4);
  4522. return t[0] = e[0],
  4523. t[1] = e[1],
  4524. t[2] = e[2],
  4525. t[3] = e[3],
  4526. t
  4527. },
  4528. fromValues: function (e, t, r, i) {
  4529. var n = new ce(4);
  4530. return n[0] = e,
  4531. n[1] = t,
  4532. n[2] = r,
  4533. n[3] = i,
  4534. n
  4535. },
  4536. copy: function (e, t) {
  4537. return e[0] = t[0],
  4538. e[1] = t[1],
  4539. e[2] = t[2],
  4540. e[3] = t[3],
  4541. e
  4542. },
  4543. set: function (e, t, r, i, n) {
  4544. return e[0] = t,
  4545. e[1] = r,
  4546. e[2] = i,
  4547. e[3] = n,
  4548. e
  4549. },
  4550. add: function (e, t, r) {
  4551. return e[0] = t[0] + r[0],
  4552. e[1] = t[1] + r[1],
  4553. e[2] = t[2] + r[2],
  4554. e[3] = t[3] + r[3],
  4555. e
  4556. },
  4557. subtract: function (e, t, r) {
  4558. return e[0] = t[0] - r[0],
  4559. e[1] = t[1] - r[1],
  4560. e[2] = t[2] - r[2],
  4561. e[3] = t[3] - r[3],
  4562. e
  4563. }
  4564. };
  4565. At.sub = At.subtract,
  4566. At.multiply = function (e, t, r) {
  4567. return e[0] = t[0] * r[0],
  4568. e[1] = t[1] * r[1],
  4569. e[2] = t[2] * r[2],
  4570. e[3] = t[3] * r[3],
  4571. e
  4572. }
  4573. ,
  4574. At.mul = At.multiply,
  4575. At.divide = function (e, t, r) {
  4576. return e[0] = t[0] / r[0],
  4577. e[1] = t[1] / r[1],
  4578. e[2] = t[2] / r[2],
  4579. e[3] = t[3] / r[3],
  4580. e
  4581. }
  4582. ,
  4583. At.div = At.divide,
  4584. At.min = function (e, t, r) {
  4585. return e[0] = Math.min(t[0], r[0]),
  4586. e[1] = Math.min(t[1], r[1]),
  4587. e[2] = Math.min(t[2], r[2]),
  4588. e[3] = Math.min(t[3], r[3]),
  4589. e
  4590. }
  4591. ,
  4592. At.max = function (e, t, r) {
  4593. return e[0] = Math.max(t[0], r[0]),
  4594. e[1] = Math.max(t[1], r[1]),
  4595. e[2] = Math.max(t[2], r[2]),
  4596. e[3] = Math.max(t[3], r[3]),
  4597. e
  4598. }
  4599. ,
  4600. At.scale = function (e, t, r) {
  4601. return e[0] = t[0] * r,
  4602. e[1] = t[1] * r,
  4603. e[2] = t[2] * r,
  4604. e[3] = t[3] * r,
  4605. e
  4606. }
  4607. ,
  4608. At.scaleAndAdd = function (e, t, r, i) {
  4609. return e[0] = t[0] + r[0] * i,
  4610. e[1] = t[1] + r[1] * i,
  4611. e[2] = t[2] + r[2] * i,
  4612. e[3] = t[3] + r[3] * i,
  4613. e
  4614. }
  4615. ,
  4616. At.distance = function (e, t) {
  4617. var r = t[0] - e[0]
  4618. , i = t[1] - e[1]
  4619. , n = t[2] - e[2]
  4620. , a = t[3] - e[3];
  4621. return Math.sqrt(r * r + i * i + n * n + a * a)
  4622. }
  4623. ,
  4624. At.dist = At.distance,
  4625. At.squaredDistance = function (e, t) {
  4626. var r = t[0] - e[0]
  4627. , i = t[1] - e[1]
  4628. , n = t[2] - e[2]
  4629. , a = t[3] - e[3];
  4630. return r * r + i * i + n * n + a * a
  4631. }
  4632. ,
  4633. At.sqrDist = At.squaredDistance,
  4634. At.length = function (e) {
  4635. var t = e[0]
  4636. , r = e[1]
  4637. , i = e[2]
  4638. , n = e[3];
  4639. return Math.sqrt(t * t + r * r + i * i + n * n)
  4640. }
  4641. ,
  4642. At.len = At.length,
  4643. At.squaredLength = function (e) {
  4644. var t = e[0]
  4645. , r = e[1]
  4646. , i = e[2]
  4647. , n = e[3];
  4648. return t * t + r * r + i * i + n * n
  4649. }
  4650. ,
  4651. At.sqrLen = At.squaredLength,
  4652. At.negate = function (e, t) {
  4653. return e[0] = -t[0],
  4654. e[1] = -t[1],
  4655. e[2] = -t[2],
  4656. e[3] = -t[3],
  4657. e
  4658. }
  4659. ,
  4660. At.inverse = function (e, t) {
  4661. return e[0] = 1 / t[0],
  4662. e[1] = 1 / t[1],
  4663. e[2] = 1 / t[2],
  4664. e[3] = 1 / t[3],
  4665. e
  4666. }
  4667. ,
  4668. At.normalize = function (e, t) {
  4669. var r = t[0]
  4670. , i = t[1]
  4671. , n = t[2]
  4672. , a = t[3]
  4673. , o = r * r + i * i + n * n + a * a;
  4674. return o > 0 && (o = 1 / Math.sqrt(o),
  4675. e[0] = t[0] * o,
  4676. e[1] = t[1] * o,
  4677. e[2] = t[2] * o,
  4678. e[3] = t[3] * o),
  4679. e
  4680. }
  4681. ,
  4682. At.dot = function (e, t) {
  4683. return e[0] * t[0] + e[1] * t[1] + e[2] * t[2] + e[3] * t[3]
  4684. }
  4685. ,
  4686. At.lerp = function (e, t, r, i) {
  4687. var n = t[0]
  4688. , a = t[1]
  4689. , o = t[2]
  4690. , s = t[3];
  4691. return e[0] = n + i * (r[0] - n),
  4692. e[1] = a + i * (r[1] - a),
  4693. e[2] = o + i * (r[2] - o),
  4694. e[3] = s + i * (r[3] - s),
  4695. e
  4696. }
  4697. ,
  4698. At.random = function (e, t) {
  4699. return t = t || 1,
  4700. e[0] = de(),
  4701. e[1] = de(),
  4702. e[2] = de(),
  4703. e[3] = de(),
  4704. At.normalize(e, e),
  4705. At.scale(e, e, t),
  4706. e
  4707. }
  4708. ,
  4709. At.transformMat4 = function (e, t, r) {
  4710. var i = t[0]
  4711. , n = t[1]
  4712. , a = t[2]
  4713. , o = t[3];
  4714. return e[0] = r[0] * i + r[4] * n + r[8] * a + r[12] * o,
  4715. e[1] = r[1] * i + r[5] * n + r[9] * a + r[13] * o,
  4716. e[2] = r[2] * i + r[6] * n + r[10] * a + r[14] * o,
  4717. e[3] = r[3] * i + r[7] * n + r[11] * a + r[15] * o,
  4718. e
  4719. }
  4720. ,
  4721. At.transformQuat = function (e, t, r) {
  4722. var i = t[0]
  4723. , n = t[1]
  4724. , a = t[2]
  4725. , o = r[0]
  4726. , s = r[1]
  4727. , l = r[2]
  4728. , h = r[3]
  4729. , u = h * i + s * a - l * n
  4730. , c = h * n + l * i - o * a
  4731. , d = h * a + o * n - s * i
  4732. , f = -o * i - s * n - l * a;
  4733. return e[0] = u * h + f * -o + c * -l - d * -s,
  4734. e[1] = c * h + f * -s + d * -o - u * -l,
  4735. e[2] = d * h + f * -l + u * -s - c * -o,
  4736. e
  4737. }
  4738. ,
  4739. At.forEach = function () {
  4740. var e = At.create();
  4741. return function (t, r, i, n, a, o) {
  4742. var s, l;
  4743. for (r || (r = 4),
  4744. i || (i = 0),
  4745. l = n ? Math.min(n * r + i, t.length) : t.length,
  4746. s = i; s < l; s += r)
  4747. e[0] = t[s],
  4748. e[1] = t[s + 1],
  4749. e[2] = t[s + 2],
  4750. e[3] = t[s + 3],
  4751. a(e, e, o),
  4752. t[s] = e[0],
  4753. t[s + 1] = e[1],
  4754. t[s + 2] = e[2],
  4755. t[s + 3] = e[3];
  4756. return t
  4757. }
  4758. }();
  4759. const Et = At;
  4760. var Ct = {
  4761. create: function () {
  4762. var e = new ce(9);
  4763. return e[0] = 1,
  4764. e[1] = 0,
  4765. e[2] = 0,
  4766. e[3] = 0,
  4767. e[4] = 1,
  4768. e[5] = 0,
  4769. e[6] = 0,
  4770. e[7] = 0,
  4771. e[8] = 1,
  4772. e
  4773. },
  4774. fromMat4: function (e, t) {
  4775. return e[0] = t[0],
  4776. e[1] = t[1],
  4777. e[2] = t[2],
  4778. e[3] = t[4],
  4779. e[4] = t[5],
  4780. e[5] = t[6],
  4781. e[6] = t[8],
  4782. e[7] = t[9],
  4783. e[8] = t[10],
  4784. e
  4785. },
  4786. clone: function (e) {
  4787. var t = new ce(9);
  4788. return t[0] = e[0],
  4789. t[1] = e[1],
  4790. t[2] = e[2],
  4791. t[3] = e[3],
  4792. t[4] = e[4],
  4793. t[5] = e[5],
  4794. t[6] = e[6],
  4795. t[7] = e[7],
  4796. t[8] = e[8],
  4797. t
  4798. },
  4799. copy: function (e, t) {
  4800. return e[0] = t[0],
  4801. e[1] = t[1],
  4802. e[2] = t[2],
  4803. e[3] = t[3],
  4804. e[4] = t[4],
  4805. e[5] = t[5],
  4806. e[6] = t[6],
  4807. e[7] = t[7],
  4808. e[8] = t[8],
  4809. e
  4810. },
  4811. identity: function (e) {
  4812. return e[0] = 1,
  4813. e[1] = 0,
  4814. e[2] = 0,
  4815. e[3] = 0,
  4816. e[4] = 1,
  4817. e[5] = 0,
  4818. e[6] = 0,
  4819. e[7] = 0,
  4820. e[8] = 1,
  4821. e
  4822. },
  4823. transpose: function (e, t) {
  4824. if (e === t) {
  4825. var r = t[1]
  4826. , i = t[2]
  4827. , n = t[5];
  4828. e[1] = t[3],
  4829. e[2] = t[6],
  4830. e[3] = r,
  4831. e[5] = t[7],
  4832. e[6] = i,
  4833. e[7] = n
  4834. } else
  4835. e[0] = t[0],
  4836. e[1] = t[3],
  4837. e[2] = t[6],
  4838. e[3] = t[1],
  4839. e[4] = t[4],
  4840. e[5] = t[7],
  4841. e[6] = t[2],
  4842. e[7] = t[5],
  4843. e[8] = t[8];
  4844. return e
  4845. },
  4846. invert: function (e, t) {
  4847. var r = t[0]
  4848. , i = t[1]
  4849. , n = t[2]
  4850. , a = t[3]
  4851. , o = t[4]
  4852. , s = t[5]
  4853. , l = t[6]
  4854. , h = t[7]
  4855. , u = t[8]
  4856. , c = u * o - s * h
  4857. , d = -u * a + s * l
  4858. , f = h * a - o * l
  4859. , p = r * c + i * d + n * f;
  4860. return p ? (p = 1 / p,
  4861. e[0] = c * p,
  4862. e[1] = (-u * i + n * h) * p,
  4863. e[2] = (s * i - n * o) * p,
  4864. e[3] = d * p,
  4865. e[4] = (u * r - n * l) * p,
  4866. e[5] = (-s * r + n * a) * p,
  4867. e[6] = f * p,
  4868. e[7] = (-h * r + i * l) * p,
  4869. e[8] = (o * r - i * a) * p,
  4870. e) : null
  4871. },
  4872. adjoint: function (e, t) {
  4873. var r = t[0]
  4874. , i = t[1]
  4875. , n = t[2]
  4876. , a = t[3]
  4877. , o = t[4]
  4878. , s = t[5]
  4879. , l = t[6]
  4880. , h = t[7]
  4881. , u = t[8];
  4882. return e[0] = o * u - s * h,
  4883. e[1] = n * h - i * u,
  4884. e[2] = i * s - n * o,
  4885. e[3] = s * l - a * u,
  4886. e[4] = r * u - n * l,
  4887. e[5] = n * a - r * s,
  4888. e[6] = a * h - o * l,
  4889. e[7] = i * l - r * h,
  4890. e[8] = r * o - i * a,
  4891. e
  4892. },
  4893. determinant: function (e) {
  4894. var t = e[0]
  4895. , r = e[1]
  4896. , i = e[2]
  4897. , n = e[3]
  4898. , a = e[4]
  4899. , o = e[5]
  4900. , s = e[6]
  4901. , l = e[7]
  4902. , h = e[8];
  4903. return t * (h * a - o * l) + r * (-h * n + o * s) + i * (l * n - a * s)
  4904. },
  4905. multiply: function (e, t, r) {
  4906. var i = t[0]
  4907. , n = t[1]
  4908. , a = t[2]
  4909. , o = t[3]
  4910. , s = t[4]
  4911. , l = t[5]
  4912. , h = t[6]
  4913. , u = t[7]
  4914. , c = t[8]
  4915. , d = r[0]
  4916. , f = r[1]
  4917. , p = r[2]
  4918. , m = r[3]
  4919. , g = r[4]
  4920. , _ = r[5]
  4921. , v = r[6]
  4922. , y = r[7]
  4923. , x = r[8];
  4924. return e[0] = d * i + f * o + p * h,
  4925. e[1] = d * n + f * s + p * u,
  4926. e[2] = d * a + f * l + p * c,
  4927. e[3] = m * i + g * o + _ * h,
  4928. e[4] = m * n + g * s + _ * u,
  4929. e[5] = m * a + g * l + _ * c,
  4930. e[6] = v * i + y * o + x * h,
  4931. e[7] = v * n + y * s + x * u,
  4932. e[8] = v * a + y * l + x * c,
  4933. e
  4934. }
  4935. };
  4936. Ct.mul = Ct.multiply,
  4937. Ct.translate = function (e, t, r) {
  4938. var i = t[0]
  4939. , n = t[1]
  4940. , a = t[2]
  4941. , o = t[3]
  4942. , s = t[4]
  4943. , l = t[5]
  4944. , h = t[6]
  4945. , u = t[7]
  4946. , c = t[8]
  4947. , d = r[0]
  4948. , f = r[1];
  4949. return e[0] = i,
  4950. e[1] = n,
  4951. e[2] = a,
  4952. e[3] = o,
  4953. e[4] = s,
  4954. e[5] = l,
  4955. e[6] = d * i + f * o + h,
  4956. e[7] = d * n + f * s + u,
  4957. e[8] = d * a + f * l + c,
  4958. e
  4959. }
  4960. ,
  4961. Ct.rotate = function (e, t, r) {
  4962. var i = t[0]
  4963. , n = t[1]
  4964. , a = t[2]
  4965. , o = t[3]
  4966. , s = t[4]
  4967. , l = t[5]
  4968. , h = t[6]
  4969. , u = t[7]
  4970. , c = t[8]
  4971. , d = Math.sin(r)
  4972. , f = Math.cos(r);
  4973. return e[0] = f * i + d * o,
  4974. e[1] = f * n + d * s,
  4975. e[2] = f * a + d * l,
  4976. e[3] = f * o - d * i,
  4977. e[4] = f * s - d * n,
  4978. e[5] = f * l - d * a,
  4979. e[6] = h,
  4980. e[7] = u,
  4981. e[8] = c,
  4982. e
  4983. }
  4984. ,
  4985. Ct.scale = function (e, t, r) {
  4986. var i = r[0]
  4987. , n = r[1];
  4988. return e[0] = i * t[0],
  4989. e[1] = i * t[1],
  4990. e[2] = i * t[2],
  4991. e[3] = n * t[3],
  4992. e[4] = n * t[4],
  4993. e[5] = n * t[5],
  4994. e[6] = t[6],
  4995. e[7] = t[7],
  4996. e[8] = t[8],
  4997. e
  4998. }
  4999. ,
  5000. Ct.fromMat2d = function (e, t) {
  5001. return e[0] = t[0],
  5002. e[1] = t[1],
  5003. e[2] = 0,
  5004. e[3] = t[2],
  5005. e[4] = t[3],
  5006. e[5] = 0,
  5007. e[6] = t[4],
  5008. e[7] = t[5],
  5009. e[8] = 1,
  5010. e
  5011. }
  5012. ,
  5013. Ct.fromQuat = function (e, t) {
  5014. var r = t[0]
  5015. , i = t[1]
  5016. , n = t[2]
  5017. , a = t[3]
  5018. , o = r + r
  5019. , s = i + i
  5020. , l = n + n
  5021. , h = r * o
  5022. , u = i * o
  5023. , c = i * s
  5024. , d = n * o
  5025. , f = n * s
  5026. , p = n * l
  5027. , m = a * o
  5028. , g = a * s
  5029. , _ = a * l;
  5030. return e[0] = 1 - c - p,
  5031. e[3] = u - _,
  5032. e[6] = d + g,
  5033. e[1] = u + _,
  5034. e[4] = 1 - h - p,
  5035. e[7] = f - m,
  5036. e[2] = d - g,
  5037. e[5] = f + m,
  5038. e[8] = 1 - h - c,
  5039. e
  5040. }
  5041. ,
  5042. Ct.normalFromMat4 = function (e, t) {
  5043. var r = t[0]
  5044. , i = t[1]
  5045. , n = t[2]
  5046. , a = t[3]
  5047. , o = t[4]
  5048. , s = t[5]
  5049. , l = t[6]
  5050. , h = t[7]
  5051. , u = t[8]
  5052. , c = t[9]
  5053. , d = t[10]
  5054. , f = t[11]
  5055. , p = t[12]
  5056. , m = t[13]
  5057. , g = t[14]
  5058. , _ = t[15]
  5059. , v = r * s - i * o
  5060. , y = r * l - n * o
  5061. , x = r * h - a * o
  5062. , b = i * l - n * s
  5063. , w = i * h - a * s
  5064. , T = n * h - a * l
  5065. , S = u * m - c * p
  5066. , M = u * g - d * p
  5067. , A = u * _ - f * p
  5068. , E = c * g - d * m
  5069. , C = c * _ - f * m
  5070. , D = d * _ - f * g
  5071. , L = v * D - y * C + x * E + b * A - w * M + T * S;
  5072. return L ? (L = 1 / L,
  5073. e[0] = (s * D - l * C + h * E) * L,
  5074. e[1] = (l * A - o * D - h * M) * L,
  5075. e[2] = (o * C - s * A + h * S) * L,
  5076. e[3] = (n * C - i * D - a * E) * L,
  5077. e[4] = (r * D - n * A + a * M) * L,
  5078. e[5] = (i * A - r * C - a * S) * L,
  5079. e[6] = (m * T - g * w + _ * b) * L,
  5080. e[7] = (g * x - p * T - _ * y) * L,
  5081. e[8] = (p * w - m * x + _ * v) * L,
  5082. e) : null
  5083. }
  5084. ,
  5085. Ct.frob = function (e) {
  5086. return Math.sqrt(Math.pow(e[0], 2) + Math.pow(e[1], 2) + Math.pow(e[2], 2) + Math.pow(e[3], 2) + Math.pow(e[4], 2) + Math.pow(e[5], 2) + Math.pow(e[6], 2) + Math.pow(e[7], 2) + Math.pow(e[8], 2))
  5087. }
  5088. ;
  5089. const Dt = Ct;
  5090. var Lt, Pt, Ot, Nt, It = {
  5091. create: function () {
  5092. var e = new ce(4);
  5093. return e[0] = 0,
  5094. e[1] = 0,
  5095. e[2] = 0,
  5096. e[3] = 1,
  5097. e
  5098. }
  5099. };
  5100. It.rotationTo = (Lt = Qe.create(),
  5101. Pt = Qe.fromValues(1, 0, 0),
  5102. Ot = Qe.fromValues(0, 1, 0),
  5103. function (e, t, r) {
  5104. var i = Qe.dot(t, r);
  5105. return i < -.999999 ? (Qe.cross(Lt, Pt, t),
  5106. Qe.length(Lt) < 1e-6 && Qe.cross(Lt, Ot, t),
  5107. Qe.normalize(Lt, Lt),
  5108. It.setAxisAngle(e, Lt, Math.PI),
  5109. e) : i > .999999 ? (e[0] = 0,
  5110. e[1] = 0,
  5111. e[2] = 0,
  5112. e[3] = 1,
  5113. e) : (Qe.cross(Lt, t, r),
  5114. e[0] = Lt[0],
  5115. e[1] = Lt[1],
  5116. e[2] = Lt[2],
  5117. e[3] = 1 + i,
  5118. It.normalize(e, e))
  5119. }
  5120. ),
  5121. It.setAxes = (Nt = Dt.create(),
  5122. function (e, t, r, i) {
  5123. return Nt[0] = r[0],
  5124. Nt[3] = r[1],
  5125. Nt[6] = r[2],
  5126. Nt[1] = i[0],
  5127. Nt[4] = i[1],
  5128. Nt[7] = i[2],
  5129. Nt[2] = -t[0],
  5130. Nt[5] = -t[1],
  5131. Nt[8] = -t[2],
  5132. It.normalize(e, It.fromMat3(e, Nt))
  5133. }
  5134. ),
  5135. It.clone = Et.clone,
  5136. It.fromValues = Et.fromValues,
  5137. It.copy = Et.copy,
  5138. It.set = Et.set,
  5139. It.identity = function (e) {
  5140. return e[0] = 0,
  5141. e[1] = 0,
  5142. e[2] = 0,
  5143. e[3] = 1,
  5144. e
  5145. }
  5146. ,
  5147. It.setAxisAngle = function (e, t, r) {
  5148. r *= .5;
  5149. var i = Math.sin(r);
  5150. return e[0] = i * t[0],
  5151. e[1] = i * t[1],
  5152. e[2] = i * t[2],
  5153. e[3] = Math.cos(r),
  5154. e
  5155. }
  5156. ,
  5157. It.add = Et.add,
  5158. It.multiply = function (e, t, r) {
  5159. var i = t[0]
  5160. , n = t[1]
  5161. , a = t[2]
  5162. , o = t[3]
  5163. , s = r[0]
  5164. , l = r[1]
  5165. , h = r[2]
  5166. , u = r[3];
  5167. return e[0] = i * u + o * s + n * h - a * l,
  5168. e[1] = n * u + o * l + a * s - i * h,
  5169. e[2] = a * u + o * h + i * l - n * s,
  5170. e[3] = o * u - i * s - n * l - a * h,
  5171. e
  5172. }
  5173. ,
  5174. It.mul = It.multiply,
  5175. It.scale = Et.scale,
  5176. It.rotateX = function (e, t, r) {
  5177. r *= .5;
  5178. var i = t[0]
  5179. , n = t[1]
  5180. , a = t[2]
  5181. , o = t[3]
  5182. , s = Math.sin(r)
  5183. , l = Math.cos(r);
  5184. return e[0] = i * l + o * s,
  5185. e[1] = n * l + a * s,
  5186. e[2] = a * l - n * s,
  5187. e[3] = o * l - i * s,
  5188. e
  5189. }
  5190. ,
  5191. It.rotateY = function (e, t, r) {
  5192. r *= .5;
  5193. var i = t[0]
  5194. , n = t[1]
  5195. , a = t[2]
  5196. , o = t[3]
  5197. , s = Math.sin(r)
  5198. , l = Math.cos(r);
  5199. return e[0] = i * l - a * s,
  5200. e[1] = n * l + o * s,
  5201. e[2] = a * l + i * s,
  5202. e[3] = o * l - n * s,
  5203. e
  5204. }
  5205. ,
  5206. It.rotateZ = function (e, t, r) {
  5207. r *= .5;
  5208. var i = t[0]
  5209. , n = t[1]
  5210. , a = t[2]
  5211. , o = t[3]
  5212. , s = Math.sin(r)
  5213. , l = Math.cos(r);
  5214. return e[0] = i * l + n * s,
  5215. e[1] = n * l - i * s,
  5216. e[2] = a * l + o * s,
  5217. e[3] = o * l - a * s,
  5218. e
  5219. }
  5220. ,
  5221. It.calculateW = function (e, t) {
  5222. var r = t[0]
  5223. , i = t[1]
  5224. , n = t[2];
  5225. return e[0] = r,
  5226. e[1] = i,
  5227. e[2] = n,
  5228. e[3] = Math.sqrt(Math.abs(1 - r * r - i * i - n * n)),
  5229. e
  5230. }
  5231. ,
  5232. It.dot = Et.dot,
  5233. It.lerp = Et.lerp,
  5234. It.slerp = function (e, t, r, i) {
  5235. var n, a, o, s, l, h = t[0], u = t[1], c = t[2], d = t[3], f = r[0], p = r[1], m = r[2], g = r[3];
  5236. return (a = h * f + u * p + c * m + d * g) < 0 && (a = -a,
  5237. f = -f,
  5238. p = -p,
  5239. m = -m,
  5240. g = -g),
  5241. 1 - a > 1e-6 ? (n = Math.acos(a),
  5242. o = Math.sin(n),
  5243. s = Math.sin((1 - i) * n) / o,
  5244. l = Math.sin(i * n) / o) : (s = 1 - i,
  5245. l = i),
  5246. e[0] = s * h + l * f,
  5247. e[1] = s * u + l * p,
  5248. e[2] = s * c + l * m,
  5249. e[3] = s * d + l * g,
  5250. e
  5251. }
  5252. ,
  5253. It.invert = function (e, t) {
  5254. var r = t[0]
  5255. , i = t[1]
  5256. , n = t[2]
  5257. , a = t[3]
  5258. , o = r * r + i * i + n * n + a * a
  5259. , s = o ? 1 / o : 0;
  5260. return e[0] = -r * s,
  5261. e[1] = -i * s,
  5262. e[2] = -n * s,
  5263. e[3] = a * s,
  5264. e
  5265. }
  5266. ,
  5267. It.conjugate = function (e, t) {
  5268. return e[0] = -t[0],
  5269. e[1] = -t[1],
  5270. e[2] = -t[2],
  5271. e[3] = t[3],
  5272. e
  5273. }
  5274. ,
  5275. It.length = Et.length,
  5276. It.len = It.length,
  5277. It.squaredLength = Et.squaredLength,
  5278. It.sqrLen = It.squaredLength,
  5279. It.normalize = Et.normalize,
  5280. It.fromMat3 = function (e, t) {
  5281. var r, i = t[0] + t[4] + t[8];
  5282. if (i > 0)
  5283. r = Math.sqrt(i + 1),
  5284. e[3] = .5 * r,
  5285. r = .5 / r,
  5286. e[0] = (t[5] - t[7]) * r,
  5287. e[1] = (t[6] - t[2]) * r,
  5288. e[2] = (t[1] - t[3]) * r;
  5289. else {
  5290. var n = 0;
  5291. t[4] > t[0] && (n = 1),
  5292. t[8] > t[3 * n + n] && (n = 2);
  5293. var a = (n + 1) % 3
  5294. , o = (n + 2) % 3;
  5295. r = Math.sqrt(t[3 * n + n] - t[3 * a + a] - t[3 * o + o] + 1),
  5296. e[n] = .5 * r,
  5297. r = .5 / r,
  5298. e[3] = (t[3 * a + o] - t[3 * o + a]) * r,
  5299. e[a] = (t[3 * a + n] + t[3 * n + a]) * r,
  5300. e[o] = (t[3 * o + n] + t[3 * n + o]) * r
  5301. }
  5302. return e
  5303. }
  5304. ;
  5305. const Rt = It;
  5306. var Bt, Ft, zt, Gt, Ut = function () {
  5307. this._axisX = new vt,
  5308. this._axisY = new vt,
  5309. this._axisZ = new vt,
  5310. this.array = Ye.create(),
  5311. this._dirty = !0
  5312. };
  5313. Ut.prototype = {
  5314. constructor: Ut,
  5315. setArray: function (e) {
  5316. for (var t = 0; t < this.array.length; t++)
  5317. this.array[t] = e[t];
  5318. return this._dirty = !0,
  5319. this
  5320. },
  5321. adjoint: function () {
  5322. return Ye.adjoint(this.array, this.array),
  5323. this._dirty = !0,
  5324. this
  5325. },
  5326. clone: function () {
  5327. return (new Ut).copy(this)
  5328. },
  5329. copy: function (e) {
  5330. return Ye.copy(this.array, e.array),
  5331. this._dirty = !0,
  5332. this
  5333. },
  5334. determinant: function () {
  5335. return Ye.determinant(this.array)
  5336. },
  5337. fromQuat: function (e) {
  5338. return Ye.fromQuat(this.array, e.array),
  5339. this._dirty = !0,
  5340. this
  5341. },
  5342. fromRotationTranslation: function (e, t) {
  5343. return Ye.fromRotationTranslation(this.array, e.array, t.array),
  5344. this._dirty = !0,
  5345. this
  5346. },
  5347. fromMat2d: function (e) {
  5348. return Ut.fromMat2d(this, e),
  5349. this
  5350. },
  5351. frustum: function (e, t, r, i, n, a) {
  5352. return Ye.frustum(this.array, e, t, r, i, n, a),
  5353. this._dirty = !0,
  5354. this
  5355. },
  5356. identity: function () {
  5357. return Ye.identity(this.array),
  5358. this._dirty = !0,
  5359. this
  5360. },
  5361. invert: function () {
  5362. return Ye.invert(this.array, this.array),
  5363. this._dirty = !0,
  5364. this
  5365. },
  5366. lookAt: function (e, t, r) {
  5367. return Ye.lookAt(this.array, e.array, t.array, r.array),
  5368. this._dirty = !0,
  5369. this
  5370. },
  5371. mul: function (e) {
  5372. return Ye.mul(this.array, this.array, e.array),
  5373. this._dirty = !0,
  5374. this
  5375. },
  5376. mulLeft: function (e) {
  5377. return Ye.mul(this.array, e.array, this.array),
  5378. this._dirty = !0,
  5379. this
  5380. },
  5381. multiply: function (e) {
  5382. return Ye.multiply(this.array, this.array, e.array),
  5383. this._dirty = !0,
  5384. this
  5385. },
  5386. multiplyLeft: function (e) {
  5387. return Ye.multiply(this.array, e.array, this.array),
  5388. this._dirty = !0,
  5389. this
  5390. },
  5391. ortho: function (e, t, r, i, n, a) {
  5392. return Ye.ortho(this.array, e, t, r, i, n, a),
  5393. this._dirty = !0,
  5394. this
  5395. },
  5396. perspective: function (e, t, r, i) {
  5397. return Ye.perspective(this.array, e, t, r, i),
  5398. this._dirty = !0,
  5399. this
  5400. },
  5401. rotate: function (e, t) {
  5402. return Ye.rotate(this.array, this.array, e, t.array),
  5403. this._dirty = !0,
  5404. this
  5405. },
  5406. rotateX: function (e) {
  5407. return Ye.rotateX(this.array, this.array, e),
  5408. this._dirty = !0,
  5409. this
  5410. },
  5411. rotateY: function (e) {
  5412. return Ye.rotateY(this.array, this.array, e),
  5413. this._dirty = !0,
  5414. this
  5415. },
  5416. rotateZ: function (e) {
  5417. return Ye.rotateZ(this.array, this.array, e),
  5418. this._dirty = !0,
  5419. this
  5420. },
  5421. scale: function (e) {
  5422. return Ye.scale(this.array, this.array, e.array),
  5423. this._dirty = !0,
  5424. this
  5425. },
  5426. translate: function (e) {
  5427. return Ye.translate(this.array, this.array, e.array),
  5428. this._dirty = !0,
  5429. this
  5430. },
  5431. transpose: function () {
  5432. return Ye.transpose(this.array, this.array),
  5433. this._dirty = !0,
  5434. this
  5435. },
  5436. decomposeMatrix: (Bt = Qe.create(),
  5437. Ft = Qe.create(),
  5438. zt = Qe.create(),
  5439. Gt = Dt.create(),
  5440. function (e, t, r) {
  5441. var i = this.array;
  5442. Qe.set(Bt, i[0], i[1], i[2]),
  5443. Qe.set(Ft, i[4], i[5], i[6]),
  5444. Qe.set(zt, i[8], i[9], i[10]);
  5445. var n = Qe.length(Bt)
  5446. , a = Qe.length(Ft)
  5447. , o = Qe.length(zt);
  5448. this.determinant() < 0 && (n = -n),
  5449. e && e.set(n, a, o),
  5450. r.set(i[12], i[13], i[14]),
  5451. Dt.fromMat4(Gt, i),
  5452. Gt[0] /= n,
  5453. Gt[1] /= n,
  5454. Gt[2] /= n,
  5455. Gt[3] /= a,
  5456. Gt[4] /= a,
  5457. Gt[5] /= a,
  5458. Gt[6] /= o,
  5459. Gt[7] /= o,
  5460. Gt[8] /= o,
  5461. Rt.fromMat3(t.array, Gt),
  5462. Rt.normalize(t.array, t.array),
  5463. t._dirty = !0,
  5464. r._dirty = !0
  5465. }
  5466. ),
  5467. toString: function () {
  5468. return "[" + Array.prototype.join.call(this.array, ",") + "]"
  5469. },
  5470. toArray: function () {
  5471. return Array.prototype.slice.call(this.array)
  5472. }
  5473. };
  5474. var kt = Object.defineProperty;
  5475. if (kt) {
  5476. var Vt = Ut.prototype;
  5477. kt(Vt, "z", {
  5478. get: function () {
  5479. var e = this.array;
  5480. return this._axisZ.set(e[8], e[9], e[10]),
  5481. this._axisZ
  5482. },
  5483. set: function (e) {
  5484. var t = this.array;
  5485. e = e.array,
  5486. t[8] = e[0],
  5487. t[9] = e[1],
  5488. t[10] = e[2],
  5489. this._dirty = !0
  5490. }
  5491. }),
  5492. kt(Vt, "y", {
  5493. get: function () {
  5494. var e = this.array;
  5495. return this._axisY.set(e[4], e[5], e[6]),
  5496. this._axisY
  5497. },
  5498. set: function (e) {
  5499. var t = this.array;
  5500. e = e.array,
  5501. t[4] = e[0],
  5502. t[5] = e[1],
  5503. t[6] = e[2],
  5504. this._dirty = !0
  5505. }
  5506. }),
  5507. kt(Vt, "x", {
  5508. get: function () {
  5509. var e = this.array;
  5510. return this._axisX.set(e[0], e[1], e[2]),
  5511. this._axisX
  5512. },
  5513. set: function (e) {
  5514. var t = this.array;
  5515. e = e.array,
  5516. t[0] = e[0],
  5517. t[1] = e[1],
  5518. t[2] = e[2],
  5519. this._dirty = !0
  5520. }
  5521. })
  5522. }
  5523. Ut.adjoint = function (e, t) {
  5524. return Ye.adjoint(e.array, t.array),
  5525. e._dirty = !0,
  5526. e
  5527. }
  5528. ,
  5529. Ut.copy = function (e, t) {
  5530. return Ye.copy(e.array, t.array),
  5531. e._dirty = !0,
  5532. e
  5533. }
  5534. ,
  5535. Ut.determinant = function (e) {
  5536. return Ye.determinant(e.array)
  5537. }
  5538. ,
  5539. Ut.identity = function (e) {
  5540. return Ye.identity(e.array),
  5541. e._dirty = !0,
  5542. e
  5543. }
  5544. ,
  5545. Ut.ortho = function (e, t, r, i, n, a, o) {
  5546. return Ye.ortho(e.array, t, r, i, n, a, o),
  5547. e._dirty = !0,
  5548. e
  5549. }
  5550. ,
  5551. Ut.perspective = function (e, t, r, i, n) {
  5552. return Ye.perspective(e.array, t, r, i, n),
  5553. e._dirty = !0,
  5554. e
  5555. }
  5556. ,
  5557. Ut.lookAt = function (e, t, r, i) {
  5558. return Ye.lookAt(e.array, t.array, r.array, i.array),
  5559. e._dirty = !0,
  5560. e
  5561. }
  5562. ,
  5563. Ut.invert = function (e, t) {
  5564. return Ye.invert(e.array, t.array),
  5565. e._dirty = !0,
  5566. e
  5567. }
  5568. ,
  5569. Ut.multiply = Ut.mul = function (e, t, r) {
  5570. return Ye.mul(e.array, t.array, r.array),
  5571. e._dirty = !0,
  5572. e
  5573. }
  5574. ,
  5575. Ut.fromQuat = function (e, t) {
  5576. return Ye.fromQuat(e.array, t.array),
  5577. e._dirty = !0,
  5578. e
  5579. }
  5580. ,
  5581. Ut.fromRotationTranslation = function (e, t, r) {
  5582. return Ye.fromRotationTranslation(e.array, t.array, r.array),
  5583. e._dirty = !0,
  5584. e
  5585. }
  5586. ,
  5587. Ut.fromMat2d = function (e, t) {
  5588. return e._dirty = !0,
  5589. t = t.array,
  5590. (e = e.array)[0] = t[0],
  5591. e[4] = t[2],
  5592. e[12] = t[4],
  5593. e[1] = t[1],
  5594. e[5] = t[3],
  5595. e[13] = t[5],
  5596. e
  5597. }
  5598. ,
  5599. Ut.rotate = function (e, t, r, i) {
  5600. return Ye.rotate(e.array, t.array, r, i.array),
  5601. e._dirty = !0,
  5602. e
  5603. }
  5604. ,
  5605. Ut.rotateX = function (e, t, r) {
  5606. return Ye.rotateX(e.array, t.array, r),
  5607. e._dirty = !0,
  5608. e
  5609. }
  5610. ,
  5611. Ut.rotateY = function (e, t, r) {
  5612. return Ye.rotateY(e.array, t.array, r),
  5613. e._dirty = !0,
  5614. e
  5615. }
  5616. ,
  5617. Ut.rotateZ = function (e, t, r) {
  5618. return Ye.rotateZ(e.array, t.array, r),
  5619. e._dirty = !0,
  5620. e
  5621. }
  5622. ,
  5623. Ut.scale = function (e, t, r) {
  5624. return Ye.scale(e.array, t.array, r.array),
  5625. e._dirty = !0,
  5626. e
  5627. }
  5628. ,
  5629. Ut.transpose = function (e, t) {
  5630. return Ye.transpose(e.array, t.array),
  5631. e._dirty = !0,
  5632. e
  5633. }
  5634. ,
  5635. Ut.translate = function (e, t, r) {
  5636. return Ye.translate(e.array, t.array, r.array),
  5637. e._dirty = !0,
  5638. e
  5639. }
  5640. ;
  5641. const Ht = Ut;
  5642. var Wt = function (e, t, r, i) {
  5643. e = e || 0,
  5644. t = t || 0,
  5645. r = r || 0,
  5646. i = void 0 === i ? 1 : i,
  5647. this.array = Rt.fromValues(e, t, r, i),
  5648. this._dirty = !0
  5649. };
  5650. Wt.prototype = {
  5651. constructor: Wt,
  5652. add: function (e) {
  5653. return Rt.add(this.array, this.array, e.array),
  5654. this._dirty = !0,
  5655. this
  5656. },
  5657. calculateW: function () {
  5658. return Rt.calculateW(this.array, this.array),
  5659. this._dirty = !0,
  5660. this
  5661. },
  5662. set: function (e, t, r, i) {
  5663. return this.array[0] = e,
  5664. this.array[1] = t,
  5665. this.array[2] = r,
  5666. this.array[3] = i,
  5667. this._dirty = !0,
  5668. this
  5669. },
  5670. setArray: function (e) {
  5671. return this.array[0] = e[0],
  5672. this.array[1] = e[1],
  5673. this.array[2] = e[2],
  5674. this.array[3] = e[3],
  5675. this._dirty = !0,
  5676. this
  5677. },
  5678. clone: function () {
  5679. return new Wt(this.x, this.y, this.z, this.w)
  5680. },
  5681. conjugate: function () {
  5682. return Rt.conjugate(this.array, this.array),
  5683. this._dirty = !0,
  5684. this
  5685. },
  5686. copy: function (e) {
  5687. return Rt.copy(this.array, e.array),
  5688. this._dirty = !0,
  5689. this
  5690. },
  5691. dot: function (e) {
  5692. return Rt.dot(this.array, e.array)
  5693. },
  5694. fromMat3: function (e) {
  5695. return Rt.fromMat3(this.array, e.array),
  5696. this._dirty = !0,
  5697. this
  5698. },
  5699. fromMat4: function () {
  5700. var e = Dt.create();
  5701. return function (t) {
  5702. return Dt.fromMat4(e, t.array),
  5703. Dt.transpose(e, e),
  5704. Rt.fromMat3(this.array, e),
  5705. this._dirty = !0,
  5706. this
  5707. }
  5708. }(),
  5709. identity: function () {
  5710. return Rt.identity(this.array),
  5711. this._dirty = !0,
  5712. this
  5713. },
  5714. invert: function () {
  5715. return Rt.invert(this.array, this.array),
  5716. this._dirty = !0,
  5717. this
  5718. },
  5719. len: function () {
  5720. return Rt.len(this.array)
  5721. },
  5722. length: function () {
  5723. return Rt.length(this.array)
  5724. },
  5725. lerp: function (e, t, r) {
  5726. return Rt.lerp(this.array, e.array, t.array, r),
  5727. this._dirty = !0,
  5728. this
  5729. },
  5730. mul: function (e) {
  5731. return Rt.mul(this.array, this.array, e.array),
  5732. this._dirty = !0,
  5733. this
  5734. },
  5735. mulLeft: function (e) {
  5736. return Rt.multiply(this.array, e.array, this.array),
  5737. this._dirty = !0,
  5738. this
  5739. },
  5740. multiply: function (e) {
  5741. return Rt.multiply(this.array, this.array, e.array),
  5742. this._dirty = !0,
  5743. this
  5744. },
  5745. multiplyLeft: function (e) {
  5746. return Rt.multiply(this.array, e.array, this.array),
  5747. this._dirty = !0,
  5748. this
  5749. },
  5750. normalize: function () {
  5751. return Rt.normalize(this.array, this.array),
  5752. this._dirty = !0,
  5753. this
  5754. },
  5755. rotateX: function (e) {
  5756. return Rt.rotateX(this.array, this.array, e),
  5757. this._dirty = !0,
  5758. this
  5759. },
  5760. rotateY: function (e) {
  5761. return Rt.rotateY(this.array, this.array, e),
  5762. this._dirty = !0,
  5763. this
  5764. },
  5765. rotateZ: function (e) {
  5766. return Rt.rotateZ(this.array, this.array, e),
  5767. this._dirty = !0,
  5768. this
  5769. },
  5770. rotationTo: function (e, t) {
  5771. return Rt.rotationTo(this.array, e.array, t.array),
  5772. this._dirty = !0,
  5773. this
  5774. },
  5775. setAxes: function (e, t, r) {
  5776. return Rt.setAxes(this.array, e.array, t.array, r.array),
  5777. this._dirty = !0,
  5778. this
  5779. },
  5780. setAxisAngle: function (e, t) {
  5781. return Rt.setAxisAngle(this.array, e.array, t),
  5782. this._dirty = !0,
  5783. this
  5784. },
  5785. slerp: function (e, t, r) {
  5786. return Rt.slerp(this.array, e.array, t.array, r),
  5787. this._dirty = !0,
  5788. this
  5789. },
  5790. sqrLen: function () {
  5791. return Rt.sqrLen(this.array)
  5792. },
  5793. squaredLength: function () {
  5794. return Rt.squaredLength(this.array)
  5795. },
  5796. fromEuler: function (e, t) {
  5797. return Wt.fromEuler(this, e, t)
  5798. },
  5799. toString: function () {
  5800. return "[" + Array.prototype.join.call(this.array, ",") + "]"
  5801. },
  5802. toArray: function () {
  5803. return Array.prototype.slice.call(this.array)
  5804. }
  5805. };
  5806. var jt = Object.defineProperty;
  5807. if (jt) {
  5808. var Xt = Wt.prototype;
  5809. jt(Xt, "x", {
  5810. get: function () {
  5811. return this.array[0]
  5812. },
  5813. set: function (e) {
  5814. this.array[0] = e,
  5815. this._dirty = !0
  5816. }
  5817. }),
  5818. jt(Xt, "y", {
  5819. get: function () {
  5820. return this.array[1]
  5821. },
  5822. set: function (e) {
  5823. this.array[1] = e,
  5824. this._dirty = !0
  5825. }
  5826. }),
  5827. jt(Xt, "z", {
  5828. get: function () {
  5829. return this.array[2]
  5830. },
  5831. set: function (e) {
  5832. this.array[2] = e,
  5833. this._dirty = !0
  5834. }
  5835. }),
  5836. jt(Xt, "w", {
  5837. get: function () {
  5838. return this.array[3]
  5839. },
  5840. set: function (e) {
  5841. this.array[3] = e,
  5842. this._dirty = !0
  5843. }
  5844. })
  5845. }
  5846. Wt.add = function (e, t, r) {
  5847. return Rt.add(e.array, t.array, r.array),
  5848. e._dirty = !0,
  5849. e
  5850. }
  5851. ,
  5852. Wt.set = function (e, t, r, i, n) {
  5853. Rt.set(e.array, t, r, i, n),
  5854. e._dirty = !0
  5855. }
  5856. ,
  5857. Wt.copy = function (e, t) {
  5858. return Rt.copy(e.array, t.array),
  5859. e._dirty = !0,
  5860. e
  5861. }
  5862. ,
  5863. Wt.calculateW = function (e, t) {
  5864. return Rt.calculateW(e.array, t.array),
  5865. e._dirty = !0,
  5866. e
  5867. }
  5868. ,
  5869. Wt.conjugate = function (e, t) {
  5870. return Rt.conjugate(e.array, t.array),
  5871. e._dirty = !0,
  5872. e
  5873. }
  5874. ,
  5875. Wt.identity = function (e) {
  5876. return Rt.identity(e.array),
  5877. e._dirty = !0,
  5878. e
  5879. }
  5880. ,
  5881. Wt.invert = function (e, t) {
  5882. return Rt.invert(e.array, t.array),
  5883. e._dirty = !0,
  5884. e
  5885. }
  5886. ,
  5887. Wt.dot = function (e, t) {
  5888. return Rt.dot(e.array, t.array)
  5889. }
  5890. ,
  5891. Wt.len = function (e) {
  5892. return Rt.length(e.array)
  5893. }
  5894. ,
  5895. Wt.lerp = function (e, t, r, i) {
  5896. return Rt.lerp(e.array, t.array, r.array, i),
  5897. e._dirty = !0,
  5898. e
  5899. }
  5900. ,
  5901. Wt.slerp = function (e, t, r, i) {
  5902. return Rt.slerp(e.array, t.array, r.array, i),
  5903. e._dirty = !0,
  5904. e
  5905. }
  5906. ,
  5907. Wt.multiply = Wt.mul = function (e, t, r) {
  5908. return Rt.multiply(e.array, t.array, r.array),
  5909. e._dirty = !0,
  5910. e
  5911. }
  5912. ,
  5913. Wt.rotateX = function (e, t, r) {
  5914. return Rt.rotateX(e.array, t.array, r),
  5915. e._dirty = !0,
  5916. e
  5917. }
  5918. ,
  5919. Wt.rotateY = function (e, t, r) {
  5920. return Rt.rotateY(e.array, t.array, r),
  5921. e._dirty = !0,
  5922. e
  5923. }
  5924. ,
  5925. Wt.rotateZ = function (e, t, r) {
  5926. return Rt.rotateZ(e.array, t.array, r),
  5927. e._dirty = !0,
  5928. e
  5929. }
  5930. ,
  5931. Wt.setAxisAngle = function (e, t, r) {
  5932. return Rt.setAxisAngle(e.array, t.array, r),
  5933. e._dirty = !0,
  5934. e
  5935. }
  5936. ,
  5937. Wt.normalize = function (e, t) {
  5938. return Rt.normalize(e.array, t.array),
  5939. e._dirty = !0,
  5940. e
  5941. }
  5942. ,
  5943. Wt.squaredLength = Wt.sqrLen = function (e) {
  5944. return Rt.sqrLen(e.array)
  5945. }
  5946. ,
  5947. Wt.fromMat3 = function (e, t) {
  5948. return Rt.fromMat3(e.array, t.array),
  5949. e._dirty = !0,
  5950. e
  5951. }
  5952. ,
  5953. Wt.setAxes = function (e, t, r, i) {
  5954. return Rt.setAxes(e.array, t.array, r.array, i.array),
  5955. e._dirty = !0,
  5956. e
  5957. }
  5958. ,
  5959. Wt.rotationTo = function (e, t, r) {
  5960. return Rt.rotationTo(e.array, t.array, r.array),
  5961. e._dirty = !0,
  5962. e
  5963. }
  5964. ,
  5965. Wt.fromEuler = function (e, t, r) {
  5966. e._dirty = !0,
  5967. t = t.array;
  5968. var i = e.array
  5969. , n = Math.cos(t[0] / 2)
  5970. , a = Math.cos(t[1] / 2)
  5971. , o = Math.cos(t[2] / 2)
  5972. , s = Math.sin(t[0] / 2)
  5973. , l = Math.sin(t[1] / 2)
  5974. , h = Math.sin(t[2] / 2);
  5975. switch (r = (r || "XYZ").toUpperCase()) {
  5976. case "XYZ":
  5977. i[0] = s * a * o + n * l * h,
  5978. i[1] = n * l * o - s * a * h,
  5979. i[2] = n * a * h + s * l * o,
  5980. i[3] = n * a * o - s * l * h;
  5981. break;
  5982. case "YXZ":
  5983. i[0] = s * a * o + n * l * h,
  5984. i[1] = n * l * o - s * a * h,
  5985. i[2] = n * a * h - s * l * o,
  5986. i[3] = n * a * o + s * l * h;
  5987. break;
  5988. case "ZXY":
  5989. i[0] = s * a * o - n * l * h,
  5990. i[1] = n * l * o + s * a * h,
  5991. i[2] = n * a * h + s * l * o,
  5992. i[3] = n * a * o - s * l * h;
  5993. break;
  5994. case "ZYX":
  5995. i[0] = s * a * o - n * l * h,
  5996. i[1] = n * l * o + s * a * h,
  5997. i[2] = n * a * h - s * l * o,
  5998. i[3] = n * a * o + s * l * h;
  5999. break;
  6000. case "YZX":
  6001. i[0] = s * a * o + n * l * h,
  6002. i[1] = n * l * o + s * a * h,
  6003. i[2] = n * a * h - s * l * o,
  6004. i[3] = n * a * o - s * l * h;
  6005. break;
  6006. case "XZY":
  6007. i[0] = s * a * o - n * l * h,
  6008. i[1] = n * l * o - s * a * h,
  6009. i[2] = n * a * h + s * l * o,
  6010. i[3] = n * a * o + s * l * h
  6011. }
  6012. }
  6013. ;
  6014. const qt = Wt;
  6015. var Zt, Yt, Kt, Qt, Jt, $t, er = Qe.set, tr = Qe.copy, rr = function (e, t) {
  6016. this.min = e || new vt(1 / 0, 1 / 0, 1 / 0),
  6017. this.max = t || new vt(-1 / 0, -1 / 0, -1 / 0),
  6018. this.vertices = null
  6019. };
  6020. rr.prototype = {
  6021. constructor: rr,
  6022. updateFromVertices: function (e) {
  6023. if (e.length > 0) {
  6024. var t = this.min
  6025. , r = this.max
  6026. , i = t.array
  6027. , n = r.array;
  6028. tr(i, e[0]),
  6029. tr(n, e[0]);
  6030. for (var a = 1; a < e.length; a++) {
  6031. var o = e[a];
  6032. o[0] < i[0] && (i[0] = o[0]),
  6033. o[1] < i[1] && (i[1] = o[1]),
  6034. o[2] < i[2] && (i[2] = o[2]),
  6035. o[0] > n[0] && (n[0] = o[0]),
  6036. o[1] > n[1] && (n[1] = o[1]),
  6037. o[2] > n[2] && (n[2] = o[2])
  6038. }
  6039. t._dirty = !0,
  6040. r._dirty = !0
  6041. }
  6042. },
  6043. union: function (e) {
  6044. var t = this.min
  6045. , r = this.max;
  6046. return Qe.min(t.array, t.array, e.min.array),
  6047. Qe.max(r.array, r.array, e.max.array),
  6048. t._dirty = !0,
  6049. r._dirty = !0,
  6050. this
  6051. },
  6052. intersection: function (e) {
  6053. var t = this.min
  6054. , r = this.max;
  6055. return Qe.max(t.array, t.array, e.min.array),
  6056. Qe.min(r.array, r.array, e.max.array),
  6057. t._dirty = !0,
  6058. r._dirty = !0,
  6059. this
  6060. },
  6061. intersectBoundingBox: function (e) {
  6062. var t = this.min.array
  6063. , r = this.max.array
  6064. , i = e.min.array
  6065. , n = e.max.array;
  6066. return !(t[0] > n[0] || t[1] > n[1] || t[2] > n[2] || r[0] < i[0] || r[1] < i[1] || r[2] < i[2])
  6067. },
  6068. containBoundingBox: function (e) {
  6069. var t = this.min.array
  6070. , r = this.max.array
  6071. , i = e.min.array
  6072. , n = e.max.array;
  6073. return t[0] <= i[0] && t[1] <= i[1] && t[2] <= i[2] && r[0] >= n[0] && r[1] >= n[1] && r[2] >= n[2]
  6074. },
  6075. containPoint: function (e) {
  6076. var t = this.min.array
  6077. , r = this.max.array
  6078. , i = e.array;
  6079. return t[0] <= i[0] && t[1] <= i[1] && t[2] <= i[2] && r[0] >= i[0] && r[1] >= i[1] && r[2] >= i[2]
  6080. },
  6081. isFinite: function () {
  6082. var e = this.min.array
  6083. , t = this.max.array;
  6084. return isFinite(e[0]) && isFinite(e[1]) && isFinite(e[2]) && isFinite(t[0]) && isFinite(t[1]) && isFinite(t[2])
  6085. },
  6086. applyTransform: function (e) {
  6087. this.transformFrom(this, e)
  6088. },
  6089. transformFrom: (Zt = Qe.create(),
  6090. Yt = Qe.create(),
  6091. Kt = Qe.create(),
  6092. Qt = Qe.create(),
  6093. Jt = Qe.create(),
  6094. $t = Qe.create(),
  6095. function (e, t) {
  6096. var r = e.min.array
  6097. , i = e.max.array
  6098. , n = t.array;
  6099. return Zt[0] = n[0] * r[0],
  6100. Zt[1] = n[1] * r[0],
  6101. Zt[2] = n[2] * r[0],
  6102. Yt[0] = n[0] * i[0],
  6103. Yt[1] = n[1] * i[0],
  6104. Yt[2] = n[2] * i[0],
  6105. Kt[0] = n[4] * r[1],
  6106. Kt[1] = n[5] * r[1],
  6107. Kt[2] = n[6] * r[1],
  6108. Qt[0] = n[4] * i[1],
  6109. Qt[1] = n[5] * i[1],
  6110. Qt[2] = n[6] * i[1],
  6111. Jt[0] = n[8] * r[2],
  6112. Jt[1] = n[9] * r[2],
  6113. Jt[2] = n[10] * r[2],
  6114. $t[0] = n[8] * i[2],
  6115. $t[1] = n[9] * i[2],
  6116. $t[2] = n[10] * i[2],
  6117. r = this.min.array,
  6118. i = this.max.array,
  6119. r[0] = Math.min(Zt[0], Yt[0]) + Math.min(Kt[0], Qt[0]) + Math.min(Jt[0], $t[0]) + n[12],
  6120. r[1] = Math.min(Zt[1], Yt[1]) + Math.min(Kt[1], Qt[1]) + Math.min(Jt[1], $t[1]) + n[13],
  6121. r[2] = Math.min(Zt[2], Yt[2]) + Math.min(Kt[2], Qt[2]) + Math.min(Jt[2], $t[2]) + n[14],
  6122. i[0] = Math.max(Zt[0], Yt[0]) + Math.max(Kt[0], Qt[0]) + Math.max(Jt[0], $t[0]) + n[12],
  6123. i[1] = Math.max(Zt[1], Yt[1]) + Math.max(Kt[1], Qt[1]) + Math.max(Jt[1], $t[1]) + n[13],
  6124. i[2] = Math.max(Zt[2], Yt[2]) + Math.max(Kt[2], Qt[2]) + Math.max(Jt[2], $t[2]) + n[14],
  6125. this.min._dirty = !0,
  6126. this.max._dirty = !0,
  6127. this
  6128. }
  6129. ),
  6130. applyProjection: function (e) {
  6131. var t = this.min.array
  6132. , r = this.max.array
  6133. , i = e.array
  6134. , n = t[0]
  6135. , a = t[1]
  6136. , o = t[2]
  6137. , s = r[0]
  6138. , l = r[1]
  6139. , h = t[2]
  6140. , u = r[0]
  6141. , c = r[1]
  6142. , d = r[2];
  6143. if (1 === i[15])
  6144. t[0] = i[0] * n + i[12],
  6145. t[1] = i[5] * a + i[13],
  6146. r[2] = i[10] * o + i[14],
  6147. r[0] = i[0] * u + i[12],
  6148. r[1] = i[5] * c + i[13],
  6149. t[2] = i[10] * d + i[14];
  6150. else {
  6151. var f = -1 / o;
  6152. t[0] = i[0] * n * f,
  6153. t[1] = i[5] * a * f,
  6154. r[2] = (i[10] * o + i[14]) * f,
  6155. f = -1 / h,
  6156. r[0] = i[0] * s * f,
  6157. r[1] = i[5] * l * f,
  6158. f = -1 / d,
  6159. t[2] = (i[10] * d + i[14]) * f
  6160. }
  6161. return this.min._dirty = !0,
  6162. this.max._dirty = !0,
  6163. this
  6164. },
  6165. updateVertices: function () {
  6166. var e = this.vertices;
  6167. if (!e) {
  6168. e = [];
  6169. for (var t = 0; t < 8; t++)
  6170. e[t] = Qe.fromValues(0, 0, 0);
  6171. this.vertices = e
  6172. }
  6173. var r = this.min.array
  6174. , i = this.max.array;
  6175. return er(e[0], r[0], r[1], r[2]),
  6176. er(e[1], r[0], i[1], r[2]),
  6177. er(e[2], i[0], r[1], r[2]),
  6178. er(e[3], i[0], i[1], r[2]),
  6179. er(e[4], r[0], r[1], i[2]),
  6180. er(e[5], r[0], i[1], i[2]),
  6181. er(e[6], i[0], r[1], i[2]),
  6182. er(e[7], i[0], i[1], i[2]),
  6183. this
  6184. },
  6185. copy: function (e) {
  6186. var t = this.min
  6187. , r = this.max;
  6188. return tr(t.array, e.min.array),
  6189. tr(r.array, e.max.array),
  6190. t._dirty = !0,
  6191. r._dirty = !0,
  6192. this
  6193. },
  6194. clone: function () {
  6195. var e = new rr;
  6196. return e.copy(this),
  6197. e
  6198. }
  6199. };
  6200. const ir = rr;
  6201. var nr, ar, or = 0;
  6202. const sr = m.extend({
  6203. name: "",
  6204. position: null,
  6205. rotation: null,
  6206. scale: null,
  6207. worldTransform: null,
  6208. localTransform: null,
  6209. autoUpdateLocalTransform: !0,
  6210. _parent: null,
  6211. _scene: null,
  6212. _needsUpdateWorldTransform: !0,
  6213. _inIterating: !1,
  6214. __depth: 0
  6215. }, (function () {
  6216. this.name || (this.name = (this.type || "NODE") + "_" + or++),
  6217. this.position || (this.position = new vt),
  6218. this.rotation || (this.rotation = new qt),
  6219. this.scale || (this.scale = new vt(1, 1, 1)),
  6220. this.worldTransform = new Ht,
  6221. this.localTransform = new Ht,
  6222. this._children = []
  6223. }
  6224. ), {
  6225. target: null,
  6226. invisible: !1,
  6227. isSkinnedMesh: function () {
  6228. return !1
  6229. },
  6230. isRenderable: function () {
  6231. return !1
  6232. },
  6233. setName: function (e) {
  6234. var t = this._scene;
  6235. if (t) {
  6236. var r = t._nodeRepository;
  6237. delete r[this.name],
  6238. r[e] = this
  6239. }
  6240. this.name = e
  6241. },
  6242. add: function (e) {
  6243. var t = e._parent;
  6244. if (t !== this) {
  6245. t && t.remove(e),
  6246. e._parent = this,
  6247. this._children.push(e);
  6248. var r = this._scene;
  6249. r && r !== e.scene && e.traverse(this._addSelfToScene, this),
  6250. e._needsUpdateWorldTransform = !0
  6251. }
  6252. },
  6253. remove: function (e) {
  6254. var t = this._children
  6255. , r = t.indexOf(e);
  6256. r < 0 || (t.splice(r, 1),
  6257. e._parent = null,
  6258. this._scene && e.traverse(this._removeSelfFromScene, this))
  6259. },
  6260. removeAll: function () {
  6261. for (var e = this._children, t = 0; t < e.length; t++)
  6262. e[t]._parent = null,
  6263. this._scene && e[t].traverse(this._removeSelfFromScene, this);
  6264. this._children = []
  6265. },
  6266. getScene: function () {
  6267. return this._scene
  6268. },
  6269. getParent: function () {
  6270. return this._parent
  6271. },
  6272. _removeSelfFromScene: function (e) {
  6273. e._scene.removeFromScene(e),
  6274. e._scene = null
  6275. },
  6276. _addSelfToScene: function (e) {
  6277. this._scene.addToScene(e),
  6278. e._scene = this._scene
  6279. },
  6280. isAncestor: function (e) {
  6281. for (var t = e._parent; t;) {
  6282. if (t === this)
  6283. return !0;
  6284. t = t._parent
  6285. }
  6286. return !1
  6287. },
  6288. children: function () {
  6289. return this._children.slice()
  6290. },
  6291. childAt: function (e) {
  6292. return this._children[e]
  6293. },
  6294. getChildByName: function (e) {
  6295. for (var t = this._children, r = 0; r < t.length; r++)
  6296. if (t[r].name === e)
  6297. return t[r]
  6298. },
  6299. getDescendantByName: function (e) {
  6300. for (var t = this._children, r = 0; r < t.length; r++) {
  6301. var i = t[r];
  6302. if (i.name === e)
  6303. return i;
  6304. var n = i.getDescendantByName(e);
  6305. if (n)
  6306. return n
  6307. }
  6308. },
  6309. queryNode: function (e) {
  6310. if (e) {
  6311. for (var t = e.split("/"), r = this, i = 0; i < t.length; i++) {
  6312. var n = t[i];
  6313. if (n) {
  6314. for (var a = !1, o = r._children, s = 0; s < o.length; s++) {
  6315. var l = o[s];
  6316. if (l.name === n) {
  6317. r = l,
  6318. a = !0;
  6319. break
  6320. }
  6321. }
  6322. if (!a)
  6323. return
  6324. }
  6325. }
  6326. return r
  6327. }
  6328. },
  6329. getPath: function (e) {
  6330. if (!this._parent)
  6331. return "/";
  6332. for (var t = this._parent, r = this.name; t._parent && (r = t.name + "/" + r,
  6333. t._parent != e);)
  6334. t = t._parent;
  6335. return !t._parent && e ? null : r
  6336. },
  6337. traverse: function (e, t) {
  6338. e.call(t, this);
  6339. for (var r = this._children, i = 0, n = r.length; i < n; i++)
  6340. r[i].traverse(e, t)
  6341. },
  6342. eachChild: function (e, t) {
  6343. for (var r = this._children, i = 0, n = r.length; i < n; i++) {
  6344. var a = r[i];
  6345. e.call(t, a, i)
  6346. }
  6347. },
  6348. setLocalTransform: function (e) {
  6349. Ye.copy(this.localTransform.array, e.array),
  6350. this.decomposeLocalTransform()
  6351. },
  6352. decomposeLocalTransform: function (e) {
  6353. var t = e ? null : this.scale;
  6354. this.localTransform.decomposeMatrix(t, this.rotation, this.position)
  6355. },
  6356. setWorldTransform: function (e) {
  6357. Ye.copy(this.worldTransform.array, e.array),
  6358. this.decomposeWorldTransform()
  6359. },
  6360. decomposeWorldTransform: (ar = Ye.create(),
  6361. function (e) {
  6362. var t = this.localTransform
  6363. , r = this.worldTransform;
  6364. this._parent ? (Ye.invert(ar, this._parent.worldTransform.array),
  6365. Ye.multiply(t.array, ar, r.array)) : Ye.copy(t.array, r.array);
  6366. var i = e ? null : this.scale;
  6367. t.decomposeMatrix(i, this.rotation, this.position)
  6368. }
  6369. ),
  6370. transformNeedsUpdate: function () {
  6371. return this.position._dirty || this.rotation._dirty || this.scale._dirty
  6372. },
  6373. updateLocalTransform: function () {
  6374. var e = this.position
  6375. , t = this.rotation
  6376. , r = this.scale;
  6377. if (this.transformNeedsUpdate()) {
  6378. var i = this.localTransform.array;
  6379. Ye.fromRotationTranslation(i, t.array, e.array),
  6380. Ye.scale(i, i, r.array),
  6381. t._dirty = !1,
  6382. r._dirty = !1,
  6383. e._dirty = !1,
  6384. this._needsUpdateWorldTransform = !0
  6385. }
  6386. },
  6387. _updateWorldTransformTopDown: function () {
  6388. var e = this.localTransform.array
  6389. , t = this.worldTransform.array;
  6390. this._parent ? Ye.multiplyAffine(t, this._parent.worldTransform.array, e) : Ye.copy(t, e)
  6391. },
  6392. updateWorldTransform: function () {
  6393. for (var e = this; e && e.getParent() && e.getParent().transformNeedsUpdate();)
  6394. e = e.getParent();
  6395. e.update()
  6396. },
  6397. update: function (e) {
  6398. this.autoUpdateLocalTransform ? this.updateLocalTransform() : e = !0,
  6399. (e || this._needsUpdateWorldTransform) && (this._updateWorldTransformTopDown(),
  6400. e = !0,
  6401. this._needsUpdateWorldTransform = !1);
  6402. for (var t = this._children, r = 0, i = t.length; r < i; r++)
  6403. t[r].update(e)
  6404. },
  6405. getBoundingBox: function () {
  6406. function e(e) {
  6407. return !e.invisible && e.geometry
  6408. }
  6409. var t = new ir
  6410. , r = new Ht
  6411. , i = new Ht;
  6412. return function (n, a) {
  6413. return a = a || new ir,
  6414. n = n || e,
  6415. this._parent ? Ht.invert(i, this._parent.worldTransform) : Ht.identity(i),
  6416. this.traverse((function (e) {
  6417. e.geometry && e.geometry.boundingBox && (t.copy(e.geometry.boundingBox),
  6418. Ht.multiply(r, i, e.worldTransform),
  6419. t.applyTransform(r),
  6420. a.union(t))
  6421. }
  6422. ), this, e),
  6423. a
  6424. }
  6425. }(),
  6426. getWorldPosition: function (e) {
  6427. this.transformNeedsUpdate() && this.updateWorldTransform();
  6428. var t = this.worldTransform.array;
  6429. if (e) {
  6430. var r = e.array;
  6431. return r[0] = t[12],
  6432. r[1] = t[13],
  6433. r[2] = t[14],
  6434. e
  6435. }
  6436. return new vt(t[12], t[13], t[14])
  6437. },
  6438. clone: function () {
  6439. var e = new this.constructor
  6440. , t = this._children;
  6441. e.setName(this.name),
  6442. e.position.copy(this.position),
  6443. e.rotation.copy(this.rotation),
  6444. e.scale.copy(this.scale);
  6445. for (var r = 0; r < t.length; r++)
  6446. e.add(t[r].clone());
  6447. return e
  6448. },
  6449. rotateAround: function () {
  6450. var e = new vt
  6451. , t = new Ht;
  6452. return function (r, i, n) {
  6453. e.copy(this.position).subtract(r);
  6454. var a = this.localTransform;
  6455. a.identity(),
  6456. a.translate(r),
  6457. a.rotate(n, i),
  6458. t.fromRotationTranslation(this.rotation, e),
  6459. a.multiply(t),
  6460. a.scale(this.scale),
  6461. this.decomposeLocalTransform(),
  6462. this._needsUpdateWorldTransform = !0
  6463. }
  6464. }(),
  6465. lookAt: (nr = new Ht,
  6466. function (e, t) {
  6467. nr.lookAt(this.position, e, t || this.localTransform.y).invert(),
  6468. this.setLocalTransform(nr),
  6469. this.target = e
  6470. }
  6471. )
  6472. });
  6473. var lr, hr = sr.extend({
  6474. material: null,
  6475. geometry: null,
  6476. mode: 4,
  6477. _renderInfo: null
  6478. }, {
  6479. __program: null,
  6480. lightGroup: 0,
  6481. renderOrder: 0,
  6482. culling: !0,
  6483. cullFace: x,
  6484. frontFace: w,
  6485. frustumCulling: !0,
  6486. receiveShadow: !0,
  6487. castShadow: !0,
  6488. ignorePicking: !1,
  6489. ignorePreZ: !1,
  6490. ignoreGBuffer: !1,
  6491. isRenderable: function () {
  6492. return this.geometry && this.material && this.material.shader && !this.invisible && this.geometry.vertexCount > 0
  6493. },
  6494. beforeRender: function (e) { },
  6495. afterRender: function (e, t) { },
  6496. getBoundingBox: function (e, t) {
  6497. return t = sr.prototype.getBoundingBox.call(this, e, t),
  6498. this.geometry && this.geometry.boundingBox && t.union(this.geometry.boundingBox),
  6499. t
  6500. },
  6501. clone: (lr = ["castShadow", "receiveShadow", "mode", "culling", "cullFace", "frontFace", "frustumCulling", "renderOrder", "lineWidth", "ignorePicking", "ignorePreZ", "ignoreGBuffer"],
  6502. function () {
  6503. var e = sr.prototype.clone.call(this);
  6504. e.geometry = this.geometry,
  6505. e.material = this.material;
  6506. for (var t = 0; t < lr.length; t++) {
  6507. var r = lr[t];
  6508. e[r] !== this[r] && (e[r] = this[r])
  6509. }
  6510. return e
  6511. }
  6512. )
  6513. });
  6514. hr.POINTS = 0,
  6515. hr.LINES = 1,
  6516. hr.LINE_LOOP = 2,
  6517. hr.LINE_STRIP = 3,
  6518. hr.TRIANGLES = 4,
  6519. hr.TRIANGLE_STRIP = 5,
  6520. hr.TRIANGLE_FAN = 6,
  6521. hr.BACK = x,
  6522. hr.FRONT = y,
  6523. hr.FRONT_AND_BACK = 1032,
  6524. hr.CW = b,
  6525. hr.CCW = w;
  6526. const ur = hr;
  6527. var cr, dr, fr, pr, mr, gr = m.extend({
  6528. scene: null,
  6529. camera: null,
  6530. renderer: null
  6531. }, (function () {
  6532. this._ray = new Mt,
  6533. this._ndc = new _e
  6534. }
  6535. ), {
  6536. pick: function (e, t, r) {
  6537. return this.pickAll(e, t, [], r)[0] || null
  6538. },
  6539. pickAll: function (e, t, r, i) {
  6540. return this.renderer.screenToNDC(e, t, this._ndc),
  6541. this.camera.castRay(this._ndc, this._ray),
  6542. r = r || [],
  6543. this._intersectNode(this.scene, r, i || !1),
  6544. r.sort(this._intersectionCompareFunc),
  6545. r
  6546. },
  6547. _intersectNode: function (e, t, r) {
  6548. e instanceof ur && e.isRenderable() && (e.ignorePicking && !r || !(4 === e.mode && e.geometry.isUseIndices() || e.geometry.pickByRay || e.geometry.pick) || this._intersectRenderable(e, t));
  6549. for (var i = 0; i < e._children.length; i++)
  6550. this._intersectNode(e._children[i], t, r)
  6551. },
  6552. _intersectRenderable: (cr = new vt,
  6553. dr = new vt,
  6554. fr = new vt,
  6555. pr = new Mt,
  6556. mr = new Ht,
  6557. function (e, t) {
  6558. var r = e.isSkinnedMesh();
  6559. pr.copy(this._ray),
  6560. Ht.invert(mr, e.worldTransform),
  6561. r || pr.applyTransform(mr);
  6562. var i = e.geometry
  6563. , n = r ? e.skeleton.boundingBox : i.boundingBox;
  6564. if (!n || pr.intersectBoundingBox(n))
  6565. if (i.pick)
  6566. i.pick(this._ndc.x, this._ndc.y, this.renderer, this.camera, e, t);
  6567. else if (i.pickByRay)
  6568. i.pickByRay(pr, e, t);
  6569. else {
  6570. var a, o, s = e.cullFace === x && e.frontFace === w || e.cullFace === y && e.frontFace === b, l = i.indices, h = i.attributes.position, u = i.attributes.weight, c = i.attributes.joint, d = [];
  6571. if (h && h.value && l) {
  6572. if (r) {
  6573. o = e.skeleton.getSubSkinMatrices(e.__uid__, e.joints);
  6574. for (var f = 0; f < e.joints.length; f++) {
  6575. d[f] = d[f] || [];
  6576. for (var p = 0; p < 16; p++)
  6577. d[f][p] = o[16 * f + p]
  6578. }
  6579. var m = []
  6580. , g = []
  6581. , _ = []
  6582. , v = []
  6583. , T = []
  6584. , S = i.attributes.skinnedPosition;
  6585. for (S && S.value || (i.createAttribute("skinnedPosition", "f", 3),
  6586. (S = i.attributes.skinnedPosition).init(i.vertexCount)),
  6587. f = 0; f < i.vertexCount; f++) {
  6588. for (h.get(f, m),
  6589. u.get(f, g),
  6590. c.get(f, _),
  6591. g[3] = 1 - g[0] - g[1] - g[2],
  6592. Qe.set(v, 0, 0, 0),
  6593. p = 0; p < 4; p++)
  6594. _[p] >= 0 && g[p] > 1e-4 && (Qe.transformMat4(T, m, d[_[p]]),
  6595. Qe.scaleAndAdd(v, v, T, g[p]));
  6596. S.set(f, v)
  6597. }
  6598. }
  6599. for (f = 0; f < l.length; f += 3) {
  6600. var M = l[f]
  6601. , A = l[f + 1]
  6602. , E = l[f + 2]
  6603. , C = r ? i.attributes.skinnedPosition : h;
  6604. if (C.get(M, cr.array),
  6605. C.get(A, dr.array),
  6606. C.get(E, fr.array),
  6607. a = s ? pr.intersectTriangle(cr, dr, fr, e.culling) : pr.intersectTriangle(cr, fr, dr, e.culling)) {
  6608. var D = new vt;
  6609. r ? vt.copy(D, a) : vt.transformMat4(D, a, e.worldTransform),
  6610. t.push(new gr.Intersection(a, D, e, [M, A, E], f / 3, vt.dist(D, this._ray.origin)))
  6611. }
  6612. }
  6613. }
  6614. }
  6615. }
  6616. ),
  6617. _intersectionCompareFunc: function (e, t) {
  6618. return e.distance - t.distance
  6619. }
  6620. });
  6621. gr.Intersection = function (e, t, r, i, n, a) {
  6622. this.point = e,
  6623. this.pointWorld = t,
  6624. this.target = r,
  6625. this.triangle = i,
  6626. this.triangleIndex = n,
  6627. this.distance = a
  6628. }
  6629. ;
  6630. const _r = gr;
  6631. var vr = "__dt__"
  6632. , yr = function () {
  6633. this._contextId = 0,
  6634. this._caches = [],
  6635. this._context = {}
  6636. };
  6637. (yr.prototype = {
  6638. use: function (e, t) {
  6639. var r = this._caches;
  6640. r[e] || (r[e] = {},
  6641. t && (r[e] = t())),
  6642. this._contextId = e,
  6643. this._context = r[e]
  6644. },
  6645. put: function (e, t) {
  6646. this._context[e] = t
  6647. },
  6648. get: function (e) {
  6649. return this._context[e]
  6650. },
  6651. dirty: function (e) {
  6652. var t = vr + (e = e || "");
  6653. this.put(t, !0)
  6654. },
  6655. dirtyAll: function (e) {
  6656. for (var t = vr + (e = e || ""), r = this._caches, i = 0; i < r.length; i++)
  6657. r[i] && (r[i][t] = !0)
  6658. },
  6659. fresh: function (e) {
  6660. var t = vr + (e = e || "");
  6661. this.put(t, !1)
  6662. },
  6663. freshAll: function (e) {
  6664. for (var t = vr + (e = e || ""), r = this._caches, i = 0; i < r.length; i++)
  6665. r[i] && (r[i][t] = !1)
  6666. },
  6667. isDirty: function (e) {
  6668. var t = vr + (e = e || "")
  6669. , r = this._context;
  6670. return !r.hasOwnProperty(t) || !0 === r[t]
  6671. },
  6672. deleteContext: function (e) {
  6673. delete this._caches[e],
  6674. this._context = {}
  6675. },
  6676. delete: function (e) {
  6677. delete this._context[e]
  6678. },
  6679. clearAll: function () {
  6680. this._caches = {}
  6681. },
  6682. getContext: function () {
  6683. return this._context
  6684. },
  6685. eachContext: function (e, t) {
  6686. Object.keys(this._caches).forEach((function (r) {
  6687. e && e.call(t, r)
  6688. }
  6689. ))
  6690. },
  6691. miss: function (e) {
  6692. return !this._context.hasOwnProperty(e)
  6693. }
  6694. }).constructor = yr;
  6695. const xr = yr;
  6696. var br = m.extend({
  6697. width: 512,
  6698. height: 512,
  6699. type: T,
  6700. format: A,
  6701. wrapS: N,
  6702. wrapT: N,
  6703. minFilter: O,
  6704. magFilter: C,
  6705. useMipmap: !0,
  6706. anisotropic: 1,
  6707. flipY: !0,
  6708. sRGB: !0,
  6709. unpackAlignment: 4,
  6710. premultiplyAlpha: !1,
  6711. dynamic: !1,
  6712. NPOT: !1,
  6713. __used: 0
  6714. }, (function () {
  6715. this._cache = new xr
  6716. }
  6717. ), {
  6718. getWebGLTexture: function (e) {
  6719. var t = e.gl
  6720. , r = this._cache;
  6721. return r.use(e.__uid__),
  6722. r.miss("webgl_texture") && r.put("webgl_texture", t.createTexture()),
  6723. this.dynamic ? this.update(e) : r.isDirty() && (this.update(e),
  6724. r.fresh()),
  6725. r.get("webgl_texture")
  6726. },
  6727. bind: function () { },
  6728. unbind: function () { },
  6729. dirty: function () {
  6730. this._cache && this._cache.dirtyAll()
  6731. },
  6732. update: function (e) { },
  6733. updateCommon: function (e) {
  6734. var t = e.gl;
  6735. t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL, this.flipY),
  6736. t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha),
  6737. t.pixelStorei(t.UNPACK_ALIGNMENT, this.unpackAlignment),
  6738. this.format === M && (this.useMipmap = !1);
  6739. var r = e.getGLExtension("EXT_sRGB");
  6740. this.format !== br.SRGB || r || (this.format = br.RGB),
  6741. this.format !== br.SRGB_ALPHA || r || (this.format = br.RGBA),
  6742. this.NPOT = !this.isPowerOfTwo()
  6743. },
  6744. getAvailableWrapS: function () {
  6745. return this.NPOT ? I : this.wrapS
  6746. },
  6747. getAvailableWrapT: function () {
  6748. return this.NPOT ? I : this.wrapT
  6749. },
  6750. getAvailableMinFilter: function () {
  6751. var e = this.minFilter;
  6752. return this.NPOT || !this.useMipmap ? e === D || e === P ? E : e === O || e === L ? C : e : e
  6753. },
  6754. getAvailableMagFilter: function () {
  6755. return this.magFilter
  6756. },
  6757. nextHighestPowerOfTwo: function (e) {
  6758. --e;
  6759. for (var t = 1; t < 32; t <<= 1)
  6760. e |= e >> t;
  6761. return e + 1
  6762. },
  6763. dispose: function (e) {
  6764. var t = this._cache;
  6765. t.use(e.__uid__);
  6766. var r = t.get("webgl_texture");
  6767. r && e.gl.deleteTexture(r),
  6768. t.deleteContext(e.__uid__)
  6769. },
  6770. isRenderable: function () { },
  6771. isPowerOfTwo: function () { }
  6772. });
  6773. Object.defineProperty(br.prototype, "width", {
  6774. get: function () {
  6775. return this._width
  6776. },
  6777. set: function (e) {
  6778. this._width = e
  6779. }
  6780. }),
  6781. Object.defineProperty(br.prototype, "height", {
  6782. get: function () {
  6783. return this._height
  6784. },
  6785. set: function (e) {
  6786. this._height = e
  6787. }
  6788. }),
  6789. br.BYTE = 5120,
  6790. br.UNSIGNED_BYTE = T,
  6791. br.SHORT = 5122,
  6792. br.UNSIGNED_SHORT = 5123,
  6793. br.INT = 5124,
  6794. br.UNSIGNED_INT = 5125,
  6795. br.FLOAT = S,
  6796. br.HALF_FLOAT = 36193,
  6797. br.UNSIGNED_INT_24_8_WEBGL = 34042,
  6798. br.DEPTH_COMPONENT = M,
  6799. br.DEPTH_STENCIL = 34041,
  6800. br.ALPHA = 6406,
  6801. br.RGB = 6407,
  6802. br.RGBA = A,
  6803. br.LUMINANCE = 6409,
  6804. br.LUMINANCE_ALPHA = 6410,
  6805. br.SRGB = 35904,
  6806. br.SRGB_ALPHA = 35906,
  6807. br.COMPRESSED_RGB_S3TC_DXT1_EXT = 33776,
  6808. br.COMPRESSED_RGBA_S3TC_DXT1_EXT = 33777,
  6809. br.COMPRESSED_RGBA_S3TC_DXT3_EXT = 33778,
  6810. br.COMPRESSED_RGBA_S3TC_DXT5_EXT = 33779,
  6811. br.NEAREST = E,
  6812. br.LINEAR = C,
  6813. br.NEAREST_MIPMAP_NEAREST = D,
  6814. br.LINEAR_MIPMAP_NEAREST = L,
  6815. br.NEAREST_MIPMAP_LINEAR = P,
  6816. br.LINEAR_MIPMAP_LINEAR = O,
  6817. br.REPEAT = N,
  6818. br.CLAMP_TO_EDGE = I,
  6819. br.MIRRORED_REPEAT = 33648;
  6820. const wr = br;
  6821. var Tr = ur.extend({
  6822. skeleton: null,
  6823. joints: null
  6824. }, (function () {
  6825. this.joints || (this.joints = [])
  6826. }
  6827. ), {
  6828. offsetMatrix: null,
  6829. isInstancedMesh: function () {
  6830. return !1
  6831. },
  6832. isSkinnedMesh: function () {
  6833. return !!(this.skeleton && this.joints && this.joints.length > 0)
  6834. },
  6835. clone: function () {
  6836. var e = ur.prototype.clone.call(this);
  6837. return e.skeleton = this.skeleton,
  6838. this.joints && (e.joints = this.joints.slice()),
  6839. e
  6840. }
  6841. });
  6842. Tr.POINTS = 0,
  6843. Tr.LINES = 1,
  6844. Tr.LINE_LOOP = 2,
  6845. Tr.LINE_STRIP = 3,
  6846. Tr.TRIANGLES = 4,
  6847. Tr.TRIANGLE_STRIP = 5,
  6848. Tr.TRIANGLE_FAN = 6,
  6849. Tr.BACK = x,
  6850. Tr.FRONT = y,
  6851. Tr.FRONT_AND_BACK = 1032,
  6852. Tr.CW = b,
  6853. Tr.CCW = w;
  6854. const Sr = Tr;
  6855. const Mr = {
  6856. isPowerOfTwo: function (e) {
  6857. return 0 == (e & e - 1)
  6858. },
  6859. nextPowerOfTwo: function (e) {
  6860. return e--,
  6861. e |= e >> 1,
  6862. e |= e >> 2,
  6863. e |= e >> 4,
  6864. e |= e >> 8,
  6865. e |= e >> 16,
  6866. ++e
  6867. },
  6868. nearestPowerOfTwo: function (e) {
  6869. return Math.pow(2, Math.round(Math.log(e) / Math.LN2))
  6870. }
  6871. };
  6872. var Ar = Mr.isPowerOfTwo;
  6873. function Er(e) {
  6874. return Math.pow(2, Math.round(Math.log(e) / Math.LN2))
  6875. }
  6876. var Cr = wr.extend((function () {
  6877. return {
  6878. image: null,
  6879. pixels: null,
  6880. mipmaps: [],
  6881. convertToPOT: !1
  6882. }
  6883. }
  6884. ), {
  6885. textureType: "texture2D",
  6886. update: function (e) {
  6887. var t = e.gl;
  6888. t.bindTexture(t.TEXTURE_2D, this._cache.get("webgl_texture")),
  6889. this.updateCommon(e);
  6890. var r = this.format
  6891. , i = this.type
  6892. , n = !(!this.convertToPOT || this.mipmaps.length || !this.image || this.wrapS !== wr.REPEAT && this.wrapT !== wr.REPEAT || !this.NPOT);
  6893. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, n ? this.wrapS : this.getAvailableWrapS()),
  6894. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, n ? this.wrapT : this.getAvailableWrapT()),
  6895. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, n ? this.magFilter : this.getAvailableMagFilter()),
  6896. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, n ? this.minFilter : this.getAvailableMinFilter());
  6897. var a = e.getGLExtension("EXT_texture_filter_anisotropic");
  6898. if (a && this.anisotropic > 1 && t.texParameterf(t.TEXTURE_2D, a.TEXTURE_MAX_ANISOTROPY_EXT, this.anisotropic),
  6899. 36193 === i && (e.getGLExtension("OES_texture_half_float") || (i = S)),
  6900. this.mipmaps.length)
  6901. for (var o = this.width, s = this.height, l = 0; l < this.mipmaps.length; l++) {
  6902. var h = this.mipmaps[l];
  6903. this._updateTextureData(t, h, l, o, s, r, i, !1),
  6904. o /= 2,
  6905. s /= 2
  6906. }
  6907. else
  6908. this._updateTextureData(t, this, 0, this.width, this.height, r, i, n),
  6909. !this.useMipmap || this.NPOT && !n || t.generateMipmap(t.TEXTURE_2D);
  6910. t.bindTexture(t.TEXTURE_2D, null)
  6911. },
  6912. _updateTextureData: function (e, t, r, i, n, a, o, s) {
  6913. if (t.image) {
  6914. var l = t.image;
  6915. s && (this._potCanvas = function (e, t) {
  6916. var r = Er(e.width)
  6917. , i = Er(e.height);
  6918. return (t = t || document.createElement("canvas")).width = r,
  6919. t.height = i,
  6920. t.getContext("2d").drawImage(e.image, 0, 0, r, i),
  6921. t
  6922. }(this, this._potCanvas),
  6923. l = this._potCanvas),
  6924. e.texImage2D(e.TEXTURE_2D, r, a, a, o, l)
  6925. } else
  6926. a <= wr.COMPRESSED_RGBA_S3TC_DXT5_EXT && a >= wr.COMPRESSED_RGB_S3TC_DXT1_EXT ? e.compressedTexImage2D(e.TEXTURE_2D, r, a, i, n, 0, t.pixels) : e.texImage2D(e.TEXTURE_2D, r, a, i, n, 0, a, o, t.pixels)
  6927. },
  6928. generateMipmap: function (e) {
  6929. var t = e.gl;
  6930. this.useMipmap && !this.NPOT && (t.bindTexture(t.TEXTURE_2D, this._cache.get("webgl_texture")),
  6931. t.generateMipmap(t.TEXTURE_2D))
  6932. },
  6933. isPowerOfTwo: function () {
  6934. return Ar(this.width) && Ar(this.height)
  6935. },
  6936. isRenderable: function () {
  6937. return this.image ? this.image.width > 0 && this.image.height > 0 : !(!this.width || !this.height)
  6938. },
  6939. bind: function (e) {
  6940. e.gl.bindTexture(e.gl.TEXTURE_2D, this.getWebGLTexture(e))
  6941. },
  6942. unbind: function (e) {
  6943. e.gl.bindTexture(e.gl.TEXTURE_2D, null)
  6944. },
  6945. load: function (e, t) {
  6946. var r = U.createImage();
  6947. t && (r.crossOrigin = t);
  6948. var i = this;
  6949. return r.onload = function () {
  6950. i.dirty(),
  6951. i.trigger("success", i)
  6952. }
  6953. ,
  6954. r.onerror = function () {
  6955. i.trigger("error", i)
  6956. }
  6957. ,
  6958. r.src = e,
  6959. this.image = r,
  6960. this
  6961. }
  6962. });
  6963. Object.defineProperty(Cr.prototype, "width", {
  6964. get: function () {
  6965. return this.image ? this.image.width : this._width
  6966. },
  6967. set: function (e) {
  6968. this.image ? console.warn("Texture from image can't set width") : (this._width !== e && this.dirty(),
  6969. this._width = e)
  6970. }
  6971. }),
  6972. Object.defineProperty(Cr.prototype, "height", {
  6973. get: function () {
  6974. return this.image ? this.image.height : this._height
  6975. },
  6976. set: function (e) {
  6977. this.image ? console.warn("Texture from image can't set height") : (this._height !== e && this.dirty(),
  6978. this._height = e)
  6979. }
  6980. });
  6981. const Dr = Cr;
  6982. function Lr(e) {
  6983. return {
  6984. byte: U.Int8Array,
  6985. ubyte: U.Uint8Array,
  6986. short: U.Int16Array,
  6987. ushort: U.Uint16Array
  6988. }[e] || U.Float32Array
  6989. }
  6990. function Pr(e) {
  6991. return "attr_" + e
  6992. }
  6993. function Or(e, t, r, i) {
  6994. switch (this.name = e,
  6995. this.type = t,
  6996. this.size = r,
  6997. this.semantic = i || "",
  6998. this.value = null,
  6999. r) {
  7000. case 1:
  7001. this.get = function (e) {
  7002. return this.value[e]
  7003. }
  7004. ,
  7005. this.set = function (e, t) {
  7006. this.value[e] = t
  7007. }
  7008. ,
  7009. this.copy = function (e, t) {
  7010. this.value[e] = this.value[e]
  7011. }
  7012. ;
  7013. break;
  7014. case 2:
  7015. this.get = function (e, t) {
  7016. var r = this.value;
  7017. return t[0] = r[2 * e],
  7018. t[1] = r[2 * e + 1],
  7019. t
  7020. }
  7021. ,
  7022. this.set = function (e, t) {
  7023. var r = this.value;
  7024. r[2 * e] = t[0],
  7025. r[2 * e + 1] = t[1]
  7026. }
  7027. ,
  7028. this.copy = function (e, t) {
  7029. var r = this.value;
  7030. t *= 2,
  7031. r[e *= 2] = r[t],
  7032. r[e + 1] = r[t + 1]
  7033. }
  7034. ;
  7035. break;
  7036. case 3:
  7037. this.get = function (e, t) {
  7038. var r = 3 * e
  7039. , i = this.value;
  7040. return t[0] = i[r],
  7041. t[1] = i[r + 1],
  7042. t[2] = i[r + 2],
  7043. t
  7044. }
  7045. ,
  7046. this.set = function (e, t) {
  7047. var r = 3 * e
  7048. , i = this.value;
  7049. i[r] = t[0],
  7050. i[r + 1] = t[1],
  7051. i[r + 2] = t[2]
  7052. }
  7053. ,
  7054. this.copy = function (e, t) {
  7055. var r = this.value;
  7056. t *= 3,
  7057. r[e *= 3] = r[t],
  7058. r[e + 1] = r[t + 1],
  7059. r[e + 2] = r[t + 2]
  7060. }
  7061. ;
  7062. break;
  7063. case 4:
  7064. this.get = function (e, t) {
  7065. var r = this.value
  7066. , i = 4 * e;
  7067. return t[0] = r[i],
  7068. t[1] = r[i + 1],
  7069. t[2] = r[i + 2],
  7070. t[3] = r[i + 3],
  7071. t
  7072. }
  7073. ,
  7074. this.set = function (e, t) {
  7075. var r = this.value
  7076. , i = 4 * e;
  7077. r[i] = t[0],
  7078. r[i + 1] = t[1],
  7079. r[i + 2] = t[2],
  7080. r[i + 3] = t[3]
  7081. }
  7082. ,
  7083. this.copy = function (e, t) {
  7084. var r = this.value;
  7085. t *= 4,
  7086. r[e *= 4] = r[t],
  7087. r[e + 1] = r[t + 1],
  7088. r[e + 2] = r[t + 2],
  7089. r[e + 3] = r[t + 3]
  7090. }
  7091. }
  7092. }
  7093. function Nr(e, t, r, i, n) {
  7094. this.name = e,
  7095. this.type = t,
  7096. this.buffer = r,
  7097. this.size = i,
  7098. this.semantic = n,
  7099. this.symbol = "",
  7100. this.needsRemove = !1
  7101. }
  7102. function Ir(e) {
  7103. this.buffer = e,
  7104. this.count = 0
  7105. }
  7106. Or.prototype.init = function (e) {
  7107. if (!this.value || this.value.length !== e * this.size) {
  7108. var t = Lr(this.type);
  7109. this.value = new t(e * this.size)
  7110. }
  7111. }
  7112. ,
  7113. Or.prototype.fromArray = function (e) {
  7114. var t, r = Lr(this.type);
  7115. if (e[0] && e[0].length) {
  7116. var i = 0
  7117. , n = this.size;
  7118. t = new r(e.length * n);
  7119. for (var a = 0; a < e.length; a++)
  7120. for (var o = 0; o < n; o++)
  7121. t[i++] = e[a][o]
  7122. } else
  7123. t = new r(e);
  7124. this.value = t
  7125. }
  7126. ,
  7127. Or.prototype.clone = function (e) {
  7128. var t = new Or(this.name, this.type, this.size, this.semantic);
  7129. return e && console.warn("todo"),
  7130. t
  7131. }
  7132. ;
  7133. var Rr = m.extend((function () {
  7134. return {
  7135. attributes: {},
  7136. indices: null,
  7137. dynamic: !0,
  7138. _enabledAttributes: null,
  7139. __used: 0
  7140. }
  7141. }
  7142. ), (function () {
  7143. this._cache = new xr,
  7144. this._attributeList = Object.keys(this.attributes),
  7145. this.__vaoCache = {}
  7146. }
  7147. ), {
  7148. mainAttribute: "",
  7149. pick: null,
  7150. pickByRay: null,
  7151. dirty: function () {
  7152. for (var e = this.getEnabledAttributes(), t = 0; t < e.length; t++)
  7153. this.dirtyAttribute(e[t]);
  7154. this.dirtyIndices(),
  7155. this._enabledAttributes = null,
  7156. this._cache.dirty("any")
  7157. },
  7158. dirtyIndices: function () {
  7159. this._cache.dirtyAll("indices")
  7160. },
  7161. dirtyAttribute: function (e) {
  7162. this._cache.dirtyAll(Pr(e)),
  7163. this._cache.dirtyAll("attributes")
  7164. },
  7165. getTriangleIndices: function (e, t) {
  7166. if (e < this.triangleCount && e >= 0) {
  7167. t || (t = []);
  7168. var r = this.indices;
  7169. return t[0] = r[3 * e],
  7170. t[1] = r[3 * e + 1],
  7171. t[2] = r[3 * e + 2],
  7172. t
  7173. }
  7174. },
  7175. setTriangleIndices: function (e, t) {
  7176. var r = this.indices;
  7177. r[3 * e] = t[0],
  7178. r[3 * e + 1] = t[1],
  7179. r[3 * e + 2] = t[2]
  7180. },
  7181. isUseIndices: function () {
  7182. return !!this.indices
  7183. },
  7184. initIndicesFromArray: function (e) {
  7185. var t, r = this.vertexCount > 65535 ? U.Uint32Array : U.Uint16Array;
  7186. if (e[0] && e[0].length) {
  7187. var i = 0;
  7188. t = new r(3 * e.length);
  7189. for (var n = 0; n < e.length; n++)
  7190. for (var a = 0; a < 3; a++)
  7191. t[i++] = e[n][a]
  7192. } else
  7193. t = new r(e);
  7194. this.indices = t
  7195. },
  7196. createAttribute: function (e, t, r, i) {
  7197. var n = new Or(e, t, r, i);
  7198. return this.attributes[e] && this.removeAttribute(e),
  7199. this.attributes[e] = n,
  7200. this._attributeList.push(e),
  7201. n
  7202. },
  7203. removeAttribute: function (e) {
  7204. var t = this._attributeList
  7205. , r = t.indexOf(e);
  7206. return r >= 0 && (t.splice(r, 1),
  7207. delete this.attributes[e],
  7208. !0)
  7209. },
  7210. getAttribute: function (e) {
  7211. return this.attributes[e]
  7212. },
  7213. getEnabledAttributes: function () {
  7214. var e = this._enabledAttributes
  7215. , t = this._attributeList;
  7216. if (e)
  7217. return e;
  7218. for (var r = [], i = this.vertexCount, n = 0; n < t.length; n++) {
  7219. var a = t[n]
  7220. , o = this.attributes[a];
  7221. o.value && o.value.length === i * o.size && r.push(a)
  7222. }
  7223. return this._enabledAttributes = r,
  7224. r
  7225. },
  7226. getBufferChunks: function (e) {
  7227. var t = this._cache;
  7228. t.use(e.__uid__);
  7229. var r = t.isDirty("attributes")
  7230. , i = t.isDirty("indices");
  7231. if (r || i) {
  7232. this._updateBuffer(e.gl, r, i);
  7233. for (var n = this.getEnabledAttributes(), a = 0; a < n.length; a++)
  7234. t.fresh(Pr(n[a]));
  7235. t.fresh("attributes"),
  7236. t.fresh("indices")
  7237. }
  7238. return t.fresh("any"),
  7239. t.get("chunks")
  7240. },
  7241. _updateBuffer: function (e, t, r) {
  7242. var i = this._cache
  7243. , n = i.get("chunks")
  7244. , a = !1;
  7245. n || ((n = [])[0] = {
  7246. attributeBuffers: [],
  7247. indicesBuffer: null
  7248. },
  7249. i.put("chunks", n),
  7250. a = !0);
  7251. var o = n[0]
  7252. , s = o.attributeBuffers
  7253. , l = o.indicesBuffer;
  7254. if (t || a) {
  7255. var h = this.getEnabledAttributes()
  7256. , u = {};
  7257. if (!a)
  7258. for (var c = 0; c < s.length; c++)
  7259. u[s[c].name] = s[c];
  7260. for (var d = 0; d < h.length; d++) {
  7261. var f, p, m = h[d], g = this.attributes[m];
  7262. a || (f = u[m]),
  7263. p = f ? f.buffer : e.createBuffer(),
  7264. i.isDirty(Pr(m)) && (e.bindBuffer(e.ARRAY_BUFFER, p),
  7265. e.bufferData(e.ARRAY_BUFFER, g.value, this.dynamic ? e.DYNAMIC_DRAW : e.STATIC_DRAW)),
  7266. s[d] = new Nr(m, g.type, p, g.size, g.semantic)
  7267. }
  7268. for (c = d; c < s.length; c++)
  7269. e.deleteBuffer(s[c].buffer);
  7270. s.length = d
  7271. }
  7272. this.isUseIndices() && (r || a) && (l || (l = new Ir(e.createBuffer()),
  7273. o.indicesBuffer = l),
  7274. l.count = this.indices.length,
  7275. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, l.buffer),
  7276. e.bufferData(e.ELEMENT_ARRAY_BUFFER, this.indices, this.dynamic ? e.DYNAMIC_DRAW : e.STATIC_DRAW))
  7277. },
  7278. dispose: function (e) {
  7279. var t = this._cache;
  7280. t.use(e.__uid__);
  7281. var r = t.get("chunks");
  7282. if (r)
  7283. for (var i = 0; i < r.length; i++) {
  7284. for (var n = r[i], a = 0; a < n.attributeBuffers.length; a++) {
  7285. var o = n.attributeBuffers[a];
  7286. e.gl.deleteBuffer(o.buffer)
  7287. }
  7288. n.indicesBuffer && e.gl.deleteBuffer(n.indicesBuffer.buffer)
  7289. }
  7290. if (this.__vaoCache) {
  7291. var s = e.getGLExtension("OES_vertex_array_object");
  7292. for (var l in this.__vaoCache) {
  7293. var h = this.__vaoCache[l].vao;
  7294. h && s.deleteVertexArrayOES(h)
  7295. }
  7296. }
  7297. this.__vaoCache = {},
  7298. t.deleteContext(e.__uid__)
  7299. }
  7300. });
  7301. Object.defineProperty && (Object.defineProperty(Rr.prototype, "vertexCount", {
  7302. enumerable: !1,
  7303. get: function () {
  7304. var e = this.attributes[this.mainAttribute];
  7305. return e || (e = this.attributes[this._attributeList[0]]),
  7306. e && e.value ? e.value.length / e.size : 0
  7307. }
  7308. }),
  7309. Object.defineProperty(Rr.prototype, "triangleCount", {
  7310. enumerable: !1,
  7311. get: function () {
  7312. var e = this.indices;
  7313. return e ? e.length / 3 : 0
  7314. }
  7315. })),
  7316. Rr.STATIC_DRAW = 35044,
  7317. Rr.DYNAMIC_DRAW = 35048,
  7318. Rr.STREAM_DRAW = 35040,
  7319. Rr.AttributeBuffer = Nr,
  7320. Rr.IndicesBuffer = Ir,
  7321. Rr.Attribute = Or;
  7322. const Br = Rr;
  7323. var Fr = Qe.create
  7324. , zr = Qe.add
  7325. , Gr = Qe.set
  7326. , Ur = Br.Attribute
  7327. , kr = Br.extend((function () {
  7328. return {
  7329. attributes: {
  7330. position: new Ur("position", "float", 3, "POSITION"),
  7331. texcoord0: new Ur("texcoord0", "float", 2, "TEXCOORD_0"),
  7332. texcoord1: new Ur("texcoord1", "float", 2, "TEXCOORD_1"),
  7333. normal: new Ur("normal", "float", 3, "NORMAL"),
  7334. tangent: new Ur("tangent", "float", 4, "TANGENT"),
  7335. color: new Ur("color", "float", 4, "COLOR"),
  7336. weight: new Ur("weight", "float", 3, "WEIGHT"),
  7337. joint: new Ur("joint", "float", 4, "JOINT"),
  7338. barycentric: new Ur("barycentric", "float", 3, null)
  7339. },
  7340. boundingBox: null
  7341. }
  7342. }
  7343. ), {
  7344. mainAttribute: "position",
  7345. updateBoundingBox: function () {
  7346. var e = this.boundingBox;
  7347. e || (e = this.boundingBox = new ir);
  7348. var t = this.attributes.position.value;
  7349. if (t && t.length) {
  7350. var r = e.min
  7351. , i = e.max
  7352. , n = r.array
  7353. , a = i.array;
  7354. Qe.set(n, t[0], t[1], t[2]),
  7355. Qe.set(a, t[0], t[1], t[2]);
  7356. for (var o = 3; o < t.length;) {
  7357. var s = t[o++]
  7358. , l = t[o++]
  7359. , h = t[o++];
  7360. s < n[0] && (n[0] = s),
  7361. l < n[1] && (n[1] = l),
  7362. h < n[2] && (n[2] = h),
  7363. s > a[0] && (a[0] = s),
  7364. l > a[1] && (a[1] = l),
  7365. h > a[2] && (a[2] = h)
  7366. }
  7367. r._dirty = !0,
  7368. i._dirty = !0
  7369. }
  7370. },
  7371. generateVertexNormals: function () {
  7372. if (this.vertexCount) {
  7373. var e = this.indices
  7374. , t = this.attributes
  7375. , r = t.position.value
  7376. , i = t.normal.value;
  7377. if (i && i.length === r.length)
  7378. for (var n = 0; n < i.length; n++)
  7379. i[n] = 0;
  7380. else
  7381. i = t.normal.value = new U.Float32Array(r.length);
  7382. for (var a, o, s, l = Fr(), h = Fr(), u = Fr(), c = Fr(), d = Fr(), f = Fr(), p = e ? e.length : this.vertexCount, m = 0; m < p;)
  7383. for (e ? (a = e[m++],
  7384. o = e[m++],
  7385. s = e[m++]) : (a = m++,
  7386. o = m++,
  7387. s = m++),
  7388. Gr(l, r[3 * a], r[3 * a + 1], r[3 * a + 2]),
  7389. Gr(h, r[3 * o], r[3 * o + 1], r[3 * o + 2]),
  7390. Gr(u, r[3 * s], r[3 * s + 1], r[3 * s + 2]),
  7391. Qe.sub(c, l, h),
  7392. Qe.sub(d, h, u),
  7393. Qe.cross(f, c, d),
  7394. n = 0; n < 3; n++)
  7395. i[3 * a + n] = i[3 * a + n] + f[n],
  7396. i[3 * o + n] = i[3 * o + n] + f[n],
  7397. i[3 * s + n] = i[3 * s + n] + f[n];
  7398. for (n = 0; n < i.length;)
  7399. Gr(f, i[n], i[n + 1], i[n + 2]),
  7400. Qe.normalize(f, f),
  7401. i[n++] = f[0],
  7402. i[n++] = f[1],
  7403. i[n++] = f[2];
  7404. this.dirty()
  7405. }
  7406. },
  7407. generateFaceNormals: function () {
  7408. if (this.vertexCount) {
  7409. this.isUniqueVertex() || this.generateUniqueVertex();
  7410. var e = this.indices
  7411. , t = this.attributes
  7412. , r = t.position.value
  7413. , i = t.normal.value
  7414. , n = Fr()
  7415. , a = Fr()
  7416. , o = Fr()
  7417. , s = Fr()
  7418. , l = Fr()
  7419. , h = Fr();
  7420. i || (i = t.normal.value = new Float32Array(r.length));
  7421. for (var u, c, d, f = e ? e.length : this.vertexCount, p = 0; p < f;) {
  7422. e ? (u = e[p++],
  7423. c = e[p++],
  7424. d = e[p++]) : (u = p++,
  7425. c = p++,
  7426. d = p++),
  7427. Gr(n, r[3 * u], r[3 * u + 1], r[3 * u + 2]),
  7428. Gr(a, r[3 * c], r[3 * c + 1], r[3 * c + 2]),
  7429. Gr(o, r[3 * d], r[3 * d + 1], r[3 * d + 2]),
  7430. Qe.sub(s, n, a),
  7431. Qe.sub(l, a, o),
  7432. Qe.cross(h, s, l),
  7433. Qe.normalize(h, h);
  7434. for (var m = 0; m < 3; m++)
  7435. i[3 * u + m] = h[m],
  7436. i[3 * c + m] = h[m],
  7437. i[3 * d + m] = h[m]
  7438. }
  7439. this.dirty()
  7440. }
  7441. },
  7442. generateTangents: function () {
  7443. if (this.vertexCount) {
  7444. var e = this.vertexCount
  7445. , t = this.attributes;
  7446. t.tangent.value || (t.tangent.value = new Float32Array(4 * e));
  7447. var r = t.texcoord0.value
  7448. , i = t.position.value
  7449. , n = t.tangent.value
  7450. , a = t.normal.value;
  7451. if (r) {
  7452. for (var o = [], s = [], l = 0; l < e; l++)
  7453. o[l] = [0, 0, 0],
  7454. s[l] = [0, 0, 0];
  7455. var h, u, c, d = [0, 0, 0], f = [0, 0, 0], p = this.indices, m = p ? p.length : this.vertexCount;
  7456. for (l = 0; l < m;) {
  7457. p ? (h = p[l++],
  7458. u = p[l++],
  7459. c = p[l++]) : (h = l++,
  7460. u = l++,
  7461. c = l++);
  7462. var g = r[2 * h]
  7463. , _ = r[2 * u]
  7464. , v = r[2 * c]
  7465. , y = r[2 * h + 1]
  7466. , x = r[2 * u + 1]
  7467. , b = r[2 * c + 1]
  7468. , w = i[3 * h]
  7469. , T = i[3 * u]
  7470. , S = i[3 * c]
  7471. , M = i[3 * h + 1]
  7472. , A = i[3 * u + 1]
  7473. , E = i[3 * c + 1]
  7474. , C = i[3 * h + 2]
  7475. , D = T - w
  7476. , L = S - w
  7477. , P = A - M
  7478. , O = E - M
  7479. , N = i[3 * u + 2] - C
  7480. , I = i[3 * c + 2] - C
  7481. , R = _ - g
  7482. , B = v - g
  7483. , F = x - y
  7484. , z = b - y
  7485. , G = 1 / (R * z - F * B);
  7486. d[0] = (z * D - F * L) * G,
  7487. d[1] = (z * P - F * O) * G,
  7488. d[2] = (z * N - F * I) * G,
  7489. f[0] = (R * L - B * D) * G,
  7490. f[1] = (R * O - B * P) * G,
  7491. f[2] = (R * I - B * N) * G,
  7492. zr(o[h], o[h], d),
  7493. zr(o[u], o[u], d),
  7494. zr(o[c], o[c], d),
  7495. zr(s[h], s[h], f),
  7496. zr(s[u], s[u], f),
  7497. zr(s[c], s[c], f)
  7498. }
  7499. var U = Fr()
  7500. , k = Fr()
  7501. , V = Fr();
  7502. for (l = 0; l < e; l++) {
  7503. V[0] = a[3 * l],
  7504. V[1] = a[3 * l + 1],
  7505. V[2] = a[3 * l + 2];
  7506. var H = o[l];
  7507. Qe.scale(U, V, Qe.dot(V, H)),
  7508. Qe.sub(U, H, U),
  7509. Qe.normalize(U, U),
  7510. Qe.cross(k, V, H),
  7511. n[4 * l] = U[0],
  7512. n[4 * l + 1] = U[1],
  7513. n[4 * l + 2] = U[2],
  7514. n[4 * l + 3] = Qe.dot(k, s[l]) < 0 ? -1 : 1
  7515. }
  7516. this.dirty()
  7517. } else
  7518. console.warn("Geometry without texcoords can't generate tangents.")
  7519. }
  7520. },
  7521. isUniqueVertex: function () {
  7522. return !this.isUseIndices() || this.vertexCount === this.indices.length
  7523. },
  7524. generateUniqueVertex: function () {
  7525. if (this.vertexCount && this.indices) {
  7526. this.indices.length > 65535 && (this.indices = new U.Uint32Array(this.indices));
  7527. for (var e = this.attributes, t = this.indices, r = this.getEnabledAttributes(), i = {}, n = 0; n < r.length; n++)
  7528. i[l = r[n]] = e[l].value,
  7529. e[l].init(this.indices.length);
  7530. for (var a = 0, o = 0; o < t.length; o++) {
  7531. var s = t[o];
  7532. for (n = 0; n < r.length; n++)
  7533. for (var l, h = e[l = r[n]].value, u = e[l].size, c = 0; c < u; c++)
  7534. h[a * u + c] = i[l][s * u + c];
  7535. t[o] = a,
  7536. a++
  7537. }
  7538. this.dirty()
  7539. }
  7540. },
  7541. generateBarycentric: function () {
  7542. if (this.vertexCount) {
  7543. this.isUniqueVertex() || this.generateUniqueVertex();
  7544. var e = this.attributes
  7545. , t = e.barycentric.value
  7546. , r = this.indices;
  7547. if (!t || t.length !== 3 * r.length) {
  7548. t = e.barycentric.value = new Float32Array(3 * r.length);
  7549. for (var i = 0; i < (r ? r.length : this.vertexCount / 3);)
  7550. for (var n = 0; n < 3; n++)
  7551. t[3 * (r ? r[i++] : 3 * i + n) + n] = 1;
  7552. this.dirty()
  7553. }
  7554. }
  7555. },
  7556. applyTransform: function (e) {
  7557. var t = this.attributes
  7558. , r = t.position.value
  7559. , i = t.normal.value
  7560. , n = t.tangent.value;
  7561. e = e.array;
  7562. var a = Ye.create();
  7563. Ye.invert(a, e),
  7564. Ye.transpose(a, a);
  7565. var o = Qe.transformMat4
  7566. , s = Qe.forEach;
  7567. s(r, 3, 0, null, o, e),
  7568. i && s(i, 3, 0, null, o, a),
  7569. n && s(n, 4, 0, null, o, a),
  7570. this.boundingBox && this.updateBoundingBox()
  7571. },
  7572. dispose: function (e) {
  7573. var t = this._cache;
  7574. t.use(e.__uid__);
  7575. var r = t.get("chunks");
  7576. if (r)
  7577. for (var i = 0; i < r.length; i++) {
  7578. for (var n = r[i], a = 0; a < n.attributeBuffers.length; a++) {
  7579. var o = n.attributeBuffers[a];
  7580. e.gl.deleteBuffer(o.buffer)
  7581. }
  7582. n.indicesBuffer && e.gl.deleteBuffer(n.indicesBuffer.buffer)
  7583. }
  7584. if (this.__vaoCache) {
  7585. var s = e.getGLExtension("OES_vertex_array_object");
  7586. for (var l in this.__vaoCache) {
  7587. var h = this.__vaoCache[l].vao;
  7588. h && s.deleteVertexArrayOES(h)
  7589. }
  7590. }
  7591. this.__vaoCache = {},
  7592. t.deleteContext(e.__uid__)
  7593. }
  7594. });
  7595. kr.STATIC_DRAW = Br.STATIC_DRAW,
  7596. kr.DYNAMIC_DRAW = Br.DYNAMIC_DRAW,
  7597. kr.STREAM_DRAW = Br.STREAM_DRAW,
  7598. kr.AttributeBuffer = Br.AttributeBuffer,
  7599. kr.IndicesBuffer = Br.IndicesBuffer,
  7600. kr.Attribute = Ur;
  7601. const Vr = kr;
  7602. var Hr = "@export clay.header."
  7603. , Wr = "@end"
  7604. , jr = ":unconfigurable;";
  7605. const Xr = [Hr + "directional_light", "uniform vec3 directionalLightDirection[DIRECTIONAL_LIGHT_COUNT]" + jr, "uniform vec3 directionalLightColor[DIRECTIONAL_LIGHT_COUNT]" + jr, Wr, Hr + "ambient_light", "uniform vec3 ambientLightColor[AMBIENT_LIGHT_COUNT]" + jr, Wr, Hr + "ambient_sh_light", "uniform vec3 ambientSHLightColor[AMBIENT_SH_LIGHT_COUNT]" + jr, "uniform vec3 ambientSHLightCoefficients[AMBIENT_SH_LIGHT_COUNT * 9]" + jr, "vec3 calcAmbientSHLight(int idx, vec3 N) {\n int offset = 9 * idx;\n return ambientSHLightCoefficients[0]\n + ambientSHLightCoefficients[1] * N.x\n + ambientSHLightCoefficients[2] * N.y\n + ambientSHLightCoefficients[3] * N.z\n + ambientSHLightCoefficients[4] * N.x * N.z\n + ambientSHLightCoefficients[5] * N.z * N.y\n + ambientSHLightCoefficients[6] * N.y * N.x\n + ambientSHLightCoefficients[7] * (3.0 * N.z * N.z - 1.0)\n + ambientSHLightCoefficients[8] * (N.x * N.x - N.y * N.y);\n}", Wr, Hr + "ambient_cubemap_light", "uniform vec3 ambientCubemapLightColor[AMBIENT_CUBEMAP_LIGHT_COUNT]" + jr, "uniform samplerCube ambientCubemapLightCubemap[AMBIENT_CUBEMAP_LIGHT_COUNT]" + jr, "uniform sampler2D ambientCubemapLightBRDFLookup[AMBIENT_CUBEMAP_LIGHT_COUNT]" + jr, Wr, Hr + "point_light", "uniform vec3 pointLightPosition[POINT_LIGHT_COUNT]" + jr, "uniform float pointLightRange[POINT_LIGHT_COUNT]" + jr, "uniform vec3 pointLightColor[POINT_LIGHT_COUNT]" + jr, Wr, Hr + "spot_light", "uniform vec3 spotLightPosition[SPOT_LIGHT_COUNT]" + jr, "uniform vec3 spotLightDirection[SPOT_LIGHT_COUNT]" + jr, "uniform float spotLightRange[SPOT_LIGHT_COUNT]" + jr, "uniform float spotLightUmbraAngleCosine[SPOT_LIGHT_COUNT]" + jr, "uniform float spotLightPenumbraAngleCosine[SPOT_LIGHT_COUNT]" + jr, "uniform float spotLightFalloffFactor[SPOT_LIGHT_COUNT]" + jr, "uniform vec3 spotLightColor[SPOT_LIGHT_COUNT]" + jr, Wr].join("\n");
  7606. Xe.import(Xr);
  7607. const qr = sr.extend((function () {
  7608. return {
  7609. color: [1, 1, 1],
  7610. intensity: 1,
  7611. castShadow: !0,
  7612. shadowResolution: 512,
  7613. group: 0
  7614. }
  7615. }
  7616. ), {
  7617. type: "",
  7618. clone: function () {
  7619. var e = sr.prototype.clone.call(this);
  7620. return e.color = Array.prototype.slice.call(this.color),
  7621. e.intensity = this.intensity,
  7622. e.castShadow = this.castShadow,
  7623. e.shadowResolution = this.shadowResolution,
  7624. e
  7625. }
  7626. });
  7627. var Zr, Yr, Kr, Qr, Jr = function (e, t) {
  7628. this.normal = e || new vt(0, 1, 0),
  7629. this.distance = t || 0
  7630. };
  7631. Jr.prototype = {
  7632. constructor: Jr,
  7633. distanceToPoint: function (e) {
  7634. return Qe.dot(e.array, this.normal.array) - this.distance
  7635. },
  7636. projectPoint: function (e, t) {
  7637. t || (t = new vt);
  7638. var r = this.distanceToPoint(e);
  7639. return Qe.scaleAndAdd(t.array, e.array, this.normal.array, -r),
  7640. t._dirty = !0,
  7641. t
  7642. },
  7643. normalize: function () {
  7644. var e = 1 / Qe.len(this.normal.array);
  7645. Qe.scale(this.normal.array, e),
  7646. this.distance *= e
  7647. },
  7648. intersectFrustum: function (e) {
  7649. for (var t = e.vertices, r = this.normal.array, i = Qe.dot(t[0].array, r) > this.distance, n = 1; n < 8; n++)
  7650. if (Qe.dot(t[n].array, r) > this.distance != i)
  7651. return !0
  7652. },
  7653. intersectLine: (Qr = Qe.create(),
  7654. function (e, t, r) {
  7655. var i = this.distanceToPoint(e)
  7656. , n = this.distanceToPoint(t);
  7657. if (i > 0 && n > 0 || i < 0 && n < 0)
  7658. return null;
  7659. var a = this.normal.array
  7660. , o = this.distance
  7661. , s = e.array;
  7662. Qe.sub(Qr, t.array, e.array),
  7663. Qe.normalize(Qr, Qr);
  7664. var l = Qe.dot(a, Qr);
  7665. if (0 === l)
  7666. return null;
  7667. r || (r = new vt);
  7668. var h = (Qe.dot(a, s) - o) / l;
  7669. return Qe.scaleAndAdd(r.array, s, Qr, -h),
  7670. r._dirty = !0,
  7671. r
  7672. }
  7673. ),
  7674. applyTransform: (Zr = Ye.create(),
  7675. Yr = Et.create(),
  7676. Kr = Et.create(),
  7677. Kr[3] = 1,
  7678. function (e) {
  7679. e = e.array,
  7680. Qe.scale(Kr, this.normal.array, this.distance),
  7681. Et.transformMat4(Kr, Kr, e),
  7682. this.distance = Qe.dot(Kr, this.normal.array),
  7683. Ye.invert(Zr, e),
  7684. Ye.transpose(Zr, Zr),
  7685. Yr[3] = 0,
  7686. Qe.copy(Yr, this.normal.array),
  7687. Et.transformMat4(Yr, Yr, Zr),
  7688. Qe.copy(this.normal.array, Yr)
  7689. }
  7690. ),
  7691. copy: function (e) {
  7692. Qe.copy(this.normal.array, e.normal.array),
  7693. this.normal._dirty = !0,
  7694. this.distance = e.distance
  7695. },
  7696. clone: function () {
  7697. var e = new Jr;
  7698. return e.copy(this),
  7699. e
  7700. }
  7701. };
  7702. const $r = Jr;
  7703. var ei, ti = Qe.set, ri = Qe.copy, ii = Qe.transformMat4, ni = Math.min, ai = Math.max, oi = function () {
  7704. this.planes = [];
  7705. for (var e = 0; e < 6; e++)
  7706. this.planes.push(new $r);
  7707. for (this.boundingBox = new ir,
  7708. this.vertices = [],
  7709. e = 0; e < 8; e++)
  7710. this.vertices[e] = Qe.fromValues(0, 0, 0)
  7711. };
  7712. oi.prototype = {
  7713. setFromProjection: function (e) {
  7714. var t = this.planes
  7715. , r = e.array
  7716. , i = r[0]
  7717. , n = r[1]
  7718. , a = r[2]
  7719. , o = r[3]
  7720. , s = r[4]
  7721. , l = r[5]
  7722. , h = r[6]
  7723. , u = r[7]
  7724. , c = r[8]
  7725. , d = r[9]
  7726. , f = r[10]
  7727. , p = r[11]
  7728. , m = r[12]
  7729. , g = r[13]
  7730. , _ = r[14]
  7731. , v = r[15];
  7732. ti(t[0].normal.array, o - i, u - s, p - c),
  7733. t[0].distance = -(v - m),
  7734. t[0].normalize(),
  7735. ti(t[1].normal.array, o + i, u + s, p + c),
  7736. t[1].distance = -(v + m),
  7737. t[1].normalize(),
  7738. ti(t[2].normal.array, o + n, u + l, p + d),
  7739. t[2].distance = -(v + g),
  7740. t[2].normalize(),
  7741. ti(t[3].normal.array, o - n, u - l, p - d),
  7742. t[3].distance = -(v - g),
  7743. t[3].normalize(),
  7744. ti(t[4].normal.array, o - a, u - h, p - f),
  7745. t[4].distance = -(v - _),
  7746. t[4].normalize(),
  7747. ti(t[5].normal.array, o + a, u + h, p + f),
  7748. t[5].distance = -(v + _),
  7749. t[5].normalize();
  7750. var y = this.boundingBox
  7751. , x = this.vertices;
  7752. if (0 === v) {
  7753. var b = l / i
  7754. , w = -_ / (f - 1)
  7755. , T = -_ / (f + 1)
  7756. , S = -T / l
  7757. , M = -w / l;
  7758. y.min.set(-S * b, -S, T),
  7759. y.max.set(S * b, S, w),
  7760. ti(x[0], -S * b, -S, T),
  7761. ti(x[1], -S * b, S, T),
  7762. ti(x[2], S * b, -S, T),
  7763. ti(x[3], S * b, S, T),
  7764. ti(x[4], -M * b, -M, w),
  7765. ti(x[5], -M * b, M, w),
  7766. ti(x[6], M * b, -M, w),
  7767. ti(x[7], M * b, M, w)
  7768. } else {
  7769. var A = (-1 - m) / i
  7770. , E = (1 - m) / i
  7771. , C = (1 - g) / l
  7772. , D = (-1 - g) / l
  7773. , L = (-1 - _) / f
  7774. , P = (1 - _) / f;
  7775. y.min.set(Math.min(A, E), Math.min(D, C), Math.min(P, L)),
  7776. y.max.set(Math.max(E, A), Math.max(C, D), Math.max(L, P));
  7777. var O = y.min.array
  7778. , N = y.max.array;
  7779. ti(x[0], O[0], O[1], O[2]),
  7780. ti(x[1], O[0], N[1], O[2]),
  7781. ti(x[2], N[0], O[1], O[2]),
  7782. ti(x[3], N[0], N[1], O[2]),
  7783. ti(x[4], O[0], O[1], N[2]),
  7784. ti(x[5], O[0], N[1], N[2]),
  7785. ti(x[6], N[0], O[1], N[2]),
  7786. ti(x[7], N[0], N[1], N[2])
  7787. }
  7788. },
  7789. getTransformedBoundingBox: (ei = Qe.create(),
  7790. function (e, t) {
  7791. var r = this.vertices
  7792. , i = t.array
  7793. , n = e.min
  7794. , a = e.max
  7795. , o = n.array
  7796. , s = a.array
  7797. , l = r[0];
  7798. ii(ei, l, i),
  7799. ri(o, ei),
  7800. ri(s, ei);
  7801. for (var h = 1; h < 8; h++)
  7802. l = r[h],
  7803. ii(ei, l, i),
  7804. o[0] = ni(ei[0], o[0]),
  7805. o[1] = ni(ei[1], o[1]),
  7806. o[2] = ni(ei[2], o[2]),
  7807. s[0] = ai(ei[0], s[0]),
  7808. s[1] = ai(ei[1], s[1]),
  7809. s[2] = ai(ei[2], s[2]);
  7810. return n._dirty = !0,
  7811. a._dirty = !0,
  7812. e
  7813. }
  7814. )
  7815. };
  7816. const si = oi;
  7817. var li;
  7818. const hi = sr.extend((function () {
  7819. return {
  7820. projectionMatrix: new Ht,
  7821. invProjectionMatrix: new Ht,
  7822. viewMatrix: new Ht,
  7823. frustum: new si
  7824. }
  7825. }
  7826. ), (function () {
  7827. this.update(!0)
  7828. }
  7829. ), {
  7830. update: function (e) {
  7831. sr.prototype.update.call(this, e),
  7832. Ht.invert(this.viewMatrix, this.worldTransform),
  7833. this.updateProjectionMatrix(),
  7834. Ht.invert(this.invProjectionMatrix, this.projectionMatrix),
  7835. this.frustum.setFromProjection(this.projectionMatrix)
  7836. },
  7837. setViewMatrix: function (e) {
  7838. Ht.copy(this.viewMatrix, e),
  7839. Ht.invert(this.worldTransform, e),
  7840. this.decomposeWorldTransform()
  7841. },
  7842. decomposeProjectionMatrix: function () { },
  7843. setProjectionMatrix: function (e) {
  7844. Ht.copy(this.projectionMatrix, e),
  7845. Ht.invert(this.invProjectionMatrix, e),
  7846. this.decomposeProjectionMatrix()
  7847. },
  7848. updateProjectionMatrix: function () { },
  7849. castRay: (li = Et.create(),
  7850. function (e, t) {
  7851. var r = void 0 !== t ? t : new Mt
  7852. , i = e.array[0]
  7853. , n = e.array[1];
  7854. return Et.set(li, i, n, -1, 1),
  7855. Et.transformMat4(li, li, this.invProjectionMatrix.array),
  7856. Et.transformMat4(li, li, this.worldTransform.array),
  7857. Qe.scale(r.origin.array, li, 1 / li[3]),
  7858. Et.set(li, i, n, 1, 1),
  7859. Et.transformMat4(li, li, this.invProjectionMatrix.array),
  7860. Et.transformMat4(li, li, this.worldTransform.array),
  7861. Qe.scale(li, li, 1 / li[3]),
  7862. Qe.sub(r.direction.array, li, r.origin.array),
  7863. Qe.normalize(r.direction.array, r.direction.array),
  7864. r.direction._dirty = !0,
  7865. r.origin._dirty = !0,
  7866. r
  7867. }
  7868. )
  7869. });
  7870. var ui, ci, di = Ye.create(), fi = Ye.create(), pi = {};
  7871. function mi(e) {
  7872. var t = []
  7873. , r = Object.keys(e);
  7874. r.sort();
  7875. for (var i = 0; i < r.length; i++) {
  7876. var n = r[i];
  7877. t.push(n + " " + e[n])
  7878. }
  7879. var a = t.join("\n");
  7880. if (pi[a])
  7881. return pi[a];
  7882. var o = f.genGUID();
  7883. return pi[a] = o,
  7884. o
  7885. }
  7886. function gi() {
  7887. this.opaque = [],
  7888. this.transparent = [],
  7889. this._opaqueCount = 0,
  7890. this._transparentCount = 0
  7891. }
  7892. function _i(e, t) {
  7893. if (t.castShadow && !e.castShadow)
  7894. return !0
  7895. }
  7896. gi.prototype.startCount = function () {
  7897. this._opaqueCount = 0,
  7898. this._transparentCount = 0
  7899. }
  7900. ,
  7901. gi.prototype.add = function (e, t) {
  7902. t ? this.transparent[this._transparentCount++] = e : this.opaque[this._opaqueCount++] = e
  7903. }
  7904. ,
  7905. gi.prototype.endCount = function () {
  7906. this.transparent.length = this._transparentCount,
  7907. this.opaque.length = this._opaqueCount
  7908. }
  7909. ;
  7910. const vi = sr.extend((function () {
  7911. return {
  7912. material: null,
  7913. lights: [],
  7914. viewBoundingBoxLastFrame: new ir,
  7915. shadowUniforms: {},
  7916. _cameraList: [],
  7917. _lightUniforms: {},
  7918. _previousLightNumber: {},
  7919. _lightNumber: {},
  7920. _lightProgramKeys: {},
  7921. _nodeRepository: {},
  7922. _renderLists: new W(20)
  7923. }
  7924. }
  7925. ), (function () {
  7926. this._scene = this
  7927. }
  7928. ), {
  7929. addToScene: function (e) {
  7930. e instanceof hi ? (this._cameraList.length > 0 && console.warn("Found multiple camera in one scene. Use the fist one."),
  7931. this._cameraList.push(e)) : e instanceof qr && this.lights.push(e),
  7932. e.name && (this._nodeRepository[e.name] = e)
  7933. },
  7934. removeFromScene: function (e) {
  7935. var t;
  7936. e instanceof hi ? (t = this._cameraList.indexOf(e)) >= 0 && this._cameraList.splice(t, 1) : e instanceof qr && (t = this.lights.indexOf(e)) >= 0 && this.lights.splice(t, 1),
  7937. e.name && delete this._nodeRepository[e.name]
  7938. },
  7939. getNode: function (e) {
  7940. return this._nodeRepository[e]
  7941. },
  7942. setMainCamera: function (e) {
  7943. var t = this._cameraList.indexOf(e);
  7944. t >= 0 && this._cameraList.splice(t, 1),
  7945. this._cameraList.unshift(e)
  7946. },
  7947. getMainCamera: function () {
  7948. return this._cameraList[0]
  7949. },
  7950. getLights: function () {
  7951. return this.lights
  7952. },
  7953. updateLights: function () {
  7954. var e = this.lights;
  7955. this._previousLightNumber = this._lightNumber;
  7956. for (var t = {}, r = 0; r < e.length; r++) {
  7957. var i = e[r];
  7958. if (!i.invisible) {
  7959. var n = i.group;
  7960. t[n] || (t[n] = {}),
  7961. t[n][i.type] = t[n][i.type] || 0,
  7962. t[n][i.type]++
  7963. }
  7964. }
  7965. for (var a in this._lightNumber = t,
  7966. t)
  7967. this._lightProgramKeys[a] = mi(t[a]);
  7968. this._updateLightUniforms()
  7969. },
  7970. cloneNode: function (e) {
  7971. var t = e.clone()
  7972. , r = {};
  7973. return function e(t, i) {
  7974. r[t.__uid__] = i;
  7975. for (var n = 0; n < t._children.length; n++)
  7976. e(t._children[n], i._children[n])
  7977. }(e, t),
  7978. t.traverse((function (e) {
  7979. e.skeleton && (e.skeleton = e.skeleton.clone(r)),
  7980. e.material && (e.material = e.material.clone())
  7981. }
  7982. )),
  7983. t
  7984. },
  7985. updateRenderList: function (e, t) {
  7986. var r = e.__uid__
  7987. , i = this._renderLists.get(r);
  7988. i || (i = new gi,
  7989. this._renderLists.put(r, i)),
  7990. i.startCount(),
  7991. t && (this.viewBoundingBoxLastFrame.min.set(1 / 0, 1 / 0, 1 / 0),
  7992. this.viewBoundingBoxLastFrame.max.set(-1 / 0, -1 / 0, -1 / 0));
  7993. var n = this.material && this.material.transparent || !1;
  7994. return this._doUpdateRenderList(this, e, n, i, t),
  7995. i.endCount(),
  7996. i
  7997. },
  7998. getRenderList: function (e) {
  7999. return this._renderLists.get(e.__uid__)
  8000. },
  8001. _doUpdateRenderList: function (e, t, r, i, n) {
  8002. if (!e.invisible)
  8003. for (var a = 0; a < e._children.length; a++) {
  8004. var o = e._children[a];
  8005. if (o.isRenderable()) {
  8006. var s = o.isSkinnedMesh() ? di : o.worldTransform.array
  8007. , l = o.geometry;
  8008. Ye.multiplyAffine(fi, t.viewMatrix.array, s),
  8009. (n && !l.boundingBox || !this.isFrustumCulled(o, t, fi)) && i.add(o, o.material.transparent || r)
  8010. }
  8011. o._children.length > 0 && this._doUpdateRenderList(o, t, r, i, n)
  8012. }
  8013. },
  8014. isFrustumCulled: (ui = new ir,
  8015. ci = new Ht,
  8016. function (e, t, r) {
  8017. var i = e.boundingBox;
  8018. if (i || (i = e.skeleton && e.skeleton.boundingBox ? e.skeleton.boundingBox : e.geometry.boundingBox),
  8019. !i)
  8020. return !1;
  8021. if (ci.array = r,
  8022. ui.transformFrom(i, ci),
  8023. e.castShadow && this.viewBoundingBoxLastFrame.union(ui),
  8024. e.frustumCulling) {
  8025. if (!ui.intersectBoundingBox(t.frustum.boundingBox))
  8026. return !0;
  8027. ci.array = t.projectionMatrix.array,
  8028. ui.max.array[2] > 0 && ui.min.array[2] < 0 && (ui.max.array[2] = -1e-20),
  8029. ui.applyProjection(ci);
  8030. var n = ui.min.array
  8031. , a = ui.max.array;
  8032. if (a[0] < -1 || n[0] > 1 || a[1] < -1 || n[1] > 1 || a[2] < -1 || n[2] > 1)
  8033. return !0
  8034. }
  8035. return !1
  8036. }
  8037. ),
  8038. _updateLightUniforms: function () {
  8039. var e = this.lights;
  8040. e.sort(_i);
  8041. var t = this._lightUniforms;
  8042. for (var r in t)
  8043. for (var i in t[r])
  8044. t[r][i].value.length = 0;
  8045. for (var n = 0; n < e.length; n++) {
  8046. var a = e[n];
  8047. if (!a.invisible)
  8048. for (var i in r = a.group,
  8049. a.uniformTemplates) {
  8050. var o = a.uniformTemplates[i]
  8051. , s = o.value(a);
  8052. if (null != s) {
  8053. t[r] || (t[r] = {}),
  8054. t[r][i] || (t[r][i] = {
  8055. type: "",
  8056. value: []
  8057. });
  8058. var l = t[r][i];
  8059. switch (l.type = o.type + "v",
  8060. o.type) {
  8061. case "1i":
  8062. case "1f":
  8063. case "t":
  8064. l.value.push(s);
  8065. break;
  8066. case "2f":
  8067. case "3f":
  8068. case "4f":
  8069. for (var h = 0; h < s.length; h++)
  8070. l.value.push(s[h]);
  8071. break;
  8072. default:
  8073. console.error("Unkown light uniform type " + o.type)
  8074. }
  8075. }
  8076. }
  8077. }
  8078. },
  8079. getLightGroups: function () {
  8080. var e = [];
  8081. for (var t in this._lightNumber)
  8082. e.push(t);
  8083. return e
  8084. },
  8085. getNumberChangedLightGroups: function () {
  8086. var e = [];
  8087. for (var t in this._lightNumber)
  8088. this.isLightNumberChanged(t) && e.push(t);
  8089. return e
  8090. },
  8091. isLightNumberChanged: function (e) {
  8092. var t = this._previousLightNumber
  8093. , r = this._lightNumber;
  8094. for (var i in r[e]) {
  8095. if (!t[e])
  8096. return !0;
  8097. if (r[e][i] !== t[e][i])
  8098. return !0
  8099. }
  8100. for (var i in t[e]) {
  8101. if (!r[e])
  8102. return !0;
  8103. if (r[e][i] !== t[e][i])
  8104. return !0
  8105. }
  8106. return !1
  8107. },
  8108. getLightsNumbers: function (e) {
  8109. return this._lightNumber[e]
  8110. },
  8111. getProgramKey: function (e) {
  8112. return this._lightProgramKeys[e]
  8113. },
  8114. setLightUniforms: function () {
  8115. function e(e, t, r) {
  8116. for (var i in e) {
  8117. var n = e[i];
  8118. if ("tv" === n.type) {
  8119. if (!t.hasUniform(i))
  8120. continue;
  8121. for (var a = [], o = 0; o < n.value.length; o++) {
  8122. var s = n.value[o]
  8123. , l = t.takeCurrentTextureSlot(r, s);
  8124. a.push(l)
  8125. }
  8126. t.setUniform(r.gl, "1iv", i, a)
  8127. } else
  8128. t.setUniform(r.gl, n.type, i, n.value)
  8129. }
  8130. }
  8131. return function (t, r, i) {
  8132. e(this._lightUniforms[r], t, i),
  8133. e(this.shadowUniforms, t, i)
  8134. }
  8135. }(),
  8136. dispose: function () {
  8137. this.material = null,
  8138. this._opaqueList = [],
  8139. this._transparentList = [],
  8140. this.lights = [],
  8141. this._lightUniforms = {},
  8142. this._lightNumber = {},
  8143. this._nodeRepository = {}
  8144. }
  8145. });
  8146. var yi = function (e) {
  8147. this.value = e
  8148. }
  8149. , xi = function () {
  8150. function e() {
  8151. this._len = 0
  8152. }
  8153. return e.prototype.insert = function (e) {
  8154. var t = new yi(e);
  8155. return this.insertEntry(t),
  8156. t
  8157. }
  8158. ,
  8159. e.prototype.insertEntry = function (e) {
  8160. this.head ? (this.tail.next = e,
  8161. e.prev = this.tail,
  8162. e.next = null,
  8163. this.tail = e) : this.head = this.tail = e,
  8164. this._len++
  8165. }
  8166. ,
  8167. e.prototype.remove = function (e) {
  8168. var t = e.prev
  8169. , r = e.next;
  8170. t ? t.next = r : this.head = r,
  8171. r ? r.prev = t : this.tail = t,
  8172. e.next = e.prev = null,
  8173. this._len--
  8174. }
  8175. ,
  8176. e.prototype.len = function () {
  8177. return this._len
  8178. }
  8179. ,
  8180. e.prototype.clear = function () {
  8181. this.head = this.tail = null,
  8182. this._len = 0
  8183. }
  8184. ,
  8185. e
  8186. }();
  8187. const bi = function () {
  8188. function e(e) {
  8189. this._list = new xi,
  8190. this._maxSize = 10,
  8191. this._map = {},
  8192. this._maxSize = e
  8193. }
  8194. return e.prototype.put = function (e, t) {
  8195. var r = this._list
  8196. , i = this._map
  8197. , n = null;
  8198. if (null == i[e]) {
  8199. var a = r.len()
  8200. , o = this._lastRemovedEntry;
  8201. if (a >= this._maxSize && a > 0) {
  8202. var s = r.head;
  8203. r.remove(s),
  8204. delete i[s.key],
  8205. n = s.value,
  8206. this._lastRemovedEntry = s
  8207. }
  8208. o ? o.value = t : o = new yi(t),
  8209. o.key = e,
  8210. r.insertEntry(o),
  8211. i[e] = o
  8212. }
  8213. return n
  8214. }
  8215. ,
  8216. e.prototype.get = function (e) {
  8217. var t = this._map[e]
  8218. , r = this._list;
  8219. if (null != t)
  8220. return t !== r.tail && (r.remove(t),
  8221. r.insertEntry(t)),
  8222. t.value
  8223. }
  8224. ,
  8225. e.prototype.clear = function () {
  8226. this._list.clear(),
  8227. this._map = {}
  8228. }
  8229. ,
  8230. e.prototype.len = function () {
  8231. return this._list.len()
  8232. }
  8233. ,
  8234. e
  8235. }();
  8236. var wi = Mr.isPowerOfTwo
  8237. , Ti = ["px", "nx", "py", "ny", "pz", "nz"]
  8238. , Si = wr.extend((function () {
  8239. return {
  8240. image: {
  8241. px: null,
  8242. nx: null,
  8243. py: null,
  8244. ny: null,
  8245. pz: null,
  8246. nz: null
  8247. },
  8248. pixels: {
  8249. px: null,
  8250. nx: null,
  8251. py: null,
  8252. ny: null,
  8253. pz: null,
  8254. nz: null
  8255. },
  8256. mipmaps: []
  8257. }
  8258. }
  8259. ), {
  8260. textureType: "textureCube",
  8261. update: function (e) {
  8262. var t = e.gl;
  8263. t.bindTexture(t.TEXTURE_CUBE_MAP, this._cache.get("webgl_texture")),
  8264. this.updateCommon(e);
  8265. var r = this.format
  8266. , i = this.type;
  8267. t.texParameteri(t.TEXTURE_CUBE_MAP, t.TEXTURE_WRAP_S, this.getAvailableWrapS()),
  8268. t.texParameteri(t.TEXTURE_CUBE_MAP, t.TEXTURE_WRAP_T, this.getAvailableWrapT()),
  8269. t.texParameteri(t.TEXTURE_CUBE_MAP, t.TEXTURE_MAG_FILTER, this.getAvailableMagFilter()),
  8270. t.texParameteri(t.TEXTURE_CUBE_MAP, t.TEXTURE_MIN_FILTER, this.getAvailableMinFilter());
  8271. var n = e.getGLExtension("EXT_texture_filter_anisotropic");
  8272. if (n && this.anisotropic > 1 && t.texParameterf(t.TEXTURE_CUBE_MAP, n.TEXTURE_MAX_ANISOTROPY_EXT, this.anisotropic),
  8273. 36193 === i && (e.getGLExtension("OES_texture_half_float") || (i = S)),
  8274. this.mipmaps.length)
  8275. for (var a = this.width, o = this.height, s = 0; s < this.mipmaps.length; s++) {
  8276. var l = this.mipmaps[s];
  8277. this._updateTextureData(t, l, s, a, o, r, i),
  8278. a /= 2,
  8279. o /= 2
  8280. }
  8281. else
  8282. this._updateTextureData(t, this, 0, this.width, this.height, r, i),
  8283. !this.NPOT && this.useMipmap && t.generateMipmap(t.TEXTURE_CUBE_MAP);
  8284. t.bindTexture(t.TEXTURE_CUBE_MAP, null)
  8285. },
  8286. _updateTextureData: function (e, t, r, i, n, a, o) {
  8287. for (var s = 0; s < 6; s++) {
  8288. var l = Ti[s]
  8289. , h = t.image && t.image[l];
  8290. h ? e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + s, r, a, a, o, h) : e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + s, r, a, i, n, 0, a, o, t.pixels && t.pixels[l])
  8291. }
  8292. },
  8293. generateMipmap: function (e) {
  8294. var t = e.gl;
  8295. this.useMipmap && !this.NPOT && (t.bindTexture(t.TEXTURE_CUBE_MAP, this._cache.get("webgl_texture")),
  8296. t.generateMipmap(t.TEXTURE_CUBE_MAP))
  8297. },
  8298. bind: function (e) {
  8299. e.gl.bindTexture(e.gl.TEXTURE_CUBE_MAP, this.getWebGLTexture(e))
  8300. },
  8301. unbind: function (e) {
  8302. e.gl.bindTexture(e.gl.TEXTURE_CUBE_MAP, null)
  8303. },
  8304. isPowerOfTwo: function () {
  8305. return this.image.px ? wi(this.image.px.width) && wi(this.image.px.height) : wi(this.width) && wi(this.height)
  8306. },
  8307. isRenderable: function () {
  8308. return this.image.px ? Mi(this.image.px) && Mi(this.image.nx) && Mi(this.image.py) && Mi(this.image.ny) && Mi(this.image.pz) && Mi(this.image.nz) : !(!this.width || !this.height)
  8309. },
  8310. load: function (e, t) {
  8311. var r = 0
  8312. , i = this;
  8313. return f.each(e, (function (e, n) {
  8314. var a = U.createImage();
  8315. t && (a.crossOrigin = t),
  8316. a.onload = function () {
  8317. 0 == --r && (i.dirty(),
  8318. i.trigger("success", i))
  8319. }
  8320. ,
  8321. a.onerror = function () {
  8322. r--
  8323. }
  8324. ,
  8325. r++,
  8326. a.src = e,
  8327. i.image[n] = a
  8328. }
  8329. )),
  8330. this
  8331. }
  8332. });
  8333. function Mi(e) {
  8334. return e.width > 0 && e.height > 0
  8335. }
  8336. Object.defineProperty(Si.prototype, "width", {
  8337. get: function () {
  8338. return this.image && this.image.px ? this.image.px.width : this._width
  8339. },
  8340. set: function (e) {
  8341. this.image && this.image.px ? console.warn("Texture from image can't set width") : (this._width !== e && this.dirty(),
  8342. this._width = e)
  8343. }
  8344. }),
  8345. Object.defineProperty(Si.prototype, "height", {
  8346. get: function () {
  8347. return this.image && this.image.px ? this.image.px.height : this._height
  8348. },
  8349. set: function (e) {
  8350. this.image && this.image.px ? console.warn("Texture from image can't set height") : (this._height !== e && this.dirty(),
  8351. this._height = e)
  8352. }
  8353. });
  8354. const Ai = Si
  8355. , Ei = hi.extend({
  8356. fov: 50,
  8357. aspect: 1,
  8358. near: .1,
  8359. far: 2e3
  8360. }, {
  8361. updateProjectionMatrix: function () {
  8362. var e = this.fov / 180 * Math.PI;
  8363. this.projectionMatrix.perspective(e, this.aspect, this.near, this.far)
  8364. },
  8365. decomposeProjectionMatrix: function () {
  8366. var e = this.projectionMatrix.array
  8367. , t = 2 * Math.atan(1 / e[5]);
  8368. this.fov = t / Math.PI * 180,
  8369. this.aspect = e[5] / e[0],
  8370. this.near = e[14] / (e[10] - 1),
  8371. this.far = e[14] / (e[10] + 1)
  8372. },
  8373. clone: function () {
  8374. var e = hi.prototype.clone.call(this);
  8375. return e.fov = this.fov,
  8376. e.aspect = this.aspect,
  8377. e.near = this.near,
  8378. e.far = this.far,
  8379. e
  8380. }
  8381. });
  8382. var Ci = "framebuffer"
  8383. , Di = "renderbuffer"
  8384. , Li = "renderbuffer_width"
  8385. , Pi = "renderbuffer_height"
  8386. , Oi = "renderbuffer_attached"
  8387. , Ni = "depthtexture_attached"
  8388. , Ii = 36160
  8389. , Ri = 36161
  8390. , Bi = 36096
  8391. , Fi = m.extend({
  8392. depthBuffer: !0,
  8393. viewport: null,
  8394. _width: 0,
  8395. _height: 0,
  8396. _textures: null,
  8397. _boundRenderer: null
  8398. }, (function () {
  8399. this._cache = new xr,
  8400. this._textures = {}
  8401. }
  8402. ), {
  8403. getTextureWidth: function () {
  8404. return this._width
  8405. },
  8406. getTextureHeight: function () {
  8407. return this._height
  8408. },
  8409. bind: function (e) {
  8410. if (e.__currentFrameBuffer) {
  8411. if (e.__currentFrameBuffer === this)
  8412. return;
  8413. console.warn("Renderer already bound with another framebuffer. Unbind it first")
  8414. }
  8415. e.__currentFrameBuffer = this;
  8416. var t = e.gl;
  8417. t.bindFramebuffer(Ii, this._getFrameBufferGL(e)),
  8418. this._boundRenderer = e;
  8419. var r = this._cache;
  8420. r.put("viewport", e.viewport);
  8421. var i, n, a = !1;
  8422. for (var o in this._textures) {
  8423. a = !0;
  8424. var s = this._textures[o];
  8425. s && (i = s.texture.width,
  8426. n = s.texture.height,
  8427. this._doAttach(e, s.texture, o, s.target))
  8428. }
  8429. this._width = i,
  8430. this._height = n,
  8431. !a && this.depthBuffer && console.error("Must attach texture before bind, or renderbuffer may have incorrect width and height."),
  8432. this.viewport ? e.setViewport(this.viewport) : e.setViewport(0, 0, i, n, 1);
  8433. var l = r.get("attached_textures");
  8434. if (l)
  8435. for (var o in l)
  8436. if (!this._textures[o]) {
  8437. var h = l[o];
  8438. this._doDetach(t, o, h)
  8439. }
  8440. if (!r.get(Ni) && this.depthBuffer) {
  8441. r.miss(Di) && r.put(Di, t.createRenderbuffer());
  8442. var u = r.get(Di);
  8443. i === r.get(Li) && n === r.get(Pi) || (t.bindRenderbuffer(Ri, u),
  8444. t.renderbufferStorage(Ri, t.DEPTH_COMPONENT16, i, n),
  8445. r.put(Li, i),
  8446. r.put(Pi, n),
  8447. t.bindRenderbuffer(Ri, null)),
  8448. r.get(Oi) || (t.framebufferRenderbuffer(Ii, Bi, Ri, u),
  8449. r.put(Oi, !0))
  8450. }
  8451. },
  8452. unbind: function (e) {
  8453. e.__currentFrameBuffer = null,
  8454. e.gl.bindFramebuffer(Ii, null),
  8455. this._boundRenderer = null,
  8456. this._cache.use(e.__uid__);
  8457. var t = this._cache.get("viewport");
  8458. t && e.setViewport(t),
  8459. this.updateMipmap(e)
  8460. },
  8461. updateMipmap: function (e) {
  8462. var t = e.gl;
  8463. for (var r in this._textures) {
  8464. var i = this._textures[r];
  8465. if (i) {
  8466. var n = i.texture;
  8467. if (!n.NPOT && n.useMipmap && n.minFilter === wr.LINEAR_MIPMAP_LINEAR) {
  8468. var a = "textureCube" === n.textureType ? 34067 : 3553;
  8469. t.bindTexture(a, n.getWebGLTexture(e)),
  8470. t.generateMipmap(a),
  8471. t.bindTexture(a, null)
  8472. }
  8473. }
  8474. }
  8475. },
  8476. checkStatus: function (e) {
  8477. return e.checkFramebufferStatus(Ii)
  8478. },
  8479. _getFrameBufferGL: function (e) {
  8480. var t = this._cache;
  8481. return t.use(e.__uid__),
  8482. t.miss(Ci) && t.put(Ci, e.gl.createFramebuffer()),
  8483. t.get(Ci)
  8484. },
  8485. attach: function (e, t, r) {
  8486. if (!e.width)
  8487. throw new Error("The texture attached to color buffer is not a valid.");
  8488. t = t || 36064,
  8489. r = r || 3553;
  8490. var i, n = this._boundRenderer;
  8491. if (n && n.gl) {
  8492. var a = this._cache;
  8493. a.use(n.__uid__),
  8494. i = a.get("attached_textures")
  8495. }
  8496. var o = this._textures[t];
  8497. if (!o || o.target !== r || o.texture !== e || !i || null == i[t]) {
  8498. var s = !0;
  8499. n && (s = this._doAttach(n, e, t, r),
  8500. this.viewport || n.setViewport(0, 0, e.width, e.height, 1)),
  8501. s && (this._textures[t] = this._textures[t] || {},
  8502. this._textures[t].texture = e,
  8503. this._textures[t].target = r)
  8504. }
  8505. },
  8506. _doAttach: function (e, t, r, i) {
  8507. var n = e.gl
  8508. , a = t.getWebGLTexture(e)
  8509. , o = this._cache.get("attached_textures");
  8510. if (o && o[r]) {
  8511. var s = o[r];
  8512. if (s.texture === t && s.target === i)
  8513. return
  8514. }
  8515. var l = !0;
  8516. if (((r = +r) === Bi || r === R) && (e.getGLExtension("WEBGL_depth_texture") || (console.error("Depth texture is not supported by the browser"),
  8517. l = !1),
  8518. t.format !== M && 34041 !== t.format && (console.error("The texture attached to depth buffer is not a valid."),
  8519. l = !1),
  8520. l)) {
  8521. var h = this._cache.get(Di);
  8522. h && (n.framebufferRenderbuffer(Ii, Bi, Ri, null),
  8523. n.deleteRenderbuffer(h),
  8524. this._cache.put(Di, !1)),
  8525. this._cache.put(Oi, !1),
  8526. this._cache.put(Ni, !0)
  8527. }
  8528. return n.framebufferTexture2D(Ii, r, i, a, 0),
  8529. o || (o = {},
  8530. this._cache.put("attached_textures", o)),
  8531. o[r] = o[r] || {},
  8532. o[r].texture = t,
  8533. o[r].target = i,
  8534. l
  8535. },
  8536. _doDetach: function (e, t, r) {
  8537. e.framebufferTexture2D(Ii, t, r, null, 0);
  8538. var i = this._cache.get("attached_textures");
  8539. i && i[t] && (i[t] = null),
  8540. t !== Bi && t !== R || this._cache.put(Ni, !1)
  8541. },
  8542. detach: function (e, t) {
  8543. this._textures[e] = null,
  8544. this._boundRenderer && (this._cache.use(this._boundRenderer.__uid__),
  8545. this._doDetach(this._boundRenderer.gl, e, t))
  8546. },
  8547. dispose: function (e) {
  8548. var t = e.gl
  8549. , r = this._cache;
  8550. r.use(e.__uid__);
  8551. var i = r.get(Di);
  8552. i && t.deleteRenderbuffer(i);
  8553. var n = r.get(Ci);
  8554. n && t.deleteFramebuffer(n),
  8555. r.deleteContext(e.__uid__),
  8556. this._textures = {}
  8557. }
  8558. });
  8559. Fi.DEPTH_ATTACHMENT = Bi,
  8560. Fi.COLOR_ATTACHMENT0 = 36064,
  8561. Fi.STENCIL_ATTACHMENT = 36128,
  8562. Fi.DEPTH_STENCIL_ATTACHMENT = R;
  8563. const zi = Fi;
  8564. var Gi = ["px", "nx", "py", "ny", "pz", "nz"];
  8565. const Ui = m.extend((function () {
  8566. var e = {
  8567. position: new vt,
  8568. far: 1e3,
  8569. near: .1,
  8570. texture: null,
  8571. shadowMapPass: null
  8572. }
  8573. , t = e._cameras = {
  8574. px: new Ei({
  8575. fov: 90
  8576. }),
  8577. nx: new Ei({
  8578. fov: 90
  8579. }),
  8580. py: new Ei({
  8581. fov: 90
  8582. }),
  8583. ny: new Ei({
  8584. fov: 90
  8585. }),
  8586. pz: new Ei({
  8587. fov: 90
  8588. }),
  8589. nz: new Ei({
  8590. fov: 90
  8591. })
  8592. };
  8593. return t.px.lookAt(vt.POSITIVE_X, vt.NEGATIVE_Y),
  8594. t.nx.lookAt(vt.NEGATIVE_X, vt.NEGATIVE_Y),
  8595. t.py.lookAt(vt.POSITIVE_Y, vt.POSITIVE_Z),
  8596. t.ny.lookAt(vt.NEGATIVE_Y, vt.NEGATIVE_Z),
  8597. t.pz.lookAt(vt.POSITIVE_Z, vt.NEGATIVE_Y),
  8598. t.nz.lookAt(vt.NEGATIVE_Z, vt.NEGATIVE_Y),
  8599. e._frameBuffer = new zi,
  8600. e
  8601. }
  8602. ), {
  8603. getCamera: function (e) {
  8604. return this._cameras[e]
  8605. },
  8606. render: function (e, t, r) {
  8607. var i = e.gl;
  8608. r || t.update();
  8609. for (var n = this.texture.width, a = 2 * Math.atan(n / (n - .5)) / Math.PI * 180, o = 0; o < 6; o++) {
  8610. var s = Gi[o]
  8611. , l = this._cameras[s];
  8612. if (vt.copy(l.position, this.position),
  8613. l.far = this.far,
  8614. l.near = this.near,
  8615. l.fov = a,
  8616. this.shadowMapPass) {
  8617. l.update();
  8618. var h = t.getBoundingBox();
  8619. h.applyTransform(l.viewMatrix),
  8620. t.viewBoundingBoxLastFrame.copy(h),
  8621. this.shadowMapPass.render(e, t, l, !0)
  8622. }
  8623. this._frameBuffer.attach(this.texture, i.COLOR_ATTACHMENT0, i.TEXTURE_CUBE_MAP_POSITIVE_X + o),
  8624. this._frameBuffer.bind(e),
  8625. e.render(t, l, !0),
  8626. this._frameBuffer.unbind(e)
  8627. }
  8628. },
  8629. dispose: function (e) {
  8630. this._frameBuffer.dispose(e)
  8631. }
  8632. })
  8633. , ki = Vr.extend({
  8634. dynamic: !1,
  8635. widthSegments: 1,
  8636. heightSegments: 1
  8637. }, (function () {
  8638. this.build()
  8639. }
  8640. ), {
  8641. build: function () {
  8642. for (var e = this.heightSegments, t = this.widthSegments, r = this.attributes, i = [], n = [], a = [], o = [], s = 0; s <= e; s++)
  8643. for (var l = s / e, h = 0; h <= t; h++) {
  8644. var u = h / t;
  8645. if (i.push([2 * u - 1, 2 * l - 1, 0]),
  8646. n && n.push([u, l]),
  8647. a && a.push([0, 0, 1]),
  8648. h < t && s < e) {
  8649. var c = h + s * (t + 1);
  8650. o.push([c, c + 1, c + t + 1]),
  8651. o.push([c + t + 1, c + 1, c + t + 2])
  8652. }
  8653. }
  8654. r.position.fromArray(i),
  8655. r.texcoord0.fromArray(n),
  8656. r.normal.fromArray(a),
  8657. this.initIndicesFromArray(o),
  8658. this.boundingBox = new ir,
  8659. this.boundingBox.min.set(-1, -1, 0),
  8660. this.boundingBox.max.set(1, 1, 0)
  8661. }
  8662. });
  8663. var Vi = new Ht;
  8664. function Hi(e, t, r) {
  8665. Vi.identity();
  8666. var i = new ki({
  8667. widthSegments: t,
  8668. heightSegments: r
  8669. });
  8670. switch (e) {
  8671. case "px":
  8672. Ht.translate(Vi, Vi, vt.POSITIVE_X),
  8673. Ht.rotateY(Vi, Vi, Math.PI / 2);
  8674. break;
  8675. case "nx":
  8676. Ht.translate(Vi, Vi, vt.NEGATIVE_X),
  8677. Ht.rotateY(Vi, Vi, -Math.PI / 2);
  8678. break;
  8679. case "py":
  8680. Ht.translate(Vi, Vi, vt.POSITIVE_Y),
  8681. Ht.rotateX(Vi, Vi, -Math.PI / 2);
  8682. break;
  8683. case "ny":
  8684. Ht.translate(Vi, Vi, vt.NEGATIVE_Y),
  8685. Ht.rotateX(Vi, Vi, Math.PI / 2);
  8686. break;
  8687. case "pz":
  8688. Ht.translate(Vi, Vi, vt.POSITIVE_Z);
  8689. break;
  8690. case "nz":
  8691. Ht.translate(Vi, Vi, vt.NEGATIVE_Z),
  8692. Ht.rotateY(Vi, Vi, Math.PI)
  8693. }
  8694. return i.applyTransform(Vi),
  8695. i
  8696. }
  8697. const Wi = Vr.extend({
  8698. dynamic: !1,
  8699. widthSegments: 1,
  8700. heightSegments: 1,
  8701. depthSegments: 1,
  8702. inside: !1
  8703. }, (function () {
  8704. this.build()
  8705. }
  8706. ), {
  8707. build: function () {
  8708. var e = {
  8709. px: Hi("px", this.depthSegments, this.heightSegments),
  8710. nx: Hi("nx", this.depthSegments, this.heightSegments),
  8711. py: Hi("py", this.widthSegments, this.depthSegments),
  8712. ny: Hi("ny", this.widthSegments, this.depthSegments),
  8713. pz: Hi("pz", this.widthSegments, this.heightSegments),
  8714. nz: Hi("nz", this.widthSegments, this.heightSegments)
  8715. }
  8716. , t = ["position", "texcoord0", "normal"]
  8717. , r = 0
  8718. , i = 0;
  8719. for (var n in e)
  8720. r += e[n].vertexCount,
  8721. i += e[n].indices.length;
  8722. for (var a = 0; a < t.length; a++)
  8723. this.attributes[t[a]].init(r);
  8724. this.indices = new U.Uint16Array(i);
  8725. var o = 0
  8726. , s = 0;
  8727. for (var n in e) {
  8728. var l = e[n];
  8729. for (a = 0; a < t.length; a++)
  8730. for (var h = t[a], u = l.attributes[h].value, c = l.attributes[h].size, d = "normal" === h, f = 0; f < u.length; f++) {
  8731. var p = u[f];
  8732. this.inside && d && (p = -p),
  8733. this.attributes[h].value[f + c * s] = p
  8734. }
  8735. var m = l.indices.length;
  8736. for (f = 0; f < l.indices.length; f++)
  8737. this.indices[f + o] = s + l.indices[this.inside ? m - f - 1 : f];
  8738. o += l.indices.length,
  8739. s += l.vertexCount
  8740. }
  8741. this.boundingBox = new ir,
  8742. this.boundingBox.max.set(1, 1, 1),
  8743. this.boundingBox.min.set(-1, -1, -1)
  8744. }
  8745. });
  8746. Xe.import("@export clay.skybox.vertex\n#define SHADER_NAME skybox\nuniform mat4 world : WORLD;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nvarying vec3 v_WorldPosition;\nvoid main()\n{\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n@export clay.skybox.fragment\n#define PI 3.1415926\nuniform mat4 viewInverse : VIEWINVERSE;\n#ifdef EQUIRECTANGULAR\nuniform sampler2D environmentMap;\n#else\nuniform samplerCube environmentMap;\n#endif\nuniform float lod: 0.0;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\n@import clay.util.srgb\n@import clay.util.ACES\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n#ifdef EQUIRECTANGULAR\n float phi = acos(V.y);\n float theta = atan(-V.x, V.z) + PI * 0.5;\n vec2 uv = vec2(theta / 2.0 / PI, phi / PI);\n vec4 texel = decodeHDR(texture2D(environmentMap, fract(uv)));\n#else\n #if defined(LOD) || defined(SUPPORT_TEXTURE_LOD)\n vec4 texel = decodeHDR(textureCubeLodEXT(environmentMap, V, lod));\n #else\n vec4 texel = decodeHDR(textureCube(environmentMap, V));\n #endif\n#endif\n#ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n#endif\n#ifdef TONEMAPPING\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n#ifdef SRGB_ENCODE\n texel = linearTosRGB(texel);\n#endif\n gl_FragColor = encodeHDR(vec4(texel.rgb, 1.0));\n}\n@end");
  8747. const ji = Sr.extend((function () {
  8748. var e = new Xe({
  8749. vertex: Xe.source("clay.skybox.vertex"),
  8750. fragment: Xe.source("clay.skybox.fragment")
  8751. })
  8752. , t = new le({
  8753. shader: e,
  8754. depthMask: !1
  8755. });
  8756. return {
  8757. scene: null,
  8758. geometry: new Wi,
  8759. material: t,
  8760. environmentMap: null,
  8761. culling: !1,
  8762. _dummyCamera: new Ei
  8763. }
  8764. }
  8765. ), (function () {
  8766. var e = this.scene;
  8767. e && this.attachScene(e),
  8768. this.environmentMap && this.setEnvironmentMap(this.environmentMap)
  8769. }
  8770. ), {
  8771. attachScene: function (e) {
  8772. this.scene && this.detachScene(),
  8773. e.skybox = this,
  8774. this.scene = e,
  8775. e.on("beforerender", this._beforeRenderScene, this)
  8776. },
  8777. detachScene: function () {
  8778. this.scene && (this.scene.off("beforerender", this._beforeRenderScene),
  8779. this.scene.skybox = null),
  8780. this.scene = null
  8781. },
  8782. dispose: function (e) {
  8783. this.detachScene(),
  8784. this.geometry.dispose(e)
  8785. },
  8786. setEnvironmentMap: function (e) {
  8787. "texture2D" === e.textureType ? (this.material.define("EQUIRECTANGULAR"),
  8788. e.minFilter = wr.LINEAR) : this.material.undefine("EQUIRECTANGULAR"),
  8789. this.material.set("environmentMap", e)
  8790. },
  8791. getEnvironmentMap: function () {
  8792. return this.material.get("environmentMap")
  8793. },
  8794. _beforeRenderScene: function (e, t, r) {
  8795. this.renderSkybox(e, r)
  8796. },
  8797. renderSkybox: function (e, t) {
  8798. var r = this._dummyCamera;
  8799. r.aspect = e.getViewportAspect(),
  8800. r.fov = t.fov || 50,
  8801. r.updateProjectionMatrix(),
  8802. Ht.invert(r.invProjectionMatrix, r.projectionMatrix),
  8803. r.worldTransform.copy(t.worldTransform),
  8804. r.viewMatrix.copy(t.viewMatrix),
  8805. this.position.copy(t.getWorldPosition()),
  8806. this.update(),
  8807. e.gl.disable(e.gl.BLEND),
  8808. this.material.get("lod") > 0 ? this.material.define("fragment", "LOD") : this.material.undefine("fragment", "LOD"),
  8809. e.renderPass([this], r)
  8810. }
  8811. })
  8812. , Xi = ji;
  8813. function qi(e) {
  8814. return e.charCodeAt(0) + (e.charCodeAt(1) << 8) + (e.charCodeAt(2) << 16) + (e.charCodeAt(3) << 24)
  8815. }
  8816. var Zi = qi("DXT1")
  8817. , Yi = qi("DXT3")
  8818. , Ki = qi("DXT5");
  8819. const Qi = function (e, t) {
  8820. var r = new Int32Array(e, 0, 31);
  8821. if (542327876 !== r[0])
  8822. return null;
  8823. if (4 & !r(20))
  8824. return null;
  8825. var i, n, a = r(21), o = r[4], s = r[3], l = 512 & r[28], h = 131072 & r[2];
  8826. switch (a) {
  8827. case Zi:
  8828. i = 8,
  8829. n = wr.COMPRESSED_RGB_S3TC_DXT1_EXT;
  8830. break;
  8831. case Yi:
  8832. i = 16,
  8833. n = wr.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  8834. break;
  8835. case Ki:
  8836. i = 16,
  8837. n = wr.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  8838. break;
  8839. default:
  8840. return null
  8841. }
  8842. var u = r[1] + 4
  8843. , c = l ? 6 : 1
  8844. , d = 1;
  8845. h && (d = Math.max(1, r[7]));
  8846. for (var f = [], p = 0; p < c; p++) {
  8847. var m = o
  8848. , g = s;
  8849. f[p] = new Dr({
  8850. width: m,
  8851. height: g,
  8852. format: n
  8853. });
  8854. for (var _ = [], v = 0; v < d; v++) {
  8855. var y = Math.max(4, m) / 4 * Math.max(4, g) / 4 * i
  8856. , x = new Uint8Array(e, u, y);
  8857. u += y,
  8858. m *= .5,
  8859. g *= .5,
  8860. _[v] = x
  8861. }
  8862. f[p].pixels = _[0],
  8863. h && (f[p].mipmaps = _)
  8864. }
  8865. if (!t)
  8866. return f[0];
  8867. t.width = f[0].width,
  8868. t.height = f[0].height,
  8869. t.format = f[0].format,
  8870. t.pixels = f[0].pixels,
  8871. t.mipmaps = f[0].mipmaps
  8872. };
  8873. var Ji = String.fromCharCode;
  8874. function $i(e, t, r, i) {
  8875. if (e[3] > 0) {
  8876. var n = Math.pow(2, e[3] - 128 - 8 + i);
  8877. t[r + 0] = e[0] * n,
  8878. t[r + 1] = e[1] * n,
  8879. t[r + 2] = e[2] * n
  8880. } else
  8881. t[r + 0] = 0,
  8882. t[r + 1] = 0,
  8883. t[r + 2] = 0;
  8884. return t[r + 3] = 1,
  8885. t
  8886. }
  8887. function en(e, t, r, i) {
  8888. for (var n, a, o = 0, s = 0, l = i; l > 0;)
  8889. if (e[s][0] = t[r++],
  8890. e[s][1] = t[r++],
  8891. e[s][2] = t[r++],
  8892. e[s][3] = t[r++],
  8893. 1 === e[s][0] && 1 === e[s][1] && 1 === e[s][2]) {
  8894. for (var h = e[s][3] << o >>> 0; h > 0; h--)
  8895. n = e[s - 1],
  8896. (a = e[s])[0] = n[0],
  8897. a[1] = n[1],
  8898. a[2] = n[2],
  8899. a[3] = n[3],
  8900. s++,
  8901. l--;
  8902. o += 8
  8903. } else
  8904. s++,
  8905. l--,
  8906. o = 0;
  8907. return r
  8908. }
  8909. function tn(e, t, r, i) {
  8910. if (i < 8 | i > 32767)
  8911. return en(e, t, r, i);
  8912. if (2 != (n = t[r++]))
  8913. return en(e, t, r - 1, i);
  8914. if (e[0][1] = t[r++],
  8915. e[0][2] = t[r++],
  8916. n = t[r++],
  8917. (e[0][2] << 8 >>> 0 | n) >>> 0 !== i)
  8918. return null;
  8919. for (var n = 0; n < 4; n++)
  8920. for (var a = 0; a < i;) {
  8921. var o = t[r++];
  8922. if (o > 128) {
  8923. o = (127 & o) >>> 0;
  8924. for (var s = t[r++]; o--;)
  8925. e[a++][n] = s
  8926. } else
  8927. for (; o--;)
  8928. e[a++][n] = t[r++]
  8929. }
  8930. return r
  8931. }
  8932. const rn = function (e, t, r) {
  8933. null == r && (r = 0);
  8934. var i = new Uint8Array(e)
  8935. , n = i.length;
  8936. if ("#?" === function (e, t, r) {
  8937. for (var i = "", n = 0; n < 2; n++)
  8938. i += Ji(e[n]);
  8939. return i
  8940. }(i)) {
  8941. for (var a = 2; a < n && ("\n" !== Ji(i[a]) || "\n" !== Ji(i[a + 1])); a++)
  8942. ;
  8943. if (!(a >= n)) {
  8944. a += 2;
  8945. for (var o = ""; a < n; a++) {
  8946. var s = Ji(i[a]);
  8947. if ("\n" === s)
  8948. break;
  8949. o += s
  8950. }
  8951. var l = o.split(" ")
  8952. , h = parseInt(l[1])
  8953. , u = parseInt(l[3]);
  8954. if (u && h) {
  8955. for (var c = a + 1, d = [], f = 0; f < u; f++) {
  8956. d[f] = [];
  8957. for (var p = 0; p < 4; p++)
  8958. d[f][p] = 0
  8959. }
  8960. for (var m = new Float32Array(u * h * 4), g = 0, _ = 0; _ < h; _++) {
  8961. if (!(c = tn(d, i, c, u)))
  8962. return null;
  8963. for (f = 0; f < u; f++)
  8964. $i(d[f], m, g, r),
  8965. g += 4
  8966. }
  8967. return t || (t = new Dr),
  8968. t.width = u,
  8969. t.height = h,
  8970. t.pixels = m,
  8971. t.type = wr.FLOAT,
  8972. t
  8973. }
  8974. }
  8975. }
  8976. };
  8977. var nn = {
  8978. loadTexture: function (e, t, r, i) {
  8979. var n;
  8980. if ("function" == typeof t ? (i = r = t,
  8981. t = {}) : t = t || {},
  8982. "string" == typeof e) {
  8983. if (e.match(/.hdr$/) || "hdr" === t.fileType)
  8984. return n = new Dr({
  8985. width: 0,
  8986. height: 0,
  8987. sRGB: !1
  8988. }),
  8989. nn._fetchTexture(e, (function (e) {
  8990. rn(e, n, t.exposure),
  8991. n.dirty(),
  8992. r && r(n)
  8993. }
  8994. ), i),
  8995. n;
  8996. e.match(/.dds$/) || "dds" === t.fileType ? (n = new Dr({
  8997. width: 0,
  8998. height: 0
  8999. }),
  9000. nn._fetchTexture(e, (function (e) {
  9001. Qi(e, n),
  9002. n.dirty(),
  9003. r && r(n)
  9004. }
  9005. ), i)) : ((n = new Dr).load(e),
  9006. n.success(r),
  9007. n.error(i))
  9008. } else
  9009. "object" == typeof e && void 0 !== e.px && ((n = new Ai).load(e),
  9010. n.success(r),
  9011. n.error(i));
  9012. return n
  9013. },
  9014. loadPanorama: function (e, t, r, i, n, a) {
  9015. var o = this;
  9016. "function" == typeof i ? (a = n = i,
  9017. i = {}) : i = i || {},
  9018. nn.loadTexture(t, i, (function (t) {
  9019. t.flipY = i.flipY || !1,
  9020. o.panoramaToCubeMap(e, t, r, i),
  9021. t.dispose(e),
  9022. n && n(r)
  9023. }
  9024. ), a)
  9025. },
  9026. panoramaToCubeMap: function (e, t, r, i) {
  9027. var n = new Ui
  9028. , a = new Xi({
  9029. scene: new vi
  9030. });
  9031. return a.setEnvironmentMap(t),
  9032. (i = i || {}).encodeRGBM && a.material.define("fragment", "RGBM_ENCODE"),
  9033. r.sRGB = t.sRGB,
  9034. n.texture = r,
  9035. n.render(e, a.scene),
  9036. n.texture = null,
  9037. n.dispose(e),
  9038. r
  9039. },
  9040. heightToNormal: function (e, t) {
  9041. var r = document.createElement("canvas")
  9042. , i = r.width = e.width
  9043. , n = r.height = e.height
  9044. , a = r.getContext("2d");
  9045. a.drawImage(e, 0, 0, i, n),
  9046. t = t || !1;
  9047. for (var o = a.getImageData(0, 0, i, n), s = a.createImageData(i, n), l = 0; l < o.data.length; l += 4) {
  9048. if (t) {
  9049. var h = o.data[l]
  9050. , u = o.data[l + 1]
  9051. , c = o.data[l + 2];
  9052. if (Math.abs(h - u) + Math.abs(u - c) > 20)
  9053. return console.warn("Given image is not a height map"),
  9054. e
  9055. }
  9056. var d, f, p, m;
  9057. l % (4 * i) == 0 ? (d = o.data[l],
  9058. p = o.data[l + 4]) : l % (4 * i) == 4 * (i - 1) ? (d = o.data[l - 4],
  9059. p = o.data[l]) : (d = o.data[l - 4],
  9060. p = o.data[l + 4]),
  9061. l < 4 * i ? (f = o.data[l],
  9062. m = o.data[l + 4 * i]) : l > i * (n - 1) * 4 ? (f = o.data[l - 4 * i],
  9063. m = o.data[l]) : (f = o.data[l - 4 * i],
  9064. m = o.data[l + 4 * i]),
  9065. s.data[l] = d - p + 127,
  9066. s.data[l + 1] = f - m + 127,
  9067. s.data[l + 2] = 255,
  9068. s.data[l + 3] = 255
  9069. }
  9070. return a.putImageData(s, 0, 0),
  9071. r
  9072. },
  9073. isHeightImage: function (e, t, r) {
  9074. if (!e || !e.width || !e.height)
  9075. return !1;
  9076. var i = document.createElement("canvas")
  9077. , n = i.getContext("2d")
  9078. , a = t || 32;
  9079. r = r || 20,
  9080. i.width = i.height = a,
  9081. n.drawImage(e, 0, 0, a, a);
  9082. for (var o = n.getImageData(0, 0, a, a), s = 0; s < o.data.length; s += 4) {
  9083. var l = o.data[s]
  9084. , h = o.data[s + 1]
  9085. , u = o.data[s + 2];
  9086. if (Math.abs(l - h) + Math.abs(h - u) > r)
  9087. return !1
  9088. }
  9089. return !0
  9090. },
  9091. _fetchTexture: function (e, t, r) {
  9092. U.request.get({
  9093. url: e,
  9094. responseType: "arraybuffer",
  9095. onload: t,
  9096. onerror: r
  9097. })
  9098. },
  9099. createChessboard: function (e, t, r, i) {
  9100. e = e || 512,
  9101. t = t || 64,
  9102. r = r || "black",
  9103. i = i || "white";
  9104. var n = Math.ceil(e / t)
  9105. , a = document.createElement("canvas");
  9106. a.width = e,
  9107. a.height = e;
  9108. var o = a.getContext("2d");
  9109. o.fillStyle = i,
  9110. o.fillRect(0, 0, e, e),
  9111. o.fillStyle = r;
  9112. for (var s = 0; s < n; s++)
  9113. for (var l = 0; l < n; l++)
  9114. (l % 2 ? s % 2 : s % 2 - 1) && o.fillRect(s * t, l * t, t, t);
  9115. return new Dr({
  9116. image: a,
  9117. anisotropic: 8
  9118. })
  9119. },
  9120. createBlank: function (e) {
  9121. var t = document.createElement("canvas");
  9122. t.width = 1,
  9123. t.height = 1;
  9124. var r = t.getContext("2d");
  9125. return r.fillStyle = e,
  9126. r.fillRect(0, 0, 1, 1),
  9127. new Dr({
  9128. image: t
  9129. })
  9130. }
  9131. };
  9132. const an = nn;
  9133. var on = ["mousedown", "mouseup", "mousemove", "mouseover", "mouseout", "click", "dblclick", "contextmenu"];
  9134. function sn(e) {
  9135. return "_on" + e
  9136. }
  9137. var ln = function (e) {
  9138. var t = this;
  9139. this._texture = new Dr({
  9140. anisotropic: 32,
  9141. flipY: !1,
  9142. surface: this,
  9143. dispose: function (e) {
  9144. t.dispose(),
  9145. Dr.prototype.dispose.call(this, e)
  9146. }
  9147. }),
  9148. on.forEach((function (e) {
  9149. this[sn(e)] = function (t) {
  9150. t.triangle && this._meshes.forEach((function (r) {
  9151. this.dispatchEvent(e, r, t.triangle, t.point)
  9152. }
  9153. ), this)
  9154. }
  9155. }
  9156. ), this),
  9157. this._meshes = [],
  9158. e && this.setECharts(e),
  9159. this.onupdate = null
  9160. };
  9161. ln.prototype = {
  9162. constructor: ln,
  9163. getTexture: function () {
  9164. return this._texture
  9165. },
  9166. setECharts: function (e) {
  9167. this._chart = e;
  9168. var t = e.getDom();
  9169. if (t instanceof HTMLCanvasElement) {
  9170. var r = this
  9171. , i = e.getZr()
  9172. , n = i.__oldRefreshImmediately || i.refreshImmediately;
  9173. i.refreshImmediately = function () {
  9174. n.call(this),
  9175. r._texture.dirty(),
  9176. r.onupdate && r.onupdate()
  9177. }
  9178. ,
  9179. i.__oldRefreshImmediately = n
  9180. } else
  9181. console.error("ECharts must init on canvas if it is used as texture."),
  9182. t = document.createElement("canvas");
  9183. this._texture.image = t,
  9184. this._texture.dirty(),
  9185. this.onupdate && this.onupdate()
  9186. },
  9187. dispatchEvent: function () {
  9188. var e = new vt
  9189. , t = new vt
  9190. , r = new vt
  9191. , i = new _e
  9192. , n = new _e
  9193. , a = new _e
  9194. , o = new _e
  9195. , s = new vt;
  9196. return function (l, h, u, c) {
  9197. var d = h.geometry
  9198. , f = d.attributes.position
  9199. , p = d.attributes.texcoord0
  9200. , m = vt.dot
  9201. , g = vt.cross;
  9202. f.get(u[0], e.array),
  9203. f.get(u[1], t.array),
  9204. f.get(u[2], r.array),
  9205. p.get(u[0], i.array),
  9206. p.get(u[1], n.array),
  9207. p.get(u[2], a.array),
  9208. g(s, t, r);
  9209. var _ = m(e, s)
  9210. , v = m(c, s) / _;
  9211. g(s, r, e);
  9212. var y = m(c, s) / _;
  9213. g(s, e, t);
  9214. var x = m(c, s) / _;
  9215. _e.scale(o, i, v),
  9216. _e.scaleAndAdd(o, o, n, y),
  9217. _e.scaleAndAdd(o, o, a, x);
  9218. var b = o.x * this._chart.getWidth()
  9219. , w = o.y * this._chart.getHeight();
  9220. this._chart.getZr().handler.dispatch(l, {
  9221. zrX: b,
  9222. zrY: w
  9223. })
  9224. }
  9225. }(),
  9226. attachToMesh: function (e) {
  9227. this._meshes.indexOf(e) >= 0 || (on.forEach((function (t) {
  9228. e.on(t, this[sn(t)], this)
  9229. }
  9230. ), this),
  9231. this._meshes.push(e))
  9232. },
  9233. detachFromMesh: function (e) {
  9234. var t = this._meshes.indexOf(e);
  9235. t >= 0 && this._meshes.splice(t, 1),
  9236. on.forEach((function (t) {
  9237. e.off(t, this[sn(t)])
  9238. }
  9239. ), this)
  9240. },
  9241. dispose: function () {
  9242. this._meshes.forEach((function (e) {
  9243. this.detachFromMesh(e)
  9244. }
  9245. ), this)
  9246. }
  9247. };
  9248. const hn = ln
  9249. , un = hi.extend({
  9250. left: -1,
  9251. right: 1,
  9252. near: -1,
  9253. far: 1,
  9254. top: 1,
  9255. bottom: -1
  9256. }, {
  9257. updateProjectionMatrix: function () {
  9258. this.projectionMatrix.ortho(this.left, this.right, this.bottom, this.top, this.near, this.far)
  9259. },
  9260. decomposeProjectionMatrix: function () {
  9261. var e = this.projectionMatrix.array;
  9262. this.left = (-1 - e[12]) / e[0],
  9263. this.right = (1 - e[12]) / e[0],
  9264. this.top = (1 - e[13]) / e[5],
  9265. this.bottom = (-1 - e[13]) / e[5],
  9266. this.near = -(-1 - e[14]) / e[10],
  9267. this.far = -(1 - e[14]) / e[10]
  9268. },
  9269. clone: function () {
  9270. var e = hi.prototype.clone.call(this);
  9271. return e.left = this.left,
  9272. e.right = this.right,
  9273. e.near = this.near,
  9274. e.far = this.far,
  9275. e.top = this.top,
  9276. e.bottom = this.bottom,
  9277. e
  9278. }
  9279. });
  9280. Xe.import("\n@export clay.compositor.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n v_Texcoord = texcoord;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end");
  9281. var cn = new ki
  9282. , dn = new Sr({
  9283. geometry: cn,
  9284. frustumCulling: !1
  9285. })
  9286. , fn = new un;
  9287. const pn = m.extend((function () {
  9288. return {
  9289. fragment: "",
  9290. outputs: null,
  9291. material: null,
  9292. blendWithPrevious: !1,
  9293. clearColor: !1,
  9294. clearDepth: !0
  9295. }
  9296. }
  9297. ), (function () {
  9298. var e = new Xe(Xe.source("clay.compositor.vertex"), this.fragment)
  9299. , t = new le({
  9300. shader: e
  9301. });
  9302. t.enableTexturesAll(),
  9303. this.material = t
  9304. }
  9305. ), {
  9306. setUniform: function (e, t) {
  9307. this.material.setUniform(e, t)
  9308. },
  9309. getUniform: function (e) {
  9310. var t = this.material.uniforms[e];
  9311. if (t)
  9312. return t.value
  9313. },
  9314. attachOutput: function (e, t) {
  9315. this.outputs || (this.outputs = {}),
  9316. t = t || 36064,
  9317. this.outputs[t] = e
  9318. },
  9319. detachOutput: function (e) {
  9320. for (var t in this.outputs)
  9321. this.outputs[t] === e && (this.outputs[t] = null)
  9322. },
  9323. bind: function (e, t) {
  9324. if (this.outputs)
  9325. for (var r in this.outputs) {
  9326. var i = this.outputs[r];
  9327. i && t.attach(i, r)
  9328. }
  9329. t && t.bind(e)
  9330. },
  9331. unbind: function (e, t) {
  9332. t.unbind(e)
  9333. },
  9334. render: function (e, t) {
  9335. var r = e.gl;
  9336. if (t) {
  9337. this.bind(e, t);
  9338. var i = e.getGLExtension("EXT_draw_buffers");
  9339. if (i && this.outputs) {
  9340. var n = [];
  9341. for (var a in this.outputs)
  9342. (a = +a) >= r.COLOR_ATTACHMENT0 && a <= r.COLOR_ATTACHMENT0 + 8 && n.push(a);
  9343. i.drawBuffersEXT(n)
  9344. }
  9345. }
  9346. this.trigger("beforerender", this, e);
  9347. var o = this.clearDepth ? r.DEPTH_BUFFER_BIT : 0;
  9348. if (r.depthMask(!0),
  9349. this.clearColor) {
  9350. o |= r.COLOR_BUFFER_BIT,
  9351. r.colorMask(!0, !0, !0, !0);
  9352. var s = this.clearColor;
  9353. Array.isArray(s) && r.clearColor(s[0], s[1], s[2], s[3])
  9354. }
  9355. r.clear(o),
  9356. this.blendWithPrevious ? (r.enable(r.BLEND),
  9357. this.material.transparent = !0) : (r.disable(r.BLEND),
  9358. this.material.transparent = !1),
  9359. this.renderQuad(e),
  9360. this.trigger("afterrender", this, e),
  9361. t && this.unbind(e, t)
  9362. },
  9363. renderQuad: function (e) {
  9364. dn.material = this.material,
  9365. e.renderPass([dn], fn)
  9366. },
  9367. dispose: function (e) { }
  9368. });
  9369. var mn = {}
  9370. , gn = ["px", "nx", "py", "ny", "pz", "nz"];
  9371. mn.prefilterEnvironmentMap = function (e, t, r, i, n) {
  9372. n && i || (i = mn.generateNormalDistribution(),
  9373. n = mn.integrateBRDF(e, i));
  9374. var a = (r = r || {}).width || 64
  9375. , o = r.height || 64
  9376. , s = r.type || t.type
  9377. , l = new Ai({
  9378. width: a,
  9379. height: o,
  9380. type: s,
  9381. flipY: !1,
  9382. mipmaps: []
  9383. });
  9384. l.isPowerOfTwo() || console.warn("Width and height must be power of two to enable mipmap.");
  9385. var h = Math.min(a, o)
  9386. , u = Math.log(h) / Math.log(2) + 1
  9387. , c = new le({
  9388. shader: new Xe({
  9389. vertex: Xe.source("clay.skybox.vertex"),
  9390. fragment: "#define SHADER_NAME prefilter\n#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform sampler2D normalDistribution;\nuniform float roughness : 0.5;\nvarying vec2 v_Texcoord;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvoid main() {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n vec3 N = V;\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n float fMaxSampleNumber = float(SAMPLE_NUMBER);\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fMaxSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(dot(N, L), 0.0, 1.0);\n if (NoL > 0.0) {\n prefilteredColor += decodeHDR(textureCube(environmentMap, L)).rgb * NoL;\n totalWeight += NoL;\n }\n }\n gl_FragColor = encodeHDR(vec4(prefilteredColor / totalWeight, 1.0));\n}\n"
  9391. })
  9392. });
  9393. c.set("normalDistribution", i),
  9394. r.encodeRGBM && c.define("fragment", "RGBM_ENCODE"),
  9395. r.decodeRGBM && c.define("fragment", "RGBM_DECODE");
  9396. var d, f = new vi;
  9397. if ("texture2D" === t.textureType) {
  9398. var p = new Ai({
  9399. width: a,
  9400. height: o,
  9401. type: s === wr.FLOAT ? wr.HALF_FLOAT : s
  9402. });
  9403. an.panoramaToCubeMap(e, t, p, {
  9404. encodeRGBM: r.decodeRGBM
  9405. }),
  9406. t = p
  9407. }
  9408. (d = new ji({
  9409. scene: f,
  9410. material: c
  9411. })).material.set("environmentMap", t);
  9412. var m = new Ui({
  9413. texture: l
  9414. });
  9415. r.encodeRGBM && (s = l.type = wr.UNSIGNED_BYTE);
  9416. for (var g = new Dr({
  9417. width: a,
  9418. height: o,
  9419. type: s
  9420. }), _ = new zi({
  9421. depthBuffer: !1
  9422. }), v = U[s === wr.UNSIGNED_BYTE ? "Uint8Array" : "Float32Array"], y = 0; y < u; y++) {
  9423. l.mipmaps[y] = {
  9424. pixels: {}
  9425. },
  9426. d.material.set("roughness", y / (u - 1));
  9427. for (var x = g.width, b = 2 * Math.atan(x / (x - .5)) / Math.PI * 180, w = 0; w < gn.length; w++) {
  9428. var T = new v(g.width * g.height * 4);
  9429. _.attach(g),
  9430. _.bind(e);
  9431. var S = m.getCamera(gn[w]);
  9432. S.fov = b,
  9433. e.render(f, S),
  9434. e.gl.readPixels(0, 0, g.width, g.height, wr.RGBA, s, T),
  9435. _.unbind(e),
  9436. l.mipmaps[y].pixels[gn[w]] = T
  9437. }
  9438. g.width /= 2,
  9439. g.height /= 2,
  9440. g.dirty()
  9441. }
  9442. return _.dispose(e),
  9443. g.dispose(e),
  9444. d.dispose(e),
  9445. i.dispose(e),
  9446. {
  9447. environmentMap: l,
  9448. brdfLookup: n,
  9449. normalDistribution: i,
  9450. maxMipmapLevel: u
  9451. }
  9452. }
  9453. ,
  9454. mn.integrateBRDF = function (e, t) {
  9455. t = t || mn.generateNormalDistribution();
  9456. var r = new zi({
  9457. depthBuffer: !1
  9458. })
  9459. , i = new pn({
  9460. fragment: "#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform sampler2D normalDistribution;\nuniform vec2 viewportSize : [512, 256];\nconst vec3 N = vec3(0.0, 0.0, 1.0);\nconst float fSampleNumber = float(SAMPLE_NUMBER);\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nfloat G_Smith(float roughness, float NoV, float NoL) {\n float k = roughness * roughness / 2.0;\n float G1V = NoV / (NoV * (1.0 - k) + k);\n float G1L = NoL / (NoL * (1.0 - k) + k);\n return G1L * G1V;\n}\nvoid main() {\n vec2 uv = gl_FragCoord.xy / viewportSize;\n float NoV = uv.x;\n float roughness = uv.y;\n vec3 V;\n V.x = sqrt(1.0 - NoV * NoV);\n V.y = 0.0;\n V.z = NoV;\n float A = 0.0;\n float B = 0.0;\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(L.z, 0.0, 1.0);\n float NoH = clamp(H.z, 0.0, 1.0);\n float VoH = clamp(dot(V, H), 0.0, 1.0);\n if (NoL > 0.0) {\n float G = G_Smith(roughness, NoV, NoL);\n float G_Vis = G * VoH / (NoH * NoV);\n float Fc = pow(1.0 - VoH, 5.0);\n A += (1.0 - Fc) * G_Vis;\n B += Fc * G_Vis;\n }\n }\n gl_FragColor = vec4(vec2(A, B) / fSampleNumber, 0.0, 1.0);\n}\n"
  9461. })
  9462. , n = new Dr({
  9463. width: 512,
  9464. height: 256,
  9465. type: wr.HALF_FLOAT,
  9466. wrapS: wr.CLAMP_TO_EDGE,
  9467. wrapT: wr.CLAMP_TO_EDGE,
  9468. minFilter: wr.NEAREST,
  9469. magFilter: wr.NEAREST,
  9470. useMipmap: !1
  9471. });
  9472. return i.setUniform("normalDistribution", t),
  9473. i.setUniform("viewportSize", [512, 256]),
  9474. i.attachOutput(n),
  9475. i.render(e, r),
  9476. r.dispose(e),
  9477. n
  9478. }
  9479. ,
  9480. mn.generateNormalDistribution = function (e, t) {
  9481. for (var r = new Dr({
  9482. width: e = e || 256,
  9483. height: t = t || 1024,
  9484. type: wr.FLOAT,
  9485. minFilter: wr.NEAREST,
  9486. magFilter: wr.NEAREST,
  9487. wrapS: wr.CLAMP_TO_EDGE,
  9488. wrapT: wr.CLAMP_TO_EDGE,
  9489. useMipmap: !1
  9490. }), i = new Float32Array(t * e * 4), n = [], a = 0; a < e; a++) {
  9491. for (var o = a / e, s = o * o, l = 0; l < t; l++) {
  9492. var h = (l << 16 | l >>> 16) >>> 0;
  9493. h = (((16711935 & (h = ((252645135 & (h = ((858993459 & (h = ((1431655765 & h) << 1 | (2863311530 & h) >>> 1) >>> 0)) << 2 | (3435973836 & h) >>> 2) >>> 0)) << 4 | (4042322160 & h) >>> 4) >>> 0)) << 8 | (4278255360 & h) >>> 8) >>> 0) / 4294967296;
  9494. var u = Math.sqrt((1 - h) / (1 + (s * s - 1) * h));
  9495. n[l] = u
  9496. }
  9497. for (l = 0; l < t; l++) {
  9498. var c = 4 * (l * e + a)
  9499. , d = (u = n[l],
  9500. Math.sqrt(1 - u * u))
  9501. , f = l / t
  9502. , p = 2 * Math.PI * f;
  9503. i[c] = d * Math.cos(p),
  9504. i[c + 1] = u,
  9505. i[c + 2] = d * Math.sin(p),
  9506. i[c + 3] = 1
  9507. }
  9508. }
  9509. return r.pixels = i,
  9510. r
  9511. }
  9512. ;
  9513. const _n = mn
  9514. , vn = qr.extend({
  9515. cubemap: null,
  9516. castShadow: !1,
  9517. _normalDistribution: null,
  9518. _brdfLookup: null
  9519. }, {
  9520. type: "AMBIENT_CUBEMAP_LIGHT",
  9521. prefilter: function (e, t) {
  9522. if (e.getGLExtension("EXT_shader_texture_lod")) {
  9523. this._brdfLookup || (this._normalDistribution = _n.generateNormalDistribution(),
  9524. this._brdfLookup = _n.integrateBRDF(e, this._normalDistribution));
  9525. var r = this.cubemap;
  9526. if (!r.__prefiltered) {
  9527. var i = _n.prefilterEnvironmentMap(e, r, {
  9528. encodeRGBM: !0,
  9529. width: t,
  9530. height: t
  9531. }, this._normalDistribution, this._brdfLookup);
  9532. this.cubemap = i.environmentMap,
  9533. this.cubemap.__prefiltered = !0,
  9534. r.dispose(e)
  9535. }
  9536. } else
  9537. console.warn("Device not support textureCubeLodEXT")
  9538. },
  9539. getBRDFLookup: function () {
  9540. return this._brdfLookup
  9541. },
  9542. uniformTemplates: {
  9543. ambientCubemapLightColor: {
  9544. type: "3f",
  9545. value: function (e) {
  9546. var t = e.color
  9547. , r = e.intensity;
  9548. return [t[0] * r, t[1] * r, t[2] * r]
  9549. }
  9550. },
  9551. ambientCubemapLightCubemap: {
  9552. type: "t",
  9553. value: function (e) {
  9554. return e.cubemap
  9555. }
  9556. },
  9557. ambientCubemapLightBRDFLookup: {
  9558. type: "t",
  9559. value: function (e) {
  9560. return e._brdfLookup
  9561. }
  9562. }
  9563. }
  9564. })
  9565. , yn = qr.extend({
  9566. castShadow: !1,
  9567. coefficients: []
  9568. }, (function () {
  9569. this._coefficientsTmpArr = new U.Float32Array(27)
  9570. }
  9571. ), {
  9572. type: "AMBIENT_SH_LIGHT",
  9573. uniformTemplates: {
  9574. ambientSHLightColor: {
  9575. type: "3f",
  9576. value: function (e) {
  9577. var t = e.color
  9578. , r = e.intensity;
  9579. return [t[0] * r, t[1] * r, t[2] * r]
  9580. }
  9581. },
  9582. ambientSHLightCoefficients: {
  9583. type: "3f",
  9584. value: function (e) {
  9585. for (var t = e._coefficientsTmpArr, r = 0; r < e.coefficients.length; r++)
  9586. t[r] = e.coefficients[r];
  9587. return t
  9588. }
  9589. }
  9590. }
  9591. });
  9592. var xn = {}
  9593. , bn = ["px", "nx", "py", "ny", "pz", "nz"];
  9594. function wn(e, t) {
  9595. var r = e[0]
  9596. , i = e[1]
  9597. , n = e[2];
  9598. return 0 === t ? 1 : 1 === t ? r : 2 === t ? i : 3 === t ? n : 4 === t ? r * n : 5 === t ? i * n : 6 === t ? r * i : 7 === t ? 3 * n * n - 1 : r * r - i * i
  9599. }
  9600. var Tn = {
  9601. px: [2, 1, 0, -1, -1, 1],
  9602. nx: [2, 1, 0, 1, -1, -1],
  9603. py: [0, 2, 1, 1, -1, -1],
  9604. ny: [0, 2, 1, 1, 1, 1],
  9605. pz: [0, 1, 2, -1, -1, -1],
  9606. nz: [0, 1, 2, 1, -1, 1]
  9607. };
  9608. xn.projectEnvironmentMap = function (e, t, r) {
  9609. var i;
  9610. (r = r || {}).lod = r.lod || 0;
  9611. var n = new vi
  9612. , a = 64;
  9613. "texture2D" === t.textureType ? i = new Xi({
  9614. scene: n,
  9615. environmentMap: t
  9616. }) : (a = t.image && t.image.px ? t.image.px.width : t.width,
  9617. i = new ji({
  9618. scene: n,
  9619. environmentMap: t
  9620. }));
  9621. var o = Math.ceil(a / Math.pow(2, r.lod))
  9622. , s = Math.ceil(a / Math.pow(2, r.lod))
  9623. , l = new Dr({
  9624. width: o,
  9625. height: s
  9626. })
  9627. , h = new zi;
  9628. i.material.define("fragment", "RGBM_ENCODE"),
  9629. r.decodeRGBM && i.material.define("fragment", "RGBM_DECODE"),
  9630. i.material.set("lod", r.lod);
  9631. for (var u = new Ui({
  9632. texture: l
  9633. }), c = {}, d = 0; d < bn.length; d++) {
  9634. c[bn[d]] = new Uint8Array(o * s * 4);
  9635. var f = u.getCamera(bn[d]);
  9636. f.fov = 90,
  9637. h.attach(l),
  9638. h.bind(e),
  9639. e.render(n, f),
  9640. e.gl.readPixels(0, 0, o, s, wr.RGBA, wr.UNSIGNED_BYTE, c[bn[d]]),
  9641. h.unbind(e)
  9642. }
  9643. return i.dispose(e),
  9644. h.dispose(e),
  9645. l.dispose(e),
  9646. function (e, t, r, i) {
  9647. for (var n = new U.Float32Array(27), a = Qe.create(), o = Qe.create(), s = Qe.create(), l = 0; l < 9; l++) {
  9648. for (var h = Qe.create(), u = 0; u < bn.length; u++) {
  9649. for (var c = t[bn[u]], d = Qe.create(), f = 0, p = 0, m = Tn[bn[u]], g = 0; g < i; g++)
  9650. for (var _ = 0; _ < r; _++) {
  9651. a[0] = _ / (r - 1) * 2 - 1,
  9652. a[1] = g / (i - 1) * 2 - 1,
  9653. a[2] = -1,
  9654. Qe.normalize(a, a),
  9655. s[0] = a[m[0]] * m[3],
  9656. s[1] = a[m[1]] * m[4],
  9657. s[2] = a[m[2]] * m[5],
  9658. o[0] = c[p++] / 255,
  9659. o[1] = c[p++] / 255,
  9660. o[2] = c[p++] / 255;
  9661. var v = c[p++] / 255 * 8.12;
  9662. o[0] *= v,
  9663. o[1] *= v,
  9664. o[2] *= v,
  9665. Qe.scaleAndAdd(d, d, o, wn(s, l) * -a[2]),
  9666. f += -a[2]
  9667. }
  9668. Qe.scaleAndAdd(h, h, d, 1 / f)
  9669. }
  9670. n[3 * l] = h[0] / 6,
  9671. n[3 * l + 1] = h[1] / 6,
  9672. n[3 * l + 2] = h[2] / 6
  9673. }
  9674. return n
  9675. }(0, c, o, s)
  9676. }
  9677. ;
  9678. const Sn = xn
  9679. , Mn = function () {
  9680. for (var e = 0, t = arguments.length; e < t; e++)
  9681. if (null != arguments[e])
  9682. return arguments[e]
  9683. }
  9684. , An = function (e, t) {
  9685. return null != t.dataIndexInside ? t.dataIndexInside : null != t.dataIndex ? i.util.isArray(t.dataIndex) ? i.util.map(t.dataIndex, (function (t) {
  9686. return e.indexOfRawIndex(t)
  9687. }
  9688. )) : e.indexOfRawIndex(t.dataIndex) : null != t.name ? i.util.isArray(t.name) ? i.util.map(t.name, (function (t) {
  9689. return e.indexOfName(t)
  9690. }
  9691. )) : e.indexOfName(t.name) : void 0
  9692. }
  9693. , En = Vr.extend({
  9694. dynamic: !1,
  9695. widthSegments: 40,
  9696. heightSegments: 20,
  9697. phiStart: 0,
  9698. phiLength: 2 * Math.PI,
  9699. thetaStart: 0,
  9700. thetaLength: Math.PI,
  9701. radius: 1
  9702. }, (function () {
  9703. this.build()
  9704. }
  9705. ), {
  9706. build: function () {
  9707. var e = this.heightSegments
  9708. , t = this.widthSegments
  9709. , r = this.attributes.position
  9710. , i = this.attributes.texcoord0
  9711. , n = this.attributes.normal
  9712. , a = (t + 1) * (e + 1);
  9713. r.init(a),
  9714. i.init(a),
  9715. n.init(a);
  9716. var o, s, l, h, u, c, d, f, p, m, g, _ = a > 65535 ? Uint32Array : Uint16Array, v = this.indices = new _(t * e * 6), y = this.radius, x = this.phiStart, b = this.phiLength, w = this.thetaStart, T = this.thetaLength, S = [], M = [], A = 0, E = 1 / (y = this.radius);
  9717. for (d = 0; d <= e; d++)
  9718. for (c = 0; c <= t; c++)
  9719. h = c / t,
  9720. u = d / e,
  9721. o = -y * Math.cos(x + h * b) * Math.sin(w + u * T),
  9722. s = y * Math.cos(w + u * T),
  9723. l = y * Math.sin(x + h * b) * Math.sin(w + u * T),
  9724. S[0] = o,
  9725. S[1] = s,
  9726. S[2] = l,
  9727. M[0] = h,
  9728. M[1] = u,
  9729. r.set(A, S),
  9730. i.set(A, M),
  9731. S[0] *= E,
  9732. S[1] *= E,
  9733. S[2] *= E,
  9734. n.set(A, S),
  9735. A++;
  9736. var C = t + 1
  9737. , D = 0;
  9738. for (d = 0; d < e; d++)
  9739. for (c = 0; c < t; c++)
  9740. p = d * C + c,
  9741. f = d * C + c + 1,
  9742. g = (d + 1) * C + c + 1,
  9743. m = (d + 1) * C + c,
  9744. v[D++] = f,
  9745. v[D++] = p,
  9746. v[D++] = g,
  9747. v[D++] = p,
  9748. v[D++] = m,
  9749. v[D++] = g;
  9750. this.boundingBox = new ir,
  9751. this.boundingBox.max.set(y, y, y),
  9752. this.boundingBox.min.set(-y, -y, -y)
  9753. }
  9754. })
  9755. , Cn = qr.extend({
  9756. castShadow: !1
  9757. }, {
  9758. type: "AMBIENT_LIGHT",
  9759. uniformTemplates: {
  9760. ambientLightColor: {
  9761. type: "3f",
  9762. value: function (e) {
  9763. var t = e.color
  9764. , r = e.intensity;
  9765. return [t[0] * r, t[1] * r, t[2] * r]
  9766. }
  9767. }
  9768. }
  9769. })
  9770. , Dn = qr.extend({
  9771. shadowBias: .001,
  9772. shadowSlopeScale: 2,
  9773. shadowCascade: 1,
  9774. cascadeSplitLogFactor: .2
  9775. }, {
  9776. type: "DIRECTIONAL_LIGHT",
  9777. uniformTemplates: {
  9778. directionalLightDirection: {
  9779. type: "3f",
  9780. value: function (e) {
  9781. return e.__dir = e.__dir || new vt,
  9782. e.__dir.copy(e.worldTransform.z).normalize().negate().array
  9783. }
  9784. },
  9785. directionalLightColor: {
  9786. type: "3f",
  9787. value: function (e) {
  9788. var t = e.color
  9789. , r = e.intensity;
  9790. return [t[0] * r, t[1] * r, t[2] * r]
  9791. }
  9792. }
  9793. },
  9794. clone: function () {
  9795. var e = qr.prototype.clone.call(this);
  9796. return e.shadowBias = this.shadowBias,
  9797. e.shadowSlopeScale = this.shadowSlopeScale,
  9798. e
  9799. }
  9800. })
  9801. , Ln = qr.extend({
  9802. range: 100,
  9803. castShadow: !1
  9804. }, {
  9805. type: "POINT_LIGHT",
  9806. uniformTemplates: {
  9807. pointLightPosition: {
  9808. type: "3f",
  9809. value: function (e) {
  9810. return e.getWorldPosition().array
  9811. }
  9812. },
  9813. pointLightRange: {
  9814. type: "1f",
  9815. value: function (e) {
  9816. return e.range
  9817. }
  9818. },
  9819. pointLightColor: {
  9820. type: "3f",
  9821. value: function (e) {
  9822. var t = e.color
  9823. , r = e.intensity;
  9824. return [t[0] * r, t[1] * r, t[2] * r]
  9825. }
  9826. }
  9827. },
  9828. clone: function () {
  9829. var e = qr.prototype.clone.call(this);
  9830. return e.range = this.range,
  9831. e
  9832. }
  9833. })
  9834. , Pn = qr.extend({
  9835. range: 20,
  9836. umbraAngle: 30,
  9837. penumbraAngle: 45,
  9838. falloffFactor: 2,
  9839. shadowBias: .001,
  9840. shadowSlopeScale: 2
  9841. }, {
  9842. type: "SPOT_LIGHT",
  9843. uniformTemplates: {
  9844. spotLightPosition: {
  9845. type: "3f",
  9846. value: function (e) {
  9847. return e.getWorldPosition().array
  9848. }
  9849. },
  9850. spotLightRange: {
  9851. type: "1f",
  9852. value: function (e) {
  9853. return e.range
  9854. }
  9855. },
  9856. spotLightUmbraAngleCosine: {
  9857. type: "1f",
  9858. value: function (e) {
  9859. return Math.cos(e.umbraAngle * Math.PI / 180)
  9860. }
  9861. },
  9862. spotLightPenumbraAngleCosine: {
  9863. type: "1f",
  9864. value: function (e) {
  9865. return Math.cos(e.penumbraAngle * Math.PI / 180)
  9866. }
  9867. },
  9868. spotLightFalloffFactor: {
  9869. type: "1f",
  9870. value: function (e) {
  9871. return e.falloffFactor
  9872. }
  9873. },
  9874. spotLightDirection: {
  9875. type: "3f",
  9876. value: function (e) {
  9877. return e.__dir = e.__dir || new vt,
  9878. e.__dir.copy(e.worldTransform.z).negate().array
  9879. }
  9880. },
  9881. spotLightColor: {
  9882. type: "3f",
  9883. value: function (e) {
  9884. var t = e.color
  9885. , r = e.intensity;
  9886. return [t[0] * r, t[1] * r, t[2] * r]
  9887. }
  9888. }
  9889. },
  9890. clone: function () {
  9891. var e = qr.prototype.clone.call(this);
  9892. return e.range = this.range,
  9893. e.umbraAngle = this.umbraAngle,
  9894. e.penumbraAngle = this.penumbraAngle,
  9895. e.falloffFactor = this.falloffFactor,
  9896. e.shadowBias = this.shadowBias,
  9897. e.shadowSlopeScale = this.shadowSlopeScale,
  9898. e
  9899. }
  9900. });
  9901. var On = function (e, t, r, i) {
  9902. e = e || 0,
  9903. t = t || 0,
  9904. r = r || 0,
  9905. i = i || 0,
  9906. this.array = Et.fromValues(e, t, r, i),
  9907. this._dirty = !0
  9908. };
  9909. On.prototype = {
  9910. constructor: On,
  9911. add: function (e) {
  9912. return Et.add(this.array, this.array, e.array),
  9913. this._dirty = !0,
  9914. this
  9915. },
  9916. set: function (e, t, r, i) {
  9917. return this.array[0] = e,
  9918. this.array[1] = t,
  9919. this.array[2] = r,
  9920. this.array[3] = i,
  9921. this._dirty = !0,
  9922. this
  9923. },
  9924. setArray: function (e) {
  9925. return this.array[0] = e[0],
  9926. this.array[1] = e[1],
  9927. this.array[2] = e[2],
  9928. this.array[3] = e[3],
  9929. this._dirty = !0,
  9930. this
  9931. },
  9932. clone: function () {
  9933. return new On(this.x, this.y, this.z, this.w)
  9934. },
  9935. copy: function (e) {
  9936. return Et.copy(this.array, e.array),
  9937. this._dirty = !0,
  9938. this
  9939. },
  9940. dist: function (e) {
  9941. return Et.dist(this.array, e.array)
  9942. },
  9943. distance: function (e) {
  9944. return Et.distance(this.array, e.array)
  9945. },
  9946. div: function (e) {
  9947. return Et.div(this.array, this.array, e.array),
  9948. this._dirty = !0,
  9949. this
  9950. },
  9951. divide: function (e) {
  9952. return Et.divide(this.array, this.array, e.array),
  9953. this._dirty = !0,
  9954. this
  9955. },
  9956. dot: function (e) {
  9957. return Et.dot(this.array, e.array)
  9958. },
  9959. len: function () {
  9960. return Et.len(this.array)
  9961. },
  9962. length: function () {
  9963. return Et.length(this.array)
  9964. },
  9965. lerp: function (e, t, r) {
  9966. return Et.lerp(this.array, e.array, t.array, r),
  9967. this._dirty = !0,
  9968. this
  9969. },
  9970. min: function (e) {
  9971. return Et.min(this.array, this.array, e.array),
  9972. this._dirty = !0,
  9973. this
  9974. },
  9975. max: function (e) {
  9976. return Et.max(this.array, this.array, e.array),
  9977. this._dirty = !0,
  9978. this
  9979. },
  9980. mul: function (e) {
  9981. return Et.mul(this.array, this.array, e.array),
  9982. this._dirty = !0,
  9983. this
  9984. },
  9985. multiply: function (e) {
  9986. return Et.multiply(this.array, this.array, e.array),
  9987. this._dirty = !0,
  9988. this
  9989. },
  9990. negate: function () {
  9991. return Et.negate(this.array, this.array),
  9992. this._dirty = !0,
  9993. this
  9994. },
  9995. normalize: function () {
  9996. return Et.normalize(this.array, this.array),
  9997. this._dirty = !0,
  9998. this
  9999. },
  10000. random: function (e) {
  10001. return Et.random(this.array, e),
  10002. this._dirty = !0,
  10003. this
  10004. },
  10005. scale: function (e) {
  10006. return Et.scale(this.array, this.array, e),
  10007. this._dirty = !0,
  10008. this
  10009. },
  10010. scaleAndAdd: function (e, t) {
  10011. return Et.scaleAndAdd(this.array, this.array, e.array, t),
  10012. this._dirty = !0,
  10013. this
  10014. },
  10015. sqrDist: function (e) {
  10016. return Et.sqrDist(this.array, e.array)
  10017. },
  10018. squaredDistance: function (e) {
  10019. return Et.squaredDistance(this.array, e.array)
  10020. },
  10021. sqrLen: function () {
  10022. return Et.sqrLen(this.array)
  10023. },
  10024. squaredLength: function () {
  10025. return Et.squaredLength(this.array)
  10026. },
  10027. sub: function (e) {
  10028. return Et.sub(this.array, this.array, e.array),
  10029. this._dirty = !0,
  10030. this
  10031. },
  10032. subtract: function (e) {
  10033. return Et.subtract(this.array, this.array, e.array),
  10034. this._dirty = !0,
  10035. this
  10036. },
  10037. transformMat4: function (e) {
  10038. return Et.transformMat4(this.array, this.array, e.array),
  10039. this._dirty = !0,
  10040. this
  10041. },
  10042. transformQuat: function (e) {
  10043. return Et.transformQuat(this.array, this.array, e.array),
  10044. this._dirty = !0,
  10045. this
  10046. },
  10047. toString: function () {
  10048. return "[" + Array.prototype.join.call(this.array, ",") + "]"
  10049. },
  10050. toArray: function () {
  10051. return Array.prototype.slice.call(this.array)
  10052. }
  10053. };
  10054. var Nn = Object.defineProperty;
  10055. if (Nn) {
  10056. var In = On.prototype;
  10057. Nn(In, "x", {
  10058. get: function () {
  10059. return this.array[0]
  10060. },
  10061. set: function (e) {
  10062. this.array[0] = e,
  10063. this._dirty = !0
  10064. }
  10065. }),
  10066. Nn(In, "y", {
  10067. get: function () {
  10068. return this.array[1]
  10069. },
  10070. set: function (e) {
  10071. this.array[1] = e,
  10072. this._dirty = !0
  10073. }
  10074. }),
  10075. Nn(In, "z", {
  10076. get: function () {
  10077. return this.array[2]
  10078. },
  10079. set: function (e) {
  10080. this.array[2] = e,
  10081. this._dirty = !0
  10082. }
  10083. }),
  10084. Nn(In, "w", {
  10085. get: function () {
  10086. return this.array[3]
  10087. },
  10088. set: function (e) {
  10089. this.array[3] = e,
  10090. this._dirty = !0
  10091. }
  10092. })
  10093. }
  10094. On.add = function (e, t, r) {
  10095. return Et.add(e.array, t.array, r.array),
  10096. e._dirty = !0,
  10097. e
  10098. }
  10099. ,
  10100. On.set = function (e, t, r, i, n) {
  10101. Et.set(e.array, t, r, i, n),
  10102. e._dirty = !0
  10103. }
  10104. ,
  10105. On.copy = function (e, t) {
  10106. return Et.copy(e.array, t.array),
  10107. e._dirty = !0,
  10108. e
  10109. }
  10110. ,
  10111. On.distance = On.dist = function (e, t) {
  10112. return Et.distance(e.array, t.array)
  10113. }
  10114. ,
  10115. On.divide = On.div = function (e, t, r) {
  10116. return Et.divide(e.array, t.array, r.array),
  10117. e._dirty = !0,
  10118. e
  10119. }
  10120. ,
  10121. On.dot = function (e, t) {
  10122. return Et.dot(e.array, t.array)
  10123. }
  10124. ,
  10125. On.len = function (e) {
  10126. return Et.length(e.array)
  10127. }
  10128. ,
  10129. On.lerp = function (e, t, r, i) {
  10130. return Et.lerp(e.array, t.array, r.array, i),
  10131. e._dirty = !0,
  10132. e
  10133. }
  10134. ,
  10135. On.min = function (e, t, r) {
  10136. return Et.min(e.array, t.array, r.array),
  10137. e._dirty = !0,
  10138. e
  10139. }
  10140. ,
  10141. On.max = function (e, t, r) {
  10142. return Et.max(e.array, t.array, r.array),
  10143. e._dirty = !0,
  10144. e
  10145. }
  10146. ,
  10147. On.multiply = On.mul = function (e, t, r) {
  10148. return Et.multiply(e.array, t.array, r.array),
  10149. e._dirty = !0,
  10150. e
  10151. }
  10152. ,
  10153. On.negate = function (e, t) {
  10154. return Et.negate(e.array, t.array),
  10155. e._dirty = !0,
  10156. e
  10157. }
  10158. ,
  10159. On.normalize = function (e, t) {
  10160. return Et.normalize(e.array, t.array),
  10161. e._dirty = !0,
  10162. e
  10163. }
  10164. ,
  10165. On.random = function (e, t) {
  10166. return Et.random(e.array, t),
  10167. e._dirty = !0,
  10168. e
  10169. }
  10170. ,
  10171. On.scale = function (e, t, r) {
  10172. return Et.scale(e.array, t.array, r),
  10173. e._dirty = !0,
  10174. e
  10175. }
  10176. ,
  10177. On.scaleAndAdd = function (e, t, r, i) {
  10178. return Et.scaleAndAdd(e.array, t.array, r.array, i),
  10179. e._dirty = !0,
  10180. e
  10181. }
  10182. ,
  10183. On.squaredDistance = On.sqrDist = function (e, t) {
  10184. return Et.sqrDist(e.array, t.array)
  10185. }
  10186. ,
  10187. On.squaredLength = On.sqrLen = function (e) {
  10188. return Et.sqrLen(e.array)
  10189. }
  10190. ,
  10191. On.subtract = On.sub = function (e, t, r) {
  10192. return Et.subtract(e.array, t.array, r.array),
  10193. e._dirty = !0,
  10194. e
  10195. }
  10196. ,
  10197. On.transformMat4 = function (e, t, r) {
  10198. return Et.transformMat4(e.array, t.array, r.array),
  10199. e._dirty = !0,
  10200. e
  10201. }
  10202. ,
  10203. On.transformQuat = function (e, t, r) {
  10204. return Et.transformQuat(e.array, t.array, r.array),
  10205. e._dirty = !0,
  10206. e
  10207. }
  10208. ;
  10209. const Rn = On;
  10210. var Bn = {
  10211. create: function () {
  10212. var e = new ce(4);
  10213. return e[0] = 1,
  10214. e[1] = 0,
  10215. e[2] = 0,
  10216. e[3] = 1,
  10217. e
  10218. },
  10219. clone: function (e) {
  10220. var t = new ce(4);
  10221. return t[0] = e[0],
  10222. t[1] = e[1],
  10223. t[2] = e[2],
  10224. t[3] = e[3],
  10225. t
  10226. },
  10227. copy: function (e, t) {
  10228. return e[0] = t[0],
  10229. e[1] = t[1],
  10230. e[2] = t[2],
  10231. e[3] = t[3],
  10232. e
  10233. },
  10234. identity: function (e) {
  10235. return e[0] = 1,
  10236. e[1] = 0,
  10237. e[2] = 0,
  10238. e[3] = 1,
  10239. e
  10240. },
  10241. transpose: function (e, t) {
  10242. if (e === t) {
  10243. var r = t[1];
  10244. e[1] = t[2],
  10245. e[2] = r
  10246. } else
  10247. e[0] = t[0],
  10248. e[1] = t[2],
  10249. e[2] = t[1],
  10250. e[3] = t[3];
  10251. return e
  10252. },
  10253. invert: function (e, t) {
  10254. var r = t[0]
  10255. , i = t[1]
  10256. , n = t[2]
  10257. , a = t[3]
  10258. , o = r * a - n * i;
  10259. return o ? (o = 1 / o,
  10260. e[0] = a * o,
  10261. e[1] = -i * o,
  10262. e[2] = -n * o,
  10263. e[3] = r * o,
  10264. e) : null
  10265. },
  10266. adjoint: function (e, t) {
  10267. var r = t[0];
  10268. return e[0] = t[3],
  10269. e[1] = -t[1],
  10270. e[2] = -t[2],
  10271. e[3] = r,
  10272. e
  10273. },
  10274. determinant: function (e) {
  10275. return e[0] * e[3] - e[2] * e[1]
  10276. },
  10277. multiply: function (e, t, r) {
  10278. var i = t[0]
  10279. , n = t[1]
  10280. , a = t[2]
  10281. , o = t[3]
  10282. , s = r[0]
  10283. , l = r[1]
  10284. , h = r[2]
  10285. , u = r[3];
  10286. return e[0] = i * s + a * l,
  10287. e[1] = n * s + o * l,
  10288. e[2] = i * h + a * u,
  10289. e[3] = n * h + o * u,
  10290. e
  10291. }
  10292. };
  10293. Bn.mul = Bn.multiply,
  10294. Bn.rotate = function (e, t, r) {
  10295. var i = t[0]
  10296. , n = t[1]
  10297. , a = t[2]
  10298. , o = t[3]
  10299. , s = Math.sin(r)
  10300. , l = Math.cos(r);
  10301. return e[0] = i * l + a * s,
  10302. e[1] = n * l + o * s,
  10303. e[2] = i * -s + a * l,
  10304. e[3] = n * -s + o * l,
  10305. e
  10306. }
  10307. ,
  10308. Bn.scale = function (e, t, r) {
  10309. var i = t[0]
  10310. , n = t[1]
  10311. , a = t[2]
  10312. , o = t[3]
  10313. , s = r[0]
  10314. , l = r[1];
  10315. return e[0] = i * s,
  10316. e[1] = n * s,
  10317. e[2] = a * l,
  10318. e[3] = o * l,
  10319. e
  10320. }
  10321. ,
  10322. Bn.frob = function (e) {
  10323. return Math.sqrt(Math.pow(e[0], 2) + Math.pow(e[1], 2) + Math.pow(e[2], 2) + Math.pow(e[3], 2))
  10324. }
  10325. ,
  10326. Bn.LDU = function (e, t, r, i) {
  10327. return e[2] = i[2] / i[0],
  10328. r[0] = i[0],
  10329. r[1] = i[1],
  10330. r[3] = i[3] - e[2] * r[1],
  10331. [e, t, r]
  10332. }
  10333. ;
  10334. const Fn = Bn;
  10335. var zn = function () {
  10336. this.array = Fn.create(),
  10337. this._dirty = !0
  10338. };
  10339. zn.prototype = {
  10340. constructor: zn,
  10341. setArray: function (e) {
  10342. for (var t = 0; t < this.array.length; t++)
  10343. this.array[t] = e[t];
  10344. return this._dirty = !0,
  10345. this
  10346. },
  10347. clone: function () {
  10348. return (new zn).copy(this)
  10349. },
  10350. copy: function (e) {
  10351. return Fn.copy(this.array, e.array),
  10352. this._dirty = !0,
  10353. this
  10354. },
  10355. adjoint: function () {
  10356. return Fn.adjoint(this.array, this.array),
  10357. this._dirty = !0,
  10358. this
  10359. },
  10360. determinant: function () {
  10361. return Fn.determinant(this.array)
  10362. },
  10363. identity: function () {
  10364. return Fn.identity(this.array),
  10365. this._dirty = !0,
  10366. this
  10367. },
  10368. invert: function () {
  10369. return Fn.invert(this.array, this.array),
  10370. this._dirty = !0,
  10371. this
  10372. },
  10373. mul: function (e) {
  10374. return Fn.mul(this.array, this.array, e.array),
  10375. this._dirty = !0,
  10376. this
  10377. },
  10378. mulLeft: function (e) {
  10379. return Fn.mul(this.array, e.array, this.array),
  10380. this._dirty = !0,
  10381. this
  10382. },
  10383. multiply: function (e) {
  10384. return Fn.multiply(this.array, this.array, e.array),
  10385. this._dirty = !0,
  10386. this
  10387. },
  10388. multiplyLeft: function (e) {
  10389. return Fn.multiply(this.array, e.array, this.array),
  10390. this._dirty = !0,
  10391. this
  10392. },
  10393. rotate: function (e) {
  10394. return Fn.rotate(this.array, this.array, e),
  10395. this._dirty = !0,
  10396. this
  10397. },
  10398. scale: function (e) {
  10399. return Fn.scale(this.array, this.array, e.array),
  10400. this._dirty = !0,
  10401. this
  10402. },
  10403. transpose: function () {
  10404. return Fn.transpose(this.array, this.array),
  10405. this._dirty = !0,
  10406. this
  10407. },
  10408. toString: function () {
  10409. return "[" + Array.prototype.join.call(this.array, ",") + "]"
  10410. },
  10411. toArray: function () {
  10412. return Array.prototype.slice.call(this.array)
  10413. }
  10414. },
  10415. zn.adjoint = function (e, t) {
  10416. return Fn.adjoint(e.array, t.array),
  10417. e._dirty = !0,
  10418. e
  10419. }
  10420. ,
  10421. zn.copy = function (e, t) {
  10422. return Fn.copy(e.array, t.array),
  10423. e._dirty = !0,
  10424. e
  10425. }
  10426. ,
  10427. zn.determinant = function (e) {
  10428. return Fn.determinant(e.array)
  10429. }
  10430. ,
  10431. zn.identity = function (e) {
  10432. return Fn.identity(e.array),
  10433. e._dirty = !0,
  10434. e
  10435. }
  10436. ,
  10437. zn.invert = function (e, t) {
  10438. return Fn.invert(e.array, t.array),
  10439. e._dirty = !0,
  10440. e
  10441. }
  10442. ,
  10443. zn.multiply = zn.mul = function (e, t, r) {
  10444. return Fn.mul(e.array, t.array, r.array),
  10445. e._dirty = !0,
  10446. e
  10447. }
  10448. ,
  10449. zn.rotate = function (e, t, r) {
  10450. return Fn.rotate(e.array, t.array, r),
  10451. e._dirty = !0,
  10452. e
  10453. }
  10454. ,
  10455. zn.scale = function (e, t, r) {
  10456. return Fn.scale(e.array, t.array, r.array),
  10457. e._dirty = !0,
  10458. e
  10459. }
  10460. ,
  10461. zn.transpose = function (e, t) {
  10462. return Fn.transpose(e.array, t.array),
  10463. e._dirty = !0,
  10464. e
  10465. }
  10466. ;
  10467. const Gn = zn;
  10468. var Un = {
  10469. create: function () {
  10470. var e = new ce(6);
  10471. return e[0] = 1,
  10472. e[1] = 0,
  10473. e[2] = 0,
  10474. e[3] = 1,
  10475. e[4] = 0,
  10476. e[5] = 0,
  10477. e
  10478. },
  10479. clone: function (e) {
  10480. var t = new ce(6);
  10481. return t[0] = e[0],
  10482. t[1] = e[1],
  10483. t[2] = e[2],
  10484. t[3] = e[3],
  10485. t[4] = e[4],
  10486. t[5] = e[5],
  10487. t
  10488. },
  10489. copy: function (e, t) {
  10490. return e[0] = t[0],
  10491. e[1] = t[1],
  10492. e[2] = t[2],
  10493. e[3] = t[3],
  10494. e[4] = t[4],
  10495. e[5] = t[5],
  10496. e
  10497. },
  10498. identity: function (e) {
  10499. return e[0] = 1,
  10500. e[1] = 0,
  10501. e[2] = 0,
  10502. e[3] = 1,
  10503. e[4] = 0,
  10504. e[5] = 0,
  10505. e
  10506. },
  10507. invert: function (e, t) {
  10508. var r = t[0]
  10509. , i = t[1]
  10510. , n = t[2]
  10511. , a = t[3]
  10512. , o = t[4]
  10513. , s = t[5]
  10514. , l = r * a - i * n;
  10515. return l ? (l = 1 / l,
  10516. e[0] = a * l,
  10517. e[1] = -i * l,
  10518. e[2] = -n * l,
  10519. e[3] = r * l,
  10520. e[4] = (n * s - a * o) * l,
  10521. e[5] = (i * o - r * s) * l,
  10522. e) : null
  10523. },
  10524. determinant: function (e) {
  10525. return e[0] * e[3] - e[1] * e[2]
  10526. },
  10527. multiply: function (e, t, r) {
  10528. var i = t[0]
  10529. , n = t[1]
  10530. , a = t[2]
  10531. , o = t[3]
  10532. , s = t[4]
  10533. , l = t[5]
  10534. , h = r[0]
  10535. , u = r[1]
  10536. , c = r[2]
  10537. , d = r[3]
  10538. , f = r[4]
  10539. , p = r[5];
  10540. return e[0] = i * h + a * u,
  10541. e[1] = n * h + o * u,
  10542. e[2] = i * c + a * d,
  10543. e[3] = n * c + o * d,
  10544. e[4] = i * f + a * p + s,
  10545. e[5] = n * f + o * p + l,
  10546. e
  10547. }
  10548. };
  10549. Un.mul = Un.multiply,
  10550. Un.rotate = function (e, t, r) {
  10551. var i = t[0]
  10552. , n = t[1]
  10553. , a = t[2]
  10554. , o = t[3]
  10555. , s = t[4]
  10556. , l = t[5]
  10557. , h = Math.sin(r)
  10558. , u = Math.cos(r);
  10559. return e[0] = i * u + a * h,
  10560. e[1] = n * u + o * h,
  10561. e[2] = i * -h + a * u,
  10562. e[3] = n * -h + o * u,
  10563. e[4] = s,
  10564. e[5] = l,
  10565. e
  10566. }
  10567. ,
  10568. Un.scale = function (e, t, r) {
  10569. var i = t[0]
  10570. , n = t[1]
  10571. , a = t[2]
  10572. , o = t[3]
  10573. , s = t[4]
  10574. , l = t[5]
  10575. , h = r[0]
  10576. , u = r[1];
  10577. return e[0] = i * h,
  10578. e[1] = n * h,
  10579. e[2] = a * u,
  10580. e[3] = o * u,
  10581. e[4] = s,
  10582. e[5] = l,
  10583. e
  10584. }
  10585. ,
  10586. Un.translate = function (e, t, r) {
  10587. var i = t[0]
  10588. , n = t[1]
  10589. , a = t[2]
  10590. , o = t[3]
  10591. , s = t[4]
  10592. , l = t[5]
  10593. , h = r[0]
  10594. , u = r[1];
  10595. return e[0] = i,
  10596. e[1] = n,
  10597. e[2] = a,
  10598. e[3] = o,
  10599. e[4] = i * h + a * u + s,
  10600. e[5] = n * h + o * u + l,
  10601. e
  10602. }
  10603. ,
  10604. Un.frob = function (e) {
  10605. return Math.sqrt(Math.pow(e[0], 2) + Math.pow(e[1], 2) + Math.pow(e[2], 2) + Math.pow(e[3], 2) + Math.pow(e[4], 2) + Math.pow(e[5], 2) + 1)
  10606. }
  10607. ;
  10608. const kn = Un;
  10609. var Vn = function () {
  10610. this.array = kn.create(),
  10611. this._dirty = !0
  10612. };
  10613. Vn.prototype = {
  10614. constructor: Vn,
  10615. setArray: function (e) {
  10616. for (var t = 0; t < this.array.length; t++)
  10617. this.array[t] = e[t];
  10618. return this._dirty = !0,
  10619. this
  10620. },
  10621. clone: function () {
  10622. return (new Vn).copy(this)
  10623. },
  10624. copy: function (e) {
  10625. return kn.copy(this.array, e.array),
  10626. this._dirty = !0,
  10627. this
  10628. },
  10629. determinant: function () {
  10630. return kn.determinant(this.array)
  10631. },
  10632. identity: function () {
  10633. return kn.identity(this.array),
  10634. this._dirty = !0,
  10635. this
  10636. },
  10637. invert: function () {
  10638. return kn.invert(this.array, this.array),
  10639. this._dirty = !0,
  10640. this
  10641. },
  10642. mul: function (e) {
  10643. return kn.mul(this.array, this.array, e.array),
  10644. this._dirty = !0,
  10645. this
  10646. },
  10647. mulLeft: function (e) {
  10648. return kn.mul(this.array, e.array, this.array),
  10649. this._dirty = !0,
  10650. this
  10651. },
  10652. multiply: function (e) {
  10653. return kn.multiply(this.array, this.array, e.array),
  10654. this._dirty = !0,
  10655. this
  10656. },
  10657. multiplyLeft: function (e) {
  10658. return kn.multiply(this.array, e.array, this.array),
  10659. this._dirty = !0,
  10660. this
  10661. },
  10662. rotate: function (e) {
  10663. return kn.rotate(this.array, this.array, e),
  10664. this._dirty = !0,
  10665. this
  10666. },
  10667. scale: function (e) {
  10668. return kn.scale(this.array, this.array, e.array),
  10669. this._dirty = !0,
  10670. this
  10671. },
  10672. translate: function (e) {
  10673. return kn.translate(this.array, this.array, e.array),
  10674. this._dirty = !0,
  10675. this
  10676. },
  10677. toString: function () {
  10678. return "[" + Array.prototype.join.call(this.array, ",") + "]"
  10679. },
  10680. toArray: function () {
  10681. return Array.prototype.slice.call(this.array)
  10682. }
  10683. },
  10684. Vn.copy = function (e, t) {
  10685. return kn.copy(e.array, t.array),
  10686. e._dirty = !0,
  10687. e
  10688. }
  10689. ,
  10690. Vn.determinant = function (e) {
  10691. return kn.determinant(e.array)
  10692. }
  10693. ,
  10694. Vn.identity = function (e) {
  10695. return kn.identity(e.array),
  10696. e._dirty = !0,
  10697. e
  10698. }
  10699. ,
  10700. Vn.invert = function (e, t) {
  10701. return kn.invert(e.array, t.array),
  10702. e._dirty = !0,
  10703. e
  10704. }
  10705. ,
  10706. Vn.multiply = Vn.mul = function (e, t, r) {
  10707. return kn.mul(e.array, t.array, r.array),
  10708. e._dirty = !0,
  10709. e
  10710. }
  10711. ,
  10712. Vn.rotate = function (e, t, r) {
  10713. return kn.rotate(e.array, t.array, r),
  10714. e._dirty = !0,
  10715. e
  10716. }
  10717. ,
  10718. Vn.scale = function (e, t, r) {
  10719. return kn.scale(e.array, t.array, r.array),
  10720. e._dirty = !0,
  10721. e
  10722. }
  10723. ,
  10724. Vn.translate = function (e, t, r) {
  10725. return kn.translate(e.array, t.array, r.array),
  10726. e._dirty = !0,
  10727. e
  10728. }
  10729. ;
  10730. const Hn = Vn;
  10731. var Wn = function () {
  10732. this.array = Dt.create(),
  10733. this._dirty = !0
  10734. };
  10735. Wn.prototype = {
  10736. constructor: Wn,
  10737. setArray: function (e) {
  10738. for (var t = 0; t < this.array.length; t++)
  10739. this.array[t] = e[t];
  10740. return this._dirty = !0,
  10741. this
  10742. },
  10743. adjoint: function () {
  10744. return Dt.adjoint(this.array, this.array),
  10745. this._dirty = !0,
  10746. this
  10747. },
  10748. clone: function () {
  10749. return (new Wn).copy(this)
  10750. },
  10751. copy: function (e) {
  10752. return Dt.copy(this.array, e.array),
  10753. this._dirty = !0,
  10754. this
  10755. },
  10756. determinant: function () {
  10757. return Dt.determinant(this.array)
  10758. },
  10759. fromMat2d: function (e) {
  10760. return Dt.fromMat2d(this.array, e.array),
  10761. this._dirty = !0,
  10762. this
  10763. },
  10764. fromMat4: function (e) {
  10765. return Dt.fromMat4(this.array, e.array),
  10766. this._dirty = !0,
  10767. this
  10768. },
  10769. fromQuat: function (e) {
  10770. return Dt.fromQuat(this.array, e.array),
  10771. this._dirty = !0,
  10772. this
  10773. },
  10774. identity: function () {
  10775. return Dt.identity(this.array),
  10776. this._dirty = !0,
  10777. this
  10778. },
  10779. invert: function () {
  10780. return Dt.invert(this.array, this.array),
  10781. this._dirty = !0,
  10782. this
  10783. },
  10784. mul: function (e) {
  10785. return Dt.mul(this.array, this.array, e.array),
  10786. this._dirty = !0,
  10787. this
  10788. },
  10789. mulLeft: function (e) {
  10790. return Dt.mul(this.array, e.array, this.array),
  10791. this._dirty = !0,
  10792. this
  10793. },
  10794. multiply: function (e) {
  10795. return Dt.multiply(this.array, this.array, e.array),
  10796. this._dirty = !0,
  10797. this
  10798. },
  10799. multiplyLeft: function (e) {
  10800. return Dt.multiply(this.array, e.array, this.array),
  10801. this._dirty = !0,
  10802. this
  10803. },
  10804. rotate: function (e) {
  10805. return Dt.rotate(this.array, this.array, e),
  10806. this._dirty = !0,
  10807. this
  10808. },
  10809. scale: function (e) {
  10810. return Dt.scale(this.array, this.array, e.array),
  10811. this._dirty = !0,
  10812. this
  10813. },
  10814. translate: function (e) {
  10815. return Dt.translate(this.array, this.array, e.array),
  10816. this._dirty = !0,
  10817. this
  10818. },
  10819. normalFromMat4: function (e) {
  10820. return Dt.normalFromMat4(this.array, e.array),
  10821. this._dirty = !0,
  10822. this
  10823. },
  10824. transpose: function () {
  10825. return Dt.transpose(this.array, this.array),
  10826. this._dirty = !0,
  10827. this
  10828. },
  10829. toString: function () {
  10830. return "[" + Array.prototype.join.call(this.array, ",") + "]"
  10831. },
  10832. toArray: function () {
  10833. return Array.prototype.slice.call(this.array)
  10834. }
  10835. },
  10836. Wn.adjoint = function (e, t) {
  10837. return Dt.adjoint(e.array, t.array),
  10838. e._dirty = !0,
  10839. e
  10840. }
  10841. ,
  10842. Wn.copy = function (e, t) {
  10843. return Dt.copy(e.array, t.array),
  10844. e._dirty = !0,
  10845. e
  10846. }
  10847. ,
  10848. Wn.determinant = function (e) {
  10849. return Dt.determinant(e.array)
  10850. }
  10851. ,
  10852. Wn.identity = function (e) {
  10853. return Dt.identity(e.array),
  10854. e._dirty = !0,
  10855. e
  10856. }
  10857. ,
  10858. Wn.invert = function (e, t) {
  10859. return Dt.invert(e.array, t.array),
  10860. e
  10861. }
  10862. ,
  10863. Wn.multiply = Wn.mul = function (e, t, r) {
  10864. return Dt.mul(e.array, t.array, r.array),
  10865. e._dirty = !0,
  10866. e
  10867. }
  10868. ,
  10869. Wn.fromMat2d = function (e, t) {
  10870. return Dt.fromMat2d(e.array, t.array),
  10871. e._dirty = !0,
  10872. e
  10873. }
  10874. ,
  10875. Wn.fromMat4 = function (e, t) {
  10876. return Dt.fromMat4(e.array, t.array),
  10877. e._dirty = !0,
  10878. e
  10879. }
  10880. ,
  10881. Wn.fromQuat = function (e, t) {
  10882. return Dt.fromQuat(e.array, t.array),
  10883. e._dirty = !0,
  10884. e
  10885. }
  10886. ,
  10887. Wn.normalFromMat4 = function (e, t) {
  10888. return Dt.normalFromMat4(e.array, t.array),
  10889. e._dirty = !0,
  10890. e
  10891. }
  10892. ,
  10893. Wn.rotate = function (e, t, r) {
  10894. return Dt.rotate(e.array, t.array, r),
  10895. e._dirty = !0,
  10896. e
  10897. }
  10898. ,
  10899. Wn.scale = function (e, t, r) {
  10900. return Dt.scale(e.array, t.array, r.array),
  10901. e._dirty = !0,
  10902. e
  10903. }
  10904. ,
  10905. Wn.transpose = function (e, t) {
  10906. return Dt.transpose(e.array, t.array),
  10907. e._dirty = !0,
  10908. e
  10909. }
  10910. ,
  10911. Wn.translate = function (e, t, r) {
  10912. return Dt.translate(e.array, t.array, r.array),
  10913. e._dirty = !0,
  10914. e
  10915. }
  10916. ;
  10917. const jn = Wn;
  10918. var Xn = {
  10919. linear: function (e) {
  10920. return e
  10921. },
  10922. quadraticIn: function (e) {
  10923. return e * e
  10924. },
  10925. quadraticOut: function (e) {
  10926. return e * (2 - e)
  10927. },
  10928. quadraticInOut: function (e) {
  10929. return (e *= 2) < 1 ? .5 * e * e : -.5 * (--e * (e - 2) - 1)
  10930. },
  10931. cubicIn: function (e) {
  10932. return e * e * e
  10933. },
  10934. cubicOut: function (e) {
  10935. return --e * e * e + 1
  10936. },
  10937. cubicInOut: function (e) {
  10938. return (e *= 2) < 1 ? .5 * e * e * e : .5 * ((e -= 2) * e * e + 2)
  10939. },
  10940. quarticIn: function (e) {
  10941. return e * e * e * e
  10942. },
  10943. quarticOut: function (e) {
  10944. return 1 - --e * e * e * e
  10945. },
  10946. quarticInOut: function (e) {
  10947. return (e *= 2) < 1 ? .5 * e * e * e * e : -.5 * ((e -= 2) * e * e * e - 2)
  10948. },
  10949. quinticIn: function (e) {
  10950. return e * e * e * e * e
  10951. },
  10952. quinticOut: function (e) {
  10953. return --e * e * e * e * e + 1
  10954. },
  10955. quinticInOut: function (e) {
  10956. return (e *= 2) < 1 ? .5 * e * e * e * e * e : .5 * ((e -= 2) * e * e * e * e + 2)
  10957. },
  10958. sinusoidalIn: function (e) {
  10959. return 1 - Math.cos(e * Math.PI / 2)
  10960. },
  10961. sinusoidalOut: function (e) {
  10962. return Math.sin(e * Math.PI / 2)
  10963. },
  10964. sinusoidalInOut: function (e) {
  10965. return .5 * (1 - Math.cos(Math.PI * e))
  10966. },
  10967. exponentialIn: function (e) {
  10968. return 0 === e ? 0 : Math.pow(1024, e - 1)
  10969. },
  10970. exponentialOut: function (e) {
  10971. return 1 === e ? 1 : 1 - Math.pow(2, -10 * e)
  10972. },
  10973. exponentialInOut: function (e) {
  10974. return 0 === e ? 0 : 1 === e ? 1 : (e *= 2) < 1 ? .5 * Math.pow(1024, e - 1) : .5 * (2 - Math.pow(2, -10 * (e - 1)))
  10975. },
  10976. circularIn: function (e) {
  10977. return 1 - Math.sqrt(1 - e * e)
  10978. },
  10979. circularOut: function (e) {
  10980. return Math.sqrt(1 - --e * e)
  10981. },
  10982. circularInOut: function (e) {
  10983. return (e *= 2) < 1 ? -.5 * (Math.sqrt(1 - e * e) - 1) : .5 * (Math.sqrt(1 - (e -= 2) * e) + 1)
  10984. },
  10985. elasticIn: function (e) {
  10986. var t, r = .1;
  10987. return 0 === e ? 0 : 1 === e ? 1 : (!r || r < 1 ? (r = 1,
  10988. t = .1) : t = .4 * Math.asin(1 / r) / (2 * Math.PI),
  10989. -r * Math.pow(2, 10 * (e -= 1)) * Math.sin((e - t) * (2 * Math.PI) / .4))
  10990. },
  10991. elasticOut: function (e) {
  10992. var t, r = .1;
  10993. return 0 === e ? 0 : 1 === e ? 1 : (!r || r < 1 ? (r = 1,
  10994. t = .1) : t = .4 * Math.asin(1 / r) / (2 * Math.PI),
  10995. r * Math.pow(2, -10 * e) * Math.sin((e - t) * (2 * Math.PI) / .4) + 1)
  10996. },
  10997. elasticInOut: function (e) {
  10998. var t, r = .1;
  10999. return 0 === e ? 0 : 1 === e ? 1 : (!r || r < 1 ? (r = 1,
  11000. t = .1) : t = .4 * Math.asin(1 / r) / (2 * Math.PI),
  11001. (e *= 2) < 1 ? r * Math.pow(2, 10 * (e -= 1)) * Math.sin((e - t) * (2 * Math.PI) / .4) * -.5 : r * Math.pow(2, -10 * (e -= 1)) * Math.sin((e - t) * (2 * Math.PI) / .4) * .5 + 1)
  11002. },
  11003. backIn: function (e) {
  11004. var t = 1.70158;
  11005. return e * e * ((t + 1) * e - t)
  11006. },
  11007. backOut: function (e) {
  11008. var t = 1.70158;
  11009. return --e * e * ((t + 1) * e + t) + 1
  11010. },
  11011. backInOut: function (e) {
  11012. var t = 2.5949095;
  11013. return (e *= 2) < 1 ? e * e * ((t + 1) * e - t) * .5 : .5 * ((e -= 2) * e * ((t + 1) * e + t) + 2)
  11014. },
  11015. bounceIn: function (e) {
  11016. return 1 - Xn.bounceOut(1 - e)
  11017. },
  11018. bounceOut: function (e) {
  11019. return e < 1 / 2.75 ? 7.5625 * e * e : e < 2 / 2.75 ? 7.5625 * (e -= 1.5 / 2.75) * e + .75 : e < 2.5 / 2.75 ? 7.5625 * (e -= 2.25 / 2.75) * e + .9375 : 7.5625 * (e -= 2.625 / 2.75) * e + .984375
  11020. },
  11021. bounceInOut: function (e) {
  11022. return e < .5 ? .5 * Xn.bounceIn(2 * e) : .5 * Xn.bounceOut(2 * e - 1) + .5
  11023. }
  11024. };
  11025. const qn = Xn
  11026. , Zn = function () {
  11027. function e(e) {
  11028. this._initialized = !1,
  11029. this._startTime = 0,
  11030. this._pausedTime = 0,
  11031. this._paused = !1,
  11032. this._life = e.life || 1e3,
  11033. this._delay = e.delay || 0,
  11034. this.loop = null != e.loop && e.loop,
  11035. this.gap = e.gap || 0,
  11036. this.easing = e.easing || "linear",
  11037. this.onframe = e.onframe,
  11038. this.ondestroy = e.ondestroy,
  11039. this.onrestart = e.onrestart
  11040. }
  11041. return e.prototype.step = function (e, t) {
  11042. if (this._initialized || (this._startTime = e + this._delay,
  11043. this._initialized = !0),
  11044. !this._paused) {
  11045. var r = (e - this._startTime - this._pausedTime) / this._life;
  11046. r < 0 && (r = 0),
  11047. r = Math.min(r, 1);
  11048. var i = this.easing
  11049. , n = "string" == typeof i ? qn[i] : i
  11050. , a = "function" == typeof n ? n(r) : r;
  11051. if (this.onframe && this.onframe(a),
  11052. 1 === r) {
  11053. if (!this.loop)
  11054. return !0;
  11055. this._restart(e),
  11056. this.onrestart && this.onrestart()
  11057. }
  11058. return !1
  11059. }
  11060. this._pausedTime += t
  11061. }
  11062. ,
  11063. e.prototype._restart = function (e) {
  11064. var t = (e - this._startTime - this._pausedTime) % this._life;
  11065. this._startTime = e - t + this.gap,
  11066. this._pausedTime = 0
  11067. }
  11068. ,
  11069. e.prototype.pause = function () {
  11070. this._paused = !0
  11071. }
  11072. ,
  11073. e.prototype.resume = function () {
  11074. this._paused = !1
  11075. }
  11076. ,
  11077. e
  11078. }();
  11079. var Yn = {
  11080. transparent: [0, 0, 0, 0],
  11081. aliceblue: [240, 248, 255, 1],
  11082. antiquewhite: [250, 235, 215, 1],
  11083. aqua: [0, 255, 255, 1],
  11084. aquamarine: [127, 255, 212, 1],
  11085. azure: [240, 255, 255, 1],
  11086. beige: [245, 245, 220, 1],
  11087. bisque: [255, 228, 196, 1],
  11088. black: [0, 0, 0, 1],
  11089. blanchedalmond: [255, 235, 205, 1],
  11090. blue: [0, 0, 255, 1],
  11091. blueviolet: [138, 43, 226, 1],
  11092. brown: [165, 42, 42, 1],
  11093. burlywood: [222, 184, 135, 1],
  11094. cadetblue: [95, 158, 160, 1],
  11095. chartreuse: [127, 255, 0, 1],
  11096. chocolate: [210, 105, 30, 1],
  11097. coral: [255, 127, 80, 1],
  11098. cornflowerblue: [100, 149, 237, 1],
  11099. cornsilk: [255, 248, 220, 1],
  11100. crimson: [220, 20, 60, 1],
  11101. cyan: [0, 255, 255, 1],
  11102. darkblue: [0, 0, 139, 1],
  11103. darkcyan: [0, 139, 139, 1],
  11104. darkgoldenrod: [184, 134, 11, 1],
  11105. darkgray: [169, 169, 169, 1],
  11106. darkgreen: [0, 100, 0, 1],
  11107. darkgrey: [169, 169, 169, 1],
  11108. darkkhaki: [189, 183, 107, 1],
  11109. darkmagenta: [139, 0, 139, 1],
  11110. darkolivegreen: [85, 107, 47, 1],
  11111. darkorange: [255, 140, 0, 1],
  11112. darkorchid: [153, 50, 204, 1],
  11113. darkred: [139, 0, 0, 1],
  11114. darksalmon: [233, 150, 122, 1],
  11115. darkseagreen: [143, 188, 143, 1],
  11116. darkslateblue: [72, 61, 139, 1],
  11117. darkslategray: [47, 79, 79, 1],
  11118. darkslategrey: [47, 79, 79, 1],
  11119. darkturquoise: [0, 206, 209, 1],
  11120. darkviolet: [148, 0, 211, 1],
  11121. deeppink: [255, 20, 147, 1],
  11122. deepskyblue: [0, 191, 255, 1],
  11123. dimgray: [105, 105, 105, 1],
  11124. dimgrey: [105, 105, 105, 1],
  11125. dodgerblue: [30, 144, 255, 1],
  11126. firebrick: [178, 34, 34, 1],
  11127. floralwhite: [255, 250, 240, 1],
  11128. forestgreen: [34, 139, 34, 1],
  11129. fuchsia: [255, 0, 255, 1],
  11130. gainsboro: [220, 220, 220, 1],
  11131. ghostwhite: [248, 248, 255, 1],
  11132. gold: [255, 215, 0, 1],
  11133. goldenrod: [218, 165, 32, 1],
  11134. gray: [128, 128, 128, 1],
  11135. green: [0, 128, 0, 1],
  11136. greenyellow: [173, 255, 47, 1],
  11137. grey: [128, 128, 128, 1],
  11138. honeydew: [240, 255, 240, 1],
  11139. hotpink: [255, 105, 180, 1],
  11140. indianred: [205, 92, 92, 1],
  11141. indigo: [75, 0, 130, 1],
  11142. ivory: [255, 255, 240, 1],
  11143. khaki: [240, 230, 140, 1],
  11144. lavender: [230, 230, 250, 1],
  11145. lavenderblush: [255, 240, 245, 1],
  11146. lawngreen: [124, 252, 0, 1],
  11147. lemonchiffon: [255, 250, 205, 1],
  11148. lightblue: [173, 216, 230, 1],
  11149. lightcoral: [240, 128, 128, 1],
  11150. lightcyan: [224, 255, 255, 1],
  11151. lightgoldenrodyellow: [250, 250, 210, 1],
  11152. lightgray: [211, 211, 211, 1],
  11153. lightgreen: [144, 238, 144, 1],
  11154. lightgrey: [211, 211, 211, 1],
  11155. lightpink: [255, 182, 193, 1],
  11156. lightsalmon: [255, 160, 122, 1],
  11157. lightseagreen: [32, 178, 170, 1],
  11158. lightskyblue: [135, 206, 250, 1],
  11159. lightslategray: [119, 136, 153, 1],
  11160. lightslategrey: [119, 136, 153, 1],
  11161. lightsteelblue: [176, 196, 222, 1],
  11162. lightyellow: [255, 255, 224, 1],
  11163. lime: [0, 255, 0, 1],
  11164. limegreen: [50, 205, 50, 1],
  11165. linen: [250, 240, 230, 1],
  11166. magenta: [255, 0, 255, 1],
  11167. maroon: [128, 0, 0, 1],
  11168. mediumaquamarine: [102, 205, 170, 1],
  11169. mediumblue: [0, 0, 205, 1],
  11170. mediumorchid: [186, 85, 211, 1],
  11171. mediumpurple: [147, 112, 219, 1],
  11172. mediumseagreen: [60, 179, 113, 1],
  11173. mediumslateblue: [123, 104, 238, 1],
  11174. mediumspringgreen: [0, 250, 154, 1],
  11175. mediumturquoise: [72, 209, 204, 1],
  11176. mediumvioletred: [199, 21, 133, 1],
  11177. midnightblue: [25, 25, 112, 1],
  11178. mintcream: [245, 255, 250, 1],
  11179. mistyrose: [255, 228, 225, 1],
  11180. moccasin: [255, 228, 181, 1],
  11181. navajowhite: [255, 222, 173, 1],
  11182. navy: [0, 0, 128, 1],
  11183. oldlace: [253, 245, 230, 1],
  11184. olive: [128, 128, 0, 1],
  11185. olivedrab: [107, 142, 35, 1],
  11186. orange: [255, 165, 0, 1],
  11187. orangered: [255, 69, 0, 1],
  11188. orchid: [218, 112, 214, 1],
  11189. palegoldenrod: [238, 232, 170, 1],
  11190. palegreen: [152, 251, 152, 1],
  11191. paleturquoise: [175, 238, 238, 1],
  11192. palevioletred: [219, 112, 147, 1],
  11193. papayawhip: [255, 239, 213, 1],
  11194. peachpuff: [255, 218, 185, 1],
  11195. peru: [205, 133, 63, 1],
  11196. pink: [255, 192, 203, 1],
  11197. plum: [221, 160, 221, 1],
  11198. powderblue: [176, 224, 230, 1],
  11199. purple: [128, 0, 128, 1],
  11200. red: [255, 0, 0, 1],
  11201. rosybrown: [188, 143, 143, 1],
  11202. royalblue: [65, 105, 225, 1],
  11203. saddlebrown: [139, 69, 19, 1],
  11204. salmon: [250, 128, 114, 1],
  11205. sandybrown: [244, 164, 96, 1],
  11206. seagreen: [46, 139, 87, 1],
  11207. seashell: [255, 245, 238, 1],
  11208. sienna: [160, 82, 45, 1],
  11209. silver: [192, 192, 192, 1],
  11210. skyblue: [135, 206, 235, 1],
  11211. slateblue: [106, 90, 205, 1],
  11212. slategray: [112, 128, 144, 1],
  11213. slategrey: [112, 128, 144, 1],
  11214. snow: [255, 250, 250, 1],
  11215. springgreen: [0, 255, 127, 1],
  11216. steelblue: [70, 130, 180, 1],
  11217. tan: [210, 180, 140, 1],
  11218. teal: [0, 128, 128, 1],
  11219. thistle: [216, 191, 216, 1],
  11220. tomato: [255, 99, 71, 1],
  11221. turquoise: [64, 224, 208, 1],
  11222. violet: [238, 130, 238, 1],
  11223. wheat: [245, 222, 179, 1],
  11224. white: [255, 255, 255, 1],
  11225. whitesmoke: [245, 245, 245, 1],
  11226. yellow: [255, 255, 0, 1],
  11227. yellowgreen: [154, 205, 50, 1]
  11228. };
  11229. function Kn(e) {
  11230. return (e = Math.round(e)) < 0 ? 0 : e > 255 ? 255 : e
  11231. }
  11232. function Qn(e) {
  11233. return e < 0 ? 0 : e > 1 ? 1 : e
  11234. }
  11235. function Jn(e) {
  11236. var t = e;
  11237. return t.length && "%" === t.charAt(t.length - 1) ? Kn(parseFloat(t) / 100 * 255) : Kn(parseInt(t, 10))
  11238. }
  11239. function $n(e) {
  11240. var t = e;
  11241. return t.length && "%" === t.charAt(t.length - 1) ? Qn(parseFloat(t) / 100) : Qn(parseFloat(t))
  11242. }
  11243. function ea(e, t, r) {
  11244. return r < 0 ? r += 1 : r > 1 && (r -= 1),
  11245. 6 * r < 1 ? e + (t - e) * r * 6 : 2 * r < 1 ? t : 3 * r < 2 ? e + (t - e) * (2 / 3 - r) * 6 : e
  11246. }
  11247. function ta(e, t, r, i, n) {
  11248. return e[0] = t,
  11249. e[1] = r,
  11250. e[2] = i,
  11251. e[3] = n,
  11252. e
  11253. }
  11254. function ra(e, t) {
  11255. return e[0] = t[0],
  11256. e[1] = t[1],
  11257. e[2] = t[2],
  11258. e[3] = t[3],
  11259. e
  11260. }
  11261. var ia = new bi(20)
  11262. , na = null;
  11263. function aa(e, t) {
  11264. na && ra(na, t),
  11265. na = ia.put(e, na || t.slice())
  11266. }
  11267. function oa(e, t) {
  11268. if (e) {
  11269. t = t || [];
  11270. var r = ia.get(e);
  11271. if (r)
  11272. return ra(t, r);
  11273. var i = (e += "").replace(/ /g, "").toLowerCase();
  11274. if (i in Yn)
  11275. return ra(t, Yn[i]),
  11276. aa(e, t),
  11277. t;
  11278. var n, a = i.length;
  11279. if ("#" === i.charAt(0))
  11280. return 4 === a || 5 === a ? (n = parseInt(i.slice(1, 4), 16)) >= 0 && n <= 4095 ? (ta(t, (3840 & n) >> 4 | (3840 & n) >> 8, 240 & n | (240 & n) >> 4, 15 & n | (15 & n) << 4, 5 === a ? parseInt(i.slice(4), 16) / 15 : 1),
  11281. aa(e, t),
  11282. t) : void ta(t, 0, 0, 0, 1) : 7 === a || 9 === a ? (n = parseInt(i.slice(1, 7), 16)) >= 0 && n <= 16777215 ? (ta(t, (16711680 & n) >> 16, (65280 & n) >> 8, 255 & n, 9 === a ? parseInt(i.slice(7), 16) / 255 : 1),
  11283. aa(e, t),
  11284. t) : void ta(t, 0, 0, 0, 1) : void 0;
  11285. var o = i.indexOf("(")
  11286. , s = i.indexOf(")");
  11287. if (-1 !== o && s + 1 === a) {
  11288. var l = i.substr(0, o)
  11289. , h = i.substr(o + 1, s - (o + 1)).split(",")
  11290. , u = 1;
  11291. switch (l) {
  11292. case "rgba":
  11293. if (4 !== h.length)
  11294. return 3 === h.length ? ta(t, +h[0], +h[1], +h[2], 1) : ta(t, 0, 0, 0, 1);
  11295. u = $n(h.pop());
  11296. case "rgb":
  11297. return 3 !== h.length ? void ta(t, 0, 0, 0, 1) : (ta(t, Jn(h[0]), Jn(h[1]), Jn(h[2]), u),
  11298. aa(e, t),
  11299. t);
  11300. case "hsla":
  11301. return 4 !== h.length ? void ta(t, 0, 0, 0, 1) : (h[3] = $n(h[3]),
  11302. sa(h, t),
  11303. aa(e, t),
  11304. t);
  11305. case "hsl":
  11306. return 3 !== h.length ? void ta(t, 0, 0, 0, 1) : (sa(h, t),
  11307. aa(e, t),
  11308. t);
  11309. default:
  11310. return
  11311. }
  11312. }
  11313. ta(t, 0, 0, 0, 1)
  11314. }
  11315. }
  11316. function sa(e, t) {
  11317. var r = (parseFloat(e[0]) % 360 + 360) % 360 / 360
  11318. , i = $n(e[1])
  11319. , n = $n(e[2])
  11320. , a = n <= .5 ? n * (i + 1) : n + i - n * i
  11321. , o = 2 * n - a;
  11322. return ta(t = t || [], Kn(255 * ea(o, a, r + 1 / 3)), Kn(255 * ea(o, a, r)), Kn(255 * ea(o, a, r - 1 / 3)), 1),
  11323. 4 === e.length && (t[3] = e[3]),
  11324. t
  11325. }
  11326. var la = Object.prototype.toString
  11327. , ha = Array.prototype
  11328. , ua = ha.forEach
  11329. , ca = ha.filter
  11330. , da = ha.slice
  11331. , fa = ha.map
  11332. , pa = function () { }
  11333. .constructor
  11334. , ma = pa ? pa.prototype : null;
  11335. function ga(e, t) {
  11336. if (Object.assign)
  11337. Object.assign(e, t);
  11338. else
  11339. for (var r in t)
  11340. t.hasOwnProperty(r) && (e[r] = t[r]);
  11341. return e
  11342. }
  11343. function _a(e, t, r) {
  11344. if (e = "prototype" in e ? e.prototype : e,
  11345. t = "prototype" in t ? t.prototype : t,
  11346. Object.getOwnPropertyNames)
  11347. for (var i = Object.getOwnPropertyNames(t), n = 0; n < i.length; n++) {
  11348. var a = i[n];
  11349. "constructor" !== a && (r ? null != t[a] : null == e[a]) && (e[a] = t[a])
  11350. }
  11351. else
  11352. !function (e, t, r) {
  11353. for (var i = ba(t), n = 0; n < i.length; n++) {
  11354. var a = i[n];
  11355. (r ? null != t[a] : null == e[a]) && (e[a] = t[a])
  11356. }
  11357. }(e, t, r)
  11358. }
  11359. function va(e) {
  11360. return !!e && "string" != typeof e && "number" == typeof e.length
  11361. }
  11362. function ya(e, t, r) {
  11363. if (e && t)
  11364. if (e.forEach && e.forEach === ua)
  11365. e.forEach(t, r);
  11366. else if (e.length === +e.length)
  11367. for (var i = 0, n = e.length; i < n; i++)
  11368. t.call(r, e[i], i, e);
  11369. else
  11370. for (var a in e)
  11371. e.hasOwnProperty(a) && t.call(r, e[a], a, e)
  11372. }
  11373. function xa(e, t, r) {
  11374. if (!e)
  11375. return [];
  11376. if (!t)
  11377. return Sa(e);
  11378. if (e.map && e.map === fa)
  11379. return e.map(t, r);
  11380. for (var i = [], n = 0, a = e.length; n < a; n++)
  11381. i.push(t.call(r, e[n], n, e));
  11382. return i
  11383. }
  11384. function ba(e) {
  11385. if (!e)
  11386. return [];
  11387. if (Object.keys)
  11388. return Object.keys(e);
  11389. var t = [];
  11390. for (var r in e)
  11391. e.hasOwnProperty(r) && t.push(r);
  11392. return t
  11393. }
  11394. function wa(e) {
  11395. for (var t = [], r = 1; r < arguments.length; r++)
  11396. t[r - 1] = arguments[r];
  11397. return function () {
  11398. return e.apply(this, t.concat(da.call(arguments)))
  11399. }
  11400. }
  11401. function Ta(e, t) {
  11402. return null != e ? e : t
  11403. }
  11404. function Sa(e) {
  11405. for (var t = [], r = 1; r < arguments.length; r++)
  11406. t[r - 1] = arguments[r];
  11407. return da.apply(e, t)
  11408. }
  11409. ma && "function" == typeof ma.bind && ma.call.bind(ma.bind);
  11410. var Ma = function () {
  11411. function e(t) {
  11412. this.data = {};
  11413. var r, i = (r = t,
  11414. Array.isArray ? Array.isArray(r) : "[object Array]" === la.call(r));
  11415. this.data = {};
  11416. var n = this;
  11417. function a(e, t) {
  11418. i ? n.set(e, t) : n.set(t, e)
  11419. }
  11420. t instanceof e ? t.each(a) : t && ya(t, a)
  11421. }
  11422. return e.prototype.get = function (e) {
  11423. return this.data.hasOwnProperty(e) ? this.data[e] : null
  11424. }
  11425. ,
  11426. e.prototype.set = function (e, t) {
  11427. return this.data[e] = t
  11428. }
  11429. ,
  11430. e.prototype.each = function (e, t) {
  11431. for (var r in this.data)
  11432. this.data.hasOwnProperty(r) && e.call(t, this.data[r], r)
  11433. }
  11434. ,
  11435. e.prototype.keys = function () {
  11436. return ba(this.data)
  11437. }
  11438. ,
  11439. e.prototype.removeKey = function (e) {
  11440. delete this.data[e]
  11441. }
  11442. ,
  11443. e
  11444. }();
  11445. function Aa(e, t) {
  11446. for (var r = new e.constructor(e.length + t.length), i = 0; i < e.length; i++)
  11447. r[i] = e[i];
  11448. var n = e.length;
  11449. for (i = 0; i < t.length; i++)
  11450. r[i + n] = t[i];
  11451. return r
  11452. }
  11453. var Ea = Array.prototype.slice;
  11454. function Ca(e, t, r) {
  11455. return (t - e) * r + e
  11456. }
  11457. function Da(e, t, r, i) {
  11458. for (var n = t.length, a = 0; a < n; a++)
  11459. e[a] = Ca(t[a], r[a], i)
  11460. }
  11461. function La(e, t, r, i) {
  11462. for (var n = t.length, a = 0; a < n; a++)
  11463. e[a] = t[a] + r[a] * i;
  11464. return e
  11465. }
  11466. function Pa(e, t, r, i) {
  11467. for (var n = t.length, a = n && t[0].length, o = 0; o < n; o++) {
  11468. e[o] || (e[o] = []);
  11469. for (var s = 0; s < a; s++)
  11470. e[o][s] = t[o][s] + r[o][s] * i
  11471. }
  11472. return e
  11473. }
  11474. function Oa(e, t, r) {
  11475. var i = e
  11476. , n = t;
  11477. if (i.push && n.push) {
  11478. var a = i.length
  11479. , o = n.length;
  11480. if (a !== o)
  11481. if (a > o)
  11482. i.length = o;
  11483. else
  11484. for (var s = a; s < o; s++)
  11485. i.push(1 === r ? n[s] : Ea.call(n[s]));
  11486. var l = i[0] && i[0].length;
  11487. for (s = 0; s < i.length; s++)
  11488. if (1 === r)
  11489. isNaN(i[s]) && (i[s] = n[s]);
  11490. else
  11491. for (var h = 0; h < l; h++)
  11492. isNaN(i[s][h]) && (i[s][h] = n[s][h])
  11493. }
  11494. }
  11495. function Na(e, t) {
  11496. var r = e.length;
  11497. if (r !== t.length)
  11498. return !1;
  11499. for (var i = 0; i < r; i++)
  11500. if (e[i] !== t[i])
  11501. return !1;
  11502. return !0
  11503. }
  11504. function Ia(e, t, r, i, n, a, o) {
  11505. var s = .5 * (r - e)
  11506. , l = .5 * (i - t);
  11507. return (2 * (t - r) + s + l) * o + (-3 * (t - r) - 2 * s - l) * a + s * n + t
  11508. }
  11509. function Ra(e, t, r, i, n, a, o, s) {
  11510. for (var l = t.length, h = 0; h < l; h++)
  11511. e[h] = Ia(t[h], r[h], i[h], n[h], a, o, s)
  11512. }
  11513. function Ba(e) {
  11514. if (va(e)) {
  11515. var t = e.length;
  11516. if (va(e[0])) {
  11517. for (var r = [], i = 0; i < t; i++)
  11518. r.push(Ea.call(e[i]));
  11519. return r
  11520. }
  11521. return Ea.call(e)
  11522. }
  11523. return e
  11524. }
  11525. function Fa(e) {
  11526. return e[0] = Math.floor(e[0]),
  11527. e[1] = Math.floor(e[1]),
  11528. e[2] = Math.floor(e[2]),
  11529. "rgba(" + e.join(",") + ")"
  11530. }
  11531. var za = [0, 0, 0, 0]
  11532. , Ga = function () {
  11533. function e(e) {
  11534. this.keyframes = [],
  11535. this.maxTime = 0,
  11536. this.arrDim = 0,
  11537. this.interpolable = !0,
  11538. this._needsSort = !1,
  11539. this._isAllValueEqual = !0,
  11540. this._lastFrame = 0,
  11541. this._lastFramePercent = 0,
  11542. this.propName = e
  11543. }
  11544. return e.prototype.isFinished = function () {
  11545. return this._finished
  11546. }
  11547. ,
  11548. e.prototype.setFinished = function () {
  11549. this._finished = !0,
  11550. this._additiveTrack && this._additiveTrack.setFinished()
  11551. }
  11552. ,
  11553. e.prototype.needsAnimate = function () {
  11554. return !this._isAllValueEqual && this.keyframes.length >= 2 && this.interpolable
  11555. }
  11556. ,
  11557. e.prototype.getAdditiveTrack = function () {
  11558. return this._additiveTrack
  11559. }
  11560. ,
  11561. e.prototype.addKeyframe = function (e, t) {
  11562. e >= this.maxTime ? this.maxTime = e : this._needsSort = !0;
  11563. var r = this.keyframes
  11564. , i = r.length;
  11565. if (this.interpolable)
  11566. if (va(t)) {
  11567. var n = function (e) {
  11568. return va(e && e[0]) ? 2 : 1
  11569. }(t);
  11570. if (i > 0 && this.arrDim !== n)
  11571. return void (this.interpolable = !1);
  11572. if (1 === n && "number" != typeof t[0] || 2 === n && "number" != typeof t[0][0])
  11573. return void (this.interpolable = !1);
  11574. if (i > 0) {
  11575. var a = r[i - 1];
  11576. this._isAllValueEqual && (1 === n && Na(t, a.value) || (this._isAllValueEqual = !1))
  11577. }
  11578. this.arrDim = n
  11579. } else {
  11580. if (this.arrDim > 0)
  11581. return void (this.interpolable = !1);
  11582. if ("string" == typeof t) {
  11583. var o = oa(t);
  11584. o ? (t = o,
  11585. this.isValueColor = !0) : this.interpolable = !1
  11586. } else if ("number" != typeof t || isNaN(t))
  11587. return void (this.interpolable = !1);
  11588. this._isAllValueEqual && i > 0 && (a = r[i - 1],
  11589. (this.isValueColor && !Na(a.value, t) || a.value !== t) && (this._isAllValueEqual = !1))
  11590. }
  11591. var s = {
  11592. time: e,
  11593. value: t,
  11594. percent: 0
  11595. };
  11596. return this.keyframes.push(s),
  11597. s
  11598. }
  11599. ,
  11600. e.prototype.prepare = function (e) {
  11601. var t = this.keyframes;
  11602. this._needsSort && t.sort((function (e, t) {
  11603. return e.time - t.time
  11604. }
  11605. ));
  11606. for (var r = this.arrDim, i = t.length, n = t[i - 1], a = 0; a < i; a++)
  11607. t[a].percent = t[a].time / this.maxTime,
  11608. r > 0 && a !== i - 1 && Oa(t[a].value, n.value, r);
  11609. if (e && this.needsAnimate() && e.needsAnimate() && r === e.arrDim && this.isValueColor === e.isValueColor && !e._finished) {
  11610. this._additiveTrack = e;
  11611. var o = t[0].value;
  11612. for (a = 0; a < i; a++)
  11613. 0 === r ? this.isValueColor ? t[a].additiveValue = La([], t[a].value, o, -1) : t[a].additiveValue = t[a].value - o : 1 === r ? t[a].additiveValue = La([], t[a].value, o, -1) : 2 === r && (t[a].additiveValue = Pa([], t[a].value, o, -1))
  11614. }
  11615. }
  11616. ,
  11617. e.prototype.step = function (e, t) {
  11618. if (!this._finished) {
  11619. this._additiveTrack && this._additiveTrack._finished && (this._additiveTrack = null);
  11620. var r, i = null != this._additiveTrack, n = i ? "additiveValue" : "value", a = this.keyframes, o = this.keyframes.length, s = this.propName, l = this.arrDim, h = this.isValueColor;
  11621. if (t < 0)
  11622. r = 0;
  11623. else if (t < this._lastFramePercent) {
  11624. for (r = Math.min(this._lastFrame + 1, o - 1); r >= 0 && !(a[r].percent <= t); r--)
  11625. ;
  11626. r = Math.min(r, o - 2)
  11627. } else {
  11628. for (r = this._lastFrame; r < o && !(a[r].percent > t); r++)
  11629. ;
  11630. r = Math.min(r - 1, o - 2)
  11631. }
  11632. var u = a[r + 1]
  11633. , c = a[r];
  11634. if (c && u) {
  11635. this._lastFrame = r,
  11636. this._lastFramePercent = t;
  11637. var d = u.percent - c.percent;
  11638. if (0 !== d) {
  11639. var f = (t - c.percent) / d
  11640. , p = i ? this._additiveValue : h ? za : e[s];
  11641. if ((l > 0 || h) && !p && (p = this._additiveValue = []),
  11642. this.useSpline) {
  11643. var m = a[r][n]
  11644. , g = a[0 === r ? r : r - 1][n]
  11645. , _ = a[r > o - 2 ? o - 1 : r + 1][n]
  11646. , v = a[r > o - 3 ? o - 1 : r + 2][n];
  11647. if (l > 0)
  11648. 1 === l ? Ra(p, g, m, _, v, f, f * f, f * f * f) : function (e, t, r, i, n, a, o, s) {
  11649. for (var l = t.length, h = t[0].length, u = 0; u < l; u++) {
  11650. e[u] || (e[1] = []);
  11651. for (var c = 0; c < h; c++)
  11652. e[u][c] = Ia(t[u][c], r[u][c], i[u][c], n[u][c], a, o, s)
  11653. }
  11654. }(p, g, m, _, v, f, f * f, f * f * f);
  11655. else if (h)
  11656. Ra(p, g, m, _, v, f, f * f, f * f * f),
  11657. i || (e[s] = Fa(p));
  11658. else {
  11659. var y = void 0;
  11660. y = this.interpolable ? Ia(g, m, _, v, f, f * f, f * f * f) : _,
  11661. i ? this._additiveValue = y : e[s] = y
  11662. }
  11663. } else
  11664. l > 0 ? 1 === l ? Da(p, c[n], u[n], f) : function (e, t, r, i) {
  11665. for (var n = t.length, a = n && t[0].length, o = 0; o < n; o++) {
  11666. e[o] || (e[o] = []);
  11667. for (var s = 0; s < a; s++)
  11668. e[o][s] = Ca(t[o][s], r[o][s], i)
  11669. }
  11670. }(p, c[n], u[n], f) : h ? (Da(p, c[n], u[n], f),
  11671. i || (e[s] = Fa(p))) : (y = void 0,
  11672. y = this.interpolable ? Ca(c[n], u[n], f) : function (e, t, r) {
  11673. return r > .5 ? t : e
  11674. }(c[n], u[n], f),
  11675. i ? this._additiveValue = y : e[s] = y);
  11676. i && this._addToTarget(e)
  11677. }
  11678. }
  11679. }
  11680. }
  11681. ,
  11682. e.prototype._addToTarget = function (e) {
  11683. var t = this.arrDim
  11684. , r = this.propName
  11685. , i = this._additiveValue;
  11686. 0 === t ? this.isValueColor ? (oa(e[r], za),
  11687. La(za, za, i, 1),
  11688. e[r] = Fa(za)) : e[r] = e[r] + i : 1 === t ? La(e[r], e[r], i, 1) : 2 === t && Pa(e[r], e[r], i, 1)
  11689. }
  11690. ,
  11691. e
  11692. }();
  11693. const Ua = function () {
  11694. function e(e, t, r) {
  11695. this._tracks = {},
  11696. this._trackKeys = [],
  11697. this._delay = 0,
  11698. this._maxTime = 0,
  11699. this._paused = !1,
  11700. this._started = 0,
  11701. this._clip = null,
  11702. this._target = e,
  11703. this._loop = t,
  11704. t && r ? function () {
  11705. for (var e = [], t = 0; t < arguments.length; t++)
  11706. e[t] = arguments[t];
  11707. "undefined" != typeof console && console.error.apply(console, e)
  11708. }("Can' use additive animation on looped animation.") : this._additiveAnimators = r
  11709. }
  11710. return e.prototype.getTarget = function () {
  11711. return this._target
  11712. }
  11713. ,
  11714. e.prototype.changeTarget = function (e) {
  11715. this._target = e
  11716. }
  11717. ,
  11718. e.prototype.when = function (e, t) {
  11719. return this.whenWithKeys(e, t, ba(t))
  11720. }
  11721. ,
  11722. e.prototype.whenWithKeys = function (e, t, r) {
  11723. for (var i = this._tracks, n = 0; n < r.length; n++) {
  11724. var a = r[n]
  11725. , o = i[a];
  11726. if (!o) {
  11727. o = i[a] = new Ga(a);
  11728. var s = void 0
  11729. , l = this._getAdditiveTrack(a);
  11730. if (l) {
  11731. var h = l.keyframes[l.keyframes.length - 1];
  11732. s = h && h.value,
  11733. l.isValueColor && s && (s = Fa(s))
  11734. } else
  11735. s = this._target[a];
  11736. if (null == s)
  11737. continue;
  11738. 0 !== e && o.addKeyframe(0, Ba(s)),
  11739. this._trackKeys.push(a)
  11740. }
  11741. o.addKeyframe(e, Ba(t[a]))
  11742. }
  11743. return this._maxTime = Math.max(this._maxTime, e),
  11744. this
  11745. }
  11746. ,
  11747. e.prototype.pause = function () {
  11748. this._clip.pause(),
  11749. this._paused = !0
  11750. }
  11751. ,
  11752. e.prototype.resume = function () {
  11753. this._clip.resume(),
  11754. this._paused = !1
  11755. }
  11756. ,
  11757. e.prototype.isPaused = function () {
  11758. return !!this._paused
  11759. }
  11760. ,
  11761. e.prototype._doneCallback = function () {
  11762. this._setTracksFinished(),
  11763. this._clip = null;
  11764. var e = this._doneList;
  11765. if (e)
  11766. for (var t = e.length, r = 0; r < t; r++)
  11767. e[r].call(this)
  11768. }
  11769. ,
  11770. e.prototype._abortedCallback = function () {
  11771. this._setTracksFinished();
  11772. var e = this.animation
  11773. , t = this._abortedList;
  11774. if (e && e.removeClip(this._clip),
  11775. this._clip = null,
  11776. t)
  11777. for (var r = 0; r < t.length; r++)
  11778. t[r].call(this)
  11779. }
  11780. ,
  11781. e.prototype._setTracksFinished = function () {
  11782. for (var e = this._tracks, t = this._trackKeys, r = 0; r < t.length; r++)
  11783. e[t[r]].setFinished()
  11784. }
  11785. ,
  11786. e.prototype._getAdditiveTrack = function (e) {
  11787. var t, r = this._additiveAnimators;
  11788. if (r)
  11789. for (var i = 0; i < r.length; i++) {
  11790. var n = r[i].getTrack(e);
  11791. n && (t = n)
  11792. }
  11793. return t
  11794. }
  11795. ,
  11796. e.prototype.start = function (e, t) {
  11797. if (!(this._started > 0)) {
  11798. this._started = 1;
  11799. for (var r = this, i = [], n = 0; n < this._trackKeys.length; n++) {
  11800. var a = this._trackKeys[n]
  11801. , o = this._tracks[a]
  11802. , s = this._getAdditiveTrack(a)
  11803. , l = o.keyframes;
  11804. if (o.prepare(s),
  11805. o.needsAnimate())
  11806. i.push(o);
  11807. else if (!o.interpolable) {
  11808. var h = l[l.length - 1];
  11809. h && (r._target[o.propName] = h.value)
  11810. }
  11811. }
  11812. if (i.length || t) {
  11813. var u = new Zn({
  11814. life: this._maxTime,
  11815. loop: this._loop,
  11816. delay: this._delay,
  11817. onframe: function (e) {
  11818. r._started = 2;
  11819. var t = r._additiveAnimators;
  11820. if (t) {
  11821. for (var n = !1, a = 0; a < t.length; a++)
  11822. if (t[a]._clip) {
  11823. n = !0;
  11824. break
  11825. }
  11826. n || (r._additiveAnimators = null)
  11827. }
  11828. for (a = 0; a < i.length; a++)
  11829. i[a].step(r._target, e);
  11830. var o = r._onframeList;
  11831. if (o)
  11832. for (a = 0; a < o.length; a++)
  11833. o[a](r._target, e)
  11834. },
  11835. ondestroy: function () {
  11836. r._doneCallback()
  11837. }
  11838. });
  11839. this._clip = u,
  11840. this.animation && this.animation.addClip(u),
  11841. e && "spline" !== e && (u.easing = e)
  11842. } else
  11843. this._doneCallback();
  11844. return this
  11845. }
  11846. }
  11847. ,
  11848. e.prototype.stop = function (e) {
  11849. if (this._clip) {
  11850. var t = this._clip;
  11851. e && t.onframe(1),
  11852. this._abortedCallback()
  11853. }
  11854. }
  11855. ,
  11856. e.prototype.delay = function (e) {
  11857. return this._delay = e,
  11858. this
  11859. }
  11860. ,
  11861. e.prototype.during = function (e) {
  11862. return e && (this._onframeList || (this._onframeList = []),
  11863. this._onframeList.push(e)),
  11864. this
  11865. }
  11866. ,
  11867. e.prototype.done = function (e) {
  11868. return e && (this._doneList || (this._doneList = []),
  11869. this._doneList.push(e)),
  11870. this
  11871. }
  11872. ,
  11873. e.prototype.aborted = function (e) {
  11874. return e && (this._abortedList || (this._abortedList = []),
  11875. this._abortedList.push(e)),
  11876. this
  11877. }
  11878. ,
  11879. e.prototype.getClip = function () {
  11880. return this._clip
  11881. }
  11882. ,
  11883. e.prototype.getTrack = function (e) {
  11884. return this._tracks[e]
  11885. }
  11886. ,
  11887. e.prototype.stopTracks = function (e, t) {
  11888. if (!e.length || !this._clip)
  11889. return !0;
  11890. for (var r = this._tracks, i = this._trackKeys, n = 0; n < e.length; n++) {
  11891. var a = r[e[n]];
  11892. a && (t ? a.step(this._target, 1) : 1 === this._started && a.step(this._target, 0),
  11893. a.setFinished())
  11894. }
  11895. var o = !0;
  11896. for (n = 0; n < i.length; n++)
  11897. if (!r[i[n]].isFinished()) {
  11898. o = !1;
  11899. break
  11900. }
  11901. return o && this._abortedCallback(),
  11902. o
  11903. }
  11904. ,
  11905. e.prototype.saveFinalToTarget = function (e, t) {
  11906. if (e) {
  11907. t = t || this._trackKeys;
  11908. for (var r = 0; r < t.length; r++) {
  11909. var i = t[r]
  11910. , n = this._tracks[i];
  11911. if (n && !n.isFinished()) {
  11912. var a = n.keyframes
  11913. , o = a[a.length - 1];
  11914. if (o) {
  11915. var s = Ba(o.value);
  11916. n.isValueColor && (s = Fa(s)),
  11917. e[i] = s
  11918. }
  11919. }
  11920. }
  11921. }
  11922. }
  11923. ,
  11924. e.prototype.__changeFinalValue = function (e, t) {
  11925. t = t || ba(e);
  11926. for (var r = 0; r < t.length; r++) {
  11927. var i = t[r]
  11928. , n = this._tracks[i];
  11929. if (n) {
  11930. var a = n.keyframes;
  11931. if (a.length > 1) {
  11932. var o = a.pop();
  11933. n.addKeyframe(o.time, e[i]),
  11934. n.prepare(n.getAdditiveTrack())
  11935. }
  11936. }
  11937. }
  11938. }
  11939. ,
  11940. e
  11941. }()
  11942. , ka = {
  11943. _animators: null,
  11944. getAnimators: function () {
  11945. return this._animators = this._animators || [],
  11946. this._animators
  11947. },
  11948. animate: function (e, t) {
  11949. var r;
  11950. if (this._animators = this._animators || [],
  11951. e) {
  11952. for (var i = e.split("."), n = this, a = 0, o = i.length; a < o; a++)
  11953. n && (n = n[i[a]]);
  11954. n && (r = n)
  11955. } else
  11956. r = this;
  11957. if (null == r)
  11958. throw new Error("Target " + e + " not exists");
  11959. var s = this._animators
  11960. , l = new Ua(r, t)
  11961. , h = this;
  11962. return l.during((function () {
  11963. h.__zr && h.__zr.refresh()
  11964. }
  11965. )).done((function () {
  11966. var e = s.indexOf(l);
  11967. e >= 0 && s.splice(e, 1)
  11968. }
  11969. )),
  11970. s.push(l),
  11971. this.__zr && this.__zr.animation.addAnimator(l),
  11972. l
  11973. },
  11974. stopAnimation: function (e) {
  11975. this._animators = this._animators || [];
  11976. for (var t = this._animators, r = t.length, i = 0; i < r; i++)
  11977. t[i].stop(e);
  11978. return t.length = 0,
  11979. this
  11980. },
  11981. addAnimatorsToZr: function (e) {
  11982. if (this._animators)
  11983. for (var t = 0; t < this._animators.length; t++)
  11984. e.animation.addAnimator(this._animators[t])
  11985. },
  11986. removeAnimatorsFromZr: function (e) {
  11987. if (this._animators)
  11988. for (var t = 0; t < this._animators.length; t++)
  11989. e.animation.removeAnimator(this._animators[t])
  11990. }
  11991. }
  11992. , Va = "\n@export clay.util.rand\nhighp float rand(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, 3.141592653589793);\n return fract(sin(sn) * c);\n}\n@end\n@export clay.util.calculate_attenuation\nuniform float attenuationFactor : 5.0;\nfloat lightAttenuation(float dist, float range)\n{\n float attenuation = 1.0;\n attenuation = dist*dist/(range*range+1.0);\n float att_s = attenuationFactor;\n attenuation = 1.0/(attenuation*att_s+1.0);\n att_s = 1.0/(att_s+1.0);\n attenuation = attenuation - att_s;\n attenuation /= 1.0 - att_s;\n return clamp(attenuation, 0.0, 1.0);\n}\n@end\n@export clay.util.edge_factor\n#ifdef SUPPORT_STANDARD_DERIVATIVES\nfloat edgeFactor(float width)\n{\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * width, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#else\nfloat edgeFactor(float width)\n{\n return 1.0;\n}\n#endif\n@end\n@export clay.util.encode_float\nvec4 encodeFloat(const in float depth)\n{\n const vec4 bitShifts = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\n const vec4 bit_mask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\n vec4 res = fract(depth * bitShifts);\n res -= res.xxyz * bit_mask;\n return res;\n}\n@end\n@export clay.util.decode_float\nfloat decodeFloat(const in vec4 color)\n{\n const vec4 bitShifts = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\n return dot(color, bitShifts);\n}\n@end\n@export clay.util.float\n@import clay.util.encode_float\n@import clay.util.decode_float\n@end\n@export clay.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n}\n@end\n@export clay.util.rgbm_encode\nvec4 RGBMEncode(vec3 color, float range) {\n if (dot(color, color) == 0.0) {\n return vec4(0.0);\n }\n vec4 rgbm;\n color /= range;\n rgbm.a = clamp(max(max(color.r, color.g), max(color.b, 1e-6)), 0.0, 1.0);\n rgbm.a = ceil(rgbm.a * 255.0) / 255.0;\n rgbm.rgb = color / rgbm.a;\n return rgbm;\n}\n@end\n@export clay.util.rgbm\n@import clay.util.rgbm_decode\n@import clay.util.rgbm_encode\nvec4 decodeHDR(vec4 color)\n{\n#if defined(RGBM_DECODE) || defined(RGBM)\n return vec4(RGBMDecode(color, 8.12), 1.0);\n#else\n return color;\n#endif\n}\nvec4 encodeHDR(vec4 color)\n{\n#if defined(RGBM_ENCODE) || defined(RGBM)\n return RGBMEncode(color.xyz, 8.12);\n#else\n return color;\n#endif\n}\n@end\n@export clay.util.srgb\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.w);\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.w);\n}\n@end\n@export clay.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\n#ifdef USE_SKIN_MATRICES_TEXTURE\nuniform sampler2D skinMatricesTexture : ignore;\nuniform float skinMatricesTextureSize: ignore;\nmat4 getSkinMatrix(sampler2D tex, float idx) {\n float j = idx * 4.0;\n float x = mod(j, skinMatricesTextureSize);\n float y = floor(j / skinMatricesTextureSize) + 0.5;\n vec2 scale = vec2(skinMatricesTextureSize);\n return mat4(\n texture2D(tex, vec2(x + 0.5, y) / scale),\n texture2D(tex, vec2(x + 1.5, y) / scale),\n texture2D(tex, vec2(x + 2.5, y) / scale),\n texture2D(tex, vec2(x + 3.5, y) / scale)\n );\n}\nmat4 getSkinMatrix(float idx) {\n return getSkinMatrix(skinMatricesTexture, idx);\n}\n#else\nuniform mat4 skinMatrix[JOINT_COUNT] : SKIN_MATRIX;\nmat4 getSkinMatrix(float idx) {\n return skinMatrix[int(idx)];\n}\n#endif\n#endif\n@end\n@export clay.chunk.skin_matrix\nmat4 skinMatrixWS = getSkinMatrix(joint.x) * weight.x;\nif (weight.y > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.y) * weight.y;\n}\nif (weight.z > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.z) * weight.z;\n}\nfloat weightW = 1.0-weight.x-weight.y-weight.z;\nif (weightW > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n@export clay.chunk.instancing_header\n#ifdef INSTANCING\nattribute vec4 instanceMat1;\nattribute vec4 instanceMat2;\nattribute vec4 instanceMat3;\n#endif\n@end\n@export clay.chunk.instancing_matrix\nmat4 instanceMat = mat4(\n vec4(instanceMat1.xyz, 0.0),\n vec4(instanceMat2.xyz, 0.0),\n vec4(instanceMat3.xyz, 0.0),\n vec4(instanceMat1.w, instanceMat2.w, instanceMat3.w, 1.0)\n);\n@end\n@export clay.util.parallax_correct\nvec3 parallaxCorrect(in vec3 dir, in vec3 pos, in vec3 boxMin, in vec3 boxMax) {\n vec3 first = (boxMax - pos) / dir;\n vec3 second = (boxMin - pos) / dir;\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n return normalize(fixedPos - boxCenter);\n}\n@end\n@export clay.util.clamp_sample\nvec4 clampSample(const in sampler2D texture, const in vec2 coord)\n{\n#ifdef STEREO\n float eye = step(0.5, coord.x) * 0.5;\n vec2 coordClamped = clamp(coord, vec2(eye, 0.0), vec2(0.5 + eye, 1.0));\n#else\n vec2 coordClamped = clamp(coord, vec2(0.0), vec2(1.0));\n#endif\n return texture2D(texture, coordClamped);\n}\n@end\n@export clay.util.ACES\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\n@end";
  11993. function Ha(e) {
  11994. return e instanceof HTMLCanvasElement || e instanceof HTMLImageElement || e instanceof Image
  11995. }
  11996. Object.assign(sr.prototype, ka),
  11997. Xe.import(Va),
  11998. Xe.import(qe),
  11999. Xe.import("\n@export ecgl.common.transformUniforms\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\n@end\n\n@export ecgl.common.attributes\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 normal : NORMAL;\n@end\n\n@export ecgl.common.uv.header\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nuniform vec2 detailUvRepeat : [1.0, 1.0];\nuniform vec2 detailUvOffset : [0.0, 0.0];\n\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n@export ecgl.common.uv.main\nv_Texcoord = texcoord * uvRepeat + uvOffset;\nv_DetailTexcoord = texcoord * detailUvRepeat + detailUvOffset;\n@end\n\n@export ecgl.common.uv.fragmentHeader\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n\n@export ecgl.common.albedo.main\n\n vec4 albedoTexel = vec4(1.0);\n#ifdef DIFFUSEMAP_ENABLED\n albedoTexel = texture2D(diffuseMap, v_Texcoord);\n #ifdef SRGB_DECODE\n albedoTexel = sRGBToLinear(albedoTexel);\n #endif\n#endif\n\n#ifdef DETAILMAP_ENABLED\n vec4 detailTexel = texture2D(detailMap, v_DetailTexcoord);\n #ifdef SRGB_DECODE\n detailTexel = sRGBToLinear(detailTexel);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, detailTexel.rgb, detailTexel.a);\n albedoTexel.a = detailTexel.a + (1.0 - detailTexel.a) * albedoTexel.a;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexHeader\n\n#ifdef WIREFRAME_QUAD\nattribute vec4 barycentric;\nvarying vec4 v_Barycentric;\n#elif defined(WIREFRAME_TRIANGLE)\nattribute vec3 barycentric;\nvarying vec3 v_Barycentric;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n v_Barycentric = barycentric;\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentHeader\n\nuniform float wireframeLineWidth : 1;\nuniform vec4 wireframeLineColor: [0, 0, 0, 0.5];\n\n#ifdef WIREFRAME_QUAD\nvarying vec4 v_Barycentric;\nfloat edgeFactor () {\n vec4 d = fwidth(v_Barycentric);\n vec4 a4 = smoothstep(vec4(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(min(a4.x, a4.y), a4.z), a4.w);\n}\n#elif defined(WIREFRAME_TRIANGLE)\nvarying vec3 v_Barycentric;\nfloat edgeFactor () {\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n if (wireframeLineWidth > 0.) {\n vec4 lineColor = wireframeLineColor;\n#ifdef SRGB_DECODE\n lineColor = sRGBToLinear(lineColor);\n#endif\n\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor()) * lineColor.a);\n }\n#endif\n@end\n\n\n\n\n@export ecgl.common.bumpMap.header\n\n#ifdef BUMPMAP_ENABLED\nuniform sampler2D bumpMap;\nuniform float bumpScale : 1.0;\n\n\nvec3 bumpNormal(vec3 surfPos, vec3 surfNormal, vec3 baseNormal)\n{\n vec2 dSTdx = dFdx(v_Texcoord);\n vec2 dSTdy = dFdy(v_Texcoord);\n\n float Hll = bumpScale * texture2D(bumpMap, v_Texcoord).x;\n float dHx = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdx).x - Hll;\n float dHy = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdy).x - Hll;\n\n vec3 vSigmaX = dFdx(surfPos);\n vec3 vSigmaY = dFdy(surfPos);\n vec3 vN = surfNormal;\n\n vec3 R1 = cross(vSigmaY, vN);\n vec3 R2 = cross(vN, vSigmaX);\n\n float fDet = dot(vSigmaX, R1);\n\n vec3 vGrad = sign(fDet) * (dHx * R1 + dHy * R2);\n return normalize(abs(fDet) * baseNormal - vGrad);\n\n}\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexHeader\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexMain\n\n#ifdef NORMALMAP_ENABLED\n if (dot(tangent, tangent) > 0.0) {\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n }\n#endif\n\n@end\n\n\n@export ecgl.common.normalMap.fragmentHeader\n\n#ifdef NORMALMAP_ENABLED\nuniform sampler2D normalMap;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.fragmentMain\n#ifdef NORMALMAP_ENABLED\n if (dot(v_Tangent, v_Tangent) > 0.0) {\n vec3 normalTexel = texture2D(normalMap, v_DetailTexcoord).xyz;\n if (dot(normalTexel, normalTexel) > 0.0) { N = normalTexel * 2.0 - 1.0;\n mat3 tbn = mat3(v_Tangent, v_Bitangent, v_Normal);\n N = normalize(tbn * N);\n }\n }\n#endif\n@end\n\n\n\n@export ecgl.common.vertexAnimation.header\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevNormal;\nuniform float percent;\n#endif\n\n@end\n\n@export ecgl.common.vertexAnimation.main\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n vec3 norm = mix(prevNormal, normal, percent);\n#else\n vec3 pos = position;\n vec3 norm = normal;\n#endif\n\n@end\n\n\n@export ecgl.common.ssaoMap.header\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n@end\n\n@export ecgl.common.ssaoMap.main\n float ao = 1.0;\n#ifdef SSAOMAP_ENABLED\n ao = texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r;\n#endif\n@end\n\n\n\n\n@export ecgl.common.diffuseLayer.header\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\nuniform float layerDiffuseIntensity[LAYER_DIFFUSEMAP_COUNT];\nuniform sampler2D layerDiffuseMap[LAYER_DIFFUSEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.header\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\nuniform float layerEmissionIntensity[LAYER_EMISSIVEMAP_COUNT];\nuniform sampler2D layerEmissiveMap[LAYER_EMISSIVEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.layers.header\n@import ecgl.common.diffuseLayer.header\n@import ecgl.common.emissiveLayer.header\n@end\n\n@export ecgl.common.diffuseLayer.main\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_DIFFUSEMAP_COUNT; _idx_++) {{\n float intensity = layerDiffuseIntensity[_idx_];\n vec4 texel2 = texture2D(layerDiffuseMap[_idx_], v_Texcoord);\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, texel2.rgb * intensity, texel2.a);\n albedoTexel.a = texel2.a + (1.0 - texel2.a) * albedoTexel.a;\n }}\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.main\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_EMISSIVEMAP_COUNT; _idx_++)\n {{\n vec4 texel2 = texture2D(layerEmissiveMap[_idx_], v_Texcoord) * layerEmissionIntensity[_idx_];\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n float intensity = layerEmissionIntensity[_idx_];\n gl_FragColor.rgb += texel2.rgb * texel2.a * intensity;\n }}\n#endif\n\n@end\n"),
  12000. Xe.import("@export ecgl.color.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\n@import ecgl.common.uv.header\n\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position: POSITION;\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\n#ifdef ATMOSPHERE_ENABLED\nattribute vec3 normal: NORMAL;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nvarying vec3 v_Normal;\n#endif\n\nvoid main()\n{\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n @import ecgl.common.uv.main\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef ATMOSPHERE_ENABLED\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n@export ecgl.color.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\nvarying vec3 v_Normal;\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.layers.header\n\n@import ecgl.common.uv.fragmentHeader\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n\n}\n@end"),
  12001. Xe.import("/**\n * http: */\n\n@export ecgl.lambert.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n\n@import ecgl.common.attributes\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.vertexAnimation.header\n\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n}\n\n@end\n\n\n@export ecgl.lambert.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n gl_FragColor *= sRGBToLinear(v_Color);\n #else\n gl_FragColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n diffuseColor += ambientLightColor[i] * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseColor += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n vec3 lightColor = directionalLightColor[i];\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n diffuseColor += lightColor * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor.rgb *= diffuseColor;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"),
  12002. Xe.import("@export ecgl.realistic.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@import ecgl.common.vertexAnimation.header\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n\n\n@export ecgl.realistic.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n#define PI 3.14159265358979\n#define ROUGHNESS_CHANEL 0\n#define METALNESS_CHANEL 1\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\n\nuniform sampler2D detailMap;\nuniform sampler2D metalnessMap;\nuniform sampler2D roughnessMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform float metalness : 0.0;\nuniform float roughness : 0.5;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n@import clay.header.ambient_cubemap_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.normalMap.fragmentHeader\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import clay.util.rgbm\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n\nfloat D_Phong(float g, float ndh) {\n float a = pow(8192.0, g);\n return (a + 2.0) / 8.0 * pow(ndh, a);\n}\n\nvoid main()\n{\n vec4 albedoColor = color;\n\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n albedoColor *= sRGBToLinear(v_Color);\n #else\n albedoColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n albedoColor *= albedoTexel;\n\n float m = metalness;\n\n#ifdef METALNESSMAP_ENABLED\n float m2 = texture2D(metalnessMap, v_DetailTexcoord)[METALNESS_CHANEL];\n m = clamp(m2 + (m - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 baseColor = albedoColor.rgb;\n albedoColor.rgb = baseColor * (1.0 - m);\n vec3 specFactor = mix(vec3(0.04), baseColor, m);\n\n float g = 1.0 - roughness;\n\n#ifdef ROUGHNESSMAP_ENABLED\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 N = v_Normal;\n\n#ifdef DOUBLE_SIDED\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n@import ecgl.common.normalMap.fragmentMain\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseTerm = vec3(0.0);\n vec3 specularTerm = vec3(0.0);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n vec3 fresnelTerm = F_Schlick(ndv, specFactor);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += ambientLightColor[_idx_] * ambientFactor * ao;\n }}\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++)\n {{\n vec3 L = -directionalLightDirection[_idx_];\n vec3 lc = directionalLightColor[_idx_];\n\n vec3 H = normalize(L + V);\n float ndl = clamp(dot(N, normalize(L)), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * shadowContrib;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n vec3 L = reflect(-V, N);\n L = vec3(L.x, L[NORMAL_UP_AXIS], L[NORMAL_FRONT_AXIS]);\n float rough2 = clamp(1.0 - g, 0.0, 1.0);\n float bias2 = rough2 * 5.0;\n vec2 brdfParam2 = texture2D(ambientCubemapLightBRDFLookup[0], vec2(rough2, ndv)).xy;\n vec3 envWeight2 = specFactor * brdfParam2.x + brdfParam2.y;\n vec3 envTexel2;\n for(int _idx_ = 0; _idx_ < AMBIENT_CUBEMAP_LIGHT_COUNT; _idx_++)\n {{\n envTexel2 = RGBMDecode(textureCubeLodEXT(ambientCubemapLightCubemap[_idx_], L, bias2), 8.12);\n specularTerm += ambientCubemapLightColor[_idx_] * envTexel2 * envWeight2 * ao;\n }}\n#endif\n\n gl_FragColor.rgb = albedoColor.rgb * diffuseTerm + specularTerm;\n gl_FragColor.a = albedoColor.a;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n#ifdef SRGB_ENCODE\n gl_FragColor = linearTosRGB(gl_FragColor);\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"),
  12003. Xe.import("@export ecgl.hatching.vertex\n\n@import ecgl.realistic.vertex\n\n@end\n\n\n@export ecgl.hatching.fragment\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform vec4 color : [0.0, 0.0, 0.0, 1.0];\nuniform vec4 paperColor : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nuniform sampler2D hatch1;\nuniform sampler2D hatch2;\nuniform sampler2D hatch3;\nuniform sampler2D hatch4;\nuniform sampler2D hatch5;\nuniform sampler2D hatch6;\n\nfloat shade(in float tone) {\n vec4 c = vec4(1. ,1., 1., 1.);\n float step = 1. / 6.;\n vec2 uv = v_DetailTexcoord;\n if (tone <= step / 2.0) {\n c = mix(vec4(0.), texture2D(hatch6, uv), 12. * tone);\n }\n else if (tone <= step) {\n c = mix(texture2D(hatch6, uv), texture2D(hatch5, uv), 6. * tone);\n }\n if(tone > step && tone <= 2. * step){\n c = mix(texture2D(hatch5, uv), texture2D(hatch4, uv) , 6. * (tone - step));\n }\n if(tone > 2. * step && tone <= 3. * step){\n c = mix(texture2D(hatch4, uv), texture2D(hatch3, uv), 6. * (tone - 2. * step));\n }\n if(tone > 3. * step && tone <= 4. * step){\n c = mix(texture2D(hatch3, uv), texture2D(hatch2, uv), 6. * (tone - 3. * step));\n }\n if(tone > 4. * step && tone <= 5. * step){\n c = mix(texture2D(hatch2, uv), texture2D(hatch1, uv), 6. * (tone - 4. * step));\n }\n if(tone > 5. * step){\n c = mix(texture2D(hatch1, uv), vec4(1.), 6. * (tone - 5. * step));\n }\n\n return c.r;\n}\n\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n vec4 inkColor = sRGBToLinear(color);\n#else\n vec4 inkColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n inkColor *= sRGBToLinear(v_Color);\n #else\n inkColor *= v_Color;\n #endif\n#endif\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float tone = 0.0;\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n tone += dot(ambientLightColor[i], w) * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n tone += dot(calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_], w) * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n float lightTone = dot(directionalLightColor[i], w);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n tone += lightTone * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor = mix(inkColor, paperColor, shade(clamp(tone, 0.0, 1.0)));\n }\n@end\n"),
  12004. Xe.import("@export ecgl.sm.depth.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\n\nvoid main(){\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n v_ViewPosition = worldViewProjection * vec4(pos, 1.0);\n gl_Position = v_ViewPosition;\n\n v_Texcoord = texcoord;\n\n}\n@end\n\n\n\n@export ecgl.sm.depth.fragment\n\n@import clay.sm.depth.fragment\n\n@end");
  12005. var Wa = vi.prototype.addToScene
  12006. , ja = vi.prototype.removeFromScene;
  12007. vi.prototype.addToScene = function (e) {
  12008. if (Wa.call(this, e),
  12009. this.__zr) {
  12010. var t = this.__zr;
  12011. e.traverse((function (e) {
  12012. e.__zr = t,
  12013. e.addAnimatorsToZr && e.addAnimatorsToZr(t)
  12014. }
  12015. ))
  12016. }
  12017. }
  12018. ,
  12019. vi.prototype.removeFromScene = function (e) {
  12020. ja.call(this, e),
  12021. e.traverse((function (e) {
  12022. var t = e.__zr;
  12023. e.__zr = null,
  12024. t && e.removeAnimatorsFromZr && e.removeAnimatorsFromZr(t)
  12025. }
  12026. ))
  12027. }
  12028. ,
  12029. le.prototype.setTextureImage = function (e, t, r, i) {
  12030. if (this.shader) {
  12031. var n, a = r.getZr(), o = this;
  12032. return o.autoUpdateTextureStatus = !1,
  12033. o.disableTexture(e),
  12034. !(s = t) || "none" === s || (n = Xa.loadTexture(t, r, i, (function (t) {
  12035. o.enableTexture(e),
  12036. a && a.refresh()
  12037. }
  12038. )),
  12039. o.set(e, n)),
  12040. n
  12041. }
  12042. var s
  12043. }
  12044. ;
  12045. var Xa = {};
  12046. Xa.Renderer = ut,
  12047. Xa.Node = sr,
  12048. Xa.Mesh = Sr,
  12049. Xa.Shader = Xe,
  12050. Xa.Material = le,
  12051. Xa.Texture = wr,
  12052. Xa.Texture2D = Dr,
  12053. Xa.Geometry = Vr,
  12054. Xa.SphereGeometry = En,
  12055. Xa.PlaneGeometry = ki,
  12056. Xa.CubeGeometry = Wi,
  12057. Xa.AmbientLight = Cn,
  12058. Xa.DirectionalLight = Dn,
  12059. Xa.PointLight = Ln,
  12060. Xa.SpotLight = Pn,
  12061. Xa.PerspectiveCamera = Ei,
  12062. Xa.OrthographicCamera = un,
  12063. Xa.Vector2 = _e,
  12064. Xa.Vector3 = vt,
  12065. Xa.Vector4 = Rn,
  12066. Xa.Quaternion = qt,
  12067. Xa.Matrix2 = Gn,
  12068. Xa.Matrix2d = Hn,
  12069. Xa.Matrix3 = jn,
  12070. Xa.Matrix4 = Ht,
  12071. Xa.Plane = $r,
  12072. Xa.Ray = Mt,
  12073. Xa.BoundingBox = ir,
  12074. Xa.Frustum = si;
  12075. var qa = null;
  12076. function Za(e) {
  12077. return Math.pow(2, Math.round(Math.log(e) / Math.LN2))
  12078. }
  12079. function Ya(e) {
  12080. if ((e.wrapS === wr.REPEAT || e.wrapT === wr.REPEAT) && e.image) {
  12081. var t = Za(e.width)
  12082. , r = Za(e.height);
  12083. if (t !== e.width || r !== e.height) {
  12084. var i = document.createElement("canvas");
  12085. i.width = t,
  12086. i.height = r,
  12087. i.getContext("2d").drawImage(e.image, 0, 0, t, r),
  12088. e.image = i
  12089. }
  12090. }
  12091. }
  12092. Xa.loadTexture = function (e, t, r, i) {
  12093. "function" == typeof r && (i = r,
  12094. r = {}),
  12095. r = r || {};
  12096. for (var n = Object.keys(r).sort(), a = "", o = 0; o < n.length; o++)
  12097. a += n[o] + "_" + r[n[o]] + "_";
  12098. var s, l = t.__textureCache = t.__textureCache || new bi(20);
  12099. if ((s = e).getZr && s.setOption) {
  12100. var h = e.__textureid__;
  12101. if (c = l.get(a + h))
  12102. c.texture.surface.setECharts(e),
  12103. i && i(c.texture);
  12104. else {
  12105. var u = new hn(e);
  12106. for (u.onupdate = function () {
  12107. t.getZr().refresh()
  12108. }
  12109. ,
  12110. c = {
  12111. texture: u.getTexture()
  12112. },
  12113. o = 0; o < n.length; o++)
  12114. c.texture[n[o]] = r[n[o]];
  12115. h = e.__textureid__ || "__ecgl_ec__" + c.texture.__uid__,
  12116. e.__textureid__ = h,
  12117. l.put(a + h, c),
  12118. i && i(c.texture)
  12119. }
  12120. return c.texture
  12121. }
  12122. if (Ha(e)) {
  12123. var c;
  12124. if (h = e.__textureid__,
  12125. !(c = l.get(a + h))) {
  12126. for (c = {
  12127. texture: new Xa.Texture2D({
  12128. image: e
  12129. })
  12130. },
  12131. o = 0; o < n.length; o++)
  12132. c.texture[n[o]] = r[n[o]];
  12133. h = e.__textureid__ || "__ecgl_image__" + c.texture.__uid__,
  12134. e.__textureid__ = h,
  12135. l.put(a + h, c),
  12136. Ya(c.texture),
  12137. i && i(c.texture)
  12138. }
  12139. return c.texture
  12140. }
  12141. if (c = l.get(a + e))
  12142. c.callbacks ? c.callbacks.push(i) : i && i(c.texture);
  12143. else if (e.match(/.hdr$|^data:application\/octet-stream/)) {
  12144. c = {
  12145. callbacks: [i]
  12146. };
  12147. var d = an.loadTexture(e, {
  12148. exposure: r.exposure,
  12149. fileType: "hdr"
  12150. }, (function () {
  12151. d.dirty(),
  12152. c.callbacks.forEach((function (e) {
  12153. e && e(d)
  12154. }
  12155. )),
  12156. c.callbacks = null
  12157. }
  12158. ));
  12159. c.texture = d,
  12160. l.put(a + e, c)
  12161. } else {
  12162. for (d = new Xa.Texture2D({
  12163. image: new Image
  12164. }),
  12165. o = 0; o < n.length; o++)
  12166. d[n[o]] = r[n[o]];
  12167. c = {
  12168. texture: d,
  12169. callbacks: [i]
  12170. };
  12171. var f = d.image;
  12172. f.onload = function () {
  12173. d.image = f,
  12174. Ya(d),
  12175. d.dirty(),
  12176. c.callbacks.forEach((function (e) {
  12177. e && e(d)
  12178. }
  12179. )),
  12180. c.callbacks = null
  12181. }
  12182. ,
  12183. f.crossOrigin = "Anonymous",
  12184. f.src = e,
  12185. d.image = null !== qa ? qa : qa = an.createBlank("rgba(255,255,255,0)").image,
  12186. l.put(a + e, c)
  12187. }
  12188. return c.texture
  12189. }
  12190. ,
  12191. Xa.createAmbientCubemap = function (e, t, r, i) {
  12192. var n = (e = e || {}).texture
  12193. , a = Mn(e.exposure, 1)
  12194. , o = new vn({
  12195. intensity: Mn(e.specularIntensity, 1)
  12196. })
  12197. , s = new yn({
  12198. intensity: Mn(e.diffuseIntensity, 1),
  12199. coefficients: [.844, .712, .691, -.037, .083, .167, .343, .288, .299, -.041, -.021, -.009, -.003, -.041, -.064, -.011, -.007, -.004, -.031, .034, .081, -.06, -.049, -.06, .046, .056, .05]
  12200. });
  12201. return o.cubemap = Xa.loadTexture(n, r, {
  12202. exposure: a
  12203. }, (function () {
  12204. o.cubemap.flipY = !1,
  12205. o.prefilter(t, 32),
  12206. s.coefficients = Sn.projectEnvironmentMap(t, o.cubemap, {
  12207. lod: 1
  12208. }),
  12209. i && i()
  12210. }
  12211. )),
  12212. {
  12213. specular: o,
  12214. diffuse: s
  12215. }
  12216. }
  12217. ,
  12218. Xa.createBlankTexture = an.createBlank,
  12219. Xa.isImage = Ha,
  12220. Xa.additiveBlend = function (e) {
  12221. e.blendEquation(e.FUNC_ADD),
  12222. e.blendFunc(e.SRC_ALPHA, e.ONE)
  12223. }
  12224. ,
  12225. Xa.parseColor = function (e, t) {
  12226. return e instanceof Array ? (t || (t = []),
  12227. t[0] = e[0],
  12228. t[1] = e[1],
  12229. t[2] = e[2],
  12230. e.length > 3 ? t[3] = e[3] : t[3] = 1,
  12231. t) : ((t = i.color.parse(e || "#000", t) || [0, 0, 0, 0])[0] /= 255,
  12232. t[1] /= 255,
  12233. t[2] /= 255,
  12234. t)
  12235. }
  12236. ,
  12237. Xa.directionFromAlphaBeta = function (e, t) {
  12238. var r = e / 180 * Math.PI + Math.PI / 2
  12239. , i = -t / 180 * Math.PI + Math.PI / 2
  12240. , n = []
  12241. , a = Math.sin(r);
  12242. return n[0] = a * Math.cos(i),
  12243. n[1] = -Math.cos(r),
  12244. n[2] = a * Math.sin(i),
  12245. n
  12246. }
  12247. ,
  12248. Xa.getShadowResolution = function (e) {
  12249. var t = 1024;
  12250. switch (e) {
  12251. case "low":
  12252. t = 512;
  12253. break;
  12254. case "medium":
  12255. break;
  12256. case "high":
  12257. t = 2048;
  12258. break;
  12259. case "ultra":
  12260. t = 4096
  12261. }
  12262. return t
  12263. }
  12264. ,
  12265. Xa.COMMON_SHADERS = ["lambert", "color", "realistic", "hatching", "shadow"],
  12266. Xa.createShader = function (e) {
  12267. "ecgl.shadow" === e && (e = "ecgl.displayShadow");
  12268. var t = Xe.source(e + ".vertex")
  12269. , r = Xe.source(e + ".fragment");
  12270. t || console.error("Vertex shader of '%s' not exits", e),
  12271. r || console.error("Fragment shader of '%s' not exits", e);
  12272. var i = new Xe(t, r);
  12273. return i.name = e,
  12274. i
  12275. }
  12276. ,
  12277. Xa.createMaterial = function (e, t) {
  12278. t instanceof Array || (t = [t]);
  12279. var r = Xa.createShader(e)
  12280. , i = new le({
  12281. shader: r
  12282. });
  12283. return t.forEach((function (e) {
  12284. "string" == typeof e && i.define(e)
  12285. }
  12286. )),
  12287. i
  12288. }
  12289. ,
  12290. Xa.setMaterialFromModel = function (e, t, r, i) {
  12291. t.autoUpdateTextureStatus = !1;
  12292. var n = r.getModel(e + "Material")
  12293. , a = n.get("detailTexture")
  12294. , o = Mn(n.get("textureTiling"), 1)
  12295. , s = Mn(n.get("textureOffset"), 0);
  12296. "number" == typeof o && (o = [o, o]),
  12297. "number" == typeof s && (s = [s, s]);
  12298. var l = o[0] > 1 || o[1] > 1 ? Xa.Texture.REPEAT : Xa.Texture.CLAMP_TO_EDGE
  12299. , h = {
  12300. anisotropic: 8,
  12301. wrapS: l,
  12302. wrapT: l
  12303. };
  12304. if ("realistic" === e) {
  12305. var u = n.get("roughness")
  12306. , c = n.get("metalness");
  12307. null != c ? isNaN(c) && (t.setTextureImage("metalnessMap", c, i, h),
  12308. c = Mn(n.get("metalnessAdjust"), .5)) : c = 0,
  12309. null != u ? isNaN(u) && (t.setTextureImage("roughnessMap", u, i, h),
  12310. u = Mn(n.get("roughnessAdjust"), .5)) : u = .5;
  12311. var d = n.get("normalTexture");
  12312. t.setTextureImage("detailMap", a, i, h),
  12313. t.setTextureImage("normalMap", d, i, h),
  12314. t.set({
  12315. roughness: u,
  12316. metalness: c,
  12317. detailUvRepeat: o,
  12318. detailUvOffset: s
  12319. })
  12320. } else if ("lambert" === e)
  12321. t.setTextureImage("detailMap", a, i, h),
  12322. t.set({
  12323. detailUvRepeat: o,
  12324. detailUvOffset: s
  12325. });
  12326. else if ("color" === e)
  12327. t.setTextureImage("detailMap", a, i, h),
  12328. t.set({
  12329. detailUvRepeat: o,
  12330. detailUvOffset: s
  12331. });
  12332. else if ("hatching" === e) {
  12333. var f = n.get("hatchingTextures") || [];
  12334. f.length;
  12335. for (var p = 0; p < 6; p++)
  12336. t.setTextureImage("hatch" + (p + 1), f[p], i, {
  12337. anisotropic: 8,
  12338. wrapS: Xa.Texture.REPEAT,
  12339. wrapT: Xa.Texture.REPEAT
  12340. });
  12341. t.set({
  12342. detailUvRepeat: o,
  12343. detailUvOffset: s
  12344. })
  12345. }
  12346. }
  12347. ,
  12348. Xa.updateVertexAnimation = function (e, t, r, i) {
  12349. var n = i.get("animation")
  12350. , a = i.get("animationDurationUpdate")
  12351. , o = i.get("animationEasingUpdate")
  12352. , s = r.shadowDepthMaterial;
  12353. if (n && t && a > 0 && t.geometry.vertexCount === r.geometry.vertexCount) {
  12354. r.material.define("vertex", "VERTEX_ANIMATION"),
  12355. r.ignorePreZ = !0,
  12356. s && s.define("vertex", "VERTEX_ANIMATION");
  12357. for (var l = 0; l < e.length; l++)
  12358. r.geometry.attributes[e[l][0]].value = t.geometry.attributes[e[l][1]].value;
  12359. r.geometry.dirty(),
  12360. r.__percent = 0,
  12361. r.material.set("percent", 0),
  12362. r.stopAnimation(),
  12363. r.animate().when(a, {
  12364. __percent: 1
  12365. }).during((function () {
  12366. r.material.set("percent", r.__percent),
  12367. s && s.set("percent", r.__percent)
  12368. }
  12369. )).done((function () {
  12370. r.ignorePreZ = !1,
  12371. r.material.undefine("vertex", "VERTEX_ANIMATION"),
  12372. s && s.undefine("vertex", "VERTEX_ANIMATION")
  12373. }
  12374. )).start(o)
  12375. } else
  12376. r.material.undefine("vertex", "VERTEX_ANIMATION"),
  12377. s && s.undefine("vertex", "VERTEX_ANIMATION")
  12378. }
  12379. ;
  12380. const Ka = Xa
  12381. , Qa = "undefined" != typeof window && (window.requestAnimationFrame && window.requestAnimationFrame.bind(window) || window.msRequestAnimationFrame && window.msRequestAnimationFrame.bind(window) || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame) || function (e) {
  12382. return setTimeout(e, 16)
  12383. }
  12384. ;
  12385. var Ja = function (e, t) {
  12386. this.id = e,
  12387. this.zr = t;
  12388. try {
  12389. this.renderer = new ut({
  12390. clearBit: 0,
  12391. devicePixelRatio: t.painter.dpr,
  12392. preserveDrawingBuffer: !0,
  12393. premultipliedAlpha: !0
  12394. }),
  12395. this.renderer.resize(t.painter.getWidth(), t.painter.getHeight())
  12396. } catch (e) {
  12397. return this.renderer = null,
  12398. this.dom = document.createElement("div"),
  12399. this.dom.style.cssText = "position:absolute; left: 0; top: 0; right: 0; bottom: 0;",
  12400. this.dom.className = "ecgl-nowebgl",
  12401. this.dom.innerHTML = "Sorry, your browser does not support WebGL",
  12402. void console.error(e)
  12403. }
  12404. this.onglobalout = this.onglobalout.bind(this),
  12405. t.on("globalout", this.onglobalout),
  12406. this.dom = this.renderer.canvas;
  12407. var r = this.dom.style;
  12408. r.position = "absolute",
  12409. r.left = "0",
  12410. r.top = "0",
  12411. this.views = [],
  12412. this._picking = new _r({
  12413. renderer: this.renderer
  12414. }),
  12415. this._viewsToDispose = [],
  12416. this._accumulatingId = 0,
  12417. this._zrEventProxy = new i.graphic.Rect({
  12418. shape: {
  12419. x: -1,
  12420. y: -1,
  12421. width: 2,
  12422. height: 2
  12423. },
  12424. __isGLToZRProxy: !0
  12425. }),
  12426. this._backgroundColor = null,
  12427. this._disposed = !1
  12428. };
  12429. function $a(e) {
  12430. var t = e.__zr;
  12431. e.__zr = null,
  12432. t && e.removeAnimatorsFromZr && e.removeAnimatorsFromZr(t)
  12433. }
  12434. Ja.prototype.setUnpainted = function () { }
  12435. ,
  12436. Ja.prototype.addView = function (e) {
  12437. if (e.layer !== this) {
  12438. var t = this._viewsToDispose.indexOf(e);
  12439. t >= 0 && this._viewsToDispose.splice(t, 1),
  12440. this.views.push(e),
  12441. e.layer = this;
  12442. var r = this.zr;
  12443. e.scene.traverse((function (e) {
  12444. e.__zr = r,
  12445. e.addAnimatorsToZr && e.addAnimatorsToZr(r)
  12446. }
  12447. ))
  12448. }
  12449. }
  12450. ,
  12451. Ja.prototype.removeView = function (e) {
  12452. if (e.layer === this) {
  12453. var t = this.views.indexOf(e);
  12454. t >= 0 && (this.views.splice(t, 1),
  12455. e.scene.traverse($a, this),
  12456. e.layer = null,
  12457. this._viewsToDispose.push(e))
  12458. }
  12459. }
  12460. ,
  12461. Ja.prototype.removeViewsAll = function () {
  12462. this.views.forEach((function (e) {
  12463. e.scene.traverse($a, this),
  12464. e.layer = null,
  12465. this._viewsToDispose.push(e)
  12466. }
  12467. ), this),
  12468. this.views.length = 0
  12469. }
  12470. ,
  12471. Ja.prototype.resize = function (e, t) {
  12472. this.renderer.resize(e, t)
  12473. }
  12474. ,
  12475. Ja.prototype.clear = function () {
  12476. var e = this.renderer.gl
  12477. , t = this._backgroundColor || [0, 0, 0, 0];
  12478. e.clearColor(t[0], t[1], t[2], t[3]),
  12479. e.depthMask(!0),
  12480. e.colorMask(!0, !0, !0, !0),
  12481. e.clear(e.DEPTH_BUFFER_BIT | e.COLOR_BUFFER_BIT)
  12482. }
  12483. ,
  12484. Ja.prototype.clearDepth = function () {
  12485. var e = this.renderer.gl;
  12486. e.clear(e.DEPTH_BUFFER_BIT)
  12487. }
  12488. ,
  12489. Ja.prototype.clearColor = function () {
  12490. var e = this.renderer.gl;
  12491. e.clearColor(0, 0, 0, 0),
  12492. e.clear(e.COLOR_BUFFER_BIT)
  12493. }
  12494. ,
  12495. Ja.prototype.needsRefresh = function () {
  12496. this.zr.refresh()
  12497. }
  12498. ,
  12499. Ja.prototype.refresh = function (e) {
  12500. this._backgroundColor = e ? Ka.parseColor(e) : [0, 0, 0, 0],
  12501. this.renderer.clearColor = this._backgroundColor;
  12502. for (var t = 0; t < this.views.length; t++)
  12503. this.views[t].prepareRender(this.renderer);
  12504. for (this._doRender(!1),
  12505. this._trackAndClean(),
  12506. t = 0; t < this._viewsToDispose.length; t++)
  12507. this._viewsToDispose[t].dispose(this.renderer);
  12508. this._viewsToDispose.length = 0,
  12509. this._startAccumulating()
  12510. }
  12511. ,
  12512. Ja.prototype.renderToCanvas = function (e) {
  12513. this._startAccumulating(!0),
  12514. e.drawImage(this.dom, 0, 0, e.canvas.width, e.canvas.height)
  12515. }
  12516. ,
  12517. Ja.prototype._doRender = function (e) {
  12518. this.clear(),
  12519. this.renderer.saveViewport();
  12520. for (var t = 0; t < this.views.length; t++)
  12521. this.views[t].render(this.renderer, e);
  12522. this.renderer.restoreViewport()
  12523. }
  12524. ,
  12525. Ja.prototype._stopAccumulating = function () {
  12526. this._accumulatingId = 0,
  12527. clearTimeout(this._accumulatingTimeout)
  12528. }
  12529. ;
  12530. var eo = 1;
  12531. function to(e) {
  12532. for (var t = 0; t < e.length; t++)
  12533. e[t].__used__ = 0
  12534. }
  12535. function ro(e, t) {
  12536. for (var r = 0; r < t.length; r++)
  12537. t[r].__used__ || t[r].dispose(e)
  12538. }
  12539. function io(e, t) {
  12540. e.__used__ = e.__used__ || 0,
  12541. e.__used__++,
  12542. 1 === e.__used__ && t.push(e)
  12543. }
  12544. function no(e, t, r) {
  12545. var i, n;
  12546. e.traverse((function (e) {
  12547. if (e.isRenderable()) {
  12548. var a = e.geometry
  12549. , o = e.material;
  12550. if (o !== i)
  12551. for (var s = o.getTextureUniforms(), l = 0; l < s.length; l++) {
  12552. var h = s[l]
  12553. , u = o.uniforms[h].value;
  12554. if (u)
  12555. if (u instanceof wr)
  12556. io(u, t);
  12557. else if (u instanceof Array)
  12558. for (var c = 0; c < u.length; c++)
  12559. u[c] instanceof wr && io(u[c], t)
  12560. }
  12561. a !== n && io(a, r),
  12562. i = o,
  12563. n = a
  12564. }
  12565. }
  12566. ));
  12567. for (var a = 0; a < e.lights.length; a++)
  12568. e.lights[a].cubemap && io(e.lights[a].cubemap, t)
  12569. }
  12570. Ja.prototype._startAccumulating = function (e) {
  12571. var t = this;
  12572. this._stopAccumulating();
  12573. for (var r = !1, i = 0; i < this.views.length; i++)
  12574. r = this.views[i].needsAccumulate() || r;
  12575. function n(i) {
  12576. if (t._accumulatingId && i === t._accumulatingId) {
  12577. for (var a = !0, o = 0; o < t.views.length; o++)
  12578. a = t.views[o].isAccumulateFinished() && r;
  12579. a || (t._doRender(!0),
  12580. e ? n(i) : Qa((function () {
  12581. n(i)
  12582. }
  12583. )))
  12584. }
  12585. }
  12586. r && (this._accumulatingId = eo++,
  12587. e ? n(t._accumulatingId) : this._accumulatingTimeout = setTimeout((function () {
  12588. n(t._accumulatingId)
  12589. }
  12590. ), 50))
  12591. }
  12592. ,
  12593. Ja.prototype._trackAndClean = function () {
  12594. var e = []
  12595. , t = [];
  12596. this._textureList && (to(this._textureList),
  12597. to(this._geometriesList));
  12598. for (var r = 0; r < this.views.length; r++)
  12599. no(this.views[r].scene, e, t);
  12600. this._textureList && (ro(this.renderer, this._textureList),
  12601. ro(this.renderer, this._geometriesList)),
  12602. this._textureList = e,
  12603. this._geometriesList = t
  12604. }
  12605. ,
  12606. Ja.prototype.dispose = function () {
  12607. this._disposed || (this._stopAccumulating(),
  12608. this._textureList && (to(this._textureList),
  12609. to(this._geometriesList),
  12610. ro(this.renderer, this._textureList),
  12611. ro(this.renderer, this._geometriesList)),
  12612. this.zr.off("globalout", this.onglobalout),
  12613. this._disposed = !0)
  12614. }
  12615. ,
  12616. Ja.prototype.onmousedown = function (e) {
  12617. if (!e.target || !e.target.__isGLToZRProxy) {
  12618. e = e.event;
  12619. var t = this.pickObject(e.offsetX, e.offsetY);
  12620. t && (this._dispatchEvent("mousedown", e, t),
  12621. this._dispatchDataEvent("mousedown", e, t)),
  12622. this._downX = e.offsetX,
  12623. this._downY = e.offsetY
  12624. }
  12625. }
  12626. ,
  12627. Ja.prototype.onmousemove = function (e) {
  12628. if (!e.target || !e.target.__isGLToZRProxy) {
  12629. e = e.event;
  12630. var t = this.pickObject(e.offsetX, e.offsetY)
  12631. , r = t && t.target
  12632. , i = this._hovered;
  12633. this._hovered = t,
  12634. i && r !== i.target && (i.relatedTarget = r,
  12635. this._dispatchEvent("mouseout", e, i),
  12636. this.zr.setCursorStyle("default")),
  12637. this._dispatchEvent("mousemove", e, t),
  12638. t && (this.zr.setCursorStyle("pointer"),
  12639. i && r === i.target || this._dispatchEvent("mouseover", e, t)),
  12640. this._dispatchDataEvent("mousemove", e, t)
  12641. }
  12642. }
  12643. ,
  12644. Ja.prototype.onmouseup = function (e) {
  12645. if (!e.target || !e.target.__isGLToZRProxy) {
  12646. e = e.event;
  12647. var t = this.pickObject(e.offsetX, e.offsetY);
  12648. t && (this._dispatchEvent("mouseup", e, t),
  12649. this._dispatchDataEvent("mouseup", e, t)),
  12650. this._upX = e.offsetX,
  12651. this._upY = e.offsetY
  12652. }
  12653. }
  12654. ,
  12655. Ja.prototype.onclick = Ja.prototype.dblclick = function (e) {
  12656. if (!e.target || !e.target.__isGLToZRProxy) {
  12657. var t = this._upX - this._downX
  12658. , r = this._upY - this._downY;
  12659. if (!(Math.sqrt(t * t + r * r) > 20)) {
  12660. e = e.event;
  12661. var i = this.pickObject(e.offsetX, e.offsetY);
  12662. i && (this._dispatchEvent(e.type, e, i),
  12663. this._dispatchDataEvent(e.type, e, i));
  12664. var n = this._clickToSetFocusPoint(e);
  12665. n && n.view.setDOFFocusOnPoint(n.distance) && this.zr.refresh()
  12666. }
  12667. }
  12668. }
  12669. ,
  12670. Ja.prototype._clickToSetFocusPoint = function (e) {
  12671. for (var t = this.renderer, r = t.viewport, i = this.views.length - 1; i >= 0; i--) {
  12672. var n = this.views[i];
  12673. if (n.hasDOF() && n.containPoint(e.offsetX, e.offsetY)) {
  12674. this._picking.scene = n.scene,
  12675. this._picking.camera = n.camera,
  12676. t.viewport = n.viewport;
  12677. var a = this._picking.pick(e.offsetX, e.offsetY, !0);
  12678. if (a)
  12679. return a.view = n,
  12680. a
  12681. }
  12682. }
  12683. t.viewport = r
  12684. }
  12685. ,
  12686. Ja.prototype.onglobalout = function (e) {
  12687. var t = this._hovered;
  12688. t && this._dispatchEvent("mouseout", e, {
  12689. target: t.target
  12690. })
  12691. }
  12692. ,
  12693. Ja.prototype.pickObject = function (e, t) {
  12694. for (var r = [], i = this.renderer, n = i.viewport, a = 0; a < this.views.length; a++) {
  12695. var o = this.views[a];
  12696. o.containPoint(e, t) && (this._picking.scene = o.scene,
  12697. this._picking.camera = o.camera,
  12698. i.viewport = o.viewport,
  12699. this._picking.pickAll(e, t, r))
  12700. }
  12701. return i.viewport = n,
  12702. r.sort((function (e, t) {
  12703. return e.distance - t.distance
  12704. }
  12705. )),
  12706. r[0]
  12707. }
  12708. ,
  12709. Ja.prototype._dispatchEvent = function (e, t, r) {
  12710. r || (r = {});
  12711. var i = r.target;
  12712. for (r.cancelBubble = !1,
  12713. r.event = t,
  12714. r.type = e,
  12715. r.offsetX = t.offsetX,
  12716. r.offsetY = t.offsetY; i && (i.trigger(e, r),
  12717. i = i.getParent(),
  12718. !r.cancelBubble);)
  12719. ;
  12720. this._dispatchToView(e, r)
  12721. }
  12722. ,
  12723. Ja.prototype._dispatchDataEvent = function (e, t, r) {
  12724. var n = r && r.target
  12725. , a = n && n.dataIndex
  12726. , o = n && n.seriesIndex
  12727. , s = n && n.eventData
  12728. , l = !1
  12729. , h = this._zrEventProxy;
  12730. h.x = t.offsetX,
  12731. h.y = t.offsetY,
  12732. h.update();
  12733. var u = {
  12734. target: h
  12735. };
  12736. const c = i.helper.getECData(h);
  12737. "mousemove" === e && (null != a ? a !== this._lastDataIndex && (parseInt(this._lastDataIndex, 10) >= 0 && (c.dataIndex = this._lastDataIndex,
  12738. c.seriesIndex = this._lastSeriesIndex,
  12739. this.zr.handler.dispatchToElement(u, "mouseout", t)),
  12740. l = !0) : null != s && s !== this._lastEventData && (null != this._lastEventData && (c.eventData = this._lastEventData,
  12741. this.zr.handler.dispatchToElement(u, "mouseout", t)),
  12742. l = !0),
  12743. this._lastEventData = s,
  12744. this._lastDataIndex = a,
  12745. this._lastSeriesIndex = o),
  12746. c.eventData = s,
  12747. c.dataIndex = a,
  12748. c.seriesIndex = o,
  12749. (null != s || parseInt(a, 10) >= 0 && parseInt(o, 10) >= 0) && (this.zr.handler.dispatchToElement(u, e, t),
  12750. l && this.zr.handler.dispatchToElement(u, "mouseover", t))
  12751. }
  12752. ,
  12753. Ja.prototype._dispatchToView = function (e, t) {
  12754. for (var r = 0; r < this.views.length; r++)
  12755. this.views[r].containPoint(t.offsetX, t.offsetY) && this.views[r].trigger(e, t)
  12756. }
  12757. ,
  12758. Object.assign(Ja.prototype, h);
  12759. const ao = Ja;
  12760. var oo = ["bar3D", "line3D", "map3D", "scatter3D", "surface", "lines3D", "scatterGL", "scatter3D"];
  12761. function so(e, t) {
  12762. if (e && e[t] && (e[t].normal || e[t].emphasis)) {
  12763. var r = e[t].normal
  12764. , i = e[t].emphasis;
  12765. r && (e[t] = r),
  12766. i && (e.emphasis = e.emphasis || {},
  12767. e.emphasis[t] = i)
  12768. }
  12769. }
  12770. function lo(e) {
  12771. e && (e instanceof Array || (e = [e]),
  12772. i.util.each(e, (function (e) {
  12773. if (e.axisLabel) {
  12774. var t = e.axisLabel;
  12775. Object.assign(t, t.textStyle),
  12776. t.textStyle = null
  12777. }
  12778. }
  12779. )))
  12780. }
  12781. function ho(e) {
  12782. this._layers = {},
  12783. this._zr = e
  12784. }
  12785. ho.prototype.update = function (e, t) {
  12786. var r = this
  12787. , n = t.getZr();
  12788. if (n.getWidth() && n.getHeight()) {
  12789. for (var a in this._layers)
  12790. this._layers[a].removeViewsAll();
  12791. e.eachComponent((function (r, i) {
  12792. if ("series" !== r) {
  12793. var n = t.getViewOfComponentModel(i)
  12794. , a = i.coordinateSystem;
  12795. if (n.__ecgl__) {
  12796. if (a) {
  12797. if (!a.viewGL)
  12798. return void console.error("Can't find viewGL in coordinateSystem of component " + i.id);
  12799. l = a.viewGL
  12800. } else {
  12801. if (!i.viewGL)
  12802. return void console.error("Can't find viewGL of component " + i.id);
  12803. l = a.viewGL
  12804. }
  12805. var l = a.viewGL
  12806. , h = o(i);
  12807. h.addView(l),
  12808. n.afterRender && n.afterRender(i, e, t, h),
  12809. s(n.groupGL, i.get("silent"))
  12810. }
  12811. }
  12812. }
  12813. )),
  12814. e.eachSeries((function (r) {
  12815. var i = t.getViewOfSeriesModel(r)
  12816. , n = r.coordinateSystem;
  12817. if (i.__ecgl__) {
  12818. if (n && !n.viewGL && !i.viewGL)
  12819. return void console.error("Can't find viewGL of series " + i.id);
  12820. var a = n && n.viewGL || i.viewGL
  12821. , l = o(r);
  12822. l.addView(a),
  12823. i.afterRender && i.afterRender(r, e, t, l),
  12824. s(i.groupGL, r.get("silent"))
  12825. }
  12826. }
  12827. ))
  12828. } else
  12829. console.warn("Dom has no width or height");
  12830. function o(e) {
  12831. var t;
  12832. n.setSleepAfterStill(0),
  12833. e.coordinateSystem && e.coordinateSystem.model,
  12834. t = e.get("zlevel");
  12835. var a = r._layers
  12836. , o = a[t];
  12837. if (!o) {
  12838. if (o = a[t] = new ao("gl-" + t, n),
  12839. n.painter.isSingleCanvas()) {
  12840. o.virtual = !0;
  12841. var s = new i.graphic.Image({
  12842. z: 1e4,
  12843. style: {
  12844. image: o.renderer.canvas
  12845. },
  12846. silent: !0
  12847. });
  12848. o.__hostImage = s,
  12849. n.add(s)
  12850. }
  12851. n.painter.insertLayer(t, o)
  12852. }
  12853. return o.__hostImage && o.__hostImage.setStyle({
  12854. width: o.renderer.getWidth(),
  12855. height: o.renderer.getHeight()
  12856. }),
  12857. o
  12858. }
  12859. function s(e, t) {
  12860. e && e.traverse((function (e) {
  12861. e.isRenderable && e.isRenderable() && (e.ignorePicking = null != e.$ignorePicking ? e.$ignorePicking : t)
  12862. }
  12863. ))
  12864. }
  12865. }
  12866. ,
  12867. i.registerPostInit((function (e) {
  12868. var t = e.getZr()
  12869. , r = t.painter.dispose;
  12870. t.painter.dispose = function () {
  12871. "function" == typeof this.eachOtherLayer && this.eachOtherLayer((function (e) {
  12872. e instanceof ao && e.dispose()
  12873. }
  12874. )),
  12875. r.call(this)
  12876. }
  12877. ,
  12878. t.painter.getRenderedCanvas = function (e) {
  12879. if (e = e || {},
  12880. this._singleCanvas)
  12881. return this._layers[0].dom;
  12882. var t = document.createElement("canvas")
  12883. , r = e.pixelRatio || this.dpr;
  12884. t.width = this.getWidth() * r,
  12885. t.height = this.getHeight() * r;
  12886. var i = t.getContext("2d");
  12887. i.dpr = r,
  12888. i.clearRect(0, 0, t.width, t.height),
  12889. e.backgroundColor && (i.fillStyle = e.backgroundColor,
  12890. i.fillRect(0, 0, t.width, t.height));
  12891. var n, a = this.storage.getDisplayList(!0), o = {}, s = this;
  12892. function l(e, t) {
  12893. var r, n = s._zlevelList;
  12894. null == e && (e = -1 / 0);
  12895. for (var a = 0; a < n.length; a++) {
  12896. var o = n[a]
  12897. , l = s._layers[o];
  12898. if (!l.__builtin__ && o > e && o < t) {
  12899. r = l;
  12900. break
  12901. }
  12902. }
  12903. r && r.renderToCanvas && (i.save(),
  12904. r.renderToCanvas(i),
  12905. i.restore())
  12906. }
  12907. for (var h = {
  12908. ctx: i
  12909. }, u = 0; u < a.length; u++) {
  12910. var c = a[u];
  12911. c.zlevel !== n && (l(n, c.zlevel),
  12912. n = c.zlevel),
  12913. this._doPaintEl(c, h, !0, null, o)
  12914. }
  12915. return l(n, 1 / 0),
  12916. t
  12917. }
  12918. }
  12919. )),
  12920. i.registerPostUpdate((function (e, t) {
  12921. var r = t.getZr();
  12922. (r.__egl = r.__egl || new ho(r)).update(e, t)
  12923. }
  12924. )),
  12925. i.registerPreprocessor((function (e) {
  12926. i.util.each(e.series, (function (t) {
  12927. i.util.indexOf(oo, t.type) >= 0 && (function (e) {
  12928. so(e, "itemStyle"),
  12929. so(e, "lineStyle"),
  12930. so(e, "areaStyle"),
  12931. so(e, "label")
  12932. }(t),
  12933. "mapbox" === t.coordinateSystem && (t.coordinateSystem = "mapbox3D",
  12934. e.mapbox3D = e.mapbox))
  12935. }
  12936. )),
  12937. lo(e.xAxis3D),
  12938. lo(e.yAxis3D),
  12939. lo(e.zAxis3D),
  12940. lo(e.grid3D),
  12941. so(e.geo3D)
  12942. }
  12943. ));
  12944. const uo = {
  12945. defaultOption: {
  12946. viewControl: {
  12947. projection: "perspective",
  12948. autoRotate: !1,
  12949. autoRotateDirection: "cw",
  12950. autoRotateSpeed: 10,
  12951. autoRotateAfterStill: 3,
  12952. damping: .8,
  12953. rotateSensitivity: 1,
  12954. zoomSensitivity: 1,
  12955. panSensitivity: 1,
  12956. panMouseButton: "middle",
  12957. rotateMouseButton: "left",
  12958. distance: 150,
  12959. minDistance: 40,
  12960. maxDistance: 400,
  12961. orthographicSize: 150,
  12962. maxOrthographicSize: 400,
  12963. minOrthographicSize: 20,
  12964. center: [0, 0, 0],
  12965. alpha: 0,
  12966. beta: 0,
  12967. minAlpha: -90,
  12968. maxAlpha: 90
  12969. }
  12970. },
  12971. setView: function (e) {
  12972. e = e || {},
  12973. this.option.viewControl = this.option.viewControl || {},
  12974. null != e.alpha && (this.option.viewControl.alpha = e.alpha),
  12975. null != e.beta && (this.option.viewControl.beta = e.beta),
  12976. null != e.distance && (this.option.viewControl.distance = e.distance),
  12977. null != e.center && (this.option.viewControl.center = e.center)
  12978. }
  12979. }
  12980. , co = {
  12981. defaultOption: {
  12982. postEffect: {
  12983. enable: !1,
  12984. bloom: {
  12985. enable: !0,
  12986. intensity: .1
  12987. },
  12988. depthOfField: {
  12989. enable: !1,
  12990. focalRange: 20,
  12991. focalDistance: 50,
  12992. blurRadius: 10,
  12993. fstop: 2.8,
  12994. quality: "medium"
  12995. },
  12996. screenSpaceAmbientOcclusion: {
  12997. enable: !1,
  12998. radius: 2,
  12999. quality: "medium",
  13000. intensity: 1
  13001. },
  13002. screenSpaceReflection: {
  13003. enable: !1,
  13004. quality: "medium",
  13005. maxRoughness: .8
  13006. },
  13007. colorCorrection: {
  13008. enable: !0,
  13009. exposure: 0,
  13010. brightness: 0,
  13011. contrast: 1,
  13012. saturation: 1,
  13013. lookupTexture: ""
  13014. },
  13015. edge: {
  13016. enable: !1
  13017. },
  13018. FXAA: {
  13019. enable: !1
  13020. }
  13021. },
  13022. temporalSuperSampling: {
  13023. enable: "auto"
  13024. }
  13025. }
  13026. }
  13027. , fo = {
  13028. defaultOption: {
  13029. light: {
  13030. main: {
  13031. shadow: !1,
  13032. shadowQuality: "high",
  13033. color: "#fff",
  13034. intensity: 1,
  13035. alpha: 0,
  13036. beta: 0
  13037. },
  13038. ambient: {
  13039. color: "#fff",
  13040. intensity: .2
  13041. },
  13042. ambientCubemap: {
  13043. texture: null,
  13044. exposure: 1,
  13045. diffuseIntensity: .5,
  13046. specularIntensity: .5
  13047. }
  13048. }
  13049. }
  13050. };
  13051. var po = i.ComponentModel.extend({
  13052. type: "grid3D",
  13053. dependencies: ["xAxis3D", "yAxis3D", "zAxis3D"],
  13054. defaultOption: {
  13055. show: !0,
  13056. zlevel: -10,
  13057. left: 0,
  13058. top: 0,
  13059. width: "100%",
  13060. height: "100%",
  13061. environment: "auto",
  13062. boxWidth: 100,
  13063. boxHeight: 100,
  13064. boxDepth: 100,
  13065. axisPointer: {
  13066. show: !0,
  13067. lineStyle: {
  13068. color: "rgba(0, 0, 0, 0.8)",
  13069. width: 1
  13070. },
  13071. label: {
  13072. show: !0,
  13073. formatter: null,
  13074. margin: 8,
  13075. textStyle: {
  13076. fontSize: 14,
  13077. color: "#fff",
  13078. backgroundColor: "rgba(0,0,0,0.5)",
  13079. padding: 3,
  13080. borderRadius: 3
  13081. }
  13082. }
  13083. },
  13084. axisLine: {
  13085. show: !0,
  13086. lineStyle: {
  13087. color: "#333",
  13088. width: 2,
  13089. type: "solid"
  13090. }
  13091. },
  13092. axisTick: {
  13093. show: !0,
  13094. inside: !1,
  13095. length: 3,
  13096. lineStyle: {
  13097. width: 1
  13098. }
  13099. },
  13100. axisLabel: {
  13101. show: !0,
  13102. inside: !1,
  13103. rotate: 0,
  13104. margin: 8,
  13105. textStyle: {
  13106. fontSize: 12
  13107. }
  13108. },
  13109. splitLine: {
  13110. show: !0,
  13111. lineStyle: {
  13112. color: ["#ccc"],
  13113. width: 1,
  13114. type: "solid"
  13115. }
  13116. },
  13117. splitArea: {
  13118. show: !1,
  13119. areaStyle: {
  13120. color: ["rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)"]
  13121. }
  13122. },
  13123. light: {
  13124. main: {
  13125. alpha: 30,
  13126. beta: 40
  13127. },
  13128. ambient: {
  13129. intensity: .4
  13130. }
  13131. },
  13132. viewControl: {
  13133. alpha: 20,
  13134. beta: 40,
  13135. autoRotate: !1,
  13136. distance: 200,
  13137. minDistance: 40,
  13138. maxDistance: 400
  13139. }
  13140. }
  13141. });
  13142. i.util.merge(po.prototype, uo),
  13143. i.util.merge(po.prototype, co),
  13144. i.util.merge(po.prototype, fo);
  13145. const mo = po;
  13146. function go(e, t) {
  13147. switch (e) {
  13148. case "center":
  13149. case "middle":
  13150. e = "50%";
  13151. break;
  13152. case "left":
  13153. case "top":
  13154. e = "0%";
  13155. break;
  13156. case "right":
  13157. case "bottom":
  13158. e = "100%"
  13159. }
  13160. return "string" == typeof e ? (r = e,
  13161. r.replace(/^\s+|\s+$/g, "")).match(/%$/) ? parseFloat(e) / 100 * t : parseFloat(e) : null == e ? NaN : +e;
  13162. var r
  13163. }
  13164. function _o() {
  13165. var e = "__ec_inner_" + vo++;
  13166. return function (t) {
  13167. return t[e] || (t[e] = {})
  13168. }
  13169. }
  13170. var vo = Math.round(9 * Math.random())
  13171. , yo = {};
  13172. function xo(e, t, r, i, n) {
  13173. var a = {};
  13174. return function (e, t, r, i, n) {
  13175. r = r || yo;
  13176. var a, o = t.ecModel, s = o && o.option.textStyle, l = function (e) {
  13177. for (var t; e && e !== e.ecModel;) {
  13178. var r = (e.option || yo).rich;
  13179. if (r) {
  13180. t = t || {};
  13181. for (var i = ba(r), n = 0; n < i.length; n++)
  13182. t[i[n]] = 1
  13183. }
  13184. e = e.parentModel
  13185. }
  13186. return t
  13187. }(t);
  13188. if (l)
  13189. for (var h in a = {},
  13190. l)
  13191. if (l.hasOwnProperty(h)) {
  13192. var u = t.getModel(["rich", h]);
  13193. So(a[h] = {}, u, s, r, i, n, !1, !0)
  13194. }
  13195. a && (e.rich = a);
  13196. var c = t.get("overflow");
  13197. c && (e.overflow = c);
  13198. var d = t.get("minMargin");
  13199. null != d && (e.margin = d),
  13200. So(e, t, s, r, i, n, !0, !1)
  13201. }(a, e, r, i, n),
  13202. t && ga(a, t),
  13203. a
  13204. }
  13205. var bo = ["fontStyle", "fontWeight", "fontSize", "fontFamily", "textShadowColor", "textShadowBlur", "textShadowOffsetX", "textShadowOffsetY"]
  13206. , wo = ["align", "lineHeight", "width", "height", "tag", "verticalAlign"]
  13207. , To = ["padding", "borderWidth", "borderRadius", "borderDashOffset", "backgroundColor", "borderColor", "shadowColor", "shadowBlur", "shadowOffsetX", "shadowOffsetY"];
  13208. function So(e, t, r, i, n, a, o, s) {
  13209. r = !n && r || yo;
  13210. var l = i && i.inheritColor
  13211. , h = t.getShallow("color")
  13212. , u = t.getShallow("textBorderColor")
  13213. , c = Ta(t.getShallow("opacity"), r.opacity);
  13214. "inherit" !== h && "auto" !== h || (h = l || null),
  13215. "inherit" !== u && "auto" !== u || (u = l || null),
  13216. a || (h = h || r.color,
  13217. u = u || r.textBorderColor),
  13218. null != h && (e.fill = h),
  13219. null != u && (e.stroke = u);
  13220. var d = Ta(t.getShallow("textBorderWidth"), r.textBorderWidth);
  13221. null != d && (e.lineWidth = d);
  13222. var f = Ta(t.getShallow("textBorderType"), r.textBorderType);
  13223. null != f && (e.lineDash = f);
  13224. var p = Ta(t.getShallow("textBorderDashOffset"), r.textBorderDashOffset);
  13225. null != p && (e.lineDashOffset = p),
  13226. n || null != c || s || (c = i && i.defaultOpacity),
  13227. null != c && (e.opacity = c),
  13228. n || a || null == e.fill && i.inheritColor && (e.fill = i.inheritColor);
  13229. for (var m = 0; m < bo.length; m++) {
  13230. var g = bo[m];
  13231. null != (v = Ta(t.getShallow(g), r[g])) && (e[g] = v)
  13232. }
  13233. for (m = 0; m < wo.length; m++)
  13234. g = wo[m],
  13235. null != (v = t.getShallow(g)) && (e[g] = v);
  13236. if (null == e.verticalAlign) {
  13237. var _ = t.getShallow("baseline");
  13238. null != _ && (e.verticalAlign = _)
  13239. }
  13240. if (!o || !i.disableBox) {
  13241. for (m = 0; m < To.length; m++) {
  13242. var v;
  13243. g = To[m],
  13244. null != (v = t.getShallow(g)) && (e[g] = v)
  13245. }
  13246. var y = t.getShallow("borderType");
  13247. null != y && (e.borderDash = y),
  13248. "auto" !== e.backgroundColor && "inherit" !== e.backgroundColor || !l || (e.backgroundColor = l),
  13249. "auto" !== e.borderColor && "inherit" !== e.borderColor || !l || (e.borderColor = l)
  13250. }
  13251. }
  13252. _o();
  13253. var Mo = Mn
  13254. , Ao = {
  13255. left: 0,
  13256. middle: 1,
  13257. right: 2
  13258. };
  13259. function Eo(e) {
  13260. return e instanceof Array || (e = [e, e]),
  13261. e
  13262. }
  13263. var Co = m.extend((function () {
  13264. return {
  13265. zr: null,
  13266. viewGL: null,
  13267. _center: new vt,
  13268. minDistance: .5,
  13269. maxDistance: 1.5,
  13270. maxOrthographicSize: 300,
  13271. minOrthographicSize: 30,
  13272. minAlpha: -90,
  13273. maxAlpha: 90,
  13274. minBeta: -1 / 0,
  13275. maxBeta: 1 / 0,
  13276. autoRotateAfterStill: 0,
  13277. autoRotateDirection: "cw",
  13278. autoRotateSpeed: 60,
  13279. damping: .8,
  13280. rotateSensitivity: 1,
  13281. zoomSensitivity: 1,
  13282. panSensitivity: 1,
  13283. panMouseButton: "middle",
  13284. rotateMouseButton: "left",
  13285. _mode: "rotate",
  13286. _camera: null,
  13287. _needsUpdate: !1,
  13288. _rotating: !1,
  13289. _phi: 0,
  13290. _theta: 0,
  13291. _mouseX: 0,
  13292. _mouseY: 0,
  13293. _rotateVelocity: new _e,
  13294. _panVelocity: new _e,
  13295. _distance: 500,
  13296. _zoomSpeed: 0,
  13297. _stillTimeout: 0,
  13298. _animators: []
  13299. }
  13300. }
  13301. ), (function () {
  13302. ["_mouseDownHandler", "_mouseWheelHandler", "_mouseMoveHandler", "_mouseUpHandler", "_pinchHandler", "_contextMenuHandler", "_update"].forEach((function (e) {
  13303. this[e] = this[e].bind(this)
  13304. }
  13305. ), this)
  13306. }
  13307. ), {
  13308. init: function () {
  13309. var e = this.zr;
  13310. e && (e.on("mousedown", this._mouseDownHandler),
  13311. e.on("globalout", this._mouseUpHandler),
  13312. e.on("mousewheel", this._mouseWheelHandler),
  13313. e.on("pinch", this._pinchHandler),
  13314. e.animation.on("frame", this._update),
  13315. e.dom.addEventListener("contextmenu", this._contextMenuHandler))
  13316. },
  13317. dispose: function () {
  13318. var e = this.zr;
  13319. e && (e.off("mousedown", this._mouseDownHandler),
  13320. e.off("mousemove", this._mouseMoveHandler),
  13321. e.off("mouseup", this._mouseUpHandler),
  13322. e.off("mousewheel", this._mouseWheelHandler),
  13323. e.off("pinch", this._pinchHandler),
  13324. e.off("globalout", this._mouseUpHandler),
  13325. e.dom.removeEventListener("contextmenu", this._contextMenuHandler),
  13326. e.animation.off("frame", this._update)),
  13327. this.stopAllAnimation()
  13328. },
  13329. getDistance: function () {
  13330. return this._distance
  13331. },
  13332. setDistance: function (e) {
  13333. this._distance = e,
  13334. this._needsUpdate = !0
  13335. },
  13336. getOrthographicSize: function () {
  13337. return this._orthoSize
  13338. },
  13339. setOrthographicSize: function (e) {
  13340. this._orthoSize = e,
  13341. this._needsUpdate = !0
  13342. },
  13343. getAlpha: function () {
  13344. return this._theta / Math.PI * 180
  13345. },
  13346. getBeta: function () {
  13347. return -this._phi / Math.PI * 180
  13348. },
  13349. getCenter: function () {
  13350. return this._center.toArray()
  13351. },
  13352. setAlpha: function (e) {
  13353. e = Math.max(Math.min(this.maxAlpha, e), this.minAlpha),
  13354. this._theta = e / 180 * Math.PI,
  13355. this._needsUpdate = !0
  13356. },
  13357. setBeta: function (e) {
  13358. e = Math.max(Math.min(this.maxBeta, e), this.minBeta),
  13359. this._phi = -e / 180 * Math.PI,
  13360. this._needsUpdate = !0
  13361. },
  13362. setCenter: function (e) {
  13363. this._center.setArray(e)
  13364. },
  13365. setViewGL: function (e) {
  13366. this.viewGL = e
  13367. },
  13368. getCamera: function () {
  13369. return this.viewGL.camera
  13370. },
  13371. setFromViewControlModel: function (e, t) {
  13372. var r = (t = t || {}).baseDistance || 0
  13373. , i = t.baseOrthoSize || 1
  13374. , n = e.get("projection");
  13375. "perspective" !== n && "orthographic" !== n && "isometric" !== n && (n = "perspective"),
  13376. this._projection = n,
  13377. this.viewGL.setProjection(n);
  13378. var a = e.get("distance") + r
  13379. , o = e.get("orthographicSize") + i;
  13380. [["damping", .8], ["autoRotate", !1], ["autoRotateAfterStill", 3], ["autoRotateDirection", "cw"], ["autoRotateSpeed", 10], ["minDistance", 30], ["maxDistance", 400], ["minOrthographicSize", 30], ["maxOrthographicSize", 300], ["minAlpha", -90], ["maxAlpha", 90], ["minBeta", -1 / 0], ["maxBeta", 1 / 0], ["rotateSensitivity", 1], ["zoomSensitivity", 1], ["panSensitivity", 1], ["panMouseButton", "left"], ["rotateMouseButton", "middle"]].forEach((function (t) {
  13381. this[t[0]] = Mo(e.get(t[0]), t[1])
  13382. }
  13383. ), this),
  13384. this.minDistance += r,
  13385. this.maxDistance += r,
  13386. this.minOrthographicSize += i,
  13387. this.maxOrthographicSize += i;
  13388. var s = e.ecModel
  13389. , l = {};
  13390. ["animation", "animationDurationUpdate", "animationEasingUpdate"].forEach((function (t) {
  13391. l[t] = Mo(e.get(t), s && s.get(t))
  13392. }
  13393. ));
  13394. var h = Mo(t.alpha, e.get("alpha")) || 0
  13395. , u = Mo(t.beta, e.get("beta")) || 0
  13396. , c = Mo(t.center, e.get("center")) || [0, 0, 0];
  13397. l.animation && l.animationDurationUpdate > 0 && this._notFirst ? this.animateTo({
  13398. alpha: h,
  13399. beta: u,
  13400. center: c,
  13401. distance: a,
  13402. orthographicSize: o,
  13403. easing: l.animationEasingUpdate,
  13404. duration: l.animationDurationUpdate
  13405. }) : (this.setDistance(a),
  13406. this.setAlpha(h),
  13407. this.setBeta(u),
  13408. this.setCenter(c),
  13409. this.setOrthographicSize(o)),
  13410. this._notFirst = !0,
  13411. this._validateProperties()
  13412. },
  13413. _validateProperties: function () { },
  13414. animateTo: function (e) {
  13415. var t = this.zr
  13416. , r = this
  13417. , i = {}
  13418. , n = {};
  13419. return null != e.distance && (i.distance = this.getDistance(),
  13420. n.distance = e.distance),
  13421. null != e.orthographicSize && (i.orthographicSize = this.getOrthographicSize(),
  13422. n.orthographicSize = e.orthographicSize),
  13423. null != e.alpha && (i.alpha = this.getAlpha(),
  13424. n.alpha = e.alpha),
  13425. null != e.beta && (i.beta = this.getBeta(),
  13426. n.beta = e.beta),
  13427. null != e.center && (i.center = this.getCenter(),
  13428. n.center = e.center),
  13429. this._addAnimator(t.animation.animate(i).when(e.duration || 1e3, n).during((function () {
  13430. null != i.alpha && r.setAlpha(i.alpha),
  13431. null != i.beta && r.setBeta(i.beta),
  13432. null != i.distance && r.setDistance(i.distance),
  13433. null != i.center && r.setCenter(i.center),
  13434. null != i.orthographicSize && r.setOrthographicSize(i.orthographicSize),
  13435. r._needsUpdate = !0
  13436. }
  13437. ))).start(e.easing || "linear")
  13438. },
  13439. stopAllAnimation: function () {
  13440. for (var e = 0; e < this._animators.length; e++)
  13441. this._animators[e].stop();
  13442. this._animators.length = 0
  13443. },
  13444. update: function () {
  13445. this._needsUpdate = !0,
  13446. this._update(20)
  13447. },
  13448. _isAnimating: function () {
  13449. return this._animators.length > 0
  13450. },
  13451. _update: function (e) {
  13452. if (this._rotating) {
  13453. var t = ("cw" === this.autoRotateDirection ? 1 : -1) * this.autoRotateSpeed / 180 * Math.PI;
  13454. this._phi -= t * e / 1e3,
  13455. this._needsUpdate = !0
  13456. } else
  13457. this._rotateVelocity.len() > 0 && (this._needsUpdate = !0);
  13458. (Math.abs(this._zoomSpeed) > .1 || this._panVelocity.len() > 0) && (this._needsUpdate = !0),
  13459. this._needsUpdate && (e = Math.min(e, 50),
  13460. this._updateDistanceOrSize(e),
  13461. this._updatePan(e),
  13462. this._updateRotate(e),
  13463. this._updateTransform(),
  13464. this.getCamera().update(),
  13465. this.zr && this.zr.refresh(),
  13466. this.trigger("update"),
  13467. this._needsUpdate = !1)
  13468. },
  13469. _updateRotate: function (e) {
  13470. var t = this._rotateVelocity;
  13471. this._phi = t.y * e / 20 + this._phi,
  13472. this._theta = t.x * e / 20 + this._theta,
  13473. this.setAlpha(this.getAlpha()),
  13474. this.setBeta(this.getBeta()),
  13475. this._vectorDamping(t, Math.pow(this.damping, e / 16))
  13476. },
  13477. _updateDistanceOrSize: function (e) {
  13478. "perspective" === this._projection ? this._setDistance(this._distance + this._zoomSpeed * e / 20) : this._setOrthoSize(this._orthoSize + this._zoomSpeed * e / 20),
  13479. this._zoomSpeed *= Math.pow(this.damping, e / 16)
  13480. },
  13481. _setDistance: function (e) {
  13482. this._distance = Math.max(Math.min(e, this.maxDistance), this.minDistance)
  13483. },
  13484. _setOrthoSize: function (e) {
  13485. this._orthoSize = Math.max(Math.min(e, this.maxOrthographicSize), this.minOrthographicSize);
  13486. var t = this.getCamera()
  13487. , r = this._orthoSize
  13488. , i = r / this.viewGL.viewport.height * this.viewGL.viewport.width;
  13489. t.left = -i / 2,
  13490. t.right = i / 2,
  13491. t.top = r / 2,
  13492. t.bottom = -r / 2
  13493. },
  13494. _updatePan: function (e) {
  13495. var t = this._panVelocity
  13496. , r = this._distance
  13497. , i = this.getCamera()
  13498. , n = i.worldTransform.y
  13499. , a = i.worldTransform.x;
  13500. this._center.scaleAndAdd(a, -t.x * r / 200).scaleAndAdd(n, -t.y * r / 200),
  13501. this._vectorDamping(t, 0)
  13502. },
  13503. _updateTransform: function () {
  13504. var e = this.getCamera()
  13505. , t = new vt
  13506. , r = this._theta + Math.PI / 2
  13507. , i = this._phi + Math.PI / 2
  13508. , n = Math.sin(r);
  13509. t.x = n * Math.cos(i),
  13510. t.y = -Math.cos(r),
  13511. t.z = n * Math.sin(i),
  13512. e.position.copy(this._center).scaleAndAdd(t, this._distance),
  13513. e.rotation.identity().rotateY(-this._phi).rotateX(-this._theta)
  13514. },
  13515. _startCountingStill: function () {
  13516. clearTimeout(this._stillTimeout);
  13517. var e = this.autoRotateAfterStill
  13518. , t = this;
  13519. !isNaN(e) && e > 0 && (this._stillTimeout = setTimeout((function () {
  13520. t._rotating = !0
  13521. }
  13522. ), 1e3 * e))
  13523. },
  13524. _vectorDamping: function (e, t) {
  13525. var r = e.len();
  13526. (r *= t) < 1e-4 && (r = 0),
  13527. e.normalize().scale(r)
  13528. },
  13529. _decomposeTransform: function () {
  13530. if (this.getCamera()) {
  13531. this.getCamera().updateWorldTransform();
  13532. var e = this.getCamera().worldTransform.z
  13533. , t = Math.asin(e.y)
  13534. , r = Math.atan2(e.x, e.z);
  13535. this._theta = t,
  13536. this._phi = -r,
  13537. this.setBeta(this.getBeta()),
  13538. this.setAlpha(this.getAlpha()),
  13539. this.getCamera().aspect ? this._setDistance(this.getCamera().position.dist(this._center)) : this._setOrthoSize(this.getCamera().top - this.getCamera().bottom)
  13540. }
  13541. },
  13542. _mouseDownHandler: function (e) {
  13543. if (!e.target && !this._isAnimating()) {
  13544. var t = e.offsetX
  13545. , r = e.offsetY;
  13546. this.viewGL && !this.viewGL.containPoint(t, r) || (this.zr.on("mousemove", this._mouseMoveHandler),
  13547. this.zr.on("mouseup", this._mouseUpHandler),
  13548. e.event.targetTouches ? 1 === e.event.targetTouches.length && (this._mode = "rotate") : e.event.button === Ao[this.rotateMouseButton] ? this._mode = "rotate" : e.event.button === Ao[this.panMouseButton] ? this._mode = "pan" : this._mode = "",
  13549. this._rotateVelocity.set(0, 0),
  13550. this._rotating = !1,
  13551. this.autoRotate && this._startCountingStill(),
  13552. this._mouseX = e.offsetX,
  13553. this._mouseY = e.offsetY)
  13554. }
  13555. },
  13556. _mouseMoveHandler: function (e) {
  13557. if (!(e.target && e.target.__isGLToZRProxy || this._isAnimating())) {
  13558. var t = Eo(this.panSensitivity)
  13559. , r = Eo(this.rotateSensitivity);
  13560. "rotate" === this._mode ? (this._rotateVelocity.y = (e.offsetX - this._mouseX) / this.zr.getHeight() * 2 * r[0],
  13561. this._rotateVelocity.x = (e.offsetY - this._mouseY) / this.zr.getWidth() * 2 * r[1]) : "pan" === this._mode && (this._panVelocity.x = (e.offsetX - this._mouseX) / this.zr.getWidth() * t[0] * 400,
  13562. this._panVelocity.y = (-e.offsetY + this._mouseY) / this.zr.getHeight() * t[1] * 400),
  13563. this._mouseX = e.offsetX,
  13564. this._mouseY = e.offsetY,
  13565. e.event.preventDefault()
  13566. }
  13567. },
  13568. _mouseWheelHandler: function (e) {
  13569. if (!this._isAnimating()) {
  13570. var t = e.event.wheelDelta || -e.event.detail;
  13571. this._zoomHandler(e, t)
  13572. }
  13573. },
  13574. _pinchHandler: function (e) {
  13575. this._isAnimating() || (this._zoomHandler(e, e.pinchScale > 1 ? 1 : -1),
  13576. this._mode = "")
  13577. },
  13578. _zoomHandler: function (e, t) {
  13579. if (0 !== t) {
  13580. var r, i = e.offsetX, n = e.offsetY;
  13581. this.viewGL && !this.viewGL.containPoint(i, n) || (r = "perspective" === this._projection ? Math.max(Math.max(Math.min(this._distance - this.minDistance, this.maxDistance - this._distance)) / 20, .5) : Math.max(Math.max(Math.min(this._orthoSize - this.minOrthographicSize, this.maxOrthographicSize - this._orthoSize)) / 20, .5),
  13582. this._zoomSpeed = (t > 0 ? -1 : 1) * r * this.zoomSensitivity,
  13583. this._rotating = !1,
  13584. this.autoRotate && "rotate" === this._mode && this._startCountingStill(),
  13585. e.event.preventDefault())
  13586. }
  13587. },
  13588. _mouseUpHandler: function () {
  13589. this.zr.off("mousemove", this._mouseMoveHandler),
  13590. this.zr.off("mouseup", this._mouseUpHandler)
  13591. },
  13592. _isRightMouseButtonUsed: function () {
  13593. return "right" === this.rotateMouseButton || "right" === this.panMouseButton
  13594. },
  13595. _contextMenuHandler: function (e) {
  13596. this._isRightMouseButtonUsed() && e.preventDefault()
  13597. },
  13598. _addAnimator: function (e) {
  13599. var t = this._animators;
  13600. return t.push(e),
  13601. e.done((function () {
  13602. var r = t.indexOf(e);
  13603. r >= 0 && t.splice(r, 1)
  13604. }
  13605. )),
  13606. e
  13607. }
  13608. });
  13609. Object.defineProperty(Co.prototype, "autoRotate", {
  13610. get: function (e) {
  13611. return this._autoRotate
  13612. },
  13613. set: function (e) {
  13614. this._autoRotate = e,
  13615. this._rotating = e
  13616. }
  13617. });
  13618. const Do = Co
  13619. , Lo = {
  13620. convertToDynamicArray: function (e) {
  13621. e && this.resetOffset();
  13622. var t = this.attributes;
  13623. for (var r in t)
  13624. e || !t[r].value ? t[r].value = [] : t[r].value = Array.prototype.slice.call(t[r].value);
  13625. e || !this.indices ? this.indices = [] : this.indices = Array.prototype.slice.call(this.indices)
  13626. },
  13627. convertToTypedArray: function () {
  13628. var e = this.attributes;
  13629. for (var t in e)
  13630. e[t].value && e[t].value.length > 0 ? e[t].value = new Float32Array(e[t].value) : e[t].value = null;
  13631. this.indices && this.indices.length > 0 && (this.indices = this.vertexCount > 65535 ? new Uint32Array(this.indices) : new Uint16Array(this.indices)),
  13632. this.dirty()
  13633. }
  13634. }
  13635. , Po = {
  13636. vec2: pe,
  13637. vec3: Qe,
  13638. vec4: Et,
  13639. mat2: Fn,
  13640. mat2d: kn,
  13641. mat3: Dt,
  13642. mat4: Ye,
  13643. quat: Rt
  13644. };
  13645. var Oo = Po.vec3
  13646. , No = [[0, 0], [1, 1]]
  13647. , Io = Vr.extend((function () {
  13648. return {
  13649. segmentScale: 1,
  13650. dynamic: !0,
  13651. useNativeLine: !0,
  13652. attributes: {
  13653. position: new Vr.Attribute("position", "float", 3, "POSITION"),
  13654. positionPrev: new Vr.Attribute("positionPrev", "float", 3),
  13655. positionNext: new Vr.Attribute("positionNext", "float", 3),
  13656. prevPositionPrev: new Vr.Attribute("prevPositionPrev", "float", 3),
  13657. prevPosition: new Vr.Attribute("prevPosition", "float", 3),
  13658. prevPositionNext: new Vr.Attribute("prevPositionNext", "float", 3),
  13659. offset: new Vr.Attribute("offset", "float", 1),
  13660. color: new Vr.Attribute("color", "float", 4, "COLOR")
  13661. }
  13662. }
  13663. }
  13664. ), {
  13665. resetOffset: function () {
  13666. this._vertexOffset = 0,
  13667. this._triangleOffset = 0,
  13668. this._itemVertexOffsets = []
  13669. },
  13670. setVertexCount: function (e) {
  13671. var t = this.attributes;
  13672. this.vertexCount !== e && (t.position.init(e),
  13673. t.color.init(e),
  13674. this.useNativeLine || (t.positionPrev.init(e),
  13675. t.positionNext.init(e),
  13676. t.offset.init(e)),
  13677. e > 65535 ? this.indices instanceof Uint16Array && (this.indices = new Uint32Array(this.indices)) : this.indices instanceof Uint32Array && (this.indices = new Uint16Array(this.indices)))
  13678. },
  13679. setTriangleCount: function (e) {
  13680. this.triangleCount !== e && (this.indices = 0 === e ? null : this.vertexCount > 65535 ? new Uint32Array(3 * e) : new Uint16Array(3 * e))
  13681. },
  13682. _getCubicCurveApproxStep: function (e, t, r, i) {
  13683. return 1 / (Oo.dist(e, t) + Oo.dist(r, t) + Oo.dist(i, r) + 1) * this.segmentScale
  13684. },
  13685. getCubicCurveVertexCount: function (e, t, r, i) {
  13686. var n = this._getCubicCurveApproxStep(e, t, r, i)
  13687. , a = Math.ceil(1 / n);
  13688. return this.useNativeLine ? 2 * a : 2 * a + 2
  13689. },
  13690. getCubicCurveTriangleCount: function (e, t, r, i) {
  13691. var n = this._getCubicCurveApproxStep(e, t, r, i)
  13692. , a = Math.ceil(1 / n);
  13693. return this.useNativeLine ? 0 : 2 * a
  13694. },
  13695. getLineVertexCount: function () {
  13696. return this.getPolylineVertexCount(No)
  13697. },
  13698. getLineTriangleCount: function () {
  13699. return this.getPolylineTriangleCount(No)
  13700. },
  13701. getPolylineVertexCount: function (e) {
  13702. var t;
  13703. return t = "number" == typeof e ? e : "number" != typeof e[0] ? e.length : e.length / 3,
  13704. this.useNativeLine ? 2 * (t - 1) : 2 * (t - 1) + 2
  13705. },
  13706. getPolylineTriangleCount: function (e) {
  13707. var t;
  13708. return t = "number" == typeof e ? e : "number" != typeof e[0] ? e.length : e.length / 3,
  13709. this.useNativeLine ? 0 : 2 * Math.max(t - 1, 0)
  13710. },
  13711. addCubicCurve: function (e, t, r, i, n, a) {
  13712. null == a && (a = 1);
  13713. var o = e[0]
  13714. , s = e[1]
  13715. , l = e[2]
  13716. , h = t[0]
  13717. , u = t[1]
  13718. , c = t[2]
  13719. , d = r[0]
  13720. , f = r[1]
  13721. , p = r[2]
  13722. , m = i[0]
  13723. , g = i[1]
  13724. , _ = i[2]
  13725. , v = this._getCubicCurveApproxStep(e, t, r, i)
  13726. , y = v * v
  13727. , x = y * v
  13728. , b = 3 * v
  13729. , w = 3 * y
  13730. , T = 6 * y
  13731. , S = 6 * x
  13732. , M = o - 2 * h + d
  13733. , A = s - 2 * u + f
  13734. , E = l - 2 * c + p
  13735. , C = 3 * (h - d) - o + m
  13736. , D = 3 * (u - f) - s + g
  13737. , L = 3 * (c - p) - l + _
  13738. , P = o
  13739. , O = s
  13740. , N = l
  13741. , I = (h - o) * b + M * w + C * x
  13742. , R = (u - s) * b + A * w + D * x
  13743. , B = (c - l) * b + E * w + L * x
  13744. , F = M * T + C * S
  13745. , z = A * T + D * S
  13746. , G = E * T + L * S
  13747. , U = C * S
  13748. , k = D * S
  13749. , V = L * S
  13750. , H = 0
  13751. , W = 0
  13752. , j = Math.ceil(1 / v)
  13753. , X = new Float32Array(3 * (j + 1))
  13754. , q = (X = [],
  13755. 0);
  13756. for (W = 0; W < j + 1; W++)
  13757. X[q++] = P,
  13758. X[q++] = O,
  13759. X[q++] = N,
  13760. P += I,
  13761. O += R,
  13762. N += B,
  13763. I += F,
  13764. R += z,
  13765. B += G,
  13766. F += U,
  13767. z += k,
  13768. G += V,
  13769. (H += v) > 1 && (P = I > 0 ? Math.min(P, m) : Math.max(P, m),
  13770. O = R > 0 ? Math.min(O, g) : Math.max(O, g),
  13771. N = B > 0 ? Math.min(N, _) : Math.max(N, _));
  13772. return this.addPolyline(X, n, a)
  13773. },
  13774. addLine: function (e, t, r, i) {
  13775. return this.addPolyline([e, t], r, i)
  13776. },
  13777. addPolyline: function (e, t, r, i, n) {
  13778. if (e.length) {
  13779. var a = "number" != typeof e[0];
  13780. if (null == n && (n = a ? e.length : e.length / 3),
  13781. !(n < 2)) {
  13782. null == i && (i = 0),
  13783. null == r && (r = 1),
  13784. this._itemVertexOffsets.push(this._vertexOffset);
  13785. var o, s, l = (a = "number" != typeof e[0]) ? "number" != typeof t[0] : t.length / 4 === n, h = this.attributes.position, u = this.attributes.positionPrev, c = this.attributes.positionNext, d = this.attributes.color, f = this.attributes.offset, p = this.indices, m = this._vertexOffset;
  13786. r = Math.max(r, .01);
  13787. for (var g = i; g < n; g++) {
  13788. if (a)
  13789. o = e[g],
  13790. s = l ? t[g] : t;
  13791. else {
  13792. var _ = 3 * g;
  13793. if ((o = o || [])[0] = e[_],
  13794. o[1] = e[_ + 1],
  13795. o[2] = e[_ + 2],
  13796. l) {
  13797. var v = 4 * g;
  13798. (s = s || [])[0] = t[v],
  13799. s[1] = t[v + 1],
  13800. s[2] = t[v + 2],
  13801. s[3] = t[v + 3]
  13802. } else
  13803. s = t
  13804. }
  13805. if (this.useNativeLine ? g > 1 && (h.copy(m, m - 1),
  13806. d.copy(m, m - 1),
  13807. m++) : (g < n - 1 && (u.set(m + 2, o),
  13808. u.set(m + 3, o)),
  13809. g > 0 && (c.set(m - 2, o),
  13810. c.set(m - 1, o)),
  13811. h.set(m, o),
  13812. h.set(m + 1, o),
  13813. d.set(m, s),
  13814. d.set(m + 1, s),
  13815. f.set(m, r / 2),
  13816. f.set(m + 1, -r / 2),
  13817. m += 2),
  13818. this.useNativeLine)
  13819. d.set(m, s),
  13820. h.set(m, o),
  13821. m++;
  13822. else if (g > 0) {
  13823. var y = 3 * this._triangleOffset;
  13824. (p = this.indices)[y] = m - 4,
  13825. p[y + 1] = m - 3,
  13826. p[y + 2] = m - 2,
  13827. p[y + 3] = m - 3,
  13828. p[y + 4] = m - 1,
  13829. p[y + 5] = m - 2,
  13830. this._triangleOffset += 2
  13831. }
  13832. }
  13833. if (!this.useNativeLine) {
  13834. var x = this._vertexOffset
  13835. , b = this._vertexOffset + 2 * n;
  13836. u.copy(x, x + 2),
  13837. u.copy(x + 1, x + 3),
  13838. c.copy(b - 1, b - 3),
  13839. c.copy(b - 2, b - 4)
  13840. }
  13841. return this._vertexOffset = m,
  13842. this._vertexOffset
  13843. }
  13844. }
  13845. },
  13846. setItemColor: function (e, t) {
  13847. for (var r = this._itemVertexOffsets[e], i = e < this._itemVertexOffsets.length - 1 ? this._itemVertexOffsets[e + 1] : this._vertexOffset, n = r; n < i; n++)
  13848. this.attributes.color.set(n, t);
  13849. this.dirty("color")
  13850. },
  13851. currentTriangleOffset: function () {
  13852. return this._triangleOffset
  13853. },
  13854. currentVertexOffset: function () {
  13855. return this._vertexOffset
  13856. }
  13857. });
  13858. i.util.defaults(Io.prototype, Lo);
  13859. const Ro = Io;
  13860. function Bo(e, t, r, i, n, a, o) {
  13861. this._zr = e,
  13862. this._x = 0,
  13863. this._y = 0,
  13864. this._rowHeight = 0,
  13865. this.width = i,
  13866. this.height = n,
  13867. this.offsetX = t,
  13868. this.offsetY = r,
  13869. this.dpr = o,
  13870. this.gap = a
  13871. }
  13872. function Fo(e) {
  13873. (e = e || {}).width = e.width || 512,
  13874. e.height = e.height || 512,
  13875. e.devicePixelRatio = e.devicePixelRatio || 1,
  13876. e.gap = null == e.gap ? 2 : e.gap;
  13877. var t = document.createElement("canvas");
  13878. t.width = e.width * e.devicePixelRatio,
  13879. t.height = e.height * e.devicePixelRatio,
  13880. this._canvas = t,
  13881. this._texture = new Dr({
  13882. image: t,
  13883. flipY: !1
  13884. });
  13885. var r = this;
  13886. this._zr = i.zrender.init(t);
  13887. var n = this._zr.refreshImmediately;
  13888. this._zr.refreshImmediately = function () {
  13889. n.call(this),
  13890. r._texture.dirty(),
  13891. r.onupdate && r.onupdate()
  13892. }
  13893. ,
  13894. this._dpr = e.devicePixelRatio,
  13895. this._coords = {},
  13896. this.onupdate = e.onupdate,
  13897. this._gap = e.gap,
  13898. this._textureAtlasNodes = [new Bo(this._zr, 0, 0, e.width, e.height, this._gap, this._dpr)],
  13899. this._nodeWidth = e.width,
  13900. this._nodeHeight = e.height,
  13901. this._currentNodeIdx = 0
  13902. }
  13903. Bo.prototype = {
  13904. constructor: Bo,
  13905. clear: function () {
  13906. this._x = 0,
  13907. this._y = 0,
  13908. this._rowHeight = 0
  13909. },
  13910. add: function (e, t, r) {
  13911. var i = e.getBoundingRect();
  13912. null == t && (t = i.width),
  13913. null == r && (r = i.height),
  13914. t *= this.dpr,
  13915. r *= this.dpr,
  13916. this._fitElement(e, t, r);
  13917. var n = this._x
  13918. , a = this._y
  13919. , o = this.width * this.dpr
  13920. , s = this.height * this.dpr
  13921. , l = this.gap;
  13922. if (n + t + l > o && (n = this._x = 0,
  13923. a += this._rowHeight + l,
  13924. this._y = a,
  13925. this._rowHeight = 0),
  13926. this._x += t + l,
  13927. this._rowHeight = Math.max(this._rowHeight, r),
  13928. a + r + l > s)
  13929. return null;
  13930. e.x += this.offsetX * this.dpr + n,
  13931. e.y += this.offsetY * this.dpr + a,
  13932. this._zr.add(e);
  13933. var h = [this.offsetX / this.width, this.offsetY / this.height];
  13934. return [[n / o + h[0], a / s + h[1]], [(n + t) / o + h[0], (a + r) / s + h[1]]]
  13935. },
  13936. _fitElement: function (e, t, r) {
  13937. var i = e.getBoundingRect()
  13938. , n = t / i.width
  13939. , a = r / i.height;
  13940. e.x = -i.x * n,
  13941. e.y = -i.y * a,
  13942. e.scaleX = n,
  13943. e.scaleY = a,
  13944. e.update()
  13945. }
  13946. },
  13947. Fo.prototype = {
  13948. clear: function () {
  13949. for (var e = 0; e < this._textureAtlasNodes.length; e++)
  13950. this._textureAtlasNodes[e].clear();
  13951. this._currentNodeIdx = 0,
  13952. this._zr.clear(),
  13953. this._coords = {}
  13954. },
  13955. getWidth: function () {
  13956. return this._width
  13957. },
  13958. getHeight: function () {
  13959. return this._height
  13960. },
  13961. getTexture: function () {
  13962. return this._texture
  13963. },
  13964. getDevicePixelRatio: function () {
  13965. return this._dpr
  13966. },
  13967. getZr: function () {
  13968. return this._zr
  13969. },
  13970. _getCurrentNode: function () {
  13971. return this._textureAtlasNodes[this._currentNodeIdx]
  13972. },
  13973. _expand: function () {
  13974. if (this._currentNodeIdx++,
  13975. this._textureAtlasNodes[this._currentNodeIdx])
  13976. return this._textureAtlasNodes[this._currentNodeIdx];
  13977. var e = 4096 / this._dpr
  13978. , t = this._textureAtlasNodes.length
  13979. , r = t * this._nodeWidth % e
  13980. , i = Math.floor(t * this._nodeWidth / e) * this._nodeHeight;
  13981. if (!(i >= e)) {
  13982. var n = (r + this._nodeWidth) * this._dpr
  13983. , a = (i + this._nodeHeight) * this._dpr;
  13984. try {
  13985. this._zr.resize({
  13986. width: n,
  13987. height: a
  13988. })
  13989. } catch (e) {
  13990. this._canvas.width = n,
  13991. this._canvas.height = a
  13992. }
  13993. var o = new Bo(this._zr, r, i, this._nodeWidth, this._nodeHeight, this._gap, this._dpr);
  13994. return this._textureAtlasNodes.push(o),
  13995. o
  13996. }
  13997. },
  13998. add: function (e, t, r) {
  13999. if (this._coords[e.id])
  14000. return this._coords[e.id];
  14001. var i = this._getCurrentNode().add(e, t, r);
  14002. if (!i) {
  14003. var n = this._expand();
  14004. if (!n)
  14005. return;
  14006. i = n.add(e, t, r)
  14007. }
  14008. return this._coords[e.id] = i,
  14009. i
  14010. },
  14011. getCoordsScale: function () {
  14012. var e = this._dpr;
  14013. return [this._nodeWidth / this._canvas.width * e, this._nodeHeight / this._canvas.height * e]
  14014. },
  14015. getCoords: function (e) {
  14016. return this._coords[e]
  14017. },
  14018. dispose: function () {
  14019. this._zr.dispose()
  14020. }
  14021. };
  14022. const zo = Fo;
  14023. function Go() { }
  14024. Go.prototype = {
  14025. constructor: Go,
  14026. setScene: function (e) {
  14027. this._scene = e,
  14028. this._skybox && this._skybox.attachScene(this._scene)
  14029. },
  14030. initLight: function (e) {
  14031. this._lightRoot = e,
  14032. this.mainLight = new Ka.DirectionalLight({
  14033. shadowBias: .005
  14034. }),
  14035. this.ambientLight = new Ka.AmbientLight,
  14036. e.add(this.mainLight),
  14037. e.add(this.ambientLight)
  14038. },
  14039. dispose: function () {
  14040. this._lightRoot && (this._lightRoot.remove(this.mainLight),
  14041. this._lightRoot.remove(this.ambientLight))
  14042. },
  14043. updateLight: function (e) {
  14044. var t = this.mainLight
  14045. , r = this.ambientLight
  14046. , i = e.getModel("light")
  14047. , n = i.getModel("main")
  14048. , a = i.getModel("ambient");
  14049. t.intensity = n.get("intensity"),
  14050. r.intensity = a.get("intensity"),
  14051. t.color = Ka.parseColor(n.get("color")).slice(0, 3),
  14052. r.color = Ka.parseColor(a.get("color")).slice(0, 3);
  14053. var o = n.get("alpha") || 0
  14054. , s = n.get("beta") || 0;
  14055. t.position.setArray(Ka.directionFromAlphaBeta(o, s)),
  14056. t.lookAt(Ka.Vector3.ZERO),
  14057. t.castShadow = n.get("shadow"),
  14058. t.shadowResolution = Ka.getShadowResolution(n.get("shadowQuality"))
  14059. },
  14060. updateAmbientCubemap: function (e, t, r) {
  14061. var i = t.getModel("light.ambientCubemap")
  14062. , n = i.get("texture");
  14063. if (n) {
  14064. this._cubemapLightsCache = this._cubemapLightsCache || {};
  14065. var a = this._cubemapLightsCache[n];
  14066. if (!a) {
  14067. var o = this;
  14068. a = this._cubemapLightsCache[n] = Ka.createAmbientCubemap(i.option, e, r, (function () {
  14069. o._isSkyboxFromAmbientCubemap && o._skybox.setEnvironmentMap(a.specular.cubemap),
  14070. r.getZr().refresh()
  14071. }
  14072. ))
  14073. }
  14074. this._lightRoot.add(a.diffuse),
  14075. this._lightRoot.add(a.specular),
  14076. this._currentCubemapLights = a
  14077. } else
  14078. this._currentCubemapLights && (this._lightRoot.remove(this._currentCubemapLights.diffuse),
  14079. this._lightRoot.remove(this._currentCubemapLights.specular),
  14080. this._currentCubemapLights = null)
  14081. },
  14082. updateSkybox: function (e, t, r) {
  14083. var n = t.get("environment")
  14084. , a = this
  14085. , o = (a._skybox = a._skybox || new ji,
  14086. a._skybox);
  14087. if (n && "none" !== n)
  14088. if ("auto" === n)
  14089. if (this._isSkyboxFromAmbientCubemap = !0,
  14090. this._currentCubemapLights) {
  14091. var s = this._currentCubemapLights.specular.cubemap;
  14092. o.setEnvironmentMap(s),
  14093. this._scene && o.attachScene(this._scene),
  14094. o.material.set("lod", 3)
  14095. } else
  14096. this._skybox && this._skybox.detachScene();
  14097. else if ("object" == typeof n && n.colorStops || "string" == typeof n && i.color.parse(n)) {
  14098. this._isSkyboxFromAmbientCubemap = !1;
  14099. var l = new Ka.Texture2D({
  14100. anisotropic: 8,
  14101. flipY: !1
  14102. });
  14103. o.setEnvironmentMap(l);
  14104. var h = l.image = document.createElement("canvas");
  14105. h.width = h.height = 16;
  14106. var u = h.getContext("2d")
  14107. , c = new i.graphic.Rect({
  14108. shape: {
  14109. x: 0,
  14110. y: 0,
  14111. width: 16,
  14112. height: 16
  14113. },
  14114. style: {
  14115. fill: n
  14116. }
  14117. });
  14118. i.innerDrawElementOnCanvas(u, c),
  14119. o.attachScene(this._scene)
  14120. } else
  14121. this._isSkyboxFromAmbientCubemap = !1,
  14122. l = Ka.loadTexture(n, r, {
  14123. anisotropic: 8,
  14124. flipY: !1
  14125. }),
  14126. o.setEnvironmentMap(l),
  14127. o.attachScene(this._scene);
  14128. else
  14129. this._skybox && this._skybox.detachScene(this._scene),
  14130. this._skybox = null;
  14131. var d = t.coordinateSystem;
  14132. if (this._skybox)
  14133. if (!d || !d.viewGL || "auto" === n || n.match && n.match(/.hdr$/))
  14134. this._skybox.material.undefine("fragment", "SRGB_DECODE");
  14135. else {
  14136. var f = d.viewGL.isLinearSpace() ? "define" : "undefine";
  14137. this._skybox.material[f]("fragment", "SRGB_DECODE")
  14138. }
  14139. }
  14140. };
  14141. const Uo = Go;
  14142. var ko = Po.vec3
  14143. , Vo = Vr.extend((function () {
  14144. return {
  14145. segmentScale: 1,
  14146. useNativeLine: !0,
  14147. attributes: {
  14148. position: new Vr.Attribute("position", "float", 3, "POSITION"),
  14149. normal: new Vr.Attribute("normal", "float", 3, "NORMAL"),
  14150. color: new Vr.Attribute("color", "float", 4, "COLOR")
  14151. }
  14152. }
  14153. }
  14154. ), {
  14155. resetOffset: function () {
  14156. this._vertexOffset = 0,
  14157. this._faceOffset = 0
  14158. },
  14159. setQuadCount: function (e) {
  14160. var t = this.attributes
  14161. , r = this.getQuadVertexCount() * e
  14162. , i = this.getQuadTriangleCount() * e;
  14163. this.vertexCount !== r && (t.position.init(r),
  14164. t.normal.init(r),
  14165. t.color.init(r)),
  14166. this.triangleCount !== i && (this.indices = r > 65535 ? new Uint32Array(3 * i) : new Uint16Array(3 * i))
  14167. },
  14168. getQuadVertexCount: function () {
  14169. return 4
  14170. },
  14171. getQuadTriangleCount: function () {
  14172. return 2
  14173. },
  14174. addQuad: function () {
  14175. var e = ko.create()
  14176. , t = ko.create()
  14177. , r = ko.create()
  14178. , i = [0, 3, 1, 3, 2, 1];
  14179. return function (n, a) {
  14180. var o = this.attributes.position
  14181. , s = this.attributes.normal
  14182. , l = this.attributes.color;
  14183. ko.sub(e, n[1], n[0]),
  14184. ko.sub(t, n[2], n[1]),
  14185. ko.cross(r, e, t),
  14186. ko.normalize(r, r);
  14187. for (var h = 0; h < 4; h++)
  14188. o.set(this._vertexOffset + h, n[h]),
  14189. l.set(this._vertexOffset + h, a),
  14190. s.set(this._vertexOffset + h, r);
  14191. var u = 3 * this._faceOffset;
  14192. for (h = 0; h < 6; h++)
  14193. this.indices[u + h] = i[h] + this._vertexOffset;
  14194. this._vertexOffset += 4,
  14195. this._faceOffset += 2
  14196. }
  14197. }()
  14198. });
  14199. i.util.defaults(Vo.prototype, Lo);
  14200. const Ho = Vo;
  14201. var Wo = Mn
  14202. , jo = {
  14203. x: 0,
  14204. y: 2,
  14205. z: 1
  14206. };
  14207. function Xo(e, t, r) {
  14208. this.rootNode = new Ka.Node;
  14209. var i = new Ka.Mesh({
  14210. geometry: new Ro({
  14211. useNativeLine: !1
  14212. }),
  14213. material: t,
  14214. castShadow: !1,
  14215. ignorePicking: !0,
  14216. $ignorePicking: !0,
  14217. renderOrder: 1
  14218. })
  14219. , n = new Ka.Mesh({
  14220. geometry: new Ho,
  14221. material: r,
  14222. castShadow: !1,
  14223. culling: !1,
  14224. ignorePicking: !0,
  14225. $ignorePicking: !0,
  14226. renderOrder: 0
  14227. });
  14228. this.rootNode.add(n),
  14229. this.rootNode.add(i),
  14230. this.faceInfo = e,
  14231. this.plane = new Ka.Plane,
  14232. this.linesMesh = i,
  14233. this.quadsMesh = n
  14234. }
  14235. Xo.prototype.update = function (e, t, r) {
  14236. var i = e.coordinateSystem
  14237. , n = [i.getAxis(this.faceInfo[0]), i.getAxis(this.faceInfo[1])]
  14238. , a = this.linesMesh.geometry
  14239. , o = this.quadsMesh.geometry;
  14240. a.convertToDynamicArray(!0),
  14241. o.convertToDynamicArray(!0),
  14242. this._updateSplitLines(a, n, e, r),
  14243. this._udpateSplitAreas(o, n, e, r),
  14244. a.convertToTypedArray(),
  14245. o.convertToTypedArray();
  14246. var s = i.getAxis(this.faceInfo[2]);
  14247. !function (e, t, r, i) {
  14248. var n = [0, 0, 0]
  14249. , a = i < 0 ? r.getExtentMin() : r.getExtentMax();
  14250. n[jo[r.dim]] = a,
  14251. e.position.setArray(n),
  14252. e.rotation.identity(),
  14253. t.distance = -Math.abs(a),
  14254. t.normal.set(0, 0, 0),
  14255. "x" === r.dim ? (e.rotation.rotateY(i * Math.PI / 2),
  14256. t.normal.x = -i) : "z" === r.dim ? (e.rotation.rotateX(-i * Math.PI / 2),
  14257. t.normal.y = -i) : (i > 0 && e.rotation.rotateY(Math.PI),
  14258. t.normal.z = -i)
  14259. }(this.rootNode, this.plane, s, this.faceInfo[3])
  14260. }
  14261. ,
  14262. Xo.prototype._updateSplitLines = function (e, t, r, n) {
  14263. var a = n.getDevicePixelRatio();
  14264. t.forEach((function (n, o) {
  14265. var s = n.model
  14266. , l = t[1 - o].getExtent();
  14267. if (!n.scale.isBlank()) {
  14268. var h = s.getModel("splitLine", r.getModel("splitLine"));
  14269. if (h.get("show")) {
  14270. var u = h.getModel("lineStyle")
  14271. , c = u.get("color")
  14272. , d = Wo(u.get("opacity"), 1)
  14273. , f = Wo(u.get("width"), 1);
  14274. c = i.util.isArray(c) ? c : [c];
  14275. for (var p = n.getTicksCoords({
  14276. tickModel: h
  14277. }), m = 0, g = 0; g < p.length; g++) {
  14278. var _ = p[g].coord
  14279. , v = Ka.parseColor(c[m % c.length]);
  14280. v[3] *= d;
  14281. var y = [0, 0, 0]
  14282. , x = [0, 0, 0];
  14283. y[o] = x[o] = _,
  14284. y[1 - o] = l[0],
  14285. x[1 - o] = l[1],
  14286. e.addLine(y, x, v, f * a),
  14287. m++
  14288. }
  14289. }
  14290. }
  14291. }
  14292. ))
  14293. }
  14294. ,
  14295. Xo.prototype._udpateSplitAreas = function (e, t, r, n) {
  14296. t.forEach((function (n, a) {
  14297. var o = n.model
  14298. , s = t[1 - a].getExtent();
  14299. if (!n.scale.isBlank()) {
  14300. var l = o.getModel("splitArea", r.getModel("splitArea"));
  14301. if (l.get("show")) {
  14302. var h = l.getModel("areaStyle")
  14303. , u = h.get("color")
  14304. , c = Wo(h.get("opacity"), 1);
  14305. u = i.util.isArray(u) ? u : [u];
  14306. for (var d = n.getTicksCoords({
  14307. tickModel: l,
  14308. clamp: !0
  14309. }), f = 0, p = [0, 0, 0], m = [0, 0, 0], g = 0; g < d.length; g++) {
  14310. var _ = d[g].coord
  14311. , v = [0, 0, 0]
  14312. , y = [0, 0, 0];
  14313. if (v[a] = y[a] = _,
  14314. v[1 - a] = s[0],
  14315. y[1 - a] = s[1],
  14316. 0 !== g) {
  14317. var x = Ka.parseColor(u[f % u.length]);
  14318. x[3] *= c,
  14319. e.addQuad([p, v, y, m], x),
  14320. p = v,
  14321. m = y,
  14322. f++
  14323. } else
  14324. p = v,
  14325. m = y
  14326. }
  14327. }
  14328. }
  14329. }
  14330. ))
  14331. }
  14332. ;
  14333. const qo = Xo;
  14334. var Zo = [0, 1, 2, 0, 2, 3]
  14335. , Yo = Vr.extend((function () {
  14336. return {
  14337. attributes: {
  14338. position: new Vr.Attribute("position", "float", 3, "POSITION"),
  14339. texcoord: new Vr.Attribute("texcoord", "float", 2, "TEXCOORD_0"),
  14340. offset: new Vr.Attribute("offset", "float", 2),
  14341. color: new Vr.Attribute("color", "float", 4, "COLOR")
  14342. }
  14343. }
  14344. }
  14345. ), {
  14346. resetOffset: function () {
  14347. this._vertexOffset = 0,
  14348. this._faceOffset = 0
  14349. },
  14350. setSpriteCount: function (e) {
  14351. this._spriteCount = e;
  14352. var t = 4 * e
  14353. , r = 2 * e;
  14354. this.vertexCount !== t && (this.attributes.position.init(t),
  14355. this.attributes.offset.init(t),
  14356. this.attributes.color.init(t)),
  14357. this.triangleCount !== r && (this.indices = t > 65535 ? new Uint32Array(3 * r) : new Uint16Array(3 * r))
  14358. },
  14359. setSpriteAlign: function (e, t, r, i, n) {
  14360. var a, o, s, l;
  14361. switch (null == r && (r = "left"),
  14362. null == i && (i = "top"),
  14363. n = n || 0,
  14364. r) {
  14365. case "left":
  14366. a = n,
  14367. s = t[0] + n;
  14368. break;
  14369. case "center":
  14370. case "middle":
  14371. a = -t[0] / 2,
  14372. s = t[0] / 2;
  14373. break;
  14374. case "right":
  14375. a = -t[0] - n,
  14376. s = -n
  14377. }
  14378. switch (i) {
  14379. case "bottom":
  14380. o = n,
  14381. l = t[1] + n;
  14382. break;
  14383. case "middle":
  14384. o = -t[1] / 2,
  14385. l = t[1] / 2;
  14386. break;
  14387. case "top":
  14388. o = -t[1] - n,
  14389. l = -n
  14390. }
  14391. var h = 4 * e
  14392. , u = this.attributes.offset;
  14393. u.set(h, [a, l]),
  14394. u.set(h + 1, [s, l]),
  14395. u.set(h + 2, [s, o]),
  14396. u.set(h + 3, [a, o])
  14397. },
  14398. addSprite: function (e, t, r, i, n, a) {
  14399. var o = this._vertexOffset;
  14400. this.setSprite(this._vertexOffset / 4, e, t, r, i, n, a);
  14401. for (var s = 0; s < Zo.length; s++)
  14402. this.indices[3 * this._faceOffset + s] = Zo[s] + o;
  14403. return this._faceOffset += 2,
  14404. this._vertexOffset += 4,
  14405. o / 4
  14406. },
  14407. setSprite: function (e, t, r, i, n, a, o) {
  14408. for (var s = 4 * e, l = this.attributes, h = 0; h < 4; h++)
  14409. l.position.set(s + h, t);
  14410. var u = l.texcoord;
  14411. u.set(s, [i[0][0], i[0][1]]),
  14412. u.set(s + 1, [i[1][0], i[0][1]]),
  14413. u.set(s + 2, [i[1][0], i[1][1]]),
  14414. u.set(s + 3, [i[0][0], i[1][1]]),
  14415. this.setSpriteAlign(e, r, n, a, o)
  14416. }
  14417. });
  14418. i.util.defaults(Yo.prototype, Lo);
  14419. const Ko = Yo;
  14420. Ka.Shader.import("@export ecgl.labels.vertex\n\nattribute vec3 position: POSITION;\nattribute vec2 texcoord: TEXCOORD_0;\nattribute vec2 offset;\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec2 v_Texcoord;\n\nvoid main()\n{\n vec4 proj = worldViewProjection * vec4(position, 1.0);\n\n vec2 screen = (proj.xy / abs(proj.w) + 1.0) * 0.5 * viewport.zw;\n\n screen += offset;\n\n proj.xy = (screen / viewport.zw - 0.5) * 2.0 * abs(proj.w);\n gl_Position = proj;\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n v_Texcoord = texcoord;\n}\n@end\n\n\n@export ecgl.labels.fragment\n\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform float alpha : 1.0;\nuniform sampler2D textureAtlas;\nuniform vec2 uvScale: [1.0, 1.0];\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\nvarying float v_Miter;\n\nvarying vec2 v_Texcoord;\n\nvoid main()\n{\n gl_FragColor = vec4(color, alpha) * texture2D(textureAtlas, v_Texcoord * uvScale);\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n}\n\n@end");
  14421. const Qo = Ka.Mesh.extend((function () {
  14422. return {
  14423. geometry: new Ko({
  14424. dynamic: !0
  14425. }),
  14426. material: new Ka.Material({
  14427. shader: Ka.createShader("ecgl.labels"),
  14428. transparent: !0,
  14429. depthMask: !1
  14430. }),
  14431. culling: !1,
  14432. castShadow: !1,
  14433. ignorePicking: !0
  14434. }
  14435. }
  14436. ));
  14437. var Jo = Mn
  14438. , $o = {
  14439. x: 0,
  14440. y: 2,
  14441. z: 1
  14442. };
  14443. function es(e, t) {
  14444. var r = new Ka.Mesh({
  14445. geometry: new Ro({
  14446. useNativeLine: !1
  14447. }),
  14448. material: t,
  14449. castShadow: !1,
  14450. ignorePicking: !0,
  14451. renderOrder: 2
  14452. })
  14453. , i = new Qo;
  14454. i.material.depthMask = !1;
  14455. var n = new Ka.Node;
  14456. n.add(r),
  14457. n.add(i),
  14458. this.rootNode = n,
  14459. this.dim = e,
  14460. this.linesMesh = r,
  14461. this.labelsMesh = i,
  14462. this.axisLineCoords = null,
  14463. this.labelElements = []
  14464. }
  14465. var ts = {
  14466. x: "y",
  14467. y: "x",
  14468. z: "y"
  14469. };
  14470. es.prototype.update = function (e, t, r) {
  14471. var n = e.coordinateSystem.getAxis(this.dim)
  14472. , a = this.linesMesh.geometry
  14473. , o = this.labelsMesh.geometry;
  14474. a.convertToDynamicArray(!0),
  14475. o.convertToDynamicArray(!0);
  14476. var s = n.model
  14477. , l = n.getExtent()
  14478. , h = r.getDevicePixelRatio()
  14479. , u = s.getModel("axisLine", e.getModel("axisLine"))
  14480. , c = s.getModel("axisTick", e.getModel("axisTick"))
  14481. , d = s.getModel("axisLabel", e.getModel("axisLabel"))
  14482. , f = u.get("lineStyle.color");
  14483. if (u.get("show")) {
  14484. var p = u.getModel("lineStyle")
  14485. , m = [0, 0, 0];
  14486. (M = [0, 0, 0])[A = $o[n.dim]] = l[0],
  14487. m[A] = l[1],
  14488. this.axisLineCoords = [M, m];
  14489. var g = Ka.parseColor(f)
  14490. , _ = Jo(p.get("width"), 1)
  14491. , v = Jo(p.get("opacity"), 1);
  14492. g[3] *= v,
  14493. a.addLine(M, m, g, _ * h)
  14494. }
  14495. if (c.get("show")) {
  14496. var y = c.getModel("lineStyle")
  14497. , x = Ka.parseColor(Jo(y.get("color"), f));
  14498. _ = Jo(y.get("width"), 1),
  14499. x[3] *= Jo(y.get("opacity"), 1);
  14500. for (var b = n.getTicksCoords(), w = c.get("length"), T = 0; T < b.length; T++) {
  14501. var S = b[T].coord
  14502. , M = [0, 0, 0]
  14503. , A = (m = [0, 0, 0],
  14504. $o[n.dim])
  14505. , E = $o[ts[n.dim]];
  14506. M[A] = m[A] = S,
  14507. m[E] = w,
  14508. a.addLine(M, m, x, _ * h)
  14509. }
  14510. }
  14511. if (this.labelElements = [],
  14512. h = r.getDevicePixelRatio(),
  14513. d.get("show")) {
  14514. b = n.getTicksCoords();
  14515. var C = s.get("data")
  14516. , D = d.get("margin")
  14517. , L = n.getViewLabels();
  14518. for (T = 0; T < L.length; T++) {
  14519. var P = L[T].tickValue
  14520. , O = L[T].formattedLabel
  14521. , N = L[T].rawLabel
  14522. , I = (S = n.dataToCoord(P),
  14523. [0, 0, 0]);
  14524. A = $o[n.dim],
  14525. E = $o[ts[n.dim]],
  14526. I[A] = I[A] = S,
  14527. I[E] = D;
  14528. var R = d;
  14529. C && C[P] && C[P].textStyle && (R = new i.Model(C[P].textStyle, d, s.ecModel));
  14530. var B = Jo(R.get("color"), f)
  14531. , F = new i.graphic.Text({
  14532. style: xo(R, {
  14533. text: O,
  14534. fill: "function" == typeof B ? B("category" === n.type ? N : "value" === n.type ? P + "" : P, T) : B,
  14535. verticalAlign: "top",
  14536. align: "left"
  14537. })
  14538. })
  14539. , z = t.add(F)
  14540. , G = F.getBoundingRect();
  14541. o.addSprite(I, [G.width * h, G.height * h], z),
  14542. this.labelElements.push(F)
  14543. }
  14544. }
  14545. if (s.get("name")) {
  14546. var U = s.getModel("nameTextStyle")
  14547. , k = (I = [0, 0, 0],
  14548. A = $o[n.dim],
  14549. E = $o[ts[n.dim]],
  14550. Jo(U.get("color"), f))
  14551. , V = U.get("borderColor");
  14552. _ = U.get("borderWidth"),
  14553. I[A] = I[A] = (l[0] + l[1]) / 2,
  14554. I[E] = s.get("nameGap"),
  14555. F = new i.graphic.Text({
  14556. style: xo(U, {
  14557. text: s.get("name"),
  14558. fill: k,
  14559. stroke: V,
  14560. lineWidth: _
  14561. })
  14562. }),
  14563. z = t.add(F),
  14564. G = F.getBoundingRect(),
  14565. o.addSprite(I, [G.width * h, G.height * h], z),
  14566. F.__idx = this.labelElements.length,
  14567. this.nameLabelElement = F
  14568. }
  14569. this.labelsMesh.material.set("textureAtlas", t.getTexture()),
  14570. this.labelsMesh.material.set("uvScale", t.getCoordsScale()),
  14571. a.convertToTypedArray(),
  14572. o.convertToTypedArray()
  14573. }
  14574. ,
  14575. es.prototype.setSpriteAlign = function (e, t, r) {
  14576. for (var i = r.getDevicePixelRatio(), n = this.labelsMesh.geometry, a = 0; a < this.labelElements.length; a++) {
  14577. var o = this.labelElements[a].getBoundingRect();
  14578. n.setSpriteAlign(a, [o.width * i, o.height * i], e, t)
  14579. }
  14580. var s = this.nameLabelElement;
  14581. s && (o = s.getBoundingRect(),
  14582. n.setSpriteAlign(s.__idx, [o.width * i, o.height * i], e, t),
  14583. n.dirty()),
  14584. this.textAlign = e,
  14585. this.textVerticalAlign = t
  14586. }
  14587. ;
  14588. const rs = es
  14589. , is = "@export ecgl.lines3D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, 1.0);\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n}\n@end\n\n\n\n@export ecgl.lines3D.clipNear\n\nvec4 clipNear(vec4 p1, vec4 p2) {\n float n = (p1.w - near) / (p1.w - p2.w);\n return vec4(mix(p1.xy, p2.xy, n), -near, near);\n}\n\n@end\n\n@export ecgl.lines3D.expandLine\n#ifdef VERTEX_ANIMATION\n vec4 prevProj = worldViewProjection * vec4(mix(prevPositionPrev, positionPrev, percent), 1.0);\n vec4 currProj = worldViewProjection * vec4(mix(prevPosition, position, percent), 1.0);\n vec4 nextProj = worldViewProjection * vec4(mix(prevPositionNext, positionNext, percent), 1.0);\n#else\n vec4 prevProj = worldViewProjection * vec4(positionPrev, 1.0);\n vec4 currProj = worldViewProjection * vec4(position, 1.0);\n vec4 nextProj = worldViewProjection * vec4(positionNext, 1.0);\n#endif\n\n if (currProj.w < 0.0) {\n if (nextProj.w > 0.0) {\n currProj = clipNear(currProj, nextProj);\n }\n else if (prevProj.w > 0.0) {\n currProj = clipNear(currProj, prevProj);\n }\n }\n\n vec2 prevScreen = (prevProj.xy / abs(prevProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 currScreen = (currProj.xy / abs(currProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 nextScreen = (nextProj.xy / abs(nextProj.w) + 1.0) * 0.5 * viewport.zw;\n\n vec2 dir;\n float len = offset;\n if (position == positionPrev) {\n dir = normalize(nextScreen - currScreen);\n }\n else if (position == positionNext) {\n dir = normalize(currScreen - prevScreen);\n }\n else {\n vec2 dirA = normalize(currScreen - prevScreen);\n vec2 dirB = normalize(nextScreen - currScreen);\n\n vec2 tanget = normalize(dirA + dirB);\n\n float miter = 1.0 / max(dot(tanget, dirA), 0.5);\n len *= miter;\n dir = tanget;\n }\n\n dir = vec2(-dir.y, dir.x) * len;\n currScreen += dir;\n\n currProj.xy = (currScreen / viewport.zw - 0.5) * 2.0 * abs(currProj.w);\n@end\n\n\n@export ecgl.meshLines3D.vertex\n\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevPositionPrev;\nattribute vec3 prevPositionNext;\nuniform float percent : 1.0;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n}\n@end\n\n\n@export ecgl.meshLines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end";
  14590. var ns = Mn;
  14591. Ka.Shader.import(is);
  14592. var as = {
  14593. x: 0,
  14594. y: 2,
  14595. z: 1
  14596. };
  14597. const os = i.ComponentView.extend({
  14598. type: "grid3D",
  14599. __ecgl__: !0,
  14600. init: function (e, t) {
  14601. var r = new Ka.Material({
  14602. shader: Ka.createShader("ecgl.color"),
  14603. depthMask: !1,
  14604. transparent: !0
  14605. })
  14606. , i = new Ka.Material({
  14607. shader: Ka.createShader("ecgl.meshLines3D"),
  14608. depthMask: !1,
  14609. transparent: !0
  14610. });
  14611. r.define("fragment", "DOUBLE_SIDED"),
  14612. r.define("both", "VERTEX_COLOR"),
  14613. this.groupGL = new Ka.Node,
  14614. this._control = new Do({
  14615. zr: t.getZr()
  14616. }),
  14617. this._control.init(),
  14618. this._faces = [["y", "z", "x", -1, "left"], ["y", "z", "x", 1, "right"], ["x", "y", "z", -1, "bottom"], ["x", "y", "z", 1, "top"], ["x", "z", "y", -1, "far"], ["x", "z", "y", 1, "near"]].map((function (e) {
  14619. var t = new qo(e, i, r);
  14620. return this.groupGL.add(t.rootNode),
  14621. t
  14622. }
  14623. ), this),
  14624. this._axes = ["x", "y", "z"].map((function (e) {
  14625. var t = new rs(e, i);
  14626. return this.groupGL.add(t.rootNode),
  14627. t
  14628. }
  14629. ), this);
  14630. var n = t.getDevicePixelRatio();
  14631. this._axisLabelSurface = new zo({
  14632. width: 256,
  14633. height: 256,
  14634. devicePixelRatio: n
  14635. }),
  14636. this._axisLabelSurface.onupdate = function () {
  14637. t.getZr().refresh()
  14638. }
  14639. ,
  14640. this._axisPointerLineMesh = new Ka.Mesh({
  14641. geometry: new Ro({
  14642. useNativeLine: !1
  14643. }),
  14644. material: i,
  14645. castShadow: !1,
  14646. ignorePicking: !0,
  14647. renderOrder: 3
  14648. }),
  14649. this.groupGL.add(this._axisPointerLineMesh),
  14650. this._axisPointerLabelsSurface = new zo({
  14651. width: 128,
  14652. height: 128,
  14653. devicePixelRatio: n
  14654. }),
  14655. this._axisPointerLabelsMesh = new Qo({
  14656. ignorePicking: !0,
  14657. renderOrder: 4,
  14658. castShadow: !1
  14659. }),
  14660. this._axisPointerLabelsMesh.material.set("textureAtlas", this._axisPointerLabelsSurface.getTexture()),
  14661. this.groupGL.add(this._axisPointerLabelsMesh),
  14662. this._lightRoot = new Ka.Node,
  14663. this._sceneHelper = new Uo,
  14664. this._sceneHelper.initLight(this._lightRoot)
  14665. },
  14666. render: function (e, t, r) {
  14667. this._model = e,
  14668. this._api = r;
  14669. var i = e.coordinateSystem;
  14670. i.viewGL.add(this._lightRoot),
  14671. e.get("show") ? i.viewGL.add(this.groupGL) : i.viewGL.remove(this.groupGL);
  14672. var n = this._control;
  14673. n.setViewGL(i.viewGL);
  14674. var a = e.getModel("viewControl");
  14675. n.setFromViewControlModel(a, 0),
  14676. this._axisLabelSurface.clear(),
  14677. n.off("update"),
  14678. e.get("show") && (this._faces.forEach((function (i) {
  14679. i.update(e, t, r)
  14680. }
  14681. ), this),
  14682. this._axes.forEach((function (t) {
  14683. t.update(e, this._axisLabelSurface, r)
  14684. }
  14685. ), this)),
  14686. n.on("update", this._onCameraChange.bind(this, e, r), this),
  14687. this._sceneHelper.setScene(i.viewGL.scene),
  14688. this._sceneHelper.updateLight(e),
  14689. i.viewGL.setPostEffect(e.getModel("postEffect"), r),
  14690. i.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),
  14691. this._initMouseHandler(e)
  14692. },
  14693. afterRender: function (e, t, r, i) {
  14694. var n = i.renderer;
  14695. this._sceneHelper.updateAmbientCubemap(n, e, r),
  14696. this._sceneHelper.updateSkybox(n, e, r)
  14697. },
  14698. showAxisPointer: function (e, t, r, i) {
  14699. this._doShowAxisPointer(),
  14700. this._updateAxisPointer(i.value)
  14701. },
  14702. hideAxisPointer: function (e, t, r, i) {
  14703. this._doHideAxisPointer()
  14704. },
  14705. _initMouseHandler: function (e) {
  14706. var t = e.coordinateSystem.viewGL;
  14707. e.get("show") && e.get("axisPointer.show") ? t.on("mousemove", this._updateAxisPointerOnMousePosition, this) : t.off("mousemove", this._updateAxisPointerOnMousePosition)
  14708. },
  14709. _updateAxisPointerOnMousePosition: function (e) {
  14710. if (!e.target) {
  14711. for (var t, r = this._model.coordinateSystem, i = r.viewGL, n = i.castRay(e.offsetX, e.offsetY, new Ka.Ray), a = 0; a < this._faces.length; a++) {
  14712. var o = this._faces[a];
  14713. if (!o.rootNode.invisible) {
  14714. o.plane.normal.dot(i.camera.worldTransform.z) < 0 && o.plane.normal.negate();
  14715. var s = n.intersectPlane(o.plane);
  14716. if (s) {
  14717. var l = r.getAxis(o.faceInfo[0])
  14718. , h = r.getAxis(o.faceInfo[1])
  14719. , u = as[o.faceInfo[0]]
  14720. , c = as[o.faceInfo[1]];
  14721. l.contain(s.array[u]) && h.contain(s.array[c]) && (t = s)
  14722. }
  14723. }
  14724. }
  14725. if (t) {
  14726. var d = r.pointToData(t.array, [], !0);
  14727. this._updateAxisPointer(d),
  14728. this._doShowAxisPointer()
  14729. } else
  14730. this._doHideAxisPointer()
  14731. }
  14732. },
  14733. _onCameraChange: function (e, t) {
  14734. e.get("show") && (this._updateFaceVisibility(),
  14735. this._updateAxisLinePosition());
  14736. var r = this._control;
  14737. t.dispatchAction({
  14738. type: "grid3DChangeCamera",
  14739. alpha: r.getAlpha(),
  14740. beta: r.getBeta(),
  14741. distance: r.getDistance(),
  14742. center: r.getCenter(),
  14743. from: this.uid,
  14744. grid3DId: e.id
  14745. })
  14746. },
  14747. _updateFaceVisibility: function () {
  14748. var e = this._control.getCamera()
  14749. , t = new Ka.Vector3;
  14750. e.update();
  14751. for (var r = 0; r < this._faces.length / 2; r++) {
  14752. for (var i = [], n = 0; n < 2; n++)
  14753. this._faces[2 * r + n].rootNode.getWorldPosition(t),
  14754. t.transformMat4(e.viewMatrix),
  14755. i[n] = t.z;
  14756. var a = i[0] > i[1] ? 0 : 1
  14757. , o = this._faces[2 * r + a]
  14758. , s = this._faces[2 * r + 1 - a];
  14759. o.rootNode.invisible = !0,
  14760. s.rootNode.invisible = !1
  14761. }
  14762. },
  14763. _updateAxisLinePosition: function () {
  14764. var e = this._model.coordinateSystem
  14765. , t = e.getAxis("x")
  14766. , r = e.getAxis("y")
  14767. , i = e.getAxis("z")
  14768. , n = i.getExtentMax()
  14769. , a = i.getExtentMin()
  14770. , o = t.getExtentMin()
  14771. , s = t.getExtentMax()
  14772. , l = r.getExtentMax()
  14773. , h = r.getExtentMin()
  14774. , u = this._axes[0].rootNode
  14775. , c = this._axes[1].rootNode
  14776. , d = this._axes[2].rootNode
  14777. , f = this._faces
  14778. , p = f[4].rootNode.invisible ? h : l
  14779. , m = f[2].rootNode.invisible ? n : a
  14780. , g = f[0].rootNode.invisible ? o : s
  14781. , _ = f[2].rootNode.invisible ? n : a
  14782. , v = f[0].rootNode.invisible ? s : o
  14783. , y = f[4].rootNode.invisible ? h : l;
  14784. u.rotation.identity(),
  14785. c.rotation.identity(),
  14786. d.rotation.identity(),
  14787. f[4].rootNode.invisible && (this._axes[0].flipped = !0,
  14788. u.rotation.rotateX(Math.PI)),
  14789. f[0].rootNode.invisible && (this._axes[1].flipped = !0,
  14790. c.rotation.rotateZ(Math.PI)),
  14791. f[4].rootNode.invisible && (this._axes[2].flipped = !0,
  14792. d.rotation.rotateY(Math.PI)),
  14793. u.position.set(0, m, p),
  14794. c.position.set(g, _, 0),
  14795. d.position.set(v, 0, y),
  14796. u.update(),
  14797. c.update(),
  14798. d.update(),
  14799. this._updateAxisLabelAlign()
  14800. },
  14801. _updateAxisLabelAlign: function () {
  14802. var e = this._control.getCamera()
  14803. , t = [new Ka.Vector4, new Ka.Vector4]
  14804. , r = new Ka.Vector4;
  14805. this.groupGL.getWorldPosition(r),
  14806. r.w = 1,
  14807. r.transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),
  14808. r.x /= r.w,
  14809. r.y /= r.w,
  14810. this._axes.forEach((function (i) {
  14811. for (var n = i.axisLineCoords, a = (i.labelsMesh.geometry,
  14812. 0); a < t.length; a++)
  14813. t[a].setArray(n[a]),
  14814. t[a].w = 1,
  14815. t[a].transformMat4(i.rootNode.worldTransform).transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),
  14816. t[a].x /= t[a].w,
  14817. t[a].y /= t[a].w;
  14818. var o, s, l = t[1].x - t[0].x, h = t[1].y - t[0].y, u = (t[1].x + t[0].x) / 2, c = (t[1].y + t[0].y) / 2;
  14819. Math.abs(h / l) < .5 ? (o = "center",
  14820. s = c > r.y ? "bottom" : "top") : (s = "middle",
  14821. o = u > r.x ? "left" : "right"),
  14822. i.setSpriteAlign(o, s, this._api)
  14823. }
  14824. ), this)
  14825. },
  14826. _doShowAxisPointer: function () {
  14827. this._axisPointerLineMesh.invisible && (this._axisPointerLineMesh.invisible = !1,
  14828. this._axisPointerLabelsMesh.invisible = !1,
  14829. this._api.getZr().refresh())
  14830. },
  14831. _doHideAxisPointer: function () {
  14832. this._axisPointerLineMesh.invisible || (this._axisPointerLineMesh.invisible = !0,
  14833. this._axisPointerLabelsMesh.invisible = !0,
  14834. this._api.getZr().refresh())
  14835. },
  14836. _updateAxisPointer: function (e) {
  14837. var t = this._model.coordinateSystem
  14838. , r = t.dataToPoint(e)
  14839. , i = this._axisPointerLineMesh.geometry
  14840. , n = this._model.getModel("axisPointer")
  14841. , a = this._api.getDevicePixelRatio();
  14842. function o(e) {
  14843. return Mn(e.model.get("axisPointer.show"), n.get("show"))
  14844. }
  14845. function s(e) {
  14846. var t = e.model.getModel("axisPointer", n).getModel("lineStyle")
  14847. , r = Ka.parseColor(t.get("color"))
  14848. , i = ns(t.get("width"), 1)
  14849. , a = ns(t.get("opacity"), 1);
  14850. return r[3] *= a,
  14851. {
  14852. color: r,
  14853. lineWidth: i
  14854. }
  14855. }
  14856. i.convertToDynamicArray(!0);
  14857. for (var l = 0; l < this._faces.length; l++) {
  14858. var h = this._faces[l];
  14859. if (!h.rootNode.invisible) {
  14860. for (var u = h.faceInfo, c = u[3] < 0 ? t.getAxis(u[2]).getExtentMin() : t.getAxis(u[2]).getExtentMax(), d = as[u[2]], f = 0; f < 2; f++) {
  14861. var p = u[f]
  14862. , m = u[1 - f]
  14863. , g = t.getAxis(p)
  14864. , _ = t.getAxis(m);
  14865. if (o(g)) {
  14866. var v = as[p]
  14867. , y = as[m];
  14868. (w = [0, 0, 0])[v] = (b = [0, 0, 0])[v] = r[v],
  14869. w[d] = b[d] = c,
  14870. w[y] = _.getExtentMin(),
  14871. b[y] = _.getExtentMax();
  14872. var x = s(g);
  14873. i.addLine(w, b, x.color, x.lineWidth * a)
  14874. }
  14875. }
  14876. if (o(t.getAxis(u[2]))) {
  14877. var b, w = r.slice();
  14878. (b = r.slice())[d] = c,
  14879. x = s(t.getAxis(u[2])),
  14880. i.addLine(w, b, x.color, x.lineWidth * a)
  14881. }
  14882. }
  14883. }
  14884. i.convertToTypedArray(),
  14885. this._updateAxisPointerLabelsMesh(e),
  14886. this._api.getZr().refresh()
  14887. },
  14888. _updateAxisPointerLabelsMesh: function (e) {
  14889. var t = this._model
  14890. , r = this._axisPointerLabelsMesh
  14891. , n = this._axisPointerLabelsSurface
  14892. , a = t.coordinateSystem
  14893. , o = t.getModel("axisPointer");
  14894. r.geometry.convertToDynamicArray(!0),
  14895. n.clear();
  14896. var s = {
  14897. x: "y",
  14898. y: "x",
  14899. z: "y"
  14900. };
  14901. this._axes.forEach((function (t, l) {
  14902. var h = a.getAxis(t.dim)
  14903. , u = h.model.getModel("axisPointer", o)
  14904. , c = u.getModel("label")
  14905. , d = u.get("lineStyle.color");
  14906. if (c.get("show") && u.get("show")) {
  14907. var f = e[l]
  14908. , p = c.get("formatter")
  14909. , m = h.scale.getLabel({
  14910. value: f
  14911. });
  14912. if (null != p)
  14913. m = p(m, e);
  14914. else if ("interval" === h.scale.type || "log" === h.scale.type) {
  14915. var g = i.number.getPrecisionSafe(h.scale.getTicks()[0]);
  14916. m = f.toFixed(g + 2)
  14917. }
  14918. var _ = c.get("color")
  14919. , v = new i.graphic.Text({
  14920. style: xo(c, {
  14921. text: m,
  14922. fill: _ || d,
  14923. align: "left",
  14924. verticalAlign: "top"
  14925. })
  14926. })
  14927. , y = n.add(v)
  14928. , x = v.getBoundingRect()
  14929. , b = this._api.getDevicePixelRatio()
  14930. , w = t.rootNode.position.toArray();
  14931. w[as[s[t.dim]]] += (t.flipped ? -1 : 1) * c.get("margin"),
  14932. w[as[t.dim]] = h.dataToCoord(e[l]),
  14933. r.geometry.addSprite(w, [x.width * b, x.height * b], y, t.textAlign, t.textVerticalAlign)
  14934. }
  14935. }
  14936. ), this),
  14937. n.getZr().refreshImmediately(),
  14938. r.material.set("uvScale", n.getCoordsScale()),
  14939. r.geometry.convertToTypedArray()
  14940. },
  14941. dispose: function () {
  14942. this.groupGL.removeAll(),
  14943. this._control.dispose(),
  14944. this._axisLabelSurface.dispose(),
  14945. this._axisPointerLabelsSurface.dispose()
  14946. }
  14947. })
  14948. , ss = function () {
  14949. function e(e) {
  14950. this.type = "cartesian",
  14951. this._dimList = [],
  14952. this._axes = {},
  14953. this.name = e || ""
  14954. }
  14955. return e.prototype.getAxis = function (e) {
  14956. return this._axes[e]
  14957. }
  14958. ,
  14959. e.prototype.getAxes = function () {
  14960. return xa(this._dimList, (function (e) {
  14961. return this._axes[e]
  14962. }
  14963. ), this)
  14964. }
  14965. ,
  14966. e.prototype.getAxesByScale = function (e) {
  14967. return e = e.toLowerCase(),
  14968. function (e, t, r) {
  14969. if (!e)
  14970. return [];
  14971. if (!t)
  14972. return Sa(e);
  14973. if (e.filter && e.filter === ca)
  14974. return e.filter(t, r);
  14975. for (var i = [], n = 0, a = e.length; n < a; n++)
  14976. t.call(r, e[n], n, e) && i.push(e[n]);
  14977. return i
  14978. }(this.getAxes(), (function (t) {
  14979. return t.scale.type === e
  14980. }
  14981. ))
  14982. }
  14983. ,
  14984. e.prototype.addAxis = function (e) {
  14985. var t = e.dim;
  14986. this._axes[t] = e,
  14987. this._dimList.push(t)
  14988. }
  14989. ,
  14990. e
  14991. }();
  14992. function ls(e) {
  14993. ss.call(this, e),
  14994. this.type = "cartesian3D",
  14995. this.dimensions = ["x", "y", "z"],
  14996. this.size = [0, 0, 0]
  14997. }
  14998. ls.prototype = {
  14999. constructor: ls,
  15000. model: null,
  15001. containPoint: function (e) {
  15002. return this.getAxis("x").contain(e[0]) && this.getAxis("y").contain(e[2]) && this.getAxis("z").contain(e[1])
  15003. },
  15004. containData: function (e) {
  15005. return this.getAxis("x").containData(e[0]) && this.getAxis("y").containData(e[1]) && this.getAxis("z").containData(e[2])
  15006. },
  15007. dataToPoint: function (e, t, r) {
  15008. return (t = t || [])[0] = this.getAxis("x").dataToCoord(e[0], r),
  15009. t[2] = this.getAxis("y").dataToCoord(e[1], r),
  15010. t[1] = this.getAxis("z").dataToCoord(e[2], r),
  15011. t
  15012. },
  15013. pointToData: function (e, t, r) {
  15014. return (t = t || [])[0] = this.getAxis("x").coordToData(e[0], r),
  15015. t[1] = this.getAxis("y").coordToData(e[2], r),
  15016. t[2] = this.getAxis("z").coordToData(e[1], r),
  15017. t
  15018. }
  15019. },
  15020. i.util.inherits(ls, ss);
  15021. const hs = ls;
  15022. function us(e, t, r) {
  15023. i.Axis.call(this, e, t, r)
  15024. }
  15025. us.prototype = {
  15026. constructor: us,
  15027. getExtentMin: function () {
  15028. var e = this._extent;
  15029. return Math.min(e[0], e[1])
  15030. },
  15031. getExtentMax: function () {
  15032. var e = this._extent;
  15033. return Math.max(e[0], e[1])
  15034. },
  15035. calculateCategoryInterval: function () {
  15036. return Math.floor(this.scale.count() / 8)
  15037. }
  15038. },
  15039. i.util.inherits(us, i.Axis);
  15040. const cs = us;
  15041. function ds(e, t, r) {
  15042. return e[0] = t[0],
  15043. e[1] = t[1],
  15044. e[2] = t[2],
  15045. e[3] = t[3],
  15046. e[4] = t[4] + r[0],
  15047. e[5] = t[5] + r[1],
  15048. e
  15049. }
  15050. const fs = function () {
  15051. function e(e, t) {
  15052. this.x = e || 0,
  15053. this.y = t || 0
  15054. }
  15055. return e.prototype.copy = function (e) {
  15056. return this.x = e.x,
  15057. this.y = e.y,
  15058. this
  15059. }
  15060. ,
  15061. e.prototype.clone = function () {
  15062. return new e(this.x, this.y)
  15063. }
  15064. ,
  15065. e.prototype.set = function (e, t) {
  15066. return this.x = e,
  15067. this.y = t,
  15068. this
  15069. }
  15070. ,
  15071. e.prototype.equal = function (e) {
  15072. return e.x === this.x && e.y === this.y
  15073. }
  15074. ,
  15075. e.prototype.add = function (e) {
  15076. return this.x += e.x,
  15077. this.y += e.y,
  15078. this
  15079. }
  15080. ,
  15081. e.prototype.scale = function (e) {
  15082. this.x *= e,
  15083. this.y *= e
  15084. }
  15085. ,
  15086. e.prototype.scaleAndAdd = function (e, t) {
  15087. this.x += e.x * t,
  15088. this.y += e.y * t
  15089. }
  15090. ,
  15091. e.prototype.sub = function (e) {
  15092. return this.x -= e.x,
  15093. this.y -= e.y,
  15094. this
  15095. }
  15096. ,
  15097. e.prototype.dot = function (e) {
  15098. return this.x * e.x + this.y * e.y
  15099. }
  15100. ,
  15101. e.prototype.len = function () {
  15102. return Math.sqrt(this.x * this.x + this.y * this.y)
  15103. }
  15104. ,
  15105. e.prototype.lenSquare = function () {
  15106. return this.x * this.x + this.y * this.y
  15107. }
  15108. ,
  15109. e.prototype.normalize = function () {
  15110. var e = this.len();
  15111. return this.x /= e,
  15112. this.y /= e,
  15113. this
  15114. }
  15115. ,
  15116. e.prototype.distance = function (e) {
  15117. var t = this.x - e.x
  15118. , r = this.y - e.y;
  15119. return Math.sqrt(t * t + r * r)
  15120. }
  15121. ,
  15122. e.prototype.distanceSquare = function (e) {
  15123. var t = this.x - e.x
  15124. , r = this.y - e.y;
  15125. return t * t + r * r
  15126. }
  15127. ,
  15128. e.prototype.negate = function () {
  15129. return this.x = -this.x,
  15130. this.y = -this.y,
  15131. this
  15132. }
  15133. ,
  15134. e.prototype.transform = function (e) {
  15135. if (e) {
  15136. var t = this.x
  15137. , r = this.y;
  15138. return this.x = e[0] * t + e[2] * r + e[4],
  15139. this.y = e[1] * t + e[3] * r + e[5],
  15140. this
  15141. }
  15142. }
  15143. ,
  15144. e.prototype.toArray = function (e) {
  15145. return e[0] = this.x,
  15146. e[1] = this.y,
  15147. e
  15148. }
  15149. ,
  15150. e.prototype.fromArray = function (e) {
  15151. this.x = e[0],
  15152. this.y = e[1]
  15153. }
  15154. ,
  15155. e.set = function (e, t, r) {
  15156. e.x = t,
  15157. e.y = r
  15158. }
  15159. ,
  15160. e.copy = function (e, t) {
  15161. e.x = t.x,
  15162. e.y = t.y
  15163. }
  15164. ,
  15165. e.len = function (e) {
  15166. return Math.sqrt(e.x * e.x + e.y * e.y)
  15167. }
  15168. ,
  15169. e.lenSquare = function (e) {
  15170. return e.x * e.x + e.y * e.y
  15171. }
  15172. ,
  15173. e.dot = function (e, t) {
  15174. return e.x * t.x + e.y * t.y
  15175. }
  15176. ,
  15177. e.add = function (e, t, r) {
  15178. e.x = t.x + r.x,
  15179. e.y = t.y + r.y
  15180. }
  15181. ,
  15182. e.sub = function (e, t, r) {
  15183. e.x = t.x - r.x,
  15184. e.y = t.y - r.y
  15185. }
  15186. ,
  15187. e.scale = function (e, t, r) {
  15188. e.x = t.x * r,
  15189. e.y = t.y * r
  15190. }
  15191. ,
  15192. e.scaleAndAdd = function (e, t, r, i) {
  15193. e.x = t.x + r.x * i,
  15194. e.y = t.y + r.y * i
  15195. }
  15196. ,
  15197. e.lerp = function (e, t, r, i) {
  15198. var n = 1 - i;
  15199. e.x = n * t.x + i * r.x,
  15200. e.y = n * t.y + i * r.y
  15201. }
  15202. ,
  15203. e
  15204. }();
  15205. var ps = Math.min
  15206. , ms = Math.max
  15207. , gs = new fs
  15208. , _s = new fs
  15209. , vs = new fs
  15210. , ys = new fs
  15211. , xs = new fs
  15212. , bs = new fs;
  15213. const ws = function () {
  15214. function e(e, t, r, i) {
  15215. r < 0 && (e += r,
  15216. r = -r),
  15217. i < 0 && (t += i,
  15218. i = -i),
  15219. this.x = e,
  15220. this.y = t,
  15221. this.width = r,
  15222. this.height = i
  15223. }
  15224. return e.prototype.union = function (e) {
  15225. var t = ps(e.x, this.x)
  15226. , r = ps(e.y, this.y);
  15227. isFinite(this.x) && isFinite(this.width) ? this.width = ms(e.x + e.width, this.x + this.width) - t : this.width = e.width,
  15228. isFinite(this.y) && isFinite(this.height) ? this.height = ms(e.y + e.height, this.y + this.height) - r : this.height = e.height,
  15229. this.x = t,
  15230. this.y = r
  15231. }
  15232. ,
  15233. e.prototype.applyTransform = function (t) {
  15234. e.applyTransform(this, this, t)
  15235. }
  15236. ,
  15237. e.prototype.calculateTransform = function (e) {
  15238. var t = this
  15239. , r = e.width / t.width
  15240. , i = e.height / t.height
  15241. , n = [1, 0, 0, 1, 0, 0];
  15242. return ds(n, n, [-t.x, -t.y]),
  15243. function (e, t, r) {
  15244. var i = r[0]
  15245. , n = r[1];
  15246. e[0] = t[0] * i,
  15247. e[1] = t[1] * n,
  15248. e[2] = t[2] * i,
  15249. e[3] = t[3] * n,
  15250. e[4] = t[4] * i,
  15251. e[5] = t[5] * n
  15252. }(n, n, [r, i]),
  15253. ds(n, n, [e.x, e.y]),
  15254. n
  15255. }
  15256. ,
  15257. e.prototype.intersect = function (t, r) {
  15258. if (!t)
  15259. return !1;
  15260. t instanceof e || (t = e.create(t));
  15261. var i = this
  15262. , n = i.x
  15263. , a = i.x + i.width
  15264. , o = i.y
  15265. , s = i.y + i.height
  15266. , l = t.x
  15267. , h = t.x + t.width
  15268. , u = t.y
  15269. , c = t.y + t.height
  15270. , d = !(a < l || h < n || s < u || c < o);
  15271. if (r) {
  15272. var f = 1 / 0
  15273. , p = 0
  15274. , m = Math.abs(a - l)
  15275. , g = Math.abs(h - n)
  15276. , _ = Math.abs(s - u)
  15277. , v = Math.abs(c - o)
  15278. , y = Math.min(m, g)
  15279. , x = Math.min(_, v);
  15280. a < l || h < n ? y > p && (p = y,
  15281. m < g ? fs.set(bs, -m, 0) : fs.set(bs, g, 0)) : y < f && (f = y,
  15282. m < g ? fs.set(xs, m, 0) : fs.set(xs, -g, 0)),
  15283. s < u || c < o ? x > p && (p = x,
  15284. _ < v ? fs.set(bs, 0, -_) : fs.set(bs, 0, v)) : y < f && (f = y,
  15285. _ < v ? fs.set(xs, 0, _) : fs.set(xs, 0, -v))
  15286. }
  15287. return r && fs.copy(r, d ? xs : bs),
  15288. d
  15289. }
  15290. ,
  15291. e.prototype.contain = function (e, t) {
  15292. var r = this;
  15293. return e >= r.x && e <= r.x + r.width && t >= r.y && t <= r.y + r.height
  15294. }
  15295. ,
  15296. e.prototype.clone = function () {
  15297. return new e(this.x, this.y, this.width, this.height)
  15298. }
  15299. ,
  15300. e.prototype.copy = function (t) {
  15301. e.copy(this, t)
  15302. }
  15303. ,
  15304. e.prototype.plain = function () {
  15305. return {
  15306. x: this.x,
  15307. y: this.y,
  15308. width: this.width,
  15309. height: this.height
  15310. }
  15311. }
  15312. ,
  15313. e.prototype.isFinite = function () {
  15314. return isFinite(this.x) && isFinite(this.y) && isFinite(this.width) && isFinite(this.height)
  15315. }
  15316. ,
  15317. e.prototype.isZero = function () {
  15318. return 0 === this.width || 0 === this.height
  15319. }
  15320. ,
  15321. e.create = function (t) {
  15322. return new e(t.x, t.y, t.width, t.height)
  15323. }
  15324. ,
  15325. e.copy = function (e, t) {
  15326. e.x = t.x,
  15327. e.y = t.y,
  15328. e.width = t.width,
  15329. e.height = t.height
  15330. }
  15331. ,
  15332. e.applyTransform = function (t, r, i) {
  15333. if (i) {
  15334. if (i[1] < 1e-5 && i[1] > -1e-5 && i[2] < 1e-5 && i[2] > -1e-5) {
  15335. var n = i[0]
  15336. , a = i[3]
  15337. , o = i[4]
  15338. , s = i[5];
  15339. return t.x = r.x * n + o,
  15340. t.y = r.y * a + s,
  15341. t.width = r.width * n,
  15342. t.height = r.height * a,
  15343. t.width < 0 && (t.x += t.width,
  15344. t.width = -t.width),
  15345. void (t.height < 0 && (t.y += t.height,
  15346. t.height = -t.height))
  15347. }
  15348. gs.x = vs.x = r.x,
  15349. gs.y = ys.y = r.y,
  15350. _s.x = ys.x = r.x + r.width,
  15351. _s.y = vs.y = r.y + r.height,
  15352. gs.transform(i),
  15353. ys.transform(i),
  15354. _s.transform(i),
  15355. vs.transform(i),
  15356. t.x = ps(gs.x, _s.x, vs.x, ys.x),
  15357. t.y = ps(gs.y, _s.y, vs.y, ys.y);
  15358. var l = ms(gs.x, _s.x, vs.x, ys.x)
  15359. , h = ms(gs.y, _s.y, vs.y, ys.y);
  15360. t.width = l - t.x,
  15361. t.height = h - t.y
  15362. } else
  15363. t !== r && e.copy(t, r)
  15364. }
  15365. ,
  15366. e
  15367. }();
  15368. function Ts(e, t, r, i, n) {
  15369. var a = 0
  15370. , o = 0;
  15371. null == i && (i = 1 / 0),
  15372. null == n && (n = 1 / 0);
  15373. var s = 0;
  15374. t.eachChild((function (l, h) {
  15375. var u, c, d = l.getBoundingRect(), f = t.childAt(h + 1), p = f && f.getBoundingRect();
  15376. if ("horizontal" === e) {
  15377. var m = d.width + (p ? -p.x + d.x : 0);
  15378. (u = a + m) > i || l.newline ? (a = 0,
  15379. u = m,
  15380. o += s + r,
  15381. s = d.height) : s = Math.max(s, d.height)
  15382. } else {
  15383. var g = d.height + (p ? -p.y + d.y : 0);
  15384. (c = o + g) > n || l.newline ? (a += s + r,
  15385. o = 0,
  15386. c = g,
  15387. s = d.width) : s = Math.max(s, d.width)
  15388. }
  15389. l.newline || (l.x = a,
  15390. l.y = o,
  15391. l.markRedraw(),
  15392. "horizontal" === e ? a = u + r : o = c + r)
  15393. }
  15394. ))
  15395. }
  15396. function Ss(e, t, r) {
  15397. r = function (e) {
  15398. if ("number" == typeof e)
  15399. return [e, e, e, e];
  15400. var t = e.length;
  15401. return 2 === t ? [e[0], e[1], e[0], e[1]] : 3 === t ? [e[0], e[1], e[2], e[1]] : e
  15402. }(r || 0);
  15403. var i = t.width
  15404. , n = t.height
  15405. , a = go(e.left, i)
  15406. , o = go(e.top, n)
  15407. , s = go(e.right, i)
  15408. , l = go(e.bottom, n)
  15409. , h = go(e.width, i)
  15410. , u = go(e.height, n)
  15411. , c = r[2] + r[0]
  15412. , d = r[1] + r[3]
  15413. , f = e.aspect;
  15414. switch (isNaN(h) && (h = i - s - d - a),
  15415. isNaN(u) && (u = n - l - c - o),
  15416. null != f && (isNaN(h) && isNaN(u) && (f > i / n ? h = .8 * i : u = .8 * n),
  15417. isNaN(h) && (h = f * u),
  15418. isNaN(u) && (u = h / f)),
  15419. isNaN(a) && (a = i - s - h - d),
  15420. isNaN(o) && (o = n - l - u - c),
  15421. e.left || e.right) {
  15422. case "center":
  15423. a = i / 2 - h / 2 - r[3];
  15424. break;
  15425. case "right":
  15426. a = i - h - d
  15427. }
  15428. switch (e.top || e.bottom) {
  15429. case "middle":
  15430. case "center":
  15431. o = n / 2 - u / 2 - r[0];
  15432. break;
  15433. case "bottom":
  15434. o = n - u - c
  15435. }
  15436. a = a || 0,
  15437. o = o || 0,
  15438. isNaN(h) && (h = i - d - a - (s || 0)),
  15439. isNaN(u) && (u = n - c - o - (l || 0));
  15440. var p = new ws(a + r[3], o + r[0], h, u);
  15441. return p.margin = r,
  15442. p
  15443. }
  15444. wa(Ts, "vertical"),
  15445. wa(Ts, "horizontal");
  15446. var Ms = function () {
  15447. this._pool = {},
  15448. this._allocatedTextures = []
  15449. };
  15450. Ms.prototype = {
  15451. constructor: Ms,
  15452. get: function (e) {
  15453. var t = Cs(e);
  15454. this._pool.hasOwnProperty(t) || (this._pool[t] = []);
  15455. var r = this._pool[t];
  15456. if (!r.length) {
  15457. var i = new Dr(e);
  15458. return this._allocatedTextures.push(i),
  15459. i
  15460. }
  15461. return r.pop()
  15462. },
  15463. put: function (e) {
  15464. var t = Cs(e);
  15465. this._pool.hasOwnProperty(t) || (this._pool[t] = []),
  15466. this._pool[t].push(e)
  15467. },
  15468. clear: function (e) {
  15469. for (var t = 0; t < this._allocatedTextures.length; t++)
  15470. this._allocatedTextures[t].dispose(e);
  15471. this._pool = {},
  15472. this._allocatedTextures = []
  15473. }
  15474. };
  15475. var As = {
  15476. width: 512,
  15477. height: 512,
  15478. type: T,
  15479. format: A,
  15480. wrapS: I,
  15481. wrapT: I,
  15482. minFilter: O,
  15483. magFilter: C,
  15484. useMipmap: !0,
  15485. anisotropic: 1,
  15486. flipY: !0,
  15487. unpackAlignment: 4,
  15488. premultiplyAlpha: !1
  15489. }
  15490. , Es = Object.keys(As);
  15491. function Cs(e) {
  15492. var t, r, i, n;
  15493. f.defaultsWithPropList(e, As, Es),
  15494. r = (t = e).width,
  15495. i = t.height,
  15496. n = 0 == (r & r - 1) && 0 == (i & i - 1),
  15497. t.format === M && (t.useMipmap = !1),
  15498. n && t.useMipmap || (t.minFilter == D || t.minFilter == P ? t.minFilter = E : t.minFilter != O && t.minFilter != L || (t.minFilter = C)),
  15499. n || (t.wrapS = I,
  15500. t.wrapT = I);
  15501. for (var a = "", o = 0; o < Es.length; o++)
  15502. a += e[Es[o]].toString();
  15503. return a
  15504. }
  15505. const Ds = Ms;
  15506. var Ls = ["px", "nx", "py", "ny", "pz", "nz"];
  15507. function Ps(e, t, r) {
  15508. return "alphaMap" === r ? e.material.get("diffuseMap") : "alphaCutoff" === r ? e.material.isDefined("fragment", "ALPHA_TEST") && e.material.get("diffuseMap") && e.material.get("alphaCutoff") || 0 : "uvRepeat" === r ? e.material.get("uvRepeat") : "uvOffset" === r ? e.material.get("uvOffset") : t.get(r)
  15509. }
  15510. function Os(e, t) {
  15511. var r = e.material
  15512. , i = t.material;
  15513. return r.get("diffuseMap") !== i.get("diffuseMap") || (r.get("alphaCutoff") || 0) !== (i.get("alphaCutoff") || 0)
  15514. }
  15515. Xe.import("@export clay.sm.depth.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nuniform vec2 uvRepeat = vec2(1.0, 1.0);\nuniform vec2 uvOffset = vec2(0.0, 0.0);\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nvoid main(){\n vec4 P = vec4(position, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n v_ViewPosition = worldViewProjection * P;\n gl_Position = v_ViewPosition;\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n}\n@end\n@export clay.sm.depth.fragment\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nuniform float bias : 0.001;\nuniform float slopeScale : 1.0;\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\n@import clay.util.encode_float\nvoid main(){\n float depth = v_ViewPosition.z / v_ViewPosition.w;\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n#ifdef USE_VSM\n depth = depth * 0.5 + 0.5;\n float moment1 = depth;\n float moment2 = depth * depth;\n #ifdef SUPPORT_STANDARD_DERIVATIVES\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n moment2 += 0.25*(dx*dx+dy*dy);\n #endif\n gl_FragColor = vec4(moment1, moment2, 0.0, 1.0);\n#else\n #ifdef SUPPORT_STANDARD_DERIVATIVES\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n depth += sqrt(dx*dx + dy*dy) * slopeScale + bias;\n #else\n depth += bias;\n #endif\n gl_FragColor = encodeFloat(depth * 0.5 + 0.5);\n#endif\n}\n@end\n@export clay.sm.debug_depth\nuniform sampler2D depthMap;\nvarying vec2 v_Texcoord;\n@import clay.util.decode_float\nvoid main() {\n vec4 tex = texture2D(depthMap, v_Texcoord);\n#ifdef USE_VSM\n gl_FragColor = vec4(tex.rgb, 1.0);\n#else\n float depth = decodeFloat(tex);\n gl_FragColor = vec4(depth, depth, depth, 1.0);\n#endif\n}\n@end\n@export clay.sm.distance.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 world : WORLD;\nattribute vec3 position : POSITION;\n@import clay.chunk.skinning_header\nvarying vec3 v_WorldPosition;\nvoid main (){\n vec4 P = vec4(position, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n gl_Position = worldViewProjection * P;\n v_WorldPosition = (world * P).xyz;\n}\n@end\n@export clay.sm.distance.fragment\nuniform vec3 lightPosition;\nuniform float range : 100;\nvarying vec3 v_WorldPosition;\n@import clay.util.encode_float\nvoid main(){\n float dist = distance(lightPosition, v_WorldPosition);\n#ifdef USE_VSM\n gl_FragColor = vec4(dist, dist * dist, 0.0, 0.0);\n#else\n dist = dist / range;\n gl_FragColor = encodeFloat(dist);\n#endif\n}\n@end\n@export clay.plugin.shadow_map_common\n@import clay.util.decode_float\nfloat tapShadowMap(sampler2D map, vec2 uv, float z){\n vec4 tex = texture2D(map, uv);\n return step(z, decodeFloat(tex) * 2.0 - 1.0);\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize, vec2 scale) {\n float shadowContrib = tapShadowMap(map, uv, z);\n vec2 offset = vec2(1.0 / textureSize) * scale;\n#ifdef PCF_KERNEL_SIZE\n for (int _idx_ = 0; _idx_ < PCF_KERNEL_SIZE; _idx_++) {{\n shadowContrib += tapShadowMap(map, uv + offset * pcfKernel[_idx_], z);\n }}\n return shadowContrib / float(PCF_KERNEL_SIZE + 1);\n#else\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, -offset.y), z);\n return shadowContrib / 9.0;\n#endif\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize) {\n return pcf(map, uv, z, textureSize, vec2(1.0));\n}\nfloat chebyshevUpperBound(vec2 moments, float z){\n float p = 0.0;\n z = z * 0.5 + 0.5;\n if (z <= moments.x) {\n p = 1.0;\n }\n float variance = moments.y - moments.x * moments.x;\n variance = max(variance, 0.0000001);\n float mD = moments.x - z;\n float pMax = variance / (variance + mD * mD);\n pMax = clamp((pMax-0.4)/(1.0-0.4), 0.0, 1.0);\n return max(p, pMax);\n}\nfloat computeShadowContrib(\n sampler2D map, mat4 lightVPM, vec3 position, float textureSize, vec2 scale, vec2 offset\n) {\n vec4 posInLightSpace = lightVPM * vec4(position, 1.0);\n posInLightSpace.xyz /= posInLightSpace.w;\n float z = posInLightSpace.z;\n if(all(greaterThan(posInLightSpace.xyz, vec3(-0.99, -0.99, -1.0))) &&\n all(lessThan(posInLightSpace.xyz, vec3(0.99, 0.99, 1.0)))){\n vec2 uv = (posInLightSpace.xy+1.0) / 2.0;\n #ifdef USE_VSM\n vec2 moments = texture2D(map, uv * scale + offset).xy;\n return chebyshevUpperBound(moments, z);\n #else\n return pcf(map, uv * scale + offset, z, textureSize, scale);\n #endif\n }\n return 1.0;\n}\nfloat computeShadowContrib(sampler2D map, mat4 lightVPM, vec3 position, float textureSize) {\n return computeShadowContrib(map, lightVPM, position, textureSize, vec2(1.0), vec2(0.0));\n}\nfloat computeShadowContribOmni(samplerCube map, vec3 direction, float range)\n{\n float dist = length(direction);\n vec4 shadowTex = textureCube(map, direction);\n#ifdef USE_VSM\n vec2 moments = shadowTex.xy;\n float variance = moments.y - moments.x * moments.x;\n float mD = moments.x - dist;\n float p = variance / (variance + mD * mD);\n if(moments.x + 0.001 < dist){\n return clamp(p, 0.0, 1.0);\n }else{\n return 1.0;\n }\n#else\n return step(dist, (decodeFloat(shadowTex) + 0.0002) * range);\n#endif\n}\n@end\n@export clay.plugin.compute_shadow_map\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT) || defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT) || defined(POINT_LIGHT_SHADOWMAP_COUNT)\n#ifdef SPOT_LIGHT_SHADOWMAP_COUNT\nuniform sampler2D spotLightShadowMaps[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 spotLightMatrices[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float spotLightShadowMapSizes[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#ifdef DIRECTIONAL_LIGHT_SHADOWMAP_COUNT\n#if defined(SHADOW_CASCADE)\nuniform sampler2D directionalLightShadowMaps[1]:unconfigurable;\nuniform mat4 directionalLightMatrices[SHADOW_CASCADE]:unconfigurable;\nuniform float directionalLightShadowMapSizes[1]:unconfigurable;\nuniform float shadowCascadeClipsNear[SHADOW_CASCADE]:unconfigurable;\nuniform float shadowCascadeClipsFar[SHADOW_CASCADE]:unconfigurable;\n#else\nuniform sampler2D directionalLightShadowMaps[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 directionalLightMatrices[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float directionalLightShadowMapSizes[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#endif\n#ifdef POINT_LIGHT_SHADOWMAP_COUNT\nuniform samplerCube pointLightShadowMaps[POINT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\nuniform bool shadowEnabled : true;\n#ifdef PCF_KERNEL_SIZE\nuniform vec2 pcfKernel[PCF_KERNEL_SIZE];\n#endif\n@import clay.plugin.shadow_map_common\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfSpotLights(vec3 position, inout float shadowContribs[SPOT_LIGHT_COUNT] ) {\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < SPOT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n spotLightShadowMaps[_idx_], spotLightMatrices[_idx_], position,\n spotLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = SPOT_LIGHT_SHADOWMAP_COUNT; _idx_ < SPOT_LIGHT_COUNT; _idx_++){{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n#ifdef SHADOW_CASCADE\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float depth = (2.0 * gl_FragCoord.z - gl_DepthRange.near - gl_DepthRange.far)\n / (gl_DepthRange.far - gl_DepthRange.near);\n float shadowContrib;\n shadowContribs[0] = 1.0;\n for (int _idx_ = 0; _idx_ < SHADOW_CASCADE; _idx_++) {{\n if (\n depth >= shadowCascadeClipsNear[_idx_] &&\n depth <= shadowCascadeClipsFar[_idx_]\n ) {\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[0], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[0],\n vec2(1.0 / float(SHADOW_CASCADE), 1.0),\n vec2(float(_idx_) / float(SHADOW_CASCADE), 0.0)\n );\n shadowContribs[0] = shadowContrib;\n }\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#else\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[_idx_], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfPointLights(vec3 position, inout float shadowContribs[POINT_LIGHT_COUNT] ){\n vec3 lightPosition;\n vec3 direction;\n for(int _idx_ = 0; _idx_ < POINT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n lightPosition = pointLightPosition[_idx_];\n direction = position - lightPosition;\n shadowContribs[_idx_] = computeShadowContribOmni(pointLightShadowMaps[_idx_], direction, pointLightRange[_idx_]);\n }}\n for(int _idx_ = POINT_LIGHT_SHADOWMAP_COUNT; _idx_ < POINT_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n@end");
  15516. var Ns, Is, Rs, Bs, Fs, zs, Gs, Us = m.extend((function () {
  15517. return {
  15518. softShadow: Us.PCF,
  15519. shadowBlur: 1,
  15520. lightFrustumBias: "auto",
  15521. kernelPCF: new Float32Array([1, 0, 1, 1, -1, 1, 0, 1, -1, 0, -1, -1, 1, -1, 0, -1]),
  15522. precision: "highp",
  15523. _lastRenderNotCastShadow: !1,
  15524. _frameBuffer: new zi,
  15525. _textures: {},
  15526. _shadowMapNumber: {
  15527. POINT_LIGHT: 0,
  15528. DIRECTIONAL_LIGHT: 0,
  15529. SPOT_LIGHT: 0
  15530. },
  15531. _depthMaterials: {},
  15532. _distanceMaterials: {},
  15533. _receivers: [],
  15534. _lightsCastShadow: [],
  15535. _lightCameras: {},
  15536. _lightMaterials: {},
  15537. _texturePool: new Ds
  15538. }
  15539. }
  15540. ), (function () {
  15541. this._gaussianPassH = new pn({
  15542. fragment: Xe.source("clay.compositor.gaussian_blur")
  15543. }),
  15544. this._gaussianPassV = new pn({
  15545. fragment: Xe.source("clay.compositor.gaussian_blur")
  15546. }),
  15547. this._gaussianPassH.setUniform("blurSize", this.shadowBlur),
  15548. this._gaussianPassH.setUniform("blurDir", 0),
  15549. this._gaussianPassV.setUniform("blurSize", this.shadowBlur),
  15550. this._gaussianPassV.setUniform("blurDir", 1),
  15551. this._outputDepthPass = new pn({
  15552. fragment: Xe.source("clay.sm.debug_depth")
  15553. })
  15554. }
  15555. ), {
  15556. render: function (e, t, r, i) {
  15557. r || (r = t.getMainCamera()),
  15558. this.trigger("beforerender", this, e, t, r),
  15559. this._renderShadowPass(e, t, r, i),
  15560. this.trigger("afterrender", this, e, t, r)
  15561. },
  15562. renderDebug: function (e, t) {
  15563. e.saveClear();
  15564. var r = e.viewport
  15565. , i = 0
  15566. , n = t || r.width / 4
  15567. , a = n;
  15568. for (var o in this.softShadow === Us.VSM ? this._outputDepthPass.material.define("fragment", "USE_VSM") : this._outputDepthPass.material.undefine("fragment", "USE_VSM"),
  15569. this._textures) {
  15570. var s = this._textures[o];
  15571. e.setViewport(i, 0, n * s.width / s.height, a),
  15572. this._outputDepthPass.setUniform("depthMap", s),
  15573. this._outputDepthPass.render(e),
  15574. i += n * s.width / s.height
  15575. }
  15576. e.setViewport(r),
  15577. e.restoreClear()
  15578. },
  15579. _updateReceivers: function (e, t) {
  15580. if (t.receiveShadow ? (this._receivers.push(t),
  15581. t.material.set("shadowEnabled", 1),
  15582. t.material.set("pcfKernel", this.kernelPCF)) : t.material.set("shadowEnabled", 0),
  15583. this.softShadow === Us.VSM)
  15584. t.material.define("fragment", "USE_VSM"),
  15585. t.material.undefine("fragment", "PCF_KERNEL_SIZE");
  15586. else {
  15587. t.material.undefine("fragment", "USE_VSM");
  15588. var r = this.kernelPCF;
  15589. r && r.length ? t.material.define("fragment", "PCF_KERNEL_SIZE", r.length / 2) : t.material.undefine("fragment", "PCF_KERNEL_SIZE")
  15590. }
  15591. },
  15592. _update: function (e, t) {
  15593. var r = this;
  15594. t.traverse((function (t) {
  15595. t.isRenderable() && r._updateReceivers(e, t)
  15596. }
  15597. ));
  15598. for (var i = 0; i < t.lights.length; i++) {
  15599. var n = t.lights[i];
  15600. n.castShadow && !n.invisible && this._lightsCastShadow.push(n)
  15601. }
  15602. },
  15603. _renderShadowPass: function (e, t, r, i) {
  15604. for (var n in this._shadowMapNumber)
  15605. this._shadowMapNumber[n] = 0;
  15606. this._lightsCastShadow.length = 0,
  15607. this._receivers.length = 0;
  15608. var a = e.gl;
  15609. if (i || t.update(),
  15610. r && r.update(),
  15611. t.updateLights(),
  15612. this._update(e, t),
  15613. this._lightsCastShadow.length || !this._lastRenderNotCastShadow) {
  15614. this._lastRenderNotCastShadow = 0 === this._lightsCastShadow,
  15615. a.enable(a.DEPTH_TEST),
  15616. a.depthMask(!0),
  15617. a.disable(a.BLEND),
  15618. a.clearColor(1, 1, 1, 1);
  15619. for (var o, s = [], l = [], h = [], u = [], c = [], d = [], f = 0; f < this._lightsCastShadow.length; f++) {
  15620. var p = this._lightsCastShadow[f];
  15621. if ("DIRECTIONAL_LIGHT" === p.type) {
  15622. if (o) {
  15623. console.warn("Only one direectional light supported with shadow cascade");
  15624. continue
  15625. }
  15626. if (p.shadowCascade > 4) {
  15627. console.warn("Support at most 4 cascade");
  15628. continue
  15629. }
  15630. p.shadowCascade > 1 && (o = p),
  15631. this.renderDirectionalLightShadow(e, t, r, p, c, u, h)
  15632. } else
  15633. "SPOT_LIGHT" === p.type ? this.renderSpotLightShadow(e, t, p, l, s) : "POINT_LIGHT" === p.type && this.renderPointLightShadow(e, t, p, d);
  15634. this._shadowMapNumber[p.type]++
  15635. }
  15636. for (var m in this._shadowMapNumber) {
  15637. var g = this._shadowMapNumber[m]
  15638. , _ = m + "_SHADOWMAP_COUNT";
  15639. for (f = 0; f < this._receivers.length; f++)
  15640. (v = this._receivers[f].material).fragmentDefines[_] !== g && (g > 0 ? v.define("fragment", _, g) : v.isDefined("fragment", _) && v.undefine("fragment", _))
  15641. }
  15642. for (f = 0; f < this._receivers.length; f++) {
  15643. var v = this._receivers[f].material;
  15644. o ? v.define("fragment", "SHADOW_CASCADE", o.shadowCascade) : v.undefine("fragment", "SHADOW_CASCADE")
  15645. }
  15646. var y = t.shadowUniforms;
  15647. if (h.length > 0) {
  15648. var x = h.map(S);
  15649. if (y.directionalLightShadowMaps = {
  15650. value: h,
  15651. type: "tv"
  15652. },
  15653. y.directionalLightMatrices = {
  15654. value: u,
  15655. type: "m4v"
  15656. },
  15657. y.directionalLightShadowMapSizes = {
  15658. value: x,
  15659. type: "1fv"
  15660. },
  15661. o) {
  15662. var b = c.slice()
  15663. , w = c.slice();
  15664. b.pop(),
  15665. w.shift(),
  15666. b.reverse(),
  15667. w.reverse(),
  15668. u.reverse(),
  15669. y.shadowCascadeClipsNear = {
  15670. value: b,
  15671. type: "1fv"
  15672. },
  15673. y.shadowCascadeClipsFar = {
  15674. value: w,
  15675. type: "1fv"
  15676. }
  15677. }
  15678. }
  15679. if (s.length > 0) {
  15680. var T = s.map(S);
  15681. (y = t.shadowUniforms).spotLightShadowMaps = {
  15682. value: s,
  15683. type: "tv"
  15684. },
  15685. y.spotLightMatrices = {
  15686. value: l,
  15687. type: "m4v"
  15688. },
  15689. y.spotLightShadowMapSizes = {
  15690. value: T,
  15691. type: "1fv"
  15692. }
  15693. }
  15694. d.length > 0 && (y.pointLightShadowMaps = {
  15695. value: d,
  15696. type: "tv"
  15697. })
  15698. }
  15699. function S(e) {
  15700. return e.height
  15701. }
  15702. },
  15703. renderDirectionalLightShadow: (Ns = new si,
  15704. Is = new Ht,
  15705. Rs = new ir,
  15706. Bs = new Ht,
  15707. Fs = new Ht,
  15708. zs = new Ht,
  15709. Gs = new Ht,
  15710. function (e, t, r, i, n, a, o) {
  15711. var s = this._getDepthMaterial(i)
  15712. , l = {
  15713. getMaterial: function (e) {
  15714. return e.shadowDepthMaterial || s
  15715. },
  15716. isMaterialChanged: Os,
  15717. getUniform: Ps,
  15718. ifRender: function (e) {
  15719. return e.castShadow
  15720. },
  15721. sortCompare: ut.opaqueSortCompare
  15722. };
  15723. if (!t.viewBoundingBoxLastFrame.isFinite()) {
  15724. var h = t.getBoundingBox();
  15725. t.viewBoundingBoxLastFrame.copy(h).applyTransform(r.viewMatrix)
  15726. }
  15727. var u = Math.min(-t.viewBoundingBoxLastFrame.min.z, r.far)
  15728. , c = Math.max(-t.viewBoundingBoxLastFrame.max.z, r.near)
  15729. , d = this._getDirectionalLightCamera(i, t, r)
  15730. , f = zs.array;
  15731. Gs.copy(d.projectionMatrix),
  15732. Ye.invert(Fs.array, d.worldTransform.array),
  15733. Ye.multiply(Fs.array, Fs.array, r.worldTransform.array),
  15734. Ye.multiply(f, Gs.array, Fs.array);
  15735. for (var p = [], m = r instanceof Ei, g = (r.near + r.far) / (r.near - r.far), _ = 2 * r.near * r.far / (r.near - r.far), v = 0; v <= i.shadowCascade; v++) {
  15736. var y = c * Math.pow(u / c, v / i.shadowCascade)
  15737. , x = c + (u - c) * v / i.shadowCascade
  15738. , b = y * i.cascadeSplitLogFactor + x * (1 - i.cascadeSplitLogFactor);
  15739. p.push(b),
  15740. n.push(-(-b * g + _) / -b)
  15741. }
  15742. var w = this._getTexture(i, i.shadowCascade);
  15743. o.push(w);
  15744. var T = e.viewport
  15745. , S = e.gl;
  15746. for (this._frameBuffer.attach(w),
  15747. this._frameBuffer.bind(e),
  15748. S.clear(S.COLOR_BUFFER_BIT | S.DEPTH_BUFFER_BIT),
  15749. v = 0; v < i.shadowCascade; v++) {
  15750. var M = p[v]
  15751. , A = p[v + 1];
  15752. m ? Ye.perspective(Is.array, r.fov / 180 * Math.PI, r.aspect, M, A) : Ye.ortho(Is.array, r.left, r.right, r.bottom, r.top, M, A),
  15753. Ns.setFromProjection(Is),
  15754. Ns.getTransformedBoundingBox(Rs, Fs),
  15755. Rs.applyProjection(Gs);
  15756. var E = Rs.min.array
  15757. , C = Rs.max.array;
  15758. E[0] = Math.max(E[0], -1),
  15759. E[1] = Math.max(E[1], -1),
  15760. C[0] = Math.min(C[0], 1),
  15761. C[1] = Math.min(C[1], 1),
  15762. Bs.ortho(E[0], C[0], E[1], C[1], 1, -1),
  15763. d.projectionMatrix.multiplyLeft(Bs);
  15764. var D = i.shadowResolution || 512;
  15765. e.setViewport((i.shadowCascade - v - 1) * D, 0, D, D, 1);
  15766. var L = t.updateRenderList(d);
  15767. e.renderPass(L.opaque, d, l),
  15768. this.softShadow === Us.VSM && this._gaussianFilter(e, w, w.width);
  15769. var P = new Ht;
  15770. P.copy(d.viewMatrix).multiplyLeft(d.projectionMatrix),
  15771. a.push(P.array),
  15772. d.projectionMatrix.copy(Gs)
  15773. }
  15774. this._frameBuffer.unbind(e),
  15775. e.setViewport(T)
  15776. }
  15777. ),
  15778. renderSpotLightShadow: function (e, t, r, i, n) {
  15779. var a = this._getTexture(r)
  15780. , o = this._getSpotLightCamera(r)
  15781. , s = e.gl;
  15782. this._frameBuffer.attach(a),
  15783. this._frameBuffer.bind(e),
  15784. s.clear(s.COLOR_BUFFER_BIT | s.DEPTH_BUFFER_BIT);
  15785. var l = this._getDepthMaterial(r)
  15786. , h = {
  15787. getMaterial: function (e) {
  15788. return e.shadowDepthMaterial || l
  15789. },
  15790. isMaterialChanged: Os,
  15791. getUniform: Ps,
  15792. ifRender: function (e) {
  15793. return e.castShadow
  15794. },
  15795. sortCompare: ut.opaqueSortCompare
  15796. }
  15797. , u = t.updateRenderList(o);
  15798. e.renderPass(u.opaque, o, h),
  15799. this._frameBuffer.unbind(e),
  15800. this.softShadow === Us.VSM && this._gaussianFilter(e, a, a.width);
  15801. var c = new Ht;
  15802. c.copy(o.worldTransform).invert().multiplyLeft(o.projectionMatrix),
  15803. n.push(a),
  15804. i.push(c.array)
  15805. },
  15806. renderPointLightShadow: function (e, t, r, i) {
  15807. var n = this._getTexture(r)
  15808. , a = e.gl;
  15809. i.push(n);
  15810. var o = this._getDepthMaterial(r)
  15811. , s = {
  15812. getMaterial: function (e) {
  15813. return e.shadowDepthMaterial || o
  15814. },
  15815. getUniform: Ps,
  15816. sortCompare: ut.opaqueSortCompare
  15817. }
  15818. , l = {
  15819. px: [],
  15820. py: [],
  15821. pz: [],
  15822. nx: [],
  15823. ny: [],
  15824. nz: []
  15825. }
  15826. , h = new ir
  15827. , u = r.getWorldPosition().array
  15828. , c = new ir
  15829. , d = r.range;
  15830. c.min.setArray(u),
  15831. c.max.setArray(u);
  15832. var f = new vt(d, d, d);
  15833. c.max.add(f),
  15834. c.min.sub(f);
  15835. var p = {
  15836. px: !1,
  15837. py: !1,
  15838. pz: !1,
  15839. nx: !1,
  15840. ny: !1,
  15841. nz: !1
  15842. };
  15843. t.traverse((function (e) {
  15844. if (e.isRenderable() && e.castShadow) {
  15845. var t = e.geometry;
  15846. if (!t.boundingBox) {
  15847. for (var r = 0; r < Ls.length; r++)
  15848. l[Ls[r]].push(e);
  15849. return
  15850. }
  15851. if (h.transformFrom(t.boundingBox, e.worldTransform),
  15852. !h.intersectBoundingBox(c))
  15853. return;
  15854. for (h.updateVertices(),
  15855. r = 0; r < Ls.length; r++)
  15856. p[Ls[r]] = !1;
  15857. for (r = 0; r < 8; r++) {
  15858. var i = h.vertices[r]
  15859. , n = i[0] - u[0]
  15860. , a = i[1] - u[1]
  15861. , o = i[2] - u[2]
  15862. , s = Math.abs(n)
  15863. , d = Math.abs(a)
  15864. , f = Math.abs(o);
  15865. s > d ? s > f ? p[n > 0 ? "px" : "nx"] = !0 : p[o > 0 ? "pz" : "nz"] = !0 : d > f ? p[a > 0 ? "py" : "ny"] = !0 : p[o > 0 ? "pz" : "nz"] = !0
  15866. }
  15867. for (r = 0; r < Ls.length; r++)
  15868. p[Ls[r]] && l[Ls[r]].push(e)
  15869. }
  15870. }
  15871. ));
  15872. for (var m = 0; m < 6; m++) {
  15873. var g = Ls[m]
  15874. , _ = this._getPointLightCamera(r, g);
  15875. this._frameBuffer.attach(n, a.COLOR_ATTACHMENT0, a.TEXTURE_CUBE_MAP_POSITIVE_X + m),
  15876. this._frameBuffer.bind(e),
  15877. a.clear(a.COLOR_BUFFER_BIT | a.DEPTH_BUFFER_BIT),
  15878. e.renderPass(l[g], _, s)
  15879. }
  15880. this._frameBuffer.unbind(e)
  15881. },
  15882. _getDepthMaterial: function (e) {
  15883. var t = this._lightMaterials[e.__uid__]
  15884. , r = "POINT_LIGHT" === e.type;
  15885. if (!t) {
  15886. var i = r ? "clay.sm.distance." : "clay.sm.depth.";
  15887. t = new le({
  15888. precision: this.precision,
  15889. shader: new Xe(Xe.source(i + "vertex"), Xe.source(i + "fragment"))
  15890. }),
  15891. this._lightMaterials[e.__uid__] = t
  15892. }
  15893. return null != e.shadowSlopeScale && t.setUniform("slopeScale", e.shadowSlopeScale),
  15894. null != e.shadowBias && t.setUniform("bias", e.shadowBias),
  15895. this.softShadow === Us.VSM ? t.define("fragment", "USE_VSM") : t.undefine("fragment", "USE_VSM"),
  15896. r && (t.set("lightPosition", e.getWorldPosition().array),
  15897. t.set("range", e.range)),
  15898. t
  15899. },
  15900. _gaussianFilter: function (e, t, r) {
  15901. var i = {
  15902. width: r,
  15903. height: r,
  15904. type: wr.FLOAT
  15905. }
  15906. , n = this._texturePool.get(i);
  15907. this._frameBuffer.attach(n),
  15908. this._frameBuffer.bind(e),
  15909. this._gaussianPassH.setUniform("texture", t),
  15910. this._gaussianPassH.setUniform("textureWidth", r),
  15911. this._gaussianPassH.render(e),
  15912. this._frameBuffer.attach(t),
  15913. this._gaussianPassV.setUniform("texture", n),
  15914. this._gaussianPassV.setUniform("textureHeight", r),
  15915. this._gaussianPassV.render(e),
  15916. this._frameBuffer.unbind(e),
  15917. this._texturePool.put(n)
  15918. },
  15919. _getTexture: function (e, t) {
  15920. var r = e.__uid__
  15921. , i = this._textures[r]
  15922. , n = e.shadowResolution || 512;
  15923. return t = t || 1,
  15924. i || ((i = "POINT_LIGHT" === e.type ? new Ai : new Dr).width = n * t,
  15925. i.height = n,
  15926. this.softShadow === Us.VSM ? (i.type = wr.FLOAT,
  15927. i.anisotropic = 4) : (i.minFilter = E,
  15928. i.magFilter = E,
  15929. i.useMipmap = !1),
  15930. this._textures[r] = i),
  15931. i
  15932. },
  15933. _getPointLightCamera: function (e, t) {
  15934. this._lightCameras.point || (this._lightCameras.point = {
  15935. px: new Ei,
  15936. nx: new Ei,
  15937. py: new Ei,
  15938. ny: new Ei,
  15939. pz: new Ei,
  15940. nz: new Ei
  15941. });
  15942. var r = this._lightCameras.point[t];
  15943. switch (r.far = e.range,
  15944. r.fov = 90,
  15945. r.position.set(0, 0, 0),
  15946. t) {
  15947. case "px":
  15948. r.lookAt(vt.POSITIVE_X, vt.NEGATIVE_Y);
  15949. break;
  15950. case "nx":
  15951. r.lookAt(vt.NEGATIVE_X, vt.NEGATIVE_Y);
  15952. break;
  15953. case "py":
  15954. r.lookAt(vt.POSITIVE_Y, vt.POSITIVE_Z);
  15955. break;
  15956. case "ny":
  15957. r.lookAt(vt.NEGATIVE_Y, vt.NEGATIVE_Z);
  15958. break;
  15959. case "pz":
  15960. r.lookAt(vt.POSITIVE_Z, vt.NEGATIVE_Y);
  15961. break;
  15962. case "nz":
  15963. r.lookAt(vt.NEGATIVE_Z, vt.NEGATIVE_Y)
  15964. }
  15965. return e.getWorldPosition(r.position),
  15966. r.update(),
  15967. r
  15968. },
  15969. _getDirectionalLightCamera: function () {
  15970. var e = new Ht
  15971. , t = new ir
  15972. , r = new ir;
  15973. return function (i, n, a) {
  15974. this._lightCameras.directional || (this._lightCameras.directional = new un);
  15975. var o = this._lightCameras.directional;
  15976. t.copy(n.viewBoundingBoxLastFrame),
  15977. t.intersection(a.frustum.boundingBox),
  15978. o.position.copy(t.min).add(t.max).scale(.5).transformMat4(a.worldTransform),
  15979. o.rotation.copy(i.rotation),
  15980. o.scale.copy(i.scale),
  15981. o.updateWorldTransform(),
  15982. Ht.invert(e, o.worldTransform),
  15983. Ht.multiply(e, e, a.worldTransform),
  15984. r.copy(t).applyTransform(e);
  15985. var s = r.min.array
  15986. , l = r.max.array;
  15987. return o.position.set((s[0] + l[0]) / 2, (s[1] + l[1]) / 2, l[2]).transformMat4(o.worldTransform),
  15988. o.near = 0,
  15989. o.far = -s[2] + l[2],
  15990. isNaN(this.lightFrustumBias) ? o.far *= 4 : o.far += this.lightFrustumBias,
  15991. o.left = s[0],
  15992. o.right = l[0],
  15993. o.top = l[1],
  15994. o.bottom = s[1],
  15995. o.update(!0),
  15996. o
  15997. }
  15998. }(),
  15999. _getSpotLightCamera: function (e) {
  16000. this._lightCameras.spot || (this._lightCameras.spot = new Ei);
  16001. var t = this._lightCameras.spot;
  16002. return t.fov = 2 * e.penumbraAngle,
  16003. t.far = e.range,
  16004. t.worldTransform.copy(e.worldTransform),
  16005. t.updateProjectionMatrix(),
  16006. Ye.invert(t.viewMatrix.array, t.worldTransform.array),
  16007. t
  16008. },
  16009. dispose: function (e) {
  16010. var t = e.gl || e;
  16011. for (var r in this._frameBuffer && this._frameBuffer.dispose(t),
  16012. this._textures)
  16013. this._textures[r].dispose(t);
  16014. this._texturePool.clear(e.gl),
  16015. this._depthMaterials = {},
  16016. this._distanceMaterials = {},
  16017. this._textures = {},
  16018. this._lightCameras = {},
  16019. this._shadowMapNumber = {
  16020. POINT_LIGHT: 0,
  16021. DIRECTIONAL_LIGHT: 0,
  16022. SPOT_LIGHT: 0
  16023. },
  16024. this._meshMaterials = {};
  16025. for (var i = 0; i < this._receivers.length; i++) {
  16026. var n = this._receivers[i];
  16027. if (n.material) {
  16028. var a = n.material;
  16029. a.undefine("fragment", "POINT_LIGHT_SHADOW_COUNT"),
  16030. a.undefine("fragment", "DIRECTIONAL_LIGHT_SHADOW_COUNT"),
  16031. a.undefine("fragment", "AMBIENT_LIGHT_SHADOW_COUNT"),
  16032. a.set("shadowEnabled", 0)
  16033. }
  16034. }
  16035. this._receivers = [],
  16036. this._lightsCastShadow = []
  16037. }
  16038. });
  16039. Us.VSM = 1,
  16040. Us.PCF = 2;
  16041. const ks = Us
  16042. , Vs = m.extend((function () {
  16043. return {
  16044. name: "",
  16045. inputLinks: {},
  16046. outputLinks: {},
  16047. _prevOutputTextures: {},
  16048. _outputTextures: {},
  16049. _outputReferences: {},
  16050. _rendering: !1,
  16051. _rendered: !1,
  16052. _compositor: null
  16053. }
  16054. }
  16055. ), {
  16056. updateParameter: function (e, t) {
  16057. var r, i, n = this.outputs[e], a = n.parameters, o = n._parametersCopy;
  16058. if (o || (o = n._parametersCopy = {}),
  16059. a)
  16060. for (var s in a)
  16061. "width" !== s && "height" !== s && (o[s] = a[s]);
  16062. return r = a.width instanceof Function ? a.width.call(this, t) : a.width,
  16063. i = a.height instanceof Function ? a.height.call(this, t) : a.height,
  16064. o.width === r && o.height === i || this._outputTextures[e] && this._outputTextures[e].dispose(t.gl),
  16065. o.width = r,
  16066. o.height = i,
  16067. o
  16068. },
  16069. setParameter: function (e, t) { },
  16070. getParameter: function (e) { },
  16071. setParameters: function (e) {
  16072. for (var t in e)
  16073. this.setParameter(t, e[t])
  16074. },
  16075. render: function () { },
  16076. getOutput: function (e, t) {
  16077. if (null == t)
  16078. return t = e,
  16079. this._outputTextures[t];
  16080. var r = this.outputs[t];
  16081. return r ? this._rendered ? r.outputLastFrame ? this._prevOutputTextures[t] : this._outputTextures[t] : this._rendering ? (this._prevOutputTextures[t] || (this._prevOutputTextures[t] = this._compositor.allocateTexture(r.parameters || {})),
  16082. this._prevOutputTextures[t]) : (this.render(e),
  16083. this._outputTextures[t]) : void 0
  16084. },
  16085. removeReference: function (e) {
  16086. this._outputReferences[e]--,
  16087. 0 === this._outputReferences[e] && (this.outputs[e].keepLastFrame ? (this._prevOutputTextures[e] && this._compositor.releaseTexture(this._prevOutputTextures[e]),
  16088. this._prevOutputTextures[e] = this._outputTextures[e]) : this._compositor.releaseTexture(this._outputTextures[e]))
  16089. },
  16090. link: function (e, t, r) {
  16091. this.inputLinks[e] = {
  16092. node: t,
  16093. pin: r
  16094. },
  16095. t.outputLinks[r] || (t.outputLinks[r] = []),
  16096. t.outputLinks[r].push({
  16097. node: this,
  16098. pin: e
  16099. }),
  16100. this.pass.material.enableTexture(e)
  16101. },
  16102. clear: function () {
  16103. this.inputLinks = {},
  16104. this.outputLinks = {}
  16105. },
  16106. updateReference: function (e) {
  16107. if (!this._rendering) {
  16108. for (var t in this._rendering = !0,
  16109. this.inputLinks) {
  16110. var r = this.inputLinks[t];
  16111. r.node.updateReference(r.pin)
  16112. }
  16113. this._rendering = !1
  16114. }
  16115. e && this._outputReferences[e]++
  16116. },
  16117. beforeFrame: function () {
  16118. for (var e in this._rendered = !1,
  16119. this.outputLinks)
  16120. this._outputReferences[e] = 0
  16121. },
  16122. afterFrame: function () {
  16123. for (var e in this.outputLinks)
  16124. this._outputReferences[e] > 0 && (this.outputs[e].keepLastFrame ? (this._prevOutputTextures[e] && this._compositor.releaseTexture(this._prevOutputTextures[e]),
  16125. this._prevOutputTextures[e] = this._outputTextures[e]) : this._compositor.releaseTexture(this._outputTextures[e]))
  16126. }
  16127. })
  16128. , Hs = m.extend((function () {
  16129. return {
  16130. nodes: []
  16131. }
  16132. }
  16133. ), {
  16134. dirty: function () {
  16135. this._dirty = !0
  16136. },
  16137. addNode: function (e) {
  16138. this.nodes.indexOf(e) >= 0 || (this.nodes.push(e),
  16139. this._dirty = !0)
  16140. },
  16141. removeNode: function (e) {
  16142. "string" == typeof e && (e = this.getNodeByName(e));
  16143. var t = this.nodes.indexOf(e);
  16144. t >= 0 && (this.nodes.splice(t, 1),
  16145. this._dirty = !0)
  16146. },
  16147. getNodeByName: function (e) {
  16148. for (var t = 0; t < this.nodes.length; t++)
  16149. if (this.nodes[t].name === e)
  16150. return this.nodes[t]
  16151. },
  16152. update: function () {
  16153. for (var e = 0; e < this.nodes.length; e++)
  16154. this.nodes[e].clear();
  16155. for (e = 0; e < this.nodes.length; e++) {
  16156. var t = this.nodes[e];
  16157. if (t.inputs)
  16158. for (var r in t.inputs)
  16159. if (t.inputs[r])
  16160. if (!t.pass || t.pass.material.isUniformEnabled(r)) {
  16161. var i = t.inputs[r]
  16162. , n = this.findPin(i);
  16163. n ? t.link(r, n.node, n.pin) : "string" == typeof i ? console.warn("Node " + i + " not exist") : console.warn("Pin of " + i.node + "." + i.pin + " not exist")
  16164. } else
  16165. console.warn("Pin " + t.name + "." + r + " not used.")
  16166. }
  16167. },
  16168. findPin: function (e) {
  16169. var t;
  16170. if (("string" == typeof e || e instanceof Vs) && (e = {
  16171. node: e
  16172. }),
  16173. "string" == typeof e.node)
  16174. for (var r = 0; r < this.nodes.length; r++) {
  16175. var i = this.nodes[r];
  16176. i.name === e.node && (t = i)
  16177. }
  16178. else
  16179. t = e.node;
  16180. if (t) {
  16181. var n = e.pin;
  16182. if (n || t.outputs && (n = Object.keys(t.outputs)[0]),
  16183. t.outputs[n])
  16184. return {
  16185. node: t,
  16186. pin: n
  16187. }
  16188. }
  16189. }
  16190. })
  16191. , Ws = Hs.extend((function () {
  16192. return {
  16193. _outputs: [],
  16194. _texturePool: new Ds,
  16195. _frameBuffer: new zi({
  16196. depthBuffer: !1
  16197. })
  16198. }
  16199. }
  16200. ), {
  16201. addNode: function (e) {
  16202. Hs.prototype.addNode.call(this, e),
  16203. e._compositor = this
  16204. },
  16205. render: function (e, t) {
  16206. if (this._dirty) {
  16207. this.update(),
  16208. this._dirty = !1,
  16209. this._outputs.length = 0;
  16210. for (var r = 0; r < this.nodes.length; r++)
  16211. this.nodes[r].outputs || this._outputs.push(this.nodes[r])
  16212. }
  16213. for (r = 0; r < this.nodes.length; r++)
  16214. this.nodes[r].beforeFrame();
  16215. for (r = 0; r < this._outputs.length; r++)
  16216. this._outputs[r].updateReference();
  16217. for (r = 0; r < this._outputs.length; r++)
  16218. this._outputs[r].render(e, t);
  16219. for (r = 0; r < this.nodes.length; r++)
  16220. this.nodes[r].afterFrame()
  16221. },
  16222. allocateTexture: function (e) {
  16223. return this._texturePool.get(e)
  16224. },
  16225. releaseTexture: function (e) {
  16226. this._texturePool.put(e)
  16227. },
  16228. getFrameBuffer: function () {
  16229. return this._frameBuffer
  16230. },
  16231. dispose: function (e) {
  16232. this._texturePool.clear(e)
  16233. }
  16234. })
  16235. , js = Vs.extend({
  16236. name: "scene",
  16237. scene: null,
  16238. camera: null,
  16239. autoUpdateScene: !0,
  16240. preZ: !1
  16241. }, (function () {
  16242. this.frameBuffer = new zi
  16243. }
  16244. ), {
  16245. render: function (e) {
  16246. this._rendering = !0;
  16247. var t, r = e.gl;
  16248. if (this.trigger("beforerender"),
  16249. this.outputs) {
  16250. var i = this.frameBuffer;
  16251. for (var n in this.outputs) {
  16252. var a = this.updateParameter(n, e)
  16253. , o = this.outputs[n]
  16254. , s = this._compositor.allocateTexture(a);
  16255. this._outputTextures[n] = s,
  16256. "string" == typeof (u = o.attachment || r.COLOR_ATTACHMENT0) && (u = r[u]),
  16257. i.attach(s, u)
  16258. }
  16259. i.bind(e);
  16260. var l = e.getGLExtension("EXT_draw_buffers");
  16261. if (l) {
  16262. var h = [];
  16263. for (var u in this.outputs)
  16264. (u = parseInt(u)) >= r.COLOR_ATTACHMENT0 && u <= r.COLOR_ATTACHMENT0 + 8 && h.push(u);
  16265. l.drawBuffersEXT(h)
  16266. }
  16267. e.saveClear(),
  16268. e.clearBit = 16640,
  16269. t = e.render(this.scene, this.camera, !this.autoUpdateScene, this.preZ),
  16270. e.restoreClear(),
  16271. i.unbind(e)
  16272. } else
  16273. t = e.render(this.scene, this.camera, !this.autoUpdateScene, this.preZ);
  16274. this.trigger("afterrender", t),
  16275. this._rendering = !1,
  16276. this._rendered = !0
  16277. }
  16278. })
  16279. , Xs = Vs.extend((function () {
  16280. return {
  16281. texture: null,
  16282. outputs: {
  16283. color: {}
  16284. }
  16285. }
  16286. }
  16287. ), (function () { }
  16288. ), {
  16289. getOutput: function (e, t) {
  16290. return this.texture
  16291. },
  16292. beforeFrame: function () { },
  16293. afterFrame: function () { }
  16294. })
  16295. , qs = Vs.extend((function () {
  16296. return {
  16297. name: "",
  16298. inputs: {},
  16299. outputs: null,
  16300. shader: "",
  16301. inputLinks: {},
  16302. outputLinks: {},
  16303. pass: null,
  16304. _prevOutputTextures: {},
  16305. _outputTextures: {},
  16306. _outputReferences: {},
  16307. _rendering: !1,
  16308. _rendered: !1,
  16309. _compositor: null
  16310. }
  16311. }
  16312. ), (function () {
  16313. var e = new pn({
  16314. fragment: this.shader
  16315. });
  16316. this.pass = e
  16317. }
  16318. ), {
  16319. render: function (e, t) {
  16320. this.trigger("beforerender", e),
  16321. this._rendering = !0;
  16322. var r = e.gl;
  16323. for (var i in this.inputLinks) {
  16324. var n = (c = this.inputLinks[i]).node.getOutput(e, c.pin);
  16325. this.pass.setUniform(i, n)
  16326. }
  16327. if (this.outputs) {
  16328. this.pass.outputs = {};
  16329. var a = {};
  16330. for (var o in this.outputs) {
  16331. var s = this.updateParameter(o, e);
  16332. isNaN(s.width) && this.updateParameter(o, e);
  16333. var l = this.outputs[o]
  16334. , h = this._compositor.allocateTexture(s);
  16335. this._outputTextures[o] = h,
  16336. "string" == typeof (u = l.attachment || r.COLOR_ATTACHMENT0) && (u = r[u]),
  16337. a[u] = h
  16338. }
  16339. for (var u in this._compositor.getFrameBuffer().bind(e),
  16340. a)
  16341. this._compositor.getFrameBuffer().attach(a[u], u);
  16342. this.pass.render(e),
  16343. this._compositor.getFrameBuffer().updateMipmap(e)
  16344. } else
  16345. this.pass.outputs = null,
  16346. this._compositor.getFrameBuffer().unbind(e),
  16347. this.pass.render(e, t);
  16348. for (var i in this.inputLinks) {
  16349. var c;
  16350. (c = this.inputLinks[i]).node.removeReference(c.pin)
  16351. }
  16352. this._rendering = !1,
  16353. this._rendered = !0,
  16354. this.trigger("afterrender", e)
  16355. },
  16356. updateParameter: function (e, t) {
  16357. var r, i, n = this.outputs[e], a = n.parameters, o = n._parametersCopy;
  16358. if (o || (o = n._parametersCopy = {}),
  16359. a)
  16360. for (var s in a)
  16361. "width" !== s && "height" !== s && (o[s] = a[s]);
  16362. return r = "function" == typeof a.width ? a.width.call(this, t) : a.width,
  16363. i = "function" == typeof a.height ? a.height.call(this, t) : a.height,
  16364. r = Math.ceil(r),
  16365. i = Math.ceil(i),
  16366. o.width === r && o.height === i || this._outputTextures[e] && this._outputTextures[e].dispose(t),
  16367. o.width = r,
  16368. o.height = i,
  16369. o
  16370. },
  16371. setParameter: function (e, t) {
  16372. this.pass.setUniform(e, t)
  16373. },
  16374. getParameter: function (e) {
  16375. return this.pass.getUniform(e)
  16376. },
  16377. setParameters: function (e) {
  16378. for (var t in e)
  16379. this.setParameter(t, e[t])
  16380. },
  16381. define: function (e, t) {
  16382. this.pass.material.define("fragment", e, t)
  16383. },
  16384. undefine: function (e) {
  16385. this.pass.material.undefine("fragment", e)
  16386. },
  16387. removeReference: function (e) {
  16388. this._outputReferences[e]--,
  16389. 0 === this._outputReferences[e] && (this.outputs[e].keepLastFrame ? (this._prevOutputTextures[e] && this._compositor.releaseTexture(this._prevOutputTextures[e]),
  16390. this._prevOutputTextures[e] = this._outputTextures[e]) : this._compositor.releaseTexture(this._outputTextures[e]))
  16391. },
  16392. clear: function () {
  16393. Vs.prototype.clear.call(this),
  16394. this.pass.material.disableTexturesAll()
  16395. }
  16396. })
  16397. , Zs = "@export clay.compositor.kernel.gaussian_9\nfloat gaussianKernel[9];\ngaussianKernel[0] = 0.07;\ngaussianKernel[1] = 0.09;\ngaussianKernel[2] = 0.12;\ngaussianKernel[3] = 0.14;\ngaussianKernel[4] = 0.16;\ngaussianKernel[5] = 0.14;\ngaussianKernel[6] = 0.12;\ngaussianKernel[7] = 0.09;\ngaussianKernel[8] = 0.07;\n@end\n@export clay.compositor.kernel.gaussian_13\nfloat gaussianKernel[13];\ngaussianKernel[0] = 0.02;\ngaussianKernel[1] = 0.03;\ngaussianKernel[2] = 0.06;\ngaussianKernel[3] = 0.08;\ngaussianKernel[4] = 0.11;\ngaussianKernel[5] = 0.13;\ngaussianKernel[6] = 0.14;\ngaussianKernel[7] = 0.13;\ngaussianKernel[8] = 0.11;\ngaussianKernel[9] = 0.08;\ngaussianKernel[10] = 0.06;\ngaussianKernel[11] = 0.03;\ngaussianKernel[12] = 0.02;\n@end\n@export clay.compositor.gaussian_blur\n#define SHADER_NAME gaussian_blur\nuniform sampler2D texture;varying vec2 v_Texcoord;\nuniform float blurSize : 2.0;\nuniform vec2 textureSize : [512.0, 512.0];\nuniform float blurDir : 0.0;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main (void)\n{\n @import clay.compositor.kernel.gaussian_9\n vec2 off = blurSize / textureSize;\n off *= vec2(1.0 - blurDir, blurDir);\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n for (int i = 0; i < 9; i++) {\n float w = gaussianKernel[i];\n vec4 texel = decodeHDR(clampSample(texture, v_Texcoord + float(i - 4) * off));\n sum += texel * w;\n weightAll += w;\n }\n gl_FragColor = encodeHDR(sum / max(weightAll, 0.01));\n}\n@end\n"
  16398. , Ys = "\n@export clay.compositor.lut\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform sampler2D lookup;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n float blueColor = tex.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec4 newColor1 = texture2D(lookup, texPos1);\n vec4 newColor2 = texture2D(lookup, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n gl_FragColor = vec4(newColor.rgb, tex.w);\n}\n@end"
  16399. , Ks = "@export clay.compositor.output\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = tex.rgb;\n#ifdef OUTPUT_ALPHA\n gl_FragColor.a = tex.a;\n#else\n gl_FragColor.a = 1.0;\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end"
  16400. , Qs = "@export clay.compositor.bright\nuniform sampler2D texture;\nuniform float threshold : 1;\nuniform float scale : 1.0;\nuniform vec2 textureSize: [512, 512];\nvarying vec2 v_Texcoord;\nconst vec3 lumWeight = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvec4 median(vec4 a, vec4 b, vec4 c)\n{\n return a + b + c - min(min(a, b), c) - max(max(a, b), c);\n}\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n#ifdef ANTI_FLICKER\n vec3 d = 1.0 / textureSize.xyx * vec3(1.0, 1.0, 0.0);\n vec4 s1 = decodeHDR(texture2D(texture, v_Texcoord - d.xz));\n vec4 s2 = decodeHDR(texture2D(texture, v_Texcoord + d.xz));\n vec4 s3 = decodeHDR(texture2D(texture, v_Texcoord - d.zy));\n vec4 s4 = decodeHDR(texture2D(texture, v_Texcoord + d.zy));\n texel = median(median(texel, s1, s2), s3, s4);\n#endif\n float lum = dot(texel.rgb , lumWeight);\n vec4 color;\n if (lum > threshold && texel.a > 0.0)\n {\n color = vec4(texel.rgb * scale, texel.a * scale);\n }\n else\n {\n color = vec4(0.0);\n }\n gl_FragColor = encodeHDR(color);\n}\n@end\n"
  16401. , Js = "@export clay.compositor.downsample\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nfloat brightness(vec3 c)\n{\n return max(max(c.r, c.g), c.b);\n}\n@import clay.util.clamp_sample\nvoid main()\n{\n vec4 d = vec4(-1.0, -1.0, 1.0, 1.0) / textureSize.xyxy;\n#ifdef ANTI_FLICKER\n vec3 s1 = decodeHDR(clampSample(texture, v_Texcoord + d.xy)).rgb;\n vec3 s2 = decodeHDR(clampSample(texture, v_Texcoord + d.zy)).rgb;\n vec3 s3 = decodeHDR(clampSample(texture, v_Texcoord + d.xw)).rgb;\n vec3 s4 = decodeHDR(clampSample(texture, v_Texcoord + d.zw)).rgb;\n float s1w = 1.0 / (brightness(s1) + 1.0);\n float s2w = 1.0 / (brightness(s2) + 1.0);\n float s3w = 1.0 / (brightness(s3) + 1.0);\n float s4w = 1.0 / (brightness(s4) + 1.0);\n float oneDivideSum = 1.0 / (s1w + s2w + s3w + s4w);\n vec4 color = vec4(\n (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * oneDivideSum,\n 1.0\n );\n#else\n vec4 color = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n color *= 0.25;\n#endif\n gl_FragColor = encodeHDR(color);\n}\n@end"
  16402. , $s = "\n@export clay.compositor.upsample\n#define HIGH_QUALITY\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nuniform float sampleScale: 0.5;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main()\n{\n#ifdef HIGH_QUALITY\n vec4 d = vec4(1.0, 1.0, -1.0, 0.0) / textureSize.xyxy * sampleScale;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord - d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord - d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord - d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord )) * 4.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n gl_FragColor = encodeHDR(s / 16.0);\n#else\n vec4 d = vec4(-1.0, -1.0, +1.0, +1.0) / textureSize.xyxy;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n gl_FragColor = encodeHDR(s / 4.0);\n#endif\n}\n@end"
  16403. , el = "@export clay.compositor.hdr.composite\n#define TONEMAPPING\nuniform sampler2D texture;\n#ifdef BLOOM_ENABLED\nuniform sampler2D bloom;\n#endif\n#ifdef LENSFLARE_ENABLED\nuniform sampler2D lensflare;\nuniform sampler2D lensdirt;\n#endif\n#ifdef LUM_ENABLED\nuniform sampler2D lum;\n#endif\n#ifdef LUT_ENABLED\nuniform sampler2D lut;\n#endif\n#ifdef COLOR_CORRECTION\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float saturation : 1.0;\n#endif\n#ifdef VIGNETTE\nuniform float vignetteDarkness: 1.0;\nuniform float vignetteOffset: 1.0;\n#endif\nuniform float exposure : 1.0;\nuniform float bloomIntensity : 0.25;\nuniform float lensflareIntensity : 1;\nvarying vec2 v_Texcoord;\n@import clay.util.srgb\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nfloat eyeAdaption(float fLum)\n{\n return mix(0.2, fLum, 0.5);\n}\n#ifdef LUT_ENABLED\nvec3 lutTransform(vec3 color) {\n float blueColor = color.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec4 newColor1 = texture2D(lut, texPos1);\n vec4 newColor2 = texture2D(lut, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n return newColor.rgb;\n}\n#endif\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = vec4(0.0);\n vec4 originalTexel = vec4(0.0);\n#ifdef TEXTURE_ENABLED\n texel = decodeHDR(texture2D(texture, v_Texcoord));\n originalTexel = texel;\n#endif\n#ifdef BLOOM_ENABLED\n vec4 bloomTexel = decodeHDR(texture2D(bloom, v_Texcoord));\n texel.rgb += bloomTexel.rgb * bloomIntensity;\n texel.a += bloomTexel.a * bloomIntensity;\n#endif\n#ifdef LENSFLARE_ENABLED\n texel += decodeHDR(texture2D(lensflare, v_Texcoord)) * texture2D(lensdirt, v_Texcoord) * lensflareIntensity;\n#endif\n texel.a = min(texel.a, 1.0);\n#ifdef LUM_ENABLED\n float fLum = texture2D(lum, vec2(0.5, 0.5)).r;\n float adaptedLumDest = 3.0 / (max(0.1, 1.0 + 10.0*eyeAdaption(fLum)));\n float exposureBias = adaptedLumDest * exposure;\n#else\n float exposureBias = exposure;\n#endif\n#ifdef TONEMAPPING\n texel.rgb *= exposureBias;\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n texel = linearTosRGB(texel);\n#ifdef LUT_ENABLED\n texel.rgb = lutTransform(clamp(texel.rgb,vec3(0.0),vec3(1.0)));\n#endif\n#ifdef COLOR_CORRECTION\n texel.rgb = clamp(texel.rgb + vec3(brightness), 0.0, 1.0);\n texel.rgb = clamp((texel.rgb - vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n float lum = dot(texel.rgb, vec3(0.2125, 0.7154, 0.0721));\n texel.rgb = mix(vec3(lum), texel.rgb, saturation);\n#endif\n#ifdef VIGNETTE\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(vignetteOffset);\n texel.rgb = mix(texel.rgb, vec3(1.0 - vignetteDarkness), dot(uv, uv));\n#endif\n gl_FragColor = encodeHDR(texel);\n#ifdef DEBUG\n #if DEBUG == 1\n gl_FragColor = encodeHDR(decodeHDR(texture2D(texture, v_Texcoord)));\n #elif DEBUG == 2\n gl_FragColor = encodeHDR(decodeHDR(texture2D(bloom, v_Texcoord)) * bloomIntensity);\n #elif DEBUG == 3\n gl_FragColor = encodeHDR(decodeHDR(texture2D(lensflare, v_Texcoord) * lensflareIntensity));\n #endif\n#endif\n if (originalTexel.a <= 0.01 && gl_FragColor.a > 1e-5) {\n gl_FragColor.a = dot(gl_FragColor.rgb, vec3(0.2125, 0.7154, 0.0721));\n }\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end"
  16404. , tl = "@export clay.compositor.blend\n#define SHADER_NAME blend\n#ifdef TEXTURE1_ENABLED\nuniform sampler2D texture1;\nuniform float weight1 : 1.0;\n#endif\n#ifdef TEXTURE2_ENABLED\nuniform sampler2D texture2;\nuniform float weight2 : 1.0;\n#endif\n#ifdef TEXTURE3_ENABLED\nuniform sampler2D texture3;\nuniform float weight3 : 1.0;\n#endif\n#ifdef TEXTURE4_ENABLED\nuniform sampler2D texture4;\nuniform float weight4 : 1.0;\n#endif\n#ifdef TEXTURE5_ENABLED\nuniform sampler2D texture5;\nuniform float weight5 : 1.0;\n#endif\n#ifdef TEXTURE6_ENABLED\nuniform sampler2D texture6;\nuniform float weight6 : 1.0;\n#endif\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = vec4(0.0);\n#ifdef TEXTURE1_ENABLED\n tex += decodeHDR(texture2D(texture1, v_Texcoord)) * weight1;\n#endif\n#ifdef TEXTURE2_ENABLED\n tex += decodeHDR(texture2D(texture2, v_Texcoord)) * weight2;\n#endif\n#ifdef TEXTURE3_ENABLED\n tex += decodeHDR(texture2D(texture3, v_Texcoord)) * weight3;\n#endif\n#ifdef TEXTURE4_ENABLED\n tex += decodeHDR(texture2D(texture4, v_Texcoord)) * weight4;\n#endif\n#ifdef TEXTURE5_ENABLED\n tex += decodeHDR(texture2D(texture5, v_Texcoord)) * weight5;\n#endif\n#ifdef TEXTURE6_ENABLED\n tex += decodeHDR(texture2D(texture6, v_Texcoord)) * weight6;\n#endif\n gl_FragColor = encodeHDR(tex);\n}\n@end"
  16405. , rl = "@export clay.compositor.fxaa\nuniform sampler2D texture;\nuniform vec4 viewport : VIEWPORT;\nvarying vec2 v_Texcoord;\n#define FXAA_REDUCE_MIN (1.0/128.0)\n#define FXAA_REDUCE_MUL (1.0/8.0)\n#define FXAA_SPAN_MAX 8.0\n@import clay.util.rgbm\nvoid main()\n{\n vec2 resolution = 1.0 / viewport.zw;\n vec3 rgbNW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbNE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ) ).xyz;\n vec4 rgbaM = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution ) );\n vec3 rgbM = rgbaM.xyz;\n float opacity = rgbaM.w;\n vec3 luma = vec3( 0.299, 0.587, 0.114 );\n float lumaNW = dot( rgbNW, luma );\n float lumaNE = dot( rgbNE, luma );\n float lumaSW = dot( rgbSW, luma );\n float lumaSE = dot( rgbSE, luma );\n float lumaM = dot( rgbM, luma );\n float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );\n float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );\n vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );\n float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );\n dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * resolution;\n vec3 rgbA = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 1.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 2.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA *= 0.5;\n vec3 rgbB = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * -0.5 ) ).xyz;\n rgbB += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * 0.5 ) ).xyz;\n rgbB *= 0.25;\n rgbB += rgbA * 0.5;\n float lumaB = dot( rgbB, luma );\n if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) )\n {\n gl_FragColor = vec4( rgbA, opacity );\n }\n else {\n gl_FragColor = vec4( rgbB, opacity );\n }\n}\n@end";
  16406. !function (e) {
  16407. e.import("@export clay.compositor.coloradjust\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float exposure : 0.0;\nuniform float gamma : 1.0;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = clamp(tex.rgb + vec3(brightness), 0.0, 1.0);\n color = clamp( (color-vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n color = clamp( color * pow(2.0, exposure), 0.0, 1.0);\n color = clamp( pow(color, vec3(gamma)), 0.0, 1.0);\n float luminance = dot( color, w );\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.brightness\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = tex.rgb + vec3(brightness);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.contrast\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float contrast : 1.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = (tex.rgb-vec3(0.5))*contrast+vec3(0.5);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.exposure\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float exposure : 0.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb * pow(2.0, exposure);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.gamma\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float gamma : 1.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = pow(tex.rgb, vec3(gamma));\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.saturation\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb;\n float luminance = dot(color, w);\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end"),
  16408. e.import(Zs),
  16409. e.import("@export clay.compositor.hdr.log_lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n float luminance = dot(tex.rgb, w);\n luminance = log(luminance + 0.001);\n gl_FragColor = encodeHDR(vec4(vec3(luminance), 1.0));\n}\n@end\n@export clay.compositor.hdr.lum_adaption\nvarying vec2 v_Texcoord;\nuniform sampler2D adaptedLum;\nuniform sampler2D currentLum;\nuniform float frameTime : 0.02;\n@import clay.util.rgbm\nvoid main()\n{\n float fAdaptedLum = decodeHDR(texture2D(adaptedLum, vec2(0.5, 0.5))).r;\n float fCurrentLum = exp(encodeHDR(texture2D(currentLum, vec2(0.5, 0.5))).r);\n fAdaptedLum += (fCurrentLum - fAdaptedLum) * (1.0 - pow(0.98, 30.0 * frameTime));\n gl_FragColor = encodeHDR(vec4(vec3(fAdaptedLum), 1.0));\n}\n@end\n@export clay.compositor.lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord );\n float luminance = dot(tex.rgb, w);\n gl_FragColor = vec4(vec3(luminance), 1.0);\n}\n@end"),
  16410. e.import(Ys),
  16411. e.import("@export clay.compositor.vignette\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float darkness: 1;\nuniform float offset: 1;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = texel.rgb;\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(offset);\n gl_FragColor = encodeHDR(vec4(mix(texel.rgb, vec3(1.0 - darkness), dot(uv, uv)), texel.a));\n}\n@end"),
  16412. e.import(Ks),
  16413. e.import(Qs),
  16414. e.import(Js),
  16415. e.import($s),
  16416. e.import(el),
  16417. e.import("@export clay.compositor.lensflare\n#define SAMPLE_NUMBER 8\nuniform sampler2D texture;\nuniform sampler2D lenscolor;\nuniform vec2 textureSize : [512, 512];\nuniform float dispersal : 0.3;\nuniform float haloWidth : 0.4;\nuniform float distortion : 1.0;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvec4 textureDistorted(\n in vec2 texcoord,\n in vec2 direction,\n in vec3 distortion\n) {\n return vec4(\n decodeHDR(texture2D(texture, texcoord + direction * distortion.r)).r,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.g)).g,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.b)).b,\n 1.0\n );\n}\nvoid main()\n{\n vec2 texcoord = -v_Texcoord + vec2(1.0); vec2 textureOffset = 1.0 / textureSize;\n vec2 ghostVec = (vec2(0.5) - texcoord) * dispersal;\n vec2 haloVec = normalize(ghostVec) * haloWidth;\n vec3 distortion = vec3(-textureOffset.x * distortion, 0.0, textureOffset.x * distortion);\n vec4 result = vec4(0.0);\n for (int i = 0; i < SAMPLE_NUMBER; i++)\n {\n vec2 offset = fract(texcoord + ghostVec * float(i));\n float weight = length(vec2(0.5) - offset) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n }\n result *= texture2D(lenscolor, vec2(length(vec2(0.5) - texcoord)) / length(vec2(0.5)));\n float weight = length(vec2(0.5) - fract(texcoord + haloVec)) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n vec2 offset = fract(texcoord + haloVec);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n gl_FragColor = result;\n}\n@end"),
  16418. e.import(tl),
  16419. e.import(rl)
  16420. }(Xe);
  16421. var il = /^#source\((.*?)\)/;
  16422. function nl(e, t, r) {
  16423. var i, n, a, o, s = e.type || "filter";
  16424. if ("filter" === s) {
  16425. var l = e.shader.trim()
  16426. , h = il.exec(l);
  16427. if (h ? i = Xe.source(h[1].trim()) : "#" === l.charAt(0) && (i = t.shaders[l.substr(1)]),
  16428. i || (i = l),
  16429. !i)
  16430. return
  16431. }
  16432. if (e.inputs)
  16433. for (var u in n = {},
  16434. e.inputs)
  16435. "string" == typeof e.inputs[u] ? n[u] = e.inputs[u] : n[u] = {
  16436. node: e.inputs[u].node,
  16437. pin: e.inputs[u].pin
  16438. };
  16439. if (e.outputs)
  16440. for (var u in a = {},
  16441. e.outputs) {
  16442. var c = e.outputs[u];
  16443. a[u] = {},
  16444. null != c.attachment && (a[u].attachment = c.attachment),
  16445. null != c.keepLastFrame && (a[u].keepLastFrame = c.keepLastFrame),
  16446. null != c.outputLastFrame && (a[u].outputLastFrame = c.outputLastFrame),
  16447. c.parameters && (a[u].parameters = sl(c.parameters))
  16448. }
  16449. if (o = "scene" === s ? new js({
  16450. name: e.name,
  16451. scene: r.scene,
  16452. camera: r.camera,
  16453. outputs: a
  16454. }) : "texture" === s ? new Xs({
  16455. name: e.name,
  16456. outputs: a
  16457. }) : new qs({
  16458. name: e.name,
  16459. shader: i,
  16460. inputs: n,
  16461. outputs: a
  16462. })) {
  16463. if (e.parameters)
  16464. for (var u in e.parameters)
  16465. "string" == typeof (d = e.parameters[u]) ? "#" === (d = d.trim()).charAt(0) ? d = t.textures[d.substr(1)] : o.on("beforerender", ll(u, hl(d))) : "function" == typeof d && o.on("beforerender", d),
  16466. o.setParameter(u, d);
  16467. if (e.defines && o.pass)
  16468. for (var u in e.defines) {
  16469. var d = e.defines[u];
  16470. o.pass.material.define("fragment", u, d)
  16471. }
  16472. }
  16473. return o
  16474. }
  16475. function al(e, t) {
  16476. return e
  16477. }
  16478. function ol(e, t) {
  16479. return t
  16480. }
  16481. function sl(e) {
  16482. var t = {};
  16483. if (!e)
  16484. return t;
  16485. ["type", "minFilter", "magFilter", "wrapS", "wrapT", "flipY", "useMipmap"].forEach((function (r) {
  16486. var i = e[r];
  16487. null != i && ("string" == typeof i && (i = wr[i]),
  16488. t[r] = i)
  16489. }
  16490. ));
  16491. var r = e.scale || 1;
  16492. return ["width", "height"].forEach((function (i) {
  16493. if (null != e[i]) {
  16494. var n = e[i];
  16495. "string" == typeof n ? (n = n.trim(),
  16496. t[i] = (a = hl(n),
  16497. o = (o = r) || 1,
  16498. function (e) {
  16499. var t = e.getDevicePixelRatio()
  16500. , r = e.getWidth() * o
  16501. , i = e.getHeight() * o;
  16502. return a(r, i, t)
  16503. }
  16504. )) : t[i] = n
  16505. }
  16506. var a, o
  16507. }
  16508. )),
  16509. t.width || (t.width = al),
  16510. t.height || (t.height = ol),
  16511. null != e.useMipmap && (t.useMipmap = e.useMipmap),
  16512. t
  16513. }
  16514. function ll(e, t) {
  16515. return function (r) {
  16516. var i = r.getDevicePixelRatio()
  16517. , n = r.getWidth()
  16518. , a = r.getHeight()
  16519. , o = t(n, a, i);
  16520. this.setParameter(e, o)
  16521. }
  16522. }
  16523. function hl(e) {
  16524. var t = /^expr\((.*)\)$/.exec(e);
  16525. if (t)
  16526. try {
  16527. var r = new Function("width", "height", "dpr", "return " + t[1]);
  16528. return r(1, 1),
  16529. r
  16530. } catch (e) {
  16531. throw new Error("Invalid expression.")
  16532. }
  16533. }
  16534. const ul = function (e, t) {
  16535. for (var r = 0, i = 1 / t, n = e; n > 0;)
  16536. r += i * (n % t),
  16537. n = Math.floor(n / t),
  16538. i /= t;
  16539. return r
  16540. };
  16541. function cl(e) {
  16542. for (var t = new Uint8Array(e * e * 4), r = 0, i = new vt, n = 0; n < e; n++)
  16543. for (var a = 0; a < e; a++)
  16544. i.set(2 * Math.random() - 1, 2 * Math.random() - 1, 0).normalize(),
  16545. t[r++] = 255 * (.5 * i.x + .5),
  16546. t[r++] = 255 * (.5 * i.y + .5),
  16547. t[r++] = 0,
  16548. t[r++] = 255;
  16549. return t
  16550. }
  16551. function dl(e) {
  16552. return new Dr({
  16553. pixels: cl(e),
  16554. wrapS: wr.REPEAT,
  16555. wrapT: wr.REPEAT,
  16556. width: e,
  16557. height: e
  16558. })
  16559. }
  16560. function fl(e, t, r) {
  16561. var i = new Float32Array(3 * e);
  16562. t = t || 0;
  16563. for (var n = 0; n < e; n++) {
  16564. var a = ul(n + t, 2) * (r ? 1 : 2) * Math.PI
  16565. , o = ul(n + t, 3) * Math.PI
  16566. , s = Math.random()
  16567. , l = Math.cos(a) * Math.sin(o) * s
  16568. , h = Math.cos(o) * s
  16569. , u = Math.sin(a) * Math.sin(o) * s;
  16570. i[3 * n] = l,
  16571. i[3 * n + 1] = h,
  16572. i[3 * n + 2] = u
  16573. }
  16574. return i
  16575. }
  16576. function pl(e) {
  16577. e = e || {},
  16578. this._ssaoPass = new pn({
  16579. fragment: Xe.source("ecgl.ssao.estimate")
  16580. }),
  16581. this._blurPass = new pn({
  16582. fragment: Xe.source("ecgl.ssao.blur")
  16583. }),
  16584. this._framebuffer = new zi({
  16585. depthBuffer: !1
  16586. }),
  16587. this._ssaoTexture = new Dr,
  16588. this._blurTexture = new Dr,
  16589. this._blurTexture2 = new Dr,
  16590. this._depthTex = e.depthTexture,
  16591. this._normalTex = e.normalTexture,
  16592. this.setNoiseSize(4),
  16593. this.setKernelSize(e.kernelSize || 12),
  16594. null != e.radius && this.setParameter("radius", e.radius),
  16595. null != e.power && this.setParameter("power", e.power),
  16596. this._normalTex || (this._ssaoPass.material.disableTexture("normalTex"),
  16597. this._blurPass.material.disableTexture("normalTex")),
  16598. this._depthTex || this._blurPass.material.disableTexture("depthTex"),
  16599. this._blurPass.material.setUniform("normalTex", this._normalTex),
  16600. this._blurPass.material.setUniform("depthTex", this._depthTex)
  16601. }
  16602. Xe.import("@export ecgl.ssao.estimate\n\nuniform sampler2D depthTex;\n\nuniform sampler2D normalTex;\n\nuniform sampler2D noiseTex;\n\nuniform vec2 depthTexSize;\n\nuniform vec2 noiseTexSize;\n\nuniform mat4 projection;\n\nuniform mat4 projectionInv;\n\nuniform mat4 viewInverseTranspose;\n\nuniform vec3 kernel[KERNEL_SIZE];\n\nuniform float radius : 1;\n\nuniform float power : 1;\n\nuniform float bias: 1e-2;\n\nuniform float intensity: 1.0;\n\nvarying vec2 v_Texcoord;\n\nfloat ssaoEstimator(in vec3 originPos, in mat3 kernelBasis) {\n float occlusion = 0.0;\n\n for (int i = 0; i < KERNEL_SIZE; i++) {\n vec3 samplePos = kernel[i];\n#ifdef NORMALTEX_ENABLED\n samplePos = kernelBasis * samplePos;\n#endif\n samplePos = samplePos * radius + originPos;\n\n vec4 texCoord = projection * vec4(samplePos, 1.0);\n texCoord.xy /= texCoord.w;\n\n vec4 depthTexel = texture2D(depthTex, texCoord.xy * 0.5 + 0.5);\n\n float sampleDepth = depthTexel.r * 2.0 - 1.0;\n if (projection[3][3] == 0.0) {\n sampleDepth = projection[3][2] / (sampleDepth * projection[2][3] - projection[2][2]);\n }\n else {\n sampleDepth = (sampleDepth - projection[3][2]) / projection[2][2];\n }\n \n float rangeCheck = smoothstep(0.0, 1.0, radius / abs(originPos.z - sampleDepth));\n occlusion += rangeCheck * step(samplePos.z, sampleDepth - bias);\n }\n#ifdef NORMALTEX_ENABLED\n occlusion = 1.0 - occlusion / float(KERNEL_SIZE);\n#else\n occlusion = 1.0 - clamp((occlusion / float(KERNEL_SIZE) - 0.6) * 2.5, 0.0, 1.0);\n#endif\n return pow(occlusion, power);\n}\n\nvoid main()\n{\n\n vec4 depthTexel = texture2D(depthTex, v_Texcoord);\n\n#ifdef NORMALTEX_ENABLED\n vec4 tex = texture2D(normalTex, v_Texcoord);\n if (dot(tex.rgb, tex.rgb) == 0.0) {\n gl_FragColor = vec4(1.0);\n return;\n }\n vec3 N = tex.rgb * 2.0 - 1.0;\n N = (viewInverseTranspose * vec4(N, 0.0)).xyz;\n\n vec2 noiseTexCoord = depthTexSize / vec2(noiseTexSize) * v_Texcoord;\n vec3 rvec = texture2D(noiseTex, noiseTexCoord).rgb * 2.0 - 1.0;\n vec3 T = normalize(rvec - N * dot(rvec, N));\n vec3 BT = normalize(cross(N, T));\n mat3 kernelBasis = mat3(T, BT, N);\n#else\n if (depthTexel.r > 0.99999) {\n gl_FragColor = vec4(1.0);\n return;\n }\n mat3 kernelBasis;\n#endif\n\n float z = depthTexel.r * 2.0 - 1.0;\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * projectedPos;\n\n vec3 position = p4.xyz / p4.w;\n\n float ao = ssaoEstimator(position, kernelBasis);\n ao = clamp(1.0 - (1.0 - ao) * intensity, 0.0, 1.0);\n gl_FragColor = vec4(vec3(ao), 1.0);\n}\n\n@end\n\n\n@export ecgl.ssao.blur\n#define SHADER_NAME SSAO_BLUR\n\nuniform sampler2D ssaoTexture;\n\n#ifdef NORMALTEX_ENABLED\nuniform sampler2D normalTex;\n#endif\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\nuniform int direction: 0.0;\n\n#ifdef DEPTHTEX_ENABLED\nuniform sampler2D depthTex;\nuniform mat4 projection;\nuniform float depthRange : 0.5;\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(depthTex, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n#endif\n\nvoid main()\n{\n float kernel[5];\n kernel[0] = 0.122581;\n kernel[1] = 0.233062;\n kernel[2] = 0.288713;\n kernel[3] = 0.233062;\n kernel[4] = 0.122581;\n\n vec2 off = vec2(0.0);\n if (direction == 0) {\n off[0] = blurSize / textureSize.x;\n }\n else {\n off[1] = blurSize / textureSize.y;\n }\n\n vec2 coord = v_Texcoord;\n\n float sum = 0.0;\n float weightAll = 0.0;\n\n#ifdef NORMALTEX_ENABLED\n vec3 centerNormal = texture2D(normalTex, v_Texcoord).rgb * 2.0 - 1.0;\n#endif\n#if defined(DEPTHTEX_ENABLED)\n float centerDepth = getLinearDepth(v_Texcoord);\n#endif\n\n for (int i = 0; i < 5; i++) {\n vec2 coord = clamp(v_Texcoord + vec2(float(i) - 2.0) * off, vec2(0.0), vec2(1.0));\n\n float w = kernel[i];\n#ifdef NORMALTEX_ENABLED\n vec3 normal = texture2D(normalTex, coord).rgb * 2.0 - 1.0;\n w *= clamp(dot(normal, centerNormal), 0.0, 1.0);\n#endif\n#ifdef DEPTHTEX_ENABLED\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(centerDepth - d) / depthRange, 0.0, 1.0));\n#endif\n\n weightAll += w;\n sum += texture2D(ssaoTexture, coord).r * w;\n }\n\n gl_FragColor = vec4(vec3(sum / weightAll), 1.0);\n}\n\n@end\n"),
  16603. pl.prototype.setDepthTexture = function (e) {
  16604. this._depthTex = e
  16605. }
  16606. ,
  16607. pl.prototype.setNormalTexture = function (e) {
  16608. this._normalTex = e,
  16609. this._ssaoPass.material[e ? "enableTexture" : "disableTexture"]("normalTex"),
  16610. this.setKernelSize(this._kernelSize)
  16611. }
  16612. ,
  16613. pl.prototype.update = function (e, t, r) {
  16614. var i = e.getWidth()
  16615. , n = e.getHeight()
  16616. , a = this._ssaoPass
  16617. , o = this._blurPass;
  16618. a.setUniform("kernel", this._kernels[r % this._kernels.length]),
  16619. a.setUniform("depthTex", this._depthTex),
  16620. null != this._normalTex && a.setUniform("normalTex", this._normalTex),
  16621. a.setUniform("depthTexSize", [this._depthTex.width, this._depthTex.height]);
  16622. var s = new Ht;
  16623. Ht.transpose(s, t.worldTransform),
  16624. a.setUniform("projection", t.projectionMatrix.array),
  16625. a.setUniform("projectionInv", t.invProjectionMatrix.array),
  16626. a.setUniform("viewInverseTranspose", s.array);
  16627. var l = this._ssaoTexture
  16628. , h = this._blurTexture
  16629. , u = this._blurTexture2;
  16630. l.width = i / 2,
  16631. l.height = n / 2,
  16632. h.width = i,
  16633. h.height = n,
  16634. u.width = i,
  16635. u.height = n,
  16636. this._framebuffer.attach(l),
  16637. this._framebuffer.bind(e),
  16638. e.gl.clearColor(1, 1, 1, 1),
  16639. e.gl.clear(e.gl.COLOR_BUFFER_BIT),
  16640. a.render(e),
  16641. o.setUniform("textureSize", [i / 2, n / 2]),
  16642. o.setUniform("projection", t.projectionMatrix.array),
  16643. this._framebuffer.attach(h),
  16644. o.setUniform("direction", 0),
  16645. o.setUniform("ssaoTexture", l),
  16646. o.render(e),
  16647. this._framebuffer.attach(u),
  16648. o.setUniform("textureSize", [i, n]),
  16649. o.setUniform("direction", 1),
  16650. o.setUniform("ssaoTexture", h),
  16651. o.render(e),
  16652. this._framebuffer.unbind(e);
  16653. var c = e.clearColor;
  16654. e.gl.clearColor(c[0], c[1], c[2], c[3])
  16655. }
  16656. ,
  16657. pl.prototype.getTargetTexture = function () {
  16658. return this._blurTexture2
  16659. }
  16660. ,
  16661. pl.prototype.setParameter = function (e, t) {
  16662. "noiseTexSize" === e ? this.setNoiseSize(t) : "kernelSize" === e ? this.setKernelSize(t) : "intensity" === e ? this._ssaoPass.material.set("intensity", t) : this._ssaoPass.setUniform(e, t)
  16663. }
  16664. ,
  16665. pl.prototype.setKernelSize = function (e) {
  16666. this._kernelSize = e,
  16667. this._ssaoPass.material.define("fragment", "KERNEL_SIZE", e),
  16668. this._kernels = this._kernels || [];
  16669. for (var t = 0; t < 30; t++)
  16670. this._kernels[t] = fl(e, t * e, !!this._normalTex)
  16671. }
  16672. ,
  16673. pl.prototype.setNoiseSize = function (e) {
  16674. var t = this._ssaoPass.getUniform("noiseTex");
  16675. t ? (t.data = cl(e),
  16676. t.width = t.height = e,
  16677. t.dirty()) : (t = dl(e),
  16678. this._ssaoPass.setUniform("noiseTex", dl(e))),
  16679. this._ssaoPass.setUniform("noiseTexSize", [e, e])
  16680. }
  16681. ,
  16682. pl.prototype.dispose = function (e) {
  16683. this._blurTexture.dispose(e),
  16684. this._ssaoTexture.dispose(e),
  16685. this._blurTexture2.dispose(e)
  16686. }
  16687. ;
  16688. const ml = pl;
  16689. function gl(e) {
  16690. e = e || {},
  16691. this._ssrPass = new pn({
  16692. fragment: Xe.source("ecgl.ssr.main"),
  16693. clearColor: [0, 0, 0, 0]
  16694. }),
  16695. this._blurPass1 = new pn({
  16696. fragment: Xe.source("ecgl.ssr.blur"),
  16697. clearColor: [0, 0, 0, 0]
  16698. }),
  16699. this._blurPass2 = new pn({
  16700. fragment: Xe.source("ecgl.ssr.blur"),
  16701. clearColor: [0, 0, 0, 0]
  16702. }),
  16703. this._blendPass = new pn({
  16704. fragment: Xe.source("clay.compositor.blend")
  16705. }),
  16706. this._blendPass.material.disableTexturesAll(),
  16707. this._blendPass.material.enableTexture(["texture1", "texture2"]),
  16708. this._ssrPass.setUniform("gBufferTexture1", e.normalTexture),
  16709. this._ssrPass.setUniform("gBufferTexture2", e.depthTexture),
  16710. this._blurPass1.setUniform("gBufferTexture1", e.normalTexture),
  16711. this._blurPass1.setUniform("gBufferTexture2", e.depthTexture),
  16712. this._blurPass2.setUniform("gBufferTexture1", e.normalTexture),
  16713. this._blurPass2.setUniform("gBufferTexture2", e.depthTexture),
  16714. this._blurPass2.material.define("fragment", "VERTICAL"),
  16715. this._blurPass2.material.define("fragment", "BLEND"),
  16716. this._ssrTexture = new Dr({
  16717. type: wr.HALF_FLOAT
  16718. }),
  16719. this._texture2 = new Dr({
  16720. type: wr.HALF_FLOAT
  16721. }),
  16722. this._texture3 = new Dr({
  16723. type: wr.HALF_FLOAT
  16724. }),
  16725. this._prevTexture = new Dr({
  16726. type: wr.HALF_FLOAT
  16727. }),
  16728. this._currentTexture = new Dr({
  16729. type: wr.HALF_FLOAT
  16730. }),
  16731. this._frameBuffer = new zi({
  16732. depthBuffer: !1
  16733. }),
  16734. this._normalDistribution = null,
  16735. this._totalSamples = 256,
  16736. this._samplePerFrame = 4,
  16737. this._ssrPass.material.define("fragment", "SAMPLE_PER_FRAME", this._samplePerFrame),
  16738. this._ssrPass.material.define("fragment", "TOTAL_SAMPLES", this._totalSamples),
  16739. this._downScale = 1
  16740. }
  16741. Xe.import("@export ecgl.ssr.main\n\n#define SHADER_NAME SSR\n#define MAX_ITERATION 20;\n#define SAMPLE_PER_FRAME 5;\n#define TOTAL_SAMPLES 128;\n\nuniform sampler2D sourceTexture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform sampler2D gBufferTexture3;\nuniform samplerCube specularCubemap;\nuniform float specularIntensity: 1;\n\nuniform mat4 projection;\nuniform mat4 projectionInv;\nuniform mat4 toViewSpace;\nuniform mat4 toWorldSpace;\n\nuniform float maxRayDistance: 200;\n\nuniform float pixelStride: 16;\nuniform float pixelStrideZCutoff: 50; \nuniform float screenEdgeFadeStart: 0.9; \nuniform float eyeFadeStart : 0.2; uniform float eyeFadeEnd: 0.8; \nuniform float minGlossiness: 0.2; uniform float zThicknessThreshold: 1;\n\nuniform float nearZ;\nuniform vec2 viewportSize : VIEWPORT_SIZE;\n\nuniform float jitterOffset: 0;\n\nvarying vec2 v_Texcoord;\n\n#ifdef DEPTH_DECODE\n@import clay.util.decode_float\n#endif\n\n#ifdef PHYSICALLY_CORRECT\nuniform sampler2D normalDistribution;\nuniform float sampleOffset: 0;\nuniform vec2 normalDistributionSize;\n\nvec3 transformNormal(vec3 H, vec3 N) {\n vec3 upVector = N.y > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvec3 importanceSampleNormalGGX(float i, float roughness, vec3 N) {\n float p = fract((i + sampleOffset) / float(TOTAL_SAMPLES));\n vec3 H = texture2D(normalDistribution,vec2(roughness, p)).rgb;\n return transformNormal(H, N);\n}\nfloat G_Smith(float g, float ndv, float ndl) {\n float roughness = 1.0 - g;\n float k = roughness * roughness / 2.0;\n float G1V = ndv / (ndv * (1.0 - k) + k);\n float G1L = ndl / (ndl * (1.0 - k) + k);\n return G1L * G1V;\n}\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n#endif\n\nfloat fetchDepth(sampler2D depthTexture, vec2 uv)\n{\n vec4 depthTexel = texture2D(depthTexture, uv);\n return depthTexel.r * 2.0 - 1.0;\n}\n\nfloat linearDepth(float depth)\n{\n if (projection[3][3] == 0.0) {\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n }\n else {\n return (depth - projection[3][2]) / projection[2][2];\n }\n}\n\nbool rayIntersectDepth(float rayZNear, float rayZFar, vec2 hitPixel)\n{\n if (rayZFar > rayZNear)\n {\n float t = rayZFar; rayZFar = rayZNear; rayZNear = t;\n }\n float cameraZ = linearDepth(fetchDepth(gBufferTexture2, hitPixel));\n return rayZFar <= cameraZ && rayZNear >= cameraZ - zThicknessThreshold;\n}\n\n\nbool traceScreenSpaceRay(\n vec3 rayOrigin, vec3 rayDir, float jitter,\n out vec2 hitPixel, out vec3 hitPoint, out float iterationCount\n)\n{\n float rayLength = ((rayOrigin.z + rayDir.z * maxRayDistance) > -nearZ)\n ? (-nearZ - rayOrigin.z) / rayDir.z : maxRayDistance;\n\n vec3 rayEnd = rayOrigin + rayDir * rayLength;\n\n vec4 H0 = projection * vec4(rayOrigin, 1.0);\n vec4 H1 = projection * vec4(rayEnd, 1.0);\n\n float k0 = 1.0 / H0.w, k1 = 1.0 / H1.w;\n\n vec3 Q0 = rayOrigin * k0, Q1 = rayEnd * k1;\n\n vec2 P0 = (H0.xy * k0 * 0.5 + 0.5) * viewportSize;\n vec2 P1 = (H1.xy * k1 * 0.5 + 0.5) * viewportSize;\n\n P1 += dot(P1 - P0, P1 - P0) < 0.0001 ? 0.01 : 0.0;\n vec2 delta = P1 - P0;\n\n bool permute = false;\n if (abs(delta.x) < abs(delta.y)) {\n permute = true;\n delta = delta.yx;\n P0 = P0.yx;\n P1 = P1.yx;\n }\n float stepDir = sign(delta.x);\n float invdx = stepDir / delta.x;\n\n vec3 dQ = (Q1 - Q0) * invdx;\n float dk = (k1 - k0) * invdx;\n\n vec2 dP = vec2(stepDir, delta.y * invdx);\n\n float strideScaler = 1.0 - min(1.0, -rayOrigin.z / pixelStrideZCutoff);\n float pixStride = 1.0 + strideScaler * pixelStride;\n\n dP *= pixStride; dQ *= pixStride; dk *= pixStride;\n\n vec4 pqk = vec4(P0, Q0.z, k0);\n vec4 dPQK = vec4(dP, dQ.z, dk);\n\n pqk += dPQK * jitter;\n float rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n float rayZNear;\n\n bool intersect = false;\n\n vec2 texelSize = 1.0 / viewportSize;\n\n iterationCount = 0.0;\n\n for (int i = 0; i < MAX_ITERATION; i++)\n {\n pqk += dPQK;\n\n rayZNear = rayZFar;\n rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n\n hitPixel = permute ? pqk.yx : pqk.xy;\n hitPixel *= texelSize;\n\n intersect = rayIntersectDepth(rayZNear, rayZFar, hitPixel);\n\n iterationCount += 1.0;\n\n dPQK *= 1.2;\n\n if (intersect) {\n break;\n }\n }\n\n Q0.xy += dQ.xy * iterationCount;\n Q0.z = pqk.z;\n hitPoint = Q0 / pqk.w;\n\n return intersect;\n}\n\nfloat calculateAlpha(\n float iterationCount, float reflectivity,\n vec2 hitPixel, vec3 hitPoint, float dist, vec3 rayDir\n)\n{\n float alpha = clamp(reflectivity, 0.0, 1.0);\n alpha *= 1.0 - (iterationCount / float(MAX_ITERATION));\n vec2 hitPixelNDC = hitPixel * 2.0 - 1.0;\n float maxDimension = min(1.0, max(abs(hitPixelNDC.x), abs(hitPixelNDC.y)));\n alpha *= 1.0 - max(0.0, maxDimension - screenEdgeFadeStart) / (1.0 - screenEdgeFadeStart);\n\n float _eyeFadeStart = eyeFadeStart;\n float _eyeFadeEnd = eyeFadeEnd;\n if (_eyeFadeStart > _eyeFadeEnd) {\n float tmp = _eyeFadeEnd;\n _eyeFadeEnd = _eyeFadeStart;\n _eyeFadeStart = tmp;\n }\n\n float eyeDir = clamp(rayDir.z, _eyeFadeStart, _eyeFadeEnd);\n alpha *= 1.0 - (eyeDir - _eyeFadeStart) / (_eyeFadeEnd - _eyeFadeStart);\n\n alpha *= 1.0 - clamp(dist / maxRayDistance, 0.0, 1.0);\n\n return alpha;\n}\n\n@import clay.util.rand\n\n@import clay.util.rgbm\n\nvoid main()\n{\n vec4 normalAndGloss = texture2D(gBufferTexture1, v_Texcoord);\n\n if (dot(normalAndGloss.rgb, vec3(1.0)) == 0.0) {\n discard;\n }\n\n float g = normalAndGloss.a;\n#if !defined(PHYSICALLY_CORRECT)\n if (g <= minGlossiness) {\n discard;\n }\n#endif\n\n float reflectivity = (g - minGlossiness) / (1.0 - minGlossiness);\n\n vec3 N = normalize(normalAndGloss.rgb * 2.0 - 1.0);\n N = normalize((toViewSpace * vec4(N, 0.0)).xyz);\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, fetchDepth(gBufferTexture2, v_Texcoord), 1.0);\n vec4 pos = projectionInv * projectedPos;\n vec3 rayOrigin = pos.xyz / pos.w;\n vec3 V = -normalize(rayOrigin);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n float iterationCount;\n float jitter = rand(fract(v_Texcoord + jitterOffset));\n\n#ifdef PHYSICALLY_CORRECT\n vec4 color = vec4(vec3(0.0), 1.0);\n vec4 albedoMetalness = texture2D(gBufferTexture3, v_Texcoord);\n vec3 albedo = albedoMetalness.rgb;\n float m = albedoMetalness.a;\n vec3 diffuseColor = albedo * (1.0 - m);\n vec3 spec = mix(vec3(0.04), albedo, m);\n\n float jitter2 = rand(fract(v_Texcoord)) * float(TOTAL_SAMPLES);\n\n for (int i = 0; i < SAMPLE_PER_FRAME; i++) {\n vec3 H = importanceSampleNormalGGX(float(i) + jitter2, 1.0 - g, N);\n vec3 rayDir = normalize(reflect(-V, H));\n#else\n vec3 rayDir = normalize(reflect(-V, N));\n#endif\n vec2 hitPixel;\n vec3 hitPoint;\n\n bool intersect = traceScreenSpaceRay(rayOrigin, rayDir, jitter, hitPixel, hitPoint, iterationCount);\n\n float dist = distance(rayOrigin, hitPoint);\n\n vec3 hitNormal = texture2D(gBufferTexture1, hitPixel).rgb * 2.0 - 1.0;\n hitNormal = normalize((toViewSpace * vec4(hitNormal, 0.0)).xyz);\n#ifdef PHYSICALLY_CORRECT\n float ndl = clamp(dot(N, rayDir), 0.0, 1.0);\n float vdh = clamp(dot(V, H), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n vec3 litTexel = vec3(0.0);\n if (dot(hitNormal, rayDir) < 0.0 && intersect) {\n litTexel = texture2D(sourceTexture, hitPixel).rgb;\n litTexel *= pow(clamp(1.0 - dist / 200.0, 0.0, 1.0), 3.0);\n\n }\n else {\n #ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n litTexel = RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, 0.0), 8.12).rgb * specularIntensity;\n#endif\n }\n color.rgb += ndl * litTexel * (\n F_Schlick(ndl, spec) * G_Smith(g, ndv, ndl) * vdh / (ndh * ndv + 0.001)\n );\n }\n color.rgb /= float(SAMPLE_PER_FRAME);\n#else\n #if !defined(SPECULARCUBEMAP_ENABLED)\n if (dot(hitNormal, rayDir) >= 0.0) {\n discard;\n }\n if (!intersect) {\n discard;\n }\n#endif\n float alpha = clamp(calculateAlpha(iterationCount, reflectivity, hitPixel, hitPoint, dist, rayDir), 0.0, 1.0);\n vec4 color = texture2D(sourceTexture, hitPixel);\n color.rgb *= alpha;\n\n#ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n alpha = alpha * (intersect ? 1.0 : 0.0);\n float bias = (1.0 -g) * 5.0;\n color.rgb += (1.0 - alpha)\n * RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, bias), 8.12).rgb\n * specularIntensity;\n#endif\n\n#endif\n\n gl_FragColor = encodeHDR(color);\n}\n@end\n\n@export ecgl.ssr.blur\n\nuniform sampler2D texture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform mat4 projection;\nuniform float depthRange : 0.05;\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\n#ifdef BLEND\n #ifdef SSAOTEX_ENABLED\nuniform sampler2D ssaoTex;\n #endif\nuniform sampler2D sourceTexture;\n#endif\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(gBufferTexture2, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n\n@import clay.util.rgbm\n\n\nvoid main()\n{\n @import clay.compositor.kernel.gaussian_9\n\n vec4 centerNTexel = texture2D(gBufferTexture1, v_Texcoord);\n float g = centerNTexel.a;\n float maxBlurSize = clamp(1.0 - g, 0.0, 1.0) * blurSize;\n#ifdef VERTICAL\n vec2 off = vec2(0.0, maxBlurSize / textureSize.y);\n#else\n vec2 off = vec2(maxBlurSize / textureSize.x, 0.0);\n#endif\n\n vec2 coord = v_Texcoord;\n\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n\n vec3 cN = centerNTexel.rgb * 2.0 - 1.0;\n float cD = getLinearDepth(v_Texcoord);\n for (int i = 0; i < 9; i++) {\n vec2 coord = clamp((float(i) - 4.0) * off + v_Texcoord, vec2(0.0), vec2(1.0));\n float w = gaussianKernel[i]\n * clamp(dot(cN, texture2D(gBufferTexture1, coord).rgb * 2.0 - 1.0), 0.0, 1.0);\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(cD - d) / depthRange, 0.0, 1.0));\n\n weightAll += w;\n sum += decodeHDR(texture2D(texture, coord)) * w;\n }\n\n#ifdef BLEND\n float aoFactor = 1.0;\n #ifdef SSAOTEX_ENABLED\n aoFactor = texture2D(ssaoTex, v_Texcoord).r;\n #endif\n gl_FragColor = encodeHDR(\n sum / weightAll * aoFactor + decodeHDR(texture2D(sourceTexture, v_Texcoord))\n );\n#else\n gl_FragColor = encodeHDR(sum / weightAll);\n#endif\n}\n\n@end"),
  16742. gl.prototype.setAmbientCubemap = function (e, t) {
  16743. this._ssrPass.material.set("specularCubemap", e),
  16744. this._ssrPass.material.set("specularIntensity", t);
  16745. var r = e && t;
  16746. this._ssrPass.material[r ? "enableTexture" : "disableTexture"]("specularCubemap")
  16747. }
  16748. ,
  16749. gl.prototype.update = function (e, t, r, i) {
  16750. var n = e.getWidth()
  16751. , a = e.getHeight()
  16752. , o = this._ssrTexture
  16753. , s = this._texture2
  16754. , l = this._texture3;
  16755. o.width = this._prevTexture.width = this._currentTexture.width = n / this._downScale,
  16756. o.height = this._prevTexture.height = this._currentTexture.height = a / this._downScale,
  16757. s.width = l.width = n,
  16758. s.height = l.height = a;
  16759. var h = this._frameBuffer
  16760. , u = this._ssrPass
  16761. , c = this._blurPass1
  16762. , d = this._blurPass2
  16763. , f = this._blendPass
  16764. , p = new Ht
  16765. , m = new Ht;
  16766. Ht.transpose(p, t.worldTransform),
  16767. Ht.transpose(m, t.viewMatrix),
  16768. u.setUniform("sourceTexture", r),
  16769. u.setUniform("projection", t.projectionMatrix.array),
  16770. u.setUniform("projectionInv", t.invProjectionMatrix.array),
  16771. u.setUniform("toViewSpace", p.array),
  16772. u.setUniform("toWorldSpace", m.array),
  16773. u.setUniform("nearZ", t.near);
  16774. var g = i / this._totalSamples * this._samplePerFrame;
  16775. if (u.setUniform("jitterOffset", g),
  16776. u.setUniform("sampleOffset", i * this._samplePerFrame),
  16777. c.setUniform("textureSize", [o.width, o.height]),
  16778. d.setUniform("textureSize", [n, a]),
  16779. d.setUniform("sourceTexture", r),
  16780. c.setUniform("projection", t.projectionMatrix.array),
  16781. d.setUniform("projection", t.projectionMatrix.array),
  16782. h.attach(o),
  16783. h.bind(e),
  16784. u.render(e),
  16785. this._physicallyCorrect && (h.attach(this._currentTexture),
  16786. f.setUniform("texture1", this._prevTexture),
  16787. f.setUniform("texture2", o),
  16788. f.material.set({
  16789. weight1: i >= 1 ? .95 : 0,
  16790. weight2: i >= 1 ? .05 : 1
  16791. }),
  16792. f.render(e)),
  16793. h.attach(s),
  16794. c.setUniform("texture", this._physicallyCorrect ? this._currentTexture : o),
  16795. c.render(e),
  16796. h.attach(l),
  16797. d.setUniform("texture", s),
  16798. d.render(e),
  16799. h.unbind(e),
  16800. this._physicallyCorrect) {
  16801. var _ = this._prevTexture;
  16802. this._prevTexture = this._currentTexture,
  16803. this._currentTexture = _
  16804. }
  16805. }
  16806. ,
  16807. gl.prototype.getTargetTexture = function () {
  16808. return this._texture3
  16809. }
  16810. ,
  16811. gl.prototype.setParameter = function (e, t) {
  16812. "maxIteration" === e ? this._ssrPass.material.define("fragment", "MAX_ITERATION", t) : this._ssrPass.setUniform(e, t)
  16813. }
  16814. ,
  16815. gl.prototype.setPhysicallyCorrect = function (e) {
  16816. e ? (this._normalDistribution || (this._normalDistribution = _n.generateNormalDistribution(64, this._totalSamples)),
  16817. this._ssrPass.material.define("fragment", "PHYSICALLY_CORRECT"),
  16818. this._ssrPass.material.set("normalDistribution", this._normalDistribution),
  16819. this._ssrPass.material.set("normalDistributionSize", [64, this._totalSamples])) : this._ssrPass.material.undefine("fragment", "PHYSICALLY_CORRECT"),
  16820. this._physicallyCorrect = e
  16821. }
  16822. ,
  16823. gl.prototype.setSSAOTexture = function (e) {
  16824. var t = this._blurPass2;
  16825. e ? (t.material.enableTexture("ssaoTex"),
  16826. t.material.set("ssaoTex", e)) : t.material.disableTexture("ssaoTex")
  16827. }
  16828. ,
  16829. gl.prototype.isFinished = function (e) {
  16830. return !this._physicallyCorrect || e > this._totalSamples / this._samplePerFrame
  16831. }
  16832. ,
  16833. gl.prototype.dispose = function (e) {
  16834. this._ssrTexture.dispose(e),
  16835. this._texture2.dispose(e),
  16836. this._texture3.dispose(e),
  16837. this._prevTexture.dispose(e),
  16838. this._currentTexture.dispose(e),
  16839. this._frameBuffer.dispose(e)
  16840. }
  16841. ;
  16842. const _l = gl
  16843. , vl = [0, 0, -.321585265978, -.154972575841, .458126042375, .188473391593, .842080129861, .527766490688, .147304551086, -.659453822776, -.331943915203, -.940619700594, .0479226680259, .54812163202, .701581552186, -.709825561388, -.295436780218, .940589268233, -.901489676764, .237713156085, .973570876096, -.109899459384, -.866792314779, -.451805525005, .330975007087, .800048655954, -.344275183665, .381779221166, -.386139432542, -.437418421534, -.576478634965, -.0148463392551, .385798197415, -.262426961053, -.666302061145, .682427250835, -.628010632582, -.732836215494, .10163141741, -.987658134403, .711995289051, -.320024291314, .0296005138058, .950296523438, .0130612307608, -.351024443122, -.879596633704, -.10478487883, .435712737232, .504254490347, .779203817497, .206477676721, .388264289969, -.896736162545, -.153106280781, -.629203242522, -.245517550697, .657969239148, .126830499058, .26862328493, -.634888119007, -.302301223431, .617074219636, .779817204925];
  16844. function yl(e, t, r, i, n) {
  16845. var a = e.gl;
  16846. t.setUniform(a, "1i", r, n),
  16847. a.activeTexture(a.TEXTURE0 + n),
  16848. i.isRenderable() ? i.bind(e) : i.unbind(e)
  16849. }
  16850. function xl(e, t, r, i, n) {
  16851. var a, o, s, l, h = e.gl;
  16852. return function (n, u, c) {
  16853. if (!l || l.material !== n.material) {
  16854. var d = n.material
  16855. , f = n.__program
  16856. , p = d.get("roughness");
  16857. null == p && (p = 1);
  16858. var m = d.get("normalMap") || t
  16859. , g = d.get("roughnessMap")
  16860. , _ = d.get("bumpMap")
  16861. , v = d.get("uvRepeat")
  16862. , y = d.get("uvOffset")
  16863. , x = d.get("detailUvRepeat")
  16864. , b = d.get("detailUvOffset")
  16865. , w = !!_ && d.isTextureEnabled("bumpMap")
  16866. , T = !!g && d.isTextureEnabled("roughnessMap")
  16867. , S = d.isDefined("fragment", "DOUBLE_SIDED");
  16868. _ = _ || r,
  16869. g = g || i,
  16870. c !== u ? (u.set("normalMap", m),
  16871. u.set("bumpMap", _),
  16872. u.set("roughnessMap", g),
  16873. u.set("useBumpMap", w),
  16874. u.set("useRoughnessMap", T),
  16875. u.set("doubleSide", S),
  16876. null != v && u.set("uvRepeat", v),
  16877. null != y && u.set("uvOffset", y),
  16878. null != x && u.set("detailUvRepeat", x),
  16879. null != b && u.set("detailUvOffset", b),
  16880. u.set("roughness", p)) : (f.setUniform(h, "1f", "roughness", p),
  16881. a !== m && yl(e, f, "normalMap", m, 0),
  16882. o !== _ && _ && yl(e, f, "bumpMap", _, 1),
  16883. s !== g && g && yl(e, f, "roughnessMap", g, 2),
  16884. null != v && f.setUniform(h, "2f", "uvRepeat", v),
  16885. null != y && f.setUniform(h, "2f", "uvOffset", y),
  16886. null != x && f.setUniform(h, "2f", "detailUvRepeat", x),
  16887. null != b && f.setUniform(h, "2f", "detailUvOffset", b),
  16888. f.setUniform(h, "1i", "useBumpMap", +w),
  16889. f.setUniform(h, "1i", "useRoughnessMap", +T),
  16890. f.setUniform(h, "1i", "doubleSide", +S)),
  16891. a = m,
  16892. o = _,
  16893. s = g,
  16894. l = n
  16895. }
  16896. }
  16897. }
  16898. function bl(e) {
  16899. e = e || {},
  16900. this._depthTex = new Dr({
  16901. format: wr.DEPTH_COMPONENT,
  16902. type: wr.UNSIGNED_INT
  16903. }),
  16904. this._normalTex = new Dr({
  16905. type: wr.HALF_FLOAT
  16906. }),
  16907. this._framebuffer = new zi,
  16908. this._framebuffer.attach(this._normalTex),
  16909. this._framebuffer.attach(this._depthTex, zi.DEPTH_ATTACHMENT),
  16910. this._normalMaterial = new le({
  16911. shader: new Xe(Xe.source("ecgl.normal.vertex"), Xe.source("ecgl.normal.fragment"))
  16912. }),
  16913. this._normalMaterial.enableTexture(["normalMap", "bumpMap", "roughnessMap"]),
  16914. this._defaultNormalMap = an.createBlank("#000"),
  16915. this._defaultBumpMap = an.createBlank("#000"),
  16916. this._defaultRoughessMap = an.createBlank("#000"),
  16917. this._debugPass = new pn({
  16918. fragment: Xe.source("clay.compositor.output")
  16919. }),
  16920. this._debugPass.setUniform("texture", this._normalTex),
  16921. this._debugPass.material.undefine("fragment", "OUTPUT_ALPHA")
  16922. }
  16923. Xe.import("@export ecgl.normal.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\n@import ecgl.common.normalMap.vertexHeader\n\n@import ecgl.common.vertexAnimation.header\n\nvoid main()\n{\n\n @import ecgl.common.vertexAnimation.main\n\n @import ecgl.common.uv.main\n\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n @import ecgl.common.normalMap.vertexMain\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n}\n\n\n@end\n\n\n@export ecgl.normal.fragment\n\n#define ROUGHNESS_CHANEL 0\n\nuniform bool useBumpMap;\nuniform bool useRoughnessMap;\nuniform bool doubleSide;\nuniform float roughness;\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n@import ecgl.common.normalMap.fragmentHeader\n@import ecgl.common.bumpMap.header\n\nuniform sampler2D roughnessMap;\n\nvoid main()\n{\n vec3 N = v_Normal;\n \n bool flipNormal = false;\n if (doubleSide) {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n flipNormal = true;\n }\n }\n\n @import ecgl.common.normalMap.fragmentMain\n\n if (useBumpMap) {\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n }\n\n float g = 1.0 - roughness;\n\n if (useRoughnessMap) {\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n }\n\n if (flipNormal) {\n N = -N;\n }\n\n gl_FragColor.rgb = (N.xyz + 1.0) * 0.5;\n gl_FragColor.a = g;\n}\n@end"),
  16924. bl.prototype.getDepthTexture = function () {
  16925. return this._depthTex
  16926. }
  16927. ,
  16928. bl.prototype.getNormalTexture = function () {
  16929. return this._normalTex
  16930. }
  16931. ,
  16932. bl.prototype.update = function (e, t, r) {
  16933. var i = e.getWidth()
  16934. , n = e.getHeight()
  16935. , a = this._depthTex
  16936. , o = this._normalTex
  16937. , s = this._normalMaterial;
  16938. a.width = i,
  16939. a.height = n,
  16940. o.width = i,
  16941. o.height = n;
  16942. var l = t.getRenderList(r).opaque;
  16943. this._framebuffer.bind(e),
  16944. e.gl.clearColor(0, 0, 0, 0),
  16945. e.gl.clear(e.gl.COLOR_BUFFER_BIT | e.gl.DEPTH_BUFFER_BIT),
  16946. e.gl.disable(e.gl.BLEND),
  16947. e.renderPass(l, r, {
  16948. getMaterial: function () {
  16949. return s
  16950. },
  16951. ifRender: function (e) {
  16952. return e.renderNormal
  16953. },
  16954. beforeRender: xl(e, this._defaultNormalMap, this._defaultBumpMap, this._defaultRoughessMap, this._normalMaterial),
  16955. sort: e.opaqueSortCompare
  16956. }),
  16957. this._framebuffer.unbind(e)
  16958. }
  16959. ,
  16960. bl.prototype.renderDebug = function (e) {
  16961. this._debugPass.render(e)
  16962. }
  16963. ,
  16964. bl.prototype.dispose = function (e) {
  16965. this._depthTex.dispose(e),
  16966. this._normalTex.dispose(e)
  16967. }
  16968. ;
  16969. const wl = bl;
  16970. function Tl(e) {
  16971. e = e || {},
  16972. this._edgePass = new pn({
  16973. fragment: Xe.source("ecgl.edge")
  16974. }),
  16975. this._edgePass.setUniform("normalTexture", e.normalTexture),
  16976. this._edgePass.setUniform("depthTexture", e.depthTexture),
  16977. this._targetTexture = new Dr({
  16978. type: wr.HALF_FLOAT
  16979. }),
  16980. this._frameBuffer = new zi,
  16981. this._frameBuffer.attach(this._targetTexture)
  16982. }
  16983. Tl.prototype.update = function (e, t, r, i) {
  16984. var n = e.getWidth()
  16985. , a = e.getHeight()
  16986. , o = this._targetTexture;
  16987. o.width = n,
  16988. o.height = a;
  16989. var s = this._frameBuffer;
  16990. s.bind(e),
  16991. this._edgePass.setUniform("projectionInv", t.invProjectionMatrix.array),
  16992. this._edgePass.setUniform("textureSize", [n, a]),
  16993. this._edgePass.setUniform("texture", r),
  16994. this._edgePass.render(e),
  16995. s.unbind(e)
  16996. }
  16997. ,
  16998. Tl.prototype.getTargetTexture = function () {
  16999. return this._targetTexture
  17000. }
  17001. ,
  17002. Tl.prototype.setParameter = function (e, t) {
  17003. this._edgePass.setUniform(e, t)
  17004. }
  17005. ,
  17006. Tl.prototype.dispose = function (e) {
  17007. this._targetTexture.dispose(e),
  17008. this._frameBuffer.dispose(e)
  17009. }
  17010. ;
  17011. const Sl = Tl
  17012. , Ml = {
  17013. type: "compositor",
  17014. nodes: [{
  17015. name: "source",
  17016. type: "texture",
  17017. outputs: {
  17018. color: {}
  17019. }
  17020. }, {
  17021. name: "source_half",
  17022. shader: "#source(clay.compositor.downsample)",
  17023. inputs: {
  17024. texture: "source"
  17025. },
  17026. outputs: {
  17027. color: {
  17028. parameters: {
  17029. width: "expr(width * 1.0 / 2)",
  17030. height: "expr(height * 1.0 / 2)",
  17031. type: "HALF_FLOAT"
  17032. }
  17033. }
  17034. },
  17035. parameters: {
  17036. textureSize: "expr( [width * 1.0, height * 1.0] )"
  17037. }
  17038. }, {
  17039. name: "bright",
  17040. shader: "#source(clay.compositor.bright)",
  17041. inputs: {
  17042. texture: "source_half"
  17043. },
  17044. outputs: {
  17045. color: {
  17046. parameters: {
  17047. width: "expr(width * 1.0 / 2)",
  17048. height: "expr(height * 1.0 / 2)",
  17049. type: "HALF_FLOAT"
  17050. }
  17051. }
  17052. },
  17053. parameters: {
  17054. threshold: 2,
  17055. scale: 4,
  17056. textureSize: "expr([width * 1.0 / 2, height / 2])"
  17057. }
  17058. }, {
  17059. name: "bright_downsample_4",
  17060. shader: "#source(clay.compositor.downsample)",
  17061. inputs: {
  17062. texture: "bright"
  17063. },
  17064. outputs: {
  17065. color: {
  17066. parameters: {
  17067. width: "expr(width * 1.0 / 4)",
  17068. height: "expr(height * 1.0 / 4)",
  17069. type: "HALF_FLOAT"
  17070. }
  17071. }
  17072. },
  17073. parameters: {
  17074. textureSize: "expr( [width * 1.0 / 2, height / 2] )"
  17075. }
  17076. }, {
  17077. name: "bright_downsample_8",
  17078. shader: "#source(clay.compositor.downsample)",
  17079. inputs: {
  17080. texture: "bright_downsample_4"
  17081. },
  17082. outputs: {
  17083. color: {
  17084. parameters: {
  17085. width: "expr(width * 1.0 / 8)",
  17086. height: "expr(height * 1.0 / 8)",
  17087. type: "HALF_FLOAT"
  17088. }
  17089. }
  17090. },
  17091. parameters: {
  17092. textureSize: "expr( [width * 1.0 / 4, height / 4] )"
  17093. }
  17094. }, {
  17095. name: "bright_downsample_16",
  17096. shader: "#source(clay.compositor.downsample)",
  17097. inputs: {
  17098. texture: "bright_downsample_8"
  17099. },
  17100. outputs: {
  17101. color: {
  17102. parameters: {
  17103. width: "expr(width * 1.0 / 16)",
  17104. height: "expr(height * 1.0 / 16)",
  17105. type: "HALF_FLOAT"
  17106. }
  17107. }
  17108. },
  17109. parameters: {
  17110. textureSize: "expr( [width * 1.0 / 8, height / 8] )"
  17111. }
  17112. }, {
  17113. name: "bright_downsample_32",
  17114. shader: "#source(clay.compositor.downsample)",
  17115. inputs: {
  17116. texture: "bright_downsample_16"
  17117. },
  17118. outputs: {
  17119. color: {
  17120. parameters: {
  17121. width: "expr(width * 1.0 / 32)",
  17122. height: "expr(height * 1.0 / 32)",
  17123. type: "HALF_FLOAT"
  17124. }
  17125. }
  17126. },
  17127. parameters: {
  17128. textureSize: "expr( [width * 1.0 / 16, height / 16] )"
  17129. }
  17130. }, {
  17131. name: "bright_upsample_16_blur_h",
  17132. shader: "#source(clay.compositor.gaussian_blur)",
  17133. inputs: {
  17134. texture: "bright_downsample_32"
  17135. },
  17136. outputs: {
  17137. color: {
  17138. parameters: {
  17139. width: "expr(width * 1.0 / 16)",
  17140. height: "expr(height * 1.0 / 16)",
  17141. type: "HALF_FLOAT"
  17142. }
  17143. }
  17144. },
  17145. parameters: {
  17146. blurSize: 1,
  17147. blurDir: 0,
  17148. textureSize: "expr( [width * 1.0 / 32, height / 32] )"
  17149. }
  17150. }, {
  17151. name: "bright_upsample_16_blur_v",
  17152. shader: "#source(clay.compositor.gaussian_blur)",
  17153. inputs: {
  17154. texture: "bright_upsample_16_blur_h"
  17155. },
  17156. outputs: {
  17157. color: {
  17158. parameters: {
  17159. width: "expr(width * 1.0 / 16)",
  17160. height: "expr(height * 1.0 / 16)",
  17161. type: "HALF_FLOAT"
  17162. }
  17163. }
  17164. },
  17165. parameters: {
  17166. blurSize: 1,
  17167. blurDir: 1,
  17168. textureSize: "expr( [width * 1.0 / 16, height * 1.0 / 16] )"
  17169. }
  17170. }, {
  17171. name: "bright_upsample_8_blur_h",
  17172. shader: "#source(clay.compositor.gaussian_blur)",
  17173. inputs: {
  17174. texture: "bright_downsample_16"
  17175. },
  17176. outputs: {
  17177. color: {
  17178. parameters: {
  17179. width: "expr(width * 1.0 / 8)",
  17180. height: "expr(height * 1.0 / 8)",
  17181. type: "HALF_FLOAT"
  17182. }
  17183. }
  17184. },
  17185. parameters: {
  17186. blurSize: 1,
  17187. blurDir: 0,
  17188. textureSize: "expr( [width * 1.0 / 16, height * 1.0 / 16] )"
  17189. }
  17190. }, {
  17191. name: "bright_upsample_8_blur_v",
  17192. shader: "#source(clay.compositor.gaussian_blur)",
  17193. inputs: {
  17194. texture: "bright_upsample_8_blur_h"
  17195. },
  17196. outputs: {
  17197. color: {
  17198. parameters: {
  17199. width: "expr(width * 1.0 / 8)",
  17200. height: "expr(height * 1.0 / 8)",
  17201. type: "HALF_FLOAT"
  17202. }
  17203. }
  17204. },
  17205. parameters: {
  17206. blurSize: 1,
  17207. blurDir: 1,
  17208. textureSize: "expr( [width * 1.0 / 8, height * 1.0 / 8] )"
  17209. }
  17210. }, {
  17211. name: "bright_upsample_8_blend",
  17212. shader: "#source(clay.compositor.blend)",
  17213. inputs: {
  17214. texture1: "bright_upsample_8_blur_v",
  17215. texture2: "bright_upsample_16_blur_v"
  17216. },
  17217. outputs: {
  17218. color: {
  17219. parameters: {
  17220. width: "expr(width * 1.0 / 8)",
  17221. height: "expr(height * 1.0 / 8)",
  17222. type: "HALF_FLOAT"
  17223. }
  17224. }
  17225. },
  17226. parameters: {
  17227. weight1: .3,
  17228. weight2: .7
  17229. }
  17230. }, {
  17231. name: "bright_upsample_4_blur_h",
  17232. shader: "#source(clay.compositor.gaussian_blur)",
  17233. inputs: {
  17234. texture: "bright_downsample_8"
  17235. },
  17236. outputs: {
  17237. color: {
  17238. parameters: {
  17239. width: "expr(width * 1.0 / 4)",
  17240. height: "expr(height * 1.0 / 4)",
  17241. type: "HALF_FLOAT"
  17242. }
  17243. }
  17244. },
  17245. parameters: {
  17246. blurSize: 1,
  17247. blurDir: 0,
  17248. textureSize: "expr( [width * 1.0 / 8, height * 1.0 / 8] )"
  17249. }
  17250. }, {
  17251. name: "bright_upsample_4_blur_v",
  17252. shader: "#source(clay.compositor.gaussian_blur)",
  17253. inputs: {
  17254. texture: "bright_upsample_4_blur_h"
  17255. },
  17256. outputs: {
  17257. color: {
  17258. parameters: {
  17259. width: "expr(width * 1.0 / 4)",
  17260. height: "expr(height * 1.0 / 4)",
  17261. type: "HALF_FLOAT"
  17262. }
  17263. }
  17264. },
  17265. parameters: {
  17266. blurSize: 1,
  17267. blurDir: 1,
  17268. textureSize: "expr( [width * 1.0 / 4, height * 1.0 / 4] )"
  17269. }
  17270. }, {
  17271. name: "bright_upsample_4_blend",
  17272. shader: "#source(clay.compositor.blend)",
  17273. inputs: {
  17274. texture1: "bright_upsample_4_blur_v",
  17275. texture2: "bright_upsample_8_blend"
  17276. },
  17277. outputs: {
  17278. color: {
  17279. parameters: {
  17280. width: "expr(width * 1.0 / 4)",
  17281. height: "expr(height * 1.0 / 4)",
  17282. type: "HALF_FLOAT"
  17283. }
  17284. }
  17285. },
  17286. parameters: {
  17287. weight1: .3,
  17288. weight2: .7
  17289. }
  17290. }, {
  17291. name: "bright_upsample_2_blur_h",
  17292. shader: "#source(clay.compositor.gaussian_blur)",
  17293. inputs: {
  17294. texture: "bright_downsample_4"
  17295. },
  17296. outputs: {
  17297. color: {
  17298. parameters: {
  17299. width: "expr(width * 1.0 / 2)",
  17300. height: "expr(height * 1.0 / 2)",
  17301. type: "HALF_FLOAT"
  17302. }
  17303. }
  17304. },
  17305. parameters: {
  17306. blurSize: 1,
  17307. blurDir: 0,
  17308. textureSize: "expr( [width * 1.0 / 4, height * 1.0 / 4] )"
  17309. }
  17310. }, {
  17311. name: "bright_upsample_2_blur_v",
  17312. shader: "#source(clay.compositor.gaussian_blur)",
  17313. inputs: {
  17314. texture: "bright_upsample_2_blur_h"
  17315. },
  17316. outputs: {
  17317. color: {
  17318. parameters: {
  17319. width: "expr(width * 1.0 / 2)",
  17320. height: "expr(height * 1.0 / 2)",
  17321. type: "HALF_FLOAT"
  17322. }
  17323. }
  17324. },
  17325. parameters: {
  17326. blurSize: 1,
  17327. blurDir: 1,
  17328. textureSize: "expr( [width * 1.0 / 2, height * 1.0 / 2] )"
  17329. }
  17330. }, {
  17331. name: "bright_upsample_2_blend",
  17332. shader: "#source(clay.compositor.blend)",
  17333. inputs: {
  17334. texture1: "bright_upsample_2_blur_v",
  17335. texture2: "bright_upsample_4_blend"
  17336. },
  17337. outputs: {
  17338. color: {
  17339. parameters: {
  17340. width: "expr(width * 1.0 / 2)",
  17341. height: "expr(height * 1.0 / 2)",
  17342. type: "HALF_FLOAT"
  17343. }
  17344. }
  17345. },
  17346. parameters: {
  17347. weight1: .3,
  17348. weight2: .7
  17349. }
  17350. }, {
  17351. name: "bright_upsample_full_blur_h",
  17352. shader: "#source(clay.compositor.gaussian_blur)",
  17353. inputs: {
  17354. texture: "bright"
  17355. },
  17356. outputs: {
  17357. color: {
  17358. parameters: {
  17359. width: "expr(width * 1.0)",
  17360. height: "expr(height * 1.0)",
  17361. type: "HALF_FLOAT"
  17362. }
  17363. }
  17364. },
  17365. parameters: {
  17366. blurSize: 1,
  17367. blurDir: 0,
  17368. textureSize: "expr( [width * 1.0 / 2, height * 1.0 / 2] )"
  17369. }
  17370. }, {
  17371. name: "bright_upsample_full_blur_v",
  17372. shader: "#source(clay.compositor.gaussian_blur)",
  17373. inputs: {
  17374. texture: "bright_upsample_full_blur_h"
  17375. },
  17376. outputs: {
  17377. color: {
  17378. parameters: {
  17379. width: "expr(width * 1.0)",
  17380. height: "expr(height * 1.0)",
  17381. type: "HALF_FLOAT"
  17382. }
  17383. }
  17384. },
  17385. parameters: {
  17386. blurSize: 1,
  17387. blurDir: 1,
  17388. textureSize: "expr( [width * 1.0, height * 1.0] )"
  17389. }
  17390. }, {
  17391. name: "bloom_composite",
  17392. shader: "#source(clay.compositor.blend)",
  17393. inputs: {
  17394. texture1: "bright_upsample_full_blur_v",
  17395. texture2: "bright_upsample_2_blend"
  17396. },
  17397. outputs: {
  17398. color: {
  17399. parameters: {
  17400. width: "expr(width * 1.0)",
  17401. height: "expr(height * 1.0)",
  17402. type: "HALF_FLOAT"
  17403. }
  17404. }
  17405. },
  17406. parameters: {
  17407. weight1: .3,
  17408. weight2: .7
  17409. }
  17410. }, {
  17411. name: "coc",
  17412. shader: "#source(ecgl.dof.coc)",
  17413. outputs: {
  17414. color: {
  17415. parameters: {
  17416. minFilter: "NEAREST",
  17417. magFilter: "NEAREST",
  17418. width: "expr(width * 1.0)",
  17419. height: "expr(height * 1.0)"
  17420. }
  17421. }
  17422. },
  17423. parameters: {
  17424. focalDist: 50,
  17425. focalRange: 30
  17426. }
  17427. }, {
  17428. name: "dof_far_blur",
  17429. shader: "#source(ecgl.dof.diskBlur)",
  17430. inputs: {
  17431. texture: "source",
  17432. coc: "coc"
  17433. },
  17434. outputs: {
  17435. color: {
  17436. parameters: {
  17437. width: "expr(width * 1.0)",
  17438. height: "expr(height * 1.0)",
  17439. type: "HALF_FLOAT"
  17440. }
  17441. }
  17442. },
  17443. parameters: {
  17444. textureSize: "expr( [width * 1.0, height * 1.0] )"
  17445. }
  17446. }, {
  17447. name: "dof_near_blur",
  17448. shader: "#source(ecgl.dof.diskBlur)",
  17449. inputs: {
  17450. texture: "source",
  17451. coc: "coc"
  17452. },
  17453. outputs: {
  17454. color: {
  17455. parameters: {
  17456. width: "expr(width * 1.0)",
  17457. height: "expr(height * 1.0)",
  17458. type: "HALF_FLOAT"
  17459. }
  17460. }
  17461. },
  17462. parameters: {
  17463. textureSize: "expr( [width * 1.0, height * 1.0] )"
  17464. },
  17465. defines: {
  17466. BLUR_NEARFIELD: null
  17467. }
  17468. }, {
  17469. name: "dof_coc_blur",
  17470. shader: "#source(ecgl.dof.diskBlur)",
  17471. inputs: {
  17472. texture: "coc"
  17473. },
  17474. outputs: {
  17475. color: {
  17476. parameters: {
  17477. minFilter: "NEAREST",
  17478. magFilter: "NEAREST",
  17479. width: "expr(width * 1.0)",
  17480. height: "expr(height * 1.0)"
  17481. }
  17482. }
  17483. },
  17484. parameters: {
  17485. textureSize: "expr( [width * 1.0, height * 1.0] )"
  17486. },
  17487. defines: {
  17488. BLUR_COC: null
  17489. }
  17490. }, {
  17491. name: "dof_composite",
  17492. shader: "#source(ecgl.dof.composite)",
  17493. inputs: {
  17494. original: "source",
  17495. blurred: "dof_far_blur",
  17496. nearfield: "dof_near_blur",
  17497. coc: "coc",
  17498. nearcoc: "dof_coc_blur"
  17499. },
  17500. outputs: {
  17501. color: {
  17502. parameters: {
  17503. width: "expr(width * 1.0)",
  17504. height: "expr(height * 1.0)",
  17505. type: "HALF_FLOAT"
  17506. }
  17507. }
  17508. }
  17509. }, {
  17510. name: "composite",
  17511. shader: "#source(clay.compositor.hdr.composite)",
  17512. inputs: {
  17513. texture: "source",
  17514. bloom: "bloom_composite"
  17515. },
  17516. outputs: {
  17517. color: {
  17518. parameters: {
  17519. width: "expr(width * 1.0)",
  17520. height: "expr(height * 1.0)"
  17521. }
  17522. }
  17523. },
  17524. defines: {}
  17525. }, {
  17526. name: "FXAA",
  17527. shader: "#source(clay.compositor.fxaa)",
  17528. inputs: {
  17529. texture: "composite"
  17530. }
  17531. }]
  17532. };
  17533. function Al(e, t) {
  17534. return {
  17535. color: {
  17536. parameters: {
  17537. width: e,
  17538. height: t
  17539. }
  17540. }
  17541. }
  17542. }
  17543. Xe.import(Zs),
  17544. Xe.import(Ys),
  17545. Xe.import(Ks),
  17546. Xe.import(Qs),
  17547. Xe.import(Js),
  17548. Xe.import($s),
  17549. Xe.import(el),
  17550. Xe.import(tl),
  17551. Xe.import(rl),
  17552. Xe.import("@export ecgl.dof.coc\n\nuniform sampler2D depth;\n\nuniform float zNear: 0.1;\nuniform float zFar: 2000;\n\nuniform float focalDistance: 3;\nuniform float focalRange: 1;\nuniform float focalLength: 30;\nuniform float fstop: 2.8;\n\nvarying vec2 v_Texcoord;\n\n@import clay.util.encode_float\n\nvoid main()\n{\n float z = texture2D(depth, v_Texcoord).r * 2.0 - 1.0;\n\n float dist = 2.0 * zNear * zFar / (zFar + zNear - z * (zFar - zNear));\n\n float aperture = focalLength / fstop;\n\n float coc;\n\n float uppper = focalDistance + focalRange;\n float lower = focalDistance - focalRange;\n if (dist <= uppper && dist >= lower) {\n coc = 0.5;\n }\n else {\n float focalAdjusted = dist > uppper ? uppper : lower;\n\n coc = abs(aperture * (focalLength * (dist - focalAdjusted)) / (dist * (focalAdjusted - focalLength)));\n coc = clamp(coc, 0.0, 2.0) / 2.00001;\n\n if (dist < lower) {\n coc = -coc;\n }\n coc = coc * 0.5 + 0.5;\n }\n\n gl_FragColor = encodeFloat(coc);\n}\n@end\n\n\n@export ecgl.dof.composite\n\n#define DEBUG 0\n\nuniform sampler2D original;\nuniform sampler2D blurred;\nuniform sampler2D nearfield;\nuniform sampler2D coc;\nuniform sampler2D nearcoc;\nvarying vec2 v_Texcoord;\n\n@import clay.util.rgbm\n@import clay.util.float\n\nvoid main()\n{\n vec4 blurredColor = texture2D(blurred, v_Texcoord);\n vec4 originalColor = texture2D(original, v_Texcoord);\n\n float fCoc = decodeFloat(texture2D(coc, v_Texcoord));\n\n fCoc = abs(fCoc * 2.0 - 1.0);\n\n float weight = smoothstep(0.0, 1.0, fCoc);\n \n#ifdef NEARFIELD_ENABLED\n vec4 nearfieldColor = texture2D(nearfield, v_Texcoord);\n float fNearCoc = decodeFloat(texture2D(nearcoc, v_Texcoord));\n fNearCoc = abs(fNearCoc * 2.0 - 1.0);\n\n gl_FragColor = encodeHDR(\n mix(\n nearfieldColor, mix(originalColor, blurredColor, weight),\n pow(1.0 - fNearCoc, 4.0)\n )\n );\n#else\n gl_FragColor = encodeHDR(mix(originalColor, blurredColor, weight));\n#endif\n\n}\n\n@end\n\n\n\n@export ecgl.dof.diskBlur\n\n#define POISSON_KERNEL_SIZE 16;\n\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\n\nuniform float blurRadius : 10.0;\nuniform vec2 textureSize : [512.0, 512.0];\n\nuniform vec2 poissonKernel[POISSON_KERNEL_SIZE];\n\nuniform float percent;\n\nfloat nrand(const in vec2 n) {\n return fract(sin(dot(n.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n\n@import clay.util.rgbm\n@import clay.util.float\n\n\nvoid main()\n{\n vec2 offset = blurRadius / textureSize;\n\n float rnd = 6.28318 * nrand(v_Texcoord + 0.07 * percent );\n float cosa = cos(rnd);\n float sina = sin(rnd);\n vec4 basis = vec4(cosa, -sina, sina, cosa);\n\n#if !defined(BLUR_NEARFIELD) && !defined(BLUR_COC)\n offset *= abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0);\n#endif\n\n#ifdef BLUR_COC\n float cocSum = 0.0;\n#else\n vec4 color = vec4(0.0);\n#endif\n\n\n float weightSum = 0.0;\n\n for (int i = 0; i < POISSON_KERNEL_SIZE; i++) {\n vec2 ofs = poissonKernel[i];\n\n ofs = vec2(dot(ofs, basis.xy), dot(ofs, basis.zw));\n\n vec2 uv = v_Texcoord + ofs * offset;\n vec4 texel = texture2D(texture, uv);\n\n float w = 1.0;\n#ifdef BLUR_COC\n float fCoc = decodeFloat(texel) * 2.0 - 1.0;\n cocSum += clamp(fCoc, -1.0, 0.0) * w;\n#else\n texel = texel;\n #if !defined(BLUR_NEARFIELD)\n float fCoc = decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0;\n w *= abs(fCoc);\n #endif\n texel.rgb *= texel.a;\n color += texel * w;\n#endif\n\n weightSum += w;\n }\n\n#ifdef BLUR_COC\n gl_FragColor = encodeFloat(clamp(cocSum / weightSum, -1.0, 0.0) * 0.5 + 0.5);\n#else\n color /= weightSum;\n color.rgb /= (color.a + 0.0001);\n gl_FragColor = color;\n#endif\n}\n\n@end"),
  17553. Xe.import("@export ecgl.edge\n\nuniform sampler2D texture;\n\nuniform sampler2D normalTexture;\nuniform sampler2D depthTexture;\n\nuniform mat4 projectionInv;\n\nuniform vec2 textureSize;\n\nuniform vec4 edgeColor: [0,0,0,0.8];\n\nvarying vec2 v_Texcoord;\n\nvec3 packColor(vec2 coord) {\n float z = texture2D(depthTexture, coord).r * 2.0 - 1.0;\n vec4 p = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * p;\n\n return vec3(\n texture2D(normalTexture, coord).rg,\n -p4.z / p4.w / 5.0\n );\n}\n\nvoid main() {\n vec2 cc = v_Texcoord;\n vec3 center = packColor(cc);\n\n float size = clamp(1.0 - (center.z - 10.0) / 100.0, 0.0, 1.0) * 0.5;\n float dx = size / textureSize.x;\n float dy = size / textureSize.y;\n\n vec2 coord;\n vec3 topLeft = packColor(cc+vec2(-dx, -dy));\n vec3 top = packColor(cc+vec2(0.0, -dy));\n vec3 topRight = packColor(cc+vec2(dx, -dy));\n vec3 left = packColor(cc+vec2(-dx, 0.0));\n vec3 right = packColor(cc+vec2(dx, 0.0));\n vec3 bottomLeft = packColor(cc+vec2(-dx, dy));\n vec3 bottom = packColor(cc+vec2(0.0, dy));\n vec3 bottomRight = packColor(cc+vec2(dx, dy));\n\n vec3 v = -topLeft-2.0*top-topRight+bottomLeft+2.0*bottom+bottomRight;\n vec3 h = -bottomLeft-2.0*left-topLeft+bottomRight+2.0*right+topRight;\n\n float edge = sqrt(dot(h, h) + dot(v, v));\n\n edge = smoothstep(0.8, 1.0, edge);\n\n gl_FragColor = mix(texture2D(texture, v_Texcoord), vec4(edgeColor.rgb, 1.0), edgeColor.a * edge);\n}\n@end");
  17554. var El = ["composite", "FXAA"];
  17555. function Cl() {
  17556. this._width,
  17557. this._height,
  17558. this._dpr,
  17559. this._sourceTexture = new Dr({
  17560. type: wr.HALF_FLOAT
  17561. }),
  17562. this._depthTexture = new Dr({
  17563. format: wr.DEPTH_COMPONENT,
  17564. type: wr.UNSIGNED_INT
  17565. }),
  17566. this._framebuffer = new zi,
  17567. this._framebuffer.attach(this._sourceTexture),
  17568. this._framebuffer.attach(this._depthTexture, zi.DEPTH_ATTACHMENT),
  17569. this._normalPass = new wl,
  17570. this._compositor = function (e, t) {
  17571. var r = new Ws;
  17572. t = t || {};
  17573. var i = {
  17574. textures: {},
  17575. parameters: {}
  17576. };
  17577. for (var n in e.parameters) {
  17578. var a = e.parameters[n];
  17579. i.parameters[n] = sl(a)
  17580. }
  17581. return function (e, t, r, i) {
  17582. if (e.textures) {
  17583. var n = {}
  17584. , a = 0
  17585. , o = !1
  17586. , s = r.textureRootPath;
  17587. f.each(e.textures, (function (e, t) {
  17588. var r, l = e.path, h = sl(e.parameters);
  17589. if (Array.isArray(l) && 6 === l.length)
  17590. s && (l = l.map((function (e) {
  17591. return f.relative2absolute(e, s)
  17592. }
  17593. ))),
  17594. r = new Ai(h);
  17595. else {
  17596. if ("string" != typeof l)
  17597. return;
  17598. s && (l = f.relative2absolute(l, s)),
  17599. r = new Dr(h)
  17600. }
  17601. r.load(l),
  17602. a++,
  17603. r.once("success", (function () {
  17604. n[t] = r,
  17605. 0 == --a && (i(n),
  17606. o = !0)
  17607. }
  17608. ))
  17609. }
  17610. )),
  17611. 0 !== a || o || i(n)
  17612. } else
  17613. i({})
  17614. }(e, 0, t, (function (n) {
  17615. i.textures = n,
  17616. function (n, a) {
  17617. for (var o = 0; o < e.nodes.length; o++) {
  17618. var s = nl(e.nodes[o], i, t);
  17619. s && r.addNode(s)
  17620. }
  17621. }()
  17622. }
  17623. )),
  17624. r
  17625. }(Ml);
  17626. var e = this._compositor.getNodeByName("source");
  17627. e.texture = this._sourceTexture;
  17628. var t = this._compositor.getNodeByName("coc");
  17629. this._sourceNode = e,
  17630. this._cocNode = t,
  17631. this._compositeNode = this._compositor.getNodeByName("composite"),
  17632. this._fxaaNode = this._compositor.getNodeByName("FXAA"),
  17633. this._dofBlurNodes = ["dof_far_blur", "dof_near_blur", "dof_coc_blur"].map((function (e) {
  17634. return this._compositor.getNodeByName(e)
  17635. }
  17636. ), this),
  17637. this._dofBlurKernel = 0,
  17638. this._dofBlurKernelSize = new Float32Array(0),
  17639. this._finalNodesChain = El.map((function (e) {
  17640. return this._compositor.getNodeByName(e)
  17641. }
  17642. ), this);
  17643. var r = {
  17644. normalTexture: this._normalPass.getNormalTexture(),
  17645. depthTexture: this._normalPass.getDepthTexture()
  17646. };
  17647. this._ssaoPass = new ml(r),
  17648. this._ssrPass = new _l(r),
  17649. this._edgePass = new Sl(r)
  17650. }
  17651. Cl.prototype.resize = function (e, t, r) {
  17652. e *= r = r || 1,
  17653. t *= r;
  17654. var i = this._sourceTexture
  17655. , n = this._depthTexture;
  17656. i.width = e,
  17657. i.height = t,
  17658. n.width = e,
  17659. n.height = t;
  17660. var a = {
  17661. getWidth: function () {
  17662. return e
  17663. },
  17664. getHeight: function () {
  17665. return t
  17666. },
  17667. getDevicePixelRatio: function () {
  17668. return r
  17669. }
  17670. };
  17671. function o(e, t) {
  17672. if ("function" == typeof e[t]) {
  17673. var r = e[t].__original || e[t];
  17674. e[t] = function (e) {
  17675. return r.call(this, a)
  17676. }
  17677. ,
  17678. e[t].__original = r
  17679. }
  17680. }
  17681. this._compositor.nodes.forEach((function (e) {
  17682. for (var t in e.outputs) {
  17683. var r = e.outputs[t].parameters;
  17684. r && (o(r, "width"),
  17685. o(r, "height"))
  17686. }
  17687. for (var i in e.parameters)
  17688. o(e.parameters, i)
  17689. }
  17690. )),
  17691. this._width = e,
  17692. this._height = t,
  17693. this._dpr = r
  17694. }
  17695. ,
  17696. Cl.prototype.getWidth = function () {
  17697. return this._width
  17698. }
  17699. ,
  17700. Cl.prototype.getHeight = function () {
  17701. return this._height
  17702. }
  17703. ,
  17704. Cl.prototype._ifRenderNormalPass = function () {
  17705. return this._enableSSAO || this._enableEdge || this._enableSSR
  17706. }
  17707. ,
  17708. Cl.prototype._getPrevNode = function (e) {
  17709. for (var t = El.indexOf(e.name) - 1, r = this._finalNodesChain[t]; r && !this._compositor.getNodeByName(r.name);)
  17710. t -= 1,
  17711. r = this._finalNodesChain[t];
  17712. return r
  17713. }
  17714. ,
  17715. Cl.prototype._getNextNode = function (e) {
  17716. for (var t = El.indexOf(e.name) + 1, r = this._finalNodesChain[t]; r && !this._compositor.getNodeByName(r.name);)
  17717. t += 1,
  17718. r = this._finalNodesChain[t];
  17719. return r
  17720. }
  17721. ,
  17722. Cl.prototype._addChainNode = function (e) {
  17723. var t = this._getPrevNode(e)
  17724. , r = this._getNextNode(e);
  17725. t && (e.inputs.texture = t.name,
  17726. r ? (e.outputs = Al(this.getWidth.bind(this), this.getHeight.bind(this)),
  17727. r.inputs.texture = e.name) : e.outputs = null,
  17728. this._compositor.addNode(e))
  17729. }
  17730. ,
  17731. Cl.prototype._removeChainNode = function (e) {
  17732. var t = this._getPrevNode(e)
  17733. , r = this._getNextNode(e);
  17734. t && (r ? (t.outputs = Al(this.getWidth.bind(this), this.getHeight.bind(this)),
  17735. r.inputs.texture = t.name) : t.outputs = null,
  17736. this._compositor.removeNode(e))
  17737. }
  17738. ,
  17739. Cl.prototype.updateNormal = function (e, t, r, i) {
  17740. this._ifRenderNormalPass() && this._normalPass.update(e, t, r)
  17741. }
  17742. ,
  17743. Cl.prototype.updateSSAO = function (e, t, r, i) {
  17744. this._ssaoPass.update(e, r, i)
  17745. }
  17746. ,
  17747. Cl.prototype.enableSSAO = function () {
  17748. this._enableSSAO = !0
  17749. }
  17750. ,
  17751. Cl.prototype.disableSSAO = function () {
  17752. this._enableSSAO = !1
  17753. }
  17754. ,
  17755. Cl.prototype.enableSSR = function () {
  17756. this._enableSSR = !0
  17757. }
  17758. ,
  17759. Cl.prototype.disableSSR = function () {
  17760. this._enableSSR = !1
  17761. }
  17762. ,
  17763. Cl.prototype.getSSAOTexture = function () {
  17764. return this._ssaoPass.getTargetTexture()
  17765. }
  17766. ,
  17767. Cl.prototype.getSourceFrameBuffer = function () {
  17768. return this._framebuffer
  17769. }
  17770. ,
  17771. Cl.prototype.getSourceTexture = function () {
  17772. return this._sourceTexture
  17773. }
  17774. ,
  17775. Cl.prototype.disableFXAA = function () {
  17776. this._removeChainNode(this._fxaaNode)
  17777. }
  17778. ,
  17779. Cl.prototype.enableFXAA = function () {
  17780. this._addChainNode(this._fxaaNode)
  17781. }
  17782. ,
  17783. Cl.prototype.enableBloom = function () {
  17784. this._compositeNode.inputs.bloom = "bloom_composite",
  17785. this._compositor.dirty()
  17786. }
  17787. ,
  17788. Cl.prototype.disableBloom = function () {
  17789. this._compositeNode.inputs.bloom = null,
  17790. this._compositor.dirty()
  17791. }
  17792. ,
  17793. Cl.prototype.enableDOF = function () {
  17794. this._compositeNode.inputs.texture = "dof_composite",
  17795. this._compositor.dirty()
  17796. }
  17797. ,
  17798. Cl.prototype.disableDOF = function () {
  17799. this._compositeNode.inputs.texture = "source",
  17800. this._compositor.dirty()
  17801. }
  17802. ,
  17803. Cl.prototype.enableColorCorrection = function () {
  17804. this._compositeNode.define("COLOR_CORRECTION"),
  17805. this._enableColorCorrection = !0
  17806. }
  17807. ,
  17808. Cl.prototype.disableColorCorrection = function () {
  17809. this._compositeNode.undefine("COLOR_CORRECTION"),
  17810. this._enableColorCorrection = !1
  17811. }
  17812. ,
  17813. Cl.prototype.enableEdge = function () {
  17814. this._enableEdge = !0
  17815. }
  17816. ,
  17817. Cl.prototype.disableEdge = function () {
  17818. this._enableEdge = !1
  17819. }
  17820. ,
  17821. Cl.prototype.setBloomIntensity = function (e) {
  17822. this._compositeNode.setParameter("bloomIntensity", e)
  17823. }
  17824. ,
  17825. Cl.prototype.setSSAOParameter = function (e, t) {
  17826. switch (e) {
  17827. case "quality":
  17828. var r = {
  17829. low: 6,
  17830. medium: 12,
  17831. high: 32,
  17832. ultra: 62
  17833. }[t] || 12;
  17834. this._ssaoPass.setParameter("kernelSize", r);
  17835. break;
  17836. case "radius":
  17837. this._ssaoPass.setParameter(e, t),
  17838. this._ssaoPass.setParameter("bias", t / 200);
  17839. break;
  17840. case "intensity":
  17841. this._ssaoPass.setParameter(e, t)
  17842. }
  17843. }
  17844. ,
  17845. Cl.prototype.setDOFParameter = function (e, t) {
  17846. switch (e) {
  17847. case "focalDistance":
  17848. case "focalRange":
  17849. case "fstop":
  17850. this._cocNode.setParameter(e, t);
  17851. break;
  17852. case "blurRadius":
  17853. for (var r = 0; r < this._dofBlurNodes.length; r++)
  17854. this._dofBlurNodes[r].setParameter("blurRadius", t);
  17855. break;
  17856. case "quality":
  17857. var i = {
  17858. low: 4,
  17859. medium: 8,
  17860. high: 16,
  17861. ultra: 32
  17862. }[t] || 8;
  17863. for (this._dofBlurKernelSize = i,
  17864. r = 0; r < this._dofBlurNodes.length; r++)
  17865. this._dofBlurNodes[r].pass.material.define("POISSON_KERNEL_SIZE", i);
  17866. this._dofBlurKernel = new Float32Array(2 * i)
  17867. }
  17868. }
  17869. ,
  17870. Cl.prototype.setSSRParameter = function (e, t) {
  17871. if (null != t)
  17872. switch (e) {
  17873. case "quality":
  17874. var r = {
  17875. low: 10,
  17876. medium: 15,
  17877. high: 30,
  17878. ultra: 80
  17879. }[t] || 20
  17880. , i = {
  17881. low: 32,
  17882. medium: 16,
  17883. high: 8,
  17884. ultra: 4
  17885. }[t] || 16;
  17886. this._ssrPass.setParameter("maxIteration", r),
  17887. this._ssrPass.setParameter("pixelStride", i);
  17888. break;
  17889. case "maxRoughness":
  17890. this._ssrPass.setParameter("minGlossiness", Math.max(Math.min(1 - t, 1), 0));
  17891. break;
  17892. case "physical":
  17893. this.setPhysicallyCorrectSSR(t);
  17894. break;
  17895. default:
  17896. console.warn("Unkown SSR parameter " + e)
  17897. }
  17898. }
  17899. ,
  17900. Cl.prototype.setPhysicallyCorrectSSR = function (e) {
  17901. this._ssrPass.setPhysicallyCorrect(e)
  17902. }
  17903. ,
  17904. Cl.prototype.setEdgeColor = function (e) {
  17905. var t = Ka.parseColor(e);
  17906. this._edgePass.setParameter("edgeColor", t)
  17907. }
  17908. ,
  17909. Cl.prototype.setExposure = function (e) {
  17910. this._compositeNode.setParameter("exposure", Math.pow(2, e))
  17911. }
  17912. ,
  17913. Cl.prototype.setColorLookupTexture = function (e, t) {
  17914. this._compositeNode.pass.material.setTextureImage("lut", this._enableColorCorrection ? e : "none", t, {
  17915. minFilter: Ka.Texture.NEAREST,
  17916. magFilter: Ka.Texture.NEAREST,
  17917. flipY: !1
  17918. })
  17919. }
  17920. ,
  17921. Cl.prototype.setColorCorrection = function (e, t) {
  17922. this._compositeNode.setParameter(e, t)
  17923. }
  17924. ,
  17925. Cl.prototype.isSSREnabled = function () {
  17926. return this._enableSSR
  17927. }
  17928. ,
  17929. Cl.prototype.composite = function (e, t, r, i, n) {
  17930. var a = this._sourceTexture
  17931. , o = a;
  17932. this._enableEdge && (this._edgePass.update(e, r, a, n),
  17933. a = o = this._edgePass.getTargetTexture()),
  17934. this._enableSSR && (this._ssrPass.update(e, r, a, n),
  17935. o = this._ssrPass.getTargetTexture(),
  17936. this._ssrPass.setSSAOTexture(this._enableSSAO ? this._ssaoPass.getTargetTexture() : null)),
  17937. this._sourceNode.texture = o,
  17938. this._cocNode.setParameter("depth", this._depthTexture);
  17939. for (var s = this._dofBlurKernel, l = this._dofBlurKernelSize, h = n % Math.floor(vl.length / 2 / l), u = 0; u < 2 * l; u++)
  17940. s[u] = vl[u + h * l * 2];
  17941. for (u = 0; u < this._dofBlurNodes.length; u++)
  17942. this._dofBlurNodes[u].setParameter("percent", n / 30),
  17943. this._dofBlurNodes[u].setParameter("poissonKernel", s);
  17944. this._cocNode.setParameter("zNear", r.near),
  17945. this._cocNode.setParameter("zFar", r.far),
  17946. this._compositor.render(e, i)
  17947. }
  17948. ,
  17949. Cl.prototype.dispose = function (e) {
  17950. this._sourceTexture.dispose(e),
  17951. this._depthTexture.dispose(e),
  17952. this._framebuffer.dispose(e),
  17953. this._compositor.dispose(e),
  17954. this._normalPass.dispose(e),
  17955. this._ssaoPass.dispose(e)
  17956. }
  17957. ;
  17958. const Dl = Cl;
  17959. function Ll(e) {
  17960. for (var t = [], r = 0; r < 30; r++)
  17961. t.push([ul(r, 2), ul(r, 3)]);
  17962. this._haltonSequence = t,
  17963. this._frame = 0,
  17964. this._sourceTex = new Dr,
  17965. this._sourceFb = new zi,
  17966. this._sourceFb.attach(this._sourceTex),
  17967. this._prevFrameTex = new Dr,
  17968. this._outputTex = new Dr;
  17969. var i = this._blendPass = new pn({
  17970. fragment: Xe.source("clay.compositor.blend")
  17971. });
  17972. i.material.disableTexturesAll(),
  17973. i.material.enableTexture(["texture1", "texture2"]),
  17974. this._blendFb = new zi({
  17975. depthBuffer: !1
  17976. }),
  17977. this._outputPass = new pn({
  17978. fragment: Xe.source("clay.compositor.output"),
  17979. blendWithPrevious: !0
  17980. }),
  17981. this._outputPass.material.define("fragment", "OUTPUT_ALPHA"),
  17982. this._outputPass.material.blend = function (e) {
  17983. e.blendEquationSeparate(e.FUNC_ADD, e.FUNC_ADD),
  17984. e.blendFuncSeparate(e.ONE, e.ONE_MINUS_SRC_ALPHA, e.ONE, e.ONE_MINUS_SRC_ALPHA)
  17985. }
  17986. }
  17987. Ll.prototype = {
  17988. constructor: Ll,
  17989. jitterProjection: function (e, t) {
  17990. var r = e.viewport
  17991. , i = r.devicePixelRatio || e.getDevicePixelRatio()
  17992. , n = r.width * i
  17993. , a = r.height * i
  17994. , o = this._haltonSequence[this._frame % this._haltonSequence.length]
  17995. , s = new Ht;
  17996. s.array[12] = (2 * o[0] - 1) / n,
  17997. s.array[13] = (2 * o[1] - 1) / a,
  17998. Ht.mul(t.projectionMatrix, s, t.projectionMatrix),
  17999. Ht.invert(t.invProjectionMatrix, t.projectionMatrix)
  18000. },
  18001. resetFrame: function () {
  18002. this._frame = 0
  18003. },
  18004. getFrame: function () {
  18005. return this._frame
  18006. },
  18007. getSourceFrameBuffer: function () {
  18008. return this._sourceFb
  18009. },
  18010. getOutputTexture: function () {
  18011. return this._outputTex
  18012. },
  18013. resize: function (e, t) {
  18014. this._prevFrameTex.width = e,
  18015. this._prevFrameTex.height = t,
  18016. this._outputTex.width = e,
  18017. this._outputTex.height = t,
  18018. this._sourceTex.width = e,
  18019. this._sourceTex.height = t,
  18020. this._prevFrameTex.dirty(),
  18021. this._outputTex.dirty(),
  18022. this._sourceTex.dirty()
  18023. },
  18024. isFinished: function () {
  18025. return this._frame >= this._haltonSequence.length
  18026. },
  18027. render: function (e, t, r) {
  18028. var i = this._blendPass;
  18029. 0 === this._frame ? (i.setUniform("weight1", 0),
  18030. i.setUniform("weight2", 1)) : (i.setUniform("weight1", .9),
  18031. i.setUniform("weight2", .1)),
  18032. i.setUniform("texture1", this._prevFrameTex),
  18033. i.setUniform("texture2", t || this._sourceTex),
  18034. this._blendFb.attach(this._outputTex),
  18035. this._blendFb.bind(e),
  18036. i.render(e),
  18037. this._blendFb.unbind(e),
  18038. r || (this._outputPass.setUniform("texture", this._outputTex),
  18039. this._outputPass.render(e));
  18040. var n = this._prevFrameTex;
  18041. this._prevFrameTex = this._outputTex,
  18042. this._outputTex = n,
  18043. this._frame++
  18044. },
  18045. dispose: function (e) {
  18046. this._sourceFb.dispose(e),
  18047. this._blendFb.dispose(e),
  18048. this._prevFrameTex.dispose(e),
  18049. this._outputTex.dispose(e),
  18050. this._sourceTex.dispose(e),
  18051. this._outputPass.dispose(e),
  18052. this._blendPass.dispose(e)
  18053. }
  18054. };
  18055. const Pl = Ll;
  18056. function Ol(e) {
  18057. e = e || "perspective",
  18058. this.layer = null,
  18059. this.scene = new vi,
  18060. this.rootNode = this.scene,
  18061. this.viewport = {
  18062. x: 0,
  18063. y: 0,
  18064. width: 0,
  18065. height: 0
  18066. },
  18067. this.setProjection(e),
  18068. this._compositor = new Dl,
  18069. this._temporalSS = new Pl,
  18070. this._shadowMapPass = new ks;
  18071. for (var t = [], r = 0, i = 0; i < 30; i++) {
  18072. for (var n = [], a = 0; a < 6; a++)
  18073. n.push(4 * ul(r, 2) - 2),
  18074. n.push(4 * ul(r, 3) - 2),
  18075. r++;
  18076. t.push(n)
  18077. }
  18078. this._pcfKernels = t,
  18079. this.scene.on("beforerender", (function (e, t, r) {
  18080. this.needsTemporalSS() && this._temporalSS.jitterProjection(e, r)
  18081. }
  18082. ), this)
  18083. }
  18084. Ol.prototype.setProjection = function (e) {
  18085. var t = this.camera;
  18086. t && t.update(),
  18087. "perspective" === e ? this.camera instanceof Ei || (this.camera = new Ei,
  18088. t && this.camera.setLocalTransform(t.localTransform)) : this.camera instanceof un || (this.camera = new un,
  18089. t && this.camera.setLocalTransform(t.localTransform)),
  18090. this.camera.near = .1,
  18091. this.camera.far = 2e3
  18092. }
  18093. ,
  18094. Ol.prototype.setViewport = function (e, t, r, i, n) {
  18095. this.camera instanceof Ei && (this.camera.aspect = r / i),
  18096. n = n || 1,
  18097. this.viewport.x = e,
  18098. this.viewport.y = t,
  18099. this.viewport.width = r,
  18100. this.viewport.height = i,
  18101. this.viewport.devicePixelRatio = n,
  18102. this._compositor.resize(r * n, i * n),
  18103. this._temporalSS.resize(r * n, i * n)
  18104. }
  18105. ,
  18106. Ol.prototype.containPoint = function (e, t) {
  18107. var r = this.viewport;
  18108. return t = this.layer.renderer.getHeight() - t,
  18109. e >= r.x && t >= r.y && e <= r.x + r.width && t <= r.y + r.height
  18110. }
  18111. ;
  18112. var Nl = new _e;
  18113. Ol.prototype.castRay = function (e, t, r) {
  18114. var i = this.layer.renderer
  18115. , n = i.viewport;
  18116. return i.viewport = this.viewport,
  18117. i.screenToNDC(e, t, Nl),
  18118. this.camera.castRay(Nl, r),
  18119. i.viewport = n,
  18120. r
  18121. }
  18122. ,
  18123. Ol.prototype.prepareRender = function () {
  18124. this.scene.update(),
  18125. this.camera.update(),
  18126. this.scene.updateLights();
  18127. var e = this.scene.updateRenderList(this.camera);
  18128. this._needsSortProgressively = !1;
  18129. for (var t = 0; t < e.transparent.length; t++) {
  18130. var r = e.transparent[t].geometry;
  18131. r.needsSortVerticesProgressively && r.needsSortVerticesProgressively() && (this._needsSortProgressively = !0),
  18132. r.needsSortTrianglesProgressively && r.needsSortTrianglesProgressively() && (this._needsSortProgressively = !0)
  18133. }
  18134. this._frame = 0,
  18135. this._temporalSS.resetFrame()
  18136. }
  18137. ,
  18138. Ol.prototype.render = function (e, t) {
  18139. this._doRender(e, t, this._frame),
  18140. this._frame++
  18141. }
  18142. ,
  18143. Ol.prototype.needsAccumulate = function () {
  18144. return this.needsTemporalSS() || this._needsSortProgressively
  18145. }
  18146. ,
  18147. Ol.prototype.needsTemporalSS = function () {
  18148. var e = this._enableTemporalSS;
  18149. return "auto" === e && (e = this._enablePostEffect),
  18150. e
  18151. }
  18152. ,
  18153. Ol.prototype.hasDOF = function () {
  18154. return this._enableDOF
  18155. }
  18156. ,
  18157. Ol.prototype.isAccumulateFinished = function () {
  18158. return this.needsTemporalSS() ? this._temporalSS.isFinished() : this._frame > 30
  18159. }
  18160. ,
  18161. Ol.prototype._doRender = function (e, t, r) {
  18162. var i = this.scene
  18163. , n = this.camera;
  18164. r = r || 0,
  18165. this._updateTransparent(e, i, n, r),
  18166. t || (this._shadowMapPass.kernelPCF = this._pcfKernels[0],
  18167. this._shadowMapPass.render(e, i, n, !0)),
  18168. this._updateShadowPCFKernel(r);
  18169. var a, o = e.clearColor;
  18170. e.gl.clearColor(o[0], o[1], o[2], o[3]),
  18171. this._enablePostEffect && (this.needsTemporalSS() && this._temporalSS.jitterProjection(e, n),
  18172. this._compositor.updateNormal(e, i, n, this._temporalSS.getFrame())),
  18173. this._updateSSAO(e, i, n, this._temporalSS.getFrame()),
  18174. this._enablePostEffect ? ((a = this._compositor.getSourceFrameBuffer()).bind(e),
  18175. e.gl.clear(e.gl.DEPTH_BUFFER_BIT | e.gl.COLOR_BUFFER_BIT),
  18176. e.render(i, n, !0, !0),
  18177. a.unbind(e),
  18178. this.needsTemporalSS() && t ? (this._compositor.composite(e, i, n, this._temporalSS.getSourceFrameBuffer(), this._temporalSS.getFrame()),
  18179. e.setViewport(this.viewport),
  18180. this._temporalSS.render(e)) : (e.setViewport(this.viewport),
  18181. this._compositor.composite(e, i, n, null, 0))) : this.needsTemporalSS() && t ? ((a = this._temporalSS.getSourceFrameBuffer()).bind(e),
  18182. e.saveClear(),
  18183. e.clearBit = e.gl.DEPTH_BUFFER_BIT | e.gl.COLOR_BUFFER_BIT,
  18184. e.render(i, n, !0, !0),
  18185. e.restoreClear(),
  18186. a.unbind(e),
  18187. e.setViewport(this.viewport),
  18188. this._temporalSS.render(e)) : (e.setViewport(this.viewport),
  18189. e.render(i, n, !0, !0))
  18190. }
  18191. ,
  18192. Ol.prototype._updateTransparent = function (e, t, r, i) {
  18193. for (var n = new vt, a = new Ht, o = r.getWorldPosition(), s = t.getRenderList(r).transparent, l = 0; l < s.length; l++) {
  18194. var h = s[l]
  18195. , u = h.geometry;
  18196. Ht.invert(a, h.worldTransform),
  18197. vt.transformMat4(n, o, a),
  18198. u.needsSortTriangles && u.needsSortTriangles() && u.doSortTriangles(n, i),
  18199. u.needsSortVertices && u.needsSortVertices() && u.doSortVertices(n, i)
  18200. }
  18201. }
  18202. ,
  18203. Ol.prototype._updateSSAO = function (e, t, r) {
  18204. var i = this._enableSSAO && this._enablePostEffect;
  18205. i && this._compositor.updateSSAO(e, t, r, this._temporalSS.getFrame());
  18206. for (var n = t.getRenderList(r), a = 0; a < n.opaque.length; a++) {
  18207. var o = n.opaque[a];
  18208. o.renderNormal && o.material[i ? "enableTexture" : "disableTexture"]("ssaoMap"),
  18209. i && o.material.set("ssaoMap", this._compositor.getSSAOTexture())
  18210. }
  18211. }
  18212. ,
  18213. Ol.prototype._updateShadowPCFKernel = function (e) {
  18214. for (var t = this._pcfKernels[e % this._pcfKernels.length], r = this.scene.getRenderList(this.camera).opaque, i = 0; i < r.length; i++)
  18215. r[i].receiveShadow && (r[i].material.set("pcfKernel", t),
  18216. r[i].material.define("fragment", "PCF_KERNEL_SIZE", t.length / 2))
  18217. }
  18218. ,
  18219. Ol.prototype.dispose = function (e) {
  18220. this._compositor.dispose(e.gl),
  18221. this._temporalSS.dispose(e.gl),
  18222. this._shadowMapPass.dispose(e)
  18223. }
  18224. ,
  18225. Ol.prototype.setPostEffect = function (e, t) {
  18226. var r = this._compositor;
  18227. this._enablePostEffect = e.get("enable");
  18228. var i = e.getModel("bloom")
  18229. , n = e.getModel("edge")
  18230. , a = e.getModel("DOF", e.getModel("depthOfField"))
  18231. , o = e.getModel("SSAO", e.getModel("screenSpaceAmbientOcclusion"))
  18232. , s = e.getModel("SSR", e.getModel("screenSpaceReflection"))
  18233. , l = e.getModel("FXAA")
  18234. , h = e.getModel("colorCorrection");
  18235. i.get("enable") ? r.enableBloom() : r.disableBloom(),
  18236. a.get("enable") ? r.enableDOF() : r.disableDOF(),
  18237. s.get("enable") ? r.enableSSR() : r.disableSSR(),
  18238. h.get("enable") ? r.enableColorCorrection() : r.disableColorCorrection(),
  18239. n.get("enable") ? r.enableEdge() : r.disableEdge(),
  18240. l.get("enable") ? r.enableFXAA() : r.disableFXAA(),
  18241. this._enableDOF = a.get("enable"),
  18242. this._enableSSAO = o.get("enable"),
  18243. this._enableSSAO ? r.enableSSAO() : r.disableSSAO(),
  18244. r.setBloomIntensity(i.get("intensity")),
  18245. r.setEdgeColor(n.get("color")),
  18246. r.setColorLookupTexture(h.get("lookupTexture"), t),
  18247. r.setExposure(h.get("exposure")),
  18248. ["radius", "quality", "intensity"].forEach((function (e) {
  18249. r.setSSAOParameter(e, o.get(e))
  18250. }
  18251. )),
  18252. ["quality", "maxRoughness", "physical"].forEach((function (e) {
  18253. r.setSSRParameter(e, s.get(e))
  18254. }
  18255. )),
  18256. ["quality", "focalDistance", "focalRange", "blurRadius", "fstop"].forEach((function (e) {
  18257. r.setDOFParameter(e, a.get(e))
  18258. }
  18259. )),
  18260. ["brightness", "contrast", "saturation"].forEach((function (e) {
  18261. r.setColorCorrection(e, h.get(e))
  18262. }
  18263. ))
  18264. }
  18265. ,
  18266. Ol.prototype.setDOFFocusOnPoint = function (e) {
  18267. if (this._enablePostEffect) {
  18268. if (e > this.camera.far || e < this.camera.near)
  18269. return;
  18270. return this._compositor.setDOFParameter("focalDistance", e),
  18271. !0
  18272. }
  18273. }
  18274. ,
  18275. Ol.prototype.setTemporalSuperSampling = function (e) {
  18276. this._enableTemporalSS = e.get("enable")
  18277. }
  18278. ,
  18279. Ol.prototype.isLinearSpace = function () {
  18280. return this._enablePostEffect
  18281. }
  18282. ,
  18283. Ol.prototype.setRootNode = function (e) {
  18284. if (this.rootNode !== e) {
  18285. for (var t = this.rootNode.children(), r = 0; r < t.length; r++)
  18286. e.add(t[r]);
  18287. e !== this.scene && this.scene.add(e),
  18288. this.rootNode = e
  18289. }
  18290. }
  18291. ,
  18292. Ol.prototype.add = function (e) {
  18293. this.rootNode.add(e)
  18294. }
  18295. ,
  18296. Ol.prototype.remove = function (e) {
  18297. this.rootNode.remove(e)
  18298. }
  18299. ,
  18300. Ol.prototype.removeAll = function (e) {
  18301. this.rootNode.removeAll(e)
  18302. }
  18303. ,
  18304. Object.assign(Ol.prototype, h);
  18305. const Il = Ol;
  18306. function Rl(e, t) {
  18307. var r = Ss(e.getBoxLayoutParams(), {
  18308. width: t.getWidth(),
  18309. height: t.getHeight()
  18310. });
  18311. r.y = t.getHeight() - r.y - r.height,
  18312. this.viewGL.setViewport(r.x, r.y, r.width, r.height, t.getDevicePixelRatio());
  18313. var i = e.get("boxWidth")
  18314. , n = e.get("boxHeight")
  18315. , a = e.get("boxDepth");
  18316. this.getAxis("x").setExtent(-i / 2, i / 2),
  18317. this.getAxis("y").setExtent(a / 2, -a / 2),
  18318. this.getAxis("z").setExtent(-n / 2, n / 2),
  18319. this.size = [i, n, a]
  18320. }
  18321. function Bl(e, t) {
  18322. var r = {};
  18323. e.eachSeries((function (e) {
  18324. if (e.coordinateSystem === this) {
  18325. var t = e.getData();
  18326. ["x", "y", "z"].forEach((function (e) {
  18327. t.mapDimensionsAll(e, !0).forEach((function (i) {
  18328. var n, a;
  18329. n = e,
  18330. a = t.getDataExtent(i, !0),
  18331. r[n] = r[n] || [1 / 0, -1 / 0],
  18332. r[n][0] = Math.min(a[0], r[n][0]),
  18333. r[n][1] = Math.max(a[1], r[n][1])
  18334. }
  18335. ))
  18336. }
  18337. ))
  18338. }
  18339. }
  18340. ), this),
  18341. ["xAxis3D", "yAxis3D", "zAxis3D"].forEach((function (t) {
  18342. e.eachComponent(t, (function (e) {
  18343. var n = t.charAt(0)
  18344. , a = e.getReferringComponents("grid3D").models[0]
  18345. , o = a.coordinateSystem;
  18346. if (o === this) {
  18347. var s = o.getAxis(n);
  18348. if (!s) {
  18349. var l = i.helper.createScale(r[n] || [1 / 0, -1 / 0], e);
  18350. (s = new cs(n, l)).type = e.get("type");
  18351. var h = "category" === s.type;
  18352. s.onBand = h && e.get("boundaryGap"),
  18353. s.inverse = e.get("inverse"),
  18354. e.axis = s,
  18355. s.model = e,
  18356. s.getLabelModel = function () {
  18357. return e.getModel("axisLabel", a.getModel("axisLabel"))
  18358. }
  18359. ,
  18360. s.getTickModel = function () {
  18361. return e.getModel("axisTick", a.getModel("axisTick"))
  18362. }
  18363. ,
  18364. o.addAxis(s)
  18365. }
  18366. }
  18367. }
  18368. ), this)
  18369. }
  18370. ), this),
  18371. this.resize(this.model, t)
  18372. }
  18373. const Fl = {
  18374. dimensions: hs.prototype.dimensions,
  18375. create: function (e, t) {
  18376. var r = [];
  18377. e.eachComponent("grid3D", (function (e) {
  18378. e.__viewGL = e.__viewGL || new Il;
  18379. var t = new hs;
  18380. t.model = e,
  18381. t.viewGL = e.__viewGL,
  18382. e.coordinateSystem = t,
  18383. r.push(t),
  18384. t.resize = Rl,
  18385. t.update = Bl
  18386. }
  18387. ));
  18388. var i = ["xAxis3D", "yAxis3D", "zAxis3D"];
  18389. return e.eachSeries((function (t) {
  18390. if ("cartesian3D" === t.get("coordinateSystem")) {
  18391. if (null == (n = t.getReferringComponents("grid3D").models[0])) {
  18392. var r = function (e, t) {
  18393. return i.map((function (r) {
  18394. var i = e.getReferringComponents(r).models[0];
  18395. return null == i && (i = t.getComponent(r)),
  18396. i
  18397. }
  18398. ))
  18399. }(t, e)
  18400. , n = r[0].getCoordSysModel();
  18401. r.forEach((function (e) {
  18402. e.getCoordSysModel()
  18403. }
  18404. ))
  18405. }
  18406. var a = n.coordinateSystem;
  18407. t.coordinateSystem = a
  18408. }
  18409. }
  18410. )),
  18411. r
  18412. }
  18413. };
  18414. var zl = i.ComponentModel.extend({
  18415. type: "cartesian3DAxis",
  18416. axis: null,
  18417. getCoordSysModel: function () {
  18418. return this.ecModel.queryComponents({
  18419. mainType: "grid3D",
  18420. index: this.option.gridIndex,
  18421. id: this.option.gridId
  18422. })[0]
  18423. }
  18424. });
  18425. i.helper.mixinAxisModelCommonMethods(zl);
  18426. const Gl = zl;
  18427. var Ul = {
  18428. show: !0,
  18429. grid3DIndex: 0,
  18430. inverse: !1,
  18431. name: "",
  18432. nameLocation: "middle",
  18433. nameTextStyle: {
  18434. fontSize: 16
  18435. },
  18436. nameGap: 20,
  18437. axisPointer: {},
  18438. axisLine: {},
  18439. axisTick: {},
  18440. axisLabel: {},
  18441. splitArea: {}
  18442. }
  18443. , kl = i.util.merge({
  18444. boundaryGap: !0,
  18445. axisTick: {
  18446. alignWithLabel: !1,
  18447. interval: "auto"
  18448. },
  18449. axisLabel: {
  18450. interval: "auto"
  18451. },
  18452. axisPointer: {
  18453. label: {
  18454. show: !1
  18455. }
  18456. }
  18457. }, Ul)
  18458. , Vl = i.util.merge({
  18459. boundaryGap: [0, 0],
  18460. splitNumber: 5,
  18461. axisPointer: {
  18462. label: {}
  18463. }
  18464. }, Ul)
  18465. , Hl = i.util.defaults({
  18466. scale: !0,
  18467. min: "dataMin",
  18468. max: "dataMax"
  18469. }, Vl)
  18470. , Wl = i.util.defaults({
  18471. logBase: 10
  18472. }, Vl);
  18473. Wl.scale = !0;
  18474. const jl = {
  18475. categoryAxis3D: kl,
  18476. valueAxis3D: Vl,
  18477. timeAxis3D: Hl,
  18478. logAxis3D: Wl
  18479. };
  18480. function Xl(e) {
  18481. return ("function" === (r = typeof (t = e)) || t && "object" === r) && null != e.value ? e.value : e + "";
  18482. var t, r
  18483. }
  18484. const ql = function () {
  18485. function e(e) {
  18486. this.categories = e.categories || [],
  18487. this._needCollect = e.needCollect,
  18488. this._deduplication = e.deduplication
  18489. }
  18490. return e.createByAxisModel = function (t) {
  18491. var r = t.option
  18492. , i = r.data
  18493. , n = i && xa(i, Xl);
  18494. return new e({
  18495. categories: n,
  18496. needCollect: !n,
  18497. deduplication: !1 !== r.dedplication
  18498. })
  18499. }
  18500. ,
  18501. e.prototype.getOrdinal = function (e) {
  18502. return this._getOrCreateMap().get(e)
  18503. }
  18504. ,
  18505. e.prototype.parseAndCollect = function (e) {
  18506. var t, r = this._needCollect;
  18507. if ("string" != typeof e && !r)
  18508. return e;
  18509. if (r && !this._deduplication)
  18510. return t = this.categories.length,
  18511. this.categories[t] = e,
  18512. t;
  18513. var i = this._getOrCreateMap();
  18514. return null == (t = i.get(e)) && (r ? (t = this.categories.length,
  18515. this.categories[t] = e,
  18516. i.set(e, t)) : t = NaN),
  18517. t
  18518. }
  18519. ,
  18520. e.prototype._getOrCreateMap = function () {
  18521. return this._map || (this._map = (e = this.categories,
  18522. new Ma(e)));
  18523. var e
  18524. }
  18525. ,
  18526. e
  18527. }();
  18528. var Zl = ["value", "category", "time", "log"];
  18529. function Yl(e, t) {
  18530. return t.type || (t.data ? "category" : "value")
  18531. }
  18532. (0,
  18533. i.use)((function (e) {
  18534. e.registerComponentModel(mo),
  18535. e.registerComponentView(os),
  18536. e.registerCoordinateSystem("grid3D", Fl),
  18537. ["x", "y", "z"].forEach((function (t) {
  18538. !function (e, t, r, n, a) {
  18539. Zl.forEach((function (o) {
  18540. var s = r.extend({
  18541. type: t + "Axis3D." + o,
  18542. __ordinalMeta: null,
  18543. mergeDefaultAndTheme: function (e, r) {
  18544. var a = r.getTheme();
  18545. i.util.merge(e, a.get(o + "Axis3D")),
  18546. i.util.merge(e, this.getDefaultOption()),
  18547. e.type = n(t, e)
  18548. },
  18549. optionUpdated: function () {
  18550. "category" === this.option.type && (this.__ordinalMeta = ql.createByAxisModel(this))
  18551. },
  18552. getCategories: function () {
  18553. if ("category" === this.option.type)
  18554. return this.__ordinalMeta.categories
  18555. },
  18556. getOrdinalMeta: function () {
  18557. return this.__ordinalMeta
  18558. },
  18559. defaultOption: i.util.merge(i.util.clone(jl[o + "Axis3D"]), a || {}, !0)
  18560. });
  18561. e.registerComponentModel(s)
  18562. }
  18563. )),
  18564. e.registerSubTypeDefaulter(t + "Axis3D", i.util.curry(n, t))
  18565. }(e, t, Gl, Yl, {
  18566. name: t.toUpperCase()
  18567. });
  18568. const r = e.ComponentView.extend({
  18569. type: t + "Axis3D"
  18570. });
  18571. e.registerComponentView(r)
  18572. }
  18573. )),
  18574. e.registerAction({
  18575. type: "grid3DChangeCamera",
  18576. event: "grid3dcamerachanged",
  18577. update: "series:updateCamera"
  18578. }, (function (e, t) {
  18579. t.eachComponent({
  18580. mainType: "grid3D",
  18581. query: e
  18582. }, (function (t) {
  18583. t.setView(e)
  18584. }
  18585. ))
  18586. }
  18587. )),
  18588. e.registerAction({
  18589. type: "grid3DShowAxisPointer",
  18590. event: "grid3dshowaxispointer",
  18591. update: "grid3D:showAxisPointer"
  18592. }, (function (e, t) { }
  18593. )),
  18594. e.registerAction({
  18595. type: "grid3DHideAxisPointer",
  18596. event: "grid3dhideaxispointer",
  18597. update: "grid3D:hideAxisPointer"
  18598. }, (function (e, t) { }
  18599. ))
  18600. }
  18601. ));
  18602. const Kl = {
  18603. defaultOption: {
  18604. shading: null,
  18605. realisticMaterial: {
  18606. textureTiling: 1,
  18607. textureOffset: 0,
  18608. detailTexture: null
  18609. },
  18610. lambertMaterial: {
  18611. textureTiling: 1,
  18612. textureOffset: 0,
  18613. detailTexture: null
  18614. },
  18615. colorMaterial: {
  18616. textureTiling: 1,
  18617. textureOffset: 0,
  18618. detailTexture: null
  18619. },
  18620. hatchingMaterial: {
  18621. textureTiling: 1,
  18622. textureOffset: 0,
  18623. paperColor: "#fff"
  18624. }
  18625. }
  18626. }
  18627. , Ql = {
  18628. getFilledRegions: function (e, t) {
  18629. var r, n = (e || []).slice();
  18630. if ("string" == typeof t ? r = (t = i.getMap(t)) && t.geoJson : t && t.features && (r = t),
  18631. !r)
  18632. return [];
  18633. for (var a = {}, o = r.features, s = 0; s < n.length; s++)
  18634. a[n[s].name] = n[s];
  18635. for (s = 0; s < o.length; s++) {
  18636. var l = o[s].properties.name;
  18637. a[l] || n.push({
  18638. name: l
  18639. })
  18640. }
  18641. return n
  18642. },
  18643. defaultOption: {
  18644. show: !0,
  18645. zlevel: -10,
  18646. map: "",
  18647. left: 0,
  18648. top: 0,
  18649. width: "100%",
  18650. height: "100%",
  18651. boxWidth: 100,
  18652. boxHeight: 10,
  18653. boxDepth: "auto",
  18654. regionHeight: 3,
  18655. environment: "auto",
  18656. groundPlane: {
  18657. show: !1,
  18658. color: "#aaa"
  18659. },
  18660. shading: "lambert",
  18661. light: {
  18662. main: {
  18663. alpha: 40,
  18664. beta: 30
  18665. }
  18666. },
  18667. viewControl: {
  18668. alpha: 40,
  18669. beta: 0,
  18670. distance: 100,
  18671. orthographicSize: 60,
  18672. minAlpha: 5,
  18673. minBeta: -80,
  18674. maxBeta: 80
  18675. },
  18676. label: {
  18677. show: !1,
  18678. distance: 2,
  18679. textStyle: {
  18680. fontSize: 20,
  18681. color: "#000",
  18682. backgroundColor: "rgba(255,255,255,0.7)",
  18683. padding: 3,
  18684. borderRadius: 4
  18685. }
  18686. },
  18687. itemStyle: {
  18688. color: "#fff",
  18689. borderWidth: 0,
  18690. borderColor: "#333"
  18691. },
  18692. emphasis: {
  18693. itemStyle: {
  18694. color: "#639fc0"
  18695. },
  18696. label: {
  18697. show: !0
  18698. }
  18699. }
  18700. }
  18701. };
  18702. var Jl = i.ComponentModel.extend({
  18703. type: "geo3D",
  18704. layoutMode: "box",
  18705. coordinateSystem: null,
  18706. optionUpdated: function () {
  18707. var e = this.option;
  18708. e.regions = this.getFilledRegions(e.regions, e.map);
  18709. var t = i.helper.createDimensions(e.data || [], {
  18710. coordDimensions: ["value"],
  18711. encodeDefine: this.get("encode"),
  18712. dimensionsDefine: this.get("dimensions")
  18713. })
  18714. , r = new i.List(t, this);
  18715. r.initData(e.regions);
  18716. var n = {};
  18717. r.each((function (e) {
  18718. var t = r.getName(e)
  18719. , i = r.getItemModel(e);
  18720. n[t] = i
  18721. }
  18722. )),
  18723. this._regionModelMap = n,
  18724. this._data = r
  18725. },
  18726. getData: function () {
  18727. return this._data
  18728. },
  18729. getRegionModel: function (e) {
  18730. var t = this.getData().getName(e);
  18731. return this._regionModelMap[t] || new i.Model(null, this)
  18732. },
  18733. getRegionPolygonCoords: function (e) {
  18734. var t = this.getData().getName(e)
  18735. , r = this.coordinateSystem.getRegion(t);
  18736. return r ? r.geometries : []
  18737. },
  18738. getFormattedLabel: function (e, t) {
  18739. var r = this._data.getName(e)
  18740. , i = this.getRegionModel(e)
  18741. , n = i.get("normal" === t ? ["label", "formatter"] : ["emphasis", "label", "formatter"]);
  18742. null == n && (n = i.get(["label", "formatter"]));
  18743. var a = {
  18744. name: r
  18745. };
  18746. if ("function" == typeof n)
  18747. return a.status = t,
  18748. n(a);
  18749. if ("string" == typeof n) {
  18750. var o = a.seriesName;
  18751. return n.replace("{a}", null != o ? o : "")
  18752. }
  18753. return r
  18754. },
  18755. defaultOption: {
  18756. regions: []
  18757. }
  18758. });
  18759. i.util.merge(Jl.prototype, Ql),
  18760. i.util.merge(Jl.prototype, uo),
  18761. i.util.merge(Jl.prototype, co),
  18762. i.util.merge(Jl.prototype, fo),
  18763. i.util.merge(Jl.prototype, Kl);
  18764. const $l = Jl
  18765. , eh = th;
  18766. function th(e, t, r) {
  18767. r = r || 2;
  18768. var i, n, a, o, s, l, h, u = t && t.length, c = u ? t[0] * r : e.length, d = rh(e, 0, c, r, !0), f = [];
  18769. if (!d)
  18770. return f;
  18771. if (u && (d = function (e, t, r, i) {
  18772. var n, a, o, s = [];
  18773. for (n = 0,
  18774. a = t.length; n < a; n++)
  18775. (o = rh(e, t[n] * i, n < a - 1 ? t[n + 1] * i : e.length, i, !1)) === o.next && (o.steiner = !0),
  18776. s.push(dh(o));
  18777. for (s.sort(hh),
  18778. n = 0; n < s.length; n++)
  18779. uh(s[n], r),
  18780. r = ih(r, r.next);
  18781. return r
  18782. }(e, t, d, r)),
  18783. e.length > 80 * r) {
  18784. i = a = e[0],
  18785. n = o = e[1];
  18786. for (var p = r; p < c; p += r)
  18787. (s = e[p]) < i && (i = s),
  18788. (l = e[p + 1]) < n && (n = l),
  18789. s > a && (a = s),
  18790. l > o && (o = l);
  18791. h = Math.max(a - i, o - n)
  18792. }
  18793. return nh(d, f, r, i, n, h),
  18794. f
  18795. }
  18796. function rh(e, t, r, i, n) {
  18797. var a, o;
  18798. if (n === Th(e, t, r, i) > 0)
  18799. for (a = t; a < r; a += i)
  18800. o = xh(a, e[a], e[a + 1], o);
  18801. else
  18802. for (a = r - i; a >= t; a -= i)
  18803. o = xh(a, e[a], e[a + 1], o);
  18804. return o && gh(o, o.next) && (bh(o),
  18805. o = o.next),
  18806. o
  18807. }
  18808. function ih(e, t) {
  18809. if (!e)
  18810. return e;
  18811. t || (t = e);
  18812. var r, i = e;
  18813. do {
  18814. if (r = !1,
  18815. i.steiner || !gh(i, i.next) && 0 !== mh(i.prev, i, i.next))
  18816. i = i.next;
  18817. else {
  18818. if (bh(i),
  18819. (i = t = i.prev) === i.next)
  18820. return null;
  18821. r = !0
  18822. }
  18823. } while (r || i !== t);
  18824. return t
  18825. }
  18826. function nh(e, t, r, i, n, a, o) {
  18827. if (e) {
  18828. !o && a && function (e, t, r, i) {
  18829. var n = e;
  18830. do {
  18831. null === n.z && (n.z = ch(n.x, n.y, t, r, i)),
  18832. n.prevZ = n.prev,
  18833. n.nextZ = n.next,
  18834. n = n.next
  18835. } while (n !== e);
  18836. n.prevZ.nextZ = null,
  18837. n.prevZ = null,
  18838. function (e) {
  18839. var t, r, i, n, a, o, s, l, h = 1;
  18840. do {
  18841. for (r = e,
  18842. e = null,
  18843. a = null,
  18844. o = 0; r;) {
  18845. for (o++,
  18846. i = r,
  18847. s = 0,
  18848. t = 0; t < h && (s++,
  18849. i = i.nextZ); t++)
  18850. ;
  18851. for (l = h; s > 0 || l > 0 && i;)
  18852. 0 !== s && (0 === l || !i || r.z <= i.z) ? (n = r,
  18853. r = r.nextZ,
  18854. s--) : (n = i,
  18855. i = i.nextZ,
  18856. l--),
  18857. a ? a.nextZ = n : e = n,
  18858. n.prevZ = a,
  18859. a = n;
  18860. r = i
  18861. }
  18862. a.nextZ = null,
  18863. h *= 2
  18864. } while (o > 1)
  18865. }(n)
  18866. }(e, i, n, a);
  18867. for (var s, l, h = e; e.prev !== e.next;)
  18868. if (s = e.prev,
  18869. l = e.next,
  18870. a ? oh(e, i, n, a) : ah(e))
  18871. t.push(s.i / r),
  18872. t.push(e.i / r),
  18873. t.push(l.i / r),
  18874. bh(e),
  18875. e = l.next,
  18876. h = l.next;
  18877. else if ((e = l) === h) {
  18878. o ? 1 === o ? nh(e = sh(e, t, r), t, r, i, n, a, 2) : 2 === o && lh(e, t, r, i, n, a) : nh(ih(e), t, r, i, n, a, 1);
  18879. break
  18880. }
  18881. }
  18882. }
  18883. function ah(e) {
  18884. var t = e.prev
  18885. , r = e
  18886. , i = e.next;
  18887. if (mh(t, r, i) >= 0)
  18888. return !1;
  18889. for (var n = e.next.next; n !== e.prev;) {
  18890. if (fh(t.x, t.y, r.x, r.y, i.x, i.y, n.x, n.y) && mh(n.prev, n, n.next) >= 0)
  18891. return !1;
  18892. n = n.next
  18893. }
  18894. return !0
  18895. }
  18896. function oh(e, t, r, i) {
  18897. var n = e.prev
  18898. , a = e
  18899. , o = e.next;
  18900. if (mh(n, a, o) >= 0)
  18901. return !1;
  18902. for (var s = n.x < a.x ? n.x < o.x ? n.x : o.x : a.x < o.x ? a.x : o.x, l = n.y < a.y ? n.y < o.y ? n.y : o.y : a.y < o.y ? a.y : o.y, h = n.x > a.x ? n.x > o.x ? n.x : o.x : a.x > o.x ? a.x : o.x, u = n.y > a.y ? n.y > o.y ? n.y : o.y : a.y > o.y ? a.y : o.y, c = ch(s, l, t, r, i), d = ch(h, u, t, r, i), f = e.nextZ; f && f.z <= d;) {
  18903. if (f !== e.prev && f !== e.next && fh(n.x, n.y, a.x, a.y, o.x, o.y, f.x, f.y) && mh(f.prev, f, f.next) >= 0)
  18904. return !1;
  18905. f = f.nextZ
  18906. }
  18907. for (f = e.prevZ; f && f.z >= c;) {
  18908. if (f !== e.prev && f !== e.next && fh(n.x, n.y, a.x, a.y, o.x, o.y, f.x, f.y) && mh(f.prev, f, f.next) >= 0)
  18909. return !1;
  18910. f = f.prevZ
  18911. }
  18912. return !0
  18913. }
  18914. function sh(e, t, r) {
  18915. var i = e;
  18916. do {
  18917. var n = i.prev
  18918. , a = i.next.next;
  18919. !gh(n, a) && _h(n, i, i.next, a) && vh(n, a) && vh(a, n) && (t.push(n.i / r),
  18920. t.push(i.i / r),
  18921. t.push(a.i / r),
  18922. bh(i),
  18923. bh(i.next),
  18924. i = e = a),
  18925. i = i.next
  18926. } while (i !== e);
  18927. return i
  18928. }
  18929. function lh(e, t, r, i, n, a) {
  18930. var o = e;
  18931. do {
  18932. for (var s = o.next.next; s !== o.prev;) {
  18933. if (o.i !== s.i && ph(o, s)) {
  18934. var l = yh(o, s);
  18935. return o = ih(o, o.next),
  18936. l = ih(l, l.next),
  18937. nh(o, t, r, i, n, a),
  18938. void nh(l, t, r, i, n, a)
  18939. }
  18940. s = s.next
  18941. }
  18942. o = o.next
  18943. } while (o !== e)
  18944. }
  18945. function hh(e, t) {
  18946. return e.x - t.x
  18947. }
  18948. function uh(e, t) {
  18949. if (t = function (e, t) {
  18950. var r, i = t, n = e.x, a = e.y, o = -1 / 0;
  18951. do {
  18952. if (a <= i.y && a >= i.next.y && i.next.y !== i.y) {
  18953. var s = i.x + (a - i.y) * (i.next.x - i.x) / (i.next.y - i.y);
  18954. if (s <= n && s > o) {
  18955. if (o = s,
  18956. s === n) {
  18957. if (a === i.y)
  18958. return i;
  18959. if (a === i.next.y)
  18960. return i.next
  18961. }
  18962. r = i.x < i.next.x ? i : i.next
  18963. }
  18964. }
  18965. i = i.next
  18966. } while (i !== t);
  18967. if (!r)
  18968. return null;
  18969. if (n === o)
  18970. return r.prev;
  18971. var l, h = r, u = r.x, c = r.y, d = 1 / 0;
  18972. for (i = r.next; i !== h;)
  18973. n >= i.x && i.x >= u && n !== i.x && fh(a < c ? n : o, a, u, c, a < c ? o : n, a, i.x, i.y) && ((l = Math.abs(a - i.y) / (n - i.x)) < d || l === d && i.x > r.x) && vh(i, e) && (r = i,
  18974. d = l),
  18975. i = i.next;
  18976. return r
  18977. }(e, t)) {
  18978. var r = yh(t, e);
  18979. ih(r, r.next)
  18980. }
  18981. }
  18982. function ch(e, t, r, i, n) {
  18983. return (e = 1431655765 & ((e = 858993459 & ((e = 252645135 & ((e = 16711935 & ((e = 32767 * (e - r) / n) | e << 8)) | e << 4)) | e << 2)) | e << 1)) | (t = 1431655765 & ((t = 858993459 & ((t = 252645135 & ((t = 16711935 & ((t = 32767 * (t - i) / n) | t << 8)) | t << 4)) | t << 2)) | t << 1)) << 1
  18984. }
  18985. function dh(e) {
  18986. var t = e
  18987. , r = e;
  18988. do {
  18989. t.x < r.x && (r = t),
  18990. t = t.next
  18991. } while (t !== e);
  18992. return r
  18993. }
  18994. function fh(e, t, r, i, n, a, o, s) {
  18995. return (n - o) * (t - s) - (e - o) * (a - s) >= 0 && (e - o) * (i - s) - (r - o) * (t - s) >= 0 && (r - o) * (a - s) - (n - o) * (i - s) >= 0
  18996. }
  18997. function ph(e, t) {
  18998. return e.next.i !== t.i && e.prev.i !== t.i && !function (e, t) {
  18999. var r = e;
  19000. do {
  19001. if (r.i !== e.i && r.next.i !== e.i && r.i !== t.i && r.next.i !== t.i && _h(r, r.next, e, t))
  19002. return !0;
  19003. r = r.next
  19004. } while (r !== e);
  19005. return !1
  19006. }(e, t) && vh(e, t) && vh(t, e) && function (e, t) {
  19007. var r = e
  19008. , i = !1
  19009. , n = (e.x + t.x) / 2
  19010. , a = (e.y + t.y) / 2;
  19011. do {
  19012. r.y > a != r.next.y > a && r.next.y !== r.y && n < (r.next.x - r.x) * (a - r.y) / (r.next.y - r.y) + r.x && (i = !i),
  19013. r = r.next
  19014. } while (r !== e);
  19015. return i
  19016. }(e, t)
  19017. }
  19018. function mh(e, t, r) {
  19019. return (t.y - e.y) * (r.x - t.x) - (t.x - e.x) * (r.y - t.y)
  19020. }
  19021. function gh(e, t) {
  19022. return e.x === t.x && e.y === t.y
  19023. }
  19024. function _h(e, t, r, i) {
  19025. return !!(gh(e, t) && gh(r, i) || gh(e, i) && gh(r, t)) || mh(e, t, r) > 0 != mh(e, t, i) > 0 && mh(r, i, e) > 0 != mh(r, i, t) > 0
  19026. }
  19027. function vh(e, t) {
  19028. return mh(e.prev, e, e.next) < 0 ? mh(e, t, e.next) >= 0 && mh(e, e.prev, t) >= 0 : mh(e, t, e.prev) < 0 || mh(e, e.next, t) < 0
  19029. }
  19030. function yh(e, t) {
  19031. var r = new wh(e.i, e.x, e.y)
  19032. , i = new wh(t.i, t.x, t.y)
  19033. , n = e.next
  19034. , a = t.prev;
  19035. return e.next = t,
  19036. t.prev = e,
  19037. r.next = n,
  19038. n.prev = r,
  19039. i.next = r,
  19040. r.prev = i,
  19041. a.next = i,
  19042. i.prev = a,
  19043. i
  19044. }
  19045. function xh(e, t, r, i) {
  19046. var n = new wh(e, t, r);
  19047. return i ? (n.next = i.next,
  19048. n.prev = i,
  19049. i.next.prev = n,
  19050. i.next = n) : (n.prev = n,
  19051. n.next = n),
  19052. n
  19053. }
  19054. function bh(e) {
  19055. e.next.prev = e.prev,
  19056. e.prev.next = e.next,
  19057. e.prevZ && (e.prevZ.nextZ = e.nextZ),
  19058. e.nextZ && (e.nextZ.prevZ = e.prevZ)
  19059. }
  19060. function wh(e, t, r) {
  19061. this.i = e,
  19062. this.x = t,
  19063. this.y = r,
  19064. this.prev = null,
  19065. this.next = null,
  19066. this.z = null,
  19067. this.prevZ = null,
  19068. this.nextZ = null,
  19069. this.steiner = !1
  19070. }
  19071. function Th(e, t, r, i) {
  19072. for (var n = 0, a = t, o = r - i; a < r; a += i)
  19073. n += (e[o] - e[a]) * (e[a + 1] + e[o + 1]),
  19074. o = a;
  19075. return n
  19076. }
  19077. function Sh(e, t, r) {
  19078. var i = e[t];
  19079. e[t] = e[r],
  19080. e[r] = i
  19081. }
  19082. function Mh(e, t, r, i, n) {
  19083. var a = r
  19084. , o = e[t];
  19085. Sh(e, t, i);
  19086. for (var s = r; s < i; s++)
  19087. n(e[s], o) < 0 && (Sh(e, s, a),
  19088. a++);
  19089. return Sh(e, i, a),
  19090. a
  19091. }
  19092. function Ah(e, t, r, i) {
  19093. if (r < i) {
  19094. var n = Mh(e, Math.floor((r + i) / 2), r, i, t);
  19095. Ah(e, t, r, n - 1),
  19096. Ah(e, t, n + 1, i)
  19097. }
  19098. }
  19099. function Eh() {
  19100. this._parts = []
  19101. }
  19102. th.deviation = function (e, t, r, i) {
  19103. var n = t && t.length
  19104. , a = n ? t[0] * r : e.length
  19105. , o = Math.abs(Th(e, 0, a, r));
  19106. if (n)
  19107. for (var s = 0, l = t.length; s < l; s++) {
  19108. var h = t[s] * r
  19109. , u = s < l - 1 ? t[s + 1] * r : e.length;
  19110. o -= Math.abs(Th(e, h, u, r))
  19111. }
  19112. var c = 0;
  19113. for (s = 0; s < i.length; s += 3) {
  19114. var d = i[s] * r
  19115. , f = i[s + 1] * r
  19116. , p = i[s + 2] * r;
  19117. c += Math.abs((e[d] - e[p]) * (e[f + 1] - e[d + 1]) - (e[d] - e[f]) * (e[p + 1] - e[d + 1]))
  19118. }
  19119. return 0 === o && 0 === c ? 0 : Math.abs((c - o) / o)
  19120. }
  19121. ,
  19122. Eh.prototype.step = function (e, t, r) {
  19123. var i = e.length;
  19124. if (0 === r) {
  19125. this._parts = [],
  19126. this._sorted = !1;
  19127. var n = Math.floor(i / 2);
  19128. this._parts.push({
  19129. pivot: n,
  19130. left: 0,
  19131. right: i - 1
  19132. }),
  19133. this._currentSortPartIdx = 0
  19134. }
  19135. if (!this._sorted) {
  19136. var a = this._parts;
  19137. if (0 === a.length)
  19138. return this._sorted = !0,
  19139. !0;
  19140. if (a.length < 512) {
  19141. for (var o = 0; o < a.length; o++)
  19142. a[o].pivot = Mh(e, a[o].pivot, a[o].left, a[o].right, t);
  19143. var s = [];
  19144. for (o = 0; o < a.length; o++) {
  19145. var l, h = a[o].left;
  19146. (l = a[o].pivot - 1) > h && s.push({
  19147. pivot: Math.floor((l + h) / 2),
  19148. left: h,
  19149. right: l
  19150. }),
  19151. h = a[o].pivot + 1,
  19152. (l = a[o].right) > h && s.push({
  19153. pivot: Math.floor((l + h) / 2),
  19154. left: h,
  19155. right: l
  19156. })
  19157. }
  19158. a = this._parts = s
  19159. } else
  19160. for (o = 0; o < Math.floor(a.length / 10); o++) {
  19161. var u = a.length - 1 - this._currentSortPartIdx;
  19162. if (Ah(e, t, a[u].left, a[u].right),
  19163. this._currentSortPartIdx++,
  19164. this._currentSortPartIdx === a.length)
  19165. return this._sorted = !0,
  19166. !0
  19167. }
  19168. return !1
  19169. }
  19170. }
  19171. ,
  19172. Eh.sort = Ah;
  19173. const Ch = Eh;
  19174. var Dh = Po.vec3
  19175. , Lh = Dh.create()
  19176. , Ph = Dh.create()
  19177. , Oh = Dh.create();
  19178. const Nh = {
  19179. needsSortTriangles: function () {
  19180. return this.indices && this.sortTriangles
  19181. },
  19182. needsSortTrianglesProgressively: function () {
  19183. return this.needsSortTriangles() && this.triangleCount >= 2e4
  19184. },
  19185. doSortTriangles: function (e, t) {
  19186. var r = this.indices;
  19187. if (0 === t) {
  19188. var i = this.attributes.position;
  19189. e = e.array,
  19190. this._triangleZList && this._triangleZList.length === this.triangleCount || (this._triangleZList = new Float32Array(this.triangleCount),
  19191. this._sortedTriangleIndices = new Uint32Array(this.triangleCount),
  19192. this._indicesTmp = new r.constructor(r.length),
  19193. this._triangleZListTmp = new Float32Array(this.triangleCount));
  19194. for (var n, a = 0, o = 0; o < r.length;) {
  19195. i.get(r[o++], Lh),
  19196. i.get(r[o++], Ph),
  19197. i.get(r[o++], Oh);
  19198. var s = Dh.sqrDist(Lh, e)
  19199. , l = Dh.sqrDist(Ph, e)
  19200. , h = Dh.sqrDist(Oh, e)
  19201. , u = Math.min(s, l);
  19202. u = Math.min(u, h),
  19203. 3 === o ? (n = u,
  19204. u = 0) : u -= n,
  19205. this._triangleZList[a++] = u
  19206. }
  19207. }
  19208. var c = this._sortedTriangleIndices;
  19209. for (o = 0; o < c.length; o++)
  19210. c[o] = o;
  19211. if (this.triangleCount < 2e4)
  19212. 0 === t && this._simpleSort(!0);
  19213. else
  19214. for (o = 0; o < 3; o++)
  19215. this._progressiveQuickSort(3 * t + o);
  19216. var d = this._indicesTmp
  19217. , f = this._triangleZListTmp
  19218. , p = this._triangleZList;
  19219. for (o = 0; o < this.triangleCount; o++) {
  19220. var m = 3 * c[o]
  19221. , g = 3 * o;
  19222. d[g++] = r[m++],
  19223. d[g++] = r[m++],
  19224. d[g] = r[m],
  19225. f[o] = p[c[o]]
  19226. }
  19227. var _ = this._indicesTmp;
  19228. this._indicesTmp = this.indices,
  19229. this.indices = _,
  19230. _ = this._triangleZListTmp,
  19231. this._triangleZListTmp = this._triangleZList,
  19232. this._triangleZList = _,
  19233. this.dirtyIndices()
  19234. },
  19235. _simpleSort: function (e) {
  19236. var t = this._triangleZList
  19237. , r = this._sortedTriangleIndices;
  19238. function i(e, r) {
  19239. return t[r] - t[e]
  19240. }
  19241. e ? Array.prototype.sort.call(r, i) : Ch.sort(r, i, 0, r.length - 1)
  19242. },
  19243. _progressiveQuickSort: function (e) {
  19244. var t = this._triangleZList
  19245. , r = this._sortedTriangleIndices;
  19246. this._quickSort = this._quickSort || new Ch,
  19247. this._quickSort.step(r, (function (e, r) {
  19248. return t[r] - t[e]
  19249. }
  19250. ), e)
  19251. }
  19252. };
  19253. function Ih(e, t) {
  19254. const r = e.getItemVisual(t, "style");
  19255. if (r)
  19256. return r[e.getVisual("drawType")]
  19257. }
  19258. function Rh(e, t) {
  19259. const r = e.getItemVisual(t, "style");
  19260. return r && r.opacity
  19261. }
  19262. function Bh(e, t, r) {
  19263. this._labelsMesh = new Qo,
  19264. this._labelTextureSurface = new zo({
  19265. width: 512,
  19266. height: 512,
  19267. devicePixelRatio: r.getDevicePixelRatio(),
  19268. onupdate: function () {
  19269. r.getZr().refresh()
  19270. }
  19271. }),
  19272. this._api = r,
  19273. this._labelsMesh.material.set("textureAtlas", this._labelTextureSurface.getTexture())
  19274. }
  19275. Bh.prototype.getLabelPosition = function (e, t, r) {
  19276. return [0, 0, 0]
  19277. }
  19278. ,
  19279. Bh.prototype.getLabelDistance = function (e, t, r) {
  19280. return 0
  19281. }
  19282. ,
  19283. Bh.prototype.getMesh = function () {
  19284. return this._labelsMesh
  19285. }
  19286. ,
  19287. Bh.prototype.updateData = function (e, t, r) {
  19288. null == t && (t = 0),
  19289. null == r && (r = e.count()),
  19290. this._labelsVisibilitiesBits && this._labelsVisibilitiesBits.length === r - t || (this._labelsVisibilitiesBits = new Uint8Array(r - t));
  19291. for (var i = ["label", "show"], n = ["emphasis", "label", "show"], a = t; a < r; a++) {
  19292. var o = e.getItemModel(a)
  19293. , s = o.get(i)
  19294. , l = o.get(n);
  19295. null == l && (l = s);
  19296. var h = (s ? 1 : 0) | (l ? 2 : 0);
  19297. this._labelsVisibilitiesBits[a - t] = h
  19298. }
  19299. this._start = t,
  19300. this._end = r,
  19301. this._data = e
  19302. }
  19303. ,
  19304. Bh.prototype.updateLabels = function (e) {
  19305. if (this._data) {
  19306. for (var t = (e = e || []).length > 0, r = {}, n = 0; n < e.length; n++)
  19307. r[e[n]] = !0;
  19308. this._labelsMesh.geometry.convertToDynamicArray(!0),
  19309. this._labelTextureSurface.clear();
  19310. for (var a = ["label"], o = ["emphasis", "label"], s = this._data.hostModel, l = this._data, h = s.getModel(a), u = s.getModel(o, h), c = {
  19311. left: "right",
  19312. right: "left",
  19313. top: "center",
  19314. bottom: "center"
  19315. }, d = {
  19316. left: "middle",
  19317. right: "middle",
  19318. top: "bottom",
  19319. bottom: "top"
  19320. }, f = this._start; f < this._end; f++) {
  19321. var p = !1;
  19322. if (t && r[f] && (p = !0),
  19323. this._labelsVisibilitiesBits[f - this._start] & (p ? 2 : 1)) {
  19324. var m = l.getItemModel(f).getModel(p ? o : a, p ? u : h)
  19325. , g = m.get("distance") || 0
  19326. , _ = m.get("position")
  19327. , v = this._api.getDevicePixelRatio()
  19328. , y = s.getFormattedLabel(f, p ? "emphasis" : "normal");
  19329. if (null == y || "" === y)
  19330. return;
  19331. var x = new i.graphic.Text({
  19332. style: xo(m, {
  19333. text: y,
  19334. fill: m.get("color") || Ih(l, f) || "#000",
  19335. align: "left",
  19336. verticalAlign: "top",
  19337. opacity: Mn(m.get("opacity"), Rh(l, f), 1)
  19338. })
  19339. })
  19340. , b = x.getBoundingRect();
  19341. b.height *= 1.2;
  19342. var w = this._labelTextureSurface.add(x)
  19343. , T = c[_] || "center"
  19344. , S = d[_] || "bottom";
  19345. this._labelsMesh.geometry.addSprite(this.getLabelPosition(f, _, g), [b.width * v, b.height * v], w, T, S, this.getLabelDistance(f, _, g) * v)
  19346. }
  19347. }
  19348. this._labelsMesh.material.set("uvScale", this._labelTextureSurface.getCoordsScale()),
  19349. this._labelTextureSurface.getZr().refreshImmediately(),
  19350. this._labelsMesh.geometry.convertToTypedArray(),
  19351. this._labelsMesh.geometry.dirty()
  19352. }
  19353. }
  19354. ,
  19355. Bh.prototype.dispose = function () {
  19356. this._labelTextureSurface.dispose()
  19357. }
  19358. ;
  19359. const Fh = Bh;
  19360. var zh = Po.vec3;
  19361. function Gh(e) {
  19362. this.rootNode = new Ka.Node,
  19363. this._triangulationResults = {},
  19364. this._shadersMap = Ka.COMMON_SHADERS.filter((function (e) {
  19365. return "shadow" !== e
  19366. }
  19367. )).reduce((function (e, t) {
  19368. return e[t] = Ka.createShader("ecgl." + t),
  19369. e
  19370. }
  19371. ), {}),
  19372. this._linesShader = Ka.createShader("ecgl.meshLines3D");
  19373. var t = {};
  19374. Ka.COMMON_SHADERS.forEach((function (e) {
  19375. t[e] = new Ka.Material({
  19376. shader: Ka.createShader("ecgl." + e)
  19377. })
  19378. }
  19379. )),
  19380. this._groundMaterials = t,
  19381. this._groundMesh = new Ka.Mesh({
  19382. geometry: new Ka.PlaneGeometry({
  19383. dynamic: !0
  19384. }),
  19385. castShadow: !1,
  19386. renderNormal: !0,
  19387. $ignorePicking: !0
  19388. }),
  19389. this._groundMesh.rotation.rotateX(-Math.PI / 2),
  19390. this._labelsBuilder = new Fh(512, 512, e),
  19391. this._labelsBuilder.getMesh().renderOrder = 100,
  19392. this._labelsBuilder.getMesh().material.depthTest = !1,
  19393. this.rootNode.add(this._labelsBuilder.getMesh()),
  19394. this._initMeshes(),
  19395. this._api = e
  19396. }
  19397. Ka.Shader.import(is),
  19398. Gh.prototype = {
  19399. constructor: Gh,
  19400. extrudeY: !0,
  19401. update: function (e, t, r, i, n) {
  19402. var a = e.getData();
  19403. null == i && (i = 0),
  19404. null == n && (n = a.count()),
  19405. this._startIndex = i,
  19406. this._endIndex = n - 1,
  19407. this._triangulation(e, i, n);
  19408. var o = this._getShader(e.get("shading"));
  19409. this._prepareMesh(e, o, r, i, n),
  19410. this.rootNode.updateWorldTransform(),
  19411. this._updateRegionMesh(e, r, i, n);
  19412. var s = e.coordinateSystem;
  19413. "geo3D" === s.type && this._updateGroundPlane(e, s, r);
  19414. var l = this;
  19415. this._labelsBuilder.updateData(a, i, n),
  19416. this._labelsBuilder.getLabelPosition = function (e, t, r) {
  19417. var i = a.getName(e)
  19418. , n = r;
  19419. if ("geo3D" === s.type) {
  19420. var o = s.getRegion(i);
  19421. return o ? (u = o.getCenter(),
  19422. s.dataToPoint([u[0], u[1], n])) : [NaN, NaN, NaN]
  19423. }
  19424. var h = l._triangulationResults[e - l._startIndex]
  19425. , u = l.extrudeY ? [(h.max[0] + h.min[0]) / 2, h.max[1] + n, (h.max[2] + h.min[2]) / 2] : [(h.max[0] + h.min[0]) / 2, (h.max[1] + h.min[1]) / 2, h.max[2] + n]
  19426. }
  19427. ,
  19428. this._data = a,
  19429. this._labelsBuilder.updateLabels(),
  19430. this._updateDebugWireframe(e),
  19431. this._lastHoverDataIndex = 0
  19432. },
  19433. _initMeshes: function () {
  19434. var e = this
  19435. , t = function () {
  19436. var t = new Ka.Mesh({
  19437. name: "Polygon",
  19438. material: new Ka.Material({
  19439. shader: e._shadersMap.lambert
  19440. }),
  19441. geometry: new Ka.Geometry({
  19442. sortTriangles: !0,
  19443. dynamic: !0
  19444. }),
  19445. culling: !1,
  19446. ignorePicking: !0,
  19447. renderNormal: !0
  19448. });
  19449. return Object.assign(t.geometry, Nh),
  19450. t
  19451. }()
  19452. , r = new Ka.Mesh({
  19453. material: new Ka.Material({
  19454. shader: this._linesShader
  19455. }),
  19456. castShadow: !1,
  19457. ignorePicking: !0,
  19458. $ignorePicking: !0,
  19459. geometry: new Ro({
  19460. useNativeLine: !1
  19461. })
  19462. });
  19463. this.rootNode.add(t),
  19464. this.rootNode.add(r),
  19465. t.material.define("both", "VERTEX_COLOR"),
  19466. t.material.define("fragment", "DOUBLE_SIDED"),
  19467. this._polygonMesh = t,
  19468. this._linesMesh = r,
  19469. this.rootNode.add(this._groundMesh)
  19470. },
  19471. _getShader: function (e) {
  19472. var t = this._shadersMap[e];
  19473. return t || (t = this._shadersMap.lambert),
  19474. t.__shading = e,
  19475. t
  19476. },
  19477. _prepareMesh: function (e, t, r, i, n) {
  19478. for (var a = 0, o = 0, s = 0, l = 0, h = i; h < n; h++) {
  19479. var u = this._getRegionPolygonInfo(h)
  19480. , c = this._getRegionLinesInfo(h, e, this._linesMesh.geometry);
  19481. a += u.vertexCount,
  19482. o += u.triangleCount,
  19483. s += c.vertexCount,
  19484. l += c.triangleCount
  19485. }
  19486. var d = this._polygonMesh
  19487. , f = d.geometry;
  19488. ["position", "normal", "texcoord0", "color"].forEach((function (e) {
  19489. f.attributes[e].init(a)
  19490. }
  19491. )),
  19492. f.indices = a > 65535 ? new Uint32Array(3 * o) : new Uint16Array(3 * o),
  19493. d.material.shader !== t && d.material.attachShader(t, !0),
  19494. Ka.setMaterialFromModel(t.__shading, d.material, e, r),
  19495. s > 0 && (this._linesMesh.geometry.resetOffset(),
  19496. this._linesMesh.geometry.setVertexCount(s),
  19497. this._linesMesh.geometry.setTriangleCount(l)),
  19498. this._dataIndexOfVertex = new Uint32Array(a),
  19499. this._vertexRangeOfDataIndex = new Uint32Array(2 * (n - i))
  19500. },
  19501. _updateRegionMesh: function (e, t, r, i) {
  19502. for (var n = e.getData(), a = 0, o = 0, s = !1, l = this._polygonMesh, h = this._linesMesh, u = r; u < i; u++) {
  19503. var c = e.getRegionModel(u)
  19504. , d = c.getModel("itemStyle")
  19505. , f = Mn(Ih(n, u), d.get("color"), "#fff")
  19506. , p = Mn(Rh(n, u), d.get("opacity"), 1)
  19507. , m = Ka.parseColor(f)
  19508. , g = Ka.parseColor(d.get("borderColor"));
  19509. m[3] *= p,
  19510. g[3] *= p;
  19511. var _ = m[3] < .99;
  19512. l.material.set("color", [1, 1, 1, 1]),
  19513. s = s || _;
  19514. for (var v = Mn(c.get("height", !0), e.get("regionHeight")), y = this._updatePolygonGeometry(e, l.geometry, u, v, a, o, m), x = a; x < y.vertexOffset; x++)
  19515. this._dataIndexOfVertex[x] = u;
  19516. this._vertexRangeOfDataIndex[2 * (u - r)] = a,
  19517. this._vertexRangeOfDataIndex[2 * (u - r) + 1] = y.vertexOffset,
  19518. a = y.vertexOffset,
  19519. o = y.triangleOffset;
  19520. var b = d.get("borderWidth")
  19521. , w = b > 0;
  19522. w && (b *= t.getDevicePixelRatio(),
  19523. this._updateLinesGeometry(h.geometry, e, u, v, b, e.coordinateSystem.transform)),
  19524. h.invisible = !w,
  19525. h.material.set({
  19526. color: g
  19527. })
  19528. }
  19529. (l = this._polygonMesh).material.transparent = s,
  19530. l.material.depthMask = !s,
  19531. l.geometry.updateBoundingBox(),
  19532. l.frontFace = this.extrudeY ? Ka.Mesh.CCW : Ka.Mesh.CW,
  19533. l.material.get("normalMap") && l.geometry.generateTangents(),
  19534. l.seriesIndex = e.seriesIndex,
  19535. l.on("mousemove", this._onmousemove, this),
  19536. l.on("mouseout", this._onmouseout, this)
  19537. },
  19538. _updateDebugWireframe: function (e) {
  19539. var t = e.getModel("debug.wireframe");
  19540. if (t.get("show")) {
  19541. var r = Ka.parseColor(t.get("lineStyle.color") || "rgba(0,0,0,0.5)")
  19542. , i = Mn(t.get("lineStyle.width"), 1)
  19543. , n = this._polygonMesh;
  19544. n.geometry.generateBarycentric(),
  19545. n.material.define("both", "WIREFRAME_TRIANGLE"),
  19546. n.material.set("wireframeLineColor", r),
  19547. n.material.set("wireframeLineWidth", i)
  19548. }
  19549. },
  19550. _onmousemove: function (e) {
  19551. var t = this._dataIndexOfVertex[e.triangle[0]];
  19552. null == t && (t = -1),
  19553. t !== this._lastHoverDataIndex && (this.downplay(this._lastHoverDataIndex),
  19554. this.highlight(t),
  19555. this._labelsBuilder.updateLabels([t])),
  19556. this._lastHoverDataIndex = t,
  19557. this._polygonMesh.dataIndex = t
  19558. },
  19559. _onmouseout: function (e) {
  19560. e.target && (this.downplay(this._lastHoverDataIndex),
  19561. this._lastHoverDataIndex = -1,
  19562. this._polygonMesh.dataIndex = -1),
  19563. this._labelsBuilder.updateLabels([])
  19564. },
  19565. _updateGroundPlane: function (e, t, r) {
  19566. var i = e.getModel("groundPlane", e);
  19567. if (this._groundMesh.invisible = !i.get("show", !0),
  19568. !this._groundMesh.invisible) {
  19569. var n = e.get("shading")
  19570. , a = this._groundMaterials[n];
  19571. a || (a = this._groundMaterials.lambert),
  19572. Ka.setMaterialFromModel(n, a, i, r),
  19573. a.get("normalMap") && this._groundMesh.geometry.generateTangents(),
  19574. this._groundMesh.material = a,
  19575. this._groundMesh.material.set("color", Ka.parseColor(i.get("color"))),
  19576. this._groundMesh.scale.set(t.size[0], t.size[2], 1)
  19577. }
  19578. },
  19579. _triangulation: function (e, t, r) {
  19580. this._triangulationResults = [];
  19581. for (var i = [1 / 0, 1 / 0, 1 / 0], n = [-1 / 0, -1 / 0, -1 / 0], a = e.coordinateSystem, o = t; o < r; o++) {
  19582. for (var s = [], l = e.getRegionPolygonCoords(o), h = 0; h < l.length; h++) {
  19583. var u = l[h].exterior
  19584. , c = l[h].interiors
  19585. , d = []
  19586. , f = [];
  19587. if (!(u.length < 3)) {
  19588. for (var p = 0, m = 0; m < u.length; m++) {
  19589. var g = u[m];
  19590. d[p++] = g[0],
  19591. d[p++] = g[1]
  19592. }
  19593. for (m = 0; m < c.length; m++)
  19594. if (!(c[m].length < 3)) {
  19595. for (var _ = d.length / 2, v = 0; v < c[m].length; v++)
  19596. g = c[m][v],
  19597. d.push(g[0]),
  19598. d.push(g[1]);
  19599. f.push(_)
  19600. }
  19601. var y = eh(d, f)
  19602. , x = new Float64Array(d.length / 2 * 3)
  19603. , b = []
  19604. , w = [1 / 0, 1 / 0, 1 / 0]
  19605. , T = [-1 / 0, -1 / 0, -1 / 0]
  19606. , S = 0;
  19607. for (m = 0; m < d.length;)
  19608. zh.set(b, d[m++], 0, d[m++]),
  19609. a && a.transform && zh.transformMat4(b, b, a.transform),
  19610. zh.min(w, w, b),
  19611. zh.max(T, T, b),
  19612. x[S++] = b[0],
  19613. x[S++] = b[1],
  19614. x[S++] = b[2];
  19615. zh.min(i, i, w),
  19616. zh.max(n, n, T),
  19617. s.push({
  19618. points: x,
  19619. indices: y,
  19620. min: w,
  19621. max: T
  19622. })
  19623. }
  19624. }
  19625. this._triangulationResults.push(s)
  19626. }
  19627. this._geoBoundingBox = [i, n]
  19628. },
  19629. _getRegionPolygonInfo: function (e) {
  19630. for (var t = this._triangulationResults[e - this._startIndex], r = 0, i = 0, n = 0; n < t.length; n++)
  19631. r += t[n].points.length / 3,
  19632. i += t[n].indices.length / 3;
  19633. return {
  19634. vertexCount: 2 * r + 4 * r,
  19635. triangleCount: 2 * i + 2 * r
  19636. }
  19637. },
  19638. _updatePolygonGeometry: function (e, t, r, i, n, a, o) {
  19639. var s = e.get("projectUVOnGround")
  19640. , l = t.attributes.position
  19641. , h = t.attributes.normal
  19642. , u = t.attributes.texcoord0
  19643. , c = t.attributes.color
  19644. , d = this._triangulationResults[r - this._startIndex]
  19645. , f = c.value && o
  19646. , p = t.indices
  19647. , m = this.extrudeY ? 1 : 2
  19648. , g = this.extrudeY ? 2 : 1
  19649. , _ = [this.rootNode.worldTransform.x.len(), this.rootNode.worldTransform.y.len(), this.rootNode.worldTransform.z.len()]
  19650. , v = zh.mul([], this._geoBoundingBox[0], _)
  19651. , y = zh.mul([], this._geoBoundingBox[1], _)
  19652. , x = Math.max(y[0] - v[0], y[2] - v[2]);
  19653. function b(e, t, r) {
  19654. var i = n;
  19655. !function (e, t, r) {
  19656. for (var i = e.points, a = i.length, s = [], h = [], d = 0; d < a; d += 3)
  19657. s[0] = i[d],
  19658. s[m] = t,
  19659. s[g] = i[d + 2],
  19660. h[0] = (i[d] * _[0] - v[0]) / x,
  19661. h[1] = (i[d + 2] * _[g] - v[2]) / x,
  19662. l.set(n, s),
  19663. f && c.set(n, o),
  19664. u.set(n++, h)
  19665. }(e, t);
  19666. for (var s = e.indices.length, h = 0; h < s; h++)
  19667. p[3 * a + h] = e.indices[h] + i;
  19668. a += e.indices.length / 3
  19669. }
  19670. for (var w = this.extrudeY ? [0, 1, 0] : [0, 0, 1], T = zh.negate([], w), S = 0; S < d.length; S++) {
  19671. var M = n
  19672. , A = d[S];
  19673. b(A, 0),
  19674. b(A, i);
  19675. for (var E = A.points.length / 3, C = 0; C < E; C++)
  19676. h.set(M + C, T),
  19677. h.set(M + C + E, w);
  19678. var D = [0, 3, 1, 1, 3, 2]
  19679. , L = [[], [], [], []]
  19680. , P = []
  19681. , O = []
  19682. , N = []
  19683. , I = []
  19684. , R = 0;
  19685. for (C = 0; C < E; C++) {
  19686. for (var B = (C + 1) % E, F = (A.points[3 * B] - A.points[3 * C]) * _[0], z = (A.points[3 * B + 2] - A.points[3 * C + 2]) * _[g], G = Math.sqrt(F * F + z * z), U = 0; U < 4; U++) {
  19687. var k = 0 === U || 3 === U
  19688. , V = 3 * (k ? C : B);
  19689. L[U][0] = A.points[V],
  19690. L[U][m] = U > 1 ? i : 0,
  19691. L[U][g] = A.points[V + 2],
  19692. l.set(n + U, L[U]),
  19693. s ? (I[0] = (A.points[V] * _[0] - v[0]) / x,
  19694. I[1] = (A.points[V + 2] * _[g] - v[g]) / x) : (I[0] = (k ? R : R + G) / x,
  19695. I[1] = (L[U][m] * _[m] - v[m]) / x),
  19696. u.set(n + U, I)
  19697. }
  19698. for (zh.sub(P, L[1], L[0]),
  19699. zh.sub(O, L[3], L[0]),
  19700. zh.cross(N, P, O),
  19701. zh.normalize(N, N),
  19702. U = 0; U < 4; U++)
  19703. h.set(n + U, N),
  19704. f && c.set(n + U, o);
  19705. for (U = 0; U < 6; U++)
  19706. p[3 * a + U] = D[U] + n;
  19707. n += 4,
  19708. a += 2,
  19709. R += G
  19710. }
  19711. }
  19712. return t.dirty(),
  19713. {
  19714. vertexOffset: n,
  19715. triangleOffset: a
  19716. }
  19717. },
  19718. _getRegionLinesInfo: function (e, t, r) {
  19719. var i = 0
  19720. , n = 0;
  19721. return t.getRegionModel(e).getModel("itemStyle").get("borderWidth") > 0 && t.getRegionPolygonCoords(e).forEach((function (e) {
  19722. var t = e.exterior
  19723. , a = e.interiors;
  19724. i += r.getPolylineVertexCount(t),
  19725. n += r.getPolylineTriangleCount(t);
  19726. for (var o = 0; o < a.length; o++)
  19727. i += r.getPolylineVertexCount(a[o]),
  19728. n += r.getPolylineTriangleCount(a[o])
  19729. }
  19730. ), this),
  19731. {
  19732. vertexCount: i,
  19733. triangleCount: n
  19734. }
  19735. },
  19736. _updateLinesGeometry: function (e, t, r, i, n, a) {
  19737. function o(e) {
  19738. for (var t = new Float64Array(3 * e.length), r = 0, n = [], o = 0; o < e.length; o++)
  19739. n[0] = e[o][0],
  19740. n[1] = i + .1,
  19741. n[2] = e[o][1],
  19742. a && zh.transformMat4(n, n, a),
  19743. t[r++] = n[0],
  19744. t[r++] = n[1],
  19745. t[r++] = n[2];
  19746. return t
  19747. }
  19748. var s = [1, 1, 1, 1];
  19749. t.getRegionPolygonCoords(r).forEach((function (t) {
  19750. var r = t.exterior
  19751. , i = t.interiors;
  19752. e.addPolyline(o(r), s, n);
  19753. for (var a = 0; a < i.length; a++)
  19754. e.addPolyline(o(i[a]), s, n)
  19755. }
  19756. ))
  19757. },
  19758. highlight: function (e) {
  19759. var t = this._data;
  19760. if (t) {
  19761. var r = t.getItemModel(e).getModel(["emphasis", "itemStyle"])
  19762. , n = r.get("color")
  19763. , a = Mn(r.get("opacity"), Rh(t, e), 1);
  19764. if (null == n) {
  19765. var o = Ih(t, e);
  19766. n = i.color.lift(o, -.4)
  19767. }
  19768. null == a && (a = Rh(t, e));
  19769. var s = Ka.parseColor(n);
  19770. s[3] *= a,
  19771. this._setColorOfDataIndex(t, e, s)
  19772. }
  19773. },
  19774. downplay: function (e) {
  19775. var t = this._data;
  19776. if (t) {
  19777. var r = t.getItemModel(e)
  19778. , i = Mn(Ih(t, e), r.get(["itemStyle", "color"]), "#fff")
  19779. , n = Mn(Rh(t, e), r.get(["itemStyle", "opacity"]), 1)
  19780. , a = Ka.parseColor(i);
  19781. a[3] *= n,
  19782. this._setColorOfDataIndex(t, e, a)
  19783. }
  19784. },
  19785. dispose: function () {
  19786. this._labelsBuilder.dispose()
  19787. },
  19788. _setColorOfDataIndex: function (e, t, r) {
  19789. if (!(t < this._startIndex && t > this._endIndex)) {
  19790. t -= this._startIndex;
  19791. for (var i = this._vertexRangeOfDataIndex[2 * t]; i < this._vertexRangeOfDataIndex[2 * t + 1]; i++)
  19792. this._polygonMesh.geometry.attributes.color.set(i, r);
  19793. this._polygonMesh.geometry.dirty(),
  19794. this._api.getZr().refresh()
  19795. }
  19796. }
  19797. };
  19798. const Uh = Gh
  19799. , kh = i.ComponentView.extend({
  19800. type: "geo3D",
  19801. __ecgl__: !0,
  19802. init: function (e, t) {
  19803. this._geo3DBuilder = new Uh(t),
  19804. this.groupGL = new Ka.Node,
  19805. this._lightRoot = new Ka.Node,
  19806. this._sceneHelper = new Uo(this._lightRoot),
  19807. this._sceneHelper.initLight(this._lightRoot),
  19808. this._control = new Do({
  19809. zr: t.getZr()
  19810. }),
  19811. this._control.init()
  19812. },
  19813. render: function (e, t, r) {
  19814. this.groupGL.add(this._geo3DBuilder.rootNode);
  19815. var i = e.coordinateSystem;
  19816. if (i && i.viewGL) {
  19817. i.viewGL.add(this._lightRoot),
  19818. e.get("show") ? i.viewGL.add(this.groupGL) : i.viewGL.remove(this.groupGL);
  19819. var n = this._control;
  19820. n.setViewGL(i.viewGL);
  19821. var a = e.getModel("viewControl");
  19822. n.setFromViewControlModel(a, 0),
  19823. this._sceneHelper.setScene(i.viewGL.scene),
  19824. this._sceneHelper.updateLight(e),
  19825. i.viewGL.setPostEffect(e.getModel("postEffect"), r),
  19826. i.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),
  19827. this._geo3DBuilder.update(e, t, r, 0, e.getData().count());
  19828. var o = i.viewGL.isLinearSpace() ? "define" : "undefine";
  19829. this._geo3DBuilder.rootNode.traverse((function (e) {
  19830. e.material && e.material[o]("fragment", "SRGB_DECODE")
  19831. }
  19832. )),
  19833. n.off("update"),
  19834. n.on("update", (function () {
  19835. r.dispatchAction({
  19836. type: "geo3DChangeCamera",
  19837. alpha: n.getAlpha(),
  19838. beta: n.getBeta(),
  19839. distance: n.getDistance(),
  19840. center: n.getCenter(),
  19841. from: this.uid,
  19842. geo3DId: e.id
  19843. })
  19844. }
  19845. )),
  19846. n.update()
  19847. }
  19848. },
  19849. afterRender: function (e, t, r, i) {
  19850. var n = i.renderer;
  19851. this._sceneHelper.updateAmbientCubemap(n, e, r),
  19852. this._sceneHelper.updateSkybox(n, e, r)
  19853. },
  19854. dispose: function () {
  19855. this._control.dispose(),
  19856. this._geo3DBuilder.dispose()
  19857. }
  19858. });
  19859. var Vh = {
  19860. 南海诸岛: [32, 80],
  19861. 广东: [0, -10],
  19862. 香港: [10, 5],
  19863. 澳门: [-10, 10],
  19864. 天津: [5, 5]
  19865. }
  19866. , Hh = {
  19867. Russia: [100, 60],
  19868. "United States": [-99, 38],
  19869. "United States of America": [-99, 38]
  19870. }
  19871. , Wh = Po.vec3
  19872. , jh = Po.mat4
  19873. , Xh = [function (e, t) {
  19874. if ("china" === e) {
  19875. var r = Vh[t.name];
  19876. if (r) {
  19877. var i = t.getCenter();
  19878. i[0] += r[0] / 10.5,
  19879. i[1] += -r[1] / 14,
  19880. t.setCenter(i)
  19881. }
  19882. }
  19883. }
  19884. , function (e, t) {
  19885. if ("world" === e) {
  19886. var r = Hh[t.name];
  19887. if (r) {
  19888. var i = [r[0], r[1]];
  19889. t.setCenter(i)
  19890. }
  19891. }
  19892. }
  19893. ];
  19894. function qh(e, t, r, i, n) {
  19895. this.name = e,
  19896. this.map = t,
  19897. this.regionHeight = 0,
  19898. this.regions = [],
  19899. this._nameCoordMap = {},
  19900. this.loadGeoJson(r, i, n),
  19901. this.transform = jh.identity(new Float64Array(16)),
  19902. this.invTransform = jh.identity(new Float64Array(16)),
  19903. this.extrudeY = !0,
  19904. this.altitudeAxis
  19905. }
  19906. qh.prototype = {
  19907. constructor: qh,
  19908. type: "geo3D",
  19909. dimensions: ["lng", "lat", "alt"],
  19910. containPoint: function () { },
  19911. loadGeoJson: function (e, t, r) {
  19912. var n = i.parseGeoJSON || i.parseGeoJson;
  19913. try {
  19914. this.regions = e ? n(e) : []
  19915. } catch (e) {
  19916. throw "Invalid geoJson format\n" + e
  19917. }
  19918. t = t || {},
  19919. r = r || {};
  19920. for (var a = this.regions, o = {}, s = 0; s < a.length; s++) {
  19921. var l = a[s].name;
  19922. l = r[l] || l,
  19923. a[s].name = l,
  19924. o[l] = a[s],
  19925. this.addGeoCoord(l, a[s].getCenter());
  19926. var h = t[l];
  19927. h && a[s].transformTo(h.left, h.top, h.width, h.height)
  19928. }
  19929. this._regionsMap = o,
  19930. this._geoRect = null,
  19931. Xh.forEach((function (e) {
  19932. e(this)
  19933. }
  19934. ), this)
  19935. },
  19936. getGeoBoundingRect: function () {
  19937. if (this._geoRect)
  19938. return this._geoRect;
  19939. for (var e, t = this.regions, r = 0; r < t.length; r++) {
  19940. var n = t[r].getBoundingRect();
  19941. (e = e || n.clone()).union(n)
  19942. }
  19943. return this._geoRect = e || new i.graphic.BoundingRect(0, 0, 0, 0)
  19944. },
  19945. addGeoCoord: function (e, t) {
  19946. this._nameCoordMap[e] = t
  19947. },
  19948. getRegion: function (e) {
  19949. return this._regionsMap[e]
  19950. },
  19951. getRegionByCoord: function (e) {
  19952. for (var t = this.regions, r = 0; r < t.length; r++)
  19953. if (t[r].contain(e))
  19954. return t[r]
  19955. },
  19956. setSize: function (e, t, r) {
  19957. this.size = [e, t, r];
  19958. var i = this.getGeoBoundingRect()
  19959. , n = e / i.width
  19960. , a = -r / i.height
  19961. , o = -e / 2 - i.x * n
  19962. , s = r / 2 - i.y * a
  19963. , l = this.extrudeY ? [o, 0, s] : [o, s, 0]
  19964. , h = this.extrudeY ? [n, 1, a] : [n, a, 1]
  19965. , u = this.transform;
  19966. jh.identity(u),
  19967. jh.translate(u, u, l),
  19968. jh.scale(u, u, h),
  19969. jh.invert(this.invTransform, u)
  19970. },
  19971. dataToPoint: function (e, t) {
  19972. t = t || [];
  19973. var r = this.extrudeY ? 1 : 2
  19974. , i = this.extrudeY ? 2 : 1
  19975. , n = e[2];
  19976. return isNaN(n) && (n = 0),
  19977. t[0] = e[0],
  19978. t[i] = e[1],
  19979. this.altitudeAxis ? t[r] = this.altitudeAxis.dataToCoord(n) : t[r] = 0,
  19980. t[r] += this.regionHeight,
  19981. Wh.transformMat4(t, t, this.transform),
  19982. t
  19983. },
  19984. pointToData: function (e, t) { }
  19985. };
  19986. const Zh = qh;
  19987. function Yh(e, t) {
  19988. var r = Ss(e.getBoxLayoutParams(), {
  19989. width: t.getWidth(),
  19990. height: t.getHeight()
  19991. });
  19992. r.y = t.getHeight() - r.y - r.height,
  19993. this.viewGL.setViewport(r.x, r.y, r.width, r.height, t.getDevicePixelRatio());
  19994. var i = this.getGeoBoundingRect()
  19995. , n = i.width / i.height * (e.get("aspectScale") || .75)
  19996. , a = e.get("boxWidth")
  19997. , o = e.get("boxDepth")
  19998. , s = e.get("boxHeight");
  19999. null == s && (s = 5),
  20000. isNaN(a) && isNaN(o) && (a = 100),
  20001. isNaN(o) ? o = a / n : isNaN(a) && (a = o / n),
  20002. this.setSize(a, s, o),
  20003. this.regionHeight = e.get("regionHeight"),
  20004. this.altitudeAxis && this.altitudeAxis.setExtent(0, Math.max(s - this.regionHeight, 0))
  20005. }
  20006. function Kh(e, t) {
  20007. var r = [1 / 0, -1 / 0];
  20008. if (e.eachSeries((function (e) {
  20009. if (e.coordinateSystem === this && "series.map3D" !== e.type) {
  20010. var t = e.getData()
  20011. , i = e.coordDimToDataDim("alt")
  20012. , n = i && i[0];
  20013. if (n) {
  20014. var a = t.getDataExtent(n, !0);
  20015. r[0] = Math.min(r[0], a[0]),
  20016. r[1] = Math.max(r[1], a[1])
  20017. }
  20018. }
  20019. }
  20020. ), this),
  20021. r && isFinite(r[1] - r[0])) {
  20022. var n = i.helper.createScale(r, {
  20023. type: "value",
  20024. min: "dataMin",
  20025. max: "dataMax"
  20026. });
  20027. this.altitudeAxis = new i.Axis("altitude", n),
  20028. this.resize(this.model, t)
  20029. }
  20030. }
  20031. var Qh = 0
  20032. , Jh = {
  20033. dimensions: Zh.prototype.dimensions,
  20034. create: function (e, t) {
  20035. var r = [];
  20036. if (!i.getMap)
  20037. throw new Error("geo3D component depends on geo component");
  20038. function n(e, i) {
  20039. var n = Jh.createGeo3D(e);
  20040. e.__viewGL = e.__viewGL || new Il,
  20041. n.viewGL = e.__viewGL,
  20042. e.coordinateSystem = n,
  20043. n.model = e,
  20044. r.push(n),
  20045. n.resize = Yh,
  20046. n.resize(e, t),
  20047. n.update = Kh
  20048. }
  20049. return e.eachComponent("geo3D", (function (e, t) {
  20050. n(e)
  20051. }
  20052. )),
  20053. e.eachSeriesByType("map3D", (function (e, t) {
  20054. var r = e.get("coordinateSystem");
  20055. null == r && (r = "geo3D"),
  20056. "geo3D" === r && n(e)
  20057. }
  20058. )),
  20059. e.eachSeries((function (t) {
  20060. if ("geo3D" === t.get("coordinateSystem")) {
  20061. if ("series.map3D" === t.type)
  20062. return;
  20063. var r = t.getReferringComponents("geo3D").models[0];
  20064. if (r || (r = e.getComponent("geo3D")),
  20065. !r)
  20066. throw new Error('geo "' + Mn(t.get("geo3DIndex"), t.get("geo3DId"), 0) + '" not found');
  20067. t.coordinateSystem = r.coordinateSystem
  20068. }
  20069. }
  20070. )),
  20071. r
  20072. },
  20073. createGeo3D: function (e) {
  20074. var t, r = e.get("map");
  20075. return "string" == typeof r ? (t = r,
  20076. r = i.getMap(r)) : r && r.features && (r = {
  20077. geoJson: r
  20078. }),
  20079. null == t && (t = "GEO_ANONYMOUS_" + Qh++),
  20080. new Zh(t + Qh++, t, r && r.geoJson, r && r.specialAreas, e.get("nameMap"))
  20081. }
  20082. };
  20083. const $h = Jh;
  20084. function eu(e) {
  20085. e.registerComponentModel($l),
  20086. e.registerComponentView(kh),
  20087. e.registerAction({
  20088. type: "geo3DChangeCamera",
  20089. event: "geo3dcamerachanged",
  20090. update: "series:updateCamera"
  20091. }, (function (e, t) {
  20092. t.eachComponent({
  20093. mainType: "geo3D",
  20094. query: e
  20095. }, (function (t) {
  20096. t.setView(e)
  20097. }
  20098. ))
  20099. }
  20100. )),
  20101. e.registerCoordinateSystem("geo3D", $h)
  20102. }
  20103. function tu(e, t) {
  20104. e.id = e.id || e.name || t + ""
  20105. }
  20106. (0,
  20107. i.use)(eu);
  20108. var ru = i.ComponentModel.extend({
  20109. type: "globe",
  20110. layoutMode: "box",
  20111. coordinateSystem: null,
  20112. init: function () {
  20113. ru.superApply(this, "init", arguments),
  20114. i.util.each(this.option.layers, (function (e, t) {
  20115. i.util.merge(e, this.defaultLayerOption),
  20116. tu(e, t)
  20117. }
  20118. ), this)
  20119. },
  20120. mergeOption: function (e) {
  20121. var t = this.option.layers;
  20122. function r(e) {
  20123. return i.util.reduce(e, (function (e, t, r) {
  20124. return tu(t, r),
  20125. e[t.id] = t,
  20126. e
  20127. }
  20128. ), {})
  20129. }
  20130. if (this.option.layers = null,
  20131. ru.superApply(this, "mergeOption", arguments),
  20132. t && t.length) {
  20133. var n = r(e.layers)
  20134. , a = r(t);
  20135. for (var o in n)
  20136. a[o] ? i.util.merge(a[o], n[o], !0) : t.push(e.layers[o]);
  20137. this.option.layers = t
  20138. }
  20139. i.util.each(this.option.layers, (function (e) {
  20140. i.util.merge(e, this.defaultLayerOption)
  20141. }
  20142. ), this)
  20143. },
  20144. optionUpdated: function () {
  20145. this.updateDisplacementHash()
  20146. },
  20147. defaultLayerOption: {
  20148. show: !0,
  20149. type: "overlay"
  20150. },
  20151. defaultOption: {
  20152. show: !0,
  20153. zlevel: -10,
  20154. left: 0,
  20155. top: 0,
  20156. width: "100%",
  20157. height: "100%",
  20158. environment: "auto",
  20159. baseColor: "#fff",
  20160. baseTexture: "",
  20161. heightTexture: "",
  20162. displacementTexture: "",
  20163. displacementScale: 0,
  20164. displacementQuality: "medium",
  20165. globeRadius: 100,
  20166. globeOuterRadius: 150,
  20167. shading: "lambert",
  20168. light: {
  20169. main: {
  20170. time: ""
  20171. }
  20172. },
  20173. atmosphere: {
  20174. show: !1,
  20175. offset: 5,
  20176. color: "#ffffff",
  20177. glowPower: 6,
  20178. innerGlowPower: 2
  20179. },
  20180. viewControl: {
  20181. autoRotate: !0,
  20182. panSensitivity: 0,
  20183. targetCoord: null
  20184. },
  20185. layers: []
  20186. },
  20187. setDisplacementData: function (e, t, r) {
  20188. this.displacementData = e,
  20189. this.displacementWidth = t,
  20190. this.displacementHeight = r
  20191. },
  20192. getDisplacementTexture: function () {
  20193. return this.get("displacementTexture") || this.get("heightTexture")
  20194. },
  20195. getDisplacemenScale: function () {
  20196. var e = this.getDisplacementTexture()
  20197. , t = this.get("displacementScale");
  20198. return e && "none" !== e || (t = 0),
  20199. t
  20200. },
  20201. hasDisplacement: function () {
  20202. return this.getDisplacemenScale() > 0
  20203. },
  20204. _displacementChanged: !0,
  20205. _displacementScale: 0,
  20206. updateDisplacementHash: function () {
  20207. var e = this.getDisplacementTexture()
  20208. , t = this.getDisplacemenScale();
  20209. this._displacementChanged = this._displacementTexture !== e || this._displacementScale !== t,
  20210. this._displacementTexture = e,
  20211. this._displacementScale = t
  20212. },
  20213. isDisplacementChanged: function () {
  20214. return this._displacementChanged
  20215. }
  20216. });
  20217. i.util.merge(ru.prototype, uo),
  20218. i.util.merge(ru.prototype, co),
  20219. i.util.merge(ru.prototype, fo),
  20220. i.util.merge(ru.prototype, Kl);
  20221. const iu = ru;
  20222. var nu = Math.PI
  20223. , au = Math.sin
  20224. , ou = Math.cos
  20225. , su = Math.tan
  20226. , lu = Math.asin
  20227. , hu = Math.atan2
  20228. , uu = nu / 180
  20229. , cu = 23.4397 * uu;
  20230. function du(e, t) {
  20231. return hu(au(e) * ou(cu) - su(t) * au(cu), ou(e))
  20232. }
  20233. function fu(e, t, r) {
  20234. return hu(au(e), ou(e) * au(t) - su(r) * ou(t))
  20235. }
  20236. function pu(e, t, r) {
  20237. return lu(au(t) * au(r) + ou(t) * ou(r) * ou(e))
  20238. }
  20239. var mu = {};
  20240. mu.getPosition = function (e, t, r) {
  20241. var i = uu * -r
  20242. , n = uu * t
  20243. , a = function (e) {
  20244. return function (e) {
  20245. return e.valueOf() / 864e5 - .5 + 2440588
  20246. }(e) - 2451545
  20247. }(e)
  20248. , o = function (e) {
  20249. var t, r, i = (r = function (e) {
  20250. return uu * (357.5291 + .98560028 * e)
  20251. }(e)) + uu * (1.9148 * au(r) + .02 * au(2 * r) + 3e-4 * au(3 * r)) + 102.9372 * uu + nu;
  20252. return {
  20253. dec: (t = i,
  20254. lu(au(0) * ou(cu) + ou(0) * au(cu) * au(t))),
  20255. ra: du(i, 0)
  20256. }
  20257. }(a)
  20258. , s = function (e, t) {
  20259. return uu * (280.16 + 360.9856235 * e) - t
  20260. }(a, i) - o.ra;
  20261. return {
  20262. azimuth: fu(s, n, o.dec),
  20263. altitude: pu(s, n, o.dec)
  20264. }
  20265. }
  20266. ;
  20267. const gu = mu;
  20268. Ka.Shader.import(Va),
  20269. Ka.Shader.import("@export ecgl.atmosphere.vertex\nattribute vec3 position: POSITION;\nattribute vec3 normal : NORMAL;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 normalMatrix : WORLDINVERSETRANSPOSE;\n\nvarying vec3 v_Normal;\n\nvoid main() {\n v_Normal = normalize((normalMatrix * vec4(normal, 0.0)).xyz);\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n\n\n@export ecgl.atmosphere.fragment\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform float glowPower;\nuniform vec3 glowColor;\n\nvarying vec3 v_Normal;\n\nvoid main() {\n float intensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor = vec4(glowColor, intensity * intensity);\n}\n@end");
  20270. const _u = i.ComponentView.extend({
  20271. type: "globe",
  20272. __ecgl__: !0,
  20273. _displacementScale: 0,
  20274. init: function (e, t) {
  20275. this.groupGL = new Ka.Node,
  20276. this._sphereGeometry = new Ka.SphereGeometry({
  20277. widthSegments: 200,
  20278. heightSegments: 100,
  20279. dynamic: !0
  20280. }),
  20281. this._overlayGeometry = new Ka.SphereGeometry({
  20282. widthSegments: 80,
  20283. heightSegments: 40
  20284. }),
  20285. this._planeGeometry = new Ka.PlaneGeometry,
  20286. this._earthMesh = new Ka.Mesh({
  20287. renderNormal: !0
  20288. }),
  20289. this._atmosphereMesh = new Ka.Mesh,
  20290. this._atmosphereGeometry = new Ka.SphereGeometry({
  20291. widthSegments: 80,
  20292. heightSegments: 40
  20293. }),
  20294. this._atmosphereMaterial = new Ka.Material({
  20295. shader: new Ka.Shader(Ka.Shader.source("ecgl.atmosphere.vertex"), Ka.Shader.source("ecgl.atmosphere.fragment")),
  20296. transparent: !0
  20297. }),
  20298. this._atmosphereMesh.geometry = this._atmosphereGeometry,
  20299. this._atmosphereMesh.material = this._atmosphereMaterial,
  20300. this._atmosphereMesh.frontFace = Ka.Mesh.CW,
  20301. this._lightRoot = new Ka.Node,
  20302. this._sceneHelper = new Uo,
  20303. this._sceneHelper.initLight(this._lightRoot),
  20304. this.groupGL.add(this._atmosphereMesh),
  20305. this.groupGL.add(this._earthMesh),
  20306. this._control = new Do({
  20307. zr: t.getZr()
  20308. }),
  20309. this._control.init(),
  20310. this._layerMeshes = {}
  20311. },
  20312. render: function (e, t, r) {
  20313. var i = e.coordinateSystem
  20314. , n = e.get("shading");
  20315. i.viewGL.add(this._lightRoot),
  20316. e.get("show") ? i.viewGL.add(this.groupGL) : i.viewGL.remove(this.groupGL),
  20317. this._sceneHelper.setScene(i.viewGL.scene),
  20318. i.viewGL.setPostEffect(e.getModel("postEffect"), r),
  20319. i.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling"));
  20320. var a = this._earthMesh;
  20321. a.geometry = this._sphereGeometry;
  20322. var o = "ecgl." + n;
  20323. a.material && a.material.shader.name === o || (a.material = Ka.createMaterial(o)),
  20324. Ka.setMaterialFromModel(n, a.material, e, r),
  20325. ["roughnessMap", "metalnessMap", "detailMap", "normalMap"].forEach((function (e) {
  20326. var t = a.material.get(e);
  20327. t && (t.flipY = !1)
  20328. }
  20329. )),
  20330. a.material.set("color", Ka.parseColor(e.get("baseColor")));
  20331. var s = .99 * i.radius;
  20332. if (a.scale.set(s, s, s),
  20333. e.get("atmosphere.show")) {
  20334. a.material.define("both", "ATMOSPHERE_ENABLED"),
  20335. this._atmosphereMesh.invisible = !1,
  20336. this._atmosphereMaterial.setUniforms({
  20337. glowPower: e.get("atmosphere.glowPower") || 6,
  20338. glowColor: e.get("atmosphere.color") || "#ffffff"
  20339. }),
  20340. a.material.setUniforms({
  20341. glowPower: e.get("atmosphere.innerGlowPower") || 2,
  20342. glowColor: e.get("atmosphere.color") || "#ffffff"
  20343. });
  20344. var l = e.get("atmosphere.offset") || 5;
  20345. this._atmosphereMesh.scale.set(s + l, s + l, s + l)
  20346. } else
  20347. a.material.undefine("both", "ATMOSPHERE_ENABLED"),
  20348. this._atmosphereMesh.invisible = !0;
  20349. var h = a.material.setTextureImage("diffuseMap", e.get("baseTexture"), r, {
  20350. flipY: !1,
  20351. anisotropic: 8
  20352. });
  20353. h && h.surface && h.surface.attachToMesh(a);
  20354. var u = a.material.setTextureImage("bumpMap", e.get("heightTexture"), r, {
  20355. flipY: !1,
  20356. anisotropic: 8
  20357. });
  20358. u && u.surface && u.surface.attachToMesh(a),
  20359. a.material[e.get("postEffect.enable") ? "define" : "undefine"]("fragment", "SRGB_DECODE"),
  20360. this._updateLight(e, r),
  20361. this._displaceVertices(e, r),
  20362. this._updateViewControl(e, r),
  20363. this._updateLayers(e, r)
  20364. },
  20365. afterRender: function (e, t, r, i) {
  20366. var n = i.renderer;
  20367. this._sceneHelper.updateAmbientCubemap(n, e, r),
  20368. this._sceneHelper.updateSkybox(n, e, r)
  20369. },
  20370. _updateLayers: function (e, t) {
  20371. var r = e.coordinateSystem
  20372. , n = e.get("layers")
  20373. , a = r.radius
  20374. , o = []
  20375. , s = []
  20376. , l = []
  20377. , h = [];
  20378. i.util.each(n, (function (e) {
  20379. var n = new i.Model(e)
  20380. , u = n.get("type")
  20381. , c = Ka.loadTexture(n.get("texture"), t, {
  20382. flipY: !1,
  20383. anisotropic: 8
  20384. });
  20385. if (c.surface && c.surface.attachToMesh(this._earthMesh),
  20386. "blend" === u) {
  20387. var d = n.get("blendTo")
  20388. , f = Mn(n.get("intensity"), 1);
  20389. "emission" === d ? (l.push(c),
  20390. h.push(f)) : (o.push(c),
  20391. s.push(f))
  20392. } else {
  20393. var p = n.get("id")
  20394. , m = this._layerMeshes[p];
  20395. m || (m = this._layerMeshes[p] = new Ka.Mesh({
  20396. geometry: this._overlayGeometry,
  20397. castShadow: !1,
  20398. ignorePicking: !0
  20399. })),
  20400. "lambert" === n.get("shading") ? (m.material = m.__lambertMaterial || new Ka.Material({
  20401. autoUpdateTextureStatus: !1,
  20402. shader: Ka.createShader("ecgl.lambert"),
  20403. transparent: !0,
  20404. depthMask: !1
  20405. }),
  20406. m.__lambertMaterial = m.material) : (m.material = m.__colorMaterial || new Ka.Material({
  20407. autoUpdateTextureStatus: !1,
  20408. shader: Ka.createShader("ecgl.color"),
  20409. transparent: !0,
  20410. depthMask: !1
  20411. }),
  20412. m.__colorMaterial = m.material),
  20413. m.material.enableTexture("diffuseMap");
  20414. var g = n.get("distance")
  20415. , _ = a + (null == g ? r.radius / 100 : g);
  20416. m.scale.set(_, _, _),
  20417. a = _;
  20418. var v = this._blankTexture || (this._blankTexture = Ka.createBlankTexture("rgba(255, 255, 255, 0)"));
  20419. m.material.set("diffuseMap", v),
  20420. Ka.loadTexture(n.get("texture"), t, {
  20421. flipY: !1,
  20422. anisotropic: 8
  20423. }, (function (e) {
  20424. e.surface && e.surface.attachToMesh(m),
  20425. m.material.set("diffuseMap", e),
  20426. t.getZr().refresh()
  20427. }
  20428. )),
  20429. n.get("show") ? this.groupGL.add(m) : this.groupGL.remove(m)
  20430. }
  20431. }
  20432. ), this);
  20433. var u = this._earthMesh.material;
  20434. u.define("fragment", "LAYER_DIFFUSEMAP_COUNT", o.length),
  20435. u.define("fragment", "LAYER_EMISSIVEMAP_COUNT", l.length),
  20436. u.set("layerDiffuseMap", o),
  20437. u.set("layerDiffuseIntensity", s),
  20438. u.set("layerEmissiveMap", l),
  20439. u.set("layerEmissionIntensity", h);
  20440. var c = e.getModel("debug.wireframe");
  20441. if (c.get("show")) {
  20442. u.define("both", "WIREFRAME_TRIANGLE");
  20443. var d = Ka.parseColor(c.get("lineStyle.color") || "rgba(0,0,0,0.5)")
  20444. , f = Mn(c.get("lineStyle.width"), 1);
  20445. u.set("wireframeLineWidth", f),
  20446. u.set("wireframeLineColor", d)
  20447. } else
  20448. u.undefine("both", "WIREFRAME_TRIANGLE")
  20449. },
  20450. _updateViewControl: function (e, t) {
  20451. var r = e.coordinateSystem
  20452. , i = e.getModel("viewControl")
  20453. , n = (r.viewGL.camera,
  20454. this)
  20455. , a = this._control;
  20456. a.setViewGL(r.viewGL);
  20457. var o, s, l = i.get("targetCoord");
  20458. null != l && (s = l[0] + 90,
  20459. o = l[1]),
  20460. a.setFromViewControlModel(i, {
  20461. baseDistance: r.radius,
  20462. alpha: o,
  20463. beta: s
  20464. }),
  20465. a.off("update"),
  20466. a.on("update", (function () {
  20467. t.dispatchAction({
  20468. type: "globeChangeCamera",
  20469. alpha: a.getAlpha(),
  20470. beta: a.getBeta(),
  20471. distance: a.getDistance() - r.radius,
  20472. center: a.getCenter(),
  20473. from: n.uid,
  20474. globeId: e.id
  20475. })
  20476. }
  20477. ))
  20478. },
  20479. _displaceVertices: function (e, t) {
  20480. var r = e.get("displacementQuality")
  20481. , i = e.get("debug.wireframe.show")
  20482. , n = e.coordinateSystem;
  20483. if (e.isDisplacementChanged() || r !== this._displacementQuality || i !== this._showDebugWireframe) {
  20484. this._displacementQuality = r,
  20485. this._showDebugWireframe = i;
  20486. var a = this._sphereGeometry
  20487. , o = {
  20488. low: 100,
  20489. medium: 200,
  20490. high: 400,
  20491. ultra: 800
  20492. }[r] || 200
  20493. , s = o / 2;
  20494. (a.widthSegments !== o || i) && (a.widthSegments = o,
  20495. a.heightSegments = s,
  20496. a.build()),
  20497. this._doDisplaceVertices(a, n),
  20498. i && a.generateBarycentric()
  20499. }
  20500. },
  20501. _doDisplaceVertices: function (e, t) {
  20502. var r = e.attributes.position.value
  20503. , i = e.attributes.texcoord0.value
  20504. , n = e.__originalPosition;
  20505. n && n.length === r.length || ((n = new Float32Array(r.length)).set(r),
  20506. e.__originalPosition = n);
  20507. for (var a = t.displacementWidth, o = t.displacementHeight, s = t.displacementData, l = 0; l < e.vertexCount; l++) {
  20508. var h = 3 * l
  20509. , u = 2 * l
  20510. , c = n[h + 1]
  20511. , d = n[h + 2]
  20512. , f = n[h + 3]
  20513. , p = i[u++]
  20514. , m = i[u++]
  20515. , g = Math.round(p * (a - 1))
  20516. , _ = Math.round(m * (o - 1))
  20517. , v = s ? s[_ * a + g] : 0;
  20518. r[h + 1] = c + c * v,
  20519. r[h + 2] = d + d * v,
  20520. r[h + 3] = f + f * v
  20521. }
  20522. e.generateVertexNormals(),
  20523. e.dirty(),
  20524. e.updateBoundingBox()
  20525. },
  20526. _updateLight: function (e, t) {
  20527. var r = this._earthMesh;
  20528. this._sceneHelper.updateLight(e);
  20529. var n = this._sceneHelper.mainLight
  20530. , a = e.get("light.main.time") || new Date
  20531. , o = gu.getPosition(i.number.parseDate(a), 0, 0)
  20532. , s = Math.cos(o.altitude);
  20533. n.position.y = -s * Math.cos(o.azimuth),
  20534. n.position.x = Math.sin(o.altitude),
  20535. n.position.z = s * Math.sin(o.azimuth),
  20536. n.lookAt(r.getWorldPosition())
  20537. },
  20538. dispose: function (e, t) {
  20539. this.groupGL.removeAll(),
  20540. this._control.dispose()
  20541. }
  20542. });
  20543. var vu = Po.vec3;
  20544. function yu(e) {
  20545. this.radius = e,
  20546. this.viewGL = null,
  20547. this.altitudeAxis,
  20548. this.displacementData = null,
  20549. this.displacementWidth,
  20550. this.displacementHeight
  20551. }
  20552. yu.prototype = {
  20553. constructor: yu,
  20554. dimensions: ["lng", "lat", "alt"],
  20555. type: "globe",
  20556. containPoint: function () { },
  20557. setDisplacementData: function (e, t, r) {
  20558. this.displacementData = e,
  20559. this.displacementWidth = t,
  20560. this.displacementHeight = r
  20561. },
  20562. _getDisplacementScale: function (e, t) {
  20563. var r = (e + 180) / 360 * (this.displacementWidth - 1)
  20564. , i = (90 - t) / 180 * (this.displacementHeight - 1)
  20565. , n = Math.round(r) + Math.round(i) * this.displacementWidth;
  20566. return this.displacementData[n]
  20567. },
  20568. dataToPoint: function (e, t) {
  20569. var r = e[0]
  20570. , i = e[1]
  20571. , n = e[2] || 0
  20572. , a = this.radius;
  20573. this.displacementData && (a *= 1 + this._getDisplacementScale(r, i)),
  20574. this.altitudeAxis && (a += this.altitudeAxis.dataToCoord(n)),
  20575. r = r * Math.PI / 180,
  20576. i = i * Math.PI / 180;
  20577. var o = Math.cos(i) * a;
  20578. return (t = t || [])[0] = -o * Math.cos(r + Math.PI),
  20579. t[1] = Math.sin(i) * a,
  20580. t[2] = o * Math.sin(r + Math.PI),
  20581. t
  20582. },
  20583. pointToData: function (e, t) {
  20584. var r = e[0]
  20585. , i = e[1]
  20586. , n = e[2]
  20587. , a = vu.len(e);
  20588. r /= a,
  20589. i /= a,
  20590. n /= a;
  20591. var o = Math.asin(i)
  20592. , s = Math.atan2(n, -r);
  20593. s < 0 && (s = 2 * Math.PI + s);
  20594. var l = 180 * o / Math.PI
  20595. , h = 180 * s / Math.PI - 180;
  20596. return (t = t || [])[0] = h,
  20597. t[1] = l,
  20598. t[2] = a - this.radius,
  20599. this.altitudeAxis && (t[2] = this.altitudeAxis.coordToData(t[2])),
  20600. t
  20601. }
  20602. };
  20603. const xu = yu;
  20604. function bu(e, t) {
  20605. var r = Ss(e.getBoxLayoutParams(), {
  20606. width: t.getWidth(),
  20607. height: t.getHeight()
  20608. });
  20609. r.y = t.getHeight() - r.y - r.height,
  20610. this.viewGL.setViewport(r.x, r.y, r.width, r.height, t.getDevicePixelRatio()),
  20611. this.radius = e.get("globeRadius");
  20612. var i = e.get("globeOuterRadius");
  20613. this.altitudeAxis && this.altitudeAxis.setExtent(0, i - this.radius)
  20614. }
  20615. function wu(e, t) {
  20616. var r = [1 / 0, -1 / 0];
  20617. if (e.eachSeries((function (e) {
  20618. if (e.coordinateSystem === this) {
  20619. var t = e.getData()
  20620. , i = e.coordDimToDataDim("alt")
  20621. , n = i && i[0];
  20622. if (n) {
  20623. var a = t.getDataExtent(n, !0);
  20624. r[0] = Math.min(r[0], a[0]),
  20625. r[1] = Math.max(r[1], a[1])
  20626. }
  20627. }
  20628. }
  20629. ), this),
  20630. r && isFinite(r[1] - r[0])) {
  20631. var n = i.helper.createScale(r, {
  20632. type: "value",
  20633. min: "dataMin",
  20634. max: "dataMax"
  20635. });
  20636. this.altitudeAxis = new i.Axis("altitude", n),
  20637. this.resize(this.model, t)
  20638. }
  20639. }
  20640. const Tu = {
  20641. dimensions: xu.prototype.dimensions,
  20642. create: function (e, t) {
  20643. var r = [];
  20644. return e.eachComponent("globe", (function (e) {
  20645. e.__viewGL = e.__viewGL || new Il;
  20646. var i = new xu;
  20647. i.viewGL = e.__viewGL,
  20648. e.coordinateSystem = i,
  20649. i.model = e,
  20650. r.push(i),
  20651. i.resize = bu,
  20652. i.resize(e, t),
  20653. i.update = wu
  20654. }
  20655. )),
  20656. e.eachSeries((function (t) {
  20657. if ("globe" === t.get("coordinateSystem")) {
  20658. var r = t.getReferringComponents("globe").models[0];
  20659. if (r || (r = e.getComponent("globe")),
  20660. !r)
  20661. throw new Error('globe "' + Mn(t.get("globe3DIndex"), t.get("globe3DId"), 0) + '" not found');
  20662. var i = r.coordinateSystem;
  20663. t.coordinateSystem = i
  20664. }
  20665. }
  20666. )),
  20667. e.eachComponent("globe", (function (e, r) {
  20668. var i = e.coordinateSystem
  20669. , n = e.getDisplacementTexture()
  20670. , a = e.getDisplacemenScale();
  20671. if (e.isDisplacementChanged()) {
  20672. if (e.hasDisplacement()) {
  20673. var o = !0;
  20674. Ka.loadTexture(n, t, (function (r) {
  20675. var i = function (e, t) {
  20676. var r = document.createElement("canvas")
  20677. , i = r.getContext("2d")
  20678. , n = e.width
  20679. , a = e.height;
  20680. r.width = n,
  20681. r.height = a,
  20682. i.drawImage(e, 0, 0, n, a);
  20683. for (var o = i.getImageData(0, 0, n, a).data, s = new Float32Array(o.length / 4), l = 0; l < o.length / 4; l++) {
  20684. var h = o[4 * l];
  20685. s[l] = h / 255 * t
  20686. }
  20687. return {
  20688. data: s,
  20689. width: n,
  20690. height: a
  20691. }
  20692. }(r.image, a);
  20693. e.setDisplacementData(i.data, i.width, i.height),
  20694. o || t.dispatchAction({
  20695. type: "globeUpdateDisplacment"
  20696. })
  20697. }
  20698. )),
  20699. o = !1
  20700. } else
  20701. i.setDisplacementData(null, 0, 0);
  20702. i.setDisplacementData(e.displacementData, e.displacementWidth, e.displacementHeight)
  20703. }
  20704. }
  20705. )),
  20706. r
  20707. }
  20708. };
  20709. (0,
  20710. i.use)((function (e) {
  20711. e.registerComponentModel(iu),
  20712. e.registerComponentView(_u),
  20713. e.registerCoordinateSystem("globe", Tu),
  20714. e.registerAction({
  20715. type: "globeChangeCamera",
  20716. event: "globecamerachanged",
  20717. update: "series:updateCamera"
  20718. }, (function (e, t) {
  20719. t.eachComponent({
  20720. mainType: "globe",
  20721. query: e
  20722. }, (function (t) {
  20723. t.setView(e)
  20724. }
  20725. ))
  20726. }
  20727. )),
  20728. e.registerAction({
  20729. type: "globeUpdateDisplacment",
  20730. event: "globedisplacementupdated",
  20731. update: "update"
  20732. }, (function (e, t) { }
  20733. ))
  20734. }
  20735. ));
  20736. var Su = ["zoom", "center", "pitch", "bearing"]
  20737. , Mu = i.ComponentModel.extend({
  20738. type: "mapbox3D",
  20739. layoutMode: "box",
  20740. coordinateSystem: null,
  20741. defaultOption: {
  20742. zlevel: -10,
  20743. style: "mapbox://styles/mapbox/light-v9",
  20744. center: [0, 0],
  20745. zoom: 0,
  20746. pitch: 0,
  20747. bearing: 0,
  20748. light: {
  20749. main: {
  20750. alpha: 20,
  20751. beta: 30
  20752. }
  20753. },
  20754. altitudeScale: 1,
  20755. boxHeight: "auto"
  20756. },
  20757. getMapboxCameraOption: function () {
  20758. var e = this;
  20759. return Su.reduce((function (t, r) {
  20760. return t[r] = e.get(r),
  20761. t
  20762. }
  20763. ), {})
  20764. },
  20765. setMapboxCameraOption: function (e) {
  20766. null != e && Su.forEach((function (t) {
  20767. null != e[t] && (this.option[t] = e[t])
  20768. }
  20769. ), this)
  20770. },
  20771. getMapbox: function () {
  20772. return this._mapbox
  20773. },
  20774. setMapbox: function (e) {
  20775. this._mapbox = e
  20776. }
  20777. });
  20778. i.util.merge(Mu.prototype, co),
  20779. i.util.merge(Mu.prototype, fo);
  20780. const Au = Mu;
  20781. function Eu(e, t) {
  20782. if (this.id = e,
  20783. this.zr = t,
  20784. this.dom = document.createElement("div"),
  20785. this.dom.style.cssText = "position:absolute;left:0;right:0;top:0;bottom:0;",
  20786. !mapboxgl)
  20787. throw new Error("Mapbox GL library must be included. See https://www.mapbox.com/mapbox-gl-js/api/");
  20788. this._mapbox = new mapboxgl.Map({
  20789. container: this.dom
  20790. }),
  20791. this._initEvents()
  20792. }
  20793. Eu.prototype.setUnpainted = function () { }
  20794. ,
  20795. Eu.prototype.resize = function () {
  20796. this._mapbox.resize()
  20797. }
  20798. ,
  20799. Eu.prototype.getMapbox = function () {
  20800. return this._mapbox
  20801. }
  20802. ,
  20803. Eu.prototype.clear = function () { }
  20804. ,
  20805. Eu.prototype.refresh = function () {
  20806. this._mapbox.resize()
  20807. }
  20808. ;
  20809. var Cu = ["mousedown", "mouseup", "click", "dblclick", "mousemove", "mousewheel", "wheel", "touchstart", "touchend", "touchmove", "touchcancel"];
  20810. Eu.prototype._initEvents = function () {
  20811. var e = this._mapbox.getCanvasContainer();
  20812. this._handlers = this._handlers || {
  20813. contextmenu: function (e) {
  20814. return e.preventDefault(),
  20815. !1
  20816. }
  20817. },
  20818. Cu.forEach((function (t) {
  20819. this._handlers[t] = function (t) {
  20820. var r = {};
  20821. for (var i in t)
  20822. r[i] = t[i];
  20823. r.bubbles = !1;
  20824. var n = new t.constructor(t.type, r);
  20825. e.dispatchEvent(n)
  20826. }
  20827. ,
  20828. this.zr.dom.addEventListener(t, this._handlers[t])
  20829. }
  20830. ), this),
  20831. this.zr.dom.addEventListener("contextmenu", this._handlers.contextmenu)
  20832. }
  20833. ,
  20834. Eu.prototype.dispose = function () {
  20835. Cu.forEach((function (e) {
  20836. this.zr.dom.removeEventListener(e, this._handlers[e])
  20837. }
  20838. ), this)
  20839. }
  20840. ;
  20841. const Du = Eu
  20842. , Lu = "\n@export ecgl.displayShadow.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_WorldPosition;\n\nvarying vec3 v_Normal;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n\n@end\n\n\n@export ecgl.displayShadow.fragment\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform float roughness: 0.2;\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.ssaoMap.header\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n float shadow = 1.0;\n\n @import ecgl.common.ssaoMap.main\n\n#if defined(DIRECTIONAL_LIGHT_COUNT) && defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n for (int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++) {\n shadow = min(shadow, shadowContribsDir[i] * 0.5 + 0.5);\n }\n#endif\n\n shadow *= 0.5 + ao * 0.5;\n shadow = clamp(shadow, 0.0, 1.0);\n\n gl_FragColor = vec4(vec3(0.0), 1.0 - shadow);\n}\n\n@end";
  20843. Ka.Shader.import(Lu);
  20844. const Pu = i.ComponentView.extend({
  20845. type: "mapbox3D",
  20846. __ecgl__: !0,
  20847. init: function (e, t) {
  20848. var r = t.getZr();
  20849. this._zrLayer = new Du("mapbox3D", r),
  20850. r.painter.insertLayer(-1e3, this._zrLayer),
  20851. this._lightRoot = new Ka.Node,
  20852. this._sceneHelper = new Uo(this._lightRoot),
  20853. this._sceneHelper.initLight(this._lightRoot);
  20854. var i = this._zrLayer.getMapbox()
  20855. , n = this._dispatchInteractAction.bind(this, t, i);
  20856. ["zoom", "rotate", "drag", "pitch", "rotate", "move"].forEach((function (e) {
  20857. i.on(e, n)
  20858. }
  20859. )),
  20860. this._groundMesh = new Ka.Mesh({
  20861. geometry: new Ka.PlaneGeometry,
  20862. material: new Ka.Material({
  20863. shader: new Ka.Shader({
  20864. vertex: Ka.Shader.source("ecgl.displayShadow.vertex"),
  20865. fragment: Ka.Shader.source("ecgl.displayShadow.fragment")
  20866. }),
  20867. depthMask: !1
  20868. }),
  20869. renderOrder: -100,
  20870. culling: !1,
  20871. castShadow: !1,
  20872. $ignorePicking: !0,
  20873. renderNormal: !0
  20874. })
  20875. },
  20876. render: function (e, t, r) {
  20877. var i = this._zrLayer.getMapbox()
  20878. , n = e.get("style")
  20879. , a = JSON.stringify(n);
  20880. a !== this._oldStyleStr && n && i.setStyle(n),
  20881. this._oldStyleStr = a,
  20882. i.setCenter(e.get("center")),
  20883. i.setZoom(e.get("zoom")),
  20884. i.setPitch(e.get("pitch")),
  20885. i.setBearing(e.get("bearing")),
  20886. e.setMapbox(i);
  20887. var o = e.coordinateSystem;
  20888. o.viewGL.scene.add(this._lightRoot),
  20889. o.viewGL.add(this._groundMesh),
  20890. this._updateGroundMesh(),
  20891. this._sceneHelper.setScene(o.viewGL.scene),
  20892. this._sceneHelper.updateLight(e),
  20893. o.viewGL.setPostEffect(e.getModel("postEffect"), r),
  20894. o.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),
  20895. this._mapbox3DModel = e
  20896. },
  20897. afterRender: function (e, t, r, i) {
  20898. var n = i.renderer;
  20899. this._sceneHelper.updateAmbientCubemap(n, e, r),
  20900. this._sceneHelper.updateSkybox(n, e, r),
  20901. e.coordinateSystem.viewGL.scene.traverse((function (e) {
  20902. e.material && (e.material.define("fragment", "NORMAL_UP_AXIS", 2),
  20903. e.material.define("fragment", "NORMAL_FRONT_AXIS", 1))
  20904. }
  20905. ))
  20906. },
  20907. updateCamera: function (e, t, r, i) {
  20908. e.coordinateSystem.setCameraOption(i),
  20909. this._updateGroundMesh(),
  20910. r.getZr().refresh()
  20911. },
  20912. _dispatchInteractAction: function (e, t, r) {
  20913. e.dispatchAction({
  20914. type: "mapbox3DChangeCamera",
  20915. pitch: t.getPitch(),
  20916. zoom: t.getZoom(),
  20917. center: t.getCenter().toArray(),
  20918. bearing: t.getBearing(),
  20919. mapbox3DId: this._mapbox3DModel && this._mapbox3DModel.id
  20920. })
  20921. },
  20922. _updateGroundMesh: function () {
  20923. if (this._mapbox3DModel) {
  20924. var e = this._mapbox3DModel.coordinateSystem
  20925. , t = e.dataToPoint(e.center);
  20926. this._groundMesh.position.set(t[0], t[1], -.001);
  20927. var r = new Ka.Plane(new Ka.Vector3(0, 0, 1), 0)
  20928. , i = e.viewGL.camera.castRay(new Ka.Vector2(-1, -1))
  20929. , n = e.viewGL.camera.castRay(new Ka.Vector2(1, 1))
  20930. , a = i.intersectPlane(r)
  20931. , o = n.intersectPlane(r)
  20932. , s = a.dist(o) / e.viewGL.rootNode.scale.x;
  20933. this._groundMesh.scale.set(s, s, 1)
  20934. }
  20935. },
  20936. dispose: function (e, t) {
  20937. this._zrLayer && this._zrLayer.dispose(),
  20938. t.getZr().painter.delLayer(-1e3)
  20939. }
  20940. });
  20941. var Ou = Po.mat4
  20942. , Nu = 512
  20943. , Iu = .6435011087932844
  20944. , Ru = Math.PI
  20945. , Bu = .1;
  20946. function Fu() {
  20947. this.width = 0,
  20948. this.height = 0,
  20949. this.altitudeScale = 1,
  20950. this.boxHeight = "auto",
  20951. this.altitudeExtent,
  20952. this.bearing = 0,
  20953. this.pitch = 0,
  20954. this.center = [0, 0],
  20955. this._origin,
  20956. this.zoom = 0,
  20957. this._initialZoom,
  20958. this.maxPitch = 60,
  20959. this.zoomOffset = 0
  20960. }
  20961. Fu.prototype = {
  20962. constructor: Fu,
  20963. dimensions: ["lng", "lat", "alt"],
  20964. containPoint: function () { },
  20965. setCameraOption: function (e) {
  20966. this.bearing = e.bearing,
  20967. this.pitch = e.pitch,
  20968. this.center = e.center,
  20969. this.zoom = e.zoom,
  20970. this._origin || (this._origin = this.projectOnTileWithScale(this.center, Nu)),
  20971. null == this._initialZoom && (this._initialZoom = this.zoom),
  20972. this.updateTransform()
  20973. },
  20974. updateTransform: function () {
  20975. if (this.height) {
  20976. var e = .5 / Math.tan(Iu / 2) * this.height * Bu
  20977. , t = Math.max(Math.min(this.pitch, this.maxPitch), 0) / 180 * Math.PI
  20978. , r = Iu / 2
  20979. , i = Math.PI / 2 + t
  20980. , n = Math.sin(r) * e / Math.sin(Math.PI - i - r)
  20981. , a = 1.1 * (Math.cos(Math.PI / 2 - t) * n + e);
  20982. this.pitch > 50 && (a = 1e3);
  20983. var o = [];
  20984. Ou.perspective(o, Iu, this.width / this.height, 1, a),
  20985. this.viewGL.camera.projectionMatrix.setArray(o),
  20986. this.viewGL.camera.decomposeProjectionMatrix(),
  20987. o = Ou.identity([]);
  20988. var s = this.dataToPoint(this.center);
  20989. Ou.scale(o, o, [1, -1, 1]),
  20990. Ou.translate(o, o, [0, 0, -e]),
  20991. Ou.rotateX(o, o, t),
  20992. Ou.rotateZ(o, o, -this.bearing / 180 * Math.PI),
  20993. Ou.translate(o, o, [-s[0] * this.getScale() * Bu, -s[1] * this.getScale() * Bu, 0]),
  20994. this.viewGL.camera.viewMatrix.array = o;
  20995. var l = [];
  20996. Ou.invert(l, o),
  20997. this.viewGL.camera.worldTransform.array = l,
  20998. this.viewGL.camera.decomposeWorldTransform();
  20999. var h, u = Nu * this.getScale();
  21000. if (this.altitudeExtent && !isNaN(this.boxHeight)) {
  21001. var c = this.altitudeExtent[1] - this.altitudeExtent[0];
  21002. h = this.boxHeight / c * this.getScale() / Math.pow(2, this._initialZoom - this.zoomOffset)
  21003. } else
  21004. h = u / (2 * Math.PI * 6378e3 * Math.abs(Math.cos(this.center[1] * (Math.PI / 180)))) * this.altitudeScale * Bu;
  21005. this.viewGL.rootNode.scale.set(this.getScale() * Bu, this.getScale() * Bu, h)
  21006. }
  21007. },
  21008. getScale: function () {
  21009. return Math.pow(2, this.zoom - this.zoomOffset)
  21010. },
  21011. projectOnTile: function (e, t) {
  21012. return this.projectOnTileWithScale(e, this.getScale() * Nu, t)
  21013. },
  21014. projectOnTileWithScale: function (e, t, r) {
  21015. var i = e[0]
  21016. , n = e[1] * Ru / 180
  21017. , a = t * (i * Ru / 180 + Ru) / (2 * Ru)
  21018. , o = t * (Ru - Math.log(Math.tan(Ru / 4 + .5 * n))) / (2 * Ru);
  21019. return (r = r || [])[0] = a,
  21020. r[1] = o,
  21021. r
  21022. },
  21023. unprojectFromTile: function (e, t) {
  21024. return this.unprojectOnTileWithScale(e, this.getScale() * Nu, t)
  21025. },
  21026. unprojectOnTileWithScale: function (e, t, r) {
  21027. var i = e[0]
  21028. , n = e[1]
  21029. , a = i / t * (2 * Ru) - Ru
  21030. , o = 2 * (Math.atan(Math.exp(Ru - n / t * (2 * Ru))) - Ru / 4);
  21031. return (r = r || [])[0] = 180 * a / Ru,
  21032. r[1] = 180 * o / Ru,
  21033. r
  21034. },
  21035. dataToPoint: function (e, t) {
  21036. return (t = this.projectOnTileWithScale(e, Nu, t))[0] -= this._origin[0],
  21037. t[1] -= this._origin[1],
  21038. t[2] = isNaN(e[2]) ? 0 : e[2],
  21039. isNaN(e[2]) || (t[2] = e[2],
  21040. this.altitudeExtent && (t[2] -= this.altitudeExtent[0])),
  21041. t
  21042. }
  21043. };
  21044. const zu = Fu;
  21045. function Gu() {
  21046. zu.apply(this, arguments)
  21047. }
  21048. function Uu(e, t, r) {
  21049. function i(e, t) {
  21050. var r = t.getWidth()
  21051. , i = t.getHeight()
  21052. , n = t.getDevicePixelRatio();
  21053. this.viewGL.setViewport(0, 0, r, i, n),
  21054. this.width = r,
  21055. this.height = i,
  21056. this.altitudeScale = e.get("altitudeScale"),
  21057. this.boxHeight = e.get("boxHeight")
  21058. }
  21059. function n(e, t) {
  21060. if ("auto" !== this.model.get("boxHeight")) {
  21061. var r = [1 / 0, -1 / 0];
  21062. e.eachSeries((function (e) {
  21063. if (e.coordinateSystem === this) {
  21064. var t = e.getData()
  21065. , i = e.coordDimToDataDim("alt")[0];
  21066. if (i) {
  21067. var n = t.getDataExtent(i, !0);
  21068. r[0] = Math.min(r[0], n[0]),
  21069. r[1] = Math.max(r[1], n[1])
  21070. }
  21071. }
  21072. }
  21073. ), this),
  21074. r && isFinite(r[1] - r[0]) && (this.altitudeExtent = r)
  21075. }
  21076. }
  21077. return {
  21078. dimensions: t.prototype.dimensions,
  21079. create: function (a, o) {
  21080. var s = [];
  21081. return a.eachComponent(e, (function (e) {
  21082. var r = e.__viewGL;
  21083. r || (r = e.__viewGL = new Il).setRootNode(new Ka.Node);
  21084. var a = new t;
  21085. a.viewGL = e.__viewGL,
  21086. a.resize = i,
  21087. a.resize(e, o),
  21088. s.push(a),
  21089. e.coordinateSystem = a,
  21090. a.model = e,
  21091. a.update = n
  21092. }
  21093. )),
  21094. a.eachSeries((function (t) {
  21095. if (t.get("coordinateSystem") === e) {
  21096. var r = t.getReferringComponents(e).models[0];
  21097. if (r || (r = a.getComponent(e)),
  21098. !r)
  21099. throw new Error(e + ' "' + Mn(t.get(e + "Index"), t.get(e + "Id"), 0) + '" not found');
  21100. t.coordinateSystem = r.coordinateSystem
  21101. }
  21102. }
  21103. )),
  21104. r && r(s, a, o),
  21105. s
  21106. }
  21107. }
  21108. }
  21109. Gu.prototype = new zu,
  21110. Gu.prototype.constructor = Gu,
  21111. Gu.prototype.type = "mapbox3D";
  21112. const ku = Uu("mapbox3D", Gu, (function (e) {
  21113. e.forEach((function (e) {
  21114. e.setCameraOption(e.model.getMapboxCameraOption())
  21115. }
  21116. ))
  21117. }
  21118. ));
  21119. (0,
  21120. i.use)((function (e) {
  21121. e.registerComponentModel(Au),
  21122. e.registerComponentView(Pu),
  21123. e.registerCoordinateSystem("mapbox3D", ku),
  21124. e.registerAction({
  21125. type: "mapbox3DChangeCamera",
  21126. event: "mapbox3dcamerachanged",
  21127. update: "mapbox3D:updateCamera"
  21128. }, (function (e, t) {
  21129. t.eachComponent({
  21130. mainType: "mapbox3D",
  21131. query: e
  21132. }, (function (t) {
  21133. t.setMapboxCameraOption(e)
  21134. }
  21135. ))
  21136. }
  21137. ))
  21138. }
  21139. ));
  21140. var Vu = ["zoom", "center", "pitch", "bearing"]
  21141. , Hu = i.ComponentModel.extend({
  21142. type: "maptalks3D",
  21143. layoutMode: "box",
  21144. coordinateSystem: null,
  21145. defaultOption: {
  21146. zlevel: -10,
  21147. urlTemplate: "http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",
  21148. attribution: '&copy; <a href="http://osm.org">OpenStreetMap</a> contributors, &copy; <a href="https://carto.com/">CARTO</a>',
  21149. center: [0, 0],
  21150. zoom: 0,
  21151. pitch: 0,
  21152. bearing: 0,
  21153. light: {
  21154. main: {
  21155. alpha: 20,
  21156. beta: 30
  21157. }
  21158. },
  21159. altitudeScale: 1,
  21160. boxHeight: "auto"
  21161. },
  21162. getMaptalksCameraOption: function () {
  21163. var e = this;
  21164. return Vu.reduce((function (t, r) {
  21165. return t[r] = e.get(r),
  21166. t
  21167. }
  21168. ), {})
  21169. },
  21170. setMaptalksCameraOption: function (e) {
  21171. null != e && Vu.forEach((function (t) {
  21172. null != e[t] && (this.option[t] = e[t])
  21173. }
  21174. ), this)
  21175. },
  21176. getMaptalks: function () {
  21177. return this._maptalks
  21178. },
  21179. setMaptalks: function (e) {
  21180. this._maptalks = e
  21181. }
  21182. });
  21183. i.util.merge(Hu.prototype, co),
  21184. i.util.merge(Hu.prototype, fo);
  21185. const Wu = Hu;
  21186. function ju(e, t, r, i) {
  21187. if (this.id = e,
  21188. this.zr = t,
  21189. this.dom = document.createElement("div"),
  21190. this.dom.style.cssText = "position:absolute;left:0;right:0;top:0;bottom:0;",
  21191. !maptalks)
  21192. throw new Error("Maptalks library must be included. See https://maptalks.org");
  21193. this._maptalks = new maptalks.Map(this.dom, {
  21194. center: r,
  21195. zoom: i,
  21196. doubleClickZoom: !1,
  21197. fog: !1
  21198. }),
  21199. this._initEvents()
  21200. }
  21201. ju.prototype.setUnpainted = function () { }
  21202. ,
  21203. ju.prototype.resize = function () {
  21204. this._maptalks.checkSize()
  21205. }
  21206. ,
  21207. ju.prototype.getMaptalks = function () {
  21208. return this._maptalks
  21209. }
  21210. ,
  21211. ju.prototype.clear = function () { }
  21212. ,
  21213. ju.prototype.refresh = function () {
  21214. this._maptalks.checkSize()
  21215. }
  21216. ;
  21217. var Xu = ["mousedown", "mouseup", "click", "dblclick", "mousemove", "mousewheel", "DOMMouseScroll", "touchstart", "touchend", "touchmove", "touchcancel"];
  21218. ju.prototype._initEvents = function () {
  21219. var e = this.dom;
  21220. this._handlers = this._handlers || {
  21221. contextmenu: function (e) {
  21222. return e.preventDefault(),
  21223. !1
  21224. }
  21225. },
  21226. Xu.forEach((function (t) {
  21227. this._handlers[t] = function (r) {
  21228. var i = {};
  21229. for (var n in r)
  21230. i[n] = r[n];
  21231. i.bubbles = !1;
  21232. var a = new r.constructor(r.type, i);
  21233. "mousewheel" === t || "DOMMouseScroll" === t ? e.dispatchEvent(a) : e.firstElementChild.dispatchEvent(a)
  21234. }
  21235. ,
  21236. this.zr.dom.addEventListener(t, this._handlers[t])
  21237. }
  21238. ), this),
  21239. this.zr.dom.addEventListener("contextmenu", this._handlers.contextmenu)
  21240. }
  21241. ,
  21242. ju.prototype.dispose = function () {
  21243. Xu.forEach((function (e) {
  21244. this.zr.dom.removeEventListener(e, this._handlers[e])
  21245. }
  21246. ), this),
  21247. this._maptalks.remove()
  21248. }
  21249. ;
  21250. const qu = ju;
  21251. Ka.Shader.import(Lu);
  21252. const Zu = i.ComponentView.extend({
  21253. type: "maptalks3D",
  21254. __ecgl__: !0,
  21255. init: function (e, t) {
  21256. this._groundMesh = new Ka.Mesh({
  21257. geometry: new Ka.PlaneGeometry,
  21258. material: new Ka.Material({
  21259. shader: new Ka.Shader({
  21260. vertex: Ka.Shader.source("ecgl.displayShadow.vertex"),
  21261. fragment: Ka.Shader.source("ecgl.displayShadow.fragment")
  21262. }),
  21263. depthMask: !1
  21264. }),
  21265. renderOrder: -100,
  21266. culling: !1,
  21267. castShadow: !1,
  21268. $ignorePicking: !0,
  21269. renderNormal: !0
  21270. })
  21271. },
  21272. _initMaptalksLayer: function (e, t) {
  21273. var r = t.getZr();
  21274. this._zrLayer = new qu("maptalks3D", r, e.get("center"), e.get("zoom")),
  21275. r.painter.insertLayer(-1e3, this._zrLayer),
  21276. this._lightRoot = new Ka.Node,
  21277. this._sceneHelper = new Uo(this._lightRoot),
  21278. this._sceneHelper.initLight(this._lightRoot);
  21279. var i = this._zrLayer.getMaptalks()
  21280. , n = this._dispatchInteractAction.bind(this, t, i);
  21281. ["zoomend", "zooming", "zoomstart", "dragrotating", "pitch", "pitchend", "movestart", "moving", "moveend", "resize", "touchstart", "touchmove", "touchend", "animating"].forEach((function (e) {
  21282. i.on(e, n)
  21283. }
  21284. ))
  21285. },
  21286. render: function (e, t, r) {
  21287. this._zrLayer || this._initMaptalksLayer(e, r);
  21288. var i = this._zrLayer.getMaptalks()
  21289. , n = e.get("urlTemplate")
  21290. , a = i.getBaseLayer();
  21291. n !== this._oldUrlTemplate && (a ? a.setOptions({
  21292. urlTemplate: n,
  21293. attribution: e.get("attribution")
  21294. }) : (a = new maptalks.TileLayer("maptalks-echarts-gl-baselayer", {
  21295. urlTemplate: n,
  21296. subdomains: ["a", "b", "c"],
  21297. attribution: e.get("attribution")
  21298. }),
  21299. i.setBaseLayer(a))),
  21300. this._oldUrlTemplate = n,
  21301. i.setCenter(e.get("center")),
  21302. i.setZoom(e.get("zoom"), {
  21303. animation: !1
  21304. }),
  21305. i.setPitch(e.get("pitch")),
  21306. i.setBearing(e.get("bearing")),
  21307. e.setMaptalks(i);
  21308. var o = e.coordinateSystem;
  21309. o.viewGL.scene.add(this._lightRoot),
  21310. o.viewGL.add(this._groundMesh),
  21311. this._updateGroundMesh(),
  21312. this._sceneHelper.setScene(o.viewGL.scene),
  21313. this._sceneHelper.updateLight(e),
  21314. o.viewGL.setPostEffect(e.getModel("postEffect"), r),
  21315. o.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),
  21316. this._maptalks3DModel = e
  21317. },
  21318. afterRender: function (e, t, r, i) {
  21319. var n = i.renderer;
  21320. this._sceneHelper.updateAmbientCubemap(n, e, r),
  21321. this._sceneHelper.updateSkybox(n, e, r),
  21322. e.coordinateSystem.viewGL.scene.traverse((function (e) {
  21323. e.material && (e.material.define("fragment", "NORMAL_UP_AXIS", 2),
  21324. e.material.define("fragment", "NORMAL_FRONT_AXIS", 1))
  21325. }
  21326. ))
  21327. },
  21328. updateCamera: function (e, t, r, i) {
  21329. e.coordinateSystem.setCameraOption(i),
  21330. this._updateGroundMesh(),
  21331. r.getZr().refresh()
  21332. },
  21333. _dispatchInteractAction: function (e, t, r) {
  21334. var i;
  21335. e.dispatchAction({
  21336. type: "maptalks3DChangeCamera",
  21337. pitch: t.getPitch(),
  21338. zoom: (i = t.getResolution(),
  21339. 19 - Math.log(i / Yu) / Math.LN2 + 1),
  21340. center: t.getCenter().toArray(),
  21341. bearing: t.getBearing(),
  21342. maptalks3DId: this._maptalks3DModel && this._maptalks3DModel.id
  21343. })
  21344. },
  21345. _updateGroundMesh: function () {
  21346. if (this._maptalks3DModel) {
  21347. var e = this._maptalks3DModel.coordinateSystem
  21348. , t = e.dataToPoint(e.center);
  21349. this._groundMesh.position.set(t[0], t[1], -.001);
  21350. var r = new Ka.Plane(new Ka.Vector3(0, 0, 1), 0)
  21351. , i = e.viewGL.camera.castRay(new Ka.Vector2(-1, -1))
  21352. , n = e.viewGL.camera.castRay(new Ka.Vector2(1, 1))
  21353. , a = i.intersectPlane(r)
  21354. , o = n.intersectPlane(r)
  21355. , s = a.dist(o) / e.viewGL.rootNode.scale.x;
  21356. this._groundMesh.scale.set(s, s, 1)
  21357. }
  21358. },
  21359. dispose: function (e, t) {
  21360. this._zrLayer && this._zrLayer.dispose(),
  21361. t.getZr().painter.delLayer(-1e3)
  21362. }
  21363. })
  21364. , Yu = 12756274 * Math.PI / (256 * Math.pow(2, 20));
  21365. function Ku() {
  21366. zu.apply(this, arguments),
  21367. this.maxPitch = 85,
  21368. this.zoomOffset = 1
  21369. }
  21370. Ku.prototype = new zu,
  21371. Ku.prototype.constructor = Ku,
  21372. Ku.prototype.type = "maptalks3D";
  21373. const Qu = Uu("maptalks3D", Ku, (function (e) {
  21374. e.forEach((function (e) {
  21375. e.setCameraOption(e.model.getMaptalksCameraOption())
  21376. }
  21377. ))
  21378. }
  21379. ));
  21380. (0,
  21381. i.use)((function (e) {
  21382. e.registerComponentModel(Wu),
  21383. e.registerComponentView(Zu),
  21384. e.registerCoordinateSystem("maptalks3D", Qu),
  21385. e.registerAction({
  21386. type: "maptalks3DChangeCamera",
  21387. event: "maptalks3dcamerachanged",
  21388. update: "maptalks3D:updateCamera"
  21389. }, (function (e, t) {
  21390. t.eachComponent({
  21391. mainType: "maptalks3D",
  21392. query: e
  21393. }, (function (t) {
  21394. t.setMaptalksCameraOption(e)
  21395. }
  21396. ))
  21397. }
  21398. ))
  21399. }
  21400. ));
  21401. var Ju = Po.vec3
  21402. , $u = i.helper.dataStack.isDimensionStacked;
  21403. function ec(e, t, r) {
  21404. for (var i = e.getDataExtent(t), n = e.getDataExtent(r), a = i[1] - i[0] || i[0], o = n[1] - n[0] || n[0], s = new Uint8Array(2500), l = 0; l < e.count(); l++) {
  21405. var h = e.get(t, l)
  21406. , u = e.get(r, l)
  21407. , c = Math.floor((h - i[0]) / a * 49)
  21408. , d = 50 * Math.floor((u - n[0]) / o * 49) + c;
  21409. s[d] = s[d] || 1
  21410. }
  21411. var f = 0;
  21412. for (l = 0; l < s.length; l++)
  21413. s[l] && f++;
  21414. return f / s.length
  21415. }
  21416. var tc = Po.vec3
  21417. , rc = i.helper.dataStack.isDimensionStacked;
  21418. function ic(e, t) {
  21419. var r = rc(e, t[2]);
  21420. return {
  21421. dimension: r ? e.getCalculationInfo("stackResultDimension") : t[2],
  21422. isStacked: r
  21423. }
  21424. }
  21425. function nc(e) {
  21426. e.registerLayout((function (e, t) {
  21427. e.eachSeriesByType("bar3D", (function (e) {
  21428. var t = e.coordinateSystem
  21429. , r = t && t.type;
  21430. "globe" === r ? function (e, t) {
  21431. var r = e.getData()
  21432. , n = e.get("minHeight") || 0
  21433. , a = e.get("barSize")
  21434. , o = ["lng", "lat", "alt"].map((function (t) {
  21435. return e.coordDimToDataDim(t)[0]
  21436. }
  21437. ));
  21438. if (null == a) {
  21439. var s = t.radius * Math.PI
  21440. , l = ec(r, o[0], o[1]);
  21441. a = [s / Math.sqrt(r.count() / l), s / Math.sqrt(r.count() / l)]
  21442. } else
  21443. i.util.isArray(a) || (a = [a, a]);
  21444. var h = ic(r, o);
  21445. r.each(o, (function (e, i, o, s) {
  21446. var l = r.get(h.dimension, s)
  21447. , u = h.isStacked ? l - o : t.altitudeAxis.scale.getExtent()[0]
  21448. , c = Math.max(t.altitudeAxis.dataToCoord(o), n)
  21449. , d = t.dataToPoint([e, i, u])
  21450. , f = t.dataToPoint([e, i, l])
  21451. , p = tc.sub([], f, d);
  21452. tc.normalize(p, p);
  21453. var m = [a[0], c, a[1]];
  21454. r.setItemLayout(s, [d, p, m])
  21455. }
  21456. )),
  21457. r.setLayout("orient", vt.UP.array)
  21458. }(e, t) : "cartesian3D" === r ? function (e, t) {
  21459. var r = e.getData()
  21460. , n = e.get("barSize");
  21461. if (null == n) {
  21462. var a, o, s = t.size, l = t.getAxis("x"), h = t.getAxis("y");
  21463. a = "category" === l.type ? .7 * l.getBandWidth() : .6 * Math.round(s[0] / Math.sqrt(r.count())),
  21464. o = "category" === h.type ? .7 * h.getBandWidth() : .6 * Math.round(s[1] / Math.sqrt(r.count())),
  21465. n = [a, o]
  21466. } else
  21467. i.util.isArray(n) || (n = [n, n]);
  21468. var u, c, d, f = t.getAxis("z").scale.getExtent(), p = (c = (u = f)[0],
  21469. d = u[1],
  21470. !(c > 0 && d > 0 || c < 0 && d < 0)), m = ["x", "y", "z"].map((function (t) {
  21471. return e.coordDimToDataDim(t)[0]
  21472. }
  21473. )), g = $u(r, m[2]), _ = g ? r.getCalculationInfo("stackResultDimension") : m[2];
  21474. r.each(m, (function (e, i, a, o) {
  21475. var s = r.get(_, o)
  21476. , l = g ? s - a : p ? 0 : f[0]
  21477. , h = t.dataToPoint([e, i, l])
  21478. , u = t.dataToPoint([e, i, s])
  21479. , c = Ju.dist(h, u)
  21480. , d = [0, u[1] < h[1] ? -1 : 1, 0];
  21481. 0 === Math.abs(c) && (c = .1);
  21482. var m = [n[0], c, n[1]];
  21483. r.setItemLayout(o, [h, d, m])
  21484. }
  21485. )),
  21486. r.setLayout("orient", [1, 0, 0])
  21487. }(e, t) : "geo3D" === r ? function (e, t) {
  21488. var r = e.getData()
  21489. , n = e.get("barSize")
  21490. , a = e.get("minHeight") || 0
  21491. , o = ["lng", "lat", "alt"].map((function (t) {
  21492. return e.coordDimToDataDim(t)[0]
  21493. }
  21494. ));
  21495. if (null == n) {
  21496. var s = Math.min(t.size[0], t.size[2])
  21497. , l = ec(r, o[0], o[1]);
  21498. n = [s / Math.sqrt(r.count() / l), s / Math.sqrt(r.count() / l)]
  21499. } else
  21500. i.util.isArray(n) || (n = [n, n]);
  21501. var h = [0, 1, 0]
  21502. , u = ic(r, o);
  21503. r.each(o, (function (e, i, o, s) {
  21504. var l = r.get(u.dimension, s)
  21505. , c = u.isStacked ? l - o : t.altitudeAxis.scale.getExtent()[0]
  21506. , d = Math.max(t.altitudeAxis.dataToCoord(o), a)
  21507. , f = t.dataToPoint([e, i, c])
  21508. , p = [n[0], d, n[1]];
  21509. r.setItemLayout(s, [f, h, p])
  21510. }
  21511. )),
  21512. r.setLayout("orient", [1, 0, 0])
  21513. }(e, t) : ("mapbox3D" === r || "maptalks3D" === r) && function (e, t) {
  21514. var r = e.getData()
  21515. , n = e.coordDimToDataDim("lng")[0]
  21516. , a = e.coordDimToDataDim("lat")[0]
  21517. , o = e.coordDimToDataDim("alt")[0]
  21518. , s = e.get("barSize")
  21519. , l = e.get("minHeight") || 0;
  21520. if (null == s) {
  21521. var h = r.getDataExtent(n)
  21522. , u = r.getDataExtent(a)
  21523. , c = t.dataToPoint([h[0], u[0]])
  21524. , d = t.dataToPoint([h[1], u[1]])
  21525. , f = Math.min(Math.abs(c[0] - d[0]), Math.abs(c[1] - d[1])) || 1
  21526. , p = ec(r, n, a);
  21527. s = [f / Math.sqrt(r.count() / p), f / Math.sqrt(r.count() / p)]
  21528. } else
  21529. i.util.isArray(s) || (s = [s, s]),
  21530. s[0] /= t.getScale() / 16,
  21531. s[1] /= t.getScale() / 16;
  21532. var m = [0, 0, 1]
  21533. , g = [n, a, o]
  21534. , _ = ic(r, g);
  21535. r.each(g, (function (e, i, n, a) {
  21536. var o = r.get(_.dimension, a)
  21537. , h = _.isStacked ? o - n : 0
  21538. , u = t.dataToPoint([e, i, h])
  21539. , c = t.dataToPoint([e, i, o])
  21540. , d = Math.max(c[2] - u[2], l)
  21541. , f = [s[0], d, s[1]];
  21542. r.setItemLayout(a, [u, m, f])
  21543. }
  21544. )),
  21545. r.setLayout("orient", [1, 0, 0])
  21546. }(e, t)
  21547. }
  21548. ))
  21549. }
  21550. ))
  21551. }
  21552. const ac = {
  21553. getFormattedLabel: function (e, t, r, n, a) {
  21554. r = r || "normal";
  21555. var o = e.getData(n).getItemModel(t)
  21556. , s = e.getDataParams(t, n);
  21557. null != a && s.value instanceof Array && (s.value = s.value[a]);
  21558. var l, h = o.get("normal" === r ? ["label", "formatter"] : ["emphasis", "label", "formatter"]);
  21559. return null == h && (h = o.get(["label", "formatter"])),
  21560. "function" == typeof h ? (s.status = r,
  21561. l = h(s)) : "string" == typeof h && (l = i.format.formatTpl(h, s)),
  21562. l
  21563. },
  21564. normalizeToArray: function (e) {
  21565. return e instanceof Array ? e : null == e ? [] : [e]
  21566. }
  21567. };
  21568. function oc(e, t, r) {
  21569. var n = e.getData()
  21570. , a = e.getRawValue(t)
  21571. , o = i.util.isArray(a) ? function (e) {
  21572. var a = []
  21573. , o = function (e, t) {
  21574. var r = [];
  21575. return i.util.each(e.dimensions, (function (t) {
  21576. var i = e.getDimensionInfo(t)
  21577. , n = i.otherDims.tooltip;
  21578. null != n && !1 !== n && (r[n] = i.name)
  21579. }
  21580. )),
  21581. r
  21582. }(n);
  21583. function s(e, t) {
  21584. var o = n.getDimensionInfo(t);
  21585. if (o && !1 !== o.otherDims.tooltip) {
  21586. var s = o.type
  21587. , l = "- " + (o.tooltipName || o.name) + ": " + ("ordinal" === s ? e + "" : "time" === s ? r ? "" : i.format.formatTime("yyyy/MM/dd hh:mm:ss", e) : i.format.addCommas(e));
  21588. l && a.push(i.format.encodeHTML(l))
  21589. }
  21590. }
  21591. return o.length ? i.util.each(o, (function (e) {
  21592. s(n.get(e, t), e)
  21593. }
  21594. )) : i.util.each(e, s),
  21595. "<br/>" + a.join("<br/>")
  21596. }(a) : i.format.encodeHTML(i.format.addCommas(a))
  21597. , s = n.getName(t)
  21598. , l = Ih(n, t);
  21599. i.util.isObject(l) && l.colorStops && (l = (l.colorStops[0] || {}).color),
  21600. l = l || "transparent";
  21601. var h = i.format.getTooltipMarker(l)
  21602. , u = e.name;
  21603. return "\0-" === u && (u = ""),
  21604. u = u ? i.format.encodeHTML(u) + (r ? ": " : "<br/>") : "",
  21605. r ? h + u + o : u + h + (s ? i.format.encodeHTML(s) + ": " + o : o)
  21606. }
  21607. function sc(e, t, r) {
  21608. r = r || e.getSource();
  21609. var n = t || i.getCoordinateSystemDimensions(e.get("coordinateSystem")) || ["x", "y", "z"]
  21610. , a = i.helper.createDimensions(r, {
  21611. dimensionsDefine: r.dimensionsDefine || e.get("dimensions"),
  21612. encodeDefine: r.encodeDefine || e.get("encode"),
  21613. coordDimensions: n.map((function (t) {
  21614. var r = e.getReferringComponents(t + "Axis3D").models[0];
  21615. return {
  21616. type: r && "category" === r.get("type") ? "ordinal" : "float",
  21617. name: t
  21618. }
  21619. }
  21620. ))
  21621. });
  21622. "cartesian3D" === e.get("coordinateSystem") && a.forEach((function (t) {
  21623. if (n.indexOf(t.coordDim) >= 0) {
  21624. var r = e.getReferringComponents(t.coordDim + "Axis3D").models[0];
  21625. r && "category" === r.get("type") && (t.ordinalMeta = r.getOrdinalMeta())
  21626. }
  21627. }
  21628. ));
  21629. var o = i.helper.dataStack.enableDataStack(e, a, {
  21630. byIndex: !0,
  21631. stackedCoordDimension: "z"
  21632. })
  21633. , s = new i.List(a, e);
  21634. return s.setCalculationInfo(o),
  21635. s.initData(r),
  21636. s
  21637. }
  21638. var lc = i.SeriesModel.extend({
  21639. type: "series.bar3D",
  21640. dependencies: ["globe"],
  21641. visualStyleAccessPathvisu: "itemStyle",
  21642. getInitialData: function (e, t) {
  21643. return sc(this)
  21644. },
  21645. getFormattedLabel: function (e, t, r, i) {
  21646. var n = ac.getFormattedLabel(this, e, t, r, i);
  21647. return null == n && (n = this.getData().get("z", e)),
  21648. n
  21649. },
  21650. formatTooltip: function (e) {
  21651. return oc(this, e)
  21652. },
  21653. defaultOption: {
  21654. coordinateSystem: "cartesian3D",
  21655. globeIndex: 0,
  21656. grid3DIndex: 0,
  21657. zlevel: -10,
  21658. bevelSize: 0,
  21659. bevelSmoothness: 2,
  21660. onGridPlane: "xy",
  21661. shading: "color",
  21662. minHeight: 0,
  21663. itemStyle: {
  21664. opacity: 1
  21665. },
  21666. label: {
  21667. show: !1,
  21668. distance: 2,
  21669. textStyle: {
  21670. fontSize: 14,
  21671. color: "#000",
  21672. backgroundColor: "rgba(255,255,255,0.7)",
  21673. padding: 3,
  21674. borderRadius: 3
  21675. }
  21676. },
  21677. emphasis: {
  21678. label: {
  21679. show: !0
  21680. }
  21681. },
  21682. animationDurationUpdate: 500
  21683. }
  21684. });
  21685. i.util.merge(lc.prototype, Kl);
  21686. const hc = lc;
  21687. var uc, cc, dc, fc, pc, mc, gc, _c, vc = Po.vec3, yc = Po.mat3, xc = Vr.extend((function () {
  21688. return {
  21689. attributes: {
  21690. position: new Vr.Attribute("position", "float", 3, "POSITION"),
  21691. normal: new Vr.Attribute("normal", "float", 3, "NORMAL"),
  21692. color: new Vr.Attribute("color", "float", 4, "COLOR"),
  21693. prevPosition: new Vr.Attribute("prevPosition", "float", 3),
  21694. prevNormal: new Vr.Attribute("prevNormal", "float", 3)
  21695. },
  21696. dynamic: !0,
  21697. enableNormal: !1,
  21698. bevelSize: 1,
  21699. bevelSegments: 0,
  21700. _dataIndices: null,
  21701. _vertexOffset: 0,
  21702. _triangleOffset: 0
  21703. }
  21704. }
  21705. ), {
  21706. resetOffset: function () {
  21707. this._vertexOffset = 0,
  21708. this._triangleOffset = 0
  21709. },
  21710. setBarCount: function (e) {
  21711. var t = this.enableNormal
  21712. , r = this.getBarVertexCount() * e
  21713. , i = this.getBarTriangleCount() * e;
  21714. this.vertexCount !== r && (this.attributes.position.init(r),
  21715. t ? this.attributes.normal.init(r) : this.attributes.normal.value = null,
  21716. this.attributes.color.init(r)),
  21717. this.triangleCount !== i && (this.indices = r > 65535 ? new Uint32Array(3 * i) : new Uint16Array(3 * i),
  21718. this._dataIndices = new Uint32Array(r))
  21719. },
  21720. getBarVertexCount: function () {
  21721. var e = this.bevelSize > 0 ? this.bevelSegments : 0;
  21722. return e > 0 ? this._getBevelBarVertexCount(e) : this.enableNormal ? 24 : 8
  21723. },
  21724. getBarTriangleCount: function () {
  21725. var e = this.bevelSize > 0 ? this.bevelSegments : 0;
  21726. return e > 0 ? this._getBevelBarTriangleCount(e) : 12
  21727. },
  21728. _getBevelBarVertexCount: function (e) {
  21729. return 4 * (e + 1) * (e + 1) * 2
  21730. },
  21731. _getBevelBarTriangleCount: function (e) {
  21732. return (4 * e + 3 + 1) * (2 * e + 1) * 2 + 4
  21733. },
  21734. setColor: function (e, t) {
  21735. for (var r = this.getBarVertexCount(), i = r * (e + 1), n = r * e; n < i; n++)
  21736. this.attributes.color.set(n, t);
  21737. this.dirtyAttribute("color")
  21738. },
  21739. getDataIndexOfVertex: function (e) {
  21740. return this._dataIndices ? this._dataIndices[e] : null
  21741. },
  21742. addBar: function () {
  21743. for (var e = vc.create, t = vc.scaleAndAdd, r = e(), i = e(), n = e(), a = e(), o = e(), s = e(), l = e(), h = [], u = [], c = 0; c < 8; c++)
  21744. h[c] = e();
  21745. var d = [[0, 1, 5, 4], [2, 3, 7, 6], [4, 5, 6, 7], [3, 2, 1, 0], [0, 4, 7, 3], [1, 2, 6, 5]]
  21746. , f = [0, 1, 2, 0, 2, 3]
  21747. , p = [];
  21748. for (c = 0; c < d.length; c++)
  21749. for (var m = d[c], g = 0; g < 2; g++) {
  21750. for (var _ = [], v = 0; v < 3; v++)
  21751. _.push(m[f[3 * g + v]]);
  21752. p.push(_)
  21753. }
  21754. return function (e, c, m, g, _, v) {
  21755. var y = this._vertexOffset;
  21756. if (this.bevelSize > 0 && this.bevelSegments > 0)
  21757. this._addBevelBar(e, c, m, g, this.bevelSize, this.bevelSegments, _);
  21758. else {
  21759. vc.copy(n, c),
  21760. vc.normalize(n, n),
  21761. vc.cross(a, m, n),
  21762. vc.normalize(a, a),
  21763. vc.cross(i, n, a),
  21764. vc.normalize(a, a),
  21765. vc.negate(o, i),
  21766. vc.negate(s, n),
  21767. vc.negate(l, a),
  21768. t(h[0], e, i, g[0] / 2),
  21769. t(h[0], h[0], a, g[2] / 2),
  21770. t(h[1], e, i, g[0] / 2),
  21771. t(h[1], h[1], l, g[2] / 2),
  21772. t(h[2], e, o, g[0] / 2),
  21773. t(h[2], h[2], l, g[2] / 2),
  21774. t(h[3], e, o, g[0] / 2),
  21775. t(h[3], h[3], a, g[2] / 2),
  21776. t(r, e, n, g[1]),
  21777. t(h[4], r, i, g[0] / 2),
  21778. t(h[4], h[4], a, g[2] / 2),
  21779. t(h[5], r, i, g[0] / 2),
  21780. t(h[5], h[5], l, g[2] / 2),
  21781. t(h[6], r, o, g[0] / 2),
  21782. t(h[6], h[6], l, g[2] / 2),
  21783. t(h[7], r, o, g[0] / 2),
  21784. t(h[7], h[7], a, g[2] / 2);
  21785. var x = this.attributes;
  21786. if (this.enableNormal) {
  21787. u[0] = i,
  21788. u[1] = o,
  21789. u[2] = n,
  21790. u[3] = s,
  21791. u[4] = a,
  21792. u[5] = l;
  21793. for (var b = this._vertexOffset, w = 0; w < d.length; w++) {
  21794. for (var T = 3 * this._triangleOffset, S = 0; S < 6; S++)
  21795. this.indices[T++] = b + f[S];
  21796. b += 4,
  21797. this._triangleOffset += 2
  21798. }
  21799. for (w = 0; w < d.length; w++) {
  21800. var M = u[w];
  21801. for (S = 0; S < 4; S++) {
  21802. var A = d[w][S];
  21803. x.position.set(this._vertexOffset, h[A]),
  21804. x.normal.set(this._vertexOffset, M),
  21805. x.color.set(this._vertexOffset++, _)
  21806. }
  21807. }
  21808. } else {
  21809. for (w = 0; w < p.length; w++) {
  21810. for (T = 3 * this._triangleOffset,
  21811. S = 0; S < 3; S++)
  21812. this.indices[T + S] = p[w][S] + this._vertexOffset;
  21813. this._triangleOffset++
  21814. }
  21815. for (w = 0; w < h.length; w++)
  21816. x.position.set(this._vertexOffset, h[w]),
  21817. x.color.set(this._vertexOffset++, _)
  21818. }
  21819. }
  21820. var E = this._vertexOffset;
  21821. for (w = y; w < E; w++)
  21822. this._dataIndices[w] = v
  21823. }
  21824. }(),
  21825. _addBevelBar: (uc = vc.create(),
  21826. cc = vc.create(),
  21827. dc = vc.create(),
  21828. fc = yc.create(),
  21829. pc = [],
  21830. mc = [1, -1, -1, 1],
  21831. gc = [1, 1, -1, -1],
  21832. _c = [2, 0],
  21833. function (e, t, r, i, n, a, o) {
  21834. vc.copy(cc, t),
  21835. vc.normalize(cc, cc),
  21836. vc.cross(dc, r, cc),
  21837. vc.normalize(dc, dc),
  21838. vc.cross(uc, cc, dc),
  21839. vc.normalize(dc, dc),
  21840. fc[0] = uc[0],
  21841. fc[1] = uc[1],
  21842. fc[2] = uc[2],
  21843. fc[3] = cc[0],
  21844. fc[4] = cc[1],
  21845. fc[5] = cc[2],
  21846. fc[6] = dc[0],
  21847. fc[7] = dc[1],
  21848. fc[8] = dc[2],
  21849. n = Math.min(i[0], i[2]) / 2 * n;
  21850. for (var s = 0; s < 3; s++)
  21851. pc[s] = Math.max(i[s] - 2 * n, 0);
  21852. var l = (i[0] - pc[0]) / 2
  21853. , h = (i[1] - pc[1]) / 2
  21854. , u = (i[2] - pc[2]) / 2
  21855. , c = []
  21856. , d = []
  21857. , f = this._vertexOffset
  21858. , p = [];
  21859. for (s = 0; s < 2; s++) {
  21860. p[s] = p[s] = [];
  21861. for (var m = 0; m <= a; m++)
  21862. for (var g = 0; g < 4; g++) {
  21863. (0 === m && 0 === s || 1 === s && m === a) && p[s].push(f);
  21864. for (var _ = 0; _ <= a; _++) {
  21865. var v = _ / a * Math.PI / 2 + Math.PI / 2 * g
  21866. , y = m / a * Math.PI / 2 + Math.PI / 2 * s;
  21867. d[0] = l * Math.cos(v) * Math.sin(y),
  21868. d[1] = h * Math.cos(y),
  21869. d[2] = u * Math.sin(v) * Math.sin(y),
  21870. c[0] = d[0] + mc[g] * pc[0] / 2,
  21871. c[1] = d[1] + h + _c[s] * pc[1] / 2,
  21872. c[2] = d[2] + gc[g] * pc[2] / 2,
  21873. Math.abs(l - h) < 1e-6 && Math.abs(h - u) < 1e-6 || (d[0] /= l * l,
  21874. d[1] /= h * h,
  21875. d[2] /= u * u),
  21876. vc.normalize(d, d),
  21877. vc.transformMat3(c, c, fc),
  21878. vc.transformMat3(d, d, fc),
  21879. vc.add(c, c, e),
  21880. this.attributes.position.set(f, c),
  21881. this.enableNormal && this.attributes.normal.set(f, d),
  21882. this.attributes.color.set(f, o),
  21883. f++
  21884. }
  21885. }
  21886. }
  21887. var x = 4 * a + 3
  21888. , b = 2 * a + 1
  21889. , w = x + 1;
  21890. for (g = 0; g < b; g++)
  21891. for (s = 0; s <= x; s++) {
  21892. var T = g * w + s + this._vertexOffset
  21893. , S = g * w + (s + 1) % w + this._vertexOffset
  21894. , M = (g + 1) * w + (s + 1) % w + this._vertexOffset
  21895. , A = (g + 1) * w + s + this._vertexOffset;
  21896. this.setTriangleIndices(this._triangleOffset++, [M, T, S]),
  21897. this.setTriangleIndices(this._triangleOffset++, [M, A, T])
  21898. }
  21899. this.setTriangleIndices(this._triangleOffset++, [p[0][0], p[0][2], p[0][1]]),
  21900. this.setTriangleIndices(this._triangleOffset++, [p[0][0], p[0][3], p[0][2]]),
  21901. this.setTriangleIndices(this._triangleOffset++, [p[1][0], p[1][1], p[1][2]]),
  21902. this.setTriangleIndices(this._triangleOffset++, [p[1][0], p[1][2], p[1][3]]),
  21903. this._vertexOffset = f
  21904. }
  21905. )
  21906. });
  21907. i.util.defaults(xc.prototype, Lo),
  21908. i.util.defaults(xc.prototype, Nh);
  21909. const bc = xc;
  21910. var wc = Po.vec3;
  21911. const Tc = i.ChartView.extend({
  21912. type: "bar3D",
  21913. __ecgl__: !0,
  21914. init: function (e, t) {
  21915. this.groupGL = new Ka.Node,
  21916. this._api = t,
  21917. this._labelsBuilder = new Fh(256, 256, t);
  21918. var r = this;
  21919. this._labelsBuilder.getLabelPosition = function (e, t, i) {
  21920. if (r._data) {
  21921. var n = r._data.getItemLayout(e)
  21922. , a = n[0]
  21923. , o = n[1]
  21924. , s = n[2][1];
  21925. return wc.scaleAndAdd([], a, o, i + s)
  21926. }
  21927. return [0, 0]
  21928. }
  21929. ,
  21930. this._labelsBuilder.getMesh().renderOrder = 100
  21931. },
  21932. render: function (e, t, r) {
  21933. var i = this._prevBarMesh;
  21934. this._prevBarMesh = this._barMesh,
  21935. this._barMesh = i,
  21936. this._barMesh || (this._barMesh = new Ka.Mesh({
  21937. geometry: new bc,
  21938. shadowDepthMaterial: new Ka.Material({
  21939. shader: new Ka.Shader(Ka.Shader.source("ecgl.sm.depth.vertex"), Ka.Shader.source("ecgl.sm.depth.fragment"))
  21940. }),
  21941. culling: "cartesian3D" === e.coordinateSystem.type,
  21942. renderOrder: 10,
  21943. renderNormal: !0
  21944. })),
  21945. this.groupGL.remove(this._prevBarMesh),
  21946. this.groupGL.add(this._barMesh),
  21947. this.groupGL.add(this._labelsBuilder.getMesh());
  21948. var n = e.coordinateSystem;
  21949. if (this._doRender(e, r),
  21950. n && n.viewGL) {
  21951. n.viewGL.add(this.groupGL);
  21952. var a = n.viewGL.isLinearSpace() ? "define" : "undefine";
  21953. this._barMesh.material[a]("fragment", "SRGB_DECODE")
  21954. }
  21955. this._data = e.getData(),
  21956. this._labelsBuilder.updateData(this._data),
  21957. this._labelsBuilder.updateLabels(),
  21958. this._updateAnimation(e)
  21959. },
  21960. _updateAnimation: function (e) {
  21961. Ka.updateVertexAnimation([["prevPosition", "position"], ["prevNormal", "normal"]], this._prevBarMesh, this._barMesh, e)
  21962. },
  21963. _doRender: function (e, t) {
  21964. var r = e.getData()
  21965. , i = e.get("shading")
  21966. , n = "color" !== i
  21967. , a = this
  21968. , o = this._barMesh
  21969. , s = "ecgl." + i;
  21970. o.material && o.material.shader.name === s || (o.material = Ka.createMaterial(s, ["VERTEX_COLOR"])),
  21971. Ka.setMaterialFromModel(i, o.material, e, t),
  21972. o.geometry.enableNormal = n,
  21973. o.geometry.resetOffset();
  21974. var l = e.get("bevelSize")
  21975. , h = e.get("bevelSmoothness");
  21976. o.geometry.bevelSegments = h,
  21977. o.geometry.bevelSize = l;
  21978. var u = []
  21979. , c = new Float32Array(4 * r.count())
  21980. , d = 0
  21981. , f = 0
  21982. , p = !1;
  21983. r.each((function (e) {
  21984. if (r.hasValue(e)) {
  21985. var t = Ih(r, e)
  21986. , i = Rh(r, e);
  21987. null == i && (i = 1),
  21988. Ka.parseColor(t, u),
  21989. u[3] *= i,
  21990. c[d++] = u[0],
  21991. c[d++] = u[1],
  21992. c[d++] = u[2],
  21993. c[d++] = u[3],
  21994. u[3] > 0 && (f++,
  21995. u[3] < .99 && (p = !0))
  21996. }
  21997. }
  21998. )),
  21999. o.geometry.setBarCount(f);
  22000. var m = r.getLayout("orient")
  22001. , g = this._barIndexOfData = new Int32Array(r.count());
  22002. f = 0,
  22003. r.each((function (e) {
  22004. if (r.hasValue(e)) {
  22005. var t = r.getItemLayout(e)
  22006. , i = t[0]
  22007. , n = t[1]
  22008. , o = t[2]
  22009. , s = 4 * e;
  22010. u[0] = c[s++],
  22011. u[1] = c[s++],
  22012. u[2] = c[s++],
  22013. u[3] = c[s++],
  22014. u[3] > 0 && (a._barMesh.geometry.addBar(i, n, m, o, u, e),
  22015. g[e] = f++)
  22016. } else
  22017. g[e] = -1
  22018. }
  22019. )),
  22020. o.geometry.dirty(),
  22021. o.geometry.updateBoundingBox();
  22022. var _ = o.material;
  22023. _.transparent = p,
  22024. _.depthMask = !p,
  22025. o.geometry.sortTriangles = p,
  22026. this._initHandler(e, t)
  22027. },
  22028. _initHandler: function (e, t) {
  22029. var r = e.getData()
  22030. , i = this._barMesh
  22031. , n = "cartesian3D" === e.coordinateSystem.type;
  22032. i.seriesIndex = e.seriesIndex;
  22033. var a = -1;
  22034. i.off("mousemove"),
  22035. i.off("mouseout"),
  22036. i.on("mousemove", (function (e) {
  22037. var o = i.geometry.getDataIndexOfVertex(e.triangle[0]);
  22038. o !== a && (this._downplay(a),
  22039. this._highlight(o),
  22040. this._labelsBuilder.updateLabels([o]),
  22041. n && t.dispatchAction({
  22042. type: "grid3DShowAxisPointer",
  22043. value: [r.get("x", o), r.get("y", o), r.get("z", o, !0)]
  22044. })),
  22045. a = o,
  22046. i.dataIndex = o
  22047. }
  22048. ), this),
  22049. i.on("mouseout", (function (e) {
  22050. this._downplay(a),
  22051. this._labelsBuilder.updateLabels(),
  22052. a = -1,
  22053. i.dataIndex = -1,
  22054. n && t.dispatchAction({
  22055. type: "grid3DHideAxisPointer"
  22056. })
  22057. }
  22058. ), this)
  22059. },
  22060. _highlight: function (e) {
  22061. var t = this._data;
  22062. if (t) {
  22063. var r = this._barIndexOfData[e];
  22064. if (!(r < 0)) {
  22065. var n = t.getItemModel(e).getModel("emphasis.itemStyle")
  22066. , a = n.get("color")
  22067. , o = n.get("opacity");
  22068. if (null == a) {
  22069. var s = Ih(t, e);
  22070. a = i.color.lift(s, -.4)
  22071. }
  22072. null == o && (o = Rh(t, e));
  22073. var l = Ka.parseColor(a);
  22074. l[3] *= o,
  22075. this._barMesh.geometry.setColor(r, l),
  22076. this._api.getZr().refresh()
  22077. }
  22078. }
  22079. },
  22080. _downplay: function (e) {
  22081. var t = this._data;
  22082. if (t) {
  22083. var r = this._barIndexOfData[e];
  22084. if (!(r < 0)) {
  22085. var i = Ih(t, e)
  22086. , n = Rh(t, e)
  22087. , a = Ka.parseColor(i);
  22088. a[3] *= n,
  22089. this._barMesh.geometry.setColor(r, a),
  22090. this._api.getZr().refresh()
  22091. }
  22092. }
  22093. },
  22094. highlight: function (e, t, r, i) {
  22095. this._toggleStatus("highlight", e, t, r, i)
  22096. },
  22097. downplay: function (e, t, r, i) {
  22098. this._toggleStatus("downplay", e, t, r, i)
  22099. },
  22100. _toggleStatus: function (e, t, r, n, a) {
  22101. var o = t.getData()
  22102. , s = An(o, a)
  22103. , l = this;
  22104. null != s ? i.util.each(ac.normalizeToArray(s), (function (t) {
  22105. "highlight" === e ? this._highlight(t) : this._downplay(t)
  22106. }
  22107. ), this) : o.each((function (t) {
  22108. "highlight" === e ? l._highlight(t) : l._downplay(t)
  22109. }
  22110. ))
  22111. },
  22112. remove: function () {
  22113. this.groupGL.removeAll()
  22114. },
  22115. dispose: function () {
  22116. this._labelsBuilder.dispose(),
  22117. this.groupGL.removeAll()
  22118. }
  22119. });
  22120. (0,
  22121. i.use)((function (e) {
  22122. e.registerChartView(Tc),
  22123. e.registerSeriesModel(hc),
  22124. nc(e),
  22125. e.registerProcessor((function (e, t) {
  22126. e.eachSeriesByType("bar3d", (function (e) {
  22127. var t = e.getData();
  22128. t.filterSelf((function (e) {
  22129. return t.hasValue(e)
  22130. }
  22131. ))
  22132. }
  22133. ))
  22134. }
  22135. ))
  22136. }
  22137. ));
  22138. const Sc = i.SeriesModel.extend({
  22139. type: "series.line3D",
  22140. dependencies: ["grid3D"],
  22141. visualStyleAccessPath: "lineStyle",
  22142. visualDrawType: "stroke",
  22143. getInitialData: function (e, t) {
  22144. return sc(this)
  22145. },
  22146. formatTooltip: function (e) {
  22147. return oc(this, e)
  22148. },
  22149. defaultOption: {
  22150. coordinateSystem: "cartesian3D",
  22151. zlevel: -10,
  22152. grid3DIndex: 0,
  22153. lineStyle: {
  22154. width: 2
  22155. },
  22156. animationDurationUpdate: 500
  22157. }
  22158. });
  22159. function Mc(e, t, r, i, n, a, o) {
  22160. if (0 === n)
  22161. return !1;
  22162. var s, l = n;
  22163. if (o > t + l && o > i + l || o < t - l && o < i - l || a > e + l && a > r + l || a < e - l && a < r - l)
  22164. return !1;
  22165. if (e === r)
  22166. return Math.abs(a - e) <= l / 2;
  22167. var h = (s = (t - i) / (e - r)) * a - o + (e * i - r * t) / (e - r);
  22168. return h * h / (s * s + 1) <= l / 2 * l / 2
  22169. }
  22170. var Ac = Po.vec3;
  22171. Ka.Shader.import(is);
  22172. const Ec = i.ChartView.extend({
  22173. type: "line3D",
  22174. __ecgl__: !0,
  22175. init: function (e, t) {
  22176. this.groupGL = new Ka.Node,
  22177. this._api = t
  22178. },
  22179. render: function (e, t, r) {
  22180. var i = this._prevLine3DMesh;
  22181. this._prevLine3DMesh = this._line3DMesh,
  22182. this._line3DMesh = i,
  22183. this._line3DMesh || (this._line3DMesh = new Ka.Mesh({
  22184. geometry: new Ro({
  22185. useNativeLine: !1,
  22186. sortTriangles: !0
  22187. }),
  22188. material: new Ka.Material({
  22189. shader: Ka.createShader("ecgl.meshLines3D")
  22190. }),
  22191. renderOrder: 10
  22192. }),
  22193. this._line3DMesh.geometry.pick = this._pick.bind(this)),
  22194. this.groupGL.remove(this._prevLine3DMesh),
  22195. this.groupGL.add(this._line3DMesh);
  22196. var n = e.coordinateSystem;
  22197. if (n && n.viewGL) {
  22198. n.viewGL.add(this.groupGL);
  22199. var a = n.viewGL.isLinearSpace() ? "define" : "undefine";
  22200. this._line3DMesh.material[a]("fragment", "SRGB_DECODE")
  22201. }
  22202. this._doRender(e, r),
  22203. this._data = e.getData(),
  22204. this._camera = n.viewGL.camera,
  22205. this.updateCamera(),
  22206. this._updateAnimation(e)
  22207. },
  22208. updateCamera: function () {
  22209. this._updateNDCPosition()
  22210. },
  22211. _doRender: function (e, t) {
  22212. var r = e.getData()
  22213. , i = this._line3DMesh;
  22214. i.geometry.resetOffset();
  22215. var n = r.getLayout("points")
  22216. , a = []
  22217. , o = new Float32Array(n.length / 3 * 4)
  22218. , s = 0
  22219. , l = !1;
  22220. r.each((function (e) {
  22221. var t = Ih(r, e)
  22222. , i = Rh(r, e);
  22223. null == i && (i = 1),
  22224. Ka.parseColor(t, a),
  22225. a[3] *= i,
  22226. o[s++] = a[0],
  22227. o[s++] = a[1],
  22228. o[s++] = a[2],
  22229. o[s++] = a[3],
  22230. a[3] < .99 && (l = !0)
  22231. }
  22232. )),
  22233. i.geometry.setVertexCount(i.geometry.getPolylineVertexCount(n)),
  22234. i.geometry.setTriangleCount(i.geometry.getPolylineTriangleCount(n)),
  22235. i.geometry.addPolyline(n, o, Mn(e.get("lineStyle.width"), 1)),
  22236. i.geometry.dirty(),
  22237. i.geometry.updateBoundingBox();
  22238. var h = i.material;
  22239. h.transparent = l,
  22240. h.depthMask = !l;
  22241. var u = e.getModel("debug.wireframe");
  22242. u.get("show") ? (i.geometry.createAttribute("barycentric", "float", 3),
  22243. i.geometry.generateBarycentric(),
  22244. i.material.set("both", "WIREFRAME_TRIANGLE"),
  22245. i.material.set("wireframeLineColor", Ka.parseColor(u.get("lineStyle.color") || "rgba(0,0,0,0.5)")),
  22246. i.material.set("wireframeLineWidth", Mn(u.get("lineStyle.width"), 1))) : i.material.set("both", "WIREFRAME_TRIANGLE"),
  22247. this._points = n,
  22248. this._initHandler(e, t)
  22249. },
  22250. _updateAnimation: function (e) {
  22251. Ka.updateVertexAnimation([["prevPosition", "position"], ["prevPositionPrev", "positionPrev"], ["prevPositionNext", "positionNext"]], this._prevLine3DMesh, this._line3DMesh, e)
  22252. },
  22253. _initHandler: function (e, t) {
  22254. var r = e.getData()
  22255. , i = e.coordinateSystem
  22256. , n = this._line3DMesh
  22257. , a = -1;
  22258. n.seriesIndex = e.seriesIndex,
  22259. n.off("mousemove"),
  22260. n.off("mouseout"),
  22261. n.on("mousemove", (function (e) {
  22262. var o = i.pointToData(e.point.array)
  22263. , s = r.indicesOfNearest("x", o[0])[0];
  22264. s !== a && (t.dispatchAction({
  22265. type: "grid3DShowAxisPointer",
  22266. value: [r.get("x", s), r.get("y", s), r.get("z", s)]
  22267. }),
  22268. n.dataIndex = s),
  22269. a = s
  22270. }
  22271. ), this),
  22272. n.on("mouseout", (function (e) {
  22273. a = -1,
  22274. n.dataIndex = -1,
  22275. t.dispatchAction({
  22276. type: "grid3DHideAxisPointer"
  22277. })
  22278. }
  22279. ), this)
  22280. },
  22281. _updateNDCPosition: function () {
  22282. var e = new Ht
  22283. , t = this._camera;
  22284. Ht.multiply(e, t.projectionMatrix, t.viewMatrix);
  22285. var r = this._positionNDC
  22286. , i = this._points
  22287. , n = i.length / 3;
  22288. r && r.length / 2 === n || (r = this._positionNDC = new Float32Array(2 * n));
  22289. for (var a = [], o = 0; o < n; o++) {
  22290. var s = 3 * o
  22291. , l = 2 * o;
  22292. a[0] = i[s],
  22293. a[1] = i[s + 1],
  22294. a[2] = i[s + 2],
  22295. a[3] = 1,
  22296. Ac.transformMat4(a, a, e.array),
  22297. r[l] = a[0] / a[3],
  22298. r[l + 1] = a[1] / a[3]
  22299. }
  22300. },
  22301. _pick: function (e, t, r, i, n, a) {
  22302. var o = this._positionNDC
  22303. , s = this._data.hostModel.get("lineStyle.width")
  22304. , l = -1
  22305. , h = .5 * r.viewport.width
  22306. , u = .5 * r.viewport.height;
  22307. e = (e + 1) * h,
  22308. t = (t + 1) * u;
  22309. for (var c = 1; c < o.length / 2; c++) {
  22310. var d = (o[2 * (c - 1)] + 1) * h
  22311. , f = (o[2 * (c - 1) + 1] + 1) * u
  22312. , p = (o[2 * c] + 1) * h
  22313. , m = (o[2 * c + 1] + 1) * u;
  22314. Mc(d, f, p, m, s, e, t) && (l = (d - e) * (d - e) + (f - t) * (f - t) < (p - e) * (p - e) + (m - t) * (m - t) ? c - 1 : c)
  22315. }
  22316. if (l >= 0) {
  22317. var g = 3 * l
  22318. , _ = new vt(this._points[g], this._points[g + 1], this._points[g + 2]);
  22319. a.push({
  22320. dataIndex: l,
  22321. point: _,
  22322. pointWorld: _.clone(),
  22323. target: this._line3DMesh,
  22324. distance: this._camera.getWorldPosition().dist(_)
  22325. })
  22326. }
  22327. },
  22328. remove: function () {
  22329. this.groupGL.removeAll()
  22330. },
  22331. dispose: function () {
  22332. this.groupGL.removeAll()
  22333. }
  22334. });
  22335. (0,
  22336. i.use)((function (e) {
  22337. e.registerChartView(Ec),
  22338. e.registerSeriesModel(Sc),
  22339. e.registerLayout((function (e, t) {
  22340. e.eachSeriesByType("line3D", (function (e) {
  22341. var t = e.getData()
  22342. , r = e.coordinateSystem;
  22343. if (r) {
  22344. if ("cartesian3D" !== r.type)
  22345. return;
  22346. var i = new Float32Array(3 * t.count())
  22347. , n = []
  22348. , a = []
  22349. , o = r.dimensions.map((function (t) {
  22350. return e.coordDimToDataDim(t)[0]
  22351. }
  22352. ));
  22353. r && t.each(o, (function (e, t, o, s) {
  22354. n[0] = e,
  22355. n[1] = t,
  22356. n[2] = o,
  22357. r.dataToPoint(n, a),
  22358. i[3 * s] = a[0],
  22359. i[3 * s + 1] = a[1],
  22360. i[3 * s + 2] = a[2]
  22361. }
  22362. )),
  22363. t.setLayout("points", i)
  22364. }
  22365. }
  22366. ))
  22367. }
  22368. ))
  22369. }
  22370. ));
  22371. const Cc = i.SeriesModel.extend({
  22372. type: "series.scatter3D",
  22373. dependencies: ["globe", "grid3D", "geo3D"],
  22374. visualStyleAccessPath: "itemStyle",
  22375. hasSymbolVisual: !0,
  22376. getInitialData: function (e, t) {
  22377. return sc(this)
  22378. },
  22379. getFormattedLabel: function (e, t, r, i) {
  22380. var n = ac.getFormattedLabel(this, e, t, r, i);
  22381. if (null == n) {
  22382. var a = this.getData()
  22383. , o = a.dimensions[a.dimensions.length - 1];
  22384. n = a.get(o, e)
  22385. }
  22386. return n
  22387. },
  22388. formatTooltip: function (e) {
  22389. return oc(this, e)
  22390. },
  22391. defaultOption: {
  22392. coordinateSystem: "cartesian3D",
  22393. zlevel: -10,
  22394. progressive: 1e5,
  22395. progressiveThreshold: 1e5,
  22396. grid3DIndex: 0,
  22397. globeIndex: 0,
  22398. symbol: "circle",
  22399. symbolSize: 10,
  22400. blendMode: "source-over",
  22401. label: {
  22402. show: !1,
  22403. position: "right",
  22404. distance: 5,
  22405. textStyle: {
  22406. fontSize: 14,
  22407. color: "#000",
  22408. backgroundColor: "rgba(255,255,255,0.7)",
  22409. padding: 3,
  22410. borderRadius: 3
  22411. }
  22412. },
  22413. itemStyle: {
  22414. opacity: .8
  22415. },
  22416. emphasis: {
  22417. label: {
  22418. show: !0
  22419. }
  22420. },
  22421. animationDurationUpdate: 500
  22422. }
  22423. });
  22424. function Dc(e, t, r) {
  22425. (t = t || document.createElement("canvas")).width = e,
  22426. t.height = e;
  22427. var i = t.getContext("2d");
  22428. return r && r(i),
  22429. t
  22430. }
  22431. var Lc = {
  22432. getMarginByStyle: function (e) {
  22433. var t = e.minMargin || 0
  22434. , r = 0;
  22435. e.stroke && "none" !== e.stroke && (r = null == e.lineWidth ? 1 : e.lineWidth);
  22436. var i = e.shadowBlur || 0
  22437. , n = e.shadowOffsetX || 0
  22438. , a = e.shadowOffsetY || 0
  22439. , o = {};
  22440. return o.left = Math.max(r / 2, -n + i, t),
  22441. o.right = Math.max(r / 2, n + i, t),
  22442. o.top = Math.max(r / 2, -a + i, t),
  22443. o.bottom = Math.max(r / 2, a + i, t),
  22444. o
  22445. },
  22446. createSymbolSprite: function (e, t, r, n) {
  22447. var a = function (e, t, r, n) {
  22448. i.util.isArray(t) || (t = [t, t]);
  22449. var a = Lc.getMarginByStyle(r, void 0)
  22450. , o = t[0] + a.left + a.right
  22451. , s = t[1] + a.top + a.bottom
  22452. , l = i.helper.createSymbol(e, 0, 0, t[0], t[1])
  22453. , h = Math.max(o, s);
  22454. l.x = a.left,
  22455. l.y = a.top,
  22456. o > s ? l.y += (h - s) / 2 : l.x += (h - o) / 2;
  22457. var u = l.getBoundingRect();
  22458. return l.x -= u.x,
  22459. l.y -= u.y,
  22460. l.setStyle(r),
  22461. l.update(),
  22462. l.__size = h,
  22463. l
  22464. }(e, t, r)
  22465. , o = Lc.getMarginByStyle(r);
  22466. return {
  22467. image: Dc(a.__size, n, (function (e) {
  22468. i.innerDrawElementOnCanvas(e, a)
  22469. }
  22470. )),
  22471. margin: o
  22472. }
  22473. },
  22474. createSDFFromCanvas: function (e, t, r, i) {
  22475. return Dc(t, i, (function (t) {
  22476. var i = e.getContext("2d").getImageData(0, 0, e.width, e.height);
  22477. t.putImageData(function (e, t, r) {
  22478. var i = t.width
  22479. , n = t.height
  22480. , a = e.canvas.width
  22481. , o = e.canvas.height
  22482. , s = i / a
  22483. , l = n / o;
  22484. function h(e) {
  22485. return e < 128 ? 1 : -1
  22486. }
  22487. function u(e, a) {
  22488. var o = 1 / 0;
  22489. e = Math.floor(e * s);
  22490. for (var u = (a = Math.floor(a * l)) * i + e, c = h(t.data[4 * u]), d = Math.max(a - r, 0); d < Math.min(a + r, n); d++)
  22491. for (var f = Math.max(e - r, 0); f < Math.min(e + r, i); f++) {
  22492. u = d * i + f;
  22493. var p = f - e
  22494. , m = d - a;
  22495. if (c !== h(t.data[4 * u])) {
  22496. var g = p * p + m * m;
  22497. g < o && (o = g)
  22498. }
  22499. }
  22500. return c * Math.sqrt(o)
  22501. }
  22502. for (var c = e.createImageData(a, o), d = 0; d < o; d++)
  22503. for (var f = 0; f < a; f++) {
  22504. var p = u(f, d) / r * .5 + .5
  22505. , m = 4 * (d * a + f);
  22506. c.data[m++] = 255 * (1 - p),
  22507. c.data[m++] = 255 * (1 - p),
  22508. c.data[m++] = 255 * (1 - p),
  22509. c.data[m++] = 255
  22510. }
  22511. return c
  22512. }(t, i, r), 0, 0)
  22513. }
  22514. ))
  22515. },
  22516. createSimpleSprite: function (e, t) {
  22517. return Dc(e, t, (function (t) {
  22518. var r = e / 2;
  22519. t.beginPath(),
  22520. t.arc(r, r, 60, 0, 2 * Math.PI, !1),
  22521. t.closePath();
  22522. var i = t.createRadialGradient(r, r, 0, r, r, r);
  22523. i.addColorStop(0, "rgba(255, 255, 255, 1)"),
  22524. i.addColorStop(.5, "rgba(255, 255, 255, 0.5)"),
  22525. i.addColorStop(1, "rgba(255, 255, 255, 0)"),
  22526. t.fillStyle = i,
  22527. t.fill()
  22528. }
  22529. ))
  22530. }
  22531. };
  22532. const Pc = Lc;
  22533. var Oc = Po.vec3;
  22534. const Nc = {
  22535. needsSortVertices: function () {
  22536. return this.sortVertices
  22537. },
  22538. needsSortVerticesProgressively: function () {
  22539. return this.needsSortVertices() && this.vertexCount >= 2e4
  22540. },
  22541. doSortVertices: function (e, t) {
  22542. var r = this.indices
  22543. , i = Oc.create();
  22544. if (!r) {
  22545. r = this.indices = this.vertexCount > 65535 ? new Uint32Array(this.vertexCount) : new Uint16Array(this.vertexCount);
  22546. for (var n = 0; n < r.length; n++)
  22547. r[n] = n
  22548. }
  22549. if (0 === t) {
  22550. var a, o = this.attributes.position, s = (e = e.array,
  22551. 0);
  22552. for (this._zList && this._zList.length === this.vertexCount || (this._zList = new Float32Array(this.vertexCount)),
  22553. n = 0; n < this.vertexCount; n++) {
  22554. o.get(n, i);
  22555. var l = Oc.sqrDist(i, e);
  22556. isNaN(l) && (l = 1e7,
  22557. s++),
  22558. 0 === n ? (a = l,
  22559. l = 0) : l -= a,
  22560. this._zList[n] = l
  22561. }
  22562. this._noneCount = s
  22563. }
  22564. if (this.vertexCount < 2e4)
  22565. 0 === t && this._simpleSort(this._noneCount / this.vertexCount > .05);
  22566. else
  22567. for (n = 0; n < 3; n++)
  22568. this._progressiveQuickSort(3 * t + n);
  22569. this.dirtyIndices()
  22570. },
  22571. _simpleSort: function (e) {
  22572. var t = this._zList
  22573. , r = this.indices;
  22574. function i(e, r) {
  22575. return t[r] - t[e]
  22576. }
  22577. e ? Array.prototype.sort.call(r, i) : Ch.sort(r, i, 0, r.length - 1)
  22578. },
  22579. _progressiveQuickSort: function (e) {
  22580. var t = this._zList
  22581. , r = this.indices;
  22582. this._quickSort = this._quickSort || new Ch,
  22583. this._quickSort.step(r, (function (e, r) {
  22584. return t[r] - t[e]
  22585. }
  22586. ), e)
  22587. }
  22588. };
  22589. var Ic = Po.vec4;
  22590. Ka.Shader.import("@export ecgl.sdfSprite.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform float elapsedTime : 0;\n\nattribute vec3 position : POSITION;\n\n#ifdef VERTEX_SIZE\nattribute float size;\n#else\nuniform float u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_FillColor: COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute float prevSize;\nuniform float percent : 1.0;\n#endif\n\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvarying float v_Size;\n\nvoid main()\n{\n\n#ifdef POSITIONTEXTURE_ENABLED\n gl_Position = worldViewProjection * vec4(texture2D(positionTexture, position.xy).xy, -10.0, 1.0);\n#else\n\n #ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n #else\n vec3 pos = position;\n #endif\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n#endif\n\n#ifdef VERTEX_SIZE\n#ifdef VERTEX_ANIMATION\n v_Size = mix(prevSize, size, percent);\n#else\n v_Size = size;\n#endif\n#else\n v_Size = u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\n v_Color = a_FillColor;\n #endif\n\n gl_PointSize = v_Size;\n}\n\n@end\n\n@export ecgl.sdfSprite.fragment\n\nuniform vec4 color: [1, 1, 1, 1];\nuniform vec4 strokeColor: [1, 1, 1, 1];\nuniform float smoothing: 0.07;\n\nuniform float lineWidth: 0.0;\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\nvarying float v_Size;\n\nuniform sampler2D sprite;\n\n@import clay.util.srgb\n\nvoid main()\n{\n gl_FragColor = color;\n\n vec4 _strokeColor = strokeColor;\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n #endif\n\n#ifdef SPRITE_ENABLED\n float d = texture2D(sprite, gl_PointCoord).r;\n gl_FragColor.a *= smoothstep(0.5 - smoothing, 0.5 + smoothing, d);\n\n if (lineWidth > 0.0) {\n float sLineWidth = lineWidth / 2.0;\n\n float outlineMaxValue0 = 0.5 + sLineWidth;\n float outlineMaxValue1 = 0.5 + sLineWidth + smoothing;\n float outlineMinValue0 = 0.5 - sLineWidth - smoothing;\n float outlineMinValue1 = 0.5 - sLineWidth;\n\n if (d <= outlineMaxValue1 && d >= outlineMinValue0) {\n float a = _strokeColor.a;\n if (d <= outlineMinValue1) {\n a = a * smoothstep(outlineMinValue0, outlineMinValue1, d);\n }\n else {\n a = a * smoothstep(outlineMaxValue1, outlineMaxValue0, d);\n }\n gl_FragColor.rgb = mix(gl_FragColor.rgb * gl_FragColor.a, _strokeColor.rgb, a);\n gl_FragColor.a = gl_FragColor.a * (1.0 - a) + a;\n }\n }\n#endif\n\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(gl_FragColor);\n#endif\n}\n@end");
  22591. const Rc = Ka.Mesh.extend((function () {
  22592. var e = new Ka.Geometry({
  22593. dynamic: !0,
  22594. attributes: {
  22595. color: new Ka.Geometry.Attribute("color", "float", 4, "COLOR"),
  22596. position: new Ka.Geometry.Attribute("position", "float", 3, "POSITION"),
  22597. size: new Ka.Geometry.Attribute("size", "float", 1),
  22598. prevPosition: new Ka.Geometry.Attribute("prevPosition", "float", 3),
  22599. prevSize: new Ka.Geometry.Attribute("prevSize", "float", 1)
  22600. }
  22601. });
  22602. Object.assign(e, Nc);
  22603. var t = new Ka.Material({
  22604. shader: Ka.createShader("ecgl.sdfSprite"),
  22605. transparent: !0,
  22606. depthMask: !1
  22607. });
  22608. t.enableTexture("sprite"),
  22609. t.define("both", "VERTEX_COLOR"),
  22610. t.define("both", "VERTEX_SIZE");
  22611. var r = new Ka.Texture2D({
  22612. image: document.createElement("canvas"),
  22613. flipY: !1
  22614. });
  22615. return t.set("sprite", r),
  22616. e.pick = this._pick.bind(this),
  22617. {
  22618. geometry: e,
  22619. material: t,
  22620. mode: Ka.Mesh.POINTS,
  22621. sizeScale: 1
  22622. }
  22623. }
  22624. ), {
  22625. _pick: function (e, t, r, i, n, a) {
  22626. var o = this._positionNDC;
  22627. if (o)
  22628. for (var s = r.viewport, l = 2 / s.width, h = 2 / s.height, u = this.geometry.vertexCount - 1; u >= 0; u--) {
  22629. var c, d = o[2 * (c = this.geometry.indices ? this.geometry.indices[u] : u)], f = o[2 * c + 1], p = this.geometry.attributes.size.get(c) / this.sizeScale / 2;
  22630. if (e > d - p * l && e < d + p * l && t > f - p * h && t < f + p * h) {
  22631. var m = new Ka.Vector3
  22632. , g = new Ka.Vector3;
  22633. this.geometry.attributes.position.get(c, m.array),
  22634. Ka.Vector3.transformMat4(g, m, this.worldTransform),
  22635. a.push({
  22636. vertexIndex: c,
  22637. point: m,
  22638. pointWorld: g,
  22639. target: this,
  22640. distance: g.distance(i.getWorldPosition())
  22641. })
  22642. }
  22643. }
  22644. },
  22645. updateNDCPosition: function (e, t, r) {
  22646. var i = this._positionNDC
  22647. , n = this.geometry;
  22648. i && i.length / 2 === n.vertexCount || (i = this._positionNDC = new Float32Array(2 * n.vertexCount));
  22649. for (var a = Ic.create(), o = 0; o < n.vertexCount; o++)
  22650. n.attributes.position.get(o, a),
  22651. a[3] = 1,
  22652. Ic.transformMat4(a, a, e.array),
  22653. Ic.scale(a, a, 1 / a[3]),
  22654. i[2 * o] = a[0],
  22655. i[2 * o + 1] = a[1]
  22656. }
  22657. });
  22658. function Bc(e, t) {
  22659. this.rootNode = new Ka.Node,
  22660. this.is2D = e,
  22661. this._labelsBuilder = new Fh(256, 256, t),
  22662. this._labelsBuilder.getMesh().renderOrder = 100,
  22663. this.rootNode.add(this._labelsBuilder.getMesh()),
  22664. this._api = t,
  22665. this._spriteImageCanvas = document.createElement("canvas"),
  22666. this._startDataIndex = 0,
  22667. this._endDataIndex = 0,
  22668. this._sizeScale = 1
  22669. }
  22670. Bc.prototype = {
  22671. constructor: Bc,
  22672. highlightOnMouseover: !0,
  22673. update: function (e, t, r, i, n) {
  22674. var a = this._prevMesh;
  22675. this._prevMesh = this._mesh,
  22676. this._mesh = a;
  22677. var o = e.getData();
  22678. if (null == i && (i = 0),
  22679. null == n && (n = o.count()),
  22680. this._startDataIndex = i,
  22681. this._endDataIndex = n - 1,
  22682. !this._mesh) {
  22683. var s = this._prevMesh && this._prevMesh.material;
  22684. this._mesh = new Rc({
  22685. renderOrder: 10,
  22686. frustumCulling: !1
  22687. }),
  22688. s && (this._mesh.material = s)
  22689. }
  22690. s = this._mesh.material;
  22691. var l = this._mesh.geometry
  22692. , h = l.attributes;
  22693. this.rootNode.remove(this._prevMesh),
  22694. this.rootNode.add(this._mesh),
  22695. this._setPositionTextureToMesh(this._mesh, this._positionTexture);
  22696. var u = this._getSymbolInfo(e, i, n)
  22697. , c = r.getDevicePixelRatio()
  22698. , d = e.getModel("itemStyle").getItemStyle()
  22699. , f = e.get("large")
  22700. , p = 1;
  22701. u.maxSize > 2 ? (p = this._updateSymbolSprite(e, d, u, c),
  22702. s.enableTexture("sprite")) : s.disableTexture("sprite"),
  22703. h.position.init(n - i);
  22704. var m = [];
  22705. if (f) {
  22706. s.undefine("VERTEX_SIZE"),
  22707. s.undefine("VERTEX_COLOR");
  22708. var g = function (e) {
  22709. const t = e.getVisual("style");
  22710. if (t)
  22711. return t[e.getVisual("drawType")]
  22712. }(o)
  22713. , _ = function (e) {
  22714. return e.getVisual("style").opacity
  22715. }(o);
  22716. Ka.parseColor(g, m),
  22717. m[3] *= _,
  22718. s.set({
  22719. color: m,
  22720. u_Size: u.maxSize * this._sizeScale
  22721. })
  22722. } else
  22723. s.set({
  22724. color: [1, 1, 1, 1]
  22725. }),
  22726. s.define("VERTEX_SIZE"),
  22727. s.define("VERTEX_COLOR"),
  22728. h.size.init(n - i),
  22729. h.color.init(n - i),
  22730. this._originalOpacity = new Float32Array(n - i);
  22731. for (var v = o.getLayout("points"), y = h.position.value, x = 0; x < n - i; x++) {
  22732. var b = 3 * x
  22733. , w = 2 * x;
  22734. if (this.is2D ? (y[b] = v[w],
  22735. y[b + 1] = v[w + 1],
  22736. y[b + 2] = -10) : (y[b] = v[b],
  22737. y[b + 1] = v[b + 1],
  22738. y[b + 2] = v[b + 2]),
  22739. !f) {
  22740. g = Ih(o, x),
  22741. _ = Rh(o, x),
  22742. Ka.parseColor(g, m),
  22743. m[3] *= _,
  22744. h.color.set(x, m),
  22745. m[3];
  22746. var T = o.getItemVisual(x, "symbolSize");
  22747. T = T instanceof Array ? Math.max(T[0], T[1]) : T,
  22748. isNaN(T) && (T = 0),
  22749. h.size.value[x] = T * p * this._sizeScale,
  22750. this._originalOpacity[x] = m[3]
  22751. }
  22752. }
  22753. this._mesh.sizeScale = p,
  22754. l.updateBoundingBox(),
  22755. l.dirty(),
  22756. this._updateMaterial(e, d);
  22757. var S = e.coordinateSystem;
  22758. S && S.viewGL && s[S.viewGL.isLinearSpace() ? "define" : "undefine"]("fragment", "SRGB_DECODE"),
  22759. f || this._updateLabelBuilder(e, i, n),
  22760. this._updateHandler(e, t, r),
  22761. this._updateAnimation(e),
  22762. this._api = r
  22763. },
  22764. getPointsMesh: function () {
  22765. return this._mesh
  22766. },
  22767. updateLabels: function (e) {
  22768. this._labelsBuilder.updateLabels(e)
  22769. },
  22770. hideLabels: function () {
  22771. this.rootNode.remove(this._labelsBuilder.getMesh())
  22772. },
  22773. showLabels: function () {
  22774. this.rootNode.add(this._labelsBuilder.getMesh())
  22775. },
  22776. dispose: function () {
  22777. this._labelsBuilder.dispose()
  22778. },
  22779. _updateSymbolSprite: function (e, t, r, i) {
  22780. r.maxSize = Math.min(2 * r.maxSize, 200);
  22781. var n, a, o = [];
  22782. return r.aspect > 1 ? (o[0] = r.maxSize,
  22783. o[1] = r.maxSize / r.aspect) : (o[1] = r.maxSize,
  22784. o[0] = r.maxSize * r.aspect),
  22785. o[0] = o[0] || 1,
  22786. o[1] = o[1] || 1,
  22787. this._symbolType === r.type && (a = o,
  22788. (n = this._symbolSize) && a && n[0] === a[0] && n[1] === a[1]) && this._lineWidth === t.lineWidth || (Pc.createSymbolSprite(r.type, o, {
  22789. fill: "#fff",
  22790. lineWidth: t.lineWidth,
  22791. stroke: "transparent",
  22792. shadowColor: "transparent",
  22793. minMargin: Math.min(o[0] / 2, 10)
  22794. }, this._spriteImageCanvas),
  22795. Pc.createSDFFromCanvas(this._spriteImageCanvas, Math.min(this._spriteImageCanvas.width, 32), 20, this._mesh.material.get("sprite").image),
  22796. this._symbolType = r.type,
  22797. this._symbolSize = o,
  22798. this._lineWidth = t.lineWidth),
  22799. this._spriteImageCanvas.width / r.maxSize * i
  22800. },
  22801. _updateMaterial: function (e, t) {
  22802. var r = "lighter" === e.get("blendMode") ? Ka.additiveBlend : null
  22803. , i = this._mesh.material;
  22804. i.blend = r,
  22805. i.set("lineWidth", t.lineWidth / 20);
  22806. var n = Ka.parseColor(t.stroke);
  22807. i.set("strokeColor", n),
  22808. i.transparent = !0,
  22809. i.depthMask = !1,
  22810. i.depthTest = !this.is2D,
  22811. i.sortVertices = !this.is2D
  22812. },
  22813. _updateLabelBuilder: function (e, t, r) {
  22814. var i = e.getData()
  22815. , n = this._mesh.geometry
  22816. , a = n.attributes.position.value
  22817. , o = (t = this._startDataIndex,
  22818. this._mesh.sizeScale);
  22819. this._labelsBuilder.updateData(i, t, r),
  22820. this._labelsBuilder.getLabelPosition = function (e, r, i) {
  22821. var n = 3 * (e - t);
  22822. return [a[n], a[n + 1], a[n + 2]]
  22823. }
  22824. ,
  22825. this._labelsBuilder.getLabelDistance = function (e, r, i) {
  22826. return n.attributes.size.get(e - t) / o / 2 + i
  22827. }
  22828. ,
  22829. this._labelsBuilder.updateLabels()
  22830. },
  22831. _updateAnimation: function (e) {
  22832. Ka.updateVertexAnimation([["prevPosition", "position"], ["prevSize", "size"]], this._prevMesh, this._mesh, e)
  22833. },
  22834. _updateHandler: function (e, t, r) {
  22835. var i, n = e.getData(), a = this._mesh, o = this, s = -1, l = e.coordinateSystem && "cartesian3D" === e.coordinateSystem.type;
  22836. l && (i = e.coordinateSystem.model),
  22837. a.seriesIndex = e.seriesIndex,
  22838. a.off("mousemove"),
  22839. a.off("mouseout"),
  22840. a.on("mousemove", (function (t) {
  22841. var h = t.vertexIndex + o._startDataIndex;
  22842. h !== s && (this.highlightOnMouseover && (this.downplay(n, s),
  22843. this.highlight(n, h),
  22844. this._labelsBuilder.updateLabels([h])),
  22845. l && r.dispatchAction({
  22846. type: "grid3DShowAxisPointer",
  22847. value: [n.get(e.coordDimToDataDim("x")[0], h), n.get(e.coordDimToDataDim("y")[0], h), n.get(e.coordDimToDataDim("z")[0], h)],
  22848. grid3DIndex: i.componentIndex
  22849. })),
  22850. a.dataIndex = h,
  22851. s = h
  22852. }
  22853. ), this),
  22854. a.on("mouseout", (function (e) {
  22855. var t = e.vertexIndex + o._startDataIndex;
  22856. this.highlightOnMouseover && (this.downplay(n, t),
  22857. this._labelsBuilder.updateLabels()),
  22858. s = -1,
  22859. a.dataIndex = -1,
  22860. l && r.dispatchAction({
  22861. type: "grid3DHideAxisPointer",
  22862. grid3DIndex: i.componentIndex
  22863. })
  22864. }
  22865. ), this)
  22866. },
  22867. updateLayout: function (e, t, r) {
  22868. var i = e.getData();
  22869. if (this._mesh) {
  22870. var n = this._mesh.geometry.attributes.position.value
  22871. , a = i.getLayout("points");
  22872. if (this.is2D)
  22873. for (var o = 0; o < a.length / 2; o++) {
  22874. var s = 3 * o
  22875. , l = 2 * o;
  22876. n[s] = a[l],
  22877. n[s + 1] = a[l + 1],
  22878. n[s + 2] = -10
  22879. }
  22880. else
  22881. for (o = 0; o < a.length; o++)
  22882. n[o] = a[o];
  22883. this._mesh.geometry.dirty(),
  22884. r.getZr().refresh()
  22885. }
  22886. },
  22887. updateView: function (e) {
  22888. if (this._mesh) {
  22889. var t = new Ht;
  22890. Ht.mul(t, e.viewMatrix, this._mesh.worldTransform),
  22891. Ht.mul(t, e.projectionMatrix, t),
  22892. this._mesh.updateNDCPosition(t, this.is2D, this._api)
  22893. }
  22894. },
  22895. highlight: function (e, t) {
  22896. if (!(t > this._endDataIndex || t < this._startDataIndex)) {
  22897. var r = e.getItemModel(t).getModel("emphasis.itemStyle")
  22898. , n = r.get("color")
  22899. , a = r.get("opacity");
  22900. if (null == n) {
  22901. var o = Ih(e, t);
  22902. n = i.color.lift(o, -.4)
  22903. }
  22904. null == a && (a = Rh(e, t));
  22905. var s = Ka.parseColor(n);
  22906. s[3] *= a,
  22907. this._mesh.geometry.attributes.color.set(t - this._startDataIndex, s),
  22908. this._mesh.geometry.dirtyAttribute("color"),
  22909. this._api.getZr().refresh()
  22910. }
  22911. },
  22912. downplay: function (e, t) {
  22913. if (!(t > this._endDataIndex || t < this._startDataIndex)) {
  22914. var r = Ih(e, t)
  22915. , i = Rh(e, t)
  22916. , n = Ka.parseColor(r);
  22917. n[3] *= i,
  22918. this._mesh.geometry.attributes.color.set(t - this._startDataIndex, n),
  22919. this._mesh.geometry.dirtyAttribute("color"),
  22920. this._api.getZr().refresh()
  22921. }
  22922. },
  22923. fadeOutAll: function (e) {
  22924. if (this._originalOpacity) {
  22925. for (var t = this._mesh.geometry, r = 0; r < t.vertexCount; r++) {
  22926. var i = this._originalOpacity[r] * e;
  22927. t.attributes.color.value[4 * r + 3] = i
  22928. }
  22929. t.dirtyAttribute("color"),
  22930. this._api.getZr().refresh()
  22931. }
  22932. },
  22933. fadeInAll: function () {
  22934. this.fadeOutAll(1)
  22935. },
  22936. setPositionTexture: function (e) {
  22937. this._mesh && this._setPositionTextureToMesh(this._mesh, e),
  22938. this._positionTexture = e
  22939. },
  22940. removePositionTexture: function () {
  22941. this._positionTexture = null,
  22942. this._mesh && this._setPositionTextureToMesh(this._mesh, null)
  22943. },
  22944. setSizeScale: function (e) {
  22945. if (e !== this._sizeScale) {
  22946. if (this._mesh) {
  22947. var t = this._mesh.material.get("u_Size");
  22948. this._mesh.material.set("u_Size", t / this._sizeScale * e);
  22949. var r = this._mesh.geometry.attributes;
  22950. if (r.size.value)
  22951. for (var i = 0; i < r.size.value.length; i++)
  22952. r.size.value[i] = r.size.value[i] / this._sizeScale * e
  22953. }
  22954. this._sizeScale = e
  22955. }
  22956. },
  22957. _setPositionTextureToMesh: function (e, t) {
  22958. t && e.material.set("positionTexture", t),
  22959. e.material[t ? "enableTexture" : "disableTexture"]("positionTexture")
  22960. },
  22961. _getSymbolInfo: function (e, t, r) {
  22962. if (e.get("large"))
  22963. return (h = Mn(e.get("symbolSize"), 1)) instanceof Array ? (o = Math.max(h[0], h[1]),
  22964. i = h[0] / h[1]) : (o = h,
  22965. i = 1),
  22966. {
  22967. maxSize: h,
  22968. type: e.get("symbol"),
  22969. aspect: i
  22970. };
  22971. for (var i, n = e.getData(), a = n.getItemVisual(0, "symbol") || "circle", o = 0, s = t; s < r; s++) {
  22972. var l, h = n.getItemVisual(s, "symbolSize"), u = n.getItemVisual(s, "symbol");
  22973. if (h instanceof Array)
  22974. l = h[0] / h[1],
  22975. o = Math.max(Math.max(h[0], h[1]), o);
  22976. else {
  22977. if (isNaN(h))
  22978. continue;
  22979. l = 1,
  22980. o = Math.max(h, o)
  22981. }
  22982. a = u,
  22983. i = l
  22984. }
  22985. return {
  22986. maxSize: o,
  22987. type: a,
  22988. aspect: i
  22989. }
  22990. }
  22991. };
  22992. const Fc = Bc
  22993. , zc = i.ChartView.extend({
  22994. type: "scatter3D",
  22995. hasSymbolVisual: !0,
  22996. __ecgl__: !0,
  22997. init: function (e, t) {
  22998. this.groupGL = new Ka.Node,
  22999. this._pointsBuilderList = [],
  23000. this._currentStep = 0
  23001. },
  23002. render: function (e, t, r) {
  23003. if (this.groupGL.removeAll(),
  23004. e.getData().count()) {
  23005. var i = e.coordinateSystem;
  23006. if (i && i.viewGL) {
  23007. i.viewGL.add(this.groupGL),
  23008. this._camera = i.viewGL.camera;
  23009. var n = this._pointsBuilderList[0];
  23010. n || (n = this._pointsBuilderList[0] = new Fc(!1, r)),
  23011. this._pointsBuilderList.length = 1,
  23012. this.groupGL.add(n.rootNode),
  23013. n.update(e, t, r),
  23014. n.updateView(i.viewGL.camera)
  23015. }
  23016. }
  23017. },
  23018. incrementalPrepareRender: function (e, t, r) {
  23019. var i = e.coordinateSystem;
  23020. i && i.viewGL && (i.viewGL.add(this.groupGL),
  23021. this._camera = i.viewGL.camera),
  23022. this.groupGL.removeAll(),
  23023. this._currentStep = 0
  23024. },
  23025. incrementalRender: function (e, t, r, i) {
  23026. if (!(e.end <= e.start)) {
  23027. var n = this._pointsBuilderList[this._currentStep];
  23028. n || (n = new Fc(!1, i),
  23029. this._pointsBuilderList[this._currentStep] = n),
  23030. this.groupGL.add(n.rootNode),
  23031. n.update(t, r, i, e.start, e.end),
  23032. n.updateView(t.coordinateSystem.viewGL.camera),
  23033. this._currentStep++
  23034. }
  23035. },
  23036. updateCamera: function () {
  23037. this._pointsBuilderList.forEach((function (e) {
  23038. e.updateView(this._camera)
  23039. }
  23040. ), this)
  23041. },
  23042. highlight: function (e, t, r, i) {
  23043. this._toggleStatus("highlight", e, t, r, i)
  23044. },
  23045. downplay: function (e, t, r, i) {
  23046. this._toggleStatus("downplay", e, t, r, i)
  23047. },
  23048. _toggleStatus: function (e, t, r, n, a) {
  23049. var o = t.getData()
  23050. , s = An(o, a)
  23051. , l = "highlight" === e;
  23052. null != s ? i.util.each(ac.normalizeToArray(s), (function (e) {
  23053. for (var t = 0; t < this._pointsBuilderList.length; t++) {
  23054. var r = this._pointsBuilderList[t];
  23055. l ? r.highlight(o, e) : r.downplay(o, e)
  23056. }
  23057. }
  23058. ), this) : o.each((function (e) {
  23059. for (var t = 0; t < this._pointsBuilderList.length; t++) {
  23060. var r = this._pointsBuilderList[t];
  23061. l ? r.highlight(o, e) : r.downplay(o, e)
  23062. }
  23063. }
  23064. ))
  23065. },
  23066. dispose: function () {
  23067. this._pointsBuilderList.forEach((function (e) {
  23068. e.dispose()
  23069. }
  23070. )),
  23071. this.groupGL.removeAll()
  23072. },
  23073. remove: function () {
  23074. this.groupGL.removeAll()
  23075. }
  23076. });
  23077. (0,
  23078. i.use)((function (e) {
  23079. e.registerChartView(zc),
  23080. e.registerSeriesModel(Cc),
  23081. e.registerLayout({
  23082. seriesType: "scatter3D",
  23083. reset: function (e) {
  23084. var t = e.coordinateSystem;
  23085. if (t) {
  23086. var r = t.dimensions;
  23087. if (r.length < 3)
  23088. return;
  23089. var i = r.map((function (t) {
  23090. return e.coordDimToDataDim(t)[0]
  23091. }
  23092. ))
  23093. , n = []
  23094. , a = [];
  23095. return {
  23096. progress: function (e, r) {
  23097. for (var o = new Float32Array(3 * (e.end - e.start)), s = e.start; s < e.end; s++) {
  23098. var l = 3 * (s - e.start);
  23099. n[0] = r.get(i[0], s),
  23100. n[1] = r.get(i[1], s),
  23101. n[2] = r.get(i[2], s),
  23102. t.dataToPoint(n, a),
  23103. o[l] = a[0],
  23104. o[l + 1] = a[1],
  23105. o[l + 2] = a[2]
  23106. }
  23107. r.setLayout("points", o)
  23108. }
  23109. }
  23110. }
  23111. }
  23112. })
  23113. }
  23114. ));
  23115. var Gc = Po.vec3
  23116. , Uc = Po.vec2
  23117. , kc = Gc.normalize
  23118. , Vc = Gc.cross
  23119. , Hc = Gc.sub
  23120. , Wc = Gc.add
  23121. , jc = Gc.create
  23122. , Xc = jc()
  23123. , qc = jc()
  23124. , Zc = jc()
  23125. , Yc = jc()
  23126. , Kc = []
  23127. , Qc = [];
  23128. function Jc(e, t) {
  23129. Uc.copy(Kc, e[0]),
  23130. Uc.copy(Qc, e[1]);
  23131. var r = []
  23132. , i = r[0] = jc()
  23133. , n = r[1] = jc()
  23134. , a = r[2] = jc()
  23135. , o = r[3] = jc();
  23136. t.dataToPoint(Kc, i),
  23137. t.dataToPoint(Qc, o),
  23138. kc(Xc, i),
  23139. Hc(qc, o, i),
  23140. kc(qc, qc),
  23141. Vc(Zc, qc, Xc),
  23142. kc(Zc, Zc),
  23143. Vc(qc, Xc, Zc),
  23144. Wc(n, Xc, qc),
  23145. kc(n, n),
  23146. kc(Xc, o),
  23147. Hc(qc, i, o),
  23148. kc(qc, qc),
  23149. Vc(Zc, qc, Xc),
  23150. kc(Zc, Zc),
  23151. Vc(qc, Xc, Zc),
  23152. Wc(a, Xc, qc),
  23153. kc(a, a),
  23154. Wc(Yc, i, o),
  23155. kc(Yc, Yc);
  23156. var s = Gc.dot(i, Yc)
  23157. , l = Gc.dot(Yc, n)
  23158. , h = (Math.max(Gc.len(i), Gc.len(o)) - s) / l * 2;
  23159. return Gc.scaleAndAdd(n, i, n, h),
  23160. Gc.scaleAndAdd(a, o, a, h),
  23161. r
  23162. }
  23163. function $c(e, t) {
  23164. for (var r = new Float32Array(3 * e.length), i = 0, n = [], a = 0; a < e.length; a++)
  23165. t.dataToPoint(e[a], n),
  23166. r[i++] = n[0],
  23167. r[i++] = n[1],
  23168. r[i++] = n[2];
  23169. return r
  23170. }
  23171. function ed(e) {
  23172. var t = [];
  23173. return e.each((function (r) {
  23174. var i = e.getItemModel(r)
  23175. , n = i.option instanceof Array ? i.option : i.getShallow("coords", !0);
  23176. t.push(n)
  23177. }
  23178. )),
  23179. {
  23180. coordsList: t
  23181. }
  23182. }
  23183. function td(e, t, r) {
  23184. var i = e.getData()
  23185. , n = e.get("polyline")
  23186. , a = ed(i);
  23187. i.setLayout("lineType", n ? "polyline" : "cubicBezier"),
  23188. i.each((function (e) {
  23189. var o = a.coordsList[e]
  23190. , s = n ? $c(o, t) : function (e, t, r) {
  23191. var i = []
  23192. , n = i[0] = Gc.create()
  23193. , a = i[1] = Gc.create()
  23194. , o = i[2] = Gc.create()
  23195. , s = i[3] = Gc.create();
  23196. t.dataToPoint(e[0], n),
  23197. t.dataToPoint(e[1], s);
  23198. var l = Gc.dist(n, s);
  23199. return Gc.lerp(a, n, s, .3),
  23200. Gc.lerp(o, n, s, .3),
  23201. Gc.scaleAndAdd(a, a, r, Math.min(.1 * l, 10)),
  23202. Gc.scaleAndAdd(o, o, r, Math.min(.1 * l, 10)),
  23203. i
  23204. }(o, t, r);
  23205. i.setItemLayout(e, s)
  23206. }
  23207. ))
  23208. }
  23209. function rd(e, t) {
  23210. e.eachSeriesByType("lines3D", (function (e) {
  23211. var t = e.coordinateSystem;
  23212. "globe" === t.type ? function (e, t) {
  23213. var r = e.getData()
  23214. , i = e.get("polyline");
  23215. r.setLayout("lineType", i ? "polyline" : "cubicBezier");
  23216. var n = ed(r);
  23217. r.each((function (e) {
  23218. var a = n.coordsList[e]
  23219. , o = i ? $c : Jc;
  23220. r.setItemLayout(e, o(a, t))
  23221. }
  23222. ))
  23223. }(e, t) : "geo3D" === t.type ? td(e, t, [0, 1, 0]) : "mapbox3D" !== t.type && "maptalks3D" !== t.type || td(e, t, [0, 0, 1])
  23224. }
  23225. ))
  23226. }
  23227. const id = i.SeriesModel.extend({
  23228. type: "series.lines3D",
  23229. dependencies: ["globe"],
  23230. visualStyleAccessPath: "lineStyle",
  23231. visualDrawType: "stroke",
  23232. getInitialData: function (e, t) {
  23233. var r = new i.List(["value"], this);
  23234. return r.hasItemOption = !1,
  23235. r.initData(e.data, [], (function (e, t, i, n) {
  23236. if (e instanceof Array)
  23237. return NaN;
  23238. r.hasItemOption = !0;
  23239. var a = e.value;
  23240. return null != a ? a instanceof Array ? a[n] : a : void 0
  23241. }
  23242. )),
  23243. r
  23244. },
  23245. defaultOption: {
  23246. coordinateSystem: "globe",
  23247. globeIndex: 0,
  23248. geo3DIndex: 0,
  23249. zlevel: -10,
  23250. polyline: !1,
  23251. effect: {
  23252. show: !1,
  23253. period: 4,
  23254. trailWidth: 4,
  23255. trailLength: .2,
  23256. spotIntensity: 6
  23257. },
  23258. silent: !0,
  23259. blendMode: "source-over",
  23260. lineStyle: {
  23261. width: 1,
  23262. opacity: .5
  23263. }
  23264. }
  23265. });
  23266. var nd = Po.vec3;
  23267. Ka.Shader.import("@export ecgl.trail2.vertex\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute float dist;\nattribute float distAll;\nattribute float start;\n\nattribute vec4 a_Color : COLOR;\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nuniform float speed : 0;\nuniform float trailLength: 0.3;\nuniform float time;\nuniform float period: 1000;\n\nuniform float spotSize: 1;\n\nvarying vec4 v_Color;\nvarying float v_Percent;\nvarying float v_SpotPercent;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n\n#ifdef CONSTANT_SPEED\n float t = mod((speed * time + start) / distAll, 1. + trailLength) - trailLength;\n#else\n float t = mod((time + start) / period, 1. + trailLength) - trailLength;\n#endif\n\n float trailLen = distAll * trailLength;\n\n v_Percent = (dist - t * distAll) / trailLen;\n\n v_SpotPercent = spotSize / distAll;\n\n }\n@end\n\n\n@export ecgl.trail2.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform float spotIntensity: 5;\n\nvarying vec4 v_Color;\nvarying float v_Percent;\nvarying float v_SpotPercent;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n if (v_Percent > 1.0 || v_Percent < 0.0) {\n discard;\n }\n\n float fade = v_Percent;\n\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n\n if (v_Percent > (1.0 - v_SpotPercent)) {\n gl_FragColor.rgb *= spotIntensity;\n }\n\n gl_FragColor.a *= fade;\n}\n\n@end");
  23268. const ad = Ka.Mesh.extend((function () {
  23269. var e = new Ka.Material({
  23270. shader: new Ka.Shader(Ka.Shader.source("ecgl.trail2.vertex"), Ka.Shader.source("ecgl.trail2.fragment")),
  23271. transparent: !0,
  23272. depthMask: !1
  23273. })
  23274. , t = new Ro({
  23275. dynamic: !0
  23276. });
  23277. return t.createAttribute("dist", "float", 1),
  23278. t.createAttribute("distAll", "float", 1),
  23279. t.createAttribute("start", "float", 1),
  23280. {
  23281. geometry: t,
  23282. material: e,
  23283. culling: !1,
  23284. $ignorePicking: !0
  23285. }
  23286. }
  23287. ), {
  23288. updateData: function (e, t, r) {
  23289. var i = e.hostModel
  23290. , n = this.geometry
  23291. , a = i.getModel("effect")
  23292. , o = a.get("trailWidth") * t.getDevicePixelRatio()
  23293. , s = a.get("trailLength")
  23294. , l = i.get("effect.constantSpeed")
  23295. , h = 1e3 * i.get("effect.period")
  23296. , u = null != l;
  23297. u ? this.material.set("speed", l / 1e3) : this.material.set("period", h),
  23298. this.material[u ? "define" : "undefine"]("vertex", "CONSTANT_SPEED");
  23299. var c = i.get("polyline");
  23300. n.trailLength = s,
  23301. this.material.set("trailLength", s),
  23302. n.resetOffset(),
  23303. ["position", "positionPrev", "positionNext"].forEach((function (e) {
  23304. n.attributes[e].value = r.attributes[e].value
  23305. }
  23306. )),
  23307. ["dist", "distAll", "start", "offset", "color"].forEach((function (e) {
  23308. n.attributes[e].init(n.vertexCount)
  23309. }
  23310. )),
  23311. n.indices = r.indices;
  23312. var d = []
  23313. , f = a.get("trailColor")
  23314. , p = a.get("trailOpacity")
  23315. , m = null != f
  23316. , g = null != p;
  23317. this.updateWorldTransform();
  23318. var _ = this.worldTransform.x.len()
  23319. , v = this.worldTransform.y.len()
  23320. , y = this.worldTransform.z.len()
  23321. , x = 0
  23322. , b = 0;
  23323. e.each((function (t) {
  23324. var i = e.getItemLayout(t)
  23325. , a = g ? p : Rh(e, t)
  23326. , s = Ih(e, t);
  23327. null == a && (a = 1),
  23328. (d = Ka.parseColor(m ? f : s, d))[3] *= a;
  23329. for (var l = c ? r.getPolylineVertexCount(i) : r.getCubicCurveVertexCount(i[0], i[1], i[2], i[3]), w = 0, T = [], S = [], M = x; M < x + l; M++)
  23330. n.attributes.position.get(M, T),
  23331. T[0] *= _,
  23332. T[1] *= v,
  23333. T[2] *= y,
  23334. M > x && (w += nd.dist(T, S)),
  23335. n.attributes.dist.set(M, w),
  23336. nd.copy(S, T);
  23337. b = Math.max(b, w);
  23338. var A = Math.random() * (u ? w : h);
  23339. for (M = x; M < x + l; M++)
  23340. n.attributes.distAll.set(M, w),
  23341. n.attributes.start.set(M, A),
  23342. n.attributes.offset.set(M, (r.attributes.offset.get(M) > 0 ? 1 : -1) * o / 2),
  23343. n.attributes.color.set(M, d);
  23344. x += l
  23345. }
  23346. )),
  23347. this.material.set("spotSize", .1 * b * s),
  23348. this.material.set("spotIntensity", a.get("spotIntensity")),
  23349. n.dirty()
  23350. },
  23351. setAnimationTime: function (e) {
  23352. this.material.set("time", e)
  23353. }
  23354. });
  23355. Ka.Shader.import(is);
  23356. const od = i.ChartView.extend({
  23357. type: "lines3D",
  23358. __ecgl__: !0,
  23359. init: function (e, t) {
  23360. this.groupGL = new Ka.Node,
  23361. this._meshLinesMaterial = new Ka.Material({
  23362. shader: Ka.createShader("ecgl.meshLines3D"),
  23363. transparent: !0,
  23364. depthMask: !1
  23365. }),
  23366. this._linesMesh = new Ka.Mesh({
  23367. geometry: new Ro,
  23368. material: this._meshLinesMaterial,
  23369. $ignorePicking: !0
  23370. }),
  23371. this._trailMesh = new ad
  23372. },
  23373. render: function (e, t, r) {
  23374. this.groupGL.add(this._linesMesh);
  23375. var i = e.coordinateSystem
  23376. , n = e.getData();
  23377. if (i && i.viewGL) {
  23378. i.viewGL.add(this.groupGL),
  23379. this._updateLines(e, t, r);
  23380. var a = i.viewGL.isLinearSpace() ? "define" : "undefine";
  23381. this._linesMesh.material[a]("fragment", "SRGB_DECODE"),
  23382. this._trailMesh.material[a]("fragment", "SRGB_DECODE")
  23383. }
  23384. var o = this._trailMesh;
  23385. if (o.stopAnimation(),
  23386. e.get("effect.show")) {
  23387. this.groupGL.add(o),
  23388. o.updateData(n, r, this._linesMesh.geometry),
  23389. o.__time = o.__time || 0;
  23390. var s = 36e5;
  23391. this._curveEffectsAnimator = o.animate("", {
  23392. loop: !0
  23393. }).when(s, {
  23394. __time: s
  23395. }).during((function () {
  23396. o.setAnimationTime(o.__time)
  23397. }
  23398. )).start()
  23399. } else
  23400. this.groupGL.remove(o),
  23401. this._curveEffectsAnimator = null;
  23402. this._linesMesh.material.blend = this._trailMesh.material.blend = "lighter" === e.get("blendMode") ? Ka.additiveBlend : null
  23403. },
  23404. pauseEffect: function () {
  23405. this._curveEffectsAnimator && this._curveEffectsAnimator.pause()
  23406. },
  23407. resumeEffect: function () {
  23408. this._curveEffectsAnimator && this._curveEffectsAnimator.resume()
  23409. },
  23410. toggleEffect: function () {
  23411. var e = this._curveEffectsAnimator;
  23412. e && (e.isPaused() ? e.resume() : e.pause())
  23413. },
  23414. _updateLines: function (e, t, r) {
  23415. var i = e.getData()
  23416. , n = e.coordinateSystem
  23417. , a = this._linesMesh.geometry
  23418. , o = e.get("polyline");
  23419. a.expandLine = !0;
  23420. var s = function (e) {
  23421. return null != e.radius ? e.radius : null != e.size ? Math.max(e.size[0], e.size[1], e.size[2]) : 100
  23422. }(n);
  23423. a.segmentScale = s / 20;
  23424. var l = "lineStyle.width".split(".")
  23425. , h = r.getDevicePixelRatio()
  23426. , u = 0;
  23427. i.each((function (e) {
  23428. var t = i.getItemModel(e).get(l);
  23429. null == t && (t = 1),
  23430. i.setItemVisual(e, "lineWidth", t),
  23431. u = Math.max(t, u)
  23432. }
  23433. )),
  23434. a.useNativeLine = !1;
  23435. var c = 0
  23436. , d = 0;
  23437. i.each((function (e) {
  23438. var t = i.getItemLayout(e);
  23439. o ? (c += a.getPolylineVertexCount(t),
  23440. d += a.getPolylineTriangleCount(t)) : (c += a.getCubicCurveVertexCount(t[0], t[1], t[2], t[3]),
  23441. d += a.getCubicCurveTriangleCount(t[0], t[1], t[2], t[3]))
  23442. }
  23443. )),
  23444. a.setVertexCount(c),
  23445. a.setTriangleCount(d),
  23446. a.resetOffset();
  23447. var f = [];
  23448. i.each((function (e) {
  23449. var t = i.getItemLayout(e)
  23450. , r = Ih(i, e)
  23451. , n = Rh(i, e)
  23452. , s = i.getItemVisual(e, "lineWidth") * h;
  23453. null == n && (n = 1),
  23454. (f = Ka.parseColor(r, f))[3] *= n,
  23455. o ? a.addPolyline(t, f, s) : a.addCubicCurve(t[0], t[1], t[2], t[3], f, s)
  23456. }
  23457. )),
  23458. a.dirty()
  23459. },
  23460. remove: function () {
  23461. this.groupGL.removeAll()
  23462. },
  23463. dispose: function () {
  23464. this.groupGL.removeAll()
  23465. }
  23466. });
  23467. function sd(e, t) {
  23468. for (var r = [], i = 0; i < t.length; i++)
  23469. r.push(e.dataToPoint(t[i]));
  23470. return r
  23471. }
  23472. (0,
  23473. i.use)((function (e) {
  23474. e.registerChartView(od),
  23475. e.registerSeriesModel(id),
  23476. e.registerLayout(rd),
  23477. e.registerAction({
  23478. type: "lines3DPauseEffect",
  23479. event: "lines3deffectpaused",
  23480. update: "series.lines3D:pauseEffect"
  23481. }, (function () { }
  23482. )),
  23483. e.registerAction({
  23484. type: "lines3DResumeEffect",
  23485. event: "lines3deffectresumed",
  23486. update: "series.lines3D:resumeEffect"
  23487. }, (function () { }
  23488. )),
  23489. e.registerAction({
  23490. type: "lines3DToggleEffect",
  23491. event: "lines3deffectchanged",
  23492. update: "series.lines3D:toggleEffect"
  23493. }, (function () { }
  23494. ))
  23495. }
  23496. ));
  23497. var ld = i.SeriesModel.extend({
  23498. type: "series.polygons3D",
  23499. getRegionModel: function (e) {
  23500. return this.getData().getItemModel(e)
  23501. },
  23502. getRegionPolygonCoords: function (e) {
  23503. var t = this.coordinateSystem
  23504. , r = this.getData().getItemModel(e)
  23505. , i = r.option instanceof Array ? r.option : r.getShallow("coords");
  23506. r.get("multiPolygon") || (i = [i]);
  23507. for (var n = [], a = 0; a < i.length; a++) {
  23508. for (var o = [], s = 1; s < i[a].length; s++)
  23509. o.push(sd(t, i[a][s]));
  23510. n.push({
  23511. exterior: sd(t, i[a][0]),
  23512. interiors: o
  23513. })
  23514. }
  23515. return n
  23516. },
  23517. getInitialData: function (e) {
  23518. var t = new i.List(["value"], this);
  23519. return t.hasItemOption = !1,
  23520. t.initData(e.data, [], (function (e, r, i, n) {
  23521. if (e instanceof Array)
  23522. return NaN;
  23523. t.hasItemOption = !0;
  23524. var a = e.value;
  23525. return null != a ? a instanceof Array ? a[n] : a : void 0
  23526. }
  23527. )),
  23528. t
  23529. },
  23530. defaultOption: {
  23531. show: !0,
  23532. data: null,
  23533. multiPolygon: !1,
  23534. progressiveThreshold: 1e3,
  23535. progressive: 1e3,
  23536. zlevel: -10,
  23537. label: {
  23538. show: !1,
  23539. distance: 2,
  23540. textStyle: {
  23541. fontSize: 20,
  23542. color: "#000",
  23543. backgroundColor: "rgba(255,255,255,0.7)",
  23544. padding: 3,
  23545. borderRadius: 4
  23546. }
  23547. },
  23548. itemStyle: {
  23549. color: "#fff",
  23550. borderWidth: 0,
  23551. borderColor: "#333"
  23552. },
  23553. emphasis: {
  23554. itemStyle: {
  23555. color: "#639fc0"
  23556. },
  23557. label: {
  23558. show: !0
  23559. }
  23560. }
  23561. }
  23562. });
  23563. i.util.merge(ld.prototype, Kl);
  23564. const hd = ld
  23565. , ud = i.ChartView.extend({
  23566. type: "polygons3D",
  23567. __ecgl__: !0,
  23568. init: function (e, t) {
  23569. this.groupGL = new Ka.Node,
  23570. this._geo3DBuilderList = [],
  23571. this._currentStep = 0
  23572. },
  23573. render: function (e, t, r) {
  23574. this.groupGL.removeAll();
  23575. var i = e.coordinateSystem;
  23576. i && i.viewGL && i.viewGL.add(this.groupGL);
  23577. var n = this._geo3DBuilderList[0];
  23578. n || ((n = new Uh(r)).extrudeY = "mapbox3D" !== i.type && "maptalks3D" !== i.type,
  23579. this._geo3DBuilderList[0] = n),
  23580. this._updateShaderDefines(i, n),
  23581. n.update(e, t, r),
  23582. this._geo3DBuilderList.length = 1,
  23583. this.groupGL.add(n.rootNode)
  23584. },
  23585. incrementalPrepareRender: function (e, t, r) {
  23586. this.groupGL.removeAll();
  23587. var i = e.coordinateSystem;
  23588. i && i.viewGL && i.viewGL.add(this.groupGL),
  23589. this._currentStep = 0
  23590. },
  23591. incrementalRender: function (e, t, r, i) {
  23592. var n = this._geo3DBuilderList[this._currentStep]
  23593. , a = t.coordinateSystem;
  23594. n || ((n = new Uh(i)).extrudeY = "mapbox3D" !== a.type && "maptalks3D" !== a.type,
  23595. this._geo3DBuilderList[this._currentStep] = n),
  23596. n.update(t, r, i, e.start, e.end),
  23597. this.groupGL.add(n.rootNode),
  23598. this._updateShaderDefines(a, n),
  23599. this._currentStep++
  23600. },
  23601. _updateShaderDefines: function (e, t) {
  23602. var r = e.viewGL.isLinearSpace() ? "define" : "undefine";
  23603. t.rootNode.traverse((function (t) {
  23604. t.material && (t.material[r]("fragment", "SRGB_DECODE"),
  23605. "mapbox3D" !== e.type && "maptalks3D" !== e.type || (t.material.define("fragment", "NORMAL_UP_AXIS", 2),
  23606. t.material.define("fragment", "NORMAL_FRONT_AXIS", 1)))
  23607. }
  23608. ))
  23609. },
  23610. remove: function () {
  23611. this.groupGL.removeAll()
  23612. },
  23613. dispose: function () {
  23614. this.groupGL.removeAll(),
  23615. this._geo3DBuilderList.forEach((function (e) {
  23616. e.dispose()
  23617. }
  23618. ))
  23619. }
  23620. });
  23621. (0,
  23622. i.use)((function (e) {
  23623. e.registerChartView(ud),
  23624. e.registerSeriesModel(hd)
  23625. }
  23626. ));
  23627. var cd = i.SeriesModel.extend({
  23628. type: "series.surface",
  23629. dependencies: ["globe", "grid3D", "geo3D"],
  23630. visualStyleAccessPath: "itemStyle",
  23631. formatTooltip: function (e) {
  23632. return oc(this, e)
  23633. },
  23634. getInitialData: function (e, t) {
  23635. var r = e.data;
  23636. function n(e) {
  23637. return !(isNaN(e.min) || isNaN(e.max) || isNaN(e.step))
  23638. }
  23639. function a(e) {
  23640. var t = i.number.getPrecisionSafe;
  23641. return Math.max(t(e.min), t(e.max), t(e.step)) + 1
  23642. }
  23643. if (!r)
  23644. if (e.parametric) {
  23645. var o = e.parametricEquation || {}
  23646. , s = o.u || {}
  23647. , l = o.v || {};
  23648. ["u", "v"].forEach((function (e) {
  23649. n(o[e])
  23650. }
  23651. )),
  23652. ["x", "y", "z"].forEach((function (e) {
  23653. o[e]
  23654. }
  23655. ));
  23656. var h = Math.floor((s.max + s.step - s.min) / s.step)
  23657. , u = Math.floor((l.max + l.step - l.min) / l.step);
  23658. r = new Float32Array(h * u * 5);
  23659. var c = a(s)
  23660. , d = a(l);
  23661. for (S = 0,
  23662. M = 0; M < u; M++)
  23663. for (A = 0; A < h; A++) {
  23664. var f = A * s.step + s.min
  23665. , p = M * l.step + l.min
  23666. , m = i.number.round(Math.min(f, s.max), c)
  23667. , g = i.number.round(Math.min(p, l.max), d);
  23668. E = o.x(m, g),
  23669. C = o.y(m, g),
  23670. P = o.z(m, g),
  23671. r[S++] = E,
  23672. r[S++] = C,
  23673. r[S++] = P,
  23674. r[S++] = m,
  23675. r[S++] = g
  23676. }
  23677. } else {
  23678. var _ = e.equation || {}
  23679. , v = _.x || {}
  23680. , y = _.y || {};
  23681. if (["x", "y"].forEach((function (e) {
  23682. n(_[e])
  23683. }
  23684. )),
  23685. "function" != typeof _.z)
  23686. return;
  23687. var x = Math.floor((v.max + v.step - v.min) / v.step)
  23688. , b = Math.floor((y.max + y.step - y.min) / y.step);
  23689. r = new Float32Array(x * b * 3);
  23690. for (var w = a(v), T = a(y), S = 0, M = 0; M < b; M++)
  23691. for (var A = 0; A < x; A++) {
  23692. var E = A * v.step + v.min
  23693. , C = M * y.step + y.min
  23694. , D = i.number.round(Math.min(E, v.max), w)
  23695. , L = i.number.round(Math.min(C, y.max), T)
  23696. , P = _.z(D, L);
  23697. r[S++] = D,
  23698. r[S++] = L,
  23699. r[S++] = P
  23700. }
  23701. }
  23702. var O = ["x", "y", "z"];
  23703. return e.parametric && O.push("u", "v"),
  23704. sc(this, O, r)
  23705. },
  23706. defaultOption: {
  23707. coordinateSystem: "cartesian3D",
  23708. zlevel: -10,
  23709. grid3DIndex: 0,
  23710. shading: "lambert",
  23711. parametric: !1,
  23712. wireframe: {
  23713. show: !0,
  23714. lineStyle: {
  23715. color: "rgba(0,0,0,0.5)",
  23716. width: 1
  23717. }
  23718. },
  23719. equation: {
  23720. x: {
  23721. min: -1,
  23722. max: 1,
  23723. step: .1
  23724. },
  23725. y: {
  23726. min: -1,
  23727. max: 1,
  23728. step: .1
  23729. },
  23730. z: null
  23731. },
  23732. parametricEquation: {
  23733. u: {
  23734. min: -1,
  23735. max: 1,
  23736. step: .1
  23737. },
  23738. v: {
  23739. min: -1,
  23740. max: 1,
  23741. step: .1
  23742. },
  23743. x: null,
  23744. y: null,
  23745. z: null
  23746. },
  23747. dataShape: null,
  23748. itemStyle: {},
  23749. animationDurationUpdate: 500
  23750. }
  23751. });
  23752. i.util.merge(cd.prototype, Kl);
  23753. const dd = cd;
  23754. var fd = Po.vec3;
  23755. const pd = i.ChartView.extend({
  23756. type: "surface",
  23757. __ecgl__: !0,
  23758. init: function (e, t) {
  23759. this.groupGL = new Ka.Node
  23760. },
  23761. render: function (e, t, r) {
  23762. var i = this._prevSurfaceMesh;
  23763. this._prevSurfaceMesh = this._surfaceMesh,
  23764. this._surfaceMesh = i,
  23765. this._surfaceMesh || (this._surfaceMesh = this._createSurfaceMesh()),
  23766. this.groupGL.remove(this._prevSurfaceMesh),
  23767. this.groupGL.add(this._surfaceMesh);
  23768. var n = e.coordinateSystem
  23769. , a = e.get("shading")
  23770. , o = e.getData()
  23771. , s = "ecgl." + a;
  23772. if (this._surfaceMesh.material && this._surfaceMesh.material.shader.name === s || (this._surfaceMesh.material = Ka.createMaterial(s, ["VERTEX_COLOR", "DOUBLE_SIDED"])),
  23773. Ka.setMaterialFromModel(a, this._surfaceMesh.material, e, r),
  23774. n && n.viewGL) {
  23775. n.viewGL.add(this.groupGL);
  23776. var l = n.viewGL.isLinearSpace() ? "define" : "undefine";
  23777. this._surfaceMesh.material[l]("fragment", "SRGB_DECODE")
  23778. }
  23779. var h = e.get("parametric")
  23780. , u = e.get("dataShape");
  23781. u || (u = this._getDataShape(o, h));
  23782. var c = e.getModel("wireframe")
  23783. , d = c.get("lineStyle.width")
  23784. , f = c.get("show") && d > 0;
  23785. this._updateSurfaceMesh(this._surfaceMesh, e, u, f);
  23786. var p = this._surfaceMesh.material;
  23787. f ? (p.define("WIREFRAME_QUAD"),
  23788. p.set("wireframeLineWidth", d),
  23789. p.set("wireframeLineColor", Ka.parseColor(c.get("lineStyle.color")))) : p.undefine("WIREFRAME_QUAD"),
  23790. this._initHandler(e, r),
  23791. this._updateAnimation(e)
  23792. },
  23793. _updateAnimation: function (e) {
  23794. Ka.updateVertexAnimation([["prevPosition", "position"], ["prevNormal", "normal"]], this._prevSurfaceMesh, this._surfaceMesh, e)
  23795. },
  23796. _createSurfaceMesh: function () {
  23797. var e = new Ka.Mesh({
  23798. geometry: new Ka.Geometry({
  23799. dynamic: !0,
  23800. sortTriangles: !0
  23801. }),
  23802. shadowDepthMaterial: new Ka.Material({
  23803. shader: new Ka.Shader(Ka.Shader.source("ecgl.sm.depth.vertex"), Ka.Shader.source("ecgl.sm.depth.fragment"))
  23804. }),
  23805. culling: !1,
  23806. renderOrder: 10,
  23807. renderNormal: !0
  23808. });
  23809. return e.geometry.createAttribute("barycentric", "float", 4),
  23810. e.geometry.createAttribute("prevPosition", "float", 3),
  23811. e.geometry.createAttribute("prevNormal", "float", 3),
  23812. Object.assign(e.geometry, Nh),
  23813. e
  23814. },
  23815. _initHandler: function (e, t) {
  23816. var r = e.getData()
  23817. , i = this._surfaceMesh
  23818. , n = e.coordinateSystem;
  23819. i.seriesIndex = e.seriesIndex;
  23820. var a = -1;
  23821. i.off("mousemove"),
  23822. i.off("mouseout"),
  23823. i.on("mousemove", (function (e) {
  23824. var o = function (e, t) {
  23825. for (var r = 1 / 0, n = -1, a = [], o = 0; o < e.length; o++) {
  23826. i.geometry.attributes.position.get(e[o], a);
  23827. var s = fd.dist(t.array, a);
  23828. s < r && (r = s,
  23829. n = e[o])
  23830. }
  23831. return n
  23832. }(e.triangle, e.point);
  23833. if (o >= 0) {
  23834. var s = [];
  23835. i.geometry.attributes.position.get(o, s);
  23836. for (var l = n.pointToData(s), h = 1 / 0, u = -1, c = [], d = 0; d < r.count(); d++) {
  23837. c[0] = r.get("x", d),
  23838. c[1] = r.get("y", d),
  23839. c[2] = r.get("z", d);
  23840. var f = fd.squaredDistance(c, l);
  23841. f < h && (u = d,
  23842. h = f)
  23843. }
  23844. u !== a && t.dispatchAction({
  23845. type: "grid3DShowAxisPointer",
  23846. value: l
  23847. }),
  23848. a = u,
  23849. i.dataIndex = u
  23850. } else
  23851. i.dataIndex = -1
  23852. }
  23853. ), this),
  23854. i.on("mouseout", (function (e) {
  23855. a = -1,
  23856. i.dataIndex = -1,
  23857. t.dispatchAction({
  23858. type: "grid3DHideAxisPointer"
  23859. })
  23860. }
  23861. ), this)
  23862. },
  23863. _updateSurfaceMesh: function (e, t, r, i) {
  23864. var n = e.geometry
  23865. , a = t.getData()
  23866. , o = a.getLayout("points")
  23867. , s = 0;
  23868. a.each((function (e) {
  23869. a.hasValue(e) || s++
  23870. }
  23871. ));
  23872. var l = s || i
  23873. , h = n.attributes.position
  23874. , u = n.attributes.normal
  23875. , c = n.attributes.texcoord0
  23876. , d = n.attributes.barycentric
  23877. , f = n.attributes.color
  23878. , p = r[0]
  23879. , m = r[1]
  23880. , g = "color" !== t.get("shading");
  23881. if (l) {
  23882. var _ = (p - 1) * (m - 1) * 4;
  23883. h.init(_),
  23884. i && d.init(_)
  23885. } else
  23886. h.value = new Float32Array(o);
  23887. f.init(n.vertexCount),
  23888. c.init(n.vertexCount);
  23889. var v, y = [0, 3, 1, 1, 3, 2], x = [[1, 1, 0, 0], [0, 1, 0, 1], [1, 0, 0, 1], [1, 0, 1, 0]], b = n.indices = new (n.vertexCount > 65535 ? Uint32Array : Uint16Array)((p - 1) * (m - 1) * 6), w = function (e, t, r) {
  23890. r[1] = e * m + t,
  23891. r[0] = e * m + t + 1,
  23892. r[3] = (e + 1) * m + t + 1,
  23893. r[2] = (e + 1) * m + t
  23894. }, T = !1;
  23895. if (l) {
  23896. var S = []
  23897. , M = []
  23898. , A = 0;
  23899. g ? u.init(n.vertexCount) : u.value = null;
  23900. for (var E = [[], [], []], C = [], D = [], L = fd.create(), P = function (e, t, r) {
  23901. var i = 3 * t;
  23902. return r[0] = e[i],
  23903. r[1] = e[i + 1],
  23904. r[2] = e[i + 2],
  23905. r
  23906. }, O = new Float32Array(o.length), N = new Float32Array(o.length / 3 * 4), I = 0; I < a.count(); I++)
  23907. if (a.hasValue(I)) {
  23908. var R = Ka.parseColor(Ih(a, I));
  23909. null != (X = Rh(a, I)) && (R[3] *= X),
  23910. R[3] < .99 && (T = !0);
  23911. for (var B = 0; B < 4; B++)
  23912. N[4 * I + B] = R[B]
  23913. }
  23914. var F = [1e7, 1e7, 1e7];
  23915. for (I = 0; I < p - 1; I++)
  23916. for (var z = 0; z < m - 1; z++) {
  23917. var G = 4 * (I * (m - 1) + z);
  23918. w(I, z, S);
  23919. var U = !1;
  23920. for (B = 0; B < 4; B++)
  23921. P(o, S[B], M),
  23922. v = M,
  23923. (isNaN(v[0]) || isNaN(v[1]) || isNaN(v[2])) && (U = !0);
  23924. for (B = 0; B < 4; B++)
  23925. U ? h.set(G + B, F) : (P(o, S[B], M),
  23926. h.set(G + B, M)),
  23927. i && d.set(G + B, x[B]);
  23928. for (B = 0; B < 6; B++)
  23929. b[A++] = y[B] + G;
  23930. if (g && !U)
  23931. for (B = 0; B < 2; B++) {
  23932. for (var k = 3 * B, V = 0; V < 3; V++)
  23933. P(o, j = S[y[k] + V], E[V]);
  23934. for (fd.sub(C, E[0], E[1]),
  23935. fd.sub(D, E[1], E[2]),
  23936. fd.cross(L, C, D),
  23937. V = 0; V < 3; V++) {
  23938. var H = 3 * S[y[k] + V];
  23939. O[H] = O[H] + L[0],
  23940. O[H + 1] = O[H + 1] + L[1],
  23941. O[H + 2] = O[H + 2] + L[2]
  23942. }
  23943. }
  23944. }
  23945. if (g)
  23946. for (I = 0; I < O.length / 3; I++)
  23947. P(O, I, L),
  23948. fd.normalize(L, L),
  23949. O[3 * I] = L[0],
  23950. O[3 * I + 1] = L[1],
  23951. O[3 * I + 2] = L[2];
  23952. R = [];
  23953. var W = [];
  23954. for (I = 0; I < p - 1; I++)
  23955. for (z = 0; z < m - 1; z++)
  23956. for (G = 4 * (I * (m - 1) + z),
  23957. w(I, z, S),
  23958. B = 0; B < 4; B++) {
  23959. for (V = 0; V < 4; V++)
  23960. R[V] = N[4 * S[B] + V];
  23961. f.set(G + B, R),
  23962. g && (P(O, S[B], L),
  23963. u.set(G + B, L));
  23964. var j = S[B];
  23965. W[0] = j % m / (m - 1),
  23966. W[1] = Math.floor(j / m) / (p - 1),
  23967. c.set(G + B, W)
  23968. }
  23969. } else {
  23970. for (W = [],
  23971. I = 0; I < a.count(); I++) {
  23972. var X;
  23973. W[0] = I % m / (m - 1),
  23974. W[1] = Math.floor(I / m) / (p - 1),
  23975. R = Ka.parseColor(Ih(a, I)),
  23976. null != (X = Rh(a, I)) && (R[3] *= X),
  23977. R[3] < .99 && (T = !0),
  23978. f.set(I, R),
  23979. c.set(I, W)
  23980. }
  23981. S = [];
  23982. var q = 0;
  23983. for (I = 0; I < p - 1; I++)
  23984. for (z = 0; z < m - 1; z++)
  23985. for (w(I, z, S),
  23986. B = 0; B < 6; B++)
  23987. b[q++] = S[y[B]];
  23988. g ? n.generateVertexNormals() : u.value = null
  23989. }
  23990. e.material.get("normalMap") && n.generateTangents(),
  23991. n.updateBoundingBox(),
  23992. n.dirty(),
  23993. e.material.transparent = T,
  23994. e.material.depthMask = !T
  23995. },
  23996. _getDataShape: function (e, t) {
  23997. for (var r = -1 / 0, i = 0, n = 0, a = !1, o = t ? "u" : "x", s = e.count(), l = 0; l < s; l++) {
  23998. var h = e.get(o, l);
  23999. h < r && (n = 0,
  24000. i++),
  24001. r = h,
  24002. n++
  24003. }
  24004. if (i && 1 !== n || (a = !0),
  24005. !a)
  24006. return [i + 1, n];
  24007. for (var u = Math.floor(Math.sqrt(s)); u > 0;) {
  24008. if (Math.floor(s / u) === s / u)
  24009. return [u, s / u];
  24010. u--
  24011. }
  24012. return [u = Math.floor(Math.sqrt(s)), u]
  24013. },
  24014. dispose: function () {
  24015. this.groupGL.removeAll()
  24016. },
  24017. remove: function () {
  24018. this.groupGL.removeAll()
  24019. }
  24020. });
  24021. function md(e, t) {
  24022. for (var r = [], i = 0; i < t.length; i++)
  24023. r.push(e.dataToPoint(t[i]));
  24024. return r
  24025. }
  24026. (0,
  24027. i.use)((function (e) {
  24028. e.registerChartView(pd),
  24029. e.registerSeriesModel(dd),
  24030. e.registerLayout((function (e, t) {
  24031. e.eachSeriesByType("surface", (function (e) {
  24032. var t = e.coordinateSystem;
  24033. t && t.type;
  24034. var r = e.getData()
  24035. , i = new Float32Array(3 * r.count())
  24036. , n = [NaN, NaN, NaN];
  24037. if (t && "cartesian3D" === t.type) {
  24038. var a = t.dimensions.map((function (t) {
  24039. return e.coordDimToDataDim(t)[0]
  24040. }
  24041. ));
  24042. r.each(a, (function (e, a, o, s) {
  24043. var l;
  24044. l = r.hasValue(s) ? t.dataToPoint([e, a, o]) : n,
  24045. i[3 * s] = l[0],
  24046. i[3 * s + 1] = l[1],
  24047. i[3 * s + 2] = l[2]
  24048. }
  24049. ))
  24050. }
  24051. r.setLayout("points", i)
  24052. }
  24053. ))
  24054. }
  24055. ))
  24056. }
  24057. ));
  24058. var gd = i.SeriesModel.extend({
  24059. type: "series.map3D",
  24060. layoutMode: "box",
  24061. coordinateSystem: null,
  24062. visualStyleAccessPath: "itemStyle",
  24063. optionUpdated: function (e) {
  24064. e = e || {};
  24065. var t = this.get("coordinateSystem");
  24066. null != t && "geo3D" !== t && (this.get("groundPlane.show") && (this.option.groundPlane.show = !1),
  24067. this._geo = null)
  24068. },
  24069. getInitialData: function (e) {
  24070. e.data = this.getFilledRegions(e.data, e.map);
  24071. var t = i.helper.createDimensions(e.data, {
  24072. coordDimensions: ["value"]
  24073. })
  24074. , r = new i.List(t, this);
  24075. r.initData(e.data);
  24076. var n = {};
  24077. return r.each((function (e) {
  24078. var t = r.getName(e)
  24079. , i = r.getItemModel(e);
  24080. n[t] = i
  24081. }
  24082. )),
  24083. this._regionModelMap = n,
  24084. r
  24085. },
  24086. formatTooltip: function (e) {
  24087. return oc(this, e)
  24088. },
  24089. getRegionModel: function (e) {
  24090. var t = this.getData().getName(e);
  24091. return this._regionModelMap[t] || new i.Model(null, this)
  24092. },
  24093. getRegionPolygonCoords: function (e) {
  24094. var t = this.coordinateSystem
  24095. , r = this.getData().getName(e);
  24096. if (t.transform)
  24097. return (i = t.getRegion(r)) ? i.geometries : [];
  24098. this._geo || (this._geo = $h.createGeo3D(this));
  24099. for (var i = this._geo.getRegion(r), n = [], a = 0; a < i.geometries.length; a++) {
  24100. var o = i.geometries[a]
  24101. , s = []
  24102. , l = md(t, o.exterior);
  24103. if (s && s.length)
  24104. for (var h = 0; h < o.interiors.length; h++)
  24105. s.push(md(t, s[h]));
  24106. n.push({
  24107. interiors: s,
  24108. exterior: l
  24109. })
  24110. }
  24111. return n
  24112. },
  24113. getFormattedLabel: function (e, t) {
  24114. var r = ac.getFormattedLabel(this, e, t);
  24115. return null == r && (r = this.getData().getName(e)),
  24116. r
  24117. },
  24118. defaultOption: {
  24119. coordinateSystem: "geo3D",
  24120. data: null
  24121. }
  24122. });
  24123. i.util.merge(gd.prototype, Ql),
  24124. i.util.merge(gd.prototype, uo),
  24125. i.util.merge(gd.prototype, co),
  24126. i.util.merge(gd.prototype, fo),
  24127. i.util.merge(gd.prototype, Kl);
  24128. const _d = gd
  24129. , vd = i.ChartView.extend({
  24130. type: "map3D",
  24131. __ecgl__: !0,
  24132. init: function (e, t) {
  24133. this._geo3DBuilder = new Uh(t),
  24134. this.groupGL = new Ka.Node
  24135. },
  24136. render: function (e, t, r) {
  24137. var i = e.coordinateSystem;
  24138. if (i && i.viewGL) {
  24139. if (this.groupGL.add(this._geo3DBuilder.rootNode),
  24140. i.viewGL.add(this.groupGL),
  24141. "geo3D" === i.type) {
  24142. this._sceneHelper || (this._sceneHelper = new Uo,
  24143. this._sceneHelper.initLight(this.groupGL)),
  24144. this._sceneHelper.setScene(i.viewGL.scene),
  24145. this._sceneHelper.updateLight(e),
  24146. i.viewGL.setPostEffect(e.getModel("postEffect"), r),
  24147. i.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling"));
  24148. var n = this._control;
  24149. n || (n = this._control = new Do({
  24150. zr: r.getZr()
  24151. }),
  24152. this._control.init());
  24153. var a = e.getModel("viewControl");
  24154. n.setViewGL(i.viewGL),
  24155. n.setFromViewControlModel(a, 0),
  24156. n.off("update"),
  24157. n.on("update", (function () {
  24158. r.dispatchAction({
  24159. type: "map3DChangeCamera",
  24160. alpha: n.getAlpha(),
  24161. beta: n.getBeta(),
  24162. distance: n.getDistance(),
  24163. from: this.uid,
  24164. map3DId: e.id
  24165. })
  24166. }
  24167. )),
  24168. this._geo3DBuilder.extrudeY = !0
  24169. } else
  24170. this._control && (this._control.dispose(),
  24171. this._control = null),
  24172. this._sceneHelper && (this._sceneHelper.dispose(),
  24173. this._sceneHelper = null),
  24174. e.getData().getLayout("geo3D"),
  24175. this._geo3DBuilder.extrudeY = !1;
  24176. this._geo3DBuilder.update(e, t, r, 0, e.getData().count());
  24177. var o = i.viewGL.isLinearSpace() ? "define" : "undefine";
  24178. this._geo3DBuilder.rootNode.traverse((function (e) {
  24179. e.material && e.material[o]("fragment", "SRGB_DECODE")
  24180. }
  24181. ))
  24182. }
  24183. },
  24184. afterRender: function (e, t, r, i) {
  24185. var n = i.renderer
  24186. , a = e.coordinateSystem;
  24187. a && "geo3D" === a.type && (this._sceneHelper.updateAmbientCubemap(n, e, r),
  24188. this._sceneHelper.updateSkybox(n, e, r))
  24189. },
  24190. dispose: function () {
  24191. this.groupGL.removeAll(),
  24192. this._control.dispose(),
  24193. this._geo3DBuilder.dispose()
  24194. }
  24195. });
  24196. (0,
  24197. i.use)((function (e) {
  24198. eu(e),
  24199. e.registerChartView(vd),
  24200. e.registerSeriesModel(_d),
  24201. e.registerAction({
  24202. type: "map3DChangeCamera",
  24203. event: "map3dcamerachanged",
  24204. update: "series:updateCamera"
  24205. }, (function (e, t) {
  24206. t.eachComponent({
  24207. mainType: "series",
  24208. subType: "map3D",
  24209. query: e
  24210. }, (function (t) {
  24211. t.setView(e)
  24212. }
  24213. ))
  24214. }
  24215. ))
  24216. }
  24217. ));
  24218. const yd = i.SeriesModel.extend({
  24219. type: "series.scatterGL",
  24220. dependencies: ["grid", "polar", "geo", "singleAxis"],
  24221. visualStyleAccessPath: "itemStyle",
  24222. hasSymbolVisual: !0,
  24223. getInitialData: function () {
  24224. return i.helper.createList(this)
  24225. },
  24226. defaultOption: {
  24227. coordinateSystem: "cartesian2d",
  24228. zlevel: 10,
  24229. progressive: 1e5,
  24230. progressiveThreshold: 1e5,
  24231. large: !1,
  24232. symbol: "circle",
  24233. symbolSize: 10,
  24234. zoomScale: 0,
  24235. blendMode: "source-over",
  24236. itemStyle: {
  24237. opacity: .8
  24238. },
  24239. postEffect: {
  24240. enable: !1,
  24241. colorCorrection: {
  24242. exposure: 0,
  24243. brightness: 0,
  24244. contrast: 1,
  24245. saturation: 1,
  24246. enable: !0
  24247. }
  24248. }
  24249. }
  24250. });
  24251. function xd(e, t, r) {
  24252. var i = t[0]
  24253. , n = t[1];
  24254. return e[0] = r[0] * i + r[2] * n + r[4],
  24255. e[1] = r[1] * i + r[3] * n + r[5],
  24256. e
  24257. }
  24258. function bd(e) {
  24259. this.viewGL = e
  24260. }
  24261. bd.prototype.reset = function (e, t) {
  24262. this._updateCamera(t.getWidth(), t.getHeight(), t.getDevicePixelRatio()),
  24263. this._viewTransform = [1, 0, 0, 1, 0, 0],
  24264. this.updateTransform(e, t)
  24265. }
  24266. ,
  24267. bd.prototype.updateTransform = function (e, t) {
  24268. var r, i, n, a, o, s, l, h, u, c = e.coordinateSystem;
  24269. c.getRoamTransform && (r = this._viewTransform,
  24270. n = (i = c.getRoamTransform())[0],
  24271. a = i[2],
  24272. o = i[4],
  24273. s = i[1],
  24274. l = i[3],
  24275. h = i[5],
  24276. (u = n * l - s * a) && (u = 1 / u,
  24277. r[0] = l * u,
  24278. r[1] = -s * u,
  24279. r[2] = -a * u,
  24280. r[3] = n * u,
  24281. r[4] = (a * h - l * o) * u,
  24282. r[5] = (s * o - n * h) * u),
  24283. this._setCameraTransform(this._viewTransform),
  24284. t.getZr().refresh())
  24285. }
  24286. ,
  24287. bd.prototype.dataToPoint = function (e, t, r) {
  24288. r = e.dataToPoint(t, null, r);
  24289. var i = this._viewTransform;
  24290. i && xd(r, r, i)
  24291. }
  24292. ,
  24293. bd.prototype.removeTransformInPoint = function (e) {
  24294. return this._viewTransform && xd(e, e, this._viewTransform),
  24295. e
  24296. }
  24297. ,
  24298. bd.prototype.getZoom = function () {
  24299. if (this._viewTransform) {
  24300. var e = this._viewTransform;
  24301. return 1 / Math.max(Math.sqrt(e[0] * e[0] + e[1] * e[1]), Math.sqrt(e[2] * e[2] + e[3] * e[3]))
  24302. }
  24303. return 1
  24304. }
  24305. ,
  24306. bd.prototype._setCameraTransform = function (e) {
  24307. var t = this.viewGL.camera;
  24308. t.position.set(e[4], e[5], 0),
  24309. t.scale.set(Math.sqrt(e[0] * e[0] + e[1] * e[1]), Math.sqrt(e[2] * e[2] + e[3] * e[3]), 1)
  24310. }
  24311. ,
  24312. bd.prototype._updateCamera = function (e, t, r) {
  24313. this.viewGL.setViewport(0, 0, e, t, r);
  24314. var i = this.viewGL.camera;
  24315. i.left = i.top = 0,
  24316. i.bottom = t,
  24317. i.right = e,
  24318. i.near = 0,
  24319. i.far = 100
  24320. }
  24321. ;
  24322. const wd = bd
  24323. , Td = i.ChartView.extend({
  24324. type: "scatterGL",
  24325. __ecgl__: !0,
  24326. init: function (e, t) {
  24327. this.groupGL = new Ka.Node,
  24328. this.viewGL = new Il("orthographic"),
  24329. this.viewGL.add(this.groupGL),
  24330. this._pointsBuilderList = [],
  24331. this._currentStep = 0,
  24332. this._sizeScale = 1,
  24333. this._glViewHelper = new wd(this.viewGL)
  24334. },
  24335. render: function (e, t, r) {
  24336. if (this.groupGL.removeAll(),
  24337. this._glViewHelper.reset(e, r),
  24338. e.getData().count()) {
  24339. var i = this._pointsBuilderList[0];
  24340. i || (i = this._pointsBuilderList[0] = new Fc(!0, r)),
  24341. this._pointsBuilderList.length = 1,
  24342. this.groupGL.add(i.rootNode),
  24343. this._removeTransformInPoints(e.getData().getLayout("points")),
  24344. i.update(e, t, r),
  24345. this.viewGL.setPostEffect(e.getModel("postEffect"), r)
  24346. }
  24347. },
  24348. incrementalPrepareRender: function (e, t, r) {
  24349. this.groupGL.removeAll(),
  24350. this._glViewHelper.reset(e, r),
  24351. this._currentStep = 0,
  24352. this.viewGL.setPostEffect(e.getModel("postEffect"), r)
  24353. },
  24354. incrementalRender: function (e, t, r, i) {
  24355. if (!(e.end <= e.start)) {
  24356. var n = this._pointsBuilderList[this._currentStep];
  24357. n || (n = new Fc(!0, i),
  24358. this._pointsBuilderList[this._currentStep] = n),
  24359. this.groupGL.add(n.rootNode),
  24360. this._removeTransformInPoints(t.getData().getLayout("points")),
  24361. n.setSizeScale(this._sizeScale),
  24362. n.update(t, r, i, e.start, e.end),
  24363. i.getZr().refresh(),
  24364. this._currentStep++
  24365. }
  24366. },
  24367. updateTransform: function (e, t, r) {
  24368. if (e.coordinateSystem.getRoamTransform) {
  24369. this._glViewHelper.updateTransform(e, r);
  24370. var i = this._glViewHelper.getZoom()
  24371. , n = Math.max((e.get("zoomScale") || 0) * (i - 1) + 1, 0);
  24372. this._sizeScale = n,
  24373. this._pointsBuilderList.forEach((function (e) {
  24374. e.setSizeScale(n)
  24375. }
  24376. ))
  24377. }
  24378. },
  24379. _removeTransformInPoints: function (e) {
  24380. if (e)
  24381. for (var t = [], r = 0; r < e.length; r += 2)
  24382. t[0] = e[r],
  24383. t[1] = e[r + 1],
  24384. this._glViewHelper.removeTransformInPoint(t),
  24385. e[r] = t[0],
  24386. e[r + 1] = t[1]
  24387. },
  24388. dispose: function () {
  24389. this.groupGL.removeAll(),
  24390. this._pointsBuilderList.forEach((function (e) {
  24391. e.dispose()
  24392. }
  24393. ))
  24394. },
  24395. remove: function () {
  24396. this.groupGL.removeAll()
  24397. }
  24398. });
  24399. function Sd(e) {
  24400. return "_EC_" + e
  24401. }
  24402. (0,
  24403. i.use)((function (e) {
  24404. e.registerChartView(Td),
  24405. e.registerSeriesModel(yd),
  24406. e.registerLayout({
  24407. seriesType: "scatterGL",
  24408. reset: function (e) {
  24409. var t, r = e.coordinateSystem, i = e.getData();
  24410. if (r) {
  24411. var n = r.dimensions.map((function (e) {
  24412. return i.mapDimension(e)
  24413. }
  24414. )).slice(0, 2)
  24415. , a = [];
  24416. 1 === n.length ? t = function (e) {
  24417. for (var t = new Float32Array(2 * (e.end - e.start)), a = e.start; a < e.end; a++) {
  24418. var o = 2 * (a - e.start)
  24419. , s = i.get(n[0], a)
  24420. , l = r.dataToPoint(s);
  24421. t[o] = l[0],
  24422. t[o + 1] = l[1]
  24423. }
  24424. i.setLayout("points", t)
  24425. }
  24426. : 2 === n.length && (t = function (e) {
  24427. for (var t = new Float32Array(2 * (e.end - e.start)), o = e.start; o < e.end; o++) {
  24428. var s = 2 * (o - e.start)
  24429. , l = i.get(n[0], o)
  24430. , h = i.get(n[1], o);
  24431. a[0] = l,
  24432. a[1] = h,
  24433. a = r.dataToPoint(a),
  24434. t[s] = a[0],
  24435. t[s + 1] = a[1]
  24436. }
  24437. i.setLayout("points", t)
  24438. }
  24439. )
  24440. }
  24441. return {
  24442. progress: t
  24443. }
  24444. }
  24445. })
  24446. }
  24447. ));
  24448. var Md = function () {
  24449. function e(e) {
  24450. this.type = "graph",
  24451. this.nodes = [],
  24452. this.edges = [],
  24453. this._nodesMap = {},
  24454. this._edgesMap = {},
  24455. this._directed = e || !1
  24456. }
  24457. return e.prototype.isDirected = function () {
  24458. return this._directed
  24459. }
  24460. ,
  24461. e.prototype.addNode = function (e, t) {
  24462. e = null == e ? "" + t : "" + e;
  24463. var r = this._nodesMap;
  24464. if (!r[Sd(e)]) {
  24465. var i = new Ad(e, t);
  24466. return i.hostGraph = this,
  24467. this.nodes.push(i),
  24468. r[Sd(e)] = i,
  24469. i
  24470. }
  24471. }
  24472. ,
  24473. e.prototype.getNodeByIndex = function (e) {
  24474. var t = this.data.getRawIndex(e);
  24475. return this.nodes[t]
  24476. }
  24477. ,
  24478. e.prototype.getNodeById = function (e) {
  24479. return this._nodesMap[Sd(e)]
  24480. }
  24481. ,
  24482. e.prototype.addEdge = function (e, t, r) {
  24483. var i = this._nodesMap
  24484. , n = this._edgesMap;
  24485. if ("number" == typeof e && (e = this.nodes[e]),
  24486. "number" == typeof t && (t = this.nodes[t]),
  24487. e instanceof Ad || (e = i[Sd(e)]),
  24488. t instanceof Ad || (t = i[Sd(t)]),
  24489. e && t) {
  24490. var a = e.id + "-" + t.id
  24491. , o = new Ed(e, t, r);
  24492. return o.hostGraph = this,
  24493. this._directed && (e.outEdges.push(o),
  24494. t.inEdges.push(o)),
  24495. e.edges.push(o),
  24496. e !== t && t.edges.push(o),
  24497. this.edges.push(o),
  24498. n[a] = o,
  24499. o
  24500. }
  24501. }
  24502. ,
  24503. e.prototype.getEdgeByIndex = function (e) {
  24504. var t = this.edgeData.getRawIndex(e);
  24505. return this.edges[t]
  24506. }
  24507. ,
  24508. e.prototype.getEdge = function (e, t) {
  24509. e instanceof Ad && (e = e.id),
  24510. t instanceof Ad && (t = t.id);
  24511. var r = this._edgesMap;
  24512. return this._directed ? r[e + "-" + t] : r[e + "-" + t] || r[t + "-" + e]
  24513. }
  24514. ,
  24515. e.prototype.eachNode = function (e, t) {
  24516. for (var r = this.nodes, i = r.length, n = 0; n < i; n++)
  24517. r[n].dataIndex >= 0 && e.call(t, r[n], n)
  24518. }
  24519. ,
  24520. e.prototype.eachEdge = function (e, t) {
  24521. for (var r = this.edges, i = r.length, n = 0; n < i; n++)
  24522. r[n].dataIndex >= 0 && r[n].node1.dataIndex >= 0 && r[n].node2.dataIndex >= 0 && e.call(t, r[n], n)
  24523. }
  24524. ,
  24525. e.prototype.breadthFirstTraverse = function (e, t, r, i) {
  24526. if (t instanceof Ad || (t = this._nodesMap[Sd(t)]),
  24527. t) {
  24528. for (var n = "out" === r ? "outEdges" : "in" === r ? "inEdges" : "edges", a = 0; a < this.nodes.length; a++)
  24529. this.nodes[a].__visited = !1;
  24530. if (!e.call(i, t, null))
  24531. for (var o = [t]; o.length;) {
  24532. var s = o.shift()
  24533. , l = s[n];
  24534. for (a = 0; a < l.length; a++) {
  24535. var h = l[a]
  24536. , u = h.node1 === s ? h.node2 : h.node1;
  24537. if (!u.__visited) {
  24538. if (e.call(i, u, s))
  24539. return;
  24540. o.push(u),
  24541. u.__visited = !0
  24542. }
  24543. }
  24544. }
  24545. }
  24546. }
  24547. ,
  24548. e.prototype.update = function () {
  24549. for (var e = this.data, t = this.edgeData, r = this.nodes, i = this.edges, n = 0, a = r.length; n < a; n++)
  24550. r[n].dataIndex = -1;
  24551. for (n = 0,
  24552. a = e.count(); n < a; n++)
  24553. r[e.getRawIndex(n)].dataIndex = n;
  24554. for (t.filterSelf((function (e) {
  24555. var r = i[t.getRawIndex(e)];
  24556. return r.node1.dataIndex >= 0 && r.node2.dataIndex >= 0
  24557. }
  24558. )),
  24559. n = 0,
  24560. a = i.length; n < a; n++)
  24561. i[n].dataIndex = -1;
  24562. for (n = 0,
  24563. a = t.count(); n < a; n++)
  24564. i[t.getRawIndex(n)].dataIndex = n
  24565. }
  24566. ,
  24567. e.prototype.clone = function () {
  24568. for (var t = new e(this._directed), r = this.nodes, i = this.edges, n = 0; n < r.length; n++)
  24569. t.addNode(r[n].id, r[n].dataIndex);
  24570. for (n = 0; n < i.length; n++) {
  24571. var a = i[n];
  24572. t.addEdge(a.node1.id, a.node2.id, a.dataIndex)
  24573. }
  24574. return t
  24575. }
  24576. ,
  24577. e
  24578. }()
  24579. , Ad = function () {
  24580. function e(e, t) {
  24581. this.inEdges = [],
  24582. this.outEdges = [],
  24583. this.edges = [],
  24584. this.dataIndex = -1,
  24585. this.id = null == e ? "" : e,
  24586. this.dataIndex = null == t ? -1 : t
  24587. }
  24588. return e.prototype.degree = function () {
  24589. return this.edges.length
  24590. }
  24591. ,
  24592. e.prototype.inDegree = function () {
  24593. return this.inEdges.length
  24594. }
  24595. ,
  24596. e.prototype.outDegree = function () {
  24597. return this.outEdges.length
  24598. }
  24599. ,
  24600. e.prototype.getModel = function (e) {
  24601. if (!(this.dataIndex < 0))
  24602. return this.hostGraph.data.getItemModel(this.dataIndex).getModel(e)
  24603. }
  24604. ,
  24605. e.prototype.getAdjacentDataIndices = function () {
  24606. for (var e = {
  24607. edge: [],
  24608. node: []
  24609. }, t = 0; t < this.edges.length; t++) {
  24610. var r = this.edges[t];
  24611. r.dataIndex < 0 || (e.edge.push(r.dataIndex),
  24612. e.node.push(r.node1.dataIndex, r.node2.dataIndex))
  24613. }
  24614. return e
  24615. }
  24616. ,
  24617. e
  24618. }()
  24619. , Ed = function () {
  24620. function e(e, t, r) {
  24621. this.dataIndex = -1,
  24622. this.node1 = e,
  24623. this.node2 = t,
  24624. this.dataIndex = null == r ? -1 : r
  24625. }
  24626. return e.prototype.getModel = function (e) {
  24627. if (!(this.dataIndex < 0))
  24628. return this.hostGraph.edgeData.getItemModel(this.dataIndex).getModel(e)
  24629. }
  24630. ,
  24631. e.prototype.getAdjacentDataIndices = function () {
  24632. return {
  24633. edge: [this.dataIndex],
  24634. node: [this.node1.dataIndex, this.node2.dataIndex]
  24635. }
  24636. }
  24637. ,
  24638. e
  24639. }();
  24640. function Cd(e, t) {
  24641. return {
  24642. getValue: function (r) {
  24643. var i = this[e][t];
  24644. return i.get(i.getDimension(r || "value"), this.dataIndex)
  24645. },
  24646. setVisual: function (r, i) {
  24647. this.dataIndex >= 0 && this[e][t].setItemVisual(this.dataIndex, r, i)
  24648. },
  24649. getVisual: function (r) {
  24650. return this[e][t].getItemVisual(this.dataIndex, r)
  24651. },
  24652. setLayout: function (r, i) {
  24653. this.dataIndex >= 0 && this[e][t].setItemLayout(this.dataIndex, r, i)
  24654. },
  24655. getLayout: function () {
  24656. return this[e][t].getItemLayout(this.dataIndex)
  24657. },
  24658. getGraphicEl: function () {
  24659. return this[e][t].getItemGraphicEl(this.dataIndex)
  24660. },
  24661. getRawIndex: function () {
  24662. return this[e][t].getRawIndex(this.dataIndex)
  24663. }
  24664. }
  24665. }
  24666. _a(Ad, Cd("hostGraph", "data")),
  24667. _a(Ed, Cd("hostGraph", "edgeData"));
  24668. const Dd = Md;
  24669. var Ld = _o();
  24670. function Pd(e, t) {
  24671. if (Ld(this).mainData === this) {
  24672. var r = ga({}, Ld(this).datas);
  24673. r[this.dataType] = t,
  24674. Bd(t, r, e)
  24675. } else
  24676. Fd(t, this.dataType, Ld(this).mainData, e);
  24677. return t
  24678. }
  24679. function Od(e, t) {
  24680. return e.struct && e.struct.update(),
  24681. t
  24682. }
  24683. function Nd(e, t) {
  24684. return ya(Ld(t).datas, (function (r, i) {
  24685. r !== t && Fd(r.cloneShallow(), i, t, e)
  24686. }
  24687. )),
  24688. t
  24689. }
  24690. function Id(e) {
  24691. var t = Ld(this).mainData;
  24692. return null == e || null == t ? t : Ld(t).datas[e]
  24693. }
  24694. function Rd() {
  24695. var e = Ld(this).mainData;
  24696. return null == e ? [{
  24697. data: e
  24698. }] : xa(ba(Ld(e).datas), (function (t) {
  24699. return {
  24700. type: t,
  24701. data: Ld(e).datas[t]
  24702. }
  24703. }
  24704. ))
  24705. }
  24706. function Bd(e, t, r) {
  24707. Ld(e).datas = {},
  24708. ya(t, (function (t, i) {
  24709. Fd(t, i, e, r)
  24710. }
  24711. ))
  24712. }
  24713. function Fd(e, t, r, i) {
  24714. Ld(r).datas[t] = e,
  24715. Ld(e).mainData = r,
  24716. e.dataType = t,
  24717. i.struct && (e[i.structAttr] = i.struct,
  24718. i.struct[i.datasAttr[t]] = e),
  24719. e.getLinkedData = Id,
  24720. e.getLinkedDataAll = Rd
  24721. }
  24722. var zd = i.SeriesModel.extend({
  24723. type: "series.graphGL",
  24724. visualStyleAccessPath: "itemStyle",
  24725. hasSymbolVisual: !0,
  24726. init: function (e) {
  24727. zd.superApply(this, "init", arguments),
  24728. this.legendDataProvider = function () {
  24729. return this._categoriesData
  24730. }
  24731. ,
  24732. this._updateCategoriesData()
  24733. },
  24734. mergeOption: function (e) {
  24735. zd.superApply(this, "mergeOption", arguments),
  24736. this._updateCategoriesData()
  24737. },
  24738. getFormattedLabel: function (e, t, r, i) {
  24739. var n = ac.getFormattedLabel(this, e, t, r, i);
  24740. if (null == n) {
  24741. var a = this.getData()
  24742. , o = a.dimensions[a.dimensions.length - 1];
  24743. n = a.get(o, e)
  24744. }
  24745. return n
  24746. },
  24747. getInitialData: function (e, t) {
  24748. var r = e.edges || e.links || []
  24749. , n = e.data || e.nodes || []
  24750. , a = this;
  24751. if (n && r)
  24752. return function (e, t, r, n, a) {
  24753. for (var o = new Dd(!0), s = 0; s < e.length; s++)
  24754. o.addNode(Mn(e[s].id, e[s].name, s), s);
  24755. var l, h = [], u = [], c = 0;
  24756. for (s = 0; s < t.length; s++) {
  24757. var d = t[s]
  24758. , f = d.source
  24759. , p = d.target;
  24760. o.addEdge(f, p, c) && (u.push(d),
  24761. h.push(Mn(d.id, f + " > " + p)),
  24762. c++)
  24763. }
  24764. var m = i.helper.createDimensions(e, {
  24765. coordDimensions: ["value"]
  24766. });
  24767. (l = new i.List(m, r)).initData(e);
  24768. var g, _, v, y = new i.List(["value"], r);
  24769. return y.initData(u, h),
  24770. a && a(l, y),
  24771. _ = (g = {
  24772. mainData: l,
  24773. struct: o,
  24774. structAttr: "graph",
  24775. datas: {
  24776. node: l,
  24777. edge: y
  24778. },
  24779. datasAttr: {
  24780. node: "data",
  24781. edge: "edgeData"
  24782. }
  24783. }).mainData,
  24784. (v = g.datas) || (v = {
  24785. main: _
  24786. },
  24787. g.datasAttr = {
  24788. main: "data"
  24789. }),
  24790. g.datas = g.mainData = null,
  24791. Bd(_, v, g),
  24792. ya(v, (function (e) {
  24793. ya(_.TRANSFERABLE_METHODS, (function (t) {
  24794. e.wrapMethod(t, wa(Pd, g))
  24795. }
  24796. ))
  24797. }
  24798. )),
  24799. _.wrapMethod("cloneShallow", wa(Nd, g)),
  24800. ya(_.CHANGABLE_METHODS, (function (e) {
  24801. _.wrapMethod(e, wa(Od, g))
  24802. }
  24803. )),
  24804. function (e, t) {
  24805. if (!e)
  24806. throw new Error(void 0)
  24807. }(v[_.dataType] === _),
  24808. o.update(),
  24809. o
  24810. }(n, r, this, 0, (function (e, r) {
  24811. e.wrapMethod("getItemModel", (function (e) {
  24812. const t = a._categoriesModels[e.getShallow("category")];
  24813. return t && (t.parentModel = e.parentModel,
  24814. e.parentModel = t),
  24815. e
  24816. }
  24817. ));
  24818. const i = t.getModel([]).getModel;
  24819. function n(e, t) {
  24820. const r = i.call(this, e, t);
  24821. return r.resolveParentPath = o,
  24822. r
  24823. }
  24824. function o(e) {
  24825. if (e && ("label" === e[0] || "label" === e[1])) {
  24826. const t = e.slice();
  24827. return "label" === e[0] ? t[0] = "edgeLabel" : "label" === e[1] && (t[1] = "edgeLabel"),
  24828. t
  24829. }
  24830. return e
  24831. }
  24832. r.wrapMethod("getItemModel", (function (e) {
  24833. return e.resolveParentPath = o,
  24834. e.getModel = n,
  24835. e
  24836. }
  24837. ))
  24838. }
  24839. )).data
  24840. },
  24841. getGraph: function () {
  24842. return this.getData().graph
  24843. },
  24844. getEdgeData: function () {
  24845. return this.getGraph().edgeData
  24846. },
  24847. getCategoriesData: function () {
  24848. return this._categoriesData
  24849. },
  24850. formatTooltip: function (e, t, r) {
  24851. if ("edge" === r) {
  24852. var n = this.getData()
  24853. , a = this.getDataParams(e, r)
  24854. , o = n.graph.getEdgeByIndex(e)
  24855. , s = n.getName(o.node1.dataIndex)
  24856. , l = n.getName(o.node2.dataIndex)
  24857. , h = [];
  24858. return null != s && h.push(s),
  24859. null != l && h.push(l),
  24860. h = i.format.encodeHTML(h.join(" > ")),
  24861. a.value && (h += " : " + i.format.encodeHTML(a.value)),
  24862. h
  24863. }
  24864. return zd.superApply(this, "formatTooltip", arguments)
  24865. },
  24866. _updateCategoriesData: function () {
  24867. var e = (this.option.categories || []).map((function (e) {
  24868. return null != e.value ? e : Object.assign({
  24869. value: 0
  24870. }, e)
  24871. }
  24872. ))
  24873. , t = new i.List(["value"], this);
  24874. t.initData(e),
  24875. this._categoriesData = t,
  24876. this._categoriesModels = t.mapArray((function (e) {
  24877. return t.getItemModel(e, !0)
  24878. }
  24879. ))
  24880. },
  24881. setView: function (e) {
  24882. null != e.zoom && (this.option.zoom = e.zoom),
  24883. null != e.offset && (this.option.offset = e.offset)
  24884. },
  24885. setNodePosition: function (e) {
  24886. for (var t = 0; t < e.length / 2; t++) {
  24887. var r = e[2 * t]
  24888. , i = e[2 * t + 1]
  24889. , n = this.getData().getRawDataItem(t);
  24890. n.x = r,
  24891. n.y = i
  24892. }
  24893. },
  24894. isAnimationEnabled: function () {
  24895. return zd.superCall(this, "isAnimationEnabled") && !("force" === this.get("layout") && this.get("force.layoutAnimation"))
  24896. },
  24897. defaultOption: {
  24898. zlevel: 10,
  24899. z: 2,
  24900. legendHoverLink: !0,
  24901. layout: "forceAtlas2",
  24902. forceAtlas2: {
  24903. initLayout: null,
  24904. GPU: !0,
  24905. steps: 1,
  24906. maxSteps: 1e3,
  24907. repulsionByDegree: !0,
  24908. linLogMode: !1,
  24909. strongGravityMode: !1,
  24910. gravity: 1,
  24911. edgeWeightInfluence: 1,
  24912. edgeWeight: [1, 4],
  24913. nodeWeight: [1, 4],
  24914. preventOverlap: !1,
  24915. gravityCenter: null
  24916. },
  24917. focusNodeAdjacency: !0,
  24918. focusNodeAdjacencyOn: "mouseover",
  24919. left: "center",
  24920. top: "center",
  24921. symbol: "circle",
  24922. symbolSize: 5,
  24923. roam: !1,
  24924. center: null,
  24925. zoom: 1,
  24926. label: {
  24927. show: !1,
  24928. formatter: "{b}",
  24929. position: "right",
  24930. distance: 5,
  24931. textStyle: {
  24932. fontSize: 14
  24933. }
  24934. },
  24935. itemStyle: {},
  24936. lineStyle: {
  24937. color: "#aaa",
  24938. width: 1,
  24939. opacity: .5
  24940. },
  24941. emphasis: {
  24942. label: {
  24943. show: !0
  24944. }
  24945. },
  24946. animation: !1
  24947. }
  24948. });
  24949. const Gd = zd;
  24950. var Ud = Po.vec2
  24951. , kd = [[0, 0], [1, 1]]
  24952. , Vd = Vr.extend((function () {
  24953. return {
  24954. segmentScale: 4,
  24955. dynamic: !0,
  24956. useNativeLine: !0,
  24957. attributes: {
  24958. position: new Vr.Attribute("position", "float", 2, "POSITION"),
  24959. normal: new Vr.Attribute("normal", "float", 2),
  24960. offset: new Vr.Attribute("offset", "float", 1),
  24961. color: new Vr.Attribute("color", "float", 4, "COLOR")
  24962. }
  24963. }
  24964. }
  24965. ), {
  24966. resetOffset: function () {
  24967. this._vertexOffset = 0,
  24968. this._faceOffset = 0,
  24969. this._itemVertexOffsets = []
  24970. },
  24971. setVertexCount: function (e) {
  24972. var t = this.attributes;
  24973. this.vertexCount !== e && (t.position.init(e),
  24974. t.color.init(e),
  24975. this.useNativeLine || (t.offset.init(e),
  24976. t.normal.init(e)),
  24977. e > 65535 ? this.indices instanceof Uint16Array && (this.indices = new Uint32Array(this.indices)) : this.indices instanceof Uint32Array && (this.indices = new Uint16Array(this.indices)))
  24978. },
  24979. setTriangleCount: function (e) {
  24980. this.triangleCount !== e && (this.indices = 0 === e ? null : this.vertexCount > 65535 ? new Uint32Array(3 * e) : new Uint16Array(3 * e))
  24981. },
  24982. _getCubicCurveApproxStep: function (e, t, r, i) {
  24983. return 1 / (Ud.dist(e, t) + Ud.dist(r, t) + Ud.dist(i, r) + 1) * this.segmentScale
  24984. },
  24985. getCubicCurveVertexCount: function (e, t, r, i) {
  24986. var n = this._getCubicCurveApproxStep(e, t, r, i)
  24987. , a = Math.ceil(1 / n);
  24988. return this.useNativeLine ? 2 * a : 2 * a + 2
  24989. },
  24990. getCubicCurveTriangleCount: function (e, t, r, i) {
  24991. var n = this._getCubicCurveApproxStep(e, t, r, i)
  24992. , a = Math.ceil(1 / n);
  24993. return this.useNativeLine ? 0 : 2 * a
  24994. },
  24995. getLineVertexCount: function () {
  24996. return this.getPolylineVertexCount(kd)
  24997. },
  24998. getLineTriangleCount: function () {
  24999. return this.getPolylineTriangleCount(kd)
  25000. },
  25001. getPolylineVertexCount: function (e) {
  25002. var t;
  25003. return t = "number" == typeof e ? e : "number" != typeof e[0] ? e.length : e.length / 2,
  25004. this.useNativeLine ? 2 * (t - 1) : 2 * (t - 1) + 2
  25005. },
  25006. getPolylineTriangleCount: function (e) {
  25007. var t;
  25008. return t = "number" == typeof e ? e : "number" != typeof e[0] ? e.length : e.length / 2,
  25009. this.useNativeLine ? 0 : 2 * (t - 1)
  25010. },
  25011. addCubicCurve: function (e, t, r, i, n, a) {
  25012. null == a && (a = 1);
  25013. var o = e[0]
  25014. , s = e[1]
  25015. , l = t[0]
  25016. , h = t[1]
  25017. , u = r[0]
  25018. , c = r[1]
  25019. , d = i[0]
  25020. , f = i[1]
  25021. , p = this._getCubicCurveApproxStep(e, t, r, i)
  25022. , m = p * p
  25023. , g = m * p
  25024. , _ = 3 * p
  25025. , v = 3 * m
  25026. , y = 6 * m
  25027. , x = 6 * g
  25028. , b = o - 2 * l + u
  25029. , w = s - 2 * h + c
  25030. , T = 3 * (l - u) - o + d
  25031. , S = 3 * (h - c) - s + f
  25032. , M = o
  25033. , A = s
  25034. , E = (l - o) * _ + b * v + T * g
  25035. , C = (h - s) * _ + w * v + S * g
  25036. , D = b * y + T * x
  25037. , L = w * y + S * x
  25038. , P = T * x
  25039. , O = S * x
  25040. , N = 0
  25041. , I = 0
  25042. , R = Math.ceil(1 / p)
  25043. , B = new Float32Array(3 * (R + 1))
  25044. , F = (B = [],
  25045. 0);
  25046. for (I = 0; I < R + 1; I++)
  25047. B[F++] = M,
  25048. B[F++] = A,
  25049. M += E,
  25050. A += C,
  25051. E += D,
  25052. C += L,
  25053. D += P,
  25054. L += O,
  25055. (N += p) > 1 && (M = E > 0 ? Math.min(M, d) : Math.max(M, d),
  25056. A = C > 0 ? Math.min(A, f) : Math.max(A, f));
  25057. this.addPolyline(B, n, a)
  25058. },
  25059. addLine: function (e, t, r, i) {
  25060. this.addPolyline([e, t], r, i)
  25061. },
  25062. addPolyline: function () {
  25063. var e = Ud.create()
  25064. , t = Ud.create()
  25065. , r = Ud.create()
  25066. , i = Ud.create()
  25067. , n = []
  25068. , a = []
  25069. , o = [];
  25070. return function (s, l, h, u, c) {
  25071. if (s.length) {
  25072. var d = "number" != typeof s[0];
  25073. if (null == c && (c = d ? s.length : s.length / 2),
  25074. !(c < 2)) {
  25075. null == u && (u = 0),
  25076. null == h && (h = 1),
  25077. this._itemVertexOffsets.push(this._vertexOffset);
  25078. for (var f, p = d ? "number" != typeof l[0] : l.length / 4 === c, m = this.attributes.position, g = this.attributes.color, _ = this.attributes.offset, v = this.attributes.normal, y = this.indices, x = this._vertexOffset, b = 0; b < c; b++) {
  25079. if (d)
  25080. n = s[b + u],
  25081. f = p ? l[b + u] : l;
  25082. else {
  25083. var w = 2 * b + u;
  25084. if ((n = n || [])[0] = s[w],
  25085. n[1] = s[w + 1],
  25086. p) {
  25087. var T = 4 * b + u;
  25088. (f = f || [])[0] = l[T],
  25089. f[1] = l[T + 1],
  25090. f[2] = l[T + 2],
  25091. f[3] = l[T + 3]
  25092. } else
  25093. f = l
  25094. }
  25095. if (this.useNativeLine)
  25096. b > 1 && (m.copy(x, x - 1),
  25097. g.copy(x, x - 1),
  25098. x++);
  25099. else {
  25100. var S;
  25101. if (b < c - 1)
  25102. if (d ? Ud.copy(a, s[b + 1]) : (w = 2 * (b + 1) + u,
  25103. (a = a || [])[0] = s[w],
  25104. a[1] = s[w + 1]),
  25105. b > 0) {
  25106. Ud.sub(e, n, o),
  25107. Ud.sub(t, a, n),
  25108. Ud.normalize(e, e),
  25109. Ud.normalize(t, t),
  25110. Ud.add(i, e, t),
  25111. Ud.normalize(i, i);
  25112. var M = h / 2 * Math.min(1 / Ud.dot(e, i), 2);
  25113. r[0] = -i[1],
  25114. r[1] = i[0],
  25115. S = M
  25116. } else
  25117. Ud.sub(e, a, n),
  25118. Ud.normalize(e, e),
  25119. r[0] = -e[1],
  25120. r[1] = e[0],
  25121. S = h / 2;
  25122. else
  25123. Ud.sub(e, n, o),
  25124. Ud.normalize(e, e),
  25125. r[0] = -e[1],
  25126. r[1] = e[0],
  25127. S = h / 2;
  25128. v.set(x, r),
  25129. v.set(x + 1, r),
  25130. _.set(x, S),
  25131. _.set(x + 1, -S),
  25132. Ud.copy(o, n),
  25133. m.set(x, n),
  25134. m.set(x + 1, n),
  25135. g.set(x, f),
  25136. g.set(x + 1, f),
  25137. x += 2
  25138. }
  25139. if (this.useNativeLine)
  25140. g.set(x, f),
  25141. m.set(x, n),
  25142. x++;
  25143. else if (b > 0) {
  25144. var A = 3 * this._faceOffset;
  25145. (y = this.indices)[A] = x - 4,
  25146. y[A + 1] = x - 3,
  25147. y[A + 2] = x - 2,
  25148. y[A + 3] = x - 3,
  25149. y[A + 4] = x - 1,
  25150. y[A + 5] = x - 2,
  25151. this._faceOffset += 2
  25152. }
  25153. }
  25154. this._vertexOffset = x
  25155. }
  25156. }
  25157. }
  25158. }(),
  25159. setItemColor: function (e, t) {
  25160. for (var r = this._itemVertexOffsets[e], i = e < this._itemVertexOffsets.length - 1 ? this._itemVertexOffsets[e + 1] : this._vertexOffset, n = r; n < i; n++)
  25161. this.attributes.color.set(n, t);
  25162. this.dirty("color")
  25163. }
  25164. });
  25165. i.util.defaults(Vd.prototype, Lo);
  25166. const Hd = Vd;
  25167. Ka.Shader.import("@export ecgl.forceAtlas2.updateNodeRepulsion\n\n#define NODE_COUNT 0\n\nuniform sampler2D positionTex;\n\nuniform vec2 textureSize;\nuniform float gravity;\nuniform float scaling;\nuniform vec2 gravityCenter;\n\nuniform bool strongGravityMode;\nuniform bool preventOverlap;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, v_Texcoord);\n\n vec2 force = vec2(0.0);\n for (int i = 0; i < NODE_COUNT; i++) {\n vec2 uv = vec2(\n mod(float(i), textureSize.x) / (textureSize.x - 1.0),\n floor(float(i) / textureSize.x) / (textureSize.y - 1.0)\n );\n vec4 n1 = texture2D(positionTex, uv);\n\n vec2 dir = n0.xy - n1.xy;\n float d2 = dot(dir, dir);\n\n if (d2 > 0.0) {\n float factor = 0.0;\n if (preventOverlap) {\n float d = sqrt(d2);\n d = d - n0.w - n1.w;\n if (d > 0.0) {\n factor = scaling * n0.z * n1.z / (d * d);\n }\n else if (d < 0.0) {\n factor = scaling * 100.0 * n0.z * n1.z;\n }\n }\n else {\n factor = scaling * n0.z * n1.z / d2;\n }\n force += dir * factor;\n }\n }\n\n vec2 dir = gravityCenter - n0.xy;\n float d = 1.0;\n if (!strongGravityMode) {\n d = length(dir);\n }\n\n force += dir * n0.z * gravity / (d + 1.0);\n\n gl_FragColor = vec4(force, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.vertex\n\nattribute vec2 node1;\nattribute vec2 node2;\nattribute float weight;\n\nuniform sampler2D positionTex;\nuniform float edgeWeightInfluence;\nuniform bool preventOverlap;\nuniform bool linLogMode;\n\nuniform vec2 windowSize: WINDOW_SIZE;\n\nvarying vec2 v_Force;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, node1);\n vec4 n1 = texture2D(positionTex, node2);\n\n vec2 dir = n1.xy - n0.xy;\n float d = length(dir);\n float w;\n if (edgeWeightInfluence == 0.0) {\n w = 1.0;\n }\n else if (edgeWeightInfluence == 1.0) {\n w = weight;\n }\n else {\n w = pow(weight, edgeWeightInfluence);\n }\n vec2 offset = vec2(1.0 / windowSize.x, 1.0 / windowSize.y);\n vec2 scale = vec2((windowSize.x - 1.0) / windowSize.x, (windowSize.y - 1.0) / windowSize.y);\n vec2 pos = node1 * scale * 2.0 - 1.0;\n gl_Position = vec4(pos + offset, 0.0, 1.0);\n gl_PointSize = 1.0;\n\n float factor;\n if (preventOverlap) {\n d = d - n1.w - n0.w;\n }\n if (d <= 0.0) {\n v_Force = vec2(0.0);\n return;\n }\n\n if (linLogMode) {\n factor = w * log(d) / d;\n }\n else {\n factor = w;\n }\n v_Force = dir * factor;\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.fragment\n\nvarying vec2 v_Force;\n\nvoid main() {\n gl_FragColor = vec4(v_Force, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.vertex\n\nattribute vec2 node;\n\nvarying vec2 v_NodeUv;\n\nvoid main() {\n\n v_NodeUv = node;\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n gl_PointSize = 1.0;\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.fragment\n\nvarying vec2 v_NodeUv;\n\nuniform sampler2D positionTex;\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_NodeUv).rg;\n vec2 forcePrev = texture2D(forcePrevTex, v_NodeUv).rg;\n\n float mass = texture2D(positionTex, v_NodeUv).z;\n float swing = length(force - forcePrev) * mass;\n float traction = length(force + forcePrev) * 0.5 * mass;\n\n gl_FragColor = vec4(swing, traction, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcGlobalSpeed\n\nuniform sampler2D globalSpeedPrevTex;\nuniform sampler2D weightedSumTex;\nuniform float jitterTolerence;\n\nvoid main() {\n vec2 weightedSum = texture2D(weightedSumTex, vec2(0.5)).xy;\n float prevGlobalSpeed = texture2D(globalSpeedPrevTex, vec2(0.5)).x;\n float globalSpeed = jitterTolerence * jitterTolerence\n * weightedSum.y / weightedSum.x;\n if (prevGlobalSpeed > 0.0) {\n globalSpeed = min(globalSpeed / prevGlobalSpeed, 1.5) * prevGlobalSpeed;\n }\n gl_FragColor = vec4(globalSpeed, 0.0, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updatePosition\n\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\nuniform sampler2D positionTex;\nuniform sampler2D globalSpeedTex;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_Texcoord).xy;\n vec2 forcePrev = texture2D(forcePrevTex, v_Texcoord).xy;\n vec4 node = texture2D(positionTex, v_Texcoord);\n\n float globalSpeed = texture2D(globalSpeedTex, vec2(0.5)).r;\n float swing = length(force - forcePrev);\n float speed = 0.1 * globalSpeed / (0.1 + globalSpeed * sqrt(swing));\n\n float df = length(force);\n if (df > 0.0) {\n speed = min(df * speed, 10.0) / df;\n\n gl_FragColor = vec4(node.xy + speed * force, node.zw);\n }\n else {\n gl_FragColor = node;\n }\n}\n@end\n\n@export ecgl.forceAtlas2.edges.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 node;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nuniform sampler2D positionTex;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(\n texture2D(positionTex, node).xy, -10.0, 1.0\n );\n v_Color = a_Color;\n}\n@end\n\n@export ecgl.forceAtlas2.edges.fragment\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nvarying vec4 v_Color;\nvoid main() {\n gl_FragColor = color * v_Color;\n}\n@end");
  25168. var Wd = {
  25169. repulsionByDegree: !0,
  25170. linLogMode: !1,
  25171. strongGravityMode: !1,
  25172. gravity: 1,
  25173. scaling: 1,
  25174. edgeWeightInfluence: 1,
  25175. jitterTolerence: .1,
  25176. preventOverlap: !1,
  25177. dissuadeHubs: !1,
  25178. gravityCenter: null
  25179. };
  25180. function jd(e) {
  25181. var t = {
  25182. type: Ka.Texture.FLOAT,
  25183. minFilter: Ka.Texture.NEAREST,
  25184. magFilter: Ka.Texture.NEAREST
  25185. };
  25186. this._positionSourceTex = new Ka.Texture2D(t),
  25187. this._positionSourceTex.flipY = !1,
  25188. this._positionTex = new Ka.Texture2D(t),
  25189. this._positionPrevTex = new Ka.Texture2D(t),
  25190. this._forceTex = new Ka.Texture2D(t),
  25191. this._forcePrevTex = new Ka.Texture2D(t),
  25192. this._weightedSumTex = new Ka.Texture2D(t),
  25193. this._weightedSumTex.width = this._weightedSumTex.height = 1,
  25194. this._globalSpeedTex = new Ka.Texture2D(t),
  25195. this._globalSpeedPrevTex = new Ka.Texture2D(t),
  25196. this._globalSpeedTex.width = this._globalSpeedTex.height = 1,
  25197. this._globalSpeedPrevTex.width = this._globalSpeedPrevTex.height = 1,
  25198. this._nodeRepulsionPass = new pn({
  25199. fragment: Ka.Shader.source("ecgl.forceAtlas2.updateNodeRepulsion")
  25200. }),
  25201. this._positionPass = new pn({
  25202. fragment: Ka.Shader.source("ecgl.forceAtlas2.updatePosition")
  25203. }),
  25204. this._globalSpeedPass = new pn({
  25205. fragment: Ka.Shader.source("ecgl.forceAtlas2.calcGlobalSpeed")
  25206. }),
  25207. this._copyPass = new pn({
  25208. fragment: Ka.Shader.source("clay.compositor.output")
  25209. });
  25210. var r = function (e) {
  25211. e.blendEquation(e.FUNC_ADD),
  25212. e.blendFunc(e.ONE, e.ONE)
  25213. };
  25214. this._edgeForceMesh = new Ka.Mesh({
  25215. geometry: new Ka.Geometry({
  25216. attributes: {
  25217. node1: new Ka.Geometry.Attribute("node1", "float", 2),
  25218. node2: new Ka.Geometry.Attribute("node2", "float", 2),
  25219. weight: new Ka.Geometry.Attribute("weight", "float", 1)
  25220. },
  25221. dynamic: !0,
  25222. mainAttribute: "node1"
  25223. }),
  25224. material: new Ka.Material({
  25225. transparent: !0,
  25226. shader: Ka.createShader("ecgl.forceAtlas2.updateEdgeAttraction"),
  25227. blend: r,
  25228. depthMask: !1,
  25229. depthText: !1
  25230. }),
  25231. mode: Ka.Mesh.POINTS
  25232. }),
  25233. this._weightedSumMesh = new Ka.Mesh({
  25234. geometry: new Ka.Geometry({
  25235. attributes: {
  25236. node: new Ka.Geometry.Attribute("node", "float", 2)
  25237. },
  25238. dynamic: !0,
  25239. mainAttribute: "node"
  25240. }),
  25241. material: new Ka.Material({
  25242. transparent: !0,
  25243. shader: Ka.createShader("ecgl.forceAtlas2.calcWeightedSum"),
  25244. blend: r,
  25245. depthMask: !1,
  25246. depthText: !1
  25247. }),
  25248. mode: Ka.Mesh.POINTS
  25249. }),
  25250. this._framebuffer = new zi({
  25251. depthBuffer: !1
  25252. }),
  25253. this._dummyCamera = new Ka.OrthographicCamera({
  25254. left: -1,
  25255. right: 1,
  25256. top: 1,
  25257. bottom: -1,
  25258. near: 0,
  25259. far: 100
  25260. }),
  25261. this._globalSpeed = 0
  25262. }
  25263. jd.prototype.updateOption = function (e) {
  25264. for (var t in Wd)
  25265. this[t] = Wd[t];
  25266. var r = this._nodes.length;
  25267. if (this.jitterTolerence = r > 5e4 ? 10 : r > 5e3 ? 1 : .1,
  25268. this.scaling = r > 100 ? 2 : 10,
  25269. e)
  25270. for (var t in Wd)
  25271. null != e[t] && (this[t] = e[t]);
  25272. if (this.repulsionByDegree)
  25273. for (var i = this._positionSourceTex.pixels, n = 0; n < this._nodes.length; n++)
  25274. i[4 * n + 2] = (this._nodes[n].degree || 0) + 1
  25275. }
  25276. ,
  25277. jd.prototype._updateGravityCenter = function (e) {
  25278. var t = this._nodes
  25279. , r = this._edges;
  25280. if (this.gravityCenter)
  25281. this._gravityCenter = this.gravityCenter;
  25282. else {
  25283. for (var i = [1 / 0, 1 / 0], n = [-1 / 0, -1 / 0], a = 0; a < t.length; a++)
  25284. i[0] = Math.min(t[a].x, i[0]),
  25285. i[1] = Math.min(t[a].y, i[1]),
  25286. n[0] = Math.max(t[a].x, n[0]),
  25287. n[1] = Math.max(t[a].y, n[1]);
  25288. this._gravityCenter = [.5 * (i[0] + n[0]), .5 * (i[1] + n[1])]
  25289. }
  25290. for (a = 0; a < r.length; a++) {
  25291. var o = r[a].node1
  25292. , s = r[a].node2;
  25293. t[o].degree = (t[o].degree || 0) + 1,
  25294. t[s].degree = (t[s].degree || 0) + 1
  25295. }
  25296. }
  25297. ,
  25298. jd.prototype.initData = function (e, t) {
  25299. this._nodes = e,
  25300. this._edges = t,
  25301. this._updateGravityCenter();
  25302. var r = Math.ceil(Math.sqrt(e.length))
  25303. , i = r
  25304. , n = new Float32Array(r * i * 4);
  25305. this._resize(r, i);
  25306. for (var a = 0, o = 0; o < e.length; o++) {
  25307. var s = e[o];
  25308. n[a++] = s.x || 0,
  25309. n[a++] = s.y || 0,
  25310. n[a++] = s.mass || 1,
  25311. n[a++] = s.size || 1
  25312. }
  25313. this._positionSourceTex.pixels = n;
  25314. var l = this._edgeForceMesh.geometry
  25315. , h = t.length;
  25316. l.attributes.node1.init(2 * h),
  25317. l.attributes.node2.init(2 * h),
  25318. l.attributes.weight.init(2 * h);
  25319. var u = [];
  25320. for (o = 0; o < t.length; o++) {
  25321. var c = l.attributes
  25322. , d = t[o].weight;
  25323. null == d && (d = 1),
  25324. c.node1.set(o, this.getNodeUV(t[o].node1, u)),
  25325. c.node2.set(o, this.getNodeUV(t[o].node2, u)),
  25326. c.weight.set(o, d),
  25327. c.node1.set(o + h, this.getNodeUV(t[o].node2, u)),
  25328. c.node2.set(o + h, this.getNodeUV(t[o].node1, u)),
  25329. c.weight.set(o + h, d)
  25330. }
  25331. var f = this._weightedSumMesh.geometry;
  25332. for (f.attributes.node.init(e.length),
  25333. o = 0; o < e.length; o++)
  25334. f.attributes.node.set(o, this.getNodeUV(o, u));
  25335. l.dirty(),
  25336. f.dirty(),
  25337. this._nodeRepulsionPass.material.define("fragment", "NODE_COUNT", e.length),
  25338. this._nodeRepulsionPass.material.setUniform("textureSize", [r, i]),
  25339. this._inited = !1,
  25340. this._frame = 0
  25341. }
  25342. ,
  25343. jd.prototype.getNodes = function () {
  25344. return this._nodes
  25345. }
  25346. ,
  25347. jd.prototype.getEdges = function () {
  25348. return this._edges
  25349. }
  25350. ,
  25351. jd.prototype.step = function (e) {
  25352. this._inited || (this._initFromSource(e),
  25353. this._inited = !0),
  25354. this._frame++,
  25355. this._framebuffer.attach(this._forceTex),
  25356. this._framebuffer.bind(e);
  25357. var t = this._nodeRepulsionPass;
  25358. t.setUniform("strongGravityMode", this.strongGravityMode),
  25359. t.setUniform("gravity", this.gravity),
  25360. t.setUniform("gravityCenter", this._gravityCenter),
  25361. t.setUniform("scaling", this.scaling),
  25362. t.setUniform("preventOverlap", this.preventOverlap),
  25363. t.setUniform("positionTex", this._positionPrevTex),
  25364. t.render(e);
  25365. var r = this._edgeForceMesh;
  25366. r.material.set("linLogMode", this.linLogMode),
  25367. r.material.set("edgeWeightInfluence", this.edgeWeightInfluence),
  25368. r.material.set("preventOverlap", this.preventOverlap),
  25369. r.material.set("positionTex", this._positionPrevTex),
  25370. e.gl.enable(e.gl.BLEND),
  25371. e.renderPass([r], this._dummyCamera),
  25372. this._framebuffer.attach(this._weightedSumTex),
  25373. e.gl.clearColor(0, 0, 0, 0),
  25374. e.gl.clear(e.gl.COLOR_BUFFER_BIT),
  25375. e.gl.enable(e.gl.BLEND);
  25376. var i = this._weightedSumMesh;
  25377. i.material.set("positionTex", this._positionPrevTex),
  25378. i.material.set("forceTex", this._forceTex),
  25379. i.material.set("forcePrevTex", this._forcePrevTex),
  25380. e.renderPass([i], this._dummyCamera),
  25381. this._framebuffer.attach(this._globalSpeedTex);
  25382. var n = this._globalSpeedPass;
  25383. n.setUniform("globalSpeedPrevTex", this._globalSpeedPrevTex),
  25384. n.setUniform("weightedSumTex", this._weightedSumTex),
  25385. n.setUniform("jitterTolerence", this.jitterTolerence),
  25386. e.gl.disable(e.gl.BLEND),
  25387. n.render(e);
  25388. var a = this._positionPass;
  25389. this._framebuffer.attach(this._positionTex),
  25390. a.setUniform("globalSpeedTex", this._globalSpeedTex),
  25391. a.setUniform("positionTex", this._positionPrevTex),
  25392. a.setUniform("forceTex", this._forceTex),
  25393. a.setUniform("forcePrevTex", this._forcePrevTex),
  25394. a.render(e),
  25395. this._framebuffer.unbind(e),
  25396. this._swapTexture()
  25397. }
  25398. ,
  25399. jd.prototype.update = function (e, t, r) {
  25400. null == t && (t = 1),
  25401. t = Math.max(t, 1);
  25402. for (var i = 0; i < t; i++)
  25403. this.step(e);
  25404. r && r()
  25405. }
  25406. ,
  25407. jd.prototype.getNodePositionTexture = function () {
  25408. return this._inited ? this._positionPrevTex : this._positionSourceTex
  25409. }
  25410. ,
  25411. jd.prototype.getNodeUV = function (e, t) {
  25412. t = t || [];
  25413. var r = this._positionTex.width
  25414. , i = this._positionTex.height;
  25415. return t[0] = e % r / (r - 1),
  25416. t[1] = Math.floor(e / r) / (i - 1) || 0,
  25417. t
  25418. }
  25419. ,
  25420. jd.prototype.getNodePosition = function (e, t) {
  25421. var r = this._positionArr
  25422. , i = this._positionTex.width
  25423. , n = this._positionTex.height
  25424. , a = i * n;
  25425. r && r.length === 4 * a || (r = this._positionArr = new Float32Array(4 * a)),
  25426. this._framebuffer.bind(e),
  25427. this._framebuffer.attach(this._positionPrevTex),
  25428. e.gl.readPixels(0, 0, i, n, e.gl.RGBA, e.gl.FLOAT, r),
  25429. this._framebuffer.unbind(e),
  25430. t || (t = new Float32Array(2 * this._nodes.length));
  25431. for (var o = 0; o < this._nodes.length; o++)
  25432. t[2 * o] = r[4 * o],
  25433. t[2 * o + 1] = r[4 * o + 1];
  25434. return t
  25435. }
  25436. ,
  25437. jd.prototype.getTextureData = function (e, t) {
  25438. var r = this["_" + t + "Tex"]
  25439. , i = r.width
  25440. , n = r.height;
  25441. this._framebuffer.bind(e),
  25442. this._framebuffer.attach(r);
  25443. var a = new Float32Array(i * n * 4);
  25444. return e.gl.readPixels(0, 0, i, n, e.gl.RGBA, e.gl.FLOAT, a),
  25445. this._framebuffer.unbind(e),
  25446. a
  25447. }
  25448. ,
  25449. jd.prototype.getTextureSize = function () {
  25450. return {
  25451. width: this._positionTex.width,
  25452. height: this._positionTex.height
  25453. }
  25454. }
  25455. ,
  25456. jd.prototype.isFinished = function (e) {
  25457. return this._frame > e
  25458. }
  25459. ,
  25460. jd.prototype._swapTexture = function () {
  25461. var e = this._positionPrevTex;
  25462. this._positionPrevTex = this._positionTex,
  25463. this._positionTex = e,
  25464. e = this._forcePrevTex,
  25465. this._forcePrevTex = this._forceTex,
  25466. this._forceTex = e,
  25467. e = this._globalSpeedPrevTex,
  25468. this._globalSpeedPrevTex = this._globalSpeedTex,
  25469. this._globalSpeedTex = e
  25470. }
  25471. ,
  25472. jd.prototype._initFromSource = function (e) {
  25473. this._framebuffer.attach(this._positionPrevTex),
  25474. this._framebuffer.bind(e),
  25475. this._copyPass.setUniform("texture", this._positionSourceTex),
  25476. this._copyPass.render(e),
  25477. e.gl.clearColor(0, 0, 0, 0),
  25478. this._framebuffer.attach(this._forcePrevTex),
  25479. e.gl.clear(e.gl.COLOR_BUFFER_BIT),
  25480. this._framebuffer.attach(this._globalSpeedPrevTex),
  25481. e.gl.clear(e.gl.COLOR_BUFFER_BIT),
  25482. this._framebuffer.unbind(e)
  25483. }
  25484. ,
  25485. jd.prototype._resize = function (e, t) {
  25486. ["_positionSourceTex", "_positionTex", "_positionPrevTex", "_forceTex", "_forcePrevTex"].forEach((function (r) {
  25487. this[r].width = e,
  25488. this[r].height = t,
  25489. this[r].dirty()
  25490. }
  25491. ), this)
  25492. }
  25493. ,
  25494. jd.prototype.dispose = function (e) {
  25495. this._framebuffer.dispose(e),
  25496. this._copyPass.dispose(e),
  25497. this._nodeRepulsionPass.dispose(e),
  25498. this._positionPass.dispose(e),
  25499. this._globalSpeedPass.dispose(e),
  25500. this._edgeForceMesh.geometry.dispose(e),
  25501. this._weightedSumMesh.geometry.dispose(e),
  25502. this._positionSourceTex.dispose(e),
  25503. this._positionTex.dispose(e),
  25504. this._positionPrevTex.dispose(e),
  25505. this._forceTex.dispose(e),
  25506. this._forcePrevTex.dispose(e),
  25507. this._weightedSumTex.dispose(e),
  25508. this._globalSpeedTex.dispose(e),
  25509. this._globalSpeedPrevTex.dispose(e)
  25510. }
  25511. ;
  25512. const Xd = jd;
  25513. var qd = function () {
  25514. var e = function () {
  25515. return new Float32Array(2)
  25516. }
  25517. , t = function (e, t) {
  25518. var r = t[0] - e[0]
  25519. , i = t[1] - e[1];
  25520. return Math.sqrt(r * r + i * i)
  25521. }
  25522. , r = function (e) {
  25523. var t = e[0]
  25524. , r = e[1];
  25525. return Math.sqrt(t * t + r * r)
  25526. }
  25527. , i = function (e, t, r, i) {
  25528. return e[0] = t[0] + r[0] * i,
  25529. e[1] = t[1] + r[1] * i,
  25530. e
  25531. }
  25532. , n = function (e, t, r) {
  25533. return e[0] = t[0] + r[0],
  25534. e[1] = t[1] + r[1],
  25535. e
  25536. }
  25537. , a = function (e, t, r) {
  25538. return e[0] = t[0] - r[0],
  25539. e[1] = t[1] - r[1],
  25540. e
  25541. }
  25542. , o = function (e, t, r) {
  25543. return e[0] = t,
  25544. e[1] = r,
  25545. e
  25546. };
  25547. function s() {
  25548. this.subRegions = [],
  25549. this.nSubRegions = 0,
  25550. this.node = null,
  25551. this.mass = 0,
  25552. this.centerOfMass = null,
  25553. this.bbox = new Float32Array(4),
  25554. this.size = 0
  25555. }
  25556. var l = s.prototype;
  25557. function h() {
  25558. this.position = new Float32Array(2),
  25559. this.force = e(),
  25560. this.forcePrev = e(),
  25561. this.mass = 1,
  25562. this.inDegree = 0,
  25563. this.outDegree = 0
  25564. }
  25565. function u(e, t) {
  25566. this.source = e,
  25567. this.target = t,
  25568. this.weight = 1
  25569. }
  25570. function c() {
  25571. this.autoSettings = !0,
  25572. this.barnesHutOptimize = !0,
  25573. this.barnesHutTheta = 1.5,
  25574. this.repulsionByDegree = !0,
  25575. this.linLogMode = !1,
  25576. this.strongGravityMode = !1,
  25577. this.gravity = 1,
  25578. this.scaling = 1,
  25579. this.edgeWeightInfluence = 1,
  25580. this.jitterTolerence = .1,
  25581. this.preventOverlap = !1,
  25582. this.dissuadeHubs = !1,
  25583. this.rootRegion = new s,
  25584. this.rootRegion.centerOfMass = e(),
  25585. this.nodes = [],
  25586. this.edges = [],
  25587. this.bbox = new Float32Array(4),
  25588. this.gravityCenter = null,
  25589. this._massArr = null,
  25590. this._swingingArr = null,
  25591. this._sizeArr = null,
  25592. this._globalSpeed = 0
  25593. }
  25594. l.beforeUpdate = function () {
  25595. for (var e = 0; e < this.nSubRegions; e++)
  25596. this.subRegions[e].beforeUpdate();
  25597. this.mass = 0,
  25598. this.centerOfMass && (this.centerOfMass[0] = 0,
  25599. this.centerOfMass[1] = 0),
  25600. this.nSubRegions = 0,
  25601. this.node = null
  25602. }
  25603. ,
  25604. l.afterUpdate = function () {
  25605. this.subRegions.length = this.nSubRegions;
  25606. for (var e = 0; e < this.nSubRegions; e++)
  25607. this.subRegions[e].afterUpdate()
  25608. }
  25609. ,
  25610. l.addNode = function (e) {
  25611. if (0 === this.nSubRegions) {
  25612. if (null == this.node)
  25613. return void (this.node = e);
  25614. this._addNodeToSubRegion(this.node),
  25615. this.node = null
  25616. }
  25617. this._addNodeToSubRegion(e),
  25618. this._updateCenterOfMass(e)
  25619. }
  25620. ,
  25621. l.findSubRegion = function (e, t) {
  25622. for (var r = 0; r < this.nSubRegions; r++) {
  25623. var i = this.subRegions[r];
  25624. if (i.contain(e, t))
  25625. return i
  25626. }
  25627. }
  25628. ,
  25629. l.contain = function (e, t) {
  25630. return this.bbox[0] <= e && this.bbox[2] >= e && this.bbox[1] <= t && this.bbox[3] >= t
  25631. }
  25632. ,
  25633. l.setBBox = function (e, t, r, i) {
  25634. this.bbox[0] = e,
  25635. this.bbox[1] = t,
  25636. this.bbox[2] = r,
  25637. this.bbox[3] = i,
  25638. this.size = (r - e + i - t) / 2
  25639. }
  25640. ,
  25641. l._newSubRegion = function () {
  25642. var e = this.subRegions[this.nSubRegions];
  25643. return e || (e = new s,
  25644. this.subRegions[this.nSubRegions] = e),
  25645. this.nSubRegions++,
  25646. e
  25647. }
  25648. ,
  25649. l._addNodeToSubRegion = function (e) {
  25650. var t = this.findSubRegion(e.position[0], e.position[1])
  25651. , r = this.bbox;
  25652. if (!t) {
  25653. var i = (r[0] + r[2]) / 2
  25654. , n = (r[1] + r[3]) / 2
  25655. , a = (r[2] - r[0]) / 2
  25656. , o = (r[3] - r[1]) / 2
  25657. , s = e.position[0] >= i ? 1 : 0
  25658. , l = e.position[1] >= n ? 1 : 0;
  25659. (t = this._newSubRegion()).setBBox(s * a + r[0], l * o + r[1], (s + 1) * a + r[0], (l + 1) * o + r[1])
  25660. }
  25661. t.addNode(e)
  25662. }
  25663. ,
  25664. l._updateCenterOfMass = function (e) {
  25665. null == this.centerOfMass && (this.centerOfMass = new Float32Array(2));
  25666. var t = this.centerOfMass[0] * this.mass
  25667. , r = this.centerOfMass[1] * this.mass;
  25668. t += e.position[0] * e.mass,
  25669. r += e.position[1] * e.mass,
  25670. this.mass += e.mass,
  25671. this.centerOfMass[0] = t / this.mass,
  25672. this.centerOfMass[1] = r / this.mass
  25673. }
  25674. ;
  25675. var d = c.prototype;
  25676. d.initNodes = function (e, t, r) {
  25677. var i = t.length;
  25678. this.nodes.length = 0;
  25679. for (var n = void 0 !== r, a = 0; a < i; a++) {
  25680. var o = new h;
  25681. o.position[0] = e[2 * a],
  25682. o.position[1] = e[2 * a + 1],
  25683. o.mass = t[a],
  25684. n && (o.size = r[a]),
  25685. this.nodes.push(o)
  25686. }
  25687. this._massArr = t,
  25688. this._swingingArr = new Float32Array(i),
  25689. n && (this._sizeArr = r)
  25690. }
  25691. ,
  25692. d.initEdges = function (e, t) {
  25693. var r = e.length / 2;
  25694. this.edges.length = 0;
  25695. for (var i = 0; i < r; i++) {
  25696. var n = e[2 * i]
  25697. , a = e[2 * i + 1]
  25698. , o = this.nodes[n]
  25699. , s = this.nodes[a];
  25700. if (!o || !s)
  25701. return void console.error("Node not exists, try initNodes before initEdges");
  25702. o.outDegree++,
  25703. s.inDegree++;
  25704. var l = new u(o, s);
  25705. t && (l.weight = t[i]),
  25706. this.edges.push(l)
  25707. }
  25708. }
  25709. ,
  25710. d.updateSettings = function () {
  25711. if (this.repulsionByDegree)
  25712. for (var e = 0; e < this.nodes.length; e++)
  25713. (t = this.nodes[e]).mass = t.inDegree + t.outDegree + 1;
  25714. else
  25715. for (e = 0; e < this.nodes.length; e++) {
  25716. var t;
  25717. (t = this.nodes[e]).mass = this._massArr[e]
  25718. }
  25719. }
  25720. ,
  25721. d.update = function () {
  25722. var a, s, l = this.nodes.length;
  25723. if (this.updateSettings(),
  25724. this.updateBBox(),
  25725. this.barnesHutOptimize) {
  25726. this.rootRegion.setBBox(this.bbox[0], this.bbox[1], this.bbox[2], this.bbox[3]),
  25727. this.rootRegion.beforeUpdate();
  25728. for (var h = 0; h < l; h++)
  25729. this.rootRegion.addNode(this.nodes[h]);
  25730. this.rootRegion.afterUpdate()
  25731. }
  25732. for (h = 0; h < l; h++) {
  25733. var u = this.nodes[h];
  25734. a = u.forcePrev,
  25735. s = u.force,
  25736. a[0] = s[0],
  25737. a[1] = s[1],
  25738. o(u.force, 0, 0)
  25739. }
  25740. for (h = 0; h < l; h++) {
  25741. var c = this.nodes[h];
  25742. if (this.barnesHutOptimize)
  25743. this.applyRegionToNodeRepulsion(this.rootRegion, c);
  25744. else
  25745. for (var d = h + 1; d < l; d++) {
  25746. var f = this.nodes[d];
  25747. this.applyNodeToNodeRepulsion(c, f, !1)
  25748. }
  25749. this.gravity > 0 && (this.strongGravityMode ? this.applyNodeStrongGravity(c) : this.applyNodeGravity(c))
  25750. }
  25751. for (h = 0; h < this.edges.length; h++)
  25752. this.applyEdgeAttraction(this.edges[h]);
  25753. var p = 0
  25754. , m = 0
  25755. , g = e();
  25756. for (h = 0; h < l; h++)
  25757. u = this.nodes[h],
  25758. p += (v = t(u.force, u.forcePrev)) * u.mass,
  25759. n(g, u.force, u.forcePrev),
  25760. m += .5 * r(g) * u.mass,
  25761. this._swingingArr[h] = v;
  25762. var _ = this.jitterTolerence * this.jitterTolerence * m / p;
  25763. for (this._globalSpeed > 0 && (_ = Math.min(_ / this._globalSpeed, 1.5) * this._globalSpeed),
  25764. this._globalSpeed = _,
  25765. h = 0; h < l; h++) {
  25766. u = this.nodes[h];
  25767. var v = this._swingingArr[h]
  25768. , y = .1 * _ / (1 + _ * Math.sqrt(v))
  25769. , x = r(u.force);
  25770. x > 0 && (y = Math.min(x * y, 10) / x,
  25771. i(u.position, u.position, u.force, y))
  25772. }
  25773. }
  25774. ,
  25775. d.applyRegionToNodeRepulsion = function () {
  25776. var t = e();
  25777. return function (e, r) {
  25778. if (e.node)
  25779. this.applyNodeToNodeRepulsion(e.node, r, !0);
  25780. else {
  25781. a(t, r.position, e.centerOfMass);
  25782. var n = t[0] * t[0] + t[1] * t[1];
  25783. if (n > this.barnesHutTheta * e.size * e.size) {
  25784. var o = this.scaling * r.mass * e.mass / n;
  25785. i(r.force, r.force, t, o)
  25786. } else
  25787. for (var s = 0; s < e.nSubRegions; s++)
  25788. this.applyRegionToNodeRepulsion(e.subRegions[s], r)
  25789. }
  25790. }
  25791. }(),
  25792. d.applyNodeToNodeRepulsion = function () {
  25793. var t = e();
  25794. return function (e, r, n) {
  25795. if (e != r) {
  25796. a(t, e.position, r.position);
  25797. var o = t[0] * t[0] + t[1] * t[1];
  25798. if (0 !== o) {
  25799. var s;
  25800. if (this.preventOverlap) {
  25801. var l = Math.sqrt(o);
  25802. if ((l = l - e.size - r.size) > 0)
  25803. s = this.scaling * e.mass * r.mass / (l * l);
  25804. else {
  25805. if (!(l < 0))
  25806. return;
  25807. s = 100 * this.scaling * e.mass * r.mass
  25808. }
  25809. } else
  25810. s = this.scaling * e.mass * r.mass / o;
  25811. i(e.force, e.force, t, s),
  25812. i(r.force, r.force, t, -s)
  25813. }
  25814. }
  25815. }
  25816. }(),
  25817. d.applyEdgeAttraction = function () {
  25818. var t = e();
  25819. return function (e) {
  25820. var n = e.source
  25821. , o = e.target;
  25822. a(t, n.position, o.position);
  25823. var s, l, h = r(t);
  25824. s = 0 === this.edgeWeightInfluence ? 1 : 1 === this.edgeWeightInfluence ? e.weight : Math.pow(e.weight, this.edgeWeightInfluence),
  25825. this.preventOverlap && (h = h - n.size - o.size) <= 0 || (l = this.linLogMode ? -s * Math.log(h + 1) / (h + 1) : -s,
  25826. i(n.force, n.force, t, l),
  25827. i(o.force, o.force, t, -l))
  25828. }
  25829. }(),
  25830. d.applyNodeGravity = function () {
  25831. var t = e();
  25832. return function (e) {
  25833. a(t, this.gravityCenter, e.position);
  25834. var n = r(t);
  25835. i(e.force, e.force, t, this.gravity * e.mass / (n + 1))
  25836. }
  25837. }(),
  25838. d.applyNodeStrongGravity = function () {
  25839. var t = e();
  25840. return function (e) {
  25841. a(t, this.gravityCenter, e.position),
  25842. i(e.force, e.force, t, this.gravity * e.mass)
  25843. }
  25844. }(),
  25845. d.updateBBox = function () {
  25846. for (var e = 1 / 0, t = 1 / 0, r = -1 / 0, i = -1 / 0, n = 0; n < this.nodes.length; n++) {
  25847. var a = this.nodes[n].position;
  25848. e = Math.min(e, a[0]),
  25849. t = Math.min(t, a[1]),
  25850. r = Math.max(r, a[0]),
  25851. i = Math.max(i, a[1])
  25852. }
  25853. this.bbox[0] = e,
  25854. this.bbox[1] = t,
  25855. this.bbox[2] = r,
  25856. this.bbox[3] = i
  25857. }
  25858. ,
  25859. d.getGlobalSpeed = function () {
  25860. return this._globalSpeed
  25861. }
  25862. ;
  25863. var f = null;
  25864. self.onmessage = function (e) {
  25865. switch (e.data.cmd) {
  25866. case "init":
  25867. (f = new c).initNodes(e.data.nodesPosition, e.data.nodesMass, e.data.nodesSize),
  25868. f.initEdges(e.data.edges, e.data.edgesWeight);
  25869. break;
  25870. case "updateConfig":
  25871. if (f)
  25872. for (var t in e.data.config)
  25873. f[t] = e.data.config[t];
  25874. break;
  25875. case "update":
  25876. var r = e.data.steps;
  25877. if (f) {
  25878. for (var i = 0; i < r; i++)
  25879. f.update();
  25880. var n = f.nodes.length
  25881. , a = new Float32Array(2 * n);
  25882. for (i = 0; i < n; i++) {
  25883. var o = f.nodes[i];
  25884. a[2 * i] = o.position[0],
  25885. a[2 * i + 1] = o.position[1]
  25886. }
  25887. self.postMessage({
  25888. buffer: a.buffer,
  25889. globalSpeed: f.getGlobalSpeed()
  25890. }, [a.buffer])
  25891. } else {
  25892. var s = new Float32Array;
  25893. self.postMessage({
  25894. buffer: s.buffer,
  25895. globalSpeed: f.getGlobalSpeed()
  25896. }, [s.buffer])
  25897. }
  25898. }
  25899. }
  25900. }
  25901. .toString();
  25902. qd = qd.slice(qd.indexOf("{") + 1, qd.lastIndexOf("}"));
  25903. var Zd = {
  25904. barnesHutOptimize: !0,
  25905. barnesHutTheta: 1.5,
  25906. repulsionByDegree: !0,
  25907. linLogMode: !1,
  25908. strongGravityMode: !1,
  25909. gravity: 1,
  25910. scaling: 1,
  25911. edgeWeightInfluence: 1,
  25912. jitterTolerence: .1,
  25913. preventOverlap: !1,
  25914. dissuadeHubs: !1,
  25915. gravityCenter: null
  25916. }
  25917. , Yd = function (e) {
  25918. for (var t in Zd)
  25919. this[t] = Zd[t];
  25920. if (e)
  25921. for (var t in e)
  25922. this[t] = e[t];
  25923. this._nodes = [],
  25924. this._edges = [],
  25925. this._disposed = !1,
  25926. this._positionTex = new Dr({
  25927. type: wr.FLOAT,
  25928. flipY: !1,
  25929. minFilter: wr.NEAREST,
  25930. magFilter: wr.NEAREST
  25931. })
  25932. };
  25933. Yd.prototype.initData = function (e, t) {
  25934. var r = new Blob([qd])
  25935. , i = window.URL.createObjectURL(r);
  25936. this._worker = new Worker(i),
  25937. this._worker.onmessage = this._$onupdate.bind(this),
  25938. this._nodes = e,
  25939. this._edges = t,
  25940. this._frame = 0;
  25941. for (var n = e.length, a = t.length, o = new Float32Array(2 * n), s = new Float32Array(n), l = new Float32Array(n), h = new Float32Array(2 * a), u = new Float32Array(a), c = 0; c < e.length; c++) {
  25942. var d = e[c];
  25943. o[2 * c] = d.x,
  25944. o[2 * c + 1] = d.y,
  25945. s[c] = null == d.mass ? 1 : d.mass,
  25946. l[c] = null == d.size ? 1 : d.size
  25947. }
  25948. for (c = 0; c < t.length; c++) {
  25949. var f = t[c]
  25950. , p = f.node1
  25951. , m = f.node2;
  25952. h[2 * c] = p,
  25953. h[2 * c + 1] = m,
  25954. u[c] = null == f.weight ? 1 : f.weight
  25955. }
  25956. var g = Math.ceil(Math.sqrt(e.length))
  25957. , _ = g
  25958. , v = new Float32Array(g * _ * 4)
  25959. , y = this._positionTex;
  25960. y.width = g,
  25961. y.height = _,
  25962. y.pixels = v,
  25963. this._worker.postMessage({
  25964. cmd: "init",
  25965. nodesPosition: o,
  25966. nodesMass: s,
  25967. nodesSize: l,
  25968. edges: h,
  25969. edgesWeight: u
  25970. }),
  25971. this._globalSpeed = 1 / 0
  25972. }
  25973. ,
  25974. Yd.prototype.updateOption = function (e) {
  25975. var t = {};
  25976. for (var r in Zd)
  25977. t[r] = Zd[r];
  25978. var i = this._nodes
  25979. , n = this._edges
  25980. , a = i.length;
  25981. if (t.jitterTolerence = a > 5e4 ? 10 : a > 5e3 ? 1 : .1,
  25982. t.scaling = a > 100 ? 2 : 10,
  25983. t.barnesHutOptimize = a > 1e3,
  25984. e)
  25985. for (var r in Zd)
  25986. null != e[r] && (t[r] = e[r]);
  25987. if (!t.gravityCenter) {
  25988. for (var o = [1 / 0, 1 / 0], s = [-1 / 0, -1 / 0], l = 0; l < i.length; l++)
  25989. o[0] = Math.min(i[l].x, o[0]),
  25990. o[1] = Math.min(i[l].y, o[1]),
  25991. s[0] = Math.max(i[l].x, s[0]),
  25992. s[1] = Math.max(i[l].y, s[1]);
  25993. t.gravityCenter = [.5 * (o[0] + s[0]), .5 * (o[1] + s[1])]
  25994. }
  25995. for (l = 0; l < n.length; l++) {
  25996. var h = n[l].node1
  25997. , u = n[l].node2;
  25998. i[h].degree = (i[h].degree || 0) + 1,
  25999. i[u].degree = (i[u].degree || 0) + 1
  26000. }
  26001. this._worker && this._worker.postMessage({
  26002. cmd: "updateConfig",
  26003. config: t
  26004. })
  26005. }
  26006. ,
  26007. Yd.prototype.update = function (e, t, r) {
  26008. null == t && (t = 1),
  26009. t = Math.max(t, 1),
  26010. this._frame += t,
  26011. this._onupdate = r,
  26012. this._worker && this._worker.postMessage({
  26013. cmd: "update",
  26014. steps: Math.round(t)
  26015. })
  26016. }
  26017. ,
  26018. Yd.prototype._$onupdate = function (e) {
  26019. if (!this._disposed) {
  26020. var t = new Float32Array(e.data.buffer);
  26021. this._globalSpeed = e.data.globalSpeed,
  26022. this._positionArr = t,
  26023. this._updateTexture(t),
  26024. this._onupdate && this._onupdate()
  26025. }
  26026. }
  26027. ,
  26028. Yd.prototype.getNodePositionTexture = function () {
  26029. return this._positionTex
  26030. }
  26031. ,
  26032. Yd.prototype.getNodeUV = function (e, t) {
  26033. t = t || [];
  26034. var r = this._positionTex.width
  26035. , i = this._positionTex.height;
  26036. return t[0] = e % r / (r - 1),
  26037. t[1] = Math.floor(e / r) / (i - 1),
  26038. t
  26039. }
  26040. ,
  26041. Yd.prototype.getNodes = function () {
  26042. return this._nodes
  26043. }
  26044. ,
  26045. Yd.prototype.getEdges = function () {
  26046. return this._edges
  26047. }
  26048. ,
  26049. Yd.prototype.isFinished = function (e) {
  26050. return this._frame > e
  26051. }
  26052. ,
  26053. Yd.prototype.getNodePosition = function (e, t) {
  26054. if (t || (t = new Float32Array(2 * this._nodes.length)),
  26055. this._positionArr)
  26056. for (var r = 0; r < this._positionArr.length; r++)
  26057. t[r] = this._positionArr[r];
  26058. return t
  26059. }
  26060. ,
  26061. Yd.prototype._updateTexture = function (e) {
  26062. for (var t = this._positionTex.pixels, r = 0, i = 0; i < e.length;)
  26063. t[r++] = e[i++],
  26064. t[r++] = e[i++],
  26065. t[r++] = 1,
  26066. t[r++] = 1;
  26067. this._positionTex.dirty()
  26068. }
  26069. ,
  26070. Yd.prototype.dispose = function (e) {
  26071. this._disposed = !0,
  26072. this._worker = null
  26073. }
  26074. ;
  26075. const Kd = Yd
  26076. , Qd = m.extend((function () {
  26077. return {
  26078. zr: null,
  26079. viewGL: null,
  26080. minZoom: .2,
  26081. maxZoom: 5,
  26082. _needsUpdate: !1,
  26083. _dx: 0,
  26084. _dy: 0,
  26085. _zoom: 1
  26086. }
  26087. }
  26088. ), (function () {
  26089. this._mouseDownHandler = this._mouseDownHandler.bind(this),
  26090. this._mouseWheelHandler = this._mouseWheelHandler.bind(this),
  26091. this._mouseMoveHandler = this._mouseMoveHandler.bind(this),
  26092. this._mouseUpHandler = this._mouseUpHandler.bind(this),
  26093. this._update = this._update.bind(this)
  26094. }
  26095. ), {
  26096. init: function () {
  26097. var e = this.zr;
  26098. e.on("mousedown", this._mouseDownHandler),
  26099. e.on("mousewheel", this._mouseWheelHandler),
  26100. e.on("globalout", this._mouseUpHandler),
  26101. e.animation.on("frame", this._update)
  26102. },
  26103. setTarget: function (e) {
  26104. this._target = e
  26105. },
  26106. setZoom: function (e) {
  26107. this._zoom = Math.max(Math.min(e, this.maxZoom), this.minZoom),
  26108. this._needsUpdate = !0
  26109. },
  26110. setOffset: function (e) {
  26111. this._dx = e[0],
  26112. this._dy = e[1],
  26113. this._needsUpdate = !0
  26114. },
  26115. getZoom: function () {
  26116. return this._zoom
  26117. },
  26118. getOffset: function () {
  26119. return [this._dx, this._dy]
  26120. },
  26121. _update: function () {
  26122. if (this._target && this._needsUpdate) {
  26123. var e = this._target
  26124. , t = this._zoom;
  26125. e.position.x = this._dx,
  26126. e.position.y = this._dy,
  26127. e.scale.set(t, t, t),
  26128. this.zr.refresh(),
  26129. this._needsUpdate = !1,
  26130. this.trigger("update")
  26131. }
  26132. },
  26133. _mouseDownHandler: function (e) {
  26134. if (!e.target) {
  26135. var t = e.offsetX
  26136. , r = e.offsetY;
  26137. if (!this.viewGL || this.viewGL.containPoint(t, r)) {
  26138. this.zr.on("mousemove", this._mouseMoveHandler),
  26139. this.zr.on("mouseup", this._mouseUpHandler);
  26140. var i = this._convertPos(t, r);
  26141. this._x = i.x,
  26142. this._y = i.y
  26143. }
  26144. }
  26145. },
  26146. _convertPos: function (e, t) {
  26147. var r = this.viewGL.camera
  26148. , i = this.viewGL.viewport;
  26149. return {
  26150. x: (e - i.x) / i.width * (r.right - r.left) + r.left,
  26151. y: (t - i.y) / i.height * (r.bottom - r.top) + r.top
  26152. }
  26153. },
  26154. _mouseMoveHandler: function (e) {
  26155. var t = this._convertPos(e.offsetX, e.offsetY);
  26156. this._dx += t.x - this._x,
  26157. this._dy += t.y - this._y,
  26158. this._x = t.x,
  26159. this._y = t.y,
  26160. this._needsUpdate = !0
  26161. },
  26162. _mouseUpHandler: function (e) {
  26163. this.zr.off("mousemove", this._mouseMoveHandler),
  26164. this.zr.off("mouseup", this._mouseUpHandler)
  26165. },
  26166. _mouseWheelHandler: function (e) {
  26167. var t = (e = e.event).wheelDelta || -e.detail;
  26168. if (0 !== t) {
  26169. var r = e.offsetX
  26170. , i = e.offsetY;
  26171. if (!this.viewGL || this.viewGL.containPoint(r, i)) {
  26172. var n = t > 0 ? 1.1 : .9
  26173. , a = Math.max(Math.min(this._zoom * n, this.maxZoom), this.minZoom);
  26174. n = a / this._zoom;
  26175. var o = this._convertPos(r, i)
  26176. , s = (o.x - this._dx) * (n - 1)
  26177. , l = (o.y - this._dy) * (n - 1);
  26178. this._dx -= s,
  26179. this._dy -= l,
  26180. this._zoom = a,
  26181. this._needsUpdate = !0
  26182. }
  26183. }
  26184. },
  26185. dispose: function () {
  26186. var e = this.zr;
  26187. e.off("mousedown", this._mouseDownHandler),
  26188. e.off("mousemove", this._mouseMoveHandler),
  26189. e.off("mouseup", this._mouseUpHandler),
  26190. e.off("mousewheel", this._mouseWheelHandler),
  26191. e.off("globalout", this._mouseUpHandler),
  26192. e.animation.off("frame", this._update)
  26193. }
  26194. });
  26195. var Jd = Po.vec2;
  26196. Ka.Shader.import("@export ecgl.lines2D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.vertex\n\nattribute vec2 position: POSITION;\nattribute vec2 normal;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n vec4 p2 = worldViewProjection * vec4(position + normal, -10.0, 1.0);\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n p2.xy /= p2.w;\n gl_Position.xy /= gl_Position.w;\n\n vec2 N = normalize(p2.xy - gl_Position.xy);\n gl_Position.xy += N * offset / viewport.zw * 2.0;\n\n gl_Position.xy *= gl_Position.w;\n\n v_Color = a_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n\n@end");
  26197. var $d = 1;
  26198. const ef = i.ChartView.extend({
  26199. type: "graphGL",
  26200. __ecgl__: !0,
  26201. init: function (e, t) {
  26202. this.groupGL = new Ka.Node,
  26203. this.viewGL = new Il("orthographic"),
  26204. this.viewGL.camera.left = this.viewGL.camera.right = 0,
  26205. this.viewGL.add(this.groupGL),
  26206. this._pointsBuilder = new Fc(!0, t),
  26207. this._forceEdgesMesh = new Ka.Mesh({
  26208. material: new Ka.Material({
  26209. shader: Ka.createShader("ecgl.forceAtlas2.edges"),
  26210. transparent: !0,
  26211. depthMask: !1,
  26212. depthTest: !1
  26213. }),
  26214. $ignorePicking: !0,
  26215. geometry: new Ka.Geometry({
  26216. attributes: {
  26217. node: new Ka.Geometry.Attribute("node", "float", 2),
  26218. color: new Ka.Geometry.Attribute("color", "float", 4, "COLOR")
  26219. },
  26220. dynamic: !0,
  26221. mainAttribute: "node"
  26222. }),
  26223. renderOrder: -1,
  26224. mode: Ka.Mesh.LINES
  26225. }),
  26226. this._edgesMesh = new Ka.Mesh({
  26227. material: new Ka.Material({
  26228. shader: Ka.createShader("ecgl.meshLines2D"),
  26229. transparent: !0,
  26230. depthMask: !1,
  26231. depthTest: !1
  26232. }),
  26233. $ignorePicking: !0,
  26234. geometry: new Hd({
  26235. useNativeLine: !1,
  26236. dynamic: !0
  26237. }),
  26238. renderOrder: -1,
  26239. culling: !1
  26240. }),
  26241. this._layoutId = 0,
  26242. this._control = new Qd({
  26243. zr: t.getZr(),
  26244. viewGL: this.viewGL
  26245. }),
  26246. this._control.setTarget(this.groupGL),
  26247. this._control.init(),
  26248. this._clickHandler = this._clickHandler.bind(this)
  26249. },
  26250. render: function (e, t, r) {
  26251. this.groupGL.add(this._pointsBuilder.rootNode),
  26252. this._model = e,
  26253. this._api = r,
  26254. this._initLayout(e, t, r),
  26255. this._pointsBuilder.update(e, t, r),
  26256. this._forceLayoutInstance instanceof Xd || this.groupGL.remove(this._forceEdgesMesh),
  26257. this._updateCamera(e, r),
  26258. this._control.off("update"),
  26259. this._control.on("update", (function () {
  26260. r.dispatchAction({
  26261. type: "graphGLRoam",
  26262. seriesId: e.id,
  26263. zoom: this._control.getZoom(),
  26264. offset: this._control.getOffset()
  26265. }),
  26266. this._pointsBuilder.updateView(this.viewGL.camera)
  26267. }
  26268. ), this),
  26269. this._control.setZoom(Mn(e.get("zoom"), 1)),
  26270. this._control.setOffset(e.get("offset") || [0, 0]);
  26271. var i = this._pointsBuilder.getPointsMesh();
  26272. if (i.off("mousemove", this._mousemoveHandler),
  26273. i.off("mouseout", this._mouseOutHandler, this),
  26274. r.getZr().off("click", this._clickHandler),
  26275. this._pointsBuilder.highlightOnMouseover = !0,
  26276. e.get("focusNodeAdjacency")) {
  26277. var n = e.get("focusNodeAdjacencyOn");
  26278. "click" === n ? r.getZr().on("click", this._clickHandler) : "mouseover" === n && (i.on("mousemove", this._mousemoveHandler, this),
  26279. i.on("mouseout", this._mouseOutHandler, this),
  26280. this._pointsBuilder.highlightOnMouseover = !1)
  26281. }
  26282. this._lastMouseOverDataIndex = -1
  26283. },
  26284. _clickHandler: function (e) {
  26285. if (!this._layouting) {
  26286. var t = this._pointsBuilder.getPointsMesh().dataIndex;
  26287. t >= 0 ? this._api.dispatchAction({
  26288. type: "graphGLFocusNodeAdjacency",
  26289. seriesId: this._model.id,
  26290. dataIndex: t
  26291. }) : this._api.dispatchAction({
  26292. type: "graphGLUnfocusNodeAdjacency",
  26293. seriesId: this._model.id
  26294. })
  26295. }
  26296. },
  26297. _mousemoveHandler: function (e) {
  26298. if (!this._layouting) {
  26299. var t = this._pointsBuilder.getPointsMesh().dataIndex;
  26300. t >= 0 ? t !== this._lastMouseOverDataIndex && this._api.dispatchAction({
  26301. type: "graphGLFocusNodeAdjacency",
  26302. seriesId: this._model.id,
  26303. dataIndex: t
  26304. }) : this._mouseOutHandler(e),
  26305. this._lastMouseOverDataIndex = t
  26306. }
  26307. },
  26308. _mouseOutHandler: function (e) {
  26309. this._layouting || (this._api.dispatchAction({
  26310. type: "graphGLUnfocusNodeAdjacency",
  26311. seriesId: this._model.id
  26312. }),
  26313. this._lastMouseOverDataIndex = -1)
  26314. },
  26315. _updateForceEdgesGeometry: function (e, t) {
  26316. var r = this._forceEdgesMesh.geometry
  26317. , i = t.getEdgeData()
  26318. , n = 0
  26319. , a = this._forceLayoutInstance
  26320. , o = 2 * i.count();
  26321. r.attributes.node.init(o),
  26322. r.attributes.color.init(o),
  26323. i.each((function (t) {
  26324. var o = e[t];
  26325. r.attributes.node.set(n, a.getNodeUV(o.node1)),
  26326. r.attributes.node.set(n + 1, a.getNodeUV(o.node2));
  26327. var s = Ih(i, o.dataIndex)
  26328. , l = Ka.parseColor(s);
  26329. l[3] *= Mn(Rh(i, o.dataIndex), 1),
  26330. r.attributes.color.set(n, l),
  26331. r.attributes.color.set(n + 1, l),
  26332. n += 2
  26333. }
  26334. )),
  26335. r.dirty()
  26336. },
  26337. _updateMeshLinesGeometry: function () {
  26338. var e = this._model.getEdgeData()
  26339. , t = this._edgesMesh.geometry
  26340. , r = (e = this._model.getEdgeData(),
  26341. this._model.getData().getLayout("points"));
  26342. t.resetOffset(),
  26343. t.setVertexCount(e.count() * t.getLineVertexCount()),
  26344. t.setTriangleCount(e.count() * t.getLineTriangleCount());
  26345. var i = []
  26346. , n = []
  26347. , a = ["lineStyle", "width"];
  26348. this._originalEdgeColors = new Float32Array(4 * e.count()),
  26349. this._edgeIndicesMap = new Float32Array(e.count()),
  26350. e.each((function (o) {
  26351. var s = e.graph.getEdgeByIndex(o)
  26352. , l = 2 * s.node1.dataIndex
  26353. , h = 2 * s.node2.dataIndex;
  26354. i[0] = r[l],
  26355. i[1] = r[l + 1],
  26356. n[0] = r[h],
  26357. n[1] = r[h + 1];
  26358. var u = Ih(e, s.dataIndex)
  26359. , c = Ka.parseColor(u);
  26360. c[3] *= Mn(Rh(e, s.dataIndex), 1);
  26361. var d = e.getItemModel(s.dataIndex)
  26362. , f = Mn(d.get(a), 1) * this._api.getDevicePixelRatio();
  26363. t.addLine(i, n, c, f);
  26364. for (var p = 0; p < 4; p++)
  26365. this._originalEdgeColors[4 * s.dataIndex + p] = c[p];
  26366. this._edgeIndicesMap[s.dataIndex] = o
  26367. }
  26368. ), this),
  26369. t.dirty()
  26370. },
  26371. _updateForceNodesGeometry: function (e) {
  26372. for (var t = this._pointsBuilder.getPointsMesh(), r = [], i = 0; i < e.count(); i++)
  26373. this._forceLayoutInstance.getNodeUV(i, r),
  26374. t.geometry.attributes.position.set(i, r);
  26375. t.geometry.dirty("position")
  26376. },
  26377. _initLayout: function (e, t, r) {
  26378. var n = e.get("layout")
  26379. , a = e.getGraph()
  26380. , o = Ss(e.getBoxLayoutParams(), {
  26381. width: r.getWidth(),
  26382. height: r.getHeight()
  26383. });
  26384. "force" === n && (n = "forceAtlas2"),
  26385. this.stopLayout(e, t, r, {
  26386. beforeLayout: !0
  26387. });
  26388. var s = e.getData()
  26389. , l = e.getData();
  26390. if ("forceAtlas2" === n) {
  26391. var h = e.getModel("forceAtlas2")
  26392. , u = this._forceLayoutInstance
  26393. , c = []
  26394. , d = []
  26395. , f = s.getDataExtent("value")
  26396. , p = l.getDataExtent("value")
  26397. , m = Mn(h.get("edgeWeight"), 1)
  26398. , g = Mn(h.get("nodeWeight"), 1);
  26399. "number" == typeof m && (m = [m, m]),
  26400. "number" == typeof g && (g = [g, g]);
  26401. var _ = 0
  26402. , v = {}
  26403. , y = new Float32Array(2 * s.count());
  26404. if (a.eachNode((function (e) {
  26405. var t, r, n = e.dataIndex, a = s.get("value", n);
  26406. if (s.hasItemOption) {
  26407. var l = s.getItemModel(n);
  26408. t = l.get("x"),
  26409. r = l.get("y")
  26410. }
  26411. null == t && (t = o.x + Math.random() * o.width,
  26412. r = o.y + Math.random() * o.height),
  26413. y[2 * _] = t,
  26414. y[2 * _ + 1] = r,
  26415. v[e.id] = _++;
  26416. var h = i.number.linearMap(a, f, g);
  26417. isNaN(h) && (h = isNaN(g[0]) ? 1 : g[0]),
  26418. c.push({
  26419. x: t,
  26420. y: r,
  26421. mass: h,
  26422. size: s.getItemVisual(n, "symbolSize")
  26423. })
  26424. }
  26425. )),
  26426. s.setLayout("points", y),
  26427. a.eachEdge((function (e) {
  26428. var t = e.dataIndex
  26429. , r = s.get("value", t)
  26430. , n = i.number.linearMap(r, p, m);
  26431. isNaN(n) && (n = isNaN(m[0]) ? 1 : m[0]),
  26432. d.push({
  26433. node1: v[e.node1.id],
  26434. node2: v[e.node2.id],
  26435. weight: n,
  26436. dataIndex: t
  26437. })
  26438. }
  26439. )),
  26440. !u) {
  26441. var x = h.get("GPU");
  26442. this._forceLayoutInstance && ((!x || this._forceLayoutInstance instanceof Xd) && (x || this._forceLayoutInstance instanceof Kd) || (this._forceLayoutInstanceToDispose = this._forceLayoutInstance)),
  26443. u = this._forceLayoutInstance = x ? new Xd : new Kd
  26444. }
  26445. u.initData(c, d),
  26446. u.updateOption(h.option),
  26447. this._updateForceEdgesGeometry(u.getEdges(), e),
  26448. this._updatePositionTexture(),
  26449. r.dispatchAction({
  26450. type: "graphGLStartLayout",
  26451. from: this.uid
  26452. })
  26453. } else
  26454. y = new Float32Array(2 * s.count()),
  26455. _ = 0,
  26456. a.eachNode((function (e) {
  26457. var t, r, i = e.dataIndex;
  26458. if (s.hasItemOption) {
  26459. var n = s.getItemModel(i);
  26460. t = n.get("x"),
  26461. r = n.get("y")
  26462. }
  26463. y[_++] = t,
  26464. y[_++] = r
  26465. }
  26466. )),
  26467. s.setLayout("points", y),
  26468. this._updateAfterLayout(e, t, r)
  26469. },
  26470. _updatePositionTexture: function () {
  26471. var e = this._forceLayoutInstance.getNodePositionTexture();
  26472. this._pointsBuilder.setPositionTexture(e),
  26473. this._forceEdgesMesh.material.set("positionTex", e)
  26474. },
  26475. startLayout: function (e, t, r, i) {
  26476. if (!i || null == i.from || i.from === this.uid) {
  26477. var n = this.viewGL
  26478. , a = (r = this._api,
  26479. this._forceLayoutInstance)
  26480. , o = this._model.getData()
  26481. , s = this._model.getModel("forceAtlas2");
  26482. if (a && (this.groupGL.remove(this._edgesMesh),
  26483. this.groupGL.add(this._forceEdgesMesh),
  26484. this._forceLayoutInstance)) {
  26485. this._updateForceNodesGeometry(e.getData()),
  26486. this._pointsBuilder.hideLabels();
  26487. var l = this
  26488. , h = this._layoutId = $d++
  26489. , u = s.getShallow("maxSteps")
  26490. , c = s.getShallow("steps")
  26491. , d = 0
  26492. , f = Math.max(2 * c, 20)
  26493. , p = function (t) {
  26494. if (t === l._layoutId)
  26495. return a.isFinished(u) ? (r.dispatchAction({
  26496. type: "graphGLStopLayout",
  26497. from: l.uid
  26498. }),
  26499. void r.dispatchAction({
  26500. type: "graphGLFinishLayout",
  26501. points: o.getLayout("points"),
  26502. from: l.uid
  26503. })) : void a.update(n.layer.renderer, c, (function () {
  26504. l._updatePositionTexture(),
  26505. (d += c) >= f && (l._syncNodePosition(e),
  26506. d = 0),
  26507. r.getZr().refresh(),
  26508. Qa((function () {
  26509. p(t)
  26510. }
  26511. ))
  26512. }
  26513. ))
  26514. };
  26515. Qa((function () {
  26516. l._forceLayoutInstanceToDispose && (l._forceLayoutInstanceToDispose.dispose(n.layer.renderer),
  26517. l._forceLayoutInstanceToDispose = null),
  26518. p(h)
  26519. }
  26520. )),
  26521. this._layouting = !0
  26522. }
  26523. }
  26524. },
  26525. stopLayout: function (e, t, r, i) {
  26526. i && null != i.from && i.from !== this.uid || (this._layoutId = 0,
  26527. this.groupGL.remove(this._forceEdgesMesh),
  26528. this.groupGL.add(this._edgesMesh),
  26529. this._forceLayoutInstance && this.viewGL.layer && (i && i.beforeLayout || (this._syncNodePosition(e),
  26530. this._updateAfterLayout(e, t, r)),
  26531. this._api.getZr().refresh(),
  26532. this._layouting = !1))
  26533. },
  26534. _syncNodePosition: function (e) {
  26535. var t = this._forceLayoutInstance.getNodePosition(this.viewGL.layer.renderer);
  26536. e.getData().setLayout("points", t),
  26537. e.setNodePosition(t)
  26538. },
  26539. _updateAfterLayout: function (e, t, r) {
  26540. this._updateMeshLinesGeometry(),
  26541. this._pointsBuilder.removePositionTexture(),
  26542. this._pointsBuilder.updateLayout(e, t, r),
  26543. this._pointsBuilder.updateView(this.viewGL.camera),
  26544. this._pointsBuilder.updateLabels(),
  26545. this._pointsBuilder.showLabels()
  26546. },
  26547. focusNodeAdjacency: function (e, t, r, i) {
  26548. var n = this._model.getData();
  26549. this._downplayAll();
  26550. var a = i.dataIndex
  26551. , o = n.graph
  26552. , s = []
  26553. , l = o.getNodeByIndex(a);
  26554. s.push(l),
  26555. l.edges.forEach((function (e) {
  26556. e.dataIndex < 0 || (e.node1 !== l && s.push(e.node1),
  26557. e.node2 !== l && s.push(e.node2))
  26558. }
  26559. ), this),
  26560. this._pointsBuilder.fadeOutAll(.05),
  26561. this._fadeOutEdgesAll(.05),
  26562. s.forEach((function (e) {
  26563. this._pointsBuilder.highlight(n, e.dataIndex)
  26564. }
  26565. ), this),
  26566. this._pointsBuilder.updateLabels(s.map((function (e) {
  26567. return e.dataIndex
  26568. }
  26569. )));
  26570. var h = [];
  26571. l.edges.forEach((function (e) {
  26572. e.dataIndex >= 0 && (this._highlightEdge(e.dataIndex),
  26573. h.push(e))
  26574. }
  26575. ), this),
  26576. this._focusNodes = s,
  26577. this._focusEdges = h
  26578. },
  26579. unfocusNodeAdjacency: function (e, t, r, i) {
  26580. this._downplayAll(),
  26581. this._pointsBuilder.fadeInAll(),
  26582. this._fadeInEdgesAll(),
  26583. this._pointsBuilder.updateLabels()
  26584. },
  26585. _highlightEdge: function (e) {
  26586. var t = this._model.getEdgeData().getItemModel(e)
  26587. , r = Ka.parseColor(t.get("emphasis.lineStyle.color") || t.get("lineStyle.color"))
  26588. , i = Mn(t.get("emphasis.lineStyle.opacity"), t.get("lineStyle.opacity"), 1);
  26589. r[3] *= i,
  26590. this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e], r)
  26591. },
  26592. _downplayAll: function () {
  26593. this._focusNodes && this._focusNodes.forEach((function (e) {
  26594. this._pointsBuilder.downplay(this._model.getData(), e.dataIndex)
  26595. }
  26596. ), this),
  26597. this._focusEdges && this._focusEdges.forEach((function (e) {
  26598. this._downplayEdge(e.dataIndex)
  26599. }
  26600. ), this)
  26601. },
  26602. _downplayEdge: function (e) {
  26603. var t = this._getColor(e, []);
  26604. this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e], t)
  26605. },
  26606. _setEdgeFade: (tf = [],
  26607. function (e, t) {
  26608. this._getColor(e, tf),
  26609. tf[3] *= t,
  26610. this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e], tf)
  26611. }
  26612. ),
  26613. _getColor: function (e, t) {
  26614. for (var r = 0; r < 4; r++)
  26615. t[r] = this._originalEdgeColors[4 * e + r];
  26616. return t
  26617. },
  26618. _fadeOutEdgesAll: function (e) {
  26619. this._model.getData().graph.eachEdge((function (t) {
  26620. this._setEdgeFade(t.dataIndex, e)
  26621. }
  26622. ), this)
  26623. },
  26624. _fadeInEdgesAll: function () {
  26625. this._fadeOutEdgesAll(1)
  26626. },
  26627. _updateCamera: function (e, t) {
  26628. this.viewGL.setViewport(0, 0, t.getWidth(), t.getHeight(), t.getDevicePixelRatio());
  26629. for (var r = this.viewGL.camera, i = e.getData().getLayout("points"), n = Jd.create(1 / 0, 1 / 0), a = Jd.create(-1 / 0, -1 / 0), o = [], s = 0; s < i.length;)
  26630. o[0] = i[s++],
  26631. o[1] = i[s++],
  26632. Jd.min(n, n, o),
  26633. Jd.max(a, a, o);
  26634. var l = (a[1] + n[1]) / 2
  26635. , h = (a[0] + n[0]) / 2;
  26636. if (!(h > r.left && h < r.right && l < r.bottom && l > r.top)) {
  26637. var u = Math.max(a[0] - n[0], 10)
  26638. , c = u / t.getWidth() * t.getHeight();
  26639. u *= 1.4,
  26640. c *= 1.4,
  26641. n[0] -= .2 * u,
  26642. r.left = n[0],
  26643. r.top = l - c / 2,
  26644. r.bottom = l + c / 2,
  26645. r.right = u + n[0],
  26646. r.near = 0,
  26647. r.far = 100
  26648. }
  26649. },
  26650. dispose: function () {
  26651. var e = this.viewGL.layer.renderer;
  26652. this._forceLayoutInstance && this._forceLayoutInstance.dispose(e),
  26653. this.groupGL.removeAll(),
  26654. this._layoutId = -1,
  26655. this._pointsBuilder.dispose()
  26656. },
  26657. remove: function () {
  26658. this.groupGL.removeAll(),
  26659. this._control.dispose()
  26660. }
  26661. });
  26662. var tf;
  26663. function rf(e) {
  26664. return e instanceof Array || (e = [e, e]),
  26665. e
  26666. }
  26667. (0,
  26668. i.use)((function (e) {
  26669. function t() { }
  26670. e.registerChartView(ef),
  26671. e.registerSeriesModel(Gd),
  26672. e.registerVisual((function (e) {
  26673. const t = {};
  26674. e.eachSeriesByType("graphGL", (function (e) {
  26675. var r = e.getCategoriesData()
  26676. , n = e.getData()
  26677. , a = {};
  26678. r.each((function (i) {
  26679. var n = r.getName(i);
  26680. a["ec-" + n] = i;
  26681. var o = r.getItemModel(i)
  26682. , s = o.getModel("itemStyle").getItemStyle();
  26683. s.fill || (s.fill = e.getColorFromPalette(n, t)),
  26684. r.setItemVisual(i, "style", s);
  26685. var l = ["symbol", "symbolSize", "symbolKeepAspect"];
  26686. for (let e = 0; e < l.length; e++) {
  26687. var h = o.getShallow(l[e], !0);
  26688. null != h && r.setItemVisual(i, l[e], h)
  26689. }
  26690. }
  26691. )),
  26692. r.count() && n.each((function (e) {
  26693. let t = n.getItemModel(e).getShallow("category");
  26694. if (null != t) {
  26695. "string" == typeof t && (t = a["ec-" + t]);
  26696. var o = r.getItemVisual(t, "style")
  26697. , s = n.ensureUniqueItemVisual(e, "style");
  26698. i.util.extend(s, o);
  26699. var l = ["symbol", "symbolSize", "symbolKeepAspect"];
  26700. for (let i = 0; i < l.length; i++)
  26701. n.setItemVisual(e, l[i], r.getItemVisual(t, l[i]))
  26702. }
  26703. }
  26704. ))
  26705. }
  26706. ))
  26707. }
  26708. )),
  26709. e.registerVisual((function (e) {
  26710. e.eachSeriesByType("graphGL", (function (e) {
  26711. var t = e.getGraph()
  26712. , r = e.getEdgeData()
  26713. , n = rf(e.get("edgeSymbol"))
  26714. , a = rf(e.get("edgeSymbolSize"));
  26715. r.setVisual("drawType", "stroke"),
  26716. r.setVisual("fromSymbol", n && n[0]),
  26717. r.setVisual("toSymbol", n && n[1]),
  26718. r.setVisual("fromSymbolSize", a && a[0]),
  26719. r.setVisual("toSymbolSize", a && a[1]),
  26720. r.setVisual("style", e.getModel("lineStyle").getLineStyle()),
  26721. r.each((function (e) {
  26722. var n = r.getItemModel(e)
  26723. , a = t.getEdgeByIndex(e)
  26724. , o = rf(n.getShallow("symbol", !0))
  26725. , s = rf(n.getShallow("symbolSize", !0))
  26726. , l = n.getModel("lineStyle").getLineStyle()
  26727. , h = r.ensureUniqueItemVisual(e, "style");
  26728. switch (i.util.extend(h, l),
  26729. h.stroke) {
  26730. case "source":
  26731. var u = a.node1.getVisual("style");
  26732. h.stroke = u && u.fill;
  26733. break;
  26734. case "target":
  26735. u = a.node2.getVisual("style"),
  26736. h.stroke = u && u.fill
  26737. }
  26738. o[0] && a.setVisual("fromSymbol", o[0]),
  26739. o[1] && a.setVisual("toSymbol", o[1]),
  26740. s[0] && a.setVisual("fromSymbolSize", s[0]),
  26741. s[1] && a.setVisual("toSymbolSize", s[1])
  26742. }
  26743. ))
  26744. }
  26745. ))
  26746. }
  26747. )),
  26748. e.registerAction({
  26749. type: "graphGLRoam",
  26750. event: "graphglroam",
  26751. update: "series.graphGL:roam"
  26752. }, (function (e, t) {
  26753. t.eachComponent({
  26754. mainType: "series",
  26755. query: e
  26756. }, (function (t) {
  26757. t.setView(e)
  26758. }
  26759. ))
  26760. }
  26761. )),
  26762. e.registerAction({
  26763. type: "graphGLStartLayout",
  26764. event: "graphgllayoutstarted",
  26765. update: "series.graphGL:startLayout"
  26766. }, t),
  26767. e.registerAction({
  26768. type: "graphGLStopLayout",
  26769. event: "graphgllayoutstopped",
  26770. update: "series.graphGL:stopLayout"
  26771. }, t),
  26772. e.registerAction({
  26773. type: "graphGLFocusNodeAdjacency",
  26774. event: "graphGLFocusNodeAdjacency",
  26775. update: "series.graphGL:focusNodeAdjacency"
  26776. }, t),
  26777. e.registerAction({
  26778. type: "graphGLUnfocusNodeAdjacency",
  26779. event: "graphGLUnfocusNodeAdjacency",
  26780. update: "series.graphGL:unfocusNodeAdjacency"
  26781. }, t)
  26782. }
  26783. ));
  26784. const nf = i.SeriesModel.extend({
  26785. type: "series.flowGL",
  26786. dependencies: ["geo", "grid", "bmap"],
  26787. visualStyleAccessPath: "itemStyle",
  26788. getInitialData: function (e, t) {
  26789. var r = this.get("coordinateSystem")
  26790. , n = "geo" === r ? ["lng", "lat"] : i.getCoordinateSystemDimensions(r) || ["x", "y"];
  26791. n.push("vx", "vy");
  26792. var a = i.helper.createDimensions(this.getSource(), {
  26793. coordDimensions: n,
  26794. encodeDefine: this.get("encode"),
  26795. dimensionsDefine: this.get("dimensions")
  26796. })
  26797. , o = new i.List(a, this);
  26798. return o.initData(this.getSource()),
  26799. o
  26800. },
  26801. defaultOption: {
  26802. coordinateSystem: "cartesian2d",
  26803. zlevel: 10,
  26804. supersampling: 1,
  26805. particleType: "point",
  26806. particleDensity: 128,
  26807. particleSize: 1,
  26808. particleSpeed: 1,
  26809. particleTrail: 2,
  26810. colorTexture: null,
  26811. gridWidth: "auto",
  26812. gridHeight: "auto",
  26813. itemStyle: {
  26814. color: "#fff",
  26815. opacity: .8
  26816. }
  26817. }
  26818. })
  26819. , af = Vr.extend((function () {
  26820. return {
  26821. dynamic: !0,
  26822. attributes: {
  26823. position: new Vr.Attribute("position", "float", 3, "POSITION")
  26824. }
  26825. }
  26826. }
  26827. ), {
  26828. resetOffset: function () {
  26829. this._vertexOffset = 0,
  26830. this._faceOffset = 0
  26831. },
  26832. setLineCount: function (e) {
  26833. var t = this.attributes
  26834. , r = 4 * e
  26835. , i = 2 * e;
  26836. this.vertexCount !== r && t.position.init(r),
  26837. this.triangleCount !== i && (this.indices = 0 === i ? null : this.vertexCount > 65535 ? new Uint32Array(3 * i) : new Uint16Array(3 * i))
  26838. },
  26839. addLine: function (e) {
  26840. var t = this._vertexOffset;
  26841. this.attributes.position.set(t, [e[0], e[1], 1]),
  26842. this.attributes.position.set(t + 1, [e[0], e[1], -1]),
  26843. this.attributes.position.set(t + 2, [e[0], e[1], 2]),
  26844. this.attributes.position.set(t + 3, [e[0], e[1], -2]),
  26845. this.setTriangleIndices(this._faceOffset++, [t, t + 1, t + 2]),
  26846. this.setTriangleIndices(this._faceOffset++, [t + 1, t + 2, t + 3]),
  26847. this._vertexOffset += 4
  26848. }
  26849. });
  26850. Xe.import("@export ecgl.vfParticle.particle.fragment\n\nuniform sampler2D particleTexture;\nuniform sampler2D spawnTexture;\nuniform sampler2D velocityTexture;\n\nuniform float deltaTime;\nuniform float elapsedTime;\n\nuniform float speedScaling : 1.0;\n\nuniform vec2 textureSize;\nuniform vec4 region : [0, 0, 1, 1];\nuniform float firstFrameTime;\n\nvarying vec2 v_Texcoord;\n\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, v_Texcoord);\n bool spawn = false;\n if (p.w <= 0.0) {\n p = texture2D(spawnTexture, fract(v_Texcoord + elapsedTime / 10.0));\n p.w -= firstFrameTime;\n spawn = true;\n }\n vec2 v = texture2D(velocityTexture, fract(p.xy * region.zw + region.xy)).xy;\n v = (v - 0.5) * 2.0;\n p.z = length(v);\n p.xy += v * deltaTime / 10.0 * speedScaling;\n p.w -= deltaTime;\n\n if (spawn || p.xy != fract(p.xy)) {\n p.z = 0.0;\n }\n p.xy = fract(p.xy);\n\n gl_FragColor = p;\n}\n@end\n\n@export ecgl.vfParticle.renderPoints.vertex\n\n#define PI 3.1415926\n\nattribute vec2 texcoord : TEXCOORD_0;\n\nuniform sampler2D particleTexture;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nuniform float size : 1.0;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, texcoord);\n\n if (p.w > 0.0 && p.z > 1e-5) {\n gl_Position = worldViewProjection * vec4(p.xy * 2.0 - 1.0, 0.0, 1.0);\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n\n v_Mag = p.z;\n v_Uv = p.xy;\n\n gl_PointSize = size;\n}\n\n@end\n\n@export ecgl.vfParticle.renderPoints.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\nuniform sampler2D spriteTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n#ifdef SPRITETEXTURE_ENABLED\n gl_FragColor *= texture2D(spriteTexture, gl_PointCoord);\n if (color.a == 0.0) {\n discard;\n }\n#endif\n#ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.vertex\n\n#define PI 3.1415926\n\nattribute vec3 position : POSITION;\n\nuniform sampler2D particleTexture;\nuniform sampler2D prevParticleTexture;\n\nuniform float size : 1.0;\nuniform vec4 vp: VIEWPORT;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\n@import clay.util.rand\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, position.xy);\n vec4 p2 = texture2D(prevParticleTexture, position.xy);\n\n p.xy = p.xy * 2.0 - 1.0;\n p2.xy = p2.xy * 2.0 - 1.0;\n\n if (p.w > 0.0 && p.z > 1e-5) {\n vec2 dir = normalize(p.xy - p2.xy);\n vec2 norm = vec2(dir.y / vp.z, -dir.x / vp.w) * sign(position.z) * size;\n if (abs(position.z) == 2.0) {\n gl_Position = vec4(p.xy + norm, 0.0, 1.0);\n v_Uv = p.xy;\n v_Mag = p.z;\n }\n else {\n gl_Position = vec4(p2.xy + norm, 0.0, 1.0);\n v_Mag = p2.z;\n v_Uv = p2.xy;\n }\n gl_Position = worldViewProjection * gl_Position;\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n #ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n");
  26851. var of = function () {
  26852. this.motionBlurFactor = .99,
  26853. this.vectorFieldTexture = new Dr({
  26854. type: wr.FLOAT,
  26855. flipY: !1
  26856. }),
  26857. this.particleLife = [5, 20],
  26858. this._particleType = "point",
  26859. this._particleSize = 1,
  26860. this.particleColor = [1, 1, 1, 1],
  26861. this.particleSpeedScaling = 1,
  26862. this._thisFrameTexture = null,
  26863. this._particlePass = null,
  26864. this._spawnTexture = null,
  26865. this._particleTexture0 = null,
  26866. this._particleTexture1 = null,
  26867. this._particlePointsMesh = null,
  26868. this._surfaceFrameBuffer = null,
  26869. this._elapsedTime = 0,
  26870. this._scene = null,
  26871. this._camera = null,
  26872. this._lastFrameTexture = null,
  26873. this._supersampling = 1,
  26874. this._downsampleTextures = [],
  26875. this._width = 512,
  26876. this._height = 512,
  26877. this.init()
  26878. };
  26879. of.prototype = {
  26880. constructor: of,
  26881. init: function () {
  26882. var e = {
  26883. type: wr.FLOAT,
  26884. minFilter: wr.NEAREST,
  26885. magFilter: wr.NEAREST,
  26886. useMipmap: !1
  26887. };
  26888. this._spawnTexture = new Dr(e),
  26889. this._particleTexture0 = new Dr(e),
  26890. this._particleTexture1 = new Dr(e),
  26891. this._frameBuffer = new zi({
  26892. depthBuffer: !1
  26893. }),
  26894. this._particlePass = new pn({
  26895. fragment: Xe.source("ecgl.vfParticle.particle.fragment")
  26896. }),
  26897. this._particlePass.setUniform("velocityTexture", this.vectorFieldTexture),
  26898. this._particlePass.setUniform("spawnTexture", this._spawnTexture),
  26899. this._downsamplePass = new pn({
  26900. fragment: Xe.source("clay.compositor.downsample")
  26901. });
  26902. var t = new Sr({
  26903. renderOrder: 10,
  26904. material: new le({
  26905. shader: new Xe(Xe.source("ecgl.vfParticle.renderPoints.vertex"), Xe.source("ecgl.vfParticle.renderPoints.fragment"))
  26906. }),
  26907. mode: Sr.POINTS,
  26908. geometry: new Vr({
  26909. dynamic: !0,
  26910. mainAttribute: "texcoord0"
  26911. })
  26912. })
  26913. , r = new Sr({
  26914. renderOrder: 10,
  26915. material: new le({
  26916. shader: new Xe(Xe.source("ecgl.vfParticle.renderLines.vertex"), Xe.source("ecgl.vfParticle.renderLines.fragment"))
  26917. }),
  26918. geometry: new af,
  26919. culling: !1
  26920. })
  26921. , i = new Sr({
  26922. material: new le({
  26923. shader: new Xe(Xe.source("ecgl.color.vertex"), Xe.source("ecgl.color.fragment"))
  26924. }),
  26925. geometry: new ki
  26926. });
  26927. i.material.enableTexture("diffuseMap"),
  26928. this._particlePointsMesh = t,
  26929. this._particleLinesMesh = r,
  26930. this._lastFrameFullQuadMesh = i,
  26931. this._camera = new un,
  26932. this._thisFrameTexture = new Dr,
  26933. this._lastFrameTexture = new Dr
  26934. },
  26935. setParticleDensity: function (e, t) {
  26936. for (var r = new Float32Array(e * t * 4), i = 0, n = this.particleLife, a = 0; a < e; a++)
  26937. for (var o = 0; o < t; o++,
  26938. i++) {
  26939. r[4 * i] = Math.random(),
  26940. r[4 * i + 1] = Math.random(),
  26941. r[4 * i + 2] = Math.random();
  26942. var s = (n[1] - n[0]) * Math.random() + n[0];
  26943. r[4 * i + 3] = s
  26944. }
  26945. "line" === this._particleType ? this._setLineGeometry(e, t) : this._setPointsGeometry(e, t),
  26946. this._spawnTexture.width = e,
  26947. this._spawnTexture.height = t,
  26948. this._spawnTexture.pixels = r,
  26949. this._particleTexture0.width = this._particleTexture1.width = e,
  26950. this._particleTexture0.height = this._particleTexture1.height = t,
  26951. this._particlePass.setUniform("textureSize", [e, t])
  26952. },
  26953. _setPointsGeometry: function (e, t) {
  26954. var r = e * t
  26955. , i = this._particlePointsMesh.geometry
  26956. , n = i.attributes;
  26957. n.texcoord0.init(r);
  26958. for (var a = 0, o = 0; o < e; o++)
  26959. for (var s = 0; s < t; s++,
  26960. a++)
  26961. n.texcoord0.value[2 * a] = o / e,
  26962. n.texcoord0.value[2 * a + 1] = s / t;
  26963. i.dirty()
  26964. },
  26965. _setLineGeometry: function (e, t) {
  26966. var r = e * t
  26967. , i = this._getParticleMesh().geometry;
  26968. i.setLineCount(r),
  26969. i.resetOffset();
  26970. for (var n = 0; n < e; n++)
  26971. for (var a = 0; a < t; a++)
  26972. i.addLine([n / e, a / t]);
  26973. i.dirty()
  26974. },
  26975. _getParticleMesh: function () {
  26976. return "line" === this._particleType ? this._particleLinesMesh : this._particlePointsMesh
  26977. },
  26978. update: function (e, t, r, i) {
  26979. var n = this._getParticleMesh()
  26980. , a = this._frameBuffer
  26981. , o = this._particlePass;
  26982. i && this._updateDownsampleTextures(e, t),
  26983. n.material.set("size", this._particleSize * this._supersampling),
  26984. n.material.set("color", this.particleColor),
  26985. o.setUniform("speedScaling", this.particleSpeedScaling),
  26986. a.attach(this._particleTexture1),
  26987. o.setUniform("firstFrameTime", i ? (this.particleLife[1] + this.particleLife[0]) / 2 : 0),
  26988. o.setUniform("particleTexture", this._particleTexture0),
  26989. o.setUniform("deltaTime", r),
  26990. o.setUniform("elapsedTime", this._elapsedTime),
  26991. o.render(e, a),
  26992. n.material.set("particleTexture", this._particleTexture1),
  26993. n.material.set("prevParticleTexture", this._particleTexture0),
  26994. a.attach(this._thisFrameTexture),
  26995. a.bind(e),
  26996. e.gl.clear(e.gl.DEPTH_BUFFER_BIT | e.gl.COLOR_BUFFER_BIT);
  26997. var s = this._lastFrameFullQuadMesh;
  26998. s.material.set("diffuseMap", this._lastFrameTexture),
  26999. s.material.set("color", [1, 1, 1, this.motionBlurFactor]),
  27000. this._camera.update(!0),
  27001. e.renderPass([s, n], this._camera),
  27002. a.unbind(e),
  27003. this._downsample(e),
  27004. this._swapTexture(),
  27005. this._elapsedTime += r
  27006. },
  27007. _downsample: function (e) {
  27008. var t = this._downsampleTextures;
  27009. if (0 !== t.length)
  27010. for (var r = 0, i = this._thisFrameTexture, n = t[r]; n;)
  27011. this._frameBuffer.attach(n),
  27012. this._downsamplePass.setUniform("texture", i),
  27013. this._downsamplePass.setUniform("textureSize", [i.width, i.height]),
  27014. this._downsamplePass.render(e, this._frameBuffer),
  27015. i = n,
  27016. n = t[++r]
  27017. },
  27018. getSurfaceTexture: function () {
  27019. var e = this._downsampleTextures;
  27020. return e.length > 0 ? e[e.length - 1] : this._lastFrameTexture
  27021. },
  27022. setRegion: function (e) {
  27023. this._particlePass.setUniform("region", e)
  27024. },
  27025. resize: function (e, t) {
  27026. this._lastFrameTexture.width = e * this._supersampling,
  27027. this._lastFrameTexture.height = t * this._supersampling,
  27028. this._thisFrameTexture.width = e * this._supersampling,
  27029. this._thisFrameTexture.height = t * this._supersampling,
  27030. this._width = e,
  27031. this._height = t
  27032. },
  27033. setParticleSize: function (e) {
  27034. var t = this._getParticleMesh();
  27035. if (e <= 2)
  27036. return t.material.disableTexture("spriteTexture"),
  27037. void (t.material.transparent = !1);
  27038. this._spriteTexture || (this._spriteTexture = new Dr),
  27039. this._spriteTexture.image && this._spriteTexture.image.width === e || (this._spriteTexture.image = function (e) {
  27040. var t = document.createElement("canvas");
  27041. t.width = t.height = e;
  27042. var r = t.getContext("2d");
  27043. return r.fillStyle = "#fff",
  27044. r.arc(e / 2, e / 2, e / 2, 0, 2 * Math.PI),
  27045. r.fill(),
  27046. t
  27047. }(e),
  27048. this._spriteTexture.dirty()),
  27049. t.material.transparent = !0,
  27050. t.material.enableTexture("spriteTexture"),
  27051. t.material.set("spriteTexture", this._spriteTexture),
  27052. this._particleSize = e
  27053. },
  27054. setGradientTexture: function (e) {
  27055. var t = this._getParticleMesh().material;
  27056. t[e ? "enableTexture" : "disableTexture"]("gradientTexture"),
  27057. t.setUniform("gradientTexture", e)
  27058. },
  27059. setColorTextureImage: function (e, t) {
  27060. this._getParticleMesh().material.setTextureImage("colorTexture", e, t, {
  27061. flipY: !0
  27062. })
  27063. },
  27064. setParticleType: function (e) {
  27065. this._particleType = e
  27066. },
  27067. clearFrame: function (e) {
  27068. var t = this._frameBuffer;
  27069. t.attach(this._lastFrameTexture),
  27070. t.bind(e),
  27071. e.gl.clear(e.gl.DEPTH_BUFFER_BIT | e.gl.COLOR_BUFFER_BIT),
  27072. t.unbind(e)
  27073. },
  27074. setSupersampling: function (e) {
  27075. this._supersampling = e,
  27076. this.resize(this._width, this._height)
  27077. },
  27078. _updateDownsampleTextures: function (e, t) {
  27079. for (var r = this._downsampleTextures, i = Math.max(Math.floor(Math.log(this._supersampling / t.getDevicePixelRatio()) / Math.log(2)), 0), n = 2, a = this._width * this._supersampling, o = this._height * this._supersampling, s = 0; s < i; s++)
  27080. r[s] = r[s] || new Dr,
  27081. r[s].width = a / n,
  27082. r[s].height = o / n,
  27083. n *= 2;
  27084. for (; s < r.length; s++)
  27085. r[s].dispose(e);
  27086. r.length = i
  27087. },
  27088. _swapTexture: function () {
  27089. var e = this._particleTexture0;
  27090. this._particleTexture0 = this._particleTexture1,
  27091. this._particleTexture1 = e,
  27092. e = this._thisFrameTexture,
  27093. this._thisFrameTexture = this._lastFrameTexture,
  27094. this._lastFrameTexture = e
  27095. },
  27096. dispose: function (e) {
  27097. e.disposeFrameBuffer(this._frameBuffer),
  27098. e.disposeTexture(this.vectorFieldTexture),
  27099. e.disposeTexture(this._spawnTexture),
  27100. e.disposeTexture(this._particleTexture0),
  27101. e.disposeTexture(this._particleTexture1),
  27102. e.disposeTexture(this._thisFrameTexture),
  27103. e.disposeTexture(this._lastFrameTexture),
  27104. e.disposeGeometry(this._particleLinesMesh.geometry),
  27105. e.disposeGeometry(this._particlePointsMesh.geometry),
  27106. e.disposeGeometry(this._lastFrameFullQuadMesh.geometry),
  27107. this._spriteTexture && e.disposeTexture(this._spriteTexture),
  27108. this._particlePass.dispose(e),
  27109. this._downsamplePass.dispose(e),
  27110. this._downsampleTextures.forEach((function (t) {
  27111. t.dispose(e)
  27112. }
  27113. ))
  27114. }
  27115. };
  27116. const sf = of
  27117. , lf = i.ChartView.extend({
  27118. type: "flowGL",
  27119. __ecgl__: !0,
  27120. init: function (e, t) {
  27121. this.viewGL = new Il("orthographic"),
  27122. this.groupGL = new Ka.Node,
  27123. this.viewGL.add(this.groupGL),
  27124. this._particleSurface = new sf;
  27125. var r = new Ka.Mesh({
  27126. geometry: new Ka.PlaneGeometry,
  27127. material: new Ka.Material({
  27128. shader: new Ka.Shader({
  27129. vertex: Ka.Shader.source("ecgl.color.vertex"),
  27130. fragment: Ka.Shader.source("ecgl.color.fragment")
  27131. }),
  27132. transparent: !0
  27133. })
  27134. });
  27135. r.material.enableTexture("diffuseMap"),
  27136. this.groupGL.add(r),
  27137. this._planeMesh = r
  27138. },
  27139. render: function (e, t, r) {
  27140. var i = this._particleSurface;
  27141. i.setParticleType(e.get("particleType")),
  27142. i.setSupersampling(e.get("supersampling")),
  27143. this._updateData(e, r),
  27144. this._updateCamera(r.getWidth(), r.getHeight(), r.getDevicePixelRatio());
  27145. var n = Mn(e.get("particleDensity"), 128);
  27146. i.setParticleDensity(n, n);
  27147. var a = this._planeMesh
  27148. , o = +new Date
  27149. , s = this
  27150. , l = !0;
  27151. a.__percent = 0,
  27152. a.stopAnimation(),
  27153. a.animate("", {
  27154. loop: !0
  27155. }).when(1e5, {
  27156. __percent: 1
  27157. }).during((function () {
  27158. var e = +new Date
  27159. , t = Math.min(e - o, 20);
  27160. o += t,
  27161. s._renderer && (i.update(s._renderer, r, t / 1e3, l),
  27162. a.material.set("diffuseMap", i.getSurfaceTexture())),
  27163. l = !1
  27164. }
  27165. )).start();
  27166. var h = e.getModel("itemStyle")
  27167. , u = Ka.parseColor(h.get("color"));
  27168. u[3] *= Mn(h.get("opacity"), 1),
  27169. a.material.set("color", u),
  27170. i.setColorTextureImage(e.get("colorTexture"), r),
  27171. i.setParticleSize(e.get("particleSize")),
  27172. i.particleSpeedScaling = e.get("particleSpeed"),
  27173. i.motionBlurFactor = 1 - Math.pow(.1, e.get("particleTrail"))
  27174. },
  27175. updateTransform: function (e, t, r) {
  27176. this._updateData(e, r)
  27177. },
  27178. afterRender: function (e, t, r, i) {
  27179. var n = i.renderer;
  27180. this._renderer = n
  27181. },
  27182. _updateData: function (e, t) {
  27183. var r = e.coordinateSystem
  27184. , i = r.dimensions.map((function (t) {
  27185. return e.coordDimToDataDim(t)[0]
  27186. }
  27187. ))
  27188. , n = e.getData()
  27189. , a = n.getDataExtent(i[0])
  27190. , o = n.getDataExtent(i[1])
  27191. , s = e.get("gridWidth")
  27192. , l = e.get("gridHeight");
  27193. if (null == s || "auto" === s) {
  27194. var h = (a[1] - a[0]) / (o[1] - o[0]);
  27195. s = Math.round(Math.sqrt(h * n.count()))
  27196. }
  27197. null != l && "auto" !== l || (l = Math.ceil(n.count() / s));
  27198. var u = this._particleSurface.vectorFieldTexture
  27199. , c = u.pixels;
  27200. if (c && c.length === l * s * 4)
  27201. for (var d = 0; d < c.length; d++)
  27202. c[d] = 0;
  27203. else
  27204. c = u.pixels = new Float32Array(s * l * 4);
  27205. var f = 0
  27206. , p = 1 / 0
  27207. , m = new Float32Array(2 * n.count())
  27208. , g = 0
  27209. , _ = [[1 / 0, 1 / 0], [-1 / 0, -1 / 0]];
  27210. n.each([i[0], i[1], "vx", "vy"], (function (e, t, i, n) {
  27211. var a = r.dataToPoint([e, t]);
  27212. m[g++] = a[0],
  27213. m[g++] = a[1],
  27214. _[0][0] = Math.min(a[0], _[0][0]),
  27215. _[0][1] = Math.min(a[1], _[0][1]),
  27216. _[1][0] = Math.max(a[0], _[1][0]),
  27217. _[1][1] = Math.max(a[1], _[1][1]);
  27218. var o = Math.sqrt(i * i + n * n);
  27219. f = Math.max(f, o),
  27220. p = Math.min(p, o)
  27221. }
  27222. )),
  27223. n.each(["vx", "vy"], (function (e, t, r) {
  27224. var i = Math.round((m[2 * r] - _[0][0]) / (_[1][0] - _[0][0]) * (s - 1))
  27225. , n = 4 * ((l - 1 - Math.round((m[2 * r + 1] - _[0][1]) / (_[1][1] - _[0][1]) * (l - 1))) * s + i);
  27226. c[n] = e / f * .5 + .5,
  27227. c[n + 1] = t / f * .5 + .5,
  27228. c[n + 3] = 1
  27229. }
  27230. )),
  27231. u.width = s,
  27232. u.height = l,
  27233. "bmap" === e.get("coordinateSystem") && this._fillEmptyPixels(u),
  27234. u.dirty(),
  27235. this._updatePlanePosition(_[0], _[1], e, t),
  27236. this._updateGradientTexture(n.getVisual("visualMeta"), [p, f])
  27237. },
  27238. _fillEmptyPixels: function (e) {
  27239. var t = e.pixels
  27240. , r = e.width
  27241. , i = e.height;
  27242. function n(e, n, a) {
  27243. e = Math.max(Math.min(e, r - 1), 0);
  27244. var o = 4 * ((n = Math.max(Math.min(n, i - 1), 0)) * (r - 1) + e);
  27245. return 0 !== t[o + 3] && (a[0] = t[o],
  27246. a[1] = t[o + 1],
  27247. !0)
  27248. }
  27249. function a(e, t, r) {
  27250. r[0] = e[0] + t[0],
  27251. r[1] = e[1] + t[1]
  27252. }
  27253. for (var o = [], s = [], l = [], h = [], u = [], c = 0, d = 0; d < i; d++)
  27254. for (var f = 0; f < r; f++) {
  27255. var p = 4 * (d * (r - 1) + f);
  27256. 0 === t[p + 3] && (c = o[0] = o[1] = 0,
  27257. n(f - 1, d, s) && (c++,
  27258. a(s, o, o)),
  27259. n(f + 1, d, l) && (c++,
  27260. a(l, o, o)),
  27261. n(f, d - 1, h) && (c++,
  27262. a(h, o, o)),
  27263. n(f, d + 1, u) && (c++,
  27264. a(u, o, o)),
  27265. o[0] /= c,
  27266. o[1] /= c,
  27267. t[p] = o[0],
  27268. t[p + 1] = o[1]),
  27269. t[p + 3] = 1
  27270. }
  27271. },
  27272. _updateGradientTexture: function (e, t) {
  27273. if (e && e.length) {
  27274. this._gradientTexture = this._gradientTexture || new Ka.Texture2D({
  27275. image: document.createElement("canvas")
  27276. });
  27277. var r = this._gradientTexture
  27278. , i = r.image;
  27279. i.width = 200,
  27280. i.height = 1;
  27281. var n = i.getContext("2d")
  27282. , a = n.createLinearGradient(0, .5, i.width, .5);
  27283. e[0].stops.forEach((function (e) {
  27284. var r;
  27285. t[1] === t[0] ? r = 0 : (r = e.value / t[1],
  27286. r = Math.min(Math.max(r, 0), 1)),
  27287. a.addColorStop(r, e.color)
  27288. }
  27289. )),
  27290. n.fillStyle = a,
  27291. n.fillRect(0, 0, i.width, i.height),
  27292. r.dirty(),
  27293. this._particleSurface.setGradientTexture(this._gradientTexture)
  27294. } else
  27295. this._particleSurface.setGradientTexture(null)
  27296. },
  27297. _updatePlanePosition: function (e, t, r, i) {
  27298. var n = this._limitInViewportAndFullFill(e, t, r, i);
  27299. e = n.leftTop,
  27300. t = n.rightBottom,
  27301. this._particleSurface.setRegion(n.region),
  27302. this._planeMesh.position.set((e[0] + t[0]) / 2, i.getHeight() - (e[1] + t[1]) / 2, 0);
  27303. var a = t[0] - e[0]
  27304. , o = t[1] - e[1];
  27305. this._planeMesh.scale.set(a / 2, o / 2, 1),
  27306. this._particleSurface.resize(Math.max(Math.min(a, 2048), 1), Math.max(Math.min(o, 2048), 1)),
  27307. this._renderer && this._particleSurface.clearFrame(this._renderer)
  27308. },
  27309. _limitInViewportAndFullFill: function (e, t, r, i) {
  27310. var n = [Math.max(e[0], 0), Math.max(e[1], 0)]
  27311. , a = [Math.min(t[0], i.getWidth()), Math.min(t[1], i.getHeight())];
  27312. if ("bmap" === r.get("coordinateSystem")) {
  27313. var o = r.getData().getDataExtent(r.coordDimToDataDim("lng")[0]);
  27314. Math.floor(o[1] - o[0]) >= 359 && (n[0] > 0 && (n[0] = 0),
  27315. a[0] < i.getWidth() && (a[0] = i.getWidth()))
  27316. }
  27317. var s = t[0] - e[0]
  27318. , l = t[1] - e[1]
  27319. , h = a[0] - n[0]
  27320. , u = a[1] - n[1];
  27321. return {
  27322. leftTop: n,
  27323. rightBottom: a,
  27324. region: [(n[0] - e[0]) / s, 1 - u / l - (n[1] - e[1]) / l, h / s, u / l]
  27325. }
  27326. },
  27327. _updateCamera: function (e, t, r) {
  27328. this.viewGL.setViewport(0, 0, e, t, r);
  27329. var i = this.viewGL.camera;
  27330. i.left = i.bottom = 0,
  27331. i.top = t,
  27332. i.right = e,
  27333. i.near = 0,
  27334. i.far = 100,
  27335. i.position.z = 10
  27336. },
  27337. remove: function () {
  27338. this._planeMesh.stopAnimation(),
  27339. this.groupGL.removeAll()
  27340. },
  27341. dispose: function () {
  27342. this._renderer && this._particleSurface.dispose(this._renderer),
  27343. this.groupGL.removeAll()
  27344. }
  27345. });
  27346. (0,
  27347. i.use)((function (e) {
  27348. e.registerChartView(lf),
  27349. e.registerSeriesModel(nf)
  27350. }
  27351. ));
  27352. var hf = i.SeriesModel.extend({
  27353. type: "series.linesGL",
  27354. dependencies: ["grid", "geo"],
  27355. visualStyleAccessPath: "lineStyle",
  27356. visualDrawType: "stroke",
  27357. streamEnabled: !0,
  27358. init: function (e) {
  27359. var t = this._processFlatCoordsArray(e.data);
  27360. this._flatCoords = t.flatCoords,
  27361. this._flatCoordsOffset = t.flatCoordsOffset,
  27362. t.flatCoords && (e.data = new Float32Array(t.count)),
  27363. hf.superApply(this, "init", arguments)
  27364. },
  27365. mergeOption: function (e) {
  27366. var t = this._processFlatCoordsArray(e.data);
  27367. this._flatCoords = t.flatCoords,
  27368. this._flatCoordsOffset = t.flatCoordsOffset,
  27369. t.flatCoords && (e.data = new Float32Array(t.count)),
  27370. hf.superApply(this, "mergeOption", arguments)
  27371. },
  27372. appendData: function (e) {
  27373. var t = this._processFlatCoordsArray(e.data);
  27374. t.flatCoords && (this._flatCoords ? (this._flatCoords = Aa(this._flatCoords, t.flatCoords),
  27375. this._flatCoordsOffset = Aa(this._flatCoordsOffset, t.flatCoordsOffset)) : (this._flatCoords = t.flatCoords,
  27376. this._flatCoordsOffset = t.flatCoordsOffset),
  27377. e.data = new Float32Array(t.count)),
  27378. this.getRawData().appendData(e.data)
  27379. },
  27380. _getCoordsFromItemModel: function (e) {
  27381. var t = this.getData().getItemModel(e);
  27382. return t.option instanceof Array ? t.option : t.getShallow("coords")
  27383. },
  27384. getLineCoordsCount: function (e) {
  27385. return this._flatCoordsOffset ? this._flatCoordsOffset[2 * e + 1] : this._getCoordsFromItemModel(e).length
  27386. },
  27387. getLineCoords: function (e, t) {
  27388. if (this._flatCoordsOffset) {
  27389. for (var r = this._flatCoordsOffset[2 * e], i = this._flatCoordsOffset[2 * e + 1], n = 0; n < i; n++)
  27390. t[n] = t[n] || [],
  27391. t[n][0] = this._flatCoords[r + 2 * n],
  27392. t[n][1] = this._flatCoords[r + 2 * n + 1];
  27393. return i
  27394. }
  27395. var a = this._getCoordsFromItemModel(e);
  27396. for (n = 0; n < a.length; n++)
  27397. t[n] = t[n] || [],
  27398. t[n][0] = a[n][0],
  27399. t[n][1] = a[n][1];
  27400. return a.length
  27401. },
  27402. _processFlatCoordsArray: function (e) {
  27403. var t = 0;
  27404. if (this._flatCoords && (t = this._flatCoords.length),
  27405. "number" == typeof e[0]) {
  27406. for (var r = e.length, i = new Uint32Array(r), n = new Float64Array(r), a = 0, o = 0, s = 0, l = 0; l < r;) {
  27407. s++;
  27408. var h = e[l++];
  27409. i[o++] = a + t,
  27410. i[o++] = h;
  27411. for (var u = 0; u < h; u++) {
  27412. var c = e[l++]
  27413. , d = e[l++];
  27414. n[a++] = c,
  27415. n[a++] = d
  27416. }
  27417. }
  27418. return {
  27419. flatCoordsOffset: new Uint32Array(i.buffer, 0, o),
  27420. flatCoords: n,
  27421. count: s
  27422. }
  27423. }
  27424. return {
  27425. flatCoordsOffset: null,
  27426. flatCoords: null,
  27427. count: e.length
  27428. }
  27429. },
  27430. getInitialData: function (e, t) {
  27431. var r = new i.List(["value"], this);
  27432. return r.hasItemOption = !1,
  27433. r.initData(e.data, [], (function (e, t, i, n) {
  27434. if (e instanceof Array)
  27435. return NaN;
  27436. r.hasItemOption = !0;
  27437. var a = e.value;
  27438. return null != a ? a instanceof Array ? a[n] : a : void 0
  27439. }
  27440. )),
  27441. r
  27442. },
  27443. defaultOption: {
  27444. coordinateSystem: "geo",
  27445. zlevel: 10,
  27446. progressive: 1e4,
  27447. progressiveThreshold: 5e4,
  27448. blendMode: "source-over",
  27449. lineStyle: {
  27450. opacity: .8
  27451. },
  27452. postEffect: {
  27453. enable: !1,
  27454. colorCorrection: {
  27455. exposure: 0,
  27456. brightness: 0,
  27457. contrast: 1,
  27458. saturation: 1,
  27459. enable: !0
  27460. }
  27461. }
  27462. }
  27463. });
  27464. const uf = hf
  27465. , cf = i.ChartView.extend({
  27466. type: "linesGL",
  27467. __ecgl__: !0,
  27468. init: function (e, t) {
  27469. this.groupGL = new Ka.Node,
  27470. this.viewGL = new Il("orthographic"),
  27471. this.viewGL.add(this.groupGL),
  27472. this._glViewHelper = new wd(this.viewGL),
  27473. this._nativeLinesShader = Ka.createShader("ecgl.lines3D"),
  27474. this._meshLinesShader = Ka.createShader("ecgl.meshLines3D"),
  27475. this._linesMeshes = [],
  27476. this._currentStep = 0
  27477. },
  27478. render: function (e, t, r) {
  27479. this.groupGL.removeAll(),
  27480. this._glViewHelper.reset(e, r);
  27481. var i = this._linesMeshes[0];
  27482. i || (i = this._linesMeshes[0] = this._createLinesMesh(e)),
  27483. this._linesMeshes.length = 1,
  27484. this.groupGL.add(i),
  27485. this._updateLinesMesh(e, i, 0, e.getData().count()),
  27486. this.viewGL.setPostEffect(e.getModel("postEffect"), r)
  27487. },
  27488. incrementalPrepareRender: function (e, t, r) {
  27489. this.groupGL.removeAll(),
  27490. this._glViewHelper.reset(e, r),
  27491. this._currentStep = 0,
  27492. this.viewGL.setPostEffect(e.getModel("postEffect"), r)
  27493. },
  27494. incrementalRender: function (e, t, r, i) {
  27495. var n = this._linesMeshes[this._currentStep];
  27496. n || (n = this._createLinesMesh(t),
  27497. this._linesMeshes[this._currentStep] = n),
  27498. this._updateLinesMesh(t, n, e.start, e.end),
  27499. this.groupGL.add(n),
  27500. i.getZr().refresh(),
  27501. this._currentStep++
  27502. },
  27503. updateTransform: function (e, t, r) {
  27504. e.coordinateSystem.getRoamTransform && this._glViewHelper.updateTransform(e, r)
  27505. },
  27506. _createLinesMesh: function (e) {
  27507. return new Ka.Mesh({
  27508. $ignorePicking: !0,
  27509. material: new Ka.Material({
  27510. shader: Ka.createShader("ecgl.lines3D"),
  27511. transparent: !0,
  27512. depthMask: !1,
  27513. depthTest: !1
  27514. }),
  27515. geometry: new Hd({
  27516. segmentScale: 10,
  27517. useNativeLine: !0,
  27518. dynamic: !1
  27519. }),
  27520. mode: Ka.Mesh.LINES,
  27521. culling: !1
  27522. })
  27523. },
  27524. _updateLinesMesh: function (e, t, r, i) {
  27525. var n = e.getData();
  27526. t.material.blend = "lighter" === e.get("blendMode") ? Ka.additiveBlend : null;
  27527. var a = e.get("lineStyle.curveness") || 0
  27528. , o = e.get("polyline")
  27529. , s = t.geometry
  27530. , l = e.coordinateSystem
  27531. , h = Mn(e.get("lineStyle.width"), 1);
  27532. h > 1 ? (t.material.shader !== this._meshLinesShader && t.material.attachShader(this._meshLinesShader),
  27533. t.mode = Ka.Mesh.TRIANGLES) : (t.material.shader !== this._nativeLinesShader && t.material.attachShader(this._nativeLinesShader),
  27534. t.mode = Ka.Mesh.LINES),
  27535. r = r || 0,
  27536. i = i || n.count(),
  27537. s.resetOffset();
  27538. var u = 0
  27539. , c = 0
  27540. , d = []
  27541. , f = []
  27542. , p = []
  27543. , m = []
  27544. , g = []
  27545. , _ = .3
  27546. , v = .7;
  27547. function y() {
  27548. f[0] = d[0] * v + m[0] * _ - (d[1] - m[1]) * a,
  27549. f[1] = d[1] * v + m[1] * _ - (m[0] - d[0]) * a,
  27550. p[0] = d[0] * _ + m[0] * v - (d[1] - m[1]) * a,
  27551. p[1] = d[1] * _ + m[1] * v - (m[0] - d[0]) * a
  27552. }
  27553. if (o || 0 !== a)
  27554. for (var x = r; x < i; x++)
  27555. if (o) {
  27556. var b = e.getLineCoordsCount(x);
  27557. u += s.getPolylineVertexCount(b),
  27558. c += s.getPolylineTriangleCount(b)
  27559. } else
  27560. e.getLineCoords(x, g),
  27561. this._glViewHelper.dataToPoint(l, g[0], d),
  27562. this._glViewHelper.dataToPoint(l, g[1], m),
  27563. y(),
  27564. u += s.getCubicCurveVertexCount(d, f, p, m),
  27565. c += s.getCubicCurveTriangleCount(d, f, p, m);
  27566. else {
  27567. var w = i - r;
  27568. u += w * s.getLineVertexCount(),
  27569. c += w * s.getLineVertexCount()
  27570. }
  27571. s.setVertexCount(u),
  27572. s.setTriangleCount(c);
  27573. var T = r
  27574. , S = [];
  27575. for (x = r; x < i; x++) {
  27576. Ka.parseColor(Ih(n, T), S);
  27577. var M = Mn(Rh(n, T), 1);
  27578. S[3] *= M,
  27579. b = e.getLineCoords(x, g);
  27580. for (var A = 0; A < b; A++)
  27581. this._glViewHelper.dataToPoint(l, g[A], g[A]);
  27582. o ? s.addPolyline(g, S, h, 0, b) : 0 !== a ? (d = g[0],
  27583. m = g[1],
  27584. y(),
  27585. s.addCubicCurve(d, f, p, m, S, h)) : s.addPolyline(g, S, h, 0, 2),
  27586. T++
  27587. }
  27588. },
  27589. dispose: function () {
  27590. this.groupGL.removeAll()
  27591. },
  27592. remove: function () {
  27593. this.groupGL.removeAll()
  27594. }
  27595. });
  27596. (0,
  27597. i.use)((function (e) {
  27598. e.registerChartView(cf),
  27599. e.registerSeriesModel(uf)
  27600. }
  27601. ))
  27602. }
  27603. ,
  27604. 83: t => {
  27605. t.exports = e
  27606. }
  27607. }
  27608. , r = {};
  27609. function i(e) {
  27610. if (r[e])
  27611. return r[e].exports;
  27612. var n = r[e] = {
  27613. exports: {}
  27614. };
  27615. return t[e](n, n.exports, i),
  27616. n.exports
  27617. }
  27618. return i.g = function () {
  27619. if ("object" == typeof globalThis)
  27620. return globalThis;
  27621. try {
  27622. return this || new Function("return this")()
  27623. } catch (e) {
  27624. if ("object" == typeof window)
  27625. return window
  27626. }
  27627. }(),
  27628. i.r = e => {
  27629. "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, {
  27630. value: "Module"
  27631. }),
  27632. Object.defineProperty(e, "__esModule", {
  27633. value: !0
  27634. })
  27635. }
  27636. ,
  27637. i(468)
  27638. }
  27639. )()
  27640. }
  27641. ));